Vulkan: Start adding object names for easier validation debugging

This commit is contained in:
Henrik Rydgård 2020-08-08 21:29:29 +02:00
parent 533a133854
commit 11f9df33ba
3 changed files with 24 additions and 0 deletions

View File

@ -694,6 +694,14 @@ VkResult VulkanContext::InitDebugUtilsCallback() {
return res;
}
void VulkanContext::SetDebugNameImpl(uint64_t handle, VkObjectType type, const char *name) {
VkDebugUtilsObjectNameInfoEXT info{ VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT };
info.pObjectName = name;
info.objectHandle = handle;
info.objectType = type;
vkSetDebugUtilsObjectNameEXT(device_, &info);
}
VkResult VulkanContext::InitSurface(WindowSystem winsys, void *data1, void *data2) {
winsys_ = winsys;
winsysData1_ = data1;

View File

@ -167,6 +167,16 @@ public:
void BeginFrame();
void EndFrame();
void SetDebugNameImpl(uint64_t handle, VkObjectType type, const char *name);
// Simple workaround for the casting warning.
template <class T>
void SetDebugName(T handle, VkObjectType type, const char *name) {
if (extensionsLookup_.EXT_debug_utils) {
SetDebugNameImpl((uint64_t)handle, type, name);
}
}
bool MemoryTypeFromProperties(uint32_t typeBits, VkFlags requirements_mask, uint32_t *typeIndex);
VkPhysicalDevice GetPhysicalDevice(int n) const {

View File

@ -37,6 +37,12 @@ public:
CreateImage(vulkan_, initCmd, color, width, height, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, true);
CreateImage(vulkan_, initCmd, depth, width, height, vulkan_->GetDeviceInfo().preferredDepthStencilFormat, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, false);
vk->SetDebugName(color.image, VK_OBJECT_TYPE_IMAGE, "fb_color");
vk->SetDebugName(color.imageView, VK_OBJECT_TYPE_IMAGE_VIEW, "fb_color_view");
vk->SetDebugName(depth.image, VK_OBJECT_TYPE_IMAGE, "fb_depth");
vk->SetDebugName(depth.imageView, VK_OBJECT_TYPE_IMAGE_VIEW, "fb_depth_view");
VkFramebufferCreateInfo fbci{ VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO };
VkImageView views[2]{};