From 6136c7f5ef95a581d49de4539d577f9e89a6b2cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 28 Dec 2024 17:20:21 +0100 Subject: [PATCH] More reorg --- GPU/Common/DepthRaster.h | 2 ++ GPU/Common/DrawEngineCommon.cpp | 31 +++++++++++++++---------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/GPU/Common/DepthRaster.h b/GPU/Common/DepthRaster.h index 816f66ee58..812094fd2d 100644 --- a/GPU/Common/DepthRaster.h +++ b/GPU/Common/DepthRaster.h @@ -35,6 +35,8 @@ struct DepthDraw { int cullMode; DepthScissor scissor; bool through; + int transformedStartIndex; + int numVertices; }; // Specialized, very limited depth-only rasterizer. diff --git a/GPU/Common/DrawEngineCommon.cpp b/GPU/Common/DrawEngineCommon.cpp index f12d8051c0..66502e3a7f 100644 --- a/GPU/Common/DrawEngineCommon.cpp +++ b/GPU/Common/DrawEngineCommon.cpp @@ -929,7 +929,7 @@ Mat4F32 ComputeFinalProjMatrix() { return m; } -static bool CalculateDepthDraw(DepthDraw *draw, GEPrimitiveType prim) { +static bool CalculateDepthDraw(DepthDraw *draw, GEPrimitiveType prim, int vertexCount) { switch (prim) { case GE_PRIM_INVALID: case GE_PRIM_KEEP_PREVIOUS: @@ -975,6 +975,8 @@ static bool CalculateDepthDraw(DepthDraw *draw, GEPrimitiveType prim) { _dbg_assert_(gstate.isDepthWriteEnabled()); } + draw->transformedStartIndex = 0; + draw->numVertices = vertexCount; draw->cullEnabled = gstate.isCullEnabled(); draw->cullMode = gstate.getCullMode(); draw->prim = prim; @@ -1000,7 +1002,7 @@ void DrawEngineCommon::DepthRasterTransform(GEPrimitiveType prim, VertexDecoder ComputeFinalProjMatrix().Store(worldviewproj); DepthDraw draw; - if (!CalculateDepthDraw(&draw, prim)) { + if (!CalculateDepthDraw(&draw, prim, vertexCount)) { return; } @@ -1025,6 +1027,9 @@ void DrawEngineCommon::DepthRasterTransform(GEPrimitiveType prim, VertexDecoder numDec += indexUpperBound - indexLowerBound + 1; } + // FUTURE SPLIT --- The above will always run on the main thread. The below can be split across workers. + // TODO: Copy indices where? Or deindex above? + int *tx = depthScreenVerts_; int *ty = depthScreenVerts_ + DEPTH_SCREENVERTS_COMPONENT_COUNT; float *tz = (float *)(depthScreenVerts_ + DEPTH_SCREENVERTS_COMPONENT_COUNT * 2); @@ -1041,13 +1046,8 @@ void DrawEngineCommon::DepthRasterPredecoded(GEPrimitiveType prim, const void *i return; } - int *tx = depthScreenVerts_; - int *ty = depthScreenVerts_ + DEPTH_SCREENVERTS_COMPONENT_COUNT; - float *tz = (float *)(depthScreenVerts_ + DEPTH_SCREENVERTS_COMPONENT_COUNT * 2); - - DepthDraw draw; - if (!CalculateDepthDraw(&draw, prim)) { + if (!CalculateDepthDraw(&draw, prim, vertexCount)) { return; } @@ -1066,6 +1066,13 @@ void DrawEngineCommon::DepthRasterPredecoded(GEPrimitiveType prim, const void *i TransformPredecodedForDepthRaster(depthTransformed_, worldviewproj, decoded_, dec, numDecoded); } + // FUTURE SPLIT --- The above will always run on the main thread. The below can be split across workers. + // TODO: Copy indices where? Or deindex above? + + int *tx = depthScreenVerts_; + int *ty = depthScreenVerts_ + DEPTH_SCREENVERTS_COMPONENT_COUNT; + float *tz = (float *)(depthScreenVerts_ + DEPTH_SCREENVERTS_COMPONENT_COUNT * 2); + int outVertCount = 0; switch (prim) { case GE_PRIM_RECTANGLES: @@ -1079,14 +1086,6 @@ void DrawEngineCommon::DepthRasterPredecoded(GEPrimitiveType prim, const void *i break; } - if (prim == GE_PRIM_TRIANGLES && (outVertCount & 15) != 0) { - // Zero padding - for (int i = outVertCount; i < ((outVertCount + 16) & ~15); i++) { - tx[i] = 0; - ty[i] = 0; - tz[i] = 0.0f; - } - } DepthRasterScreenVerts((uint16_t *)Memory::GetPointerWrite(gstate.getDepthBufRawAddress() | 0x04000000), gstate.DepthBufStride(), tx, ty, tz, outVertCount, draw); }