]> git.tdb.fi Git - libs/gl.git/commitdiff
Set debug names for pipeline and descriptor set layouts on Vulkan
authorMikko Rasa <tdb@tdb.fi>
Wed, 16 Mar 2022 16:28:27 +0000 (18:28 +0200)
committerMikko Rasa <tdb@tdb.fi>
Wed, 16 Mar 2022 16:28:27 +0000 (18:28 +0200)
source/backends/vulkan/program_backend.cpp
source/backends/vulkan/program_backend.h

index 728bacbce7c6f75217c258691287e9ee164a2597..a2c40ad3fec3feb0492a49f8f3296ed8d6c1eb2b 100644 (file)
@@ -165,12 +165,18 @@ void VulkanProgram::finalize_uniforms()
        layout_info.pPushConstantRanges = &push_const_range;
 
        vk.CreatePipelineLayout(layout_info, layout_handle);
        layout_info.pPushConstantRanges = &push_const_range;
 
        vk.CreatePipelineLayout(layout_info, layout_handle);
+
+#if DEBUG
+       if(!debug_name.empty())
+               set_vulkan_object_name();
+#endif
 }
 
 void VulkanProgram::set_debug_name(const string &name)
 {
 #ifdef DEBUG
        debug_name = name;
 }
 
 void VulkanProgram::set_debug_name(const string &name)
 {
 #ifdef DEBUG
        debug_name = name;
+       set_vulkan_object_name();
        if(SpirVModule *spirv = static_cast<Program *>(this)->specialized_spirv)
                spirv->set_debug_name(debug_name);
 #else
        if(SpirVModule *spirv = static_cast<Program *>(this)->specialized_spirv)
                spirv->set_debug_name(debug_name);
 #else
@@ -178,5 +184,30 @@ void VulkanProgram::set_debug_name(const string &name)
 #endif
 }
 
 #endif
 }
 
+void VulkanProgram::set_vulkan_object_name() const
+{
+#ifdef DEBUG
+       const VulkanFunctions &vk = device.get_functions();
+
+       string layout_name = debug_name+" [layout]";
+
+       VkDebugUtilsObjectNameInfoEXT name_info = { };
+       name_info.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;
+       name_info.objectType = VK_OBJECT_TYPE_PIPELINE_LAYOUT;
+       name_info.objectHandle = reinterpret_cast<uint64_t>(layout_handle);
+       name_info.pObjectName = layout_name.c_str();
+       vk.SetDebugUtilsObjectName(name_info);
+
+       name_info.objectType = VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT;
+       for(unsigned i=0; i<desc_set_layout_handles.size(); ++i)
+       {
+               layout_name = format("%s [layout:%d]", debug_name, i);
+       name_info.objectHandle = reinterpret_cast<uint64_t>(desc_set_layout_handles[i]);
+               name_info.pObjectName = layout_name.c_str();
+               vk.SetDebugUtilsObjectName(name_info);
+       }
+#endif
+}
+
 } // namespace GL
 } // namespace Msp
 } // namespace GL
 } // namespace Msp
index ff39aa4e46857858b804d983a0bf2d38f5b387cc..16cf7b27f9756c0dca5e4662784419e36f91766c 100644 (file)
@@ -39,6 +39,7 @@ protected:
        void finalize_uniforms();
 
        void set_debug_name(const std::string &);
        void finalize_uniforms();
 
        void set_debug_name(const std::string &);
+       void set_vulkan_object_name() const;
 };
 
 using ProgramBackend = VulkanProgram;
 };
 
 using ProgramBackend = VulkanProgram;