Skip to content

[GPU] Assign debug names to command pools and command buffers #11932

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = (uint64_t)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 %p'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 %p] Command pool %p", threadID, vulkanCommandPool
);

vulkanCommandPool->threadID = threadID;

vulkanCommandPool->inactiveCommandBufferCapacity = 0;
Expand Down
Loading