From 1412d1e70a2c5087eebb8a7cf7a1246205d0b71d Mon Sep 17 00:00:00 2001 From: Samuliak Date: Fri, 30 Aug 2024 11:02:09 +0200 Subject: [PATCH] enable triangle fan support --- src/Cafe/HW/Latte/Core/LatteIndices.cpp | 4 ---- src/Cafe/HW/Latte/Renderer/Metal/MetalMemoryManager.cpp | 3 +++ src/Cafe/HW/Latte/Renderer/Metal/MetalPerformanceMonitor.h | 4 ++++ src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.cpp | 6 ++++++ 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Cafe/HW/Latte/Core/LatteIndices.cpp b/src/Cafe/HW/Latte/Core/LatteIndices.cpp index dc6408f9..e92f0f73 100644 --- a/src/Cafe/HW/Latte/Core/LatteIndices.cpp +++ b/src/Cafe/HW/Latte/Core/LatteIndices.cpp @@ -287,7 +287,6 @@ void LatteIndices_generateAutoLineLoopIndices(void* indexDataOutput, uint32 coun template void LatteIndices_unpackTriangleFanAndConvert(const void* indexDataInput, void* indexDataOutput, uint32 count, uint32& indexMin, uint32& indexMax) { - debug_printf("TRIANGLE FAN UNPACK %u\n", rand()); const betype* src = (betype*)indexDataInput; T* dst = (T*)indexDataOutput; // TODO: check this @@ -308,7 +307,6 @@ void LatteIndices_unpackTriangleFanAndConvert(const void* indexDataInput, void* template void LatteIndices_generateAutoTriangleFanIndices(const void* indexDataInput, void* indexDataOutput, uint32 count, uint32& indexMin, uint32& indexMax) { - debug_printf("TRIANGLE FAN AUTO %u\n", rand()); const betype* src = (betype*)indexDataInput; T* dst = (T*)indexDataOutput; for (sint32 i = 0; i < count; i++) @@ -699,7 +697,6 @@ void LatteIndices_decode(const void* indexData, LatteIndexType indexType, uint32 cemu_assert_debug(false); outputCount = count + 1; } - /* else if (primitiveMode == LattePrimitiveMode::TRIANGLE_FAN && g_renderer->GetType() == RendererAPI::Metal) { if (indexType == LatteIndexType::AUTO) @@ -723,7 +720,6 @@ void LatteIndices_decode(const void* indexData, LatteIndexType indexType, uint32 cemu_assert_debug(false); outputCount = count; } - */ else { if (indexType == LatteIndexType::U16_BE) diff --git a/src/Cafe/HW/Latte/Renderer/Metal/MetalMemoryManager.cpp b/src/Cafe/HW/Latte/Renderer/Metal/MetalMemoryManager.cpp index ef55e96d..07bd2a22 100644 --- a/src/Cafe/HW/Latte/Renderer/Metal/MetalMemoryManager.cpp +++ b/src/Cafe/HW/Latte/Renderer/Metal/MetalMemoryManager.cpp @@ -60,6 +60,9 @@ MetalRestridedBufferRange MetalVertexBufferCache::RestrideBufferIfNeeded(MTL::Bu // TODO: do the barriers in one call? MTL::Resource* barrierBuffers[] = {buffer}; renderCommandEncoder->memoryBarrier(barrierBuffers, 1, MTL::RenderStageVertex, MTL::RenderStageVertex); + + // Debug + m_mtlr->GetPerformanceMonitor().m_vertexBufferRestrides++; } else { diff --git a/src/Cafe/HW/Latte/Renderer/Metal/MetalPerformanceMonitor.h b/src/Cafe/HW/Latte/Renderer/Metal/MetalPerformanceMonitor.h index 64e94d38..100b4b39 100644 --- a/src/Cafe/HW/Latte/Renderer/Metal/MetalPerformanceMonitor.h +++ b/src/Cafe/HW/Latte/Renderer/Metal/MetalPerformanceMonitor.h @@ -7,6 +7,8 @@ public: // Per frame data uint32 m_renderPasses = 0; + uint32 m_vertexBufferRestrides = 0; + uint32 m_triangleFans = 0; MetalPerformanceMonitor() = default; ~MetalPerformanceMonitor() = default; @@ -14,5 +16,7 @@ public: void ResetPerFrameData() { m_renderPasses = 0; + m_vertexBufferRestrides = 0; + m_triangleFans = 0; } }; diff --git a/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.cpp index 392ede6d..59b18ac5 100644 --- a/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.cpp @@ -449,6 +449,8 @@ void MetalRenderer::AppendOverlayDebugInfo() ImGui::Text("--- Metal info (per frame) ---"); ImGui::Text("Command buffers %zu", m_commandBuffers.size()); ImGui::Text("Render passes %u", m_performanceMonitor.m_renderPasses); + ImGui::Text("Vertex buffer restrides %u", m_performanceMonitor.m_vertexBufferRestrides); + ImGui::Text("Triangle fans %u", m_performanceMonitor.m_triangleFans); } // TODO: halfZ @@ -1221,6 +1223,10 @@ void MetalRenderer::draw_execute(uint32 baseVertex, uint32 baseInstance, uint32 LatteStreamout_FinishDrawcall(false); + // Debug + if (primitiveMode == LattePrimitiveMode::TRIANGLE_FAN) + m_performanceMonitor.m_triangleFans++; + LatteGPUState.drawCallCounter++; }