diff --git a/src/vulkan/vulkan-backend.h b/src/vulkan/vulkan-backend.h index a1599e9..64f2612 100644 --- a/src/vulkan/vulkan-backend.h +++ b/src/vulkan/vulkan-backend.h @@ -172,8 +172,8 @@ namespace nvrhi::vulkan bool EXT_conservative_rasterization = false; bool EXT_opacity_micromap = false; bool NV_ray_tracing_invocation_reorder = false; -#if NVRHI_WITH_AFTERMATH bool EXT_debug_utils = false; +#if NVRHI_WITH_AFTERMATH bool NV_device_diagnostic_checkpoints = false; bool NV_device_diagnostics_config= false; #endif @@ -194,7 +194,8 @@ namespace nvrhi::vulkan #endif vk::DescriptorSetLayout emptyDescriptorSetLayout; - void nameVKObject(const void* handle, vk::DebugReportObjectTypeEXT objtype, const char* name) const; + void nameVKObject(const void* handle, const vk::ObjectType objtype, + const vk::DebugReportObjectTypeEXT objtypeEXT, const char* name) const; void error(const std::string& message) const; void warning(const std::string& message) const; }; diff --git a/src/vulkan/vulkan-buffer.cpp b/src/vulkan/vulkan-buffer.cpp index 45cb502..2b17b42 100644 --- a/src/vulkan/vulkan-buffer.cpp +++ b/src/vulkan/vulkan-buffer.cpp @@ -129,14 +129,14 @@ namespace nvrhi::vulkan vk::Result res = m_Context.device.createBuffer(&bufferInfo, m_Context.allocationCallbacks, &buffer->buffer); CHECK_VK_FAIL(res); - m_Context.nameVKObject(VkBuffer(buffer->buffer), vk::DebugReportObjectTypeEXT::eBuffer, desc.debugName.c_str()); + m_Context.nameVKObject(VkBuffer(buffer->buffer), vk::ObjectType::eBuffer, vk::DebugReportObjectTypeEXT::eBuffer, desc.debugName.c_str()); if (!desc.isVirtual) { res = m_Allocator.allocateBufferMemory(buffer, (usageFlags & vk::BufferUsageFlagBits::eShaderDeviceAddress) != vk::BufferUsageFlags(0)); CHECK_VK_FAIL(res) - m_Context.nameVKObject(buffer->memory, vk::DebugReportObjectTypeEXT::eDeviceMemory, desc.debugName.c_str()); + m_Context.nameVKObject(buffer->memory, vk::ObjectType::eDeviceMemory, vk::DebugReportObjectTypeEXT::eDeviceMemory, desc.debugName.c_str()); if (desc.isVolatile) { diff --git a/src/vulkan/vulkan-device.cpp b/src/vulkan/vulkan-device.cpp index fcb661a..9bd600c 100644 --- a/src/vulkan/vulkan-device.cpp +++ b/src/vulkan/vulkan-device.cpp @@ -71,21 +71,21 @@ namespace nvrhi::vulkan // maps Vulkan extension strings into the corresponding boolean flags in Device const std::unordered_map extensionStringMap = { - { VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME, &m_Context.extensions.KHR_synchronization2 }, - { VK_KHR_MAINTENANCE1_EXTENSION_NAME, &m_Context.extensions.KHR_maintenance1 }, - { VK_EXT_DEBUG_REPORT_EXTENSION_NAME, &m_Context.extensions.EXT_debug_report }, + { VK_EXT_CONSERVATIVE_RASTERIZATION_EXTENSION_NAME, &m_Context.extensions.EXT_conservative_rasterization}, { VK_EXT_DEBUG_MARKER_EXTENSION_NAME, &m_Context.extensions.EXT_debug_marker }, + { VK_EXT_DEBUG_REPORT_EXTENSION_NAME, &m_Context.extensions.EXT_debug_report }, + { VK_EXT_DEBUG_UTILS_EXTENSION_NAME, &m_Context.extensions.EXT_debug_utils }, + { VK_EXT_OPACITY_MICROMAP_EXTENSION_NAME, &m_Context.extensions.EXT_opacity_micromap }, { VK_KHR_ACCELERATION_STRUCTURE_EXTENSION_NAME, &m_Context.extensions.KHR_acceleration_structure }, { VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME, &m_Context.extensions.buffer_device_address }, + { VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME, &m_Context.extensions.KHR_fragment_shading_rate }, + { VK_KHR_MAINTENANCE1_EXTENSION_NAME, &m_Context.extensions.KHR_maintenance1 }, { VK_KHR_RAY_QUERY_EXTENSION_NAME,&m_Context.extensions.KHR_ray_query }, { VK_KHR_RAY_TRACING_PIPELINE_EXTENSION_NAME, &m_Context.extensions.KHR_ray_tracing_pipeline }, + { VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME, &m_Context.extensions.KHR_synchronization2 }, { VK_NV_MESH_SHADER_EXTENSION_NAME, &m_Context.extensions.NV_mesh_shader }, - { VK_EXT_CONSERVATIVE_RASTERIZATION_EXTENSION_NAME, &m_Context.extensions.EXT_conservative_rasterization}, - { VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME, &m_Context.extensions.KHR_fragment_shading_rate }, - { VK_EXT_OPACITY_MICROMAP_EXTENSION_NAME, &m_Context.extensions.EXT_opacity_micromap }, { VK_NV_RAY_TRACING_INVOCATION_REORDER_EXTENSION_NAME, &m_Context.extensions.NV_ray_tracing_invocation_reorder }, #if NVRHI_WITH_AFTERMATH - { VK_EXT_DEBUG_UTILS_EXTENSION_NAME, &m_Context.extensions.EXT_debug_utils }, { VK_NV_DEVICE_DIAGNOSTIC_CHECKPOINTS_EXTENSION_NAME, &m_Context.extensions.NV_device_diagnostic_checkpoints }, { VK_NV_DEVICE_DIAGNOSTICS_CONFIG_EXTENSION_NAME, &m_Context.extensions.NV_device_diagnostics_config } #endif @@ -576,7 +576,7 @@ namespace nvrhi::vulkan if (!d.debugName.empty()) { - m_Context.nameVKObject(heap->memory, vk::DebugReportObjectTypeEXT::eDeviceMemory, d.debugName.c_str()); + m_Context.nameVKObject(heap->memory, vk::ObjectType::eDeviceMemory, vk::DebugReportObjectTypeEXT::eDeviceMemory, d.debugName.c_str()); } return HeapHandle::Create(heap); @@ -591,27 +591,29 @@ namespace nvrhi::vulkan } } - void VulkanContext::nameVKObject(const void* handle, const vk::DebugReportObjectTypeEXT objtype, const char* name) const + void VulkanContext::nameVKObject(const void* handle, const vk::ObjectType objtype, + const vk::DebugReportObjectTypeEXT objtypeEXT, const char* name) const { - if (extensions.EXT_debug_marker && name && *name && handle) - { - auto info = vk::DebugMarkerObjectNameInfoEXT() - .setObjectType(objtype) - .setObject(reinterpret_cast(handle)) - .setPObjectName(name); + if (!(name && *name && handle)) + return; - (void)device.debugMarkerSetObjectNameEXT(&info); - } -#if NVRHI_WITH_AFTERMATH - if (extensions.EXT_debug_utils && name && *name) + if (extensions.EXT_debug_utils) { auto info = vk::DebugUtilsObjectNameInfoEXT() - .setObjectType(vk::ObjectType::eUnknown) + .setObjectType(objtype) .setObjectHandle(reinterpret_cast(handle)) .setPObjectName(name); device.setDebugUtilsObjectNameEXT(info); } -#endif + else if (extensions.EXT_debug_marker) + { + auto info = vk::DebugMarkerObjectNameInfoEXT() + .setObjectType(objtypeEXT) + .setObject(reinterpret_cast(handle)) + .setPObjectName(name); + + (void)device.debugMarkerSetObjectNameEXT(&info); + } } void VulkanContext::error(const std::string& message) const diff --git a/src/vulkan/vulkan-queries.cpp b/src/vulkan/vulkan-queries.cpp index 06593f5..956403e 100644 --- a/src/vulkan/vulkan-queries.cpp +++ b/src/vulkan/vulkan-queries.cpp @@ -209,7 +209,15 @@ namespace nvrhi::vulkan void CommandList::beginMarker(const char* name) { - if (m_Context.extensions.EXT_debug_marker) + if (m_Context.extensions.EXT_debug_utils) + { + assert(m_CurrentCmdBuf); + + auto label = vk::DebugUtilsLabelEXT() + .setPLabelName(name); + m_CurrentCmdBuf->cmdBuf.beginDebugUtilsLabelEXT(&label); + } + else if (m_Context.extensions.EXT_debug_marker) { assert(m_CurrentCmdBuf); @@ -217,6 +225,7 @@ namespace nvrhi::vulkan .setPMarkerName(name); m_CurrentCmdBuf->cmdBuf.debugMarkerBeginEXT(&markerInfo); } + #if NVRHI_WITH_AFTERMATH if (m_Device->isAftermathEnabled()) { @@ -228,12 +237,19 @@ namespace nvrhi::vulkan void CommandList::endMarker() { - if (m_Context.extensions.EXT_debug_marker) + if (m_Context.extensions.EXT_debug_utils) + { + assert(m_CurrentCmdBuf); + + m_CurrentCmdBuf->cmdBuf.endDebugUtilsLabelEXT(); + } + else if (m_Context.extensions.EXT_debug_marker) { assert(m_CurrentCmdBuf); m_CurrentCmdBuf->cmdBuf.debugMarkerEndEXT(); } + #if NVRHI_WITH_AFTERMATH m_AftermathTracker.popEvent(); #endif diff --git a/src/vulkan/vulkan-shader.cpp b/src/vulkan/vulkan-shader.cpp index c288626..8a6d649 100644 --- a/src/vulkan/vulkan-shader.cpp +++ b/src/vulkan/vulkan-shader.cpp @@ -41,7 +41,7 @@ namespace nvrhi::vulkan CHECK_VK_FAIL(res) const std::string debugName = desc.debugName + ":" + desc.entryName; - m_Context.nameVKObject(VkShaderModule(shader->shaderModule), vk::DebugReportObjectTypeEXT::eShaderModule, debugName.c_str()); + m_Context.nameVKObject(VkShaderModule(shader->shaderModule), vk::ObjectType::eShaderModule, vk::DebugReportObjectTypeEXT::eShaderModule, debugName.c_str()); return ShaderHandle::Create(shader); } diff --git a/src/vulkan/vulkan-texture.cpp b/src/vulkan/vulkan-texture.cpp index 8fa664e..45ba50e 100644 --- a/src/vulkan/vulkan-texture.cpp +++ b/src/vulkan/vulkan-texture.cpp @@ -321,7 +321,7 @@ namespace nvrhi::vulkan ASSERT_VK_OK(res); const std::string debugName = std::string("ImageView for: ") + utils::DebugNameToString(desc.debugName); - m_Context.nameVKObject(VkImageView(view.view), vk::DebugReportObjectTypeEXT::eImageView, debugName.c_str()); + m_Context.nameVKObject(VkImageView(view.view), vk::ObjectType::eImageView, vk::DebugReportObjectTypeEXT::eImageView, debugName.c_str()); return view; } @@ -336,7 +336,7 @@ namespace nvrhi::vulkan ASSERT_VK_OK(res); CHECK_VK_FAIL(res) - m_Context.nameVKObject(texture->image, vk::DebugReportObjectTypeEXT::eImage, desc.debugName.c_str()); + m_Context.nameVKObject(texture->image, vk::ObjectType::eImage, vk::DebugReportObjectTypeEXT::eImage, desc.debugName.c_str()); if (!desc.isVirtual) { @@ -353,7 +353,7 @@ namespace nvrhi::vulkan #endif } - m_Context.nameVKObject(texture->memory, vk::DebugReportObjectTypeEXT::eDeviceMemory, desc.debugName.c_str()); + m_Context.nameVKObject(texture->memory, vk::ObjectType::eDeviceMemory, vk::DebugReportObjectTypeEXT::eDeviceMemory, desc.debugName.c_str()); } return TextureHandle::Create(texture);