From a91147a3a597430f03d23a712f4c2a92623dc78a Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 10 Jun 2018 15:58:01 +0200 Subject: [PATCH] - move DrawArray and DrawElements to PolyTriangleDrawer --- src/polyrenderer/drawers/poly_draw_args.cpp | 18 ----- src/polyrenderer/drawers/poly_draw_args.h | 11 --- src/polyrenderer/drawers/poly_triangle.cpp | 76 +++++++++++---------- src/polyrenderer/drawers/poly_triangle.h | 15 ++-- src/polyrenderer/scene/poly_decal.cpp | 2 +- src/polyrenderer/scene/poly_model.cpp | 4 +- src/polyrenderer/scene/poly_particle.cpp | 2 +- src/polyrenderer/scene/poly_plane.cpp | 10 +-- src/polyrenderer/scene/poly_scene.cpp | 4 +- src/polyrenderer/scene/poly_sky.cpp | 4 +- src/polyrenderer/scene/poly_sprite.cpp | 2 +- src/polyrenderer/scene/poly_wall.cpp | 10 +-- src/polyrenderer/scene/poly_wallsprite.cpp | 2 +- src/swrenderer/things/r_model.cpp | 4 +- 14 files changed, 73 insertions(+), 91 deletions(-) diff --git a/src/polyrenderer/drawers/poly_draw_args.cpp b/src/polyrenderer/drawers/poly_draw_args.cpp index 1ca30ea538..158c24dcf6 100644 --- a/src/polyrenderer/drawers/poly_draw_args.cpp +++ b/src/polyrenderer/drawers/poly_draw_args.cpp @@ -140,24 +140,6 @@ void PolyDrawArgs::SetColor(uint32_t bgra, uint8_t palindex) } } -void PolyDrawArgs::DrawArray(const DrawerCommandQueuePtr &queue, const void *vertices, int vcount, PolyDrawMode mode) -{ - mVertices = vertices; - mVertexCount = vcount; - mElements = nullptr; - mDrawMode = mode; - queue->Push(*this); -} - -void PolyDrawArgs::DrawElements(const DrawerCommandQueuePtr &queue, const void *vertices, const unsigned int *elements, int count, PolyDrawMode mode) -{ - mVertices = vertices; - mElements = elements; - mVertexCount = count; - mDrawMode = mode; - queue->Push(*this); -} - void PolyDrawArgs::SetStyle(const FRenderStyle &renderstyle, double alpha, uint32_t fillcolor, uint32_t translationID, FTexture *tex, bool fullbright) { SetTexture(tex, translationID, renderstyle); diff --git a/src/polyrenderer/drawers/poly_draw_args.h b/src/polyrenderer/drawers/poly_draw_args.h index 12ca5a662d..8450bd655c 100644 --- a/src/polyrenderer/drawers/poly_draw_args.h +++ b/src/polyrenderer/drawers/poly_draw_args.h @@ -80,16 +80,9 @@ public: void SetColor(uint32_t bgra, uint8_t palindex); void SetLights(PolyLight *lights, int numLights) { mLights = lights; mNumLights = numLights; } void SetDynLightColor(uint32_t color) { mDynLightColor = color; } - void DrawArray(const DrawerCommandQueuePtr &queue, const void *vertices, int vcount, PolyDrawMode mode = PolyDrawMode::Triangles); - void DrawElements(const DrawerCommandQueuePtr &queue, const void *vertices, const unsigned int *elements, int count, PolyDrawMode mode = PolyDrawMode::Triangles); const PolyClipPlane &ClipPlane(int index) const { return mClipPlane[index]; } - const void *Vertices() const { return mVertices; } - int VertexCount() const { return mVertexCount; } - const unsigned int *Elements() const { return mElements; } - PolyDrawMode DrawMode() const { return mDrawMode; } - bool WriteColor() const { return mWriteColor; } FTexture *Texture() const { return mTexture; } @@ -134,10 +127,6 @@ public: void SetNormal(const FVector3 &normal) { mNormal = normal; } private: - const void *mVertices = nullptr; - int mVertexCount = 0; - const unsigned int *mElements = nullptr; - PolyDrawMode mDrawMode = PolyDrawMode::Triangles; bool mDepthTest = false; bool mWriteStencil = true; bool mWriteColor = true; diff --git a/src/polyrenderer/drawers/poly_triangle.cpp b/src/polyrenderer/drawers/poly_triangle.cpp index 0600e3a039..bc10b98c2c 100644 --- a/src/polyrenderer/drawers/poly_triangle.cpp +++ b/src/polyrenderer/drawers/poly_triangle.cpp @@ -108,6 +108,16 @@ void PolyTriangleDrawer::SetModelVertexShader(const DrawerCommandQueuePtr &queue queue->Push(frame1, frame2, interpolationFactor); } +void PolyTriangleDrawer::DrawArray(const DrawerCommandQueuePtr &queue, const PolyDrawArgs &args, const void *vertices, int vcount, PolyDrawMode mode) +{ + queue->Push(args, vertices, nullptr, vcount, mode); +} + +void PolyTriangleDrawer::DrawElements(const DrawerCommandQueuePtr &queue, const PolyDrawArgs &args, const void *vertices, const unsigned int *elements, int count, PolyDrawMode mode) +{ + queue->Push(args, vertices, elements, count, mode); +} + ///////////////////////////////////////////////////////////////////////////// void PolyTriangleThreadData::ClearStencil(uint8_t value) @@ -146,9 +156,9 @@ void PolyTriangleThreadData::SetTransform(const Mat4f *newObjectToClip, const Ma objectToWorld = newObjectToWorld; } -void PolyTriangleThreadData::DrawElements(const PolyDrawArgs &drawargs) +void PolyTriangleThreadData::DrawElements(const PolyDrawArgs &drawargs, const void *vertices, const unsigned int *elements, int vcount, PolyDrawMode drawmode) { - if (drawargs.VertexCount() < 3) + if (vcount < 3) return; TriDrawTriangleArgs args; @@ -162,26 +172,23 @@ void PolyTriangleThreadData::DrawElements(const PolyDrawArgs &drawargs) args.zbuffer = PolyZBuffer::Instance()->Values(); args.depthOffset = weaponScene ? 1.0f : 0.0f; - const unsigned int *elements = drawargs.Elements(); - int vcount = drawargs.VertexCount(); - ShadedTriVertex vert[3]; - if (drawargs.DrawMode() == PolyDrawMode::Triangles) + if (drawmode == PolyDrawMode::Triangles) { for (int i = 0; i < vcount / 3; i++) { for (int j = 0; j < 3; j++) - vert[j] = ShadeVertex(drawargs, *(elements++)); + vert[j] = ShadeVertex(drawargs, vertices, *(elements++)); DrawShadedTriangle(vert, ccw, &args); } } - else if (drawargs.DrawMode() == PolyDrawMode::TriangleFan) + else if (drawmode == PolyDrawMode::TriangleFan) { - vert[0] = ShadeVertex(drawargs, *(elements++)); - vert[1] = ShadeVertex(drawargs, *(elements++)); + vert[0] = ShadeVertex(drawargs, vertices, *(elements++)); + vert[1] = ShadeVertex(drawargs, vertices, *(elements++)); for (int i = 2; i < vcount; i++) { - vert[2] = ShadeVertex(drawargs, *(elements++)); + vert[2] = ShadeVertex(drawargs, vertices, *(elements++)); DrawShadedTriangle(vert, ccw, &args); vert[1] = vert[2]; } @@ -189,11 +196,11 @@ void PolyTriangleThreadData::DrawElements(const PolyDrawArgs &drawargs) else // TriangleDrawMode::TriangleStrip { bool toggleccw = ccw; - vert[0] = ShadeVertex(drawargs, *(elements++)); - vert[1] = ShadeVertex(drawargs, *(elements++)); + vert[0] = ShadeVertex(drawargs, vertices, *(elements++)); + vert[1] = ShadeVertex(drawargs, vertices, *(elements++)); for (int i = 2; i < vcount; i++) { - vert[2] = ShadeVertex(drawargs, *(elements++)); + vert[2] = ShadeVertex(drawargs, vertices, *(elements++)); DrawShadedTriangle(vert, toggleccw, &args); vert[0] = vert[1]; vert[1] = vert[2]; @@ -202,9 +209,9 @@ void PolyTriangleThreadData::DrawElements(const PolyDrawArgs &drawargs) } } -void PolyTriangleThreadData::DrawArrays(const PolyDrawArgs &drawargs) +void PolyTriangleThreadData::DrawArray(const PolyDrawArgs &drawargs, const void *vertices, int vcount, PolyDrawMode drawmode) { - if (drawargs.VertexCount() < 3) + if (vcount < 3) return; TriDrawTriangleArgs args; @@ -219,25 +226,24 @@ void PolyTriangleThreadData::DrawArrays(const PolyDrawArgs &drawargs) args.depthOffset = weaponScene ? 1.0f : 0.0f; int vinput = 0; - int vcount = drawargs.VertexCount(); ShadedTriVertex vert[3]; - if (drawargs.DrawMode() == PolyDrawMode::Triangles) + if (drawmode == PolyDrawMode::Triangles) { for (int i = 0; i < vcount / 3; i++) { for (int j = 0; j < 3; j++) - vert[j] = ShadeVertex(drawargs, vinput++); + vert[j] = ShadeVertex(drawargs, vertices, vinput++); DrawShadedTriangle(vert, ccw, &args); } } - else if (drawargs.DrawMode() == PolyDrawMode::TriangleFan) + else if (drawmode == PolyDrawMode::TriangleFan) { - vert[0] = ShadeVertex(drawargs, vinput++); - vert[1] = ShadeVertex(drawargs, vinput++); + vert[0] = ShadeVertex(drawargs, vertices, vinput++); + vert[1] = ShadeVertex(drawargs, vertices, vinput++); for (int i = 2; i < vcount; i++) { - vert[2] = ShadeVertex(drawargs, vinput++); + vert[2] = ShadeVertex(drawargs, vertices, vinput++); DrawShadedTriangle(vert, ccw, &args); vert[1] = vert[2]; } @@ -245,11 +251,11 @@ void PolyTriangleThreadData::DrawArrays(const PolyDrawArgs &drawargs) else // TriangleDrawMode::TriangleStrip { bool toggleccw = ccw; - vert[0] = ShadeVertex(drawargs, vinput++); - vert[1] = ShadeVertex(drawargs, vinput++); + vert[0] = ShadeVertex(drawargs, vertices, vinput++); + vert[1] = ShadeVertex(drawargs, vertices, vinput++); for (int i = 2; i < vcount; i++) { - vert[2] = ShadeVertex(drawargs, vinput++); + vert[2] = ShadeVertex(drawargs, vertices, vinput++); DrawShadedTriangle(vert, toggleccw, &args); vert[0] = vert[1]; vert[1] = vert[2]; @@ -258,29 +264,29 @@ void PolyTriangleThreadData::DrawArrays(const PolyDrawArgs &drawargs) } } -ShadedTriVertex PolyTriangleThreadData::ShadeVertex(const PolyDrawArgs &drawargs, int index) +ShadedTriVertex PolyTriangleThreadData::ShadeVertex(const PolyDrawArgs &drawargs, const void *vertices, int index) { ShadedTriVertex sv; Vec4f objpos; if (modelFrame1 == -1) { - const TriVertex &v = ((TriVertex*)drawargs.Vertices())[index]; + const TriVertex &v = static_cast(vertices)[index]; objpos = Vec4f(v.x, v.y, v.z, v.w); sv.u = v.u; sv.v = v.v; } else if (modelFrame1 == modelFrame2 || modelInterpolationFactor == 0.f) { - const FModelVertex &v = ((FModelVertex*)drawargs.Vertices())[modelFrame1 + index]; + const FModelVertex &v = static_cast(vertices)[modelFrame1 + index]; objpos = Vec4f(v.x, v.y, v.z, 1.0f); sv.u = v.u; sv.v = v.v; } else { - const FModelVertex &v1 = ((FModelVertex*)drawargs.Vertices())[modelFrame1 + index]; - const FModelVertex &v2 = ((FModelVertex*)drawargs.Vertices())[modelFrame2 + index]; + const FModelVertex &v1 = static_cast(vertices)[modelFrame1 + index]; + const FModelVertex &v2 = static_cast(vertices)[modelFrame2 + index]; float frac = modelInterpolationFactor; float inv_frac = 1.0f - frac; @@ -718,16 +724,16 @@ void PolySetViewportCommand::Execute(DrawerThread *thread) ///////////////////////////////////////////////////////////////////////////// -DrawPolyTrianglesCommand::DrawPolyTrianglesCommand(const PolyDrawArgs &args) : args(args) +DrawPolyTrianglesCommand::DrawPolyTrianglesCommand(const PolyDrawArgs &args, const void *vertices, const unsigned int *elements, int count, PolyDrawMode mode) : args(args), vertices(vertices), elements(elements), count(count), mode(mode) { } void DrawPolyTrianglesCommand::Execute(DrawerThread *thread) { - if (!args.Elements()) - PolyTriangleThreadData::Get(thread)->DrawArrays(args); + if (!elements) + PolyTriangleThreadData::Get(thread)->DrawArray(args, vertices, count, mode); else - PolyTriangleThreadData::Get(thread)->DrawElements(args); + PolyTriangleThreadData::Get(thread)->DrawElements(args, vertices, elements, count, mode); } ///////////////////////////////////////////////////////////////////////////// diff --git a/src/polyrenderer/drawers/poly_triangle.h b/src/polyrenderer/drawers/poly_triangle.h index b4aa09c2c4..d2a49ec979 100644 --- a/src/polyrenderer/drawers/poly_triangle.h +++ b/src/polyrenderer/drawers/poly_triangle.h @@ -40,7 +40,8 @@ public: static void SetWeaponScene(const DrawerCommandQueuePtr &queue, bool enable); static void SetModelVertexShader(const DrawerCommandQueuePtr &queue, int frame1, int frame2, float interpolationFactor); static void SetTransform(const DrawerCommandQueuePtr &queue, const Mat4f *objectToClip, const Mat4f *objectToWorld); - + static void DrawArray(const DrawerCommandQueuePtr &queue, const PolyDrawArgs &args, const void *vertices, int vcount, PolyDrawMode mode = PolyDrawMode::Triangles); + static void DrawElements(const DrawerCommandQueuePtr &queue, const PolyDrawArgs &args, const void *vertices, const unsigned int *elements, int count, PolyDrawMode mode = PolyDrawMode::Triangles); static bool IsBgra(); }; @@ -57,8 +58,8 @@ public: void SetWeaponScene(bool value) { weaponScene = value; } void SetModelVertexShader(int frame1, int frame2, float interpolationFactor) { modelFrame1 = frame1; modelFrame2 = frame2; modelInterpolationFactor = interpolationFactor; } - void DrawElements(const PolyDrawArgs &args); - void DrawArrays(const PolyDrawArgs &args); + void DrawElements(const PolyDrawArgs &args, const void *vertices, const unsigned int *elements, int count, PolyDrawMode mode); + void DrawArray(const PolyDrawArgs &args, const void *vertices, int vcount, PolyDrawMode mode); int32_t core; int32_t num_cores; @@ -73,7 +74,7 @@ public: static PolyTriangleThreadData *Get(DrawerThread *thread); private: - ShadedTriVertex ShadeVertex(const PolyDrawArgs &drawargs, int index); + ShadedTriVertex ShadeVertex(const PolyDrawArgs &drawargs, const void *vertices, int index); void DrawShadedTriangle(const ShadedTriVertex *vertices, bool ccw, TriDrawTriangleArgs *args); static bool IsDegenerate(const ShadedTriVertex *vertices); static bool IsFrontfacing(TriDrawTriangleArgs *args); @@ -191,12 +192,16 @@ private: class DrawPolyTrianglesCommand : public DrawerCommand { public: - DrawPolyTrianglesCommand(const PolyDrawArgs &args); + DrawPolyTrianglesCommand(const PolyDrawArgs &args, const void *vertices, const unsigned int *elements, int count, PolyDrawMode mode); void Execute(DrawerThread *thread) override; private: PolyDrawArgs args; + const void *vertices; + const unsigned int *elements; + int count; + PolyDrawMode mode; }; class DrawRectCommand : public DrawerCommand diff --git a/src/polyrenderer/scene/poly_decal.cpp b/src/polyrenderer/scene/poly_decal.cpp index 16754727bc..f15c15ba3a 100644 --- a/src/polyrenderer/scene/poly_decal.cpp +++ b/src/polyrenderer/scene/poly_decal.cpp @@ -191,7 +191,7 @@ void RenderPolyDecal::Render(PolyRenderThread *thread, DBaseDecal *decal, const args.SetDepthTest(true); args.SetWriteStencil(false); args.SetWriteDepth(false); - args.DrawArray(thread->DrawQueue, vertices, 4, PolyDrawMode::TriangleFan); + PolyTriangleDrawer::DrawArray(thread->DrawQueue, args, vertices, 4, PolyDrawMode::TriangleFan); } void RenderPolyDecal::GetDecalSectors(DBaseDecal *decal, const seg_t *line, sector_t **front, sector_t **back) diff --git a/src/polyrenderer/scene/poly_model.cpp b/src/polyrenderer/scene/poly_model.cpp index 8109868e8f..46d064a7b5 100644 --- a/src/polyrenderer/scene/poly_model.cpp +++ b/src/polyrenderer/scene/poly_model.cpp @@ -231,7 +231,7 @@ void PolyModelRenderer::DrawArrays(int start, int count) args.SetDepthTest(true); args.SetWriteDepth(true); args.SetWriteStencil(false); - args.DrawArray(Thread->DrawQueue, VertexBuffer + start, count); + PolyTriangleDrawer::DrawArray(Thread->DrawQueue, args, VertexBuffer + start, count); } void PolyModelRenderer::DrawElements(int numIndices, size_t offset) @@ -254,7 +254,7 @@ void PolyModelRenderer::DrawElements(int numIndices, size_t offset) args.SetDepthTest(true); args.SetWriteDepth(true); args.SetWriteStencil(false); - args.DrawElements(Thread->DrawQueue, VertexBuffer, IndexBuffer + offset / sizeof(unsigned int), numIndices); + PolyTriangleDrawer::DrawElements(Thread->DrawQueue, args, VertexBuffer, IndexBuffer + offset / sizeof(unsigned int), numIndices); } ///////////////////////////////////////////////////////////////////////////// diff --git a/src/polyrenderer/scene/poly_particle.cpp b/src/polyrenderer/scene/poly_particle.cpp index da2a2bba27..73617ebce1 100644 --- a/src/polyrenderer/scene/poly_particle.cpp +++ b/src/polyrenderer/scene/poly_particle.cpp @@ -86,7 +86,7 @@ void RenderPolyParticle::Render(PolyRenderThread *thread, particle_t *particle, args.SetWriteStencil(false); args.SetWriteDepth(false); args.SetTexture(GetParticleTexture(), ParticleTextureSize, ParticleTextureSize); - args.DrawArray(thread->DrawQueue, vertices, 4, PolyDrawMode::TriangleFan); + PolyTriangleDrawer::DrawArray(thread->DrawQueue, args, vertices, 4, PolyDrawMode::TriangleFan); } uint8_t *RenderPolyParticle::GetParticleTexture() diff --git a/src/polyrenderer/scene/poly_plane.cpp b/src/polyrenderer/scene/poly_plane.cpp index f43e51a932..55a4c11d0c 100644 --- a/src/polyrenderer/scene/poly_plane.cpp +++ b/src/polyrenderer/scene/poly_plane.cpp @@ -80,7 +80,7 @@ void RenderPolyPlane::RenderNormal(PolyRenderThread *thread, const PolyTransferH args.SetWriteStencil(true, stencilValue + 1); args.SetTexture(tex, DefaultRenderStyle()); args.SetStyle(TriBlendMode::Opaque); - args.DrawArray(thread->DrawQueue, vertices, fakeflat.Subsector->numlines, PolyDrawMode::TriangleFan); + PolyTriangleDrawer::DrawArray(thread->DrawQueue, args, vertices, fakeflat.Subsector->numlines, PolyDrawMode::TriangleFan); } else { @@ -91,7 +91,7 @@ void RenderPolyPlane::RenderNormal(PolyRenderThread *thread, const PolyTransferH args.SetWriteStencil(true, 255); args.SetWriteColor(false); args.SetWriteDepth(false); - args.DrawArray(thread->DrawQueue, vertices, fakeflat.Subsector->numlines, PolyDrawMode::TriangleFan); + PolyTriangleDrawer::DrawArray(thread->DrawQueue, args, vertices, fakeflat.Subsector->numlines, PolyDrawMode::TriangleFan); RenderSkyWalls(thread, args, fakeflat.Subsector, nullptr, ceiling, skyHeight); } @@ -157,7 +157,7 @@ void RenderPolyPlane::RenderPortal(PolyRenderThread *thread, const PolyTransferH args.SetWriteStencil(true, polyportal->StencilValue); args.SetWriteColor(false); args.SetWriteDepth(false); - args.DrawArray(thread->DrawQueue, vertices, fakeflat.Subsector->numlines, PolyDrawMode::TriangleFan); + PolyTriangleDrawer::DrawArray(thread->DrawQueue, args, vertices, fakeflat.Subsector->numlines, PolyDrawMode::TriangleFan); RenderSkyWalls(thread, args, fakeflat.Subsector, polyportal, ceiling, skyHeight); @@ -235,7 +235,7 @@ void RenderPolyPlane::RenderSkyWalls(PolyRenderThread *thread, PolyDrawArgs &arg wallvert[3] = GetSkyVertex(line->v1, skyHeight); } - args.DrawArray(thread->DrawQueue, wallvert, 4, PolyDrawMode::TriangleFan); + PolyTriangleDrawer::DrawArray(thread->DrawQueue, args, wallvert, 4, PolyDrawMode::TriangleFan); if (polyportal) { @@ -557,5 +557,5 @@ void Render3DFloorPlane::Render(PolyRenderThread *thread) args.SetStencilTestValue(stencilValue); args.SetWriteStencil(true, stencilValue + 1); args.SetTexture(tex, DefaultRenderStyle()); - args.DrawArray(thread->DrawQueue, vertices, sub->numlines, PolyDrawMode::TriangleFan); + PolyTriangleDrawer::DrawArray(thread->DrawQueue, args, vertices, sub->numlines, PolyDrawMode::TriangleFan); } diff --git a/src/polyrenderer/scene/poly_scene.cpp b/src/polyrenderer/scene/poly_scene.cpp index 48f03eea39..469f56bc9d 100644 --- a/src/polyrenderer/scene/poly_scene.cpp +++ b/src/polyrenderer/scene/poly_scene.cpp @@ -357,7 +357,7 @@ void RenderPolyScene::RenderPortals() args.SetWriteStencil(true, CurrentViewpoint->StencilValue + 1); for (const auto &verts : portal->Shape) { - args.DrawArray(thread->DrawQueue, verts.Vertices, verts.Count, PolyDrawMode::TriangleFan); + PolyTriangleDrawer::DrawArray(thread->DrawQueue, args, verts.Vertices, verts.Count, PolyDrawMode::TriangleFan); } } @@ -368,7 +368,7 @@ void RenderPolyScene::RenderPortals() args.SetWriteStencil(true, CurrentViewpoint->StencilValue + 1); for (const auto &verts : portal->Shape) { - args.DrawArray(thread->DrawQueue, verts.Vertices, verts.Count, PolyDrawMode::TriangleFan); + PolyTriangleDrawer::DrawArray(thread->DrawQueue, args, verts.Vertices, verts.Count, PolyDrawMode::TriangleFan); } } } diff --git a/src/polyrenderer/scene/poly_sky.cpp b/src/polyrenderer/scene/poly_sky.cpp index 1fa71ba83a..6f7294b9e4 100644 --- a/src/polyrenderer/scene/poly_sky.cpp +++ b/src/polyrenderer/scene/poly_sky.cpp @@ -112,7 +112,7 @@ void PolySkyDome::RenderRow(PolyRenderThread *thread, PolyDrawArgs &args, int ro { args.SetColor(capcolor, capcolorindex); args.SetStyle(TriBlendMode::Skycap); - args.DrawArray(thread->DrawQueue, &mVertices[mPrimStart[row]], mPrimStart[row + 1] - mPrimStart[row], PolyDrawMode::TriangleStrip); + PolyTriangleDrawer::DrawArray(thread->DrawQueue, args, &mVertices[mPrimStart[row]], mPrimStart[row + 1] - mPrimStart[row], PolyDrawMode::TriangleStrip); } void PolySkyDome::RenderCapColorRow(PolyRenderThread *thread, PolyDrawArgs &args, FTexture *skytex, int row, bool bottomCap) @@ -122,7 +122,7 @@ void PolySkyDome::RenderCapColorRow(PolyRenderThread *thread, PolyDrawArgs &args args.SetColor(solid, palsolid); args.SetStyle(TriBlendMode::Fill); - args.DrawArray(thread->DrawQueue, &mVertices[mPrimStart[row]], mPrimStart[row + 1] - mPrimStart[row], PolyDrawMode::TriangleFan); + PolyTriangleDrawer::DrawArray(thread->DrawQueue, args, &mVertices[mPrimStart[row]], mPrimStart[row + 1] - mPrimStart[row], PolyDrawMode::TriangleFan); } void PolySkyDome::CreateDome() diff --git a/src/polyrenderer/scene/poly_sprite.cpp b/src/polyrenderer/scene/poly_sprite.cpp index 9dda0edf7a..7be5648b0a 100644 --- a/src/polyrenderer/scene/poly_sprite.cpp +++ b/src/polyrenderer/scene/poly_sprite.cpp @@ -168,7 +168,7 @@ void RenderPolySprite::Render(PolyRenderThread *thread, AActor *thing, subsector args.SetDepthTest(true); args.SetWriteDepth(false); args.SetWriteStencil(false); - args.DrawArray(thread->DrawQueue, vertices, 4, PolyDrawMode::TriangleFan); + PolyTriangleDrawer::DrawArray(thread->DrawQueue, args, vertices, 4, PolyDrawMode::TriangleFan); } double RenderPolySprite::GetSpriteFloorZ(AActor *thing, const DVector2 &thingpos) diff --git a/src/polyrenderer/scene/poly_wall.cpp b/src/polyrenderer/scene/poly_wall.cpp index 7d478ce80e..02eb5e7b2e 100644 --- a/src/polyrenderer/scene/poly_wall.cpp +++ b/src/polyrenderer/scene/poly_wall.cpp @@ -331,7 +331,7 @@ void RenderPolyWall::Render(PolyRenderThread *thread) args.SetDepthTest(true); args.SetWriteDepth(true); args.SetWriteStencil(false); - args.DrawArray(thread->DrawQueue, vertices, 4, PolyDrawMode::TriangleFan); + PolyTriangleDrawer::DrawArray(thread->DrawQueue, args, vertices, 4, PolyDrawMode::TriangleFan); if (!Texture) return; } @@ -342,7 +342,7 @@ void RenderPolyWall::Render(PolyRenderThread *thread) args.SetWriteStencil(true, Polyportal->StencilValue); args.SetWriteColor(false); args.SetWriteDepth(false); - args.DrawArray(thread->DrawQueue, vertices, 4, PolyDrawMode::TriangleFan); + PolyTriangleDrawer::DrawArray(thread->DrawQueue, args, vertices, 4, PolyDrawMode::TriangleFan); Polyportal->Shape.push_back({ vertices, 4 }); } else if (!Masked) @@ -466,7 +466,7 @@ void RenderPolyWall::DrawStripes(PolyRenderThread *thread, PolyDrawArgs &args, T args.SetClipPlane(1, topPlane); args.SetClipPlane(2, bottomPlane); - args.DrawArray(thread->DrawQueue, vertices, 4, PolyDrawMode::TriangleFan); + PolyTriangleDrawer::DrawArray(thread->DrawQueue, args, vertices, 4, PolyDrawMode::TriangleFan); FDynamicColormap *basecolormap = GetColorTable(lit->extra_colormap, Line->frontsector->SpecialColors[sector_t::walltop]); @@ -489,11 +489,11 @@ void RenderPolyWall::DrawStripes(PolyRenderThread *thread, PolyDrawArgs &args, T args.SetClipPlane(1, topPlane); args.SetClipPlane(2, PolyClipPlane()); - args.DrawArray(thread->DrawQueue, vertices, 4, PolyDrawMode::TriangleFan); + PolyTriangleDrawer::DrawArray(thread->DrawQueue, args, vertices, 4, PolyDrawMode::TriangleFan); } else { - args.DrawArray(thread->DrawQueue, vertices, 4, PolyDrawMode::TriangleFan); + PolyTriangleDrawer::DrawArray(thread->DrawQueue, args, vertices, 4, PolyDrawMode::TriangleFan); } } diff --git a/src/polyrenderer/scene/poly_wallsprite.cpp b/src/polyrenderer/scene/poly_wallsprite.cpp index 90024866e3..7702dbd3dd 100644 --- a/src/polyrenderer/scene/poly_wallsprite.cpp +++ b/src/polyrenderer/scene/poly_wallsprite.cpp @@ -108,5 +108,5 @@ void RenderPolyWallSprite::Render(PolyRenderThread *thread, AActor *thing, subse args.SetWriteDepth(false); args.SetWriteStencil(false); args.SetStyle(TriBlendMode::Normal); - args.DrawArray(thread->DrawQueue, vertices, 4, PolyDrawMode::TriangleFan); + PolyTriangleDrawer::DrawArray(thread->DrawQueue, args, vertices, 4, PolyDrawMode::TriangleFan); } diff --git a/src/swrenderer/things/r_model.cpp b/src/swrenderer/things/r_model.cpp index 40db26882a..aa94376709 100644 --- a/src/swrenderer/things/r_model.cpp +++ b/src/swrenderer/things/r_model.cpp @@ -330,7 +330,7 @@ namespace swrenderer args.SetClipPlane(1, ClipTop); args.SetClipPlane(2, ClipBottom); - args.DrawArray(Thread->DrawQueue, VertexBuffer + start, count); + PolyTriangleDrawer::DrawArray(Thread->DrawQueue, args, VertexBuffer + start, count); } void SWModelRenderer::DrawElements(int numIndices, size_t offset) @@ -356,7 +356,7 @@ namespace swrenderer args.SetClipPlane(1, ClipTop); args.SetClipPlane(2, ClipBottom); - args.DrawElements(Thread->DrawQueue, VertexBuffer, IndexBuffer + offset / sizeof(unsigned int), numIndices); + PolyTriangleDrawer::DrawElements(Thread->DrawQueue, args, VertexBuffer, IndexBuffer + offset / sizeof(unsigned int), numIndices); } /////////////////////////////////////////////////////////////////////////////