Skip to content

Commit

Permalink
take most direct drawinfo references out of HWWall.
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Oct 25, 2023
1 parent 1f5df23 commit eeac40f
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 33 deletions.
15 changes: 9 additions & 6 deletions src/rendering/hwrenderer/scene/hw_drawlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "hw_renderstate.h"
#include "hw_drawinfo.h"
#include "hw_fakeflat.h"
#include "hw_walldispatcher.h"

FMemArena RenderDataAllocator(1024*1024); // Use large blocks to reduce allocation time.

Expand Down Expand Up @@ -304,8 +305,8 @@ void HWDrawList::SortWallIntoPlane(HWDrawInfo* di, SortNode * head, SortNode * s
w->tcs[HWWall::UPLFT].v = ws->tcs[HWWall::LOLFT].v = w->tcs[HWWall::UPRGT].v = ws->tcs[HWWall::LORGT].v = newtexv;
w->lightuv[HWWall::UPLFT].v = ws->lightuv[HWWall::LOLFT].v = w->lightuv[HWWall::UPRGT].v = ws->lightuv[HWWall::LORGT].v = newlmv;
}
w->MakeVertices(di, false);
ws->MakeVertices(di, false);
w->MakeVertices(false);
ws->MakeVertices(false);
}

SortNode * sort2 = SortNodes.GetNew();
Expand Down Expand Up @@ -451,8 +452,8 @@ void HWDrawList::SortWallIntoWall(HWDrawInfo *di, SortNode * head,SortNode * sor
w->zbottom[0]=ws->zbottom[1]=izb;
w->tcs[HWWall::LOLFT].u = w->tcs[HWWall::UPLFT].u = ws->tcs[HWWall::LORGT].u = ws->tcs[HWWall::UPRGT].u = iu;
w->lightuv[HWWall::LOLFT].u = w->lightuv[HWWall::UPLFT].u = ws->lightuv[HWWall::LORGT].u = ws->lightuv[HWWall::UPRGT].u = iu;
ws->MakeVertices(di, false);
w->MakeVertices(di, false);
ws->MakeVertices(false);
w->MakeVertices(false);

SortNode * sort2=SortNodes.GetNew();
memset(sort2,0,sizeof(SortNode));
Expand Down Expand Up @@ -808,8 +809,9 @@ void HWDrawList::DoDraw(HWDrawInfo *di, FRenderState &state, bool translucent, i
case DrawType_WALL:
{
HWWall * w= walls[drawitems[i].index];
HWWallDispatcher dis(di);
RenderWall.Clock();
w->DrawWall(di, state, translucent);
w->DrawWall(&dis, state, translucent);
RenderWall.Unclock();
}
break;
Expand Down Expand Up @@ -845,10 +847,11 @@ void HWDrawList::Draw(HWDrawInfo *di, FRenderState &state, bool translucent)
//==========================================================================
void HWDrawList::DrawWalls(HWDrawInfo *di, FRenderState &state, bool translucent)
{
HWWallDispatcher dis(di);
RenderWall.Clock();
for (auto &item : drawitems)
{
walls[item.index]->DrawWall(di, state, translucent);
walls[item.index]->DrawWall(&dis, state, translucent);
}
RenderWall.Unclock();
}
Expand Down
2 changes: 1 addition & 1 deletion src/rendering/hwrenderer/scene/hw_drawlistadd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void HWDrawInfo::AddMirrorSurface(HWWall *w)
auto tcs = newwall->tcs;
tcs[HWWall::LOLFT].u = tcs[HWWall::LORGT].u = tcs[HWWall::UPLFT].u = tcs[HWWall::UPRGT].u = v.X;
tcs[HWWall::LOLFT].v = tcs[HWWall::LORGT].v = tcs[HWWall::UPLFT].v = tcs[HWWall::UPRGT].v = v.Z;
newwall->MakeVertices(this, false);
newwall->MakeVertices(false);

bool hasDecals = newwall->seg->sidedef && newwall->seg->sidedef->AttachedDecals;
if (hasDecals && Level->HasDynamicLights && !isFullbrightScene())
Expand Down
14 changes: 7 additions & 7 deletions src/rendering/hwrenderer/scene/hw_drawstructs.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class HWWall

void SetupLights(HWDrawInfo* di, FDynLightData& lightdata);

void MakeVertices(HWDrawInfo* di, bool nosplit);
void MakeVertices(bool nosplit);

void SkyPlane(HWWallDispatcher* di, sector_t* sector, int plane, bool allowmirror);
void SkyLine(HWWallDispatcher* di, sector_t* sec, line_t* line);
Expand Down Expand Up @@ -280,11 +280,11 @@ class HWWall

int CountVertices();

void RenderWall(HWDrawInfo* di, FRenderState& state, int textured);
void RenderFogBoundary(HWDrawInfo* di, FRenderState& state);
void RenderMirrorSurface(HWDrawInfo* di, FRenderState& state);
void RenderTexturedWall(HWDrawInfo* di, FRenderState& state, int rflags);
void RenderTranslucentWall(HWDrawInfo* di, FRenderState& state);
void RenderWall(FRenderState& state, int textured);
void RenderFogBoundary(HWWallDispatcher* di, FRenderState& state);
void RenderMirrorSurface(HWWallDispatcher* di, FRenderState& state);
void RenderTexturedWall(HWWallDispatcher* di, FRenderState& state, int rflags);
void RenderTranslucentWall(HWWallDispatcher* di, FRenderState& state);
void DrawDecalsForMirror(HWDrawInfo* di, FRenderState& state, TArray<HWDecal*>& decals);

public:
Expand All @@ -296,7 +296,7 @@ class HWWall
return -((y - glseg.y1) * (glseg.x2 - glseg.x1) - (x - glseg.x1) * (glseg.y2 - glseg.y1));
}

void DrawWall(HWDrawInfo* di, FRenderState& state, bool translucent);
void DrawWall(HWWallDispatcher* di, FRenderState& state, bool translucent);

};

Expand Down
36 changes: 18 additions & 18 deletions src/rendering/hwrenderer/scene/hw_walls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void SetSplitPlanes(FRenderState& state, const secplane_t& top, const secplane_t
//
//==========================================================================

void HWWall::RenderWall(HWDrawInfo*di, FRenderState &state, int textured)
void HWWall::RenderWall(FRenderState &state, int textured)
{
assert(vertcount > 0);
state.SetLightIndex(dynlightindex);
Expand All @@ -95,7 +95,7 @@ void HWWall::RenderWall(HWDrawInfo*di, FRenderState &state, int textured)
//
//==========================================================================

void HWWall::RenderFogBoundary(HWDrawInfo*di, FRenderState &state)
void HWWall::RenderFogBoundary(HWWallDispatcher*di, FRenderState &state)
{
if (gl_fogmode && !di->isFullbrightScene())
{
Expand All @@ -105,7 +105,7 @@ void HWWall::RenderFogBoundary(HWDrawInfo*di, FRenderState &state)
state.SetEffect(EFF_FOGBOUNDARY);
state.AlphaFunc(Alpha_GEqual, 0.f);
state.SetDepthBias(-1, -128);
RenderWall(di, state, HWWall::RWF_BLANK);
RenderWall(state, HWWall::RWF_BLANK);
state.ClearDepthBias();
state.SetEffect(EFF_NONE);
state.EnableDrawBufferAttachments(true);
Expand All @@ -118,7 +118,7 @@ void HWWall::RenderFogBoundary(HWDrawInfo*di, FRenderState &state)
//
//
//==========================================================================
void HWWall::RenderMirrorSurface(HWDrawInfo*di, FRenderState &state)
void HWWall::RenderMirrorSurface(HWWallDispatcher*di, FRenderState &state)
{
if (!TexMan.mirrorTexture.isValid()) return;

Expand All @@ -138,7 +138,7 @@ void HWWall::RenderMirrorSurface(HWDrawInfo*di, FRenderState &state)
state.SetMaterial(tex, UF_None, 0, CLAMP_NONE, 0, -1); // do not upscale the mirror texture.

flags &= ~HWWall::HWF_GLOW;
RenderWall(di, state, HWWall::RWF_BLANK);
RenderWall(state, HWWall::RWF_BLANK);

state.EnableTextureMatrix(false);
state.SetEffect(EFF_NONE);
Expand All @@ -149,9 +149,9 @@ void HWWall::RenderMirrorSurface(HWDrawInfo*di, FRenderState &state)
// This is drawn in the translucent pass which is done after the decal pass
// As a result the decals have to be drawn here, right after the wall they are on,
// because the depth buffer won't get set by translucent items.
if (seg->sidedef->AttachedDecals)
if (di->di && seg->sidedef->AttachedDecals)
{
DrawDecalsForMirror(di, state, di->Decals[1]);
DrawDecalsForMirror(di->di, state, di->di->Decals[1]);
}
state.SetRenderStyle(STYLE_Translucent);
}
Expand Down Expand Up @@ -180,7 +180,7 @@ static const uint8_t renderwalltotier[] =
CVAR(Bool, hw_npottest, false, 0)
#endif

void HWWall::RenderTexturedWall(HWDrawInfo*di, FRenderState &state, int rflags)
void HWWall::RenderTexturedWall(HWWallDispatcher*di, FRenderState &state, int rflags)
{
int tmode = state.GetTextureMode();
int rel = rellight + getExtraLight();
Expand Down Expand Up @@ -266,7 +266,7 @@ void HWWall::RenderTexturedWall(HWDrawInfo*di, FRenderState &state, int rflags)
{
if (type != RENDERWALL_M2SNF) SetFog(state, di->Level, di->lightmode, lightlevel, rel, di->isFullbrightScene(), &Colormap, RenderStyle == STYLE_Add);
SetColor(state, di->Level, di->lightmode, lightlevel, rel, di->isFullbrightScene(), Colormap, absalpha);
RenderWall(di, state, rflags);
RenderWall(state, rflags);
}
else
{
Expand All @@ -289,7 +289,7 @@ void HWWall::RenderTexturedWall(HWDrawInfo*di, FRenderState &state, int rflags)
SetColor(state, di->Level, di->lightmode, thisll, rel, false, thiscm, absalpha);
if (type != RENDERWALL_M2SNF) SetFog(state, di->Level, di->lightmode, thisll, rel, false, &thiscm, RenderStyle == STYLE_Add);
SetSplitPlanes(state, (*lightlist)[i].plane, lowplane);
RenderWall(di, state, rflags);
RenderWall(state, rflags);
}
if (low1 <= zbottom[0] && low2 <= zbottom[1]) break;
}
Expand All @@ -313,7 +313,7 @@ void HWWall::RenderTexturedWall(HWDrawInfo*di, FRenderState &state, int rflags)
//
//==========================================================================

void HWWall::RenderTranslucentWall(HWDrawInfo*di, FRenderState &state)
void HWWall::RenderTranslucentWall(HWWallDispatcher*di, FRenderState &state)
{
state.SetRenderStyle(RenderStyle);
if (texture)
Expand All @@ -328,7 +328,7 @@ void HWWall::RenderTranslucentWall(HWDrawInfo*di, FRenderState &state)
SetColor(state, di->Level, di->lightmode, lightlevel, 0, false, Colormap, fabsf(alpha));
SetFog(state, di->Level, di->lightmode, lightlevel, 0, false, &Colormap, RenderStyle == STYLE_Add);
state.EnableTexture(false);
RenderWall(di, state, HWWall::RWF_NOSPLIT);
RenderWall(state, HWWall::RWF_NOSPLIT);
state.EnableTexture(true);
}
state.SetRenderStyle(STYLE_Translucent);
Expand All @@ -339,15 +339,15 @@ void HWWall::RenderTranslucentWall(HWDrawInfo*di, FRenderState &state)
//
//
//==========================================================================
void HWWall::DrawWall(HWDrawInfo*di, FRenderState &state, bool translucent)
void HWWall::DrawWall(HWWallDispatcher*di, FRenderState &state, bool translucent)
{
if (screen->BuffersArePersistent())
{
if (di->Level->HasDynamicLights && !di->isFullbrightScene() && texture != nullptr)
if (di->di && di->Level->HasDynamicLights && !di->isFullbrightScene() && texture != nullptr)
{
SetupLights(di, lightdata);
SetupLights(di->di, lightdata);
}
MakeVertices(di, !!(flags & HWWall::HWF_TRANSLUCENT));
MakeVertices(!!(flags & HWWall::HWF_TRANSLUCENT));
}

state.SetNormal(glseg.Normal());
Expand Down Expand Up @@ -532,7 +532,7 @@ void HWWall::PutWall(HWWallDispatcher *di, bool translucent)
{
SetupLights(ddi, lightdata);
}
MakeVertices(ddi, translucent);
MakeVertices(translucent);
}


Expand Down Expand Up @@ -580,7 +580,7 @@ void HWWall::PutPortal(HWWallDispatcher *di, int ptype, int plane)
auto ddi = di->di;
if (ddi)
{
MakeVertices(ddi, false);
MakeVertices(false);
switch (ptype)
{
// portals don't go into the draw list.
Expand Down
2 changes: 1 addition & 1 deletion src/rendering/hwrenderer/scene/hw_walls_vertex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ int HWWall::CountVertices()
//
//==========================================================================

void HWWall::MakeVertices(HWDrawInfo *di, bool nosplit)
void HWWall::MakeVertices(bool nosplit)
{
if (vertcount == 0)
{
Expand Down

0 comments on commit eeac40f

Please sign in to comment.