Remove redundant span drawer args

This commit is contained in:
Magnus Norddahl 2017-01-30 04:35:28 +01:00
parent 0af86efb17
commit fd459b1f13
7 changed files with 26 additions and 60 deletions

View file

@ -1849,7 +1849,7 @@ namespace swrenderer
PalSpanCommand::PalSpanCommand(const SpanDrawerArgs &args) PalSpanCommand::PalSpanCommand(const SpanDrawerArgs &args)
{ {
_source = args.ds_source; _source = args.ds_source;
_colormap = args.ds_colormap; _colormap = args.dc_colormap;
_xfrac = args.ds_xfrac; _xfrac = args.ds_xfrac;
_yfrac = args.ds_yfrac; _yfrac = args.ds_yfrac;
_y = args.ds_y; _y = args.ds_y;
@ -2624,7 +2624,7 @@ namespace swrenderer
DrawTiltedSpanPalCommand::DrawTiltedSpanPalCommand(const SpanDrawerArgs &args, int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy, FDynamicColormap *basecolormap) DrawTiltedSpanPalCommand::DrawTiltedSpanPalCommand(const SpanDrawerArgs &args, int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy, FDynamicColormap *basecolormap)
: y(y), x1(x1), x2(x2), plane_sz(plane_sz), plane_su(plane_su), plane_sv(plane_sv), plane_shade(plane_shade), planeshade(planeshade), planelightfloat(planelightfloat), pviewx(pviewx), pviewy(pviewy) : y(y), x1(x1), x2(x2), plane_sz(plane_sz), plane_su(plane_su), plane_sv(plane_sv), plane_shade(plane_shade), planeshade(planeshade), planelightfloat(planelightfloat), pviewx(pviewx), pviewy(pviewy)
{ {
_colormap = args.ds_colormap; _colormap = args.dc_colormap;
_destorg = dc_destorg; _destorg = dc_destorg;
_ybits = args.ds_ybits; _ybits = args.ds_ybits;
_xbits = args.ds_xbits; _xbits = args.ds_xbits;

View file

@ -74,20 +74,20 @@ namespace swrenderer
args.destorg = (uint32_t*)dc_destorg; args.destorg = (uint32_t*)dc_destorg;
args.destpitch = dc_pitch; args.destpitch = dc_pitch;
args.source = (const uint32_t*)drawerargs.ds_source; args.source = (const uint32_t*)drawerargs.ds_source;
args.light = LightBgra::calc_light_multiplier(drawerargs.ds_light); args.light = LightBgra::calc_light_multiplier(drawerargs.dc_light);
args.light_red = drawerargs.ds_shade_constants.light_red; args.light_red = drawerargs.dc_shade_constants.light_red;
args.light_green = drawerargs.ds_shade_constants.light_green; args.light_green = drawerargs.dc_shade_constants.light_green;
args.light_blue = drawerargs.ds_shade_constants.light_blue; args.light_blue = drawerargs.dc_shade_constants.light_blue;
args.light_alpha = drawerargs.ds_shade_constants.light_alpha; args.light_alpha = drawerargs.dc_shade_constants.light_alpha;
args.fade_red = drawerargs.ds_shade_constants.fade_red; args.fade_red = drawerargs.dc_shade_constants.fade_red;
args.fade_green = drawerargs.ds_shade_constants.fade_green; args.fade_green = drawerargs.dc_shade_constants.fade_green;
args.fade_blue = drawerargs.ds_shade_constants.fade_blue; args.fade_blue = drawerargs.dc_shade_constants.fade_blue;
args.fade_alpha = drawerargs.ds_shade_constants.fade_alpha; args.fade_alpha = drawerargs.dc_shade_constants.fade_alpha;
args.desaturate = drawerargs.ds_shade_constants.desaturate; args.desaturate = drawerargs.dc_shade_constants.desaturate;
args.srcalpha = drawerargs.dc_srcalpha >> (FRACBITS - 8); args.srcalpha = drawerargs.dc_srcalpha >> (FRACBITS - 8);
args.destalpha = drawerargs.dc_destalpha >> (FRACBITS - 8); args.destalpha = drawerargs.dc_destalpha >> (FRACBITS - 8);
args.flags = 0; args.flags = 0;
if (drawerargs.ds_shade_constants.simple_shade) if (drawerargs.dc_shade_constants.simple_shade)
args.flags |= DrawSpanArgs::simple_shade; args.flags |= DrawSpanArgs::simple_shade;
if (!sampler_setup(drawerargs.ds_lod, args.source, args.xbits, args.ybits, drawerargs.ds_source_mipmapped)) if (!sampler_setup(drawerargs.ds_lod, args.source, args.xbits, args.ybits, drawerargs.ds_source_mipmapped))
args.flags |= DrawSpanArgs::nearest_filter; args.flags |= DrawSpanArgs::nearest_filter;
@ -436,7 +436,7 @@ namespace swrenderer
_x2 = drawerargs.ds_x2; _x2 = drawerargs.ds_x2;
_y = drawerargs.ds_y; _y = drawerargs.ds_y;
_destorg = dc_destorg; _destorg = dc_destorg;
_light = drawerargs.ds_light; _light = drawerargs.dc_light;
_color = drawerargs.ds_color; _color = drawerargs.ds_color;
} }
@ -534,8 +534,8 @@ namespace swrenderer
_x2 = x2; _x2 = x2;
_y = y; _y = y;
_destorg = dc_destorg; _destorg = dc_destorg;
_light = drawerargs.ds_light; _light = drawerargs.dc_light;
_shade_constants = drawerargs.ds_shade_constants; _shade_constants = drawerargs.dc_shade_constants;
_plane_sz = plane_sz; _plane_sz = plane_sz;
_plane_su = plane_su; _plane_su = plane_su;
_plane_sv = plane_sv; _plane_sv = plane_sv;
@ -669,7 +669,7 @@ namespace swrenderer
_x2 = x2; _x2 = x2;
_destorg = dc_destorg; _destorg = dc_destorg;
_light = drawerargs.ds_light; _light = drawerargs.dc_light;
_color = drawerargs.ds_color; _color = drawerargs.ds_color;
} }

View file

@ -91,29 +91,6 @@ namespace swrenderer
} }
} }
void SpanDrawerArgs::SetDSColorMapLight(FSWColormap *base_colormap, float light, int shade)
{
if (r_swtruecolor)
{
ds_shade_constants.light_red = base_colormap->Color.r * 256 / 255;
ds_shade_constants.light_green = base_colormap->Color.g * 256 / 255;
ds_shade_constants.light_blue = base_colormap->Color.b * 256 / 255;
ds_shade_constants.light_alpha = base_colormap->Color.a * 256 / 255;
ds_shade_constants.fade_red = base_colormap->Fade.r;
ds_shade_constants.fade_green = base_colormap->Fade.g;
ds_shade_constants.fade_blue = base_colormap->Fade.b;
ds_shade_constants.fade_alpha = base_colormap->Fade.a;
ds_shade_constants.desaturate = MIN(abs(base_colormap->Desaturate), 255) * 255 / 256;
ds_shade_constants.simple_shade = (base_colormap->Color.d == 0x00ffffff && base_colormap->Fade.d == 0x00000000 && base_colormap->Desaturate == 0);
ds_colormap = base_colormap->Maps;
ds_light = LIGHTSCALE(light, shade);
}
else
{
ds_colormap = base_colormap->Maps + (GETPALOOKUP(light, shade) << COLORMAPSHIFT);
}
}
void DrawerArgs::SetTranslationMap(lighttable_t *translation) void DrawerArgs::SetTranslationMap(lighttable_t *translation)
{ {
if (r_swtruecolor) if (r_swtruecolor)
@ -156,11 +133,6 @@ namespace swrenderer
ds_source_mipmapped = tex->Mipmapped() && tex->GetWidth() > 1 && tex->GetHeight() > 1; ds_source_mipmapped = tex->Mipmapped() && tex->GetWidth() > 1 && tex->GetHeight() > 1;
} }
void SpanDrawerArgs::SetSpanColormap(FDynamicColormap *colormap, int shade)
{
SetDSColorMapLight(colormap, 0, shade);
}
void ColumnDrawerArgs::DrawMaskedColumn(int x, fixed_t iscale, FTexture *tex, fixed_t col, double spryscale, double sprtopscreen, bool sprflipvert, const short *mfloorclip, const short *mceilingclip, bool unmasked) void ColumnDrawerArgs::DrawMaskedColumn(int x, fixed_t iscale, FTexture *tex, fixed_t col, double spryscale, double sprtopscreen, bool sprflipvert, const short *mfloorclip, const short *mceilingclip, bool unmasked)
{ {
// Handle the linear filtered version in a different function to reduce chances of merge conflicts from zdoom. // Handle the linear filtered version in a different function to reduce chances of merge conflicts from zdoom.

View file

@ -140,10 +140,7 @@ namespace swrenderer
class SpanDrawerArgs : public DrawerArgs class SpanDrawerArgs : public DrawerArgs
{ {
public: public:
void SetDSColorMapLight(FSWColormap *base_colormap, float light, int shade);
void SetSpanTexture(FTexture *tex); void SetSpanTexture(FTexture *tex);
void SetSpanColormap(FDynamicColormap *colormap, int shade);
void DrawTiltedSpan(int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy, FDynamicColormap *basecolormap); void DrawTiltedSpan(int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy, FDynamicColormap *basecolormap);
void DrawColoredSpan(int y, int x1, int x2); void DrawColoredSpan(int y, int x1, int x2);
@ -152,9 +149,6 @@ namespace swrenderer
int ds_y; int ds_y;
int ds_x1; int ds_x1;
int ds_x2; int ds_x2;
uint8_t * ds_colormap;
ShadeConstants ds_shade_constants;
dsfixed_t ds_light;
dsfixed_t ds_xfrac; dsfixed_t ds_xfrac;
dsfixed_t ds_yfrac; dsfixed_t ds_yfrac;
dsfixed_t ds_xstep; dsfixed_t ds_xstep;

View file

@ -108,16 +108,16 @@ namespace swrenderer
basecolormap = colormap; basecolormap = colormap;
GlobVis = LightVisibility::Instance()->FlatPlaneGlobVis() / planeheight; GlobVis = LightVisibility::Instance()->FlatPlaneGlobVis() / planeheight;
drawerargs.ds_light = 0; drawerargs.dc_light = 0;
CameraLight *cameraLight = CameraLight::Instance(); CameraLight *cameraLight = CameraLight::Instance();
if (cameraLight->fixedlightlev >= 0) if (cameraLight->fixedlightlev >= 0)
{ {
drawerargs.SetDSColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(cameraLight->fixedlightlev)); drawerargs.SetColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(cameraLight->fixedlightlev));
plane_shade = false; plane_shade = false;
} }
else if (cameraLight->fixedcolormap) else if (cameraLight->fixedcolormap)
{ {
drawerargs.SetDSColorMapLight(cameraLight->fixedcolormap, 0, 0); drawerargs.SetColorMapLight(cameraLight->fixedcolormap, 0, 0);
plane_shade = false; plane_shade = false;
} }
else else
@ -183,7 +183,7 @@ namespace swrenderer
if (plane_shade) if (plane_shade)
{ {
// Determine lighting based on the span's distance from the viewer. // Determine lighting based on the span's distance from the viewer.
drawerargs.SetDSColorMapLight(basecolormap, (float)(GlobVis * fabs(CenterY - y)), planeshade); drawerargs.SetColorMapLight(basecolormap, (float)(GlobVis * fabs(CenterY - y)), planeshade);
} }
if (r_dynlights) if (r_dynlights)

View file

@ -154,17 +154,17 @@ namespace swrenderer
CameraLight *cameraLight = CameraLight::Instance(); CameraLight *cameraLight = CameraLight::Instance();
if (cameraLight->fixedlightlev >= 0) if (cameraLight->fixedlightlev >= 0)
{ {
drawerargs.SetDSColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(cameraLight->fixedlightlev)); drawerargs.SetColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(cameraLight->fixedlightlev));
plane_shade = false; plane_shade = false;
} }
else if (cameraLight->fixedcolormap) else if (cameraLight->fixedcolormap)
{ {
drawerargs.SetDSColorMapLight(cameraLight->fixedcolormap, 0, 0); drawerargs.SetColorMapLight(cameraLight->fixedcolormap, 0, 0);
plane_shade = false; plane_shade = false;
} }
else else
{ {
drawerargs.SetDSColorMapLight(basecolormap, 0, 0); drawerargs.SetColorMapLight(basecolormap, 0, 0);
plane_shade = true; plane_shade = true;
planeshade = LIGHT2SHADE(pl->lightlevel); planeshade = LIGHT2SHADE(pl->lightlevel);
} }

View file

@ -1390,9 +1390,9 @@ void DCanvas::FillSimplePoly(FTexture *tex, FVector2 *points, int npoints,
SpanDrawerArgs drawerargs; SpanDrawerArgs drawerargs;
drawerargs.SetSpanTexture(tex); drawerargs.SetSpanTexture(tex);
if (colormap) if (colormap)
drawerargs.SetSpanColormap(colormap, clamp(shade >> FRACBITS, 0, NUMCOLORMAPS - 1)); drawerargs.SetColorMapLight(colormap, 0, clamp(shade >> FRACBITS, 0, NUMCOLORMAPS - 1));
else else
drawerargs.SetSpanColormap(&identitycolormap, 0); drawerargs.SetColorMapLight(&identitycolormap, 0, 0);
if (drawerargs.ds_xbits != 0) if (drawerargs.ds_xbits != 0)
{ {
scalex = double(1u << (32 - drawerargs.ds_xbits)) / scalex; scalex = double(1u << (32 - drawerargs.ds_xbits)) / scalex;