diff --git a/src/swrenderer/drawers/r_draw_pal.cpp b/src/swrenderer/drawers/r_draw_pal.cpp index 2304cff090..6e3da73de6 100644 --- a/src/swrenderer/drawers/r_draw_pal.cpp +++ b/src/swrenderer/drawers/r_draw_pal.cpp @@ -1848,23 +1848,23 @@ namespace swrenderer PalSpanCommand::PalSpanCommand(const SpanDrawerArgs &args) { - _source = args.ds_source; + _source = args.TexturePixels(); _colormap = args.Colormap(); - _xfrac = args.ds_xfrac; - _yfrac = args.ds_yfrac; - _y = args.ds_y; - _x1 = args.ds_x1; - _x2 = args.ds_x2; + _xfrac = args.TextureUPos(); + _yfrac = args.TextureVPos(); + _y = args.DestY(); + _x1 = args.DestX1(); + _x2 = args.DestX2(); _destorg = dc_destorg; - _xstep = args.ds_xstep; - _ystep = args.ds_ystep; - _xbits = args.ds_xbits; - _ybits = args.ds_ybits; - _srcblend = args.dc_srcblend; - _destblend = args.dc_destblend; - _color = args.ds_color; - _srcalpha = args.dc_srcalpha; - _destalpha = args.dc_destalpha; + _xstep = args.TextureUStep(); + _ystep = args.TextureVStep(); + _xbits = args.TextureWidthBits(); + _ybits = args.TextureHeightBits(); + _srcblend = args.SrcBlend(); + _destblend = args.DestBlend(); + _color = args.SolidColor(); + _srcalpha = args.SrcAlpha(); + _destalpha = args.DestAlpha(); _dynlights = args.dc_lights; _num_dynlights = args.dc_num_lights; _viewpos_x = args.dc_viewpos.X; @@ -2626,9 +2626,9 @@ namespace swrenderer { _colormap = args.Colormap(); _destorg = dc_destorg; - _ybits = args.ds_ybits; - _xbits = args.ds_xbits; - _source = args.ds_source; + _ybits = args.TextureHeightBits(); + _xbits = args.TextureWidthBits(); + _source = args.TexturePixels(); basecolormapdata = basecolormap->Maps; } @@ -2869,7 +2869,7 @@ namespace swrenderer DrawColoredSpanPalCommand::DrawColoredSpanPalCommand(const SpanDrawerArgs &args, int y, int x1, int x2) : PalSpanCommand(args), y(y), x1(x1), x2(x2) { - color = args.ds_color; + color = args.SolidColor(); destorg = dc_destorg; } diff --git a/src/swrenderer/drawers/r_draw_rgba.cpp b/src/swrenderer/drawers/r_draw_rgba.cpp index 183d347c1e..ab932cdcac 100644 --- a/src/swrenderer/drawers/r_draw_rgba.cpp +++ b/src/swrenderer/drawers/r_draw_rgba.cpp @@ -63,18 +63,18 @@ namespace swrenderer DrawSpanLLVMCommand::DrawSpanLLVMCommand(const SpanDrawerArgs &drawerargs) { auto shade_constants = drawerargs.ColormapConstants(); - args.xfrac = drawerargs.ds_xfrac; - args.yfrac = drawerargs.ds_yfrac; - args.xstep = drawerargs.ds_xstep; - args.ystep = drawerargs.ds_ystep; - args.x1 = drawerargs.ds_x1; - args.x2 = drawerargs.ds_x2; - args.y = drawerargs.ds_y; - args.xbits = drawerargs.ds_xbits; - args.ybits = drawerargs.ds_ybits; + args.xfrac = drawerargs.TextureUPos(); + args.yfrac = drawerargs.TextureVPos(); + args.xstep = drawerargs.TextureUStep(); + args.ystep = drawerargs.TextureVStep(); + args.x1 = drawerargs.DestX1(); + args.x2 = drawerargs.DestX2(); + args.y = drawerargs.DestY(); + args.xbits = drawerargs.TextureWidthBits(); + args.ybits = drawerargs.TextureHeightBits(); args.destorg = (uint32_t*)dc_destorg; args.destpitch = dc_pitch; - args.source = (const uint32_t*)drawerargs.ds_source; + args.source = (const uint32_t*)drawerargs.TexturePixels(); args.light = LightBgra::calc_light_multiplier(drawerargs.Light()); args.light_red = shade_constants.light_red; args.light_green = shade_constants.light_green; @@ -85,12 +85,12 @@ namespace swrenderer args.fade_blue = shade_constants.fade_blue; args.fade_alpha = shade_constants.fade_alpha; args.desaturate = shade_constants.desaturate; - args.srcalpha = drawerargs.dc_srcalpha >> (FRACBITS - 8); - args.destalpha = drawerargs.dc_destalpha >> (FRACBITS - 8); + args.srcalpha = drawerargs.SrcAlpha() >> (FRACBITS - 8); + args.destalpha = drawerargs.DestAlpha() >> (FRACBITS - 8); args.flags = 0; if (shade_constants.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.TextureLOD(), args.source, args.xbits, args.ybits, drawerargs.MipmappedTexture())) args.flags |= DrawSpanArgs::nearest_filter; args.viewpos_x = drawerargs.dc_viewpos.X; @@ -436,12 +436,12 @@ namespace swrenderer FillSpanRGBACommand::FillSpanRGBACommand(const SpanDrawerArgs &drawerargs) { - _x1 = drawerargs.ds_x1; - _x2 = drawerargs.ds_x2; - _y = drawerargs.ds_y; + _x1 = drawerargs.DestX1(); + _x2 = drawerargs.DestX2(); + _y = drawerargs.DestY(); _destorg = dc_destorg; _light = drawerargs.Light(); - _color = drawerargs.ds_color; + _color = drawerargs.SolidColor(); } void FillSpanRGBACommand::Execute(DrawerThread *thread) @@ -548,9 +548,9 @@ namespace swrenderer _planelightfloat = planelightfloat; _pviewx = pviewx; _pviewy = pviewy; - _source = (const uint32_t*)drawerargs.ds_source; - _xbits = drawerargs.ds_xbits; - _ybits = drawerargs.ds_ybits; + _source = (const uint32_t*)drawerargs.TexturePixels(); + _xbits = drawerargs.TextureWidthBits(); + _ybits = drawerargs.TextureHeightBits(); } void DrawTiltedSpanRGBACommand::Execute(DrawerThread *thread) @@ -674,7 +674,7 @@ namespace swrenderer _destorg = dc_destorg; _light = drawerargs.Light(); - _color = drawerargs.ds_color; + _color = drawerargs.SolidColor(); } void DrawColoredSpanRGBACommand::Execute(DrawerThread *thread) diff --git a/src/swrenderer/drawers/r_drawerargs.cpp b/src/swrenderer/drawers/r_drawerargs.cpp index 82c0675042..d2dff94826 100644 --- a/src/swrenderer/drawers/r_drawerargs.cpp +++ b/src/swrenderer/drawers/r_drawerargs.cpp @@ -124,7 +124,7 @@ namespace swrenderer return shadeConstants; } - void SpanDrawerArgs::SetSpanTexture(FTexture *tex) + void SpanDrawerArgs::SetTexture(FTexture *tex) { tex->GetWidth(); ds_xbits = tex->WidthBits; @@ -596,7 +596,7 @@ namespace swrenderer (Drawers()->*wallfunc)(*this); } - void SpanDrawerArgs::SetSpanStyle(bool masked, bool additive, fixed_t alpha) + void SpanDrawerArgs::SetStyle(bool masked, bool additive, fixed_t alpha) { if (masked) { diff --git a/src/swrenderer/drawers/r_drawerargs.h b/src/swrenderer/drawers/r_drawerargs.h index 5ae0dadd0f..58f44931b4 100644 --- a/src/swrenderer/drawers/r_drawerargs.h +++ b/src/swrenderer/drawers/r_drawerargs.h @@ -71,33 +71,40 @@ namespace swrenderer public: SpanDrawerArgs(); - void SetSpanStyle(bool masked, bool additive, fixed_t alpha); - void SetSpanTexture(FTexture *tex); + void SetStyle(bool masked, bool additive, fixed_t alpha); + void SetDestY(int y) { ds_y = y; } + void SetDestX1(int x) { ds_x1 = x; } + void SetDestX2(int x) { ds_x2 = x; } + void SetTexture(FTexture *tex); + void SetTextureLOD(double lod) { ds_lod = lod; } + void SetTextureUPos(dsfixed_t xfrac) { ds_xfrac = xfrac; } + void SetTextureVPos(dsfixed_t yfrac) { ds_yfrac = yfrac; } + void SetTextureUStep(dsfixed_t xstep) { ds_xstep = xstep; } + void SetTextureVStep(dsfixed_t vstep) { ds_ystep = vstep; } + void SetSolidColor(int colorIndex) { ds_color = colorIndex; } void DrawSpan(); 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 DrawFogBoundaryLine(int y, int x1, int x2); - uint32_t *dc_srcblend; - uint32_t *dc_destblend; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; - - int ds_y; - int ds_x1; - int ds_x2; - dsfixed_t ds_xfrac; - dsfixed_t ds_yfrac; - dsfixed_t ds_xstep; - dsfixed_t ds_ystep; - int ds_xbits; - int ds_ybits; - fixed_t ds_alpha; - double ds_lod; - const uint8_t *ds_source; - bool ds_source_mipmapped; - int ds_color = 0; + uint32_t *SrcBlend() const { return dc_srcblend; } + uint32_t *DestBlend() const { return dc_destblend; } + fixed_t SrcAlpha() const { return dc_srcalpha; } + fixed_t DestAlpha() const { return dc_destalpha; } + int DestY() const { return ds_y; } + int DestX1() const { return ds_x1; } + int DestX2() const { return ds_x2; } + dsfixed_t TextureUPos() const { return ds_xfrac; } + dsfixed_t TextureVPos() const { return ds_yfrac; } + dsfixed_t TextureUStep() const { return ds_xstep; } + dsfixed_t TextureVStep() const { return ds_xstep; } + int SolidColor() const { return ds_color; } + int TextureWidthBits() const { return ds_xbits; } + int TextureHeightBits() const { return ds_ybits; } + const uint8_t *TexturePixels() const { return ds_source; } + bool MipmappedTexture() const { return ds_source_mipmapped; } + double TextureLOD() const { return ds_lod; } FVector3 dc_normal; FVector3 dc_viewpos; @@ -108,6 +115,24 @@ namespace swrenderer private: typedef void(SWPixelFormatDrawers::*SpanDrawerFunc)(const SpanDrawerArgs &args); SpanDrawerFunc spanfunc; + + int ds_y; + int ds_x1; + int ds_x2; + int ds_xbits; + int ds_ybits; + const uint8_t *ds_source; + bool ds_source_mipmapped; + dsfixed_t ds_xfrac; + dsfixed_t ds_yfrac; + dsfixed_t ds_xstep; + dsfixed_t ds_ystep; + uint32_t *dc_srcblend; + uint32_t *dc_destblend; + fixed_t dc_srcalpha; + fixed_t dc_destalpha; + int ds_color = 0; + double ds_lod; }; class WallDrawerArgs : public DrawerArgs diff --git a/src/swrenderer/plane/r_flatplane.cpp b/src/swrenderer/plane/r_flatplane.cpp index 0663d02bfa..895734ea6c 100644 --- a/src/swrenderer/plane/r_flatplane.cpp +++ b/src/swrenderer/plane/r_flatplane.cpp @@ -51,15 +51,15 @@ namespace swrenderer return; } - drawerargs.ds_color = 3; - drawerargs.SetSpanTexture(texture); + drawerargs.SetSolidColor(3); + drawerargs.SetTexture(texture); double planeang = (pl->xform.Angle + pl->xform.baseAngle).Radians(); double xstep, ystep, leftxfrac, leftyfrac, rightxfrac, rightyfrac; double x; - xscale = xs_ToFixed(32 - drawerargs.ds_xbits, _xscale); - yscale = xs_ToFixed(32 - drawerargs.ds_ybits, _yscale); + xscale = xs_ToFixed(32 - drawerargs.TextureWidthBits(), _xscale); + yscale = xs_ToFixed(32 - drawerargs.TextureHeightBits(), _yscale); if (planeang != 0) { double cosine = cos(planeang), sine = sin(planeang); @@ -126,7 +126,7 @@ namespace swrenderer planeshade = LIGHT2SHADE(pl->lightlevel); } - drawerargs.SetSpanStyle(masked, additive, alpha); + drawerargs.SetStyle(masked, additive, alpha); light_list = pl->lights; @@ -149,25 +149,26 @@ namespace swrenderer distance = planeheight * yslope[y]; - if (drawerargs.ds_xbits != 0) + if (drawerargs.TextureWidthBits() != 0) { - drawerargs.ds_xstep = xs_ToFixed(32 - drawerargs.ds_xbits, distance * xstepscale); - drawerargs.ds_xfrac = xs_ToFixed(32 - drawerargs.ds_xbits, distance * basexfrac) + pviewx; + drawerargs.SetTextureUStep(xs_ToFixed(32 - drawerargs.TextureWidthBits(), distance * xstepscale)); + drawerargs.SetTextureUPos(xs_ToFixed(32 - drawerargs.TextureWidthBits(), distance * basexfrac) + pviewx); } else { - drawerargs.ds_xstep = 0; - drawerargs.ds_xfrac = 0; + drawerargs.SetTextureUStep(0); + drawerargs.SetTextureUPos(0); } - if (drawerargs.ds_ybits != 0) + + if (drawerargs.TextureHeightBits() != 0) { - drawerargs.ds_ystep = xs_ToFixed(32 - drawerargs.ds_ybits, distance * ystepscale); - drawerargs.ds_yfrac = xs_ToFixed(32 - drawerargs.ds_ybits, distance * baseyfrac) + pviewy; + drawerargs.SetTextureVStep(xs_ToFixed(32 - drawerargs.TextureHeightBits(), distance * ystepscale)); + drawerargs.SetTextureVPos(xs_ToFixed(32 - drawerargs.TextureHeightBits(), distance * baseyfrac) + pviewy); } else { - drawerargs.ds_ystep = 0; - drawerargs.ds_yfrac = 0; + drawerargs.SetTextureVStep(0); + drawerargs.SetTextureVPos(0); } if (r_swtruecolor) @@ -177,7 +178,7 @@ namespace swrenderer double ymagnitude = fabs(xstepscale * (distance2 - distance) * FocalLengthX); double magnitude = MAX(ymagnitude, xmagnitude); double min_lod = -1000.0; - drawerargs.ds_lod = MAX(log2(magnitude) + r_lod_bias, min_lod); + drawerargs.SetTextureLOD(MAX(log2(magnitude) + r_lod_bias, min_lod)); } if (plane_shade) @@ -250,9 +251,9 @@ namespace swrenderer drawerargs.dc_num_lights = 0; } - drawerargs.ds_y = y; - drawerargs.ds_x1 = x1; - drawerargs.ds_x2 = x2; + drawerargs.SetDestY(y); + drawerargs.SetDestX1(x1); + drawerargs.SetDestX2(x2); drawerargs.DrawSpan(); } diff --git a/src/swrenderer/plane/r_slopeplane.cpp b/src/swrenderer/plane/r_slopeplane.cpp index 363ff9edfe..cdee76e0c9 100644 --- a/src/swrenderer/plane/r_slopeplane.cpp +++ b/src/swrenderer/plane/r_slopeplane.cpp @@ -70,17 +70,17 @@ namespace swrenderer return; } - drawerargs.ds_color = 3; - drawerargs.SetSpanTexture(texture); + drawerargs.SetSolidColor(3); + drawerargs.SetTexture(texture); - lxscale = _xscale * ifloatpow2[drawerargs.ds_xbits]; - lyscale = _yscale * ifloatpow2[drawerargs.ds_ybits]; + lxscale = _xscale * ifloatpow2[drawerargs.TextureWidthBits()]; + lyscale = _yscale * ifloatpow2[drawerargs.TextureHeightBits()]; xscale = 64.f / lxscale; yscale = 64.f / lyscale; zeroheight = pl->height.ZatPoint(ViewPos); - pviewx = xs_ToFixed(32 - drawerargs.ds_xbits, pl->xform.xOffs * pl->xform.xScale); - pviewy = xs_ToFixed(32 - drawerargs.ds_ybits, pl->xform.yOffs * pl->xform.yScale); + pviewx = xs_ToFixed(32 - drawerargs.TextureWidthBits(), pl->xform.xOffs * pl->xform.xScale); + pviewy = xs_ToFixed(32 - drawerargs.TextureHeightBits(), pl->xform.yOffs * pl->xform.yScale); planeang = (pl->xform.Angle + pl->xform.baseAngle).Radians(); // p is the texture origin in view space @@ -170,11 +170,11 @@ namespace swrenderer } // Hack in support for 1 x Z and Z x 1 texture sizes - if (drawerargs.ds_ybits == 0) + if (drawerargs.TextureHeightBits() == 0) { plane_sv[2] = plane_sv[1] = plane_sv[0] = 0; } - if (drawerargs.ds_xbits == 0) + if (drawerargs.TextureWidthBits() == 0) { plane_su[2] = plane_su[1] = plane_su[0] = 0; } diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 9ad73942d4..574fb09dd7 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -1384,30 +1384,30 @@ void DCanvas::FillSimplePoly(FTexture *tex, FVector2 *points, int npoints, // Setup constant texture mapping parameters. SpanDrawerArgs drawerargs; - drawerargs.SetSpanTexture(tex); + drawerargs.SetTexture(tex); if (colormap) drawerargs.SetColorMapLight(colormap, 0, clamp(shade >> FRACBITS, 0, NUMCOLORMAPS - 1)); else drawerargs.SetColorMapLight(&identitycolormap, 0, 0); - if (drawerargs.ds_xbits != 0) + if (drawerargs.TextureWidthBits() != 0) { - scalex = double(1u << (32 - drawerargs.ds_xbits)) / scalex; - drawerargs.ds_xstep = xs_RoundToInt(cosrot * scalex); + scalex = double(1u << (32 - drawerargs.TextureWidthBits())) / scalex; + drawerargs.SetTextureUStep(xs_RoundToInt(cosrot * scalex)); } else { // Texture is one pixel wide. scalex = 0; - drawerargs.ds_xstep = 0; + drawerargs.SetTextureUStep(0); } - if (drawerargs.ds_ybits != 0) + if (drawerargs.TextureHeightBits() != 0) { - scaley = double(1u << (32 - drawerargs.ds_ybits)) / scaley; - drawerargs.ds_ystep = xs_RoundToInt(sinrot * scaley); + scaley = double(1u << (32 - drawerargs.TextureHeightBits())) / scaley; + drawerargs.SetTextureVStep(xs_RoundToInt(sinrot * scaley)); } else { // Texture is one pixel tall. scaley = 0; - drawerargs.ds_ystep = 0; + drawerargs.SetTextureVStep(0); } // Travel down the right edge and create an outline of that edge. @@ -1473,9 +1473,9 @@ void DCanvas::FillSimplePoly(FTexture *tex, FVector2 *points, int npoints, #if 0 memset(this->Buffer + y * this->Pitch + x1, (int)tex, x2 - x1); #else - drawerargs.ds_y = y; - drawerargs.ds_x1 = x1; - drawerargs.ds_x2 = x2 - 1; + drawerargs.SetDestY(y); + drawerargs.SetDestX1(x1); + drawerargs.SetDestX2(x2 - 1); DVector2 tex(x1 - originx, y - originy); if (dorotate) @@ -1484,8 +1484,8 @@ void DCanvas::FillSimplePoly(FTexture *tex, FVector2 *points, int npoints, tex.X = t * cosrot - tex.Y * sinrot; tex.Y = tex.Y * cosrot + t * sinrot; } - drawerargs.ds_xfrac = xs_RoundToInt(tex.X * scalex); - drawerargs.ds_yfrac = xs_RoundToInt(tex.Y * scaley); + drawerargs.SetTextureUPos(xs_RoundToInt(tex.X * scalex)); + drawerargs.SetTextureVPos(xs_RoundToInt(tex.Y * scaley)); drawerargs.DrawSpan(); #endif