Remove r_swtruecolor variable as it is redundant

This commit is contained in:
Magnus Norddahl 2017-02-01 21:42:08 +01:00
parent e78e76a593
commit 93166fa150
18 changed files with 49 additions and 69 deletions

View file

@ -49,7 +49,7 @@ void PolyDrawArgs::SetTexture(FTexture *texture)
textureWidth = texture->GetWidth();
textureHeight = texture->GetHeight();
auto viewport = swrenderer::RenderViewport::Instance();
if (viewport->r_swtruecolor)
if (viewport->RenderTarget->IsBgra())
texturePixels = (const uint8_t *)texture->GetPixelsBgra();
else
texturePixels = texture->GetPixels();
@ -63,7 +63,7 @@ void PolyDrawArgs::SetTexture(FTexture *texture, uint32_t translationID, bool fo
FRemapTable *table = TranslationToTable(translationID);
if (table != nullptr && !table->Inactive)
{
if (swrenderer::RenderViewport::Instance()->r_swtruecolor)
if (swrenderer::RenderViewport::Instance()->RenderTarget->IsBgra())
translation = (uint8_t*)table->Palette;
else
translation = table->Remap;

View file

@ -58,9 +58,6 @@ void PolyRenderer::RenderView(player_t *player)
viewport->RenderTarget = screen;
bool saved_swtruecolor = viewport->r_swtruecolor;
viewport->r_swtruecolor = screen->IsBgra();
int width = SCREENWIDTH;
int height = SCREENHEIGHT;
int stHeight = gST_Y;
@ -72,14 +69,12 @@ void PolyRenderer::RenderView(player_t *player)
// Apply special colormap if the target cannot do it
CameraLight *cameraLight = CameraLight::Instance();
if (cameraLight->realfixedcolormap && viewport->r_swtruecolor && !(r_shadercolormaps && screen->Accel2D))
if (cameraLight->realfixedcolormap && viewport->RenderTarget->IsBgra() && !(r_shadercolormaps && screen->Accel2D))
{
R_BeginDrawerCommands();
DrawerCommandQueue::QueueCommand<ApplySpecialColormapRGBACommand>(cameraLight->realfixedcolormap, screen);
R_EndDrawerCommands();
}
viewport->r_swtruecolor = saved_swtruecolor;
}
void PolyRenderer::RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int y, int width, int height, bool dontmaplines)
@ -87,7 +82,6 @@ void PolyRenderer::RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int
auto viewport = swrenderer::RenderViewport::Instance();
const bool savedviewactive = viewactive;
const bool savedoutputformat = viewport->r_swtruecolor;
viewwidth = width;
viewport->RenderTarget = canvas;
@ -97,7 +91,6 @@ void PolyRenderer::RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int
viewwindowx = x;
viewwindowy = y;
viewactive = true;
viewport->r_swtruecolor = canvas->IsBgra();
canvas->Lock(true);
@ -112,7 +105,6 @@ void PolyRenderer::RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int
ActiveRatio(width, height, &trueratio);
viewport->SetViewport(width, height, WidescreenRatio);
viewactive = savedviewactive;
viewport->r_swtruecolor = savedoutputformat;
}
void PolyRenderer::RenderActorView(AActor *actor, bool dontmaplines)

View file

@ -151,7 +151,7 @@ void RenderPolyDecal::Render(const TriMatrix &worldToClip, const Vec4f &clipPlan
}
args.uniforms.subsectorDepth = subsectorDepth;
if (swrenderer::RenderViewport::Instance()->r_swtruecolor)
if (swrenderer::RenderViewport::Instance()->RenderTarget->IsBgra())
{
args.uniforms.color = 0xff000000 | decal->AlphaColor;
}

View file

@ -90,7 +90,7 @@ void RenderPolyParticle::Render(const TriMatrix &worldToClip, const Vec4f &clipP
uint32_t alpha = (uint32_t)clamp(particle->alpha * 255.0f + 0.5f, 0.0f, 255.0f);
if (swrenderer::RenderViewport::Instance()->r_swtruecolor)
if (swrenderer::RenderViewport::Instance()->RenderTarget->IsBgra())
{
args.uniforms.color = (alpha << 24) | (particle->color & 0xffffff);
}

View file

@ -94,7 +94,7 @@ void PolySkyDome::RenderRow(PolyDrawArgs &args, int row, uint32_t capcolor)
void PolySkyDome::RenderCapColorRow(PolyDrawArgs &args, FTexture *skytex, int row, bool bottomCap)
{
uint32_t solid = skytex->GetSkyCapColor(bottomCap);
if (!swrenderer::RenderViewport::Instance()->r_swtruecolor)
if (!swrenderer::RenderViewport::Instance()->RenderTarget->IsBgra())
solid = RGB32k.RGB[(RPART(solid) >> 3)][(GPART(solid) >> 3)][(BPART(solid) >> 3)];
args.vinput = &mVertices[mPrimStart[row]];

View file

@ -250,7 +250,7 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, const Vec4f &clipPla
args.SetTexture(tex, thing->Translation, true);
}
if (!swrenderer::RenderViewport::Instance()->r_swtruecolor)
if (!swrenderer::RenderViewport::Instance()->RenderTarget->IsBgra())
{
uint32_t r = (args.uniforms.color >> 16) & 0xff;
uint32_t g = (args.uniforms.color >> 8) & 0xff;

View file

@ -41,7 +41,7 @@ namespace swrenderer
{
SWPixelFormatDrawers *DrawerArgs::Drawers()
{
if (RenderViewport::Instance()->r_swtruecolor)
if (RenderViewport::Instance()->RenderTarget->IsBgra())
{
static SWTruecolorDrawers tc_drawers;
return &tc_drawers;
@ -80,7 +80,7 @@ namespace swrenderer
{
if (mBaseColormap)
{
if (RenderViewport::Instance()->r_swtruecolor)
if (RenderViewport::Instance()->RenderTarget->IsBgra())
return mBaseColormap->Maps;
else
return mBaseColormap->Maps + (GETPALOOKUP(mLight, mShade) << COLORMAPSHIFT);
@ -138,7 +138,7 @@ namespace swrenderer
}
auto viewport = RenderViewport::Instance();
ds_source = viewport->r_swtruecolor ? (const uint8_t*)tex->GetPixelsBgra() : tex->GetPixels();
ds_source = viewport->RenderTarget->IsBgra() ? (const uint8_t*)tex->GetPixelsBgra() : tex->GetPixels();
ds_source_mipmapped = tex->Mipmapped() && tex->GetWidth() > 1 && tex->GetHeight() > 1;
}
@ -147,7 +147,7 @@ namespace swrenderer
auto viewport = RenderViewport::Instance();
// Handle the linear filtered version in a different function to reduce chances of merge conflicts from zdoom.
if (viewport->r_swtruecolor && !drawer_needs_pal_input) // To do: add support to R_DrawColumnHoriz_rgba
if (viewport->RenderTarget->IsBgra() && !drawer_needs_pal_input) // To do: add support to R_DrawColumnHoriz_rgba
{
DrawMaskedColumnBgra(x, iscale, tex, col, spryscale, sprtopscreen, sprflipvert, mfloorclip, mceilingclip, unmasked);
return;
@ -159,7 +159,7 @@ namespace swrenderer
const FTexture::Span *span;
const BYTE *column;
if (viewport->r_swtruecolor && !drawer_needs_pal_input)
if (viewport->RenderTarget->IsBgra() && !drawer_needs_pal_input)
column = (const BYTE *)tex->GetColumnBgra(col >> FRACBITS, &span);
else
column = tex->GetColumn(col >> FRACBITS, &span);
@ -174,7 +174,7 @@ namespace swrenderer
unmaskedSpan[1].Length = 0;
}
int pixelsize = viewport->r_swtruecolor ? 4 : 1;
int pixelsize = viewport->RenderTarget->IsBgra() ? 4 : 1;
while (span->Length != 0)
{
@ -514,7 +514,7 @@ namespace swrenderer
FRemapTable *table = TranslationToTable(translation);
if (table != NULL && !table->Inactive)
{
if (viewport->r_swtruecolor)
if (viewport->RenderTarget->IsBgra())
SetTranslationMap((uint8_t*)table->Palette);
else
SetTranslationMap(table->Remap);
@ -591,7 +591,7 @@ namespace swrenderer
void WallDrawerArgs::SetDest(int x, int y)
{
auto viewport = RenderViewport::Instance();
int pixelsize = viewport->r_swtruecolor ? 4 : 1;
int pixelsize = viewport->RenderTarget->IsBgra() ? 4 : 1;
dc_dest = viewport->dc_destorg + (ylookup[y] + x) * pixelsize;
dc_dest_y = y;
}
@ -726,14 +726,14 @@ namespace swrenderer
void SkyDrawerArgs::SetDest(int x, int y)
{
auto viewport = RenderViewport::Instance();
int pixelsize = viewport->r_swtruecolor ? 4 : 1;
int pixelsize = viewport->RenderTarget->IsBgra() ? 4 : 1;
dc_dest = viewport->dc_destorg + (ylookup[y] + x) * pixelsize;
dc_dest_y = y;
}
void SkyDrawerArgs::SetFrontTexture(FTexture *texture, uint32_t column)
{
if (RenderViewport::Instance()->r_swtruecolor)
if (RenderViewport::Instance()->RenderTarget->IsBgra())
{
dc_source = (const uint8_t *)texture->GetColumnBgra(column, nullptr);
dc_sourceheight = texture->GetHeight();
@ -752,7 +752,7 @@ namespace swrenderer
dc_source2 = nullptr;
dc_sourceheight2 = 1;
}
else if (RenderViewport::Instance()->r_swtruecolor)
else if (RenderViewport::Instance()->RenderTarget->IsBgra())
{
dc_source2 = (const uint8_t *)texture->GetColumnBgra(column, nullptr);
dc_sourceheight2 = texture->GetHeight();
@ -772,7 +772,7 @@ namespace swrenderer
void SpriteDrawerArgs::SetDest(int x, int y)
{
auto viewport = RenderViewport::Instance();
int pixelsize = viewport->r_swtruecolor ? 4 : 1;
int pixelsize = viewport->RenderTarget->IsBgra() ? 4 : 1;
dc_dest = viewport->dc_destorg + (ylookup[y] + x) * pixelsize;
dc_dest_y = y;
}

View file

@ -49,7 +49,7 @@ namespace swrenderer
xoffset += FLOAT2FIXED(xmagnitude * 0.5);
if (!viewport->r_swtruecolor)
if (!viewport->RenderTarget->IsBgra())
{
height = texture->GetHeight();
@ -88,7 +88,7 @@ namespace swrenderer
col = width + (col % width);
}
if (viewport->r_swtruecolor)
if (viewport->RenderTarget->IsBgra())
source = (const uint8_t *)texture->GetColumnBgra(col, nullptr);
else
source = texture->GetColumn(col, nullptr);
@ -240,7 +240,7 @@ namespace swrenderer
drawerargs.dc_num_lights = 0;
}
if (RenderViewport::Instance()->r_swtruecolor)
if (RenderViewport::Instance()->RenderTarget->IsBgra())
{
int count = y2 - y1;
@ -324,7 +324,7 @@ namespace swrenderer
texturemid = 0;
}
drawerargs.dc_wall_fracbits = RenderViewport::Instance()->r_swtruecolor ? FRACBITS : fracbits;
drawerargs.dc_wall_fracbits = RenderViewport::Instance()->RenderTarget->IsBgra() ? FRACBITS : fracbits;
CameraLight *cameraLight = CameraLight::Instance();
bool fixed = (cameraLight->fixedcolormap != NULL || cameraLight->fixedlightlev >= 0);

View file

@ -175,7 +175,7 @@ namespace swrenderer
auto viewport = RenderViewport::Instance();
if (viewport->r_swtruecolor)
if (viewport->RenderTarget->IsBgra())
{
double distance2 = planeheight * yslope[(y + 1 < viewheight) ? y + 1 : y - 1];
double xmagnitude = fabs(ystepscale * (distance2 - distance) * viewport->FocalLengthX);

View file

@ -89,7 +89,6 @@ void FSoftwareRenderer::Init()
{
gl_ParseDefs();
RenderViewport::Instance()->r_swtruecolor = screen->IsBgra();
RenderScene::Instance()->Init();
}
@ -251,8 +250,8 @@ void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoin
{
auto viewport = RenderViewport::Instance();
BYTE *Pixels = viewport->r_swtruecolor ? (BYTE*)tex->GetPixelsBgra() : (BYTE*)tex->GetPixels();
DSimpleCanvas *Canvas = viewport->r_swtruecolor ? tex->GetCanvasBgra() : tex->GetCanvas();
BYTE *Pixels = viewport->RenderTarget->IsBgra() ? (BYTE*)tex->GetPixelsBgra() : (BYTE*)tex->GetPixels();
DSimpleCanvas *Canvas = viewport->RenderTarget->IsBgra() ? tex->GetCanvasBgra() : tex->GetCanvas();
// curse Doom's overuse of global variables in the renderer.
// These get clobbered by rendering to a camera texture but they need to be preserved so the final rendering can be done with the correct palette.
@ -291,7 +290,7 @@ void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoin
}
}
if (viewport->r_swtruecolor)
if (viewport->RenderTarget->IsBgra())
{
// True color render still sometimes uses palette textures (for sprites, mostly).
// We need to make sure that both pixel buffers contain data:

View file

@ -60,7 +60,7 @@ namespace swrenderer
{
realfixedcolormap = &SpecialColormaps[player->fixedcolormap];
auto viewport = RenderViewport::Instance();
if (viewport->RenderTarget == screen && (viewport->r_swtruecolor || ((DFrameBuffer *)screen->Accel2D && r_shadercolormaps)))
if (viewport->RenderTarget == screen && (viewport->RenderTarget->IsBgra() || ((DFrameBuffer *)screen->Accel2D && r_shadercolormaps)))
{
// Render everything fullbright. The copy to video memory will
// apply the special colormap, so it won't be restricted to the

View file

@ -304,7 +304,7 @@ namespace swrenderer
int Ytop = pds->ceilingclip[x - pds->x1];
int Ybottom = pds->floorclip[x - pds->x1];
if (viewport->r_swtruecolor)
if (viewport->RenderTarget->IsBgra())
{
uint32_t *dest = (uint32_t*)viewport->RenderTarget->GetBuffer() + x + Ytop * spacing;
@ -487,7 +487,7 @@ namespace swrenderer
auto viewport = RenderViewport::Instance();
if (viewport->r_swtruecolor) // Assuming this is just a debug function
if (viewport->RenderTarget->IsBgra()) // Assuming this is just a debug function
return;
BYTE color = (BYTE)BestColor((DWORD *)GPalette.BaseColors, 255, 0, 0, 0, 255);

View file

@ -77,14 +77,9 @@ namespace swrenderer
ActiveRatio(width, height, &trueratio);
viewport->SetViewport(width, height, trueratio);
if (viewport->r_swtruecolor != screen->IsBgra())
{
viewport->r_swtruecolor = screen->IsBgra();
}
if (r_clearbuffer != 0)
{
if (!viewport->r_swtruecolor)
if (!viewport->RenderTarget->IsBgra())
{
memset(viewport->RenderTarget->GetBuffer(), clearcolor, viewport->RenderTarget->GetPitch() * viewport->RenderTarget->GetHeight());
}
@ -103,7 +98,7 @@ namespace swrenderer
RenderActorView(player->mo);
// Apply special colormap if the target cannot do it
if (CameraLight::Instance()->realfixedcolormap && viewport->r_swtruecolor && !(r_shadercolormaps && screen->Accel2D))
if (CameraLight::Instance()->realfixedcolormap && viewport->RenderTarget->IsBgra() && !(r_shadercolormaps && screen->Accel2D))
{
DrawerCommandQueue::QueueCommand<ApplySpecialColormapRGBACommand>(CameraLight::Instance()->realfixedcolormap, screen);
}
@ -188,7 +183,7 @@ namespace swrenderer
// If we don't want shadered colormaps, NULL it now so that the
// copy to the screen does not use a special colormap shader.
if (!r_shadercolormaps && !RenderViewport::Instance()->r_swtruecolor)
if (!r_shadercolormaps && !RenderViewport::Instance()->RenderTarget->IsBgra())
{
CameraLight::Instance()->realfixedcolormap = NULL;
}
@ -199,12 +194,6 @@ namespace swrenderer
auto viewport = RenderViewport::Instance();
const bool savedviewactive = viewactive;
const bool savedoutputformat = viewport->r_swtruecolor;
if (viewport->r_swtruecolor != canvas->IsBgra())
{
viewport->r_swtruecolor = canvas->IsBgra();
}
R_BeginDrawerCommands();
@ -233,7 +222,6 @@ namespace swrenderer
screen->Unlock();
viewactive = savedviewactive;
viewport->r_swtruecolor = savedoutputformat;
}
void RenderScene::ScreenResized()

View file

@ -129,7 +129,7 @@ namespace swrenderer
static BYTE *lastbuff = NULL;
int pitch = RenderTarget->GetPitch();
int pixelsize = r_swtruecolor ? 4 : 1;
int pixelsize = RenderTarget->IsBgra() ? 4 : 1;
BYTE *lineptr = RenderTarget->GetBuffer() + (viewwindowy*pitch + viewwindowx) * pixelsize;
if (dc_pitch != pitch || lineptr != lastbuff)

View file

@ -37,7 +37,6 @@ namespace swrenderer
double CenterY = 0.0;
double YaspectMul = 0.0;
double IYaspectMul = 0.0;
bool r_swtruecolor = false;
double globaluclip = 0.0;
double globaldclip = 0.0;

View file

@ -239,7 +239,7 @@ namespace swrenderer
RenderTranslucentPass *translucentPass = RenderTranslucentPass::Instance();
if (viewport->r_swtruecolor)
if (viewport->RenderTarget->IsBgra())
{
for (int x = x1; x < (x1 + countbase); x++, fracposx += fracstepx)
{

View file

@ -251,17 +251,19 @@ namespace swrenderer
double dy = (view_origin.Y - sprite_origin.Y) / sprite_xscale;
int backX = (int)(dx * spriteCos - dy * spriteSin + mip.Pivot.X);
int backY = (int)(dy * spriteCos + dx * spriteSin + mip.Pivot.Y);
int endX = clamp(backX, 0, mip.SizeX - 1);
int endY = clamp(backY, 0, mip.SizeY - 1);
//int endX = clamp(backX, 0, mip.SizeX - 1);
//int endY = clamp(backY, 0, mip.SizeY - 1);
int endX = mip.SizeX - 1;// clamp(backX, 0, mip.SizeX - 1);
int endY = mip.SizeY - 1;// clamp(backY, 0, mip.SizeY - 1);
// Draw the voxel cube:
for (int index = 0; index < 4; index++)
for (int index = 0; index < 1; index++)
{
if ((stepX[index] < 0 && endX >= startX[index]) ||
/*if ((stepX[index] < 0 && endX >= startX[index]) ||
(stepX[index] > 0 && endX <= startX[index]) ||
(stepY[index] < 0 && endY >= startY[index]) ||
(stepY[index] > 0 && endY <= startY[index])) continue;
(stepY[index] > 0 && endY <= startY[index])) continue;*/
for (int x = startX[index]; x != endX; x += stepX[index])
{
@ -346,7 +348,7 @@ namespace swrenderer
int y1 = MAX((int)(screenY - screenExtentY), 0);
int y2 = MIN((int)(screenY + screenExtentY + 0.5f), viewheight - 1);
int pixelsize = viewport->r_swtruecolor ? 4 : 1;
int pixelsize = viewport->RenderTarget->IsBgra() ? 4 : 1;
if (y1 < y2)
{

View file

@ -149,7 +149,7 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms)
auto viewport = RenderViewport::Instance();
viewport->r_swtruecolor = IsBgra();
viewport->RenderTarget = screen;
if (APART(parms.colorOverlay) != 0)
{
@ -167,7 +167,7 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms)
parms.colorOverlay = PalEntry(parms.colorOverlay).InverseColor();
}
// Note that this overrides DTA_Translation in software, but not in hardware.
if (!viewport->r_swtruecolor)
if (!viewport->RenderTarget->IsBgra())
{
FDynamicColormap *colormap = GetSpecialLights(MAKERGB(255, 255, 255),
parms.colorOverlay & MAKEARGB(0, 255, 255, 255), 0);
@ -176,7 +176,7 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms)
}
else if (parms.remap != NULL)
{
if (viewport->r_swtruecolor)
if (viewport->RenderTarget->IsBgra())
translation = (const BYTE*)parms.remap->Palette;
else
translation = parms.remap->Remap;
@ -190,7 +190,7 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms)
}
else
{
if (viewport->r_swtruecolor)
if (viewport->RenderTarget->IsBgra())
drawerargs.SetTranslationMap(nullptr);
else
drawerargs.SetTranslationMap(identitymap);
@ -198,7 +198,7 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms)
bool visible;
FDynamicColormap *basecolormap = nullptr;
if (viewport->r_swtruecolor)
if (viewport->RenderTarget->IsBgra())
visible = drawerargs.SetPatchStyle(parms.style, parms.Alpha, -1, parms.fillcolor, basecolormap);
else
visible = drawerargs.SetPatchStyle(parms.style, parms.Alpha, 0, parms.fillcolor, basecolormap);