From 757a9532e65625afd54e18fe64b2f7d42fb461c1 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Mon, 24 Apr 2023 23:25:02 +1000 Subject: [PATCH] GS: Add Render Pass stats --- pcsx2/GS/GS.cpp | 3 ++- pcsx2/GS/GSPerfMon.h | 2 +- pcsx2/GS/Renderers/DX11/GSDevice11.cpp | 6 +++++- pcsx2/GS/Renderers/DX12/GSDevice12.cpp | 7 ++++++- pcsx2/GS/Renderers/Metal/GSDeviceMTL.mm | 1 + pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp | 2 ++ pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp | 6 ++++-- 7 files changed, 21 insertions(+), 6 deletions(-) diff --git a/pcsx2/GS/GS.cpp b/pcsx2/GS/GS.cpp index e2a47c644f..e457236887 100644 --- a/pcsx2/GS/GS.cpp +++ b/pcsx2/GS/GS.cpp @@ -748,12 +748,13 @@ void GSgetStats(std::string& info) } else { - fmt::format_to(std::back_inserter(info), "{} HW | {} P | {} D | {} DC | {} B | {} RB | {} TC | {} TU", + fmt::format_to(std::back_inserter(info), "{} HW | {} P | {} D | {} DC | {} B | {} RP | {} RB | {} TC | {} TU", api_name, (int)pm.Get(GSPerfMon::Prim), (int)pm.Get(GSPerfMon::Draw), (int)std::ceil(pm.Get(GSPerfMon::DrawCalls)), (int)std::ceil(pm.Get(GSPerfMon::Barriers)), + (int)std::ceil(pm.Get(GSPerfMon::RenderPasses)), (int)std::ceil(pm.Get(GSPerfMon::Readbacks)), (int)std::ceil(pm.Get(GSPerfMon::TextureCopies)), (int)std::ceil(pm.Get(GSPerfMon::TextureUploads))); diff --git a/pcsx2/GS/GSPerfMon.h b/pcsx2/GS/GSPerfMon.h index 0dbfd6e838..75e8bff84e 100644 --- a/pcsx2/GS/GSPerfMon.h +++ b/pcsx2/GS/GSPerfMon.h @@ -27,9 +27,9 @@ public: Swizzle, Unswizzle, Fillrate, - Quad, SyncPoint, Barriers, + RenderPasses, CounterLast, // Reused counters for HW. diff --git a/pcsx2/GS/Renderers/DX11/GSDevice11.cpp b/pcsx2/GS/Renderers/DX11/GSDevice11.cpp index ab708e8fb5..cc282e3136 100644 --- a/pcsx2/GS/Renderers/DX11/GSDevice11.cpp +++ b/pcsx2/GS/Renderers/DX11/GSDevice11.cpp @@ -883,7 +883,9 @@ GSDevice::PresentResult GSDevice11::BeginPresent(bool frame_skip) { m_state.dsv->Release(); m_state.dsv = nullptr; - } + } + + g_perfmon.Put(GSPerfMon::RenderPasses, 1); const GSVector2i size = GetWindowSize(); SetViewport(size); @@ -2063,6 +2065,8 @@ void GSDevice11::OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVector if (ds) dsv = *(GSTexture11*)ds; const bool changed = (m_state.rt_view != rtv || m_state.dsv != dsv); + g_perfmon.Put(GSPerfMon::RenderPasses, static_cast(changed)); + if (m_state.rt_view != rtv) { if (m_state.rt_view) diff --git a/pcsx2/GS/Renderers/DX12/GSDevice12.cpp b/pcsx2/GS/Renderers/DX12/GSDevice12.cpp index afc21e36c0..448113ce1d 100644 --- a/pcsx2/GS/Renderers/DX12/GSDevice12.cpp +++ b/pcsx2/GS/Renderers/DX12/GSDevice12.cpp @@ -538,6 +538,7 @@ GSDevice::PresentResult GSDevice12::BeginPresent(bool frame_skip) swap_chain_buf.TransitionToState(cmdlist, D3D12_RESOURCE_STATE_RENDER_TARGET); cmdlist->ClearRenderTargetView(swap_chain_buf.GetWriteDescriptor(), clear_color.data(), 0, nullptr); cmdlist->OMSetRenderTargets(1, &swap_chain_buf.GetWriteDescriptor().cpu_handle, FALSE, nullptr); + g_perfmon.Put(GSPerfMon::RenderPasses, 1); const D3D12_VIEWPORT vp{0.0f, 0.0f, static_cast(m_window_info.surface_width), static_cast(m_window_info.surface_height), 0.0f, 1.0f}; @@ -2746,11 +2747,15 @@ void GSDevice12::EndRenderPass() if (!m_in_render_pass) return; - g_d3d12_context->GetCommandList()->EndRenderPass(); m_in_render_pass = false; // to render again, we need to reset OM m_dirty_flags |= DIRTY_FLAG_RENDER_TARGET; + + g_perfmon.Put(GSPerfMon::RenderPasses, 1); + + g_d3d12_context->GetCommandList()->EndRenderPass(); + } void GSDevice12::SetViewport(const D3D12_VIEWPORT& viewport) diff --git a/pcsx2/GS/Renderers/Metal/GSDeviceMTL.mm b/pcsx2/GS/Renderers/Metal/GSDeviceMTL.mm index c963aabcdd..2346d5d03f 100644 --- a/pcsx2/GS/Renderers/Metal/GSDeviceMTL.mm +++ b/pcsx2/GS/Renderers/Metal/GSDeviceMTL.mm @@ -371,6 +371,7 @@ void GSDeviceMTL::EndRenderPass() if (m_current_render.encoder) { EndDebugGroup(m_current_render.encoder); + g_perfmon.Put(GSPerfMon::RenderPasses, 1); if (m_spin_timer) [m_current_render.encoder updateFence:m_spin_fence afterStages:MTLRenderStageFragment]; [m_current_render.encoder endEncoding]; diff --git a/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp b/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp index 4f7b4727b1..3b9395fd20 100644 --- a/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp +++ b/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp @@ -2156,6 +2156,8 @@ void GSDeviceOGL::OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVecto GSTextureOGL* RT = static_cast(rt); GSTextureOGL* DS = static_cast(ds); + g_perfmon.Put(GSPerfMon::RenderPasses, static_cast(GLState::rt != RT || GLState::ds != DS)); + OMSetFBO(m_fbo); if (rt) { diff --git a/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp b/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp index 497f2e53df..dead6ad427 100644 --- a/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp +++ b/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp @@ -475,6 +475,7 @@ void GSDeviceVK::EndPresent() VkCommandBuffer cmdbuffer = g_vulkan_context->GetCurrentCommandBuffer(); vkCmdEndRenderPass(g_vulkan_context->GetCurrentCommandBuffer()); m_swap_chain->GetCurrentTexture().TransitionToLayout(cmdbuffer, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR); + g_perfmon.Put(GSPerfMon::RenderPasses, 1); g_vulkan_context->SubmitCommandBuffer(m_swap_chain.get(), !m_swap_chain->IsPresentModeSynchronizing()); g_vulkan_context->MoveToNextCommandBuffer(); @@ -3100,9 +3101,10 @@ void GSDeviceVK::EndRenderPass() if (m_current_render_pass == VK_NULL_HANDLE) return; - vkCmdEndRenderPass(g_vulkan_context->GetCurrentCommandBuffer()); - m_current_render_pass = VK_NULL_HANDLE; + g_perfmon.Put(GSPerfMon::RenderPasses, 1); + + vkCmdEndRenderPass(g_vulkan_context->GetCurrentCommandBuffer()); } void GSDeviceVK::SetViewport(const VkViewport& viewport)