From ca4ee8303871e2f907e884fa98540558d55c7b33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 19 Sep 2023 11:17:25 +0200 Subject: [PATCH] Vulkan: Add debug names to renderpasses --- Common/GPU/Vulkan/VulkanFramebuffer.cpp | 33 +++++++++++++++++++++++++ Common/GPU/Vulkan/VulkanFramebuffer.h | 2 ++ Common/GPU/Vulkan/VulkanQueueRunner.cpp | 22 +---------------- 3 files changed, 36 insertions(+), 21 deletions(-) diff --git a/Common/GPU/Vulkan/VulkanFramebuffer.cpp b/Common/GPU/Vulkan/VulkanFramebuffer.cpp index 975dab04bd..cf1db13d7a 100644 --- a/Common/GPU/Vulkan/VulkanFramebuffer.cpp +++ b/Common/GPU/Vulkan/VulkanFramebuffer.cpp @@ -2,6 +2,35 @@ #include "Common/GPU/Vulkan/VulkanFramebuffer.h" #include "Common/GPU/Vulkan/VulkanQueueRunner.h" +static const char *rpTypeDebugNames[] = { + "RENDER", + "RENDER_DEPTH", + "RENDER_INPUT", + "RENDER_DEPTH_INPUT", + "MV_RENDER", + "MV_RENDER_DEPTH", + "MV_RENDER_INPUT", + "MV_RENDER_DEPTH_INPUT", + "MS_RENDER", + "MS_RENDER_DEPTH", + "MS_RENDER_INPUT", + "MS_RENDER_DEPTH_INPUT", + "MS_MV_RENDER", + "MS_MV_RENDER_DEPTH", + "MS_MV_RENDER_INPUT", + "MS_MV_RENDER_DEPTH_INPUT", + "BACKBUF", +}; + +const char *GetRPTypeName(RenderPassType rpType) { + uint32_t index = (uint32_t)rpType; + if (index < ARRAY_SIZE(rpTypeDebugNames)) { + return rpTypeDebugNames[index]; + } else { + return "N/A"; + } +} + VkSampleCountFlagBits MultiSampleLevelToFlagBits(int count) { // TODO: Check hardware support here, or elsewhere? // Some hardware only supports 4x. @@ -494,6 +523,10 @@ VkRenderPass CreateRenderPass(VulkanContext *vulkan, const RPKey &key, RenderPas res = vkCreateRenderPass(vulkan->GetDevice(), &rp, nullptr, &pass); } + if (pass) { + vulkan->SetDebugName(pass, VK_OBJECT_TYPE_RENDER_PASS, GetRPTypeName(rpType)); + } + _assert_(res == VK_SUCCESS); _assert_(pass != VK_NULL_HANDLE); return pass; diff --git a/Common/GPU/Vulkan/VulkanFramebuffer.h b/Common/GPU/Vulkan/VulkanFramebuffer.h index 465983efaa..97ff9e367a 100644 --- a/Common/GPU/Vulkan/VulkanFramebuffer.h +++ b/Common/GPU/Vulkan/VulkanFramebuffer.h @@ -157,3 +157,5 @@ private: VkSampleCountFlagBits sampleCounts[(size_t)RenderPassType::TYPE_COUNT]; RPKey key_; }; + +const char *GetRPTypeName(RenderPassType rpType); diff --git a/Common/GPU/Vulkan/VulkanQueueRunner.cpp b/Common/GPU/Vulkan/VulkanQueueRunner.cpp index c4a04f90bc..e6bb324f76 100644 --- a/Common/GPU/Vulkan/VulkanQueueRunner.cpp +++ b/Common/GPU/Vulkan/VulkanQueueRunner.cpp @@ -674,26 +674,6 @@ const char *AspectToString(VkImageAspectFlags aspect) { } } -static const char *rpTypeDebugNames[] = { - "RENDER", - "RENDER_DEPTH", - "RENDER_INPUT", - "RENDER_DEPTH_INPUT", - "MV_RENDER", - "MV_RENDER_DEPTH", - "MV_RENDER_INPUT", - "MV_RENDER_DEPTH_INPUT", - "MS_RENDER", - "MS_RENDER_DEPTH", - "MS_RENDER_INPUT", - "MS_RENDER_DEPTH_INPUT", - "MS_MV_RENDER", - "MS_MV_RENDER_DEPTH", - "MS_MV_RENDER_INPUT", - "MS_MV_RENDER_DEPTH_INPUT", - "BACKBUF", -}; - std::string VulkanQueueRunner::StepToString(VulkanContext *vulkan, const VKRStep &step) { char buffer[256]; switch (step.stepType) { @@ -703,7 +683,7 @@ std::string VulkanQueueRunner::StepToString(VulkanContext *vulkan, const VKRStep int h = step.render.framebuffer ? step.render.framebuffer->height : vulkan->GetBackbufferHeight(); int actual_w = step.render.renderArea.extent.width; int actual_h = step.render.renderArea.extent.height; - const char *renderCmd = rpTypeDebugNames[(size_t)step.render.renderPassType]; + const char *renderCmd = GetRPTypeName(step.render.renderPassType); snprintf(buffer, sizeof(buffer), "%s %s %s (draws: %d, %dx%d/%dx%d)", renderCmd, step.tag, step.render.framebuffer ? step.render.framebuffer->Tag() : "", step.render.numDraws, actual_w, actual_h, w, h); break; }