~OpenGLSpirVModule() = default;
void create() { }
+
+ void set_debug_name(const std::string &) { }
};
using SpirVModuleBackend = OpenGLSpirVModule;
module_info.pCode = code.data();
vk.CreateShaderModule(module_info, handle);
+
+ if(!debug_name.empty())
+ set_vulkan_object_name();
+}
+
+void VulkanSpirVModule::set_debug_name(const string &name)
+{
+#ifdef DEBUG
+ debug_name = name;
+ if(handle)
+ set_vulkan_object_name();
+#else
+ (void)name;
+#endif
+}
+
+void VulkanSpirVModule::set_vulkan_object_name() const
+{
+#ifdef DEBUG
+ const VulkanFunctions &vk = device.get_functions();
+
+ VkDebugUtilsObjectNameInfoEXT name_info = { };
+ name_info.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;
+ name_info.objectType = VK_OBJECT_TYPE_SHADER_MODULE;
+ name_info.objectHandle = reinterpret_cast<uint64_t>(handle);
+ name_info.pObjectName = debug_name.c_str();
+ vk.SetDebugUtilsObjectName(name_info);
+#endif
}
protected:
Device &device;
VkShaderModule handle = 0;
+ std::string debug_name;
VulkanSpirVModule();
VulkanSpirVModule(VulkanSpirVModule &&);
~VulkanSpirVModule();
void create();
+
+ void set_debug_name(const std::string &);
+ void set_vulkan_object_name() const;
};
using SpirVModuleBackend = VulkanSpirVModule;
stage_flags(other.stage_flags),
creation_info(move(other.creation_info)),
desc_set_layout_handles(move(other.desc_set_layout_handles)),
- layout_handle(other.layout_handle)
+ layout_handle(other.layout_handle),
+ debug_name(move(other.debug_name))
{
other.desc_set_layout_handles.clear();
other.layout_handle = 0;
stage_infos[i].pSpecializationInfo = spec_info;
++i;
}
+
+#if DEBUG
+ if(!debug_name.empty())
+ if(SpirVModule *spirv = static_cast<Program *>(this)->specialized_spirv)
+ spirv->set_debug_name(debug_name);
+#endif
}
void VulkanProgram::finalize_uniforms()
vk.CreatePipelineLayout(layout_info, layout_handle);
}
+void VulkanProgram::set_debug_name(const string &name)
+{
+#ifdef DEBUG
+ debug_name = name;
+ if(SpirVModule *spirv = static_cast<Program *>(this)->specialized_spirv)
+ spirv->set_debug_name(debug_name);
+#else
+ (void)name;
+#endif
+}
+
} // namespace GL
} // namespace Msp
std::vector<char> creation_info;
std::vector<VkDescriptorSetLayout> desc_set_layout_handles;
VkPipelineLayout layout_handle = 0;
+ std::string debug_name;
VulkanProgram();
VulkanProgram(VulkanProgram &&);
void finalize_uniforms();
- void set_debug_name(const std::string &) { }
+ void set_debug_name(const std::string &);
};
using ProgramBackend = VulkanProgram;
virtual void compile(SL::Compiler &) = 0;
SL::Features create_features() const;
+
+public:
+ virtual void set_debug_name(const std::string &) { }
};
/**
private:
std::vector<const InstructionBlock *> collect_visited_blocks(const std::map<unsigned, int> &) const;
void collect_visited_blocks(unsigned, std::vector<std::uint8_t> &) const;
+
+public:
+ void set_debug_name(const std::string &n) { SpirVModuleBackend::set_debug_name(n); }
};
} // namespace GL
.creator([this](const string &n){ return create_mesh(n); })
.notify(&set_debug_name<Mesh>);
add_type<Module>().suffix(".glsl").suffix(".spv")
- .creator([this](const string &n){ return create_module(n); });
+ .creator([this](const string &n){ return create_module(n); })
+ .notify(&set_debug_name<Module>);
add_type<Object>().base<Renderable>().keyword("object");
add_type<OccludedScene>().base<Scene>().base<Renderable>().suffix(".scene")
.creator([this](const string &n) -> OccludedScene * { create_generic<Scene>(n); return 0; });