Vulkan: Provide utilities to put markers and labels where needed in the GPUmodule #106098

Merged
Jeroen Bakker merged 29 commits from :vk_debug_update into main 2023-04-21 12:32:52 +02:00
1 changed files with 42 additions and 30 deletions
Showing only changes of commit 6b6283b22b - Show all commits

View File

@ -107,56 +107,68 @@ namespace blender {
}
void pushMarker(blender::gpu::VKContext *ctx, VkCommandBuffer cmd, const char *name)
{
VKDebuggingTools tools = ctx->debuggingtools_get();
if (tools.enabled) {
VkDebugUtilsLabelEXT info = {};
info.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT;
info.pLabelName = name;
tools.vkCmdBeginDebugUtilsLabelEXT_r(cmd, &info);
if (G.debug & G_DEBUG_GPU) {
VKDebuggingTools tools = ctx->debuggingtools_get();
if (tools.enabled) {
VkDebugUtilsLabelEXT info = {};
info.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT;
info.pLabelName = name;
tools.vkCmdBeginDebugUtilsLabelEXT_r(cmd, &info);
}
}
}
vnapdv marked this conversation as resolved
Review

use context when referring to VKContext (be consistent with other areas of the code-base)

When referring to instances of the Vulkan API it is used. Eg VkCommandBuffer parameters should be named vk_command_buffer VKCommandBuffer (internal class) should be referred to as command_buffer.

Abbreviations like q should not be used, just call them what they are queue.

etc

use `context` when referring to `VKContext` (be consistent with other areas of the code-base) When referring to instances of the Vulkan API it is used. Eg VkCommandBuffer parameters should be named `vk_command_buffer` VKCommandBuffer (internal class) should be referred to as `command_buffer`. Abbreviations like `q` should not be used, just call them what they are `queue`. etc
void setMarker(blender::gpu::VKContext *ctx, VkCommandBuffer cmd, const char *name)
{
VKDebuggingTools tools = ctx->debuggingtools_get();
if (tools.enabled) {
VkDebugUtilsLabelEXT info = {};
info.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT;
info.pLabelName = name;
tools.vkCmdInsertDebugUtilsLabelEXT_r(cmd, &info);
if (G.debug & G_DEBUG_GPU) {
VKDebuggingTools tools = ctx->debuggingtools_get();
if (tools.enabled) {
VkDebugUtilsLabelEXT info = {};
vnapdv marked this conversation as resolved Outdated

/home/jeroen/blender-git/blender/source/blender/gpu/vulkan/vk_debug.cc:125:26: warning: variable ‘tools’ set but not used [-Wunused-but-set-variable]

`/home/jeroen/blender-git/blender/source/blender/gpu/vulkan/vk_debug.cc:125:26: warning: variable ‘tools’ set but not used [-Wunused-but-set-variable]`
info.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT;
info.pLabelName = name;
tools.vkCmdInsertDebugUtilsLabelEXT_r(cmd, &info);
}
}

obj isn't very useful. would use object_handle

`obj` isn't very useful. would use `object_handle`
}

objType -> vk_object_type

`objType` -> `vk_object_type`
void popMarker(blender::gpu::VKContext *ctx, VkCommandBuffer cmd)
vnapdv marked this conversation as resolved Outdated

Add empty line between each function.

Add empty line between each function.
{
VKDebuggingTools tools = ctx->debuggingtools_get();
if (tools.enabled) {
tools.vkCmdEndDebugUtilsLabelEXT_r(cmd);
if (G.debug & G_DEBUG_GPU) {
VKDebuggingTools tools = ctx->debuggingtools_get();
if (tools.enabled) {
tools.vkCmdEndDebugUtilsLabelEXT_r(cmd);
}
}
}
void pushMarker(blender::gpu::VKContext *ctx, VkQueue q, const char *name)
{
VKDebuggingTools tools = ctx->debuggingtools_get();
if (tools.enabled) {
VkDebugUtilsLabelEXT info = {};
info.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT;
info.pLabelName = name;
tools.vkQueueBeginDebugUtilsLabelEXT_r(q, &info);
if (G.debug & G_DEBUG_GPU) {
VKDebuggingTools tools = ctx->debuggingtools_get();
if (tools.enabled) {
Review

cmd -> vk_command_buffer. No need to confuse readers with incorrect abbreviations.

Also check the other functions.

`cmd` -> `vk_command_buffer`. No need to confuse readers with incorrect abbreviations. Also check the other functions.
VkDebugUtilsLabelEXT info = {};
info.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT;
info.pLabelName = name;
tools.vkQueueBeginDebugUtilsLabelEXT_r(q, &info);
}
}
}
void setMarker(blender::gpu::VKContext *ctx, VkQueue q, const char *name)
{
VKDebuggingTools tools = ctx->debuggingtools_get();
if (tools.enabled) {
VkDebugUtilsLabelEXT info = {};
info.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT;
info.pLabelName = name;
tools.vkQueueInsertDebugUtilsLabelEXT_r(q, &info);
if (G.debug & G_DEBUG_GPU) {
VKDebuggingTools tools = ctx->debuggingtools_get();
if (tools.enabled) {
VkDebugUtilsLabelEXT info = {};
info.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT;
info.pLabelName = name;
tools.vkQueueInsertDebugUtilsLabelEXT_r(q, &info);
}
}
}
void popMarker(blender::gpu::VKContext *ctx, VkQueue q)
{
VKDebuggingTools tools = ctx->debuggingtools_get();
if (tools.enabled) {
tools.vkQueueEndDebugUtilsLabelEXT_r(q);
if (G.debug & G_DEBUG_GPU) {
VKDebuggingTools tools = ctx->debuggingtools_get();
if (tools.enabled) {
tools.vkQueueEndDebugUtilsLabelEXT_r(q);
}
}
}