2828#include " Common.h"
2929#include < atomic>
3030#include < Shlwapi.h>
31+ #include < unordered_set>
3132
3233#pragma comment(lib, "shlwapi.lib")
3334
@@ -86,7 +87,7 @@ static std::vector<VkImageView> g_SwapchainImageViews;
8687static std::vector<VkFramebuffer> g_Framebuffers;
8788static VkCommandPool g_hCommandPool;
8889static VkCommandBuffer g_MainCommandBuffers[COMMAND_BUFFER_COUNT];
89- static VkFence g_MainCommandBufferExecutedFances [COMMAND_BUFFER_COUNT];
90+ static VkFence g_MainCommandBufferExecutedFences [COMMAND_BUFFER_COUNT];
9091VkFence g_ImmediateFence;
9192static uint32_t g_NextCommandBufferIndex;
9293// Notice we need as many semaphores as there are swapchain images
@@ -261,16 +262,16 @@ struct CommandLineParameters
261262 }
262263} g_CommandLineParameters;
263264
264- void SetDebugUtilsObjectName (VkObjectType type, uint64_t handle, const char * name)
265+ void SetDebugUtilsObjectName (VkObjectType type, uint64_t handle, const std::string & name)
265266{
266- if (vkSetDebugUtilsObjectNameEXT_Func == nullptr )
267+ if (vkSetDebugUtilsObjectNameEXT_Func == nullptr )
267268 return ;
268269
269270 VkDebugUtilsObjectNameInfoEXT info = { VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT };
270271 info.objectType = type;
271272 info.objectHandle = handle;
272- info.pObjectName = name;
273- vkSetDebugUtilsObjectNameEXT_Func (g_hDevice, &info);
273+ info.pObjectName = name. c_str () ;
274+ ERR_GUARD_VULKAN ( vkSetDebugUtilsObjectNameEXT_Func (g_hDevice, &info) );
274275}
275276
276277void BeginSingleTimeCommands ()
@@ -284,6 +285,8 @@ void EndSingleTimeCommands()
284285{
285286 ERR_GUARD_VULKAN ( vkEndCommandBuffer (g_hTemporaryCommandBuffer) );
286287
288+ SetDebugUtilsObjectName (VK_OBJECT_TYPE_COMMAND_BUFFER, reinterpret_cast <std::uint64_t >(g_hTemporaryCommandBuffer), " g_hTemporaryCommandBuffer" );
289+
287290 VkSubmitInfo submitInfo = { VK_STRUCTURE_TYPE_SUBMIT_INFO };
288291 submitInfo.commandBufferCount = 1 ;
289292 submitInfo.pCommandBuffers = &g_hTemporaryCommandBuffer;
@@ -700,6 +703,7 @@ static void CreateMesh()
700703 vbInfo.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT;
701704 vbAllocCreateInfo.flags = 0 ;
702705 ERR_GUARD_VULKAN ( vmaCreateBuffer (g_hAllocator, &vbInfo, &vbAllocCreateInfo, &g_hVertexBuffer, &g_hVertexBufferAlloc, nullptr ) );
706+ SetDebugUtilsObjectName (VK_OBJECT_TYPE_BUFFER, reinterpret_cast <std::uint64_t >(g_hVertexBuffer), " g_hVertexBuffer" );
703707
704708 // Create index buffer
705709
@@ -724,6 +728,7 @@ static void CreateMesh()
724728 ibInfo.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_INDEX_BUFFER_BIT;
725729 ibAllocCreateInfo.flags = 0 ;
726730 ERR_GUARD_VULKAN ( vmaCreateBuffer (g_hAllocator, &ibInfo, &ibAllocCreateInfo, &g_hIndexBuffer, &g_hIndexBufferAlloc, nullptr ) );
731+ SetDebugUtilsObjectName (VK_OBJECT_TYPE_BUFFER, reinterpret_cast <std::uint64_t >(g_hIndexBuffer), " g_hIndexBuffer" );
727732
728733 // Copy buffers
729734
@@ -805,7 +810,11 @@ static void CreateTexture(uint32_t sizeX, uint32_t sizeY)
805810 VmaAllocationCreateInfo imageAllocCreateInfo = {};
806811 imageAllocCreateInfo.usage = VMA_MEMORY_USAGE_AUTO;
807812
808- ERR_GUARD_VULKAN ( vmaCreateImage (g_hAllocator, &imageInfo, &imageAllocCreateInfo, &g_hTextureImage, &g_hTextureImageAlloc, nullptr ) );
813+ VmaAllocationInfo textureImageAllocInfo = {};
814+
815+ ERR_GUARD_VULKAN ( vmaCreateImage (g_hAllocator, &imageInfo, &imageAllocCreateInfo, &g_hTextureImage, &g_hTextureImageAlloc, &textureImageAllocInfo) );
816+ SetDebugUtilsObjectName (VK_OBJECT_TYPE_IMAGE, reinterpret_cast <std::uint64_t >(g_hTextureImage), " g_hTextureImage" );
817+ SetDebugUtilsObjectName (VK_OBJECT_TYPE_DEVICE_MEMORY, reinterpret_cast <std::uint64_t >(textureImageAllocInfo.deviceMemory ), " textureImageAllocInfo.deviceMemory" );
809818
810819 // Transition image layouts, copy image.
811820
@@ -874,6 +883,7 @@ static void CreateTexture(uint32_t sizeX, uint32_t sizeY)
874883 textureImageViewInfo.subresourceRange .baseArrayLayer = 0 ;
875884 textureImageViewInfo.subresourceRange .layerCount = 1 ;
876885 ERR_GUARD_VULKAN ( vkCreateImageView (g_hDevice, &textureImageViewInfo, g_Allocs, &g_hTextureImageView) );
886+ SetDebugUtilsObjectName (VK_OBJECT_TYPE_IMAGE_VIEW, reinterpret_cast <std::uint64_t >(g_hTextureImageView), " g_hTextureImageView" );
877887}
878888
879889struct UniformBufferObject
@@ -979,13 +989,20 @@ static void CreateSwapchain()
979989 vkDestroySwapchainKHR (g_hDevice, g_hSwapchain, g_Allocs);
980990 g_hSwapchain = hNewSwapchain;
981991
992+ SetDebugUtilsObjectName (VK_OBJECT_TYPE_SWAPCHAIN_KHR, reinterpret_cast <std::uint64_t >(g_hSwapchain), " g_hSwapchain" );
993+
982994 // Retrieve swapchain images.
983995
984996 uint32_t swapchainImageCount = 0 ;
985997 ERR_GUARD_VULKAN ( vkGetSwapchainImagesKHR (g_hDevice, g_hSwapchain, &swapchainImageCount, nullptr ) );
986998 g_SwapchainImages.resize (swapchainImageCount);
987999 ERR_GUARD_VULKAN ( vkGetSwapchainImagesKHR (g_hDevice, g_hSwapchain, &swapchainImageCount, g_SwapchainImages.data ()) );
9881000
1001+ for (size_t i = 0 ; i < swapchainImageCount; i++) {
1002+ std::string swapchainImgName = " g_SwapchainImages[" + std::to_string (i) + " ]" ;
1003+ SetDebugUtilsObjectName (VK_OBJECT_TYPE_IMAGE, reinterpret_cast <std::uint64_t >(g_SwapchainImages[i]), swapchainImgName);
1004+ }
1005+
9891006 // Create swapchain image views.
9901007
9911008 for (size_t i = g_SwapchainImageViews.size (); i--; )
@@ -1009,6 +1026,8 @@ static void CreateSwapchain()
10091026 swapchainImageViewInfo.subresourceRange .baseArrayLayer = 0 ;
10101027 swapchainImageViewInfo.subresourceRange .layerCount = 1 ;
10111028 ERR_GUARD_VULKAN ( vkCreateImageView (g_hDevice, &swapchainImageViewInfo, g_Allocs, &g_SwapchainImageViews[i]) );
1029+ std::string imgViewName = " g_SwapchainImageViews[" + std::to_string (i) + " ]" ;
1030+ SetDebugUtilsObjectName (VK_OBJECT_TYPE_IMAGE_VIEW, reinterpret_cast <std::uint64_t >(g_SwapchainImageViews[i]), imgViewName);
10121031 }
10131032
10141033 // Create depth buffer
@@ -1034,7 +1053,11 @@ static void CreateSwapchain()
10341053 VmaAllocationCreateInfo depthImageAllocCreateInfo = {};
10351054 depthImageAllocCreateInfo.usage = VMA_MEMORY_USAGE_AUTO;
10361055
1037- ERR_GUARD_VULKAN ( vmaCreateImage (g_hAllocator, &depthImageInfo, &depthImageAllocCreateInfo, &g_hDepthImage, &g_hDepthImageAlloc, nullptr ) );
1056+ VmaAllocationInfo depthImageAllocInfo = {};
1057+
1058+ ERR_GUARD_VULKAN ( vmaCreateImage (g_hAllocator, &depthImageInfo, &depthImageAllocCreateInfo, &g_hDepthImage, &g_hDepthImageAlloc, &depthImageAllocInfo) );
1059+ SetDebugUtilsObjectName (VK_OBJECT_TYPE_IMAGE, reinterpret_cast <std::uint64_t >(g_hDepthImage), " g_hDepthImage" );
1060+ SetDebugUtilsObjectName (VK_OBJECT_TYPE_DEVICE_MEMORY, reinterpret_cast <std::uint64_t >(depthImageAllocInfo.deviceMemory ), " depthImageAllocInfo.deviceMemory" );
10381061
10391062 VkImageViewCreateInfo depthImageViewInfo = { VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO };
10401063 depthImageViewInfo.image = g_hDepthImage;
@@ -1047,6 +1070,7 @@ static void CreateSwapchain()
10471070 depthImageViewInfo.subresourceRange .layerCount = 1 ;
10481071
10491072 ERR_GUARD_VULKAN ( vkCreateImageView (g_hDevice, &depthImageViewInfo, g_Allocs, &g_hDepthImageView) );
1073+ SetDebugUtilsObjectName (VK_OBJECT_TYPE_IMAGE_VIEW, reinterpret_cast <std::uint64_t >(g_hDepthImageView), " g_hDepthImageView" );
10501074
10511075 // Create pipeline layout
10521076 {
@@ -1069,6 +1093,7 @@ static void CreateSwapchain()
10691093 pipelineLayoutInfo.pushConstantRangeCount = 1 ;
10701094 pipelineLayoutInfo.pPushConstantRanges = pushConstantRanges;
10711095 ERR_GUARD_VULKAN ( vkCreatePipelineLayout (g_hDevice, &pipelineLayoutInfo, g_Allocs, &g_hPipelineLayout) );
1096+ SetDebugUtilsObjectName (VK_OBJECT_TYPE_PIPELINE_LAYOUT, reinterpret_cast <std::uint64_t >(g_hPipelineLayout), " g_hPipelineLayout" );
10721097 }
10731098
10741099 // Create render pass
@@ -1121,6 +1146,7 @@ static void CreateSwapchain()
11211146 renderPassInfo.pSubpasses = &subpassDesc;
11221147 renderPassInfo.dependencyCount = 0 ;
11231148 ERR_GUARD_VULKAN ( vkCreateRenderPass (g_hDevice, &renderPassInfo, g_Allocs, &g_hRenderPass) );
1149+ SetDebugUtilsObjectName (VK_OBJECT_TYPE_RENDER_PASS, reinterpret_cast <std::uint64_t >(g_hRenderPass), " g_hRenderPass" );
11241150 }
11251151
11261152 // Create pipeline
@@ -1132,13 +1158,15 @@ static void CreateSwapchain()
11321158 shaderModuleInfo.pCode = (const uint32_t *)vertShaderCode.data ();
11331159 VkShaderModule hVertShaderModule = VK_NULL_HANDLE;
11341160 ERR_GUARD_VULKAN ( vkCreateShaderModule (g_hDevice, &shaderModuleInfo, g_Allocs, &hVertShaderModule) );
1161+ SetDebugUtilsObjectName (VK_OBJECT_TYPE_SHADER_MODULE, reinterpret_cast <std::uint64_t >(hVertShaderModule), " hVertShaderModule" );
11351162
11361163 std::vector<char > hFragShaderCode;
11371164 LoadShader (hFragShaderCode, " Shader.frag.spv" );
11381165 shaderModuleInfo.codeSize = hFragShaderCode.size ();
11391166 shaderModuleInfo.pCode = (const uint32_t *)hFragShaderCode.data ();
11401167 VkShaderModule fragShaderModule = VK_NULL_HANDLE;
11411168 ERR_GUARD_VULKAN ( vkCreateShaderModule (g_hDevice, &shaderModuleInfo, g_Allocs, &fragShaderModule) );
1169+ SetDebugUtilsObjectName (VK_OBJECT_TYPE_SHADER_MODULE, reinterpret_cast <std::uint64_t >(fragShaderModule), " fragShaderModule" );
11421170
11431171 VkPipelineShaderStageCreateInfo vertPipelineShaderStageInfo = { VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO };
11441172 vertPipelineShaderStageInfo.stage = VK_SHADER_STAGE_VERTEX_BIT;
@@ -1278,6 +1306,8 @@ static void CreateSwapchain()
12781306 g_Allocs,
12791307 &g_hPipeline) );
12801308
1309+ SetDebugUtilsObjectName (VK_OBJECT_TYPE_PIPELINE, reinterpret_cast <std::uint64_t >(g_hPipeline), " g_hPipeline" );
1310+
12811311 vkDestroyShaderModule (g_hDevice, fragShaderModule, g_Allocs);
12821312 vkDestroyShaderModule (g_hDevice, hVertShaderModule, g_Allocs);
12831313 }
@@ -1301,6 +1331,8 @@ static void CreateSwapchain()
13011331 framebufferInfo.height = g_Extent.height ;
13021332 framebufferInfo.layers = 1 ;
13031333 ERR_GUARD_VULKAN ( vkCreateFramebuffer (g_hDevice, &framebufferInfo, g_Allocs, &g_Framebuffers[i]) );
1334+ std::string framebufName = " g_Framebuffers[" + std::to_string (i) + " ]" ;
1335+ SetDebugUtilsObjectName (VK_OBJECT_TYPE_FRAMEBUFFER, reinterpret_cast <std::uint64_t >(g_Framebuffers[i]), framebufName);
13041336 }
13051337
13061338 // Destroy the old semaphores and create new ones
@@ -1327,7 +1359,12 @@ static void CreateSwapchain()
13271359
13281360 for (std::size_t swapchain_img_index = 0 ; swapchain_img_index < g_SwapchainImageCount; swapchain_img_index++) {
13291361 ERR_GUARD_VULKAN (vkCreateSemaphore (g_hDevice, &semaphoreInfo, g_Allocs, &g_hImageAvailableSemaphores[swapchain_img_index]));
1362+ std::string semaphoreName = " g_hImageAvailableSemaphores[" + std::to_string (swapchain_img_index) + " ]" ;
1363+ SetDebugUtilsObjectName (VK_OBJECT_TYPE_SEMAPHORE, reinterpret_cast <std::uint64_t >(g_hImageAvailableSemaphores[swapchain_img_index]), semaphoreName);
1364+
13301365 ERR_GUARD_VULKAN (vkCreateSemaphore (g_hDevice, &semaphoreInfo, g_Allocs, &g_hRenderFinishedSemaphores[swapchain_img_index]));
1366+ semaphoreName = " g_hRenderFinishedSemaphores[" + std::to_string (swapchain_img_index) + " ]" ;
1367+ SetDebugUtilsObjectName (VK_OBJECT_TYPE_SEMAPHORE, reinterpret_cast <std::uint64_t >(g_hRenderFinishedSemaphores[swapchain_img_index]), semaphoreName);
13311368 }
13321369}
13331370
@@ -2030,6 +2067,10 @@ static void InitializeApplication()
20302067 deviceCreateInfo.pQueueCreateInfos = queueCreateInfo;
20312068
20322069 ERR_GUARD_VULKAN ( vkCreateDevice (g_hPhysicalDevice, &deviceCreateInfo, g_Allocs, &g_hDevice) );
2070+ SetDebugUtilsObjectName (VK_OBJECT_TYPE_DEVICE, reinterpret_cast <std::uint64_t >(g_hDevice), " g_hDevice" );
2071+ // Only now that SetDebugUtilsObjectName is loaded, we can assign a name to g_hVulkanInstance as well
2072+ SetDebugUtilsObjectName (VK_OBJECT_TYPE_INSTANCE, reinterpret_cast <std::uint64_t >(g_hVulkanInstance), " g_hVulkanInstance" );
2073+ SetDebugUtilsObjectName (VK_OBJECT_TYPE_PHYSICAL_DEVICE, reinterpret_cast <std::uint64_t >(g_hPhysicalDevice), " g_hPhysicalDevice" );
20332074
20342075 // Fetch pointers to extension functions
20352076 if (VK_KHR_buffer_device_address_enabled)
@@ -2064,6 +2105,8 @@ static void InitializeApplication()
20642105 vkGetDeviceQueue (g_hDevice, g_PresentQueueFamilyIndex, 0 , &g_hPresentQueue);
20652106 assert (g_hGraphicsQueue);
20662107 assert (g_hPresentQueue);
2108+ SetDebugUtilsObjectName (VK_OBJECT_TYPE_QUEUE, reinterpret_cast <std::uint64_t >(g_hGraphicsQueue), " g_hGraphicsQueue" );
2109+ SetDebugUtilsObjectName (VK_OBJECT_TYPE_QUEUE, reinterpret_cast <std::uint64_t >(g_hPresentQueue), " g_hPresentQueue" );
20672110
20682111 if (g_SparseBindingEnabled)
20692112 {
@@ -2077,24 +2120,33 @@ static void InitializeApplication()
20772120 commandPoolInfo.queueFamilyIndex = g_GraphicsQueueFamilyIndex;
20782121 commandPoolInfo.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
20792122 ERR_GUARD_VULKAN ( vkCreateCommandPool (g_hDevice, &commandPoolInfo, g_Allocs, &g_hCommandPool) );
2123+ SetDebugUtilsObjectName (VK_OBJECT_TYPE_COMMAND_POOL, reinterpret_cast <std::uint64_t >(g_hCommandPool), " g_hCommandPool" );
20802124
20812125 VkCommandBufferAllocateInfo commandBufferInfo = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO };
20822126 commandBufferInfo.commandPool = g_hCommandPool;
20832127 commandBufferInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
20842128 commandBufferInfo.commandBufferCount = COMMAND_BUFFER_COUNT;
20852129 ERR_GUARD_VULKAN ( vkAllocateCommandBuffers (g_hDevice, &commandBufferInfo, g_MainCommandBuffers) );
2130+ for (size_t i = 0 ; i < COMMAND_BUFFER_COUNT; i++) {
2131+ std::string cmdBufName = " g_MainCommandBuffers[" + std::to_string (i) + " ]" ;
2132+ SetDebugUtilsObjectName (VK_OBJECT_TYPE_COMMAND_BUFFER, reinterpret_cast <std::uint64_t >(g_MainCommandBuffers[i]), cmdBufName);
2133+ }
20862134
20872135 VkFenceCreateInfo fenceInfo = { VK_STRUCTURE_TYPE_FENCE_CREATE_INFO };
20882136 fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT;
20892137 for (size_t i = 0 ; i < COMMAND_BUFFER_COUNT; ++i)
20902138 {
2091- ERR_GUARD_VULKAN ( vkCreateFence (g_hDevice, &fenceInfo, g_Allocs, &g_MainCommandBufferExecutedFances[i]) );
2139+ ERR_GUARD_VULKAN ( vkCreateFence (g_hDevice, &fenceInfo, g_Allocs, &g_MainCommandBufferExecutedFences[i]) );
2140+ std::string fenceName = " g_MainCommandBufferExecutedFences[" + std::to_string (i) + " ]" ;
2141+ SetDebugUtilsObjectName (VK_OBJECT_TYPE_FENCE, reinterpret_cast <std::uint64_t >(g_MainCommandBufferExecutedFences[i]), fenceName);
20922142 }
20932143
20942144 ERR_GUARD_VULKAN ( vkCreateFence (g_hDevice, &fenceInfo, g_Allocs, &g_ImmediateFence) );
2145+ SetDebugUtilsObjectName (VK_OBJECT_TYPE_FENCE, reinterpret_cast <std::uint64_t >(g_ImmediateFence), " g_ImmediateFence" );
20952146
20962147 commandBufferInfo.commandBufferCount = 1 ;
20972148 ERR_GUARD_VULKAN ( vkAllocateCommandBuffers (g_hDevice, &commandBufferInfo, &g_hTemporaryCommandBuffer) );
2149+ SetDebugUtilsObjectName (VK_OBJECT_TYPE_COMMAND_BUFFER, reinterpret_cast <std::uint64_t >(g_hTemporaryCommandBuffer), " g_hTemporaryCommandBuffer" );
20982150
20992151 // Create texture sampler
21002152
@@ -2115,6 +2167,7 @@ static void InitializeApplication()
21152167 samplerInfo.minLod = 0 .f ;
21162168 samplerInfo.maxLod = FLT_MAX;
21172169 ERR_GUARD_VULKAN ( vkCreateSampler (g_hDevice, &samplerInfo, g_Allocs, &g_hSampler) );
2170+ SetDebugUtilsObjectName (VK_OBJECT_TYPE_SAMPLER, reinterpret_cast <std::uint64_t >(g_hSampler), " g_hSampler" );
21182171
21192172 CreateTexture (128 , 128 );
21202173 CreateMesh ();
@@ -2129,6 +2182,7 @@ static void InitializeApplication()
21292182 descriptorSetLayoutInfo.bindingCount = 1 ;
21302183 descriptorSetLayoutInfo.pBindings = &samplerLayoutBinding;
21312184 ERR_GUARD_VULKAN ( vkCreateDescriptorSetLayout (g_hDevice, &descriptorSetLayoutInfo, g_Allocs, &g_hDescriptorSetLayout) );
2185+ SetDebugUtilsObjectName (VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT, reinterpret_cast <std::uint64_t >(g_hDescriptorSetLayout), " g_hDescriptorSetLayout" );
21322186
21332187 // Create descriptor pool
21342188
@@ -2144,6 +2198,7 @@ static void InitializeApplication()
21442198 descriptorPoolInfo.pPoolSizes = descriptorPoolSizes;
21452199 descriptorPoolInfo.maxSets = 1 ;
21462200 ERR_GUARD_VULKAN ( vkCreateDescriptorPool (g_hDevice, &descriptorPoolInfo, g_Allocs, &g_hDescriptorPool) );
2201+ SetDebugUtilsObjectName (VK_OBJECT_TYPE_DESCRIPTOR_POOL, reinterpret_cast <std::uint64_t >(g_hDescriptorPool), " g_hDescriptorPool" );
21472202
21482203 // Create descriptor set layout
21492204
@@ -2153,6 +2208,7 @@ static void InitializeApplication()
21532208 descriptorSetInfo.descriptorSetCount = 1 ;
21542209 descriptorSetInfo.pSetLayouts = descriptorSetLayouts;
21552210 ERR_GUARD_VULKAN ( vkAllocateDescriptorSets (g_hDevice, &descriptorSetInfo, &g_hDescriptorSet) );
2211+ SetDebugUtilsObjectName (VK_OBJECT_TYPE_DESCRIPTOR_SET, reinterpret_cast <std::uint64_t >(g_hDescriptorSet), " g_hDescriptorSet" );
21562212
21572213 VkDescriptorImageInfo descriptorImageInfo = {};
21582214 descriptorImageInfo.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
@@ -2226,10 +2282,10 @@ static void FinalizeApplication()
22262282
22272283 for (size_t i = COMMAND_BUFFER_COUNT; i--; )
22282284 {
2229- if (g_MainCommandBufferExecutedFances [i] != VK_NULL_HANDLE)
2285+ if (g_MainCommandBufferExecutedFences [i] != VK_NULL_HANDLE)
22302286 {
2231- vkDestroyFence (g_hDevice, g_MainCommandBufferExecutedFances [i], g_Allocs);
2232- g_MainCommandBufferExecutedFances [i] = VK_NULL_HANDLE;
2287+ vkDestroyFence (g_hDevice, g_MainCommandBufferExecutedFences [i], g_Allocs);
2288+ g_MainCommandBufferExecutedFences [i] = VK_NULL_HANDLE;
22332289 }
22342290 }
22352291 if (g_MainCommandBuffers[0 ] != VK_NULL_HANDLE)
@@ -2290,14 +2346,15 @@ static void DrawFrame()
22902346 // Begin main command buffer
22912347 size_t cmdBufIndex = (g_NextCommandBufferIndex++) % COMMAND_BUFFER_COUNT;
22922348 VkCommandBuffer hCommandBuffer = g_MainCommandBuffers[cmdBufIndex];
2293- VkFence hCommandBufferExecutedFence = g_MainCommandBufferExecutedFances [cmdBufIndex];
2349+ VkFence hCommandBufferExecutedFence = g_MainCommandBufferExecutedFences [cmdBufIndex];
22942350
22952351 ERR_GUARD_VULKAN ( vkWaitForFences (g_hDevice, 1 , &hCommandBufferExecutedFence, VK_TRUE, UINT64_MAX) );
22962352 ERR_GUARD_VULKAN ( vkResetFences (g_hDevice, 1 , &hCommandBufferExecutedFence) );
22972353
22982354 VkCommandBufferBeginInfo commandBufferBeginInfo = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO };
22992355 commandBufferBeginInfo.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
23002356 ERR_GUARD_VULKAN ( vkBeginCommandBuffer (hCommandBuffer, &commandBufferBeginInfo) );
2357+ SetDebugUtilsObjectName (VK_OBJECT_TYPE_COMMAND_BUFFER, reinterpret_cast <std::uint64_t >(hCommandBuffer), " hCommandBuffer" );
23012358
23022359 // Acquire swapchain image
23032360 uint32_t imageIndex = 0 ;
0 commit comments