@@ -262,29 +262,15 @@ struct CommandLineParameters
262262 }
263263} g_CommandLineParameters;
264264
265- void SetDebugUtilsObjectName (VkObjectType type, uint64_t handle, std::string name)
265+ void SetDebugUtilsObjectName (VkObjectType type, uint64_t handle, const std::string & name)
266266{
267- TEST (!name.empty ());
268-
269- // We must make sure the std::string we pass as name is still valid memory until the program ends.
270- // Since Vulkan is a C-Style API, it only accepts const char* as pObjectName parameter.
271- // Naming objects with unformatted names like "g_hTemporaryCommandBuffer" is no problem because
272- // this string ends up in the read-only data section of the program. However, if we for example want to
273- // name every item in a dynamic array of items (swapchain images for example), we can only use a std::string,
274- // and we must make sure the object lifetime of that string does not end before it's read as pObjectName.
275- // Therefore, we store the strings as a static unordered_set here just to be sure.
276- // Do not use a std::vector because it would continue to grow, eventually running out of memory.
277- static std::unordered_set<std::string> debug_names;
278- auto result = debug_names.insert (name);
279- const char * pObjectName = result.first ->c_str ();
280-
281267 if (vkSetDebugUtilsObjectNameEXT_Func == nullptr )
282268 return ;
283269
284270 VkDebugUtilsObjectNameInfoEXT info = { VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT };
285271 info.objectType = type;
286272 info.objectHandle = handle;
287- info.pObjectName = pObjectName ;
273+ info.pObjectName = name. c_str () ;
288274 ERR_GUARD_VULKAN ( vkSetDebugUtilsObjectNameEXT_Func (g_hDevice, &info) );
289275}
290276
0 commit comments