Skip to content
Permalink
Browse files

Only allocate WallColumnDrawerArgs once per thread

  • Loading branch information
dpjudas committed Nov 23, 2019
1 parent c75233a commit 8abbd63427c38a1ae28832ab29c1af24c92da982
@@ -225,7 +225,11 @@ namespace swrenderer

void DrawWallCommand::Execute(DrawerThread* thread)
{
WallColumnDrawerArgs drawerargs(wallargs);
if (!thread->columndrawer)
thread->columndrawer = std::make_shared<WallColumnDrawerArgs>();

WallColumnDrawerArgs& drawerargs = *thread->columndrawer.get();
drawerargs.wallargs = &wallargs;

bool fixed = wallargs.fixedlight;

@@ -17,8 +17,6 @@ namespace swrenderer
class WallColumnDrawerArgs
{
public:
WallColumnDrawerArgs(const WallDrawerArgs& wallargs) : wallargs(wallargs) { }

void SetDest(int x, int y)
{
dc_dest = Viewport()->GetDest(x, y);
@@ -43,10 +41,10 @@ namespace swrenderer
int DestY() const { return dc_dest_y; }
int Count() const { return dc_count; }

uint32_t* SrcBlend() const { return wallargs.SrcBlend(); }
uint32_t* DestBlend() const { return wallargs.DestBlend(); }
fixed_t SrcAlpha() const { return wallargs.SrcAlpha(); }
fixed_t DestAlpha() const { return wallargs.DestAlpha(); }
uint32_t* SrcBlend() const { return wallargs->SrcBlend(); }
uint32_t* DestBlend() const { return wallargs->DestBlend(); }
fixed_t SrcAlpha() const { return wallargs->SrcAlpha(); }
fixed_t DestAlpha() const { return wallargs->DestAlpha(); }

uint32_t TextureUPos() const { return dc_texturefracx; }
fixed_t TextureVPos() const { return dc_texturefrac; }
@@ -65,11 +63,11 @@ namespace swrenderer
DrawerLight dc_lights[MAX_DRAWER_LIGHTS];
int dc_num_lights = 0;

RenderViewport* Viewport() const { return wallargs.Viewport(); }
RenderViewport* Viewport() const { return wallargs->Viewport(); }

uint8_t* Colormap(RenderViewport* viewport) const
{
auto basecolormap = wallargs.BaseColormap();
auto basecolormap = wallargs->BaseColormap();
if (basecolormap)
{
if (viewport->RenderTarget->IsBgra())
@@ -79,20 +77,20 @@ namespace swrenderer
}
else
{
return wallargs.TranslationMap();
return wallargs->TranslationMap();
}
}

uint8_t* TranslationMap() const { return wallargs.TranslationMap(); }
uint8_t* TranslationMap() const { return wallargs->TranslationMap(); }

ShadeConstants ColormapConstants() const { return wallargs.ColormapConstants(); }
ShadeConstants ColormapConstants() const { return wallargs->ColormapConstants(); }
fixed_t Light() const { return LIGHTSCALE(mLight, mShade); }

FLightNode* LightList() const { return wallargs.lightlist; }
FLightNode* LightList() const { return wallargs->lightlist; }

private:
const WallDrawerArgs& wallargs;
const WallDrawerArgs* wallargs;

private:
uint8_t* dc_dest = nullptr;
int dc_dest_y = 0;
int dc_count = 0;
@@ -34,6 +34,8 @@ EXTERN_CVAR(Int, r_multithreaded)

class PolyTriangleThreadData;

namespace swrenderer { class WallColumnDrawerArgs; }

// Worker data for each thread executing drawer commands
class DrawerThread
{
@@ -61,6 +63,7 @@ class DrawerThread
const uint8_t *tiltlighting[MAXWIDTH];

std::shared_ptr<PolyTriangleThreadData> poly;
std::shared_ptr<swrenderer::WallColumnDrawerArgs> columndrawer;

size_t debug_draw_pos = 0;

0 comments on commit 8abbd63

Please sign in to comment.
You can’t perform that action at this time.