- fixed stencil cap generation for old hardware and changed it so that it only gets done once for each stencil setup, not for each stencil pass.

This commit is contained in:
Christoph Oelckers 2018-11-17 15:34:23 +01:00
parent bb4007f16a
commit 160f17a907
2 changed files with 33 additions and 16 deletions

View file

@ -185,6 +185,33 @@ void HWPortal::DrawPortalStencil(FRenderState &state, int pass)
mPrimIndices[i * 2] = lines[i].vertindex;
mPrimIndices[i * 2 + 1] = lines[i].vertcount;
}
if (NeedCap() && lines.Size() > 1 && planesused != 0)
{
screen->mVertexData->Map();
if (planesused & (1 << sector_t::floor))
{
auto verts = screen->mVertexData->AllocVertices(4);
auto ptr = verts.first;
ptr[0].Set((float)boundingBox.left, -32767.f, (float)boundingBox.top, 0, 0);
ptr[1].Set((float)boundingBox.right, -32767.f, (float)boundingBox.top, 0, 0);
ptr[2].Set((float)boundingBox.left, -32767.f, (float)boundingBox.bottom, 0, 0);
ptr[3].Set((float)boundingBox.right, -32767.f, (float)boundingBox.bottom, 0, 0);
mBottomCap = verts.second;
}
if (planesused & (1 << sector_t::ceiling))
{
auto verts = screen->mVertexData->AllocVertices(4);
auto ptr = verts.first;
ptr[0].Set((float)boundingBox.left, 32767.f, (float)boundingBox.top, 0, 0);
ptr[1].Set((float)boundingBox.right, 32767.f, (float)boundingBox.top, 0, 0);
ptr[2].Set((float)boundingBox.left, 32767.f, (float)boundingBox.bottom, 0, 0);
ptr[3].Set((float)boundingBox.right, 32767.f, (float)boundingBox.bottom, 0, 0);
mTopCap = verts.second;
}
screen->mVertexData->Unmap();
}
}
for (unsigned int i = 0; i < mPrimIndices.Size(); i += 2)
@ -196,26 +223,15 @@ void HWPortal::DrawPortalStencil(FRenderState &state, int pass)
// The cap's depth handling needs special treatment so that it won't block further portal caps.
if (pass == STP_DepthRestore) state.SetDepthRange(1, 1);
if (planesused & (1 << sector_t::floor))
if (mBottomCap != ~0u)
{
auto verts = screen->mVertexData->AllocVertices(4);
auto ptr = verts.first;
ptr[0].Set((float)boundingBox.left, -32767.f, (float)boundingBox.top, 0, 0);
ptr[1].Set((float)boundingBox.right, -32767.f, (float)boundingBox.top, 0, 0);
ptr[2].Set((float)boundingBox.left, -32767.f, (float)boundingBox.bottom, 0, 0);
ptr[3].Set((float)boundingBox.right, -32767.f, (float)boundingBox.bottom, 0, 0);
state.Draw(DT_TriangleStrip, verts.second, 4, false);
state.Draw(DT_TriangleStrip, mBottomCap, 4, false);
}
if (planesused & (1 << sector_t::ceiling))
if (mTopCap != ~0u)
{
auto verts = screen->mVertexData->AllocVertices(4);
auto ptr = verts.first;
ptr[0].Set((float)boundingBox.left, 32767.f, (float)boundingBox.top, 0, 0);
ptr[1].Set((float)boundingBox.right, 32767.f, (float)boundingBox.top, 0, 0);
ptr[2].Set((float)boundingBox.left, 32767.f, (float)boundingBox.bottom, 0, 0);
ptr[3].Set((float)boundingBox.right, 32767.f, (float)boundingBox.bottom, 0, 0);
state.Draw(DT_TriangleStrip, verts.second, 4, false);
state.Draw(DT_TriangleStrip, mTopCap, 4, false);
}
if (pass == STP_DepthRestore) state.SetDepthRange(0, 1);
}
}

View file

@ -55,6 +55,7 @@ class HWPortal
ActorRenderFlags savedvisibility;
TArray<unsigned int> mPrimIndices;
unsigned int mTopCap = ~0u, mBottomCap = ~0u;
void DrawPortalStencil(FRenderState &state, int pass);