diff --git a/GPU/Common/DrawEngineCommon.cpp b/GPU/Common/DrawEngineCommon.cpp index 357736b9b2..edc66aec59 100644 --- a/GPU/Common/DrawEngineCommon.cpp +++ b/GPU/Common/DrawEngineCommon.cpp @@ -1042,6 +1042,10 @@ void DrawEngineCommon::DepthRasterTransform(GEPrimitiveType prim, VertexDecoder depthIndexCount_ += vertexCount; depthVertexCount_ += numDecoded; + if (depthDraws_.empty()) { + rasterTimeStart_ = time_now_d(); + } + depthDraws_.push_back(draw); // FlushQueuedDepth(); @@ -1081,11 +1085,19 @@ void DrawEngineCommon::DepthRasterPredecoded(GEPrimitiveType prim, const void *i depthDraws_.push_back(draw); + if (depthDraws_.empty()) { + rasterTimeStart_ = time_now_d(); + } // FlushQueuedDepth(); } void DrawEngineCommon::FlushQueuedDepth() { - TimeCollector collectStat(&gpuStats.msRasterizeDepth, coreCollectDebugStats); + if (rasterTimeStart_ != 0.0) { + gpuStats.msRasterTimeAvailable += time_now_d() - rasterTimeStart_; + rasterTimeStart_ = 0.0; + } + + const bool collectStats = coreCollectDebugStats; for (const auto &draw : depthDraws_) { int *tx = depthScreenVerts_; @@ -1097,19 +1109,24 @@ void DrawEngineCommon::FlushQueuedDepth() { const float *vertices = depthTransformed_ + 4 * draw.vertexOffset; const uint16_t *indices = depthIndices_ + draw.indexOffset; - switch (draw.prim) { - case GE_PRIM_RECTANGLES: - outVertCount = DepthRasterClipIndexedRectangles(tx, ty, tz, vertices, indices, draw); - break; - case GE_PRIM_TRIANGLES: - outVertCount = DepthRasterClipIndexedTriangles(tx, ty, tz, vertices, indices, draw); - break; - default: - _dbg_assert_(false); - break; + { + TimeCollector collectStat(&gpuStats.msCullDepth, collectStats); + switch (draw.prim) { + case GE_PRIM_RECTANGLES: + outVertCount = DepthRasterClipIndexedRectangles(tx, ty, tz, vertices, indices, draw); + break; + case GE_PRIM_TRIANGLES: + outVertCount = DepthRasterClipIndexedTriangles(tx, ty, tz, vertices, indices, draw); + break; + default: + _dbg_assert_(false); + break; + } + } + { + TimeCollector collectStat(&gpuStats.msRasterizeDepth, collectStats); + DepthRasterScreenVerts((uint16_t *)Memory::GetPointerWrite(draw.depthAddr), draw.depthStride, tx, ty, tz, outVertCount, draw); } - // TODO: Could potentially split into tasks here! - DepthRasterScreenVerts((uint16_t *)Memory::GetPointerWrite(draw.depthAddr), draw.depthStride, tx, ty, tz, outVertCount, draw); } // Reset queue diff --git a/GPU/Common/DrawEngineCommon.h b/GPU/Common/DrawEngineCommon.h index 8b56f3cd65..e927a82e9a 100644 --- a/GPU/Common/DrawEngineCommon.h +++ b/GPU/Common/DrawEngineCommon.h @@ -367,4 +367,6 @@ protected: int depthVertexCount_ = 0; int depthIndexCount_ = 0; std::vector depthDraws_; + + double rasterTimeStart_ = 0.0; }; diff --git a/GPU/GPU.h b/GPU/GPU.h index cbf5bc93a1..506f0d9c38 100644 --- a/GPU/GPU.h +++ b/GPU/GPU.h @@ -108,8 +108,10 @@ struct GPUStatistics { numCachedReplacedTextures = 0; numClutTextures = 0; msProcessingDisplayLists = 0; - msPrepareDepth = 0.0f; - msRasterizeDepth = 0.0f; + msPrepareDepth = 0.0; + msCullDepth = 0.0; + msRasterizeDepth = 0.0; + msRasterTimeAvailable = 0.0; numDepthRasterPrims = 0; numDepthRasterEarlySize = 0; numDepthRasterNoPixels = 0; @@ -156,7 +158,9 @@ struct GPUStatistics { int numClutTextures; double msProcessingDisplayLists; double msPrepareDepth; + double msCullDepth; double msRasterizeDepth; + double msRasterTimeAvailable; int vertexGPUCycles; int otherGPUCycles; int numDepthRasterPrims; diff --git a/GPU/GPUCommonHW.cpp b/GPU/GPUCommonHW.cpp index c665f379a2..a58d5c3e28 100644 --- a/GPU/GPUCommonHW.cpp +++ b/GPU/GPUCommonHW.cpp @@ -1763,7 +1763,7 @@ void GPUCommonHW::Execute_BoneMtxData(u32 op, u32 diff) { gstate_c.Dirty(DIRTY_BONEMATRIX0 << (num / 12)); } else { gstate_c.deferredVertTypeDirty |= DIRTY_BONEMATRIX0 << (num / 12); - } + } ((u32 *)gstate.boneMatrix)[num] = newVal; } num++; @@ -1801,7 +1801,8 @@ size_t GPUCommonHW::FormatGPUStatsCommon(char *buffer, size_t size) { "replacer: tracks %d references, %d unique textures\n" "Cpy: depth %d, color %d, reint %d, blend %d, self %d\n" "GPU cycles: %d (%0.1f per vertex)\n" - "Z-rast: %0.2f/%0.2f ms, %d prim, %d nopix, %d small, %d earlysize, %d zcull, %d box\n%s", + "Z-rast: %0.2f+%0.2f+%0.2f (total %0.2f/%0.2f) ms\n" + "Z-rast: %d prim, %d nopix, %d small, %d earlysize, %d zcull, %d box\n%s", gpuStats.msProcessingDisplayLists * 1000.0f, gpuStats.numDrawSyncs, gpuStats.numListSyncs, @@ -1839,7 +1840,10 @@ size_t GPUCommonHW::FormatGPUStatsCommon(char *buffer, size_t size) { gpuStats.vertexGPUCycles + gpuStats.otherGPUCycles, vertexAverageCycles, gpuStats.msPrepareDepth * 1000.0, + gpuStats.msCullDepth * 1000.0, gpuStats.msRasterizeDepth * 1000.0, + (gpuStats.msPrepareDepth + gpuStats.msCullDepth + gpuStats.msRasterizeDepth) * 1000.0, + gpuStats.msRasterTimeAvailable * 1000.0, gpuStats.numDepthRasterPrims, gpuStats.numDepthRasterNoPixels, gpuStats.numDepthRasterTooSmall,