Skip to content

Commit

Permalink
Assign debug names to command pools and command buffers identifying t…
Browse files Browse the repository at this point in the history
…heir SDL_GPU pointers and what thread they have affinity to
  • Loading branch information
kg committed Jan 13, 2025
1 parent 4ba4f0a commit 54bb24e
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/gpu/vulkan/SDL_gpu_vulkan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1279,6 +1279,27 @@ static inline const char *VkErrorMessages(VkResult code)

// Utility

static void VULKAN_INTERNAL_SetObjectNamePrintf(
VulkanRenderer *renderer, void *object, VkObjectType objectType, const char *format, ...
) {
if (!renderer->debugMode)
return;

va_list args;
char buf[1024] = { 0 };
va_start(args, format);
vsnprintf(buf, sizeof(buf), format, args);
va_end(args);
VkDebugUtilsObjectNameInfoEXT nameInfo = {
.objectHandle = object,
.objectType = objectType,
.pObjectName = buf,
.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT,
.pNext = NULL,
};
renderer->vkSetDebugUtilsObjectNameEXT(renderer->logicalDevice, &nameInfo);
}

static inline VkPolygonMode SDLToVK_PolygonMode(
VulkanRenderer *renderer,
SDL_GPUFillMode mode)
Expand Down Expand Up @@ -9205,6 +9226,11 @@ static bool VULKAN_INTERNAL_AllocateCommandBuffer(

// Pool it!

VULKAN_INTERNAL_SetObjectNamePrintf(
renderer, commandBuffer->commandBuffer, VK_OBJECT_TYPE_COMMAND_BUFFER,
"[Thread %d's Command pool %p] Command buffer %p", vulkanCommandPool->threadID, vulkanCommandPool, commandBuffer
);

vulkanCommandPool->inactiveCommandBuffers[vulkanCommandPool->inactiveCommandBufferCount] = commandBuffer;
vulkanCommandPool->inactiveCommandBufferCount += 1;

Expand Down Expand Up @@ -9249,6 +9275,11 @@ static VulkanCommandPool *VULKAN_INTERNAL_FetchCommandPool(
return NULL;
}

VULKAN_INTERNAL_SetObjectNamePrintf(
renderer, vulkanCommandPool->commandPool, VK_OBJECT_TYPE_COMMAND_POOL,
"[Thread %d] Command pool %p", threadID, vulkanCommandPool
);

vulkanCommandPool->threadID = threadID;

vulkanCommandPool->inactiveCommandBufferCapacity = 0;
Expand Down

0 comments on commit 54bb24e

Please sign in to comment.