mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 15:22:15 +00:00
Remove TriDrawVariant
This commit is contained in:
parent
99435f5018
commit
adb65ce72a
11 changed files with 83 additions and 98 deletions
|
@ -251,17 +251,6 @@ struct TriDrawTriangleArgs
|
||||||
const uint8_t *BaseColors;
|
const uint8_t *BaseColors;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class TriDrawVariant
|
|
||||||
{
|
|
||||||
DrawNormal,
|
|
||||||
FillNormal,
|
|
||||||
DrawSubsector,
|
|
||||||
FillSubsector,
|
|
||||||
FuzzSubsector,
|
|
||||||
Stencil,
|
|
||||||
StencilClose
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class TriBlendMode
|
enum class TriBlendMode
|
||||||
{
|
{
|
||||||
Copy, // blend_copy(shade(fg))
|
Copy, // blend_copy(shade(fg))
|
||||||
|
|
|
@ -167,5 +167,9 @@ void RenderPolyDecal::Render(const TriMatrix &worldToClip, const Vec4f &clipPlan
|
||||||
args.stencilwritevalue = stencilValue;
|
args.stencilwritevalue = stencilValue;
|
||||||
//mode = R_SetPatchStyle (decal->RenderStyle, (float)decal->Alpha, decal->Translation, decal->AlphaColor);
|
//mode = R_SetPatchStyle (decal->RenderStyle, (float)decal->Alpha, decal->Translation, decal->AlphaColor);
|
||||||
args.SetClipPlane(clipPlane.x, clipPlane.y, clipPlane.z, clipPlane.w);
|
args.SetClipPlane(clipPlane.x, clipPlane.y, clipPlane.z, clipPlane.w);
|
||||||
PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::Shaded);
|
args.blendmode = TriBlendMode::Shaded;
|
||||||
|
args.subsectorTest = true;
|
||||||
|
args.writeStencil = false;
|
||||||
|
args.writeSubsector = false;
|
||||||
|
PolyTriangleDrawer::draw(args);
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,5 +105,9 @@ void RenderPolyParticle::Render(const TriMatrix &worldToClip, const Vec4f &clipP
|
||||||
args.stencilwritevalue = stencilValue;
|
args.stencilwritevalue = stencilValue;
|
||||||
args.SetColormap(sub->sector->ColorMap);
|
args.SetColormap(sub->sector->ColorMap);
|
||||||
args.SetClipPlane(clipPlane.x, clipPlane.y, clipPlane.z, clipPlane.w);
|
args.SetClipPlane(clipPlane.x, clipPlane.y, clipPlane.z, clipPlane.w);
|
||||||
PolyTriangleDrawer::draw(args, TriDrawVariant::FillSubsector, TriBlendMode::AlphaBlend);
|
args.subsectorTest = true;
|
||||||
|
args.writeStencil = false;
|
||||||
|
args.writeSubsector = false;
|
||||||
|
args.blendmode = TriBlendMode::AlphaBlend;
|
||||||
|
PolyTriangleDrawer::draw(args);
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,8 +143,8 @@ void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, const Vec4f &c
|
||||||
args.SetTexture(tex);
|
args.SetTexture(tex);
|
||||||
args.SetColormap(sub->sector->ColorMap);
|
args.SetColormap(sub->sector->ColorMap);
|
||||||
args.SetClipPlane(clipPlane.x, clipPlane.y, clipPlane.z, clipPlane.w);
|
args.SetClipPlane(clipPlane.x, clipPlane.y, clipPlane.z, clipPlane.w);
|
||||||
PolyTriangleDrawer::draw(args, TriDrawVariant::DrawNormal, TriBlendMode::Copy);
|
args.blendmode = TriBlendMode::Copy;
|
||||||
PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy);
|
PolyTriangleDrawer::draw(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderPolyPlane::Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, PolyCull &cull, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, double skyHeight, std::vector<std::unique_ptr<PolyDrawSectorPortal>> §orPortals)
|
void RenderPolyPlane::Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, PolyCull &cull, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, double skyHeight, std::vector<std::unique_ptr<PolyDrawSectorPortal>> §orPortals)
|
||||||
|
@ -341,13 +341,15 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, const Vec4f &clipPlan
|
||||||
if (!portal)
|
if (!portal)
|
||||||
{
|
{
|
||||||
args.SetTexture(tex);
|
args.SetTexture(tex);
|
||||||
PolyTriangleDrawer::draw(args, TriDrawVariant::DrawNormal, TriBlendMode::Copy);
|
args.blendmode = TriBlendMode::Copy;
|
||||||
PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy);
|
PolyTriangleDrawer::draw(args);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
args.stencilwritevalue = polyportal->StencilValue;
|
args.stencilwritevalue = polyportal->StencilValue;
|
||||||
PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy);
|
args.writeColor = false;
|
||||||
|
args.writeSubsector = false;
|
||||||
|
PolyTriangleDrawer::draw(args);
|
||||||
polyportal->Shape.push_back({ args.vinput, args.vcount, args.ccw, subsectorDepth });
|
polyportal->Shape.push_back({ args.vinput, args.vcount, args.ccw, subsectorDepth });
|
||||||
polyportal->Segments.insert(polyportal->Segments.end(), portalSegments.begin(), portalSegments.end());
|
polyportal->Segments.insert(polyportal->Segments.end(), portalSegments.begin(), portalSegments.end());
|
||||||
}
|
}
|
||||||
|
@ -365,7 +367,9 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, const Vec4f &clipPlan
|
||||||
args.stencilwritevalue = 255;
|
args.stencilwritevalue = 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy);
|
args.writeColor = false;
|
||||||
|
args.writeSubsector = false;
|
||||||
|
PolyTriangleDrawer::draw(args);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < sub->numlines; i++)
|
for (uint32_t i = 0; i < sub->numlines; i++)
|
||||||
{
|
{
|
||||||
|
@ -433,7 +437,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, const Vec4f &clipPlan
|
||||||
|
|
||||||
args.vinput = wallvert;
|
args.vinput = wallvert;
|
||||||
args.vcount = 4;
|
args.vcount = 4;
|
||||||
PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy);
|
PolyTriangleDrawer::draw(args);
|
||||||
|
|
||||||
if (portal)
|
if (portal)
|
||||||
{
|
{
|
||||||
|
|
|
@ -255,7 +255,8 @@ void RenderPolyScene::RenderPortals(int portalDepth)
|
||||||
args.vcount = verts.Count;
|
args.vcount = verts.Count;
|
||||||
args.ccw = verts.Ccw;
|
args.ccw = verts.Ccw;
|
||||||
args.uniforms.subsectorDepth = verts.SubsectorDepth;
|
args.uniforms.subsectorDepth = verts.SubsectorDepth;
|
||||||
PolyTriangleDrawer::draw(args, TriDrawVariant::FillNormal, TriBlendMode::Copy);
|
args.blendmode = TriBlendMode::Copy;
|
||||||
|
PolyTriangleDrawer::draw(args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,7 +270,7 @@ void RenderPolyScene::RenderPortals(int portalDepth)
|
||||||
args.vcount = verts.Count;
|
args.vcount = verts.Count;
|
||||||
args.ccw = verts.Ccw;
|
args.ccw = verts.Ccw;
|
||||||
args.uniforms.subsectorDepth = verts.SubsectorDepth;
|
args.uniforms.subsectorDepth = verts.SubsectorDepth;
|
||||||
PolyTriangleDrawer::draw(args, TriDrawVariant::FillNormal, TriBlendMode::Copy);
|
PolyTriangleDrawer::draw(args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -296,7 +297,8 @@ void RenderPolyScene::RenderTranslucent(int portalDepth)
|
||||||
args.vcount = verts.Count;
|
args.vcount = verts.Count;
|
||||||
args.ccw = verts.Ccw;
|
args.ccw = verts.Ccw;
|
||||||
args.uniforms.subsectorDepth = verts.SubsectorDepth;
|
args.uniforms.subsectorDepth = verts.SubsectorDepth;
|
||||||
PolyTriangleDrawer::draw(args, TriDrawVariant::StencilClose, TriBlendMode::Copy);
|
args.writeColor = false;
|
||||||
|
PolyTriangleDrawer::draw(args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,7 +319,8 @@ void RenderPolyScene::RenderTranslucent(int portalDepth)
|
||||||
args.vcount = verts.Count;
|
args.vcount = verts.Count;
|
||||||
args.ccw = verts.Ccw;
|
args.ccw = verts.Ccw;
|
||||||
args.uniforms.subsectorDepth = verts.SubsectorDepth;
|
args.uniforms.subsectorDepth = verts.SubsectorDepth;
|
||||||
PolyTriangleDrawer::draw(args, TriDrawVariant::StencilClose, TriBlendMode::Copy);
|
args.writeColor = false;
|
||||||
|
PolyTriangleDrawer::draw(args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,13 +59,14 @@ void PolySkyDome::Render(const TriMatrix &worldToClip)
|
||||||
args.objectToClip = &objectToClip;
|
args.objectToClip = &objectToClip;
|
||||||
args.stenciltestvalue = 255;
|
args.stenciltestvalue = 255;
|
||||||
args.stencilwritevalue = 1;
|
args.stencilwritevalue = 1;
|
||||||
args.SetTexture(frontskytex);
|
|
||||||
args.SetColormap(&NormalLight);
|
args.SetColormap(&NormalLight);
|
||||||
args.SetClipPlane(0.0f, 0.0f, 0.0f, 0.0f);
|
args.SetClipPlane(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
RenderCapColorRow(args, frontskytex, 0, false);
|
RenderCapColorRow(args, frontskytex, 0, false);
|
||||||
RenderCapColorRow(args, frontskytex, rc, true);
|
RenderCapColorRow(args, frontskytex, rc, true);
|
||||||
|
|
||||||
|
args.SetTexture(frontskytex);
|
||||||
|
|
||||||
uint32_t topcapcolor = frontskytex->GetSkyCapColor(false);
|
uint32_t topcapcolor = frontskytex->GetSkyCapColor(false);
|
||||||
uint32_t bottomcapcolor = frontskytex->GetSkyCapColor(true);
|
uint32_t bottomcapcolor = frontskytex->GetSkyCapColor(true);
|
||||||
|
|
||||||
|
@ -83,8 +84,8 @@ void PolySkyDome::RenderRow(PolyDrawArgs &args, int row, uint32_t capcolor)
|
||||||
args.mode = TriangleDrawMode::Strip;
|
args.mode = TriangleDrawMode::Strip;
|
||||||
args.ccw = false;
|
args.ccw = false;
|
||||||
args.uniforms.color = capcolor;
|
args.uniforms.color = capcolor;
|
||||||
PolyTriangleDrawer::draw(args, TriDrawVariant::DrawNormal, TriBlendMode::Skycap);
|
args.blendmode = TriBlendMode::Skycap;
|
||||||
PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Skycap);
|
PolyTriangleDrawer::draw(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolySkyDome::RenderCapColorRow(PolyDrawArgs &args, FTexture *skytex, int row, bool bottomCap)
|
void PolySkyDome::RenderCapColorRow(PolyDrawArgs &args, FTexture *skytex, int row, bool bottomCap)
|
||||||
|
@ -98,8 +99,8 @@ void PolySkyDome::RenderCapColorRow(PolyDrawArgs &args, FTexture *skytex, int ro
|
||||||
args.mode = TriangleDrawMode::Fan;
|
args.mode = TriangleDrawMode::Fan;
|
||||||
args.ccw = bottomCap;
|
args.ccw = bottomCap;
|
||||||
args.uniforms.color = solid;
|
args.uniforms.color = solid;
|
||||||
PolyTriangleDrawer::draw(args, TriDrawVariant::FillNormal, TriBlendMode::Copy);
|
args.blendmode = TriBlendMode::Copy;
|
||||||
PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy);
|
PolyTriangleDrawer::draw(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolySkyDome::CreateDome()
|
void PolySkyDome::CreateDome()
|
||||||
|
|
|
@ -258,7 +258,11 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, const Vec4f &clipPla
|
||||||
blendmode = TriBlendMode::Add;
|
blendmode = TriBlendMode::Add;
|
||||||
}
|
}
|
||||||
|
|
||||||
PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, blendmode);
|
args.subsectorTest = true;
|
||||||
|
args.writeSubsector = false;
|
||||||
|
args.writeStencil = false;
|
||||||
|
args.blendmode = blendmode;
|
||||||
|
PolyTriangleDrawer::draw(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RenderPolySprite::IsThingCulled(AActor *thing)
|
bool RenderPolySprite::IsThingCulled(AActor *thing)
|
||||||
|
|
|
@ -77,12 +77,12 @@ void PolyTriangleDrawer::toggle_mirror()
|
||||||
mirror = !mirror;
|
mirror = !mirror;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolyTriangleDrawer::draw(const PolyDrawArgs &args, TriDrawVariant variant, TriBlendMode blendmode)
|
void PolyTriangleDrawer::draw(const PolyDrawArgs &args)
|
||||||
{
|
{
|
||||||
DrawerCommandQueue::QueueCommand<DrawPolyTrianglesCommand>(args, variant, blendmode, mirror);
|
DrawerCommandQueue::QueueCommand<DrawPolyTrianglesCommand>(args, mirror);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, TriDrawVariant variant, TriBlendMode blendmode, WorkerThreadData *thread)
|
void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, WorkerThreadData *thread)
|
||||||
{
|
{
|
||||||
if (drawargs.vcount < 3)
|
if (drawargs.vcount < 3)
|
||||||
return;
|
return;
|
||||||
|
@ -92,45 +92,19 @@ void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, TriDrawVarian
|
||||||
PolyDrawFuncPtr drawfuncs[3];
|
PolyDrawFuncPtr drawfuncs[3];
|
||||||
int num_drawfuncs = 0;
|
int num_drawfuncs = 0;
|
||||||
|
|
||||||
int bmode = (int)blendmode;
|
drawfuncs[num_drawfuncs++] = drawargs.subsectorTest ? &ScreenTriangle::SetupSubsector : &ScreenTriangle::SetupNormal;
|
||||||
switch (variant)
|
|
||||||
{
|
int bmode = (int)drawargs.blendmode;
|
||||||
case TriDrawVariant::DrawNormal:
|
if (drawargs.writeColor && drawargs.texturePixels)
|
||||||
drawfuncs[num_drawfuncs++] = &ScreenTriangle::SetupNormal;
|
|
||||||
drawfuncs[num_drawfuncs++] = dest_bgra ? llvm->TriDraw32[bmode] : llvm->TriDraw8[bmode];
|
drawfuncs[num_drawfuncs++] = dest_bgra ? llvm->TriDraw32[bmode] : llvm->TriDraw8[bmode];
|
||||||
drawfuncs[num_drawfuncs++] = &ScreenTriangle::SubsectorWrite;
|
else if (drawargs.writeColor)
|
||||||
break;
|
|
||||||
|
|
||||||
case TriDrawVariant::FillNormal:
|
|
||||||
drawfuncs[num_drawfuncs++] = &ScreenTriangle::SetupNormal;
|
|
||||||
drawfuncs[num_drawfuncs++] = dest_bgra ? llvm->TriFill32[bmode] : llvm->TriFill8[bmode];
|
drawfuncs[num_drawfuncs++] = dest_bgra ? llvm->TriFill32[bmode] : llvm->TriFill8[bmode];
|
||||||
drawfuncs[num_drawfuncs++] = &ScreenTriangle::SubsectorWrite;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TriDrawVariant::DrawSubsector:
|
if (drawargs.writeStencil)
|
||||||
drawfuncs[num_drawfuncs++] = &ScreenTriangle::SetupSubsector;
|
|
||||||
drawfuncs[num_drawfuncs++] = dest_bgra ? llvm->TriDraw32[bmode] : llvm->TriDraw8[bmode];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TriDrawVariant::FillSubsector:
|
|
||||||
drawfuncs[num_drawfuncs++] = &ScreenTriangle::SetupSubsector;
|
|
||||||
drawfuncs[num_drawfuncs++] = dest_bgra ? llvm->TriFill32[bmode] : llvm->TriFill8[bmode];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TriDrawVariant::Stencil:
|
|
||||||
drawfuncs[num_drawfuncs++] = &ScreenTriangle::SetupNormal;
|
|
||||||
drawfuncs[num_drawfuncs++] = &ScreenTriangle::StencilWrite;
|
drawfuncs[num_drawfuncs++] = &ScreenTriangle::StencilWrite;
|
||||||
break;
|
|
||||||
|
|
||||||
case TriDrawVariant::StencilClose:
|
if (drawargs.writeSubsector)
|
||||||
drawfuncs[num_drawfuncs++] = &ScreenTriangle::SetupNormal;
|
|
||||||
drawfuncs[num_drawfuncs++] = &ScreenTriangle::StencilWrite;
|
|
||||||
drawfuncs[num_drawfuncs++] = &ScreenTriangle::SubsectorWrite;
|
drawfuncs[num_drawfuncs++] = &ScreenTriangle::SubsectorWrite;
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
TriDrawTriangleArgs args;
|
TriDrawTriangleArgs args;
|
||||||
args.dest = dest;
|
args.dest = dest;
|
||||||
|
@ -384,8 +358,8 @@ void PolyTriangleDrawer::clipedge(const ShadedTriVertex *verts, TriVertex *clipp
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
DrawPolyTrianglesCommand::DrawPolyTrianglesCommand(const PolyDrawArgs &args, TriDrawVariant variant, TriBlendMode blendmode, bool mirror)
|
DrawPolyTrianglesCommand::DrawPolyTrianglesCommand(const PolyDrawArgs &args, bool mirror)
|
||||||
: args(args), variant(variant), blendmode(blendmode)
|
: args(args)
|
||||||
{
|
{
|
||||||
if (mirror)
|
if (mirror)
|
||||||
this->args.ccw = !this->args.ccw;
|
this->args.ccw = !this->args.ccw;
|
||||||
|
@ -402,25 +376,13 @@ void DrawPolyTrianglesCommand::Execute(DrawerThread *thread)
|
||||||
thread_data.FullSpans = thread->FullSpansBuffer.data();
|
thread_data.FullSpans = thread->FullSpansBuffer.data();
|
||||||
thread_data.PartialBlocks = thread->PartialBlocksBuffer.data();
|
thread_data.PartialBlocks = thread->PartialBlocksBuffer.data();
|
||||||
|
|
||||||
PolyTriangleDrawer::draw_arrays(args, variant, blendmode, &thread_data);
|
PolyTriangleDrawer::draw_arrays(args, &thread_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
FString DrawPolyTrianglesCommand::DebugInfo()
|
FString DrawPolyTrianglesCommand::DebugInfo()
|
||||||
{
|
{
|
||||||
FString variantstr;
|
|
||||||
switch (variant)
|
|
||||||
{
|
|
||||||
default: variantstr = "Unknown"; break;
|
|
||||||
case TriDrawVariant::DrawNormal: variantstr = "DrawNormal"; break;
|
|
||||||
case TriDrawVariant::FillNormal: variantstr = "FillNormal"; break;
|
|
||||||
case TriDrawVariant::DrawSubsector: variantstr = "DrawSubsector"; break;
|
|
||||||
case TriDrawVariant::FillSubsector: variantstr = "FillSubsector"; break;
|
|
||||||
case TriDrawVariant::FuzzSubsector: variantstr = "FuzzSubsector"; break;
|
|
||||||
case TriDrawVariant::Stencil: variantstr = "Stencil"; break;
|
|
||||||
}
|
|
||||||
|
|
||||||
FString blendmodestr;
|
FString blendmodestr;
|
||||||
switch (blendmode)
|
switch (args.blendmode)
|
||||||
{
|
{
|
||||||
default: blendmodestr = "Unknown"; break;
|
default: blendmodestr = "Unknown"; break;
|
||||||
case TriBlendMode::Copy: blendmodestr = "Copy"; break;
|
case TriBlendMode::Copy: blendmodestr = "Copy"; break;
|
||||||
|
@ -440,8 +402,8 @@ FString DrawPolyTrianglesCommand::DebugInfo()
|
||||||
}
|
}
|
||||||
|
|
||||||
FString info;
|
FString info;
|
||||||
info.Format("DrawPolyTriangles: variant = %s, blend mode = %s, color = %d, light = %d, textureWidth = %d, textureHeight = %d, texture = %s, translation = %s, colormaps = %s",
|
info.Format("DrawPolyTriangles: blend mode = %s, color = %d, light = %d, textureWidth = %d, textureHeight = %d, texture = %s, translation = %s, colormaps = %s",
|
||||||
variantstr.GetChars(), blendmodestr.GetChars(), args.uniforms.color, args.uniforms.light, args.textureWidth, args.textureHeight,
|
blendmodestr.GetChars(), args.uniforms.color, args.uniforms.light, args.textureWidth, args.textureHeight,
|
||||||
args.texturePixels ? "ptr" : "null", args.translation ? "ptr" : "null", args.colormaps ? "ptr" : "null");
|
args.texturePixels ? "ptr" : "null", args.translation ? "ptr" : "null", args.colormaps ? "ptr" : "null");
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,11 @@ public:
|
||||||
int vcount = 0;
|
int vcount = 0;
|
||||||
TriangleDrawMode mode = TriangleDrawMode::Normal;
|
TriangleDrawMode mode = TriangleDrawMode::Normal;
|
||||||
bool ccw = false;
|
bool ccw = false;
|
||||||
|
// bool stencilTest = true; // Always true for now
|
||||||
|
bool subsectorTest = false;
|
||||||
|
bool writeStencil = true;
|
||||||
|
bool writeColor = true;
|
||||||
|
bool writeSubsector = true;
|
||||||
const uint8_t *texturePixels = nullptr;
|
const uint8_t *texturePixels = nullptr;
|
||||||
int textureWidth = 0;
|
int textureWidth = 0;
|
||||||
int textureHeight = 0;
|
int textureHeight = 0;
|
||||||
|
@ -57,6 +62,7 @@ public:
|
||||||
uint8_t stencilwritevalue = 0;
|
uint8_t stencilwritevalue = 0;
|
||||||
const uint8_t *colormaps = nullptr;
|
const uint8_t *colormaps = nullptr;
|
||||||
float clipPlane[4];
|
float clipPlane[4];
|
||||||
|
TriBlendMode blendmode = TriBlendMode::Copy;
|
||||||
|
|
||||||
void SetClipPlane(float a, float b, float c, float d)
|
void SetClipPlane(float a, float b, float c, float d)
|
||||||
{
|
{
|
||||||
|
@ -159,12 +165,12 @@ class PolyTriangleDrawer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void set_viewport(int x, int y, int width, int height, DCanvas *canvas);
|
static void set_viewport(int x, int y, int width, int height, DCanvas *canvas);
|
||||||
static void draw(const PolyDrawArgs &args, TriDrawVariant variant, TriBlendMode blendmode);
|
static void draw(const PolyDrawArgs &args);
|
||||||
static void toggle_mirror();
|
static void toggle_mirror();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static ShadedTriVertex shade_vertex(const TriMatrix &objectToClip, const float *clipPlane, const TriVertex &v);
|
static ShadedTriVertex shade_vertex(const TriMatrix &objectToClip, const float *clipPlane, const TriVertex &v);
|
||||||
static void draw_arrays(const PolyDrawArgs &args, TriDrawVariant variant, TriBlendMode blendmode, WorkerThreadData *thread);
|
static void draw_arrays(const PolyDrawArgs &args, WorkerThreadData *thread);
|
||||||
static void draw_shaded_triangle(const ShadedTriVertex *vertices, bool ccw, TriDrawTriangleArgs *args, WorkerThreadData *thread, PolyDrawFuncPtr *drawfuncs, int num_drawfuncs);
|
static void draw_shaded_triangle(const ShadedTriVertex *vertices, bool ccw, TriDrawTriangleArgs *args, WorkerThreadData *thread, PolyDrawFuncPtr *drawfuncs, int num_drawfuncs);
|
||||||
static bool cullhalfspace(float clipdistance1, float clipdistance2, float &t1, float &t2);
|
static bool cullhalfspace(float clipdistance1, float clipdistance2, float &t1, float &t2);
|
||||||
static void clipedge(const ShadedTriVertex *verts, TriVertex *clippedvert, int &numclipvert);
|
static void clipedge(const ShadedTriVertex *verts, TriVertex *clippedvert, int &numclipvert);
|
||||||
|
@ -249,15 +255,13 @@ private:
|
||||||
class DrawPolyTrianglesCommand : public DrawerCommand
|
class DrawPolyTrianglesCommand : public DrawerCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DrawPolyTrianglesCommand(const PolyDrawArgs &args, TriDrawVariant variant, TriBlendMode blendmode, bool mirror);
|
DrawPolyTrianglesCommand(const PolyDrawArgs &args, bool mirror);
|
||||||
|
|
||||||
void Execute(DrawerThread *thread) override;
|
void Execute(DrawerThread *thread) override;
|
||||||
FString DebugInfo() override;
|
FString DebugInfo() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PolyDrawArgs args;
|
PolyDrawArgs args;
|
||||||
TriDrawVariant variant;
|
|
||||||
TriBlendMode blendmode;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class PolyVertexBuffer
|
class PolyVertexBuffer
|
||||||
|
|
|
@ -264,7 +264,9 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip, const Vec4f &clipPlane
|
||||||
if (Polyportal)
|
if (Polyportal)
|
||||||
{
|
{
|
||||||
args.stencilwritevalue = Polyportal->StencilValue;
|
args.stencilwritevalue = Polyportal->StencilValue;
|
||||||
PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy);
|
args.writeColor = false;
|
||||||
|
args.writeSubsector = false;
|
||||||
|
PolyTriangleDrawer::draw(args);
|
||||||
Polyportal->Shape.push_back({ args.vinput, args.vcount, args.ccw, args.uniforms.subsectorDepth });
|
Polyportal->Shape.push_back({ args.vinput, args.vcount, args.ccw, args.uniforms.subsectorDepth });
|
||||||
|
|
||||||
int sx1, sx2;
|
int sx1, sx2;
|
||||||
|
@ -274,17 +276,21 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip, const Vec4f &clipPlane
|
||||||
}
|
}
|
||||||
else if (!Masked)
|
else if (!Masked)
|
||||||
{
|
{
|
||||||
PolyTriangleDrawer::draw(args, TriDrawVariant::DrawNormal, TriBlendMode::Copy);
|
args.blendmode = TriBlendMode::Copy;
|
||||||
PolyTriangleDrawer::draw(args, TriDrawVariant::Stencil, TriBlendMode::Copy);
|
PolyTriangleDrawer::draw(args);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
args.uniforms.destalpha = (Line->flags & ML_ADDTRANS) ? 256 : (uint32_t)(256 - Line->alpha * 256);
|
args.uniforms.destalpha = (Line->flags & ML_ADDTRANS) ? 256 : (uint32_t)(256 - Line->alpha * 256);
|
||||||
args.uniforms.srcalpha = (uint32_t)(Line->alpha * 256);
|
args.uniforms.srcalpha = (uint32_t)(Line->alpha * 256);
|
||||||
|
args.subsectorTest = true;
|
||||||
|
args.writeSubsector = false;
|
||||||
|
args.writeStencil = false;
|
||||||
if (args.uniforms.destalpha == 0 && args.uniforms.srcalpha == 256)
|
if (args.uniforms.destalpha == 0 && args.uniforms.srcalpha == 256)
|
||||||
PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::AlphaBlend);
|
args.blendmode = TriBlendMode::AlphaBlend;
|
||||||
else
|
else
|
||||||
PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::Add);
|
args.blendmode = TriBlendMode::Add;
|
||||||
|
PolyTriangleDrawer::draw(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderPolyDecal::RenderWallDecals(worldToClip, clipPlane, LineSeg, SubsectorDepth, StencilValue);
|
RenderPolyDecal::RenderWallDecals(worldToClip, clipPlane, LineSeg, SubsectorDepth, StencilValue);
|
||||||
|
|
|
@ -121,5 +121,9 @@ void RenderPolyWallSprite::Render(const TriMatrix &worldToClip, const Vec4f &cli
|
||||||
args.SetTexture(tex);
|
args.SetTexture(tex);
|
||||||
args.SetColormap(sub->sector->ColorMap);
|
args.SetColormap(sub->sector->ColorMap);
|
||||||
args.SetClipPlane(clipPlane.x, clipPlane.y, clipPlane.z, clipPlane.w);
|
args.SetClipPlane(clipPlane.x, clipPlane.y, clipPlane.z, clipPlane.w);
|
||||||
PolyTriangleDrawer::draw(args, TriDrawVariant::DrawSubsector, TriBlendMode::AlphaBlend);
|
args.subsectorTest = true;
|
||||||
|
args.writeSubsector = false;
|
||||||
|
args.writeStencil = false;
|
||||||
|
args.blendmode = TriBlendMode::AlphaBlend;
|
||||||
|
PolyTriangleDrawer::draw(args);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue