From 2ef44e6d74cba7ae0e129d182c8272f15283850b Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Wed, 6 Nov 2024 12:30:26 +0100 Subject: [PATCH] [dxvk] Add debug name support to DxvkImage --- src/dxvk/dxvk_image.cpp | 8 ++++++++ src/dxvk/dxvk_image.h | 5 +++++ src/dxvk/dxvk_memory.cpp | 10 ++++++++++ 3 files changed, 23 insertions(+) diff --git a/src/dxvk/dxvk_image.cpp b/src/dxvk/dxvk_image.cpp index bc25c49be..e9fe1ffb8 100644 --- a/src/dxvk/dxvk_image.cpp +++ b/src/dxvk/dxvk_image.cpp @@ -14,6 +14,13 @@ namespace dxvk { m_properties (memFlags), m_shaderStages (util::shaderStages(createInfo.stages)), m_info (createInfo) { + if (device->isDebugEnabled()) { + m_debugName = str::format(createInfo.debugName ? createInfo.debugName : "Image", " (", cookie(), ")"); + m_info.debugName = m_debugName.data(); + } else { + m_info.debugName = nullptr; + } + m_allocator->registerResource(this); copyFormatList(createInfo.viewFormatCount, createInfo.viewFormats); @@ -184,6 +191,7 @@ namespace dxvk { allocationInfo.resourceCookie = cookie(); allocationInfo.properties = m_properties; allocationInfo.mode = mode; + allocationInfo.debugName = m_info.debugName; return m_allocator->createImageResource(imageInfo, allocationInfo, sharedMemoryInfo); diff --git a/src/dxvk/dxvk_image.h b/src/dxvk/dxvk_image.h index f98184370..4a1740e80 100644 --- a/src/dxvk/dxvk_image.h +++ b/src/dxvk/dxvk_image.h @@ -66,6 +66,9 @@ namespace dxvk { // Shared handle info DxvkSharedHandleInfo sharing = { }; + + /// Debug name + const char* debugName = nullptr; }; @@ -626,6 +629,8 @@ namespace dxvk { std::unordered_map m_views; + std::string m_debugName; + VkImageCreateInfo getImageCreateInfo( const DxvkImageUsageInfo& usageInfo) const; diff --git a/src/dxvk/dxvk_memory.cpp b/src/dxvk/dxvk_memory.cpp index be6c1c709..8c39c193e 100644 --- a/src/dxvk/dxvk_memory.cpp +++ b/src/dxvk/dxvk_memory.cpp @@ -1038,6 +1038,16 @@ namespace dxvk { } } + // Assign debug name to the image + if (allocationInfo.debugName && m_device->isDebugEnabled()) { + VkDebugUtilsObjectNameInfoEXT name = { VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT }; + name.objectType = VK_OBJECT_TYPE_IMAGE; + name.objectHandle = reinterpret_cast(image); + name.pObjectName = allocationInfo.debugName; + + vk->vkSetDebugUtilsObjectNameEXT(vk->device(), &name); + } + return allocation; }