Change RenderTranslucentPass to be a singleton

This commit is contained in:
Magnus Norddahl 2017-01-26 08:36:28 +01:00
parent 8b0304c1e3
commit 34f85569b4
8 changed files with 31 additions and 20 deletions

View File

@ -239,7 +239,7 @@ namespace swrenderer
// Masked textures and planes need the view coordinates restored for proper positioning. // Masked textures and planes need the view coordinates restored for proper positioning.
viewposStack.Pop(ViewPos); viewposStack.Pop(ViewPos);
RenderTranslucentPass::Render(); RenderTranslucentPass::Instance()->Render();
drawseglist->ds_p = drawseglist->firstdrawseg; drawseglist->ds_p = drawseglist->firstdrawseg;
@ -458,7 +458,7 @@ namespace swrenderer
NetUpdate(); NetUpdate();
MaskedCycles.Clock(); // [ZZ] count sprites in portals/mirrors along with normal ones. MaskedCycles.Clock(); // [ZZ] count sprites in portals/mirrors along with normal ones.
RenderTranslucentPass::Render(); // this is required since with portals there often will be cases when more than 80% of the view is inside a portal. RenderTranslucentPass::Instance()->Render(); // this is required since with portals there often will be cases when more than 80% of the view is inside a portal.
MaskedCycles.Unclock(); MaskedCycles.Unclock();
NetUpdate(); NetUpdate();

View File

@ -134,7 +134,7 @@ namespace swrenderer
RenderClipSegment::Instance()->Clear(0, viewwidth); RenderClipSegment::Instance()->Clear(0, viewwidth);
DrawSegmentList::Instance()->Clear(); DrawSegmentList::Instance()->Clear();
VisiblePlaneList::Instance()->Clear(); VisiblePlaneList::Instance()->Clear();
RenderTranslucentPass::Clear(); RenderTranslucentPass::Instance()->Clear();
// opening / clipping determination // opening / clipping determination
RenderOpaquePass::Instance()->ClearClip(); RenderOpaquePass::Instance()->ClearClip();
@ -182,7 +182,7 @@ namespace swrenderer
NetUpdate(); NetUpdate();
MaskedCycles.Clock(); MaskedCycles.Clock();
RenderTranslucentPass::Render(); RenderTranslucentPass::Instance()->Render();
MaskedCycles.Unclock(); MaskedCycles.Unclock();
NetUpdate(); NetUpdate();
@ -267,7 +267,7 @@ namespace swrenderer
void RenderScene::Deinit() void RenderScene::Deinit()
{ {
RenderTranslucentPass::Deinit(); RenderTranslucentPass::Instance()->Deinit();
Clip3DFloors::Instance()->Cleanup(); Clip3DFloors::Instance()->Cleanup();
DrawSegmentList::Instance()->Deinit(); DrawSegmentList::Instance()->Deinit();
} }

View File

@ -47,8 +47,11 @@ CVAR(Bool, r_fullbrightignoresectorcolor, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG
namespace swrenderer namespace swrenderer
{ {
bool RenderTranslucentPass::DrewAVoxel; RenderTranslucentPass *RenderTranslucentPass::Instance()
TArray<DrawSegment *> RenderTranslucentPass::portaldrawsegs; {
static RenderTranslucentPass instance;
return &instance;
}
void RenderTranslucentPass::Deinit() void RenderTranslucentPass::Deinit()
{ {

View File

@ -28,18 +28,20 @@ namespace swrenderer
class RenderTranslucentPass class RenderTranslucentPass
{ {
public: public:
static void Deinit(); static RenderTranslucentPass *Instance();
static void Clear();
static void Render();
static bool DrewAVoxel; void Deinit();
void Clear();
void Render();
static bool ClipSpriteColumnWithPortals(int x, VisibleSprite *spr); bool DrewAVoxel = false;
bool ClipSpriteColumnWithPortals(int x, VisibleSprite *spr);
private: private:
static void CollectPortals(); void CollectPortals();
static void DrawMaskedSingle(bool renew); void DrawMaskedSingle(bool renew);
static TArray<DrawSegment *> portaldrawsegs; TArray<DrawSegment *> portaldrawsegs;
}; };
} }

View File

@ -236,11 +236,13 @@ namespace swrenderer
uint32_t fracstepx = PARTICLE_TEXTURE_SIZE * FRACUNIT / countbase; uint32_t fracstepx = PARTICLE_TEXTURE_SIZE * FRACUNIT / countbase;
uint32_t fracposx = fracstepx / 2; uint32_t fracposx = fracstepx / 2;
RenderTranslucentPass *translucentPass = RenderTranslucentPass::Instance();
if (r_swtruecolor) if (r_swtruecolor)
{ {
for (int x = x1; x < (x1 + countbase); x++, fracposx += fracstepx) for (int x = x1; x < (x1 + countbase); x++, fracposx += fracstepx)
{ {
if (RenderTranslucentPass::ClipSpriteColumnWithPortals(x, vis)) if (translucentPass->ClipSpriteColumnWithPortals(x, vis))
continue; continue;
uint32_t *dest = ylookup[yl] + x + (uint32_t*)dc_destorg; uint32_t *dest = ylookup[yl] + x + (uint32_t*)dc_destorg;
DrawerCommandQueue::QueueCommand<DrawParticleColumnRGBACommand>(dest, yl, spacing, ycount, fg, alpha, fracposx); DrawerCommandQueue::QueueCommand<DrawParticleColumnRGBACommand>(dest, yl, spacing, ycount, fg, alpha, fracposx);
@ -250,7 +252,7 @@ namespace swrenderer
{ {
for (int x = x1; x < (x1 + countbase); x++, fracposx += fracstepx) for (int x = x1; x < (x1 + countbase); x++, fracposx += fracstepx)
{ {
if (RenderTranslucentPass::ClipSpriteColumnWithPortals(x, vis)) if (translucentPass->ClipSpriteColumnWithPortals(x, vis))
continue; continue;
uint8_t *dest = ylookup[yl] + x + dc_destorg; uint8_t *dest = ylookup[yl] + x + dc_destorg;
DrawerCommandQueue::QueueCommand<DrawParticleColumnPalCommand>(dest, yl, spacing, ycount, fg, alpha, fracposx); DrawerCommandQueue::QueueCommand<DrawParticleColumnPalCommand>(dest, yl, spacing, ycount, fg, alpha, fracposx);

View File

@ -288,9 +288,11 @@ namespace swrenderer
if (x < x2) if (x < x2)
{ {
RenderTranslucentPass *translucentPass = RenderTranslucentPass::Instance();
while (x < x2) while (x < x2)
{ {
if (!RenderTranslucentPass::ClipSpriteColumnWithPortals(x, vis)) if (!translucentPass->ClipSpriteColumnWithPortals(x, vis))
R_DrawMaskedColumn(x, iscale, tex, frac, spryscale, sprtopscreen, sprflipvert, mfloorclip, mceilingclip, false); R_DrawMaskedColumn(x, iscale, tex, frac, spryscale, sprtopscreen, sprflipvert, mfloorclip, mceilingclip, false);
x++; x++;
frac += xiscale; frac += xiscale;

View File

@ -178,7 +178,7 @@ namespace swrenderer
vis->Light.SetColormap(r_SpriteVisibility / MAX(tz, MINZ), spriteshade, basecolormap, fullbright, invertcolormap, fadeToBlack); vis->Light.SetColormap(r_SpriteVisibility / MAX(tz, MINZ), spriteshade, basecolormap, fullbright, invertcolormap, fadeToBlack);
VisibleSpriteList::Instance()->Push(vis); VisibleSpriteList::Instance()->Push(vis);
RenderTranslucentPass::DrewAVoxel = true; RenderTranslucentPass::Instance()->DrewAVoxel = true;
} }
void RenderVoxel::Render(short *cliptop, short *clipbottom, int minZ, int maxZ) void RenderVoxel::Render(short *cliptop, short *clipbottom, int minZ, int maxZ)

View File

@ -226,13 +226,15 @@ namespace swrenderer
} }
else else
{ {
RenderTranslucentPass *translucentPass = RenderTranslucentPass::Instance();
while (x < x2) while (x < x2)
{ {
if (calclighting) if (calclighting)
{ // calculate lighting { // calculate lighting
R_SetColorMapLight(usecolormap, light, shade); R_SetColorMapLight(usecolormap, light, shade);
} }
if (!RenderTranslucentPass::ClipSpriteColumnWithPortals(x, spr)) if (!translucentPass->ClipSpriteColumnWithPortals(x, spr))
DrawColumn(x, WallSpriteTile, walltexcoords, texturemid, maskedScaleY, sprflipvert, mfloorclip, mceilingclip); DrawColumn(x, WallSpriteTile, walltexcoords, texturemid, maskedScaleY, sprflipvert, mfloorclip, mceilingclip);
light += lightstep; light += lightstep;
x++; x++;