From 7b578bbb536a8666bd48c9279a34e24668e4024a Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 1 Feb 2017 21:52:29 +0100 Subject: [PATCH] Remove redundant dc_pitch --- src/swrenderer/drawers/r_draw_pal.cpp | 8 ++++---- src/swrenderer/drawers/r_draw_rgba.cpp | 12 ++++++------ src/swrenderer/scene/r_viewport.cpp | 20 ++++++-------------- src/swrenderer/scene/r_viewport.h | 1 - 4 files changed, 16 insertions(+), 25 deletions(-) diff --git a/src/swrenderer/drawers/r_draw_pal.cpp b/src/swrenderer/drawers/r_draw_pal.cpp index e7906d3192..f5b6e51ef6 100644 --- a/src/swrenderer/drawers/r_draw_pal.cpp +++ b/src/swrenderer/drawers/r_draw_pal.cpp @@ -106,7 +106,7 @@ namespace swrenderer _dest = args.Dest(); _dest_y = args.DestY(); _fracbits = args.dc_wall_fracbits; - _pitch = RenderViewport::Instance()->dc_pitch; + _pitch = RenderViewport::Instance()->RenderTarget->GetPitch(); _srcblend = args.dc_srcblend; _destblend = args.dc_destblend; _dynlights = args.dc_lights; @@ -564,7 +564,7 @@ namespace swrenderer _dest = args.Dest(); _dest_y = args.DestY(); _count = args.Count(); - _pitch = RenderViewport::Instance()->dc_pitch; + _pitch = RenderViewport::Instance()->RenderTarget->GetPitch(); _source = args.FrontTexturePixels(); _source2 = args.BackTexturePixels(); _sourceheight[0] = args.FrontTextureHeight(); @@ -870,7 +870,7 @@ namespace swrenderer _count = args.dc_count; _dest = args.Dest(); _dest_y = args.DestY(); - _pitch = RenderViewport::Instance()->dc_pitch; + _pitch = RenderViewport::Instance()->RenderTarget->GetPitch(); _iscale = args.dc_iscale; _texturefrac = args.dc_texturefrac; _colormap = args.Colormap(); @@ -1768,7 +1768,7 @@ namespace swrenderer _yh = args.dc_yh; _x = args.dc_x; _destorg = RenderViewport::Instance()->dc_destorg; - _pitch = RenderViewport::Instance()->dc_pitch; + _pitch = RenderViewport::Instance()->RenderTarget->GetPitch(); _fuzzpos = fuzzpos; _fuzzviewheight = fuzzviewheight; } diff --git a/src/swrenderer/drawers/r_draw_rgba.cpp b/src/swrenderer/drawers/r_draw_rgba.cpp index 59521bb065..9d3a15ad82 100644 --- a/src/swrenderer/drawers/r_draw_rgba.cpp +++ b/src/swrenderer/drawers/r_draw_rgba.cpp @@ -73,7 +73,7 @@ namespace swrenderer args.xbits = drawerargs.TextureWidthBits(); args.ybits = drawerargs.TextureHeightBits(); args.destorg = (uint32_t*)RenderViewport::Instance()->dc_destorg; - args.destpitch = RenderViewport::Instance()->dc_pitch; + args.destpitch = RenderViewport::Instance()->RenderTarget->GetPitch(); args.source = (const uint32_t*)drawerargs.TexturePixels(); args.light = LightBgra::calc_light_multiplier(drawerargs.Light()); args.light_red = shade_constants.light_red; @@ -186,7 +186,7 @@ namespace swrenderer auto shade_constants = drawerargs.ColormapConstants(); args.dest = (uint32_t*)drawerargs.Dest(); args.dest_y = drawerargs.DestY(); - args.pitch = RenderViewport::Instance()->dc_pitch; + args.pitch = RenderViewport::Instance()->RenderTarget->GetPitch(); args.count = drawerargs.dc_count; args.texturefrac[0] = drawerargs.dc_texturefrac; args.texturefracx[0] = drawerargs.dc_texturefracx; @@ -256,7 +256,7 @@ namespace swrenderer args.colormap = drawerargs.Colormap(); args.translation = drawerargs.TranslationMap(); args.basecolors = (const uint32_t *)GPalette.BaseColors; - args.pitch = RenderViewport::Instance()->dc_pitch; + args.pitch = RenderViewport::Instance()->RenderTarget->GetPitch(); args.count = drawerargs.dc_count; args.dest_y = drawerargs.DestY(); args.iscale = drawerargs.dc_iscale; @@ -307,7 +307,7 @@ namespace swrenderer args.dest = (uint32_t*)drawerargs.Dest(); args.dest_y = drawerargs.DestY(); args.count = drawerargs.Count(); - args.pitch = RenderViewport::Instance()->dc_pitch; + args.pitch = RenderViewport::Instance()->RenderTarget->GetPitch(); args.texturefrac[0] = drawerargs.TextureVPos(); args.iscale[0] = drawerargs.TextureVStep(); args.source0[0] = (const uint32_t *)drawerargs.FrontTexturePixels(); @@ -332,7 +332,7 @@ namespace swrenderer _yl = drawerargs.dc_yl; _yh = drawerargs.dc_yh; _destorg = RenderViewport::Instance()->dc_destorg; - _pitch = RenderViewport::Instance()->dc_pitch; + _pitch = RenderViewport::Instance()->RenderTarget->GetPitch(); _fuzzpos = fuzzpos; _fuzzviewheight = fuzzviewheight; } @@ -710,7 +710,7 @@ namespace swrenderer _a = a; _destorg = RenderViewport::Instance()->dc_destorg; - _pitch = RenderViewport::Instance()->dc_pitch; + _pitch = RenderViewport::Instance()->RenderTarget->GetPitch(); } void FillTransColumnRGBACommand::Execute(DrawerThread *thread) diff --git a/src/swrenderer/scene/r_viewport.cpp b/src/swrenderer/scene/r_viewport.cpp index 677332bd82..d4c8fae842 100644 --- a/src/swrenderer/scene/r_viewport.cpp +++ b/src/swrenderer/scene/r_viewport.cpp @@ -126,25 +126,17 @@ namespace swrenderer void RenderViewport::SetupBuffer() { - static BYTE *lastbuff = NULL; - int pitch = RenderTarget->GetPitch(); int pixelsize = RenderTarget->IsBgra() ? 4 : 1; BYTE *lineptr = RenderTarget->GetBuffer() + (viewwindowy*pitch + viewwindowx) * pixelsize; - if (dc_pitch != pitch || lineptr != lastbuff) + R_InitFuzzTable(pitch); + + dc_destorg = lineptr; + dc_destheight = RenderTarget->GetHeight() - viewwindowy; + for (int i = 0; i < RenderTarget->GetHeight(); i++) { - if (dc_pitch != pitch) - { - dc_pitch = pitch; - R_InitFuzzTable(pitch); - } - dc_destorg = lineptr; - dc_destheight = RenderTarget->GetHeight() - viewwindowy; - for (int i = 0; i < RenderTarget->GetHeight(); i++) - { - ylookup[i] = i * pitch; - } + ylookup[i] = i * pitch; } R_InitParticleTexture(); diff --git a/src/swrenderer/scene/r_viewport.h b/src/swrenderer/scene/r_viewport.h index 44f28b6aa0..a430dbd975 100644 --- a/src/swrenderer/scene/r_viewport.h +++ b/src/swrenderer/scene/r_viewport.h @@ -47,7 +47,6 @@ namespace swrenderer uint8_t *dc_destorg = nullptr; int dc_destheight = 0; - int dc_pitch = 0; private: void InitTextureMapping();