Vulkan: Provide utilities to put markers and labels where needed in the GPUmodule #106098
|
@ -871,8 +871,6 @@ GHOST_TSuccess GHOST_ContextVK::initializeDrawingContext()
|
|||
requireExtension(extensions_available, extensions_enabled, VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (use_window_surface) {
|
||||
vnapdv marked this conversation as resolved
Outdated
|
||||
const char *native_surface_extension_name = getPlatformSpecificSurfaceExtension();
|
||||
|
||||
|
|
|
@ -235,6 +235,7 @@ set(VULKAN_SRC
|
|||
vulkan/vk_common.hh
|
||||
vulkan/vk_context.hh
|
||||
vulkan/vk_data_conversion.hh
|
||||
vulkan/vk_debug.hh
|
||||
vulkan/vk_descriptor_pools.hh
|
||||
vulkan/vk_descriptor_set.hh
|
||||
vulkan/vk_drawlist.hh
|
||||
|
@ -256,7 +257,7 @@ set(VULKAN_SRC
|
|||
vulkan/vk_texture.hh
|
||||
vulkan/vk_uniform_buffer.hh
|
||||
vulkan/vk_vertex_buffer.hh
|
||||
vnapdv marked this conversation as resolved
Outdated
Jeroen Bakker
commented
Try to keep the list of files sorted. This way it is easier to find missing ones. Try to keep the list of files sorted. This way it is easier to find missing ones.
|
||||
vulkan/vk_debug.hh
|
||||
|
||||
vnapdv marked this conversation as resolved
Outdated
Jeroen Bakker
commented
Empty lines can be removed Empty lines can be removed
|
||||
|
||||
)
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <typeinfo>
|
||||
|
||||
#ifdef __APPLE__
|
||||
# include <MoltenVK/vk_mvk_moltenvk.h>
|
||||
#else
|
||||
|
@ -16,7 +18,6 @@
|
|||
#include "vk_mem_alloc.h"
|
||||
|
||||
vnapdv marked this conversation as resolved
Outdated
Jeroen Bakker
commented
Add one line between imports of different categories. Put system includes on top. Add one line between imports of different categories. Put system includes on top.
|
||||
#include "gpu_texture_private.hh"
|
||||
#include <typeinfo>
|
||||
|
||||
namespace blender::gpu {
|
||||
|
||||
|
@ -29,10 +30,10 @@ VkImageType to_vk_image_type(const eGPUTextureType type);
|
|||
template<typename T> VkObjectType to_vk_object_type(T /*vk_obj*/)
|
||||
{
|
||||
const std::type_info &tid = typeid(T);
|
||||
#define VK_EQ_TYPEID(name, name2) \
|
||||
if (tid == typeid(name)) { \
|
||||
return VK_OBJECT_TYPE_##name2; \
|
||||
}
|
||||
# define VK_EQ_TYPEID(name, name2) \
|
||||
if (tid == typeid(name)) { \
|
||||
return VK_OBJECT_TYPE_##name2; \
|
||||
}
|
||||
|
||||
VK_EQ_TYPEID(VkInstance, INSTANCE);
|
||||
VK_EQ_TYPEID(VkPhysicalDevice, PHYSICAL_DEVICE);
|
||||
|
@ -67,13 +68,13 @@ template<typename T> VkObjectType to_vk_object_type(T /*vk_obj*/)
|
|||
VK_EQ_TYPEID(VkSwapchainKHR, SWAPCHAIN_KHR);
|
||||
VK_EQ_TYPEID(VkDisplayKHR, DISPLAY_KHR);
|
||||
VK_EQ_TYPEID(VkDisplayModeKHR, DISPLAY_MODE_KHR);
|
||||
VK_EQ_TYPEID(VkDebugReportCallbackEXT,DEBUG_REPORT_CALLBACK_EXT);
|
||||
#ifdef VK_ENABLE_BETA_EXTENSIONS
|
||||
VK_EQ_TYPEID(VkDebugReportCallbackEXT, DEBUG_REPORT_CALLBACK_EXT);
|
||||
# ifdef VK_ENABLE_BETA_EXTENSIONS
|
||||
VK_EQ_TYPEID(VkVideoSessionKHR, VIDEO_SESSION_KHR);
|
||||
#endif
|
||||
#ifdef VK_ENABLE_BETA_EXTENSIONS
|
||||
# endif
|
||||
# ifdef VK_ENABLE_BETA_EXTENSIONS
|
||||
VK_EQ_TYPEID(VkVideoSessionParametersKHR, VIDEO_SESSION_PARAMETERS_KHR);
|
||||
#endif
|
||||
# endif
|
||||
VK_EQ_TYPEID(VkCuModuleNVX, CU_MODULE_NVX);
|
||||
VK_EQ_TYPEID(VkCuFunctionNVX, CU_FUNCTION_NVX);
|
||||
VK_EQ_TYPEID(VkDebugUtilsMessengerEXT, DEBUG_UTILS_MESSENGER_EXT);
|
||||
|
@ -86,8 +87,8 @@ template<typename T> VkObjectType to_vk_object_type(T /*vk_obj*/)
|
|||
VK_EQ_TYPEID(VkPrivateDataSlotEXT, PRIVATE_DATA_SLOT_EXT);
|
||||
|
||||
BLI_assert_unreachable();
|
||||
#undef VK_EQ_TYPEID
|
||||
# undef VK_EQ_TYPEID
|
||||
return VK_OBJECT_TYPE_UNKNOWN;
|
||||
vnapdv marked this conversation as resolved
Outdated
Jeroen Bakker
commented
`// namespace blender::gpu` can be removed.
|
||||
} // namespace blender::gpu
|
||||
}
|
||||
#endif
|
||||
} // namespace blender::gpu
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
/** \file
|
||||
* \ingroup gpu
|
||||
*/
|
||||
#include "vk_debug.hh"
|
||||
#include "vk_context.hh"
|
||||
#include "vk_debug.hh"
|
||||
|
||||
#include "vk_backend.hh"
|
||||
#include "vk_framebuffer.hh"
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
#pragma once
|
||||
|
||||
#include "gpu_context_private.hh"
|
||||
#include "vk_common.hh"
|
||||
#include "vk_command_buffer.hh"
|
||||
#include "vk_descriptor_pools.hh"
|
||||
#include "vk_common.hh"
|
||||
#include "vk_debug.hh"
|
||||
#include "vk_descriptor_pools.hh"
|
||||
|
||||
namespace blender::gpu {
|
||||
|
||||
|
|
|
@ -4,13 +4,16 @@
|
|||
/** \file
|
||||
* \ingroup gpu
|
||||
*/
|
||||
#include "BKE_global.h"
|
||||
#include "CLG_log.h"
|
||||
#include "vk_common.hh"
|
||||
|
||||
vnapdv marked this conversation as resolved
Outdated
Jeroen Bakker
commented
Add empty lines between each category of includes Add empty lines between each category of includes
|
||||
#include "BKE_global.h"
|
||||
#include "CLG_log.h"
|
||||
|
||||
#include "vk_debug.hh"
|
||||
#include "vk_backend.hh"
|
||||
#include "vk_common.hh"
|
||||
vnapdv marked this conversation as resolved
Outdated
Jeroen Bakker
commented
Add empty line between includes and code. Add empty line between includes and code.
|
||||
#include "vk_context.hh"
|
||||
static CLG_LogRef LOG = { "gpu.debug.vulkan" };
|
||||
|
||||
static CLG_LogRef LOG = {"gpu.debug.vulkan"};
|
||||
|
||||
namespace blender::gpu {
|
||||
void VKContext::debug_group_begin(const char *, int)
|
||||
|
@ -66,155 +69,162 @@ void VKContext::debug_capture_scope_end(void * /*scope*/)
|
|||
|
||||
} // namespace blender::gpu
|
||||
|
||||
namespace blender::gpu::debug{
|
||||
namespace blender::gpu::debug {
|
||||
|
||||
static void vulkan_dynamic_debug_functions(VKContext* ctx,
|
||||
PFN_vkGetInstanceProcAddr instload)
|
||||
{
|
||||
VKDebuggingTools &tools = ctx->debuggingtools_get();
|
||||
VkInstance instance = ctx->instance_get();
|
||||
|
||||
if (instload) {
|
||||
|
||||
tools.enabled = false;
|
||||
tools.vkCmdBeginDebugUtilsLabelEXT_r = (PFN_vkCmdBeginDebugUtilsLabelEXT)instload(
|
||||
instance, "vkCmdBeginDebugUtilsLabelEXT");
|
||||
tools.vkCmdEndDebugUtilsLabelEXT_r = (PFN_vkCmdEndDebugUtilsLabelEXT)instload(
|
||||
instance, "vkCmdEndDebugUtilsLabelEXT");
|
||||
tools.vkCmdInsertDebugUtilsLabelEXT_r = (PFN_vkCmdInsertDebugUtilsLabelEXT)instload(
|
||||
instance, "vkCmdInsertDebugUtilsLabelEXT");
|
||||
tools.vkCreateDebugUtilsMessengerEXT_r = (PFN_vkCreateDebugUtilsMessengerEXT)instload(
|
||||
instance, "vkCreateDebugUtilsMessengerEXT");
|
||||
tools.vkDestroyDebugUtilsMessengerEXT_r = (PFN_vkDestroyDebugUtilsMessengerEXT)instload(
|
||||
instance, "vkDestroyDebugUtilsMessengerEXT");
|
||||
tools.vkQueueBeginDebugUtilsLabelEXT_r = (PFN_vkQueueBeginDebugUtilsLabelEXT)instload(
|
||||
instance, "vkQueueBeginDebugUtilsLabelEXT");
|
||||
tools.vkQueueEndDebugUtilsLabelEXT_r = (PFN_vkQueueEndDebugUtilsLabelEXT)instload(
|
||||
instance, "vkQueueEndDebugUtilsLabelEXT");
|
||||
tools.vkQueueInsertDebugUtilsLabelEXT_r = (PFN_vkQueueInsertDebugUtilsLabelEXT)instload(
|
||||
instance, "vkQueueInsertDebugUtilsLabelEXT");
|
||||
tools.vkSetDebugUtilsObjectNameEXT_r = (PFN_vkSetDebugUtilsObjectNameEXT)instload(
|
||||
instance, "vkSetDebugUtilsObjectNameEXT");
|
||||
tools.vkSetDebugUtilsObjectTagEXT_r = (PFN_vkSetDebugUtilsObjectTagEXT)instload(
|
||||
instance, "vkSetDebugUtilsObjectTagEXT");
|
||||
tools.vkSubmitDebugUtilsMessageEXT_r = (PFN_vkSubmitDebugUtilsMessageEXT)instload(
|
||||
instance, "vkSubmitDebugUtilsMessageEXT");
|
||||
if (tools.vkCmdBeginDebugUtilsLabelEXT_r) {
|
||||
tools.enabled = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
tools.vkCmdBeginDebugUtilsLabelEXT_r = nullptr;
|
||||
tools.vkCmdEndDebugUtilsLabelEXT_r = nullptr;
|
||||
tools.vkCmdInsertDebugUtilsLabelEXT_r = nullptr;
|
||||
tools.vkCreateDebugUtilsMessengerEXT_r = nullptr;
|
||||
tools.vkDestroyDebugUtilsMessengerEXT_r = nullptr;
|
||||
tools.vkQueueBeginDebugUtilsLabelEXT_r = nullptr;
|
||||
tools.vkQueueEndDebugUtilsLabelEXT_r = nullptr;
|
||||
tools.vkQueueInsertDebugUtilsLabelEXT_r = nullptr;
|
||||
tools.vkSetDebugUtilsObjectNameEXT_r = nullptr;
|
||||
tools.vkSetDebugUtilsObjectTagEXT_r = nullptr;
|
||||
tools.vkSubmitDebugUtilsMessageEXT_r = nullptr;
|
||||
tools.enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool init_vk_callbacks(VKContext* ctx, PFN_vkGetInstanceProcAddr instload)
|
||||
{
|
||||
CLOG_ENSURE(&LOG);
|
||||
VKDebuggingTools tools = ctx->debuggingtools_get();
|
||||
if (instload ) {
|
||||
vulkan_dynamic_debug_functions(ctx, instload);
|
||||
return true;
|
||||
};
|
||||
return false;
|
||||
}
|
||||
void destroy_vk_callbacks(VKContext* ctx)
|
||||
{
|
||||
VKDebuggingTools tools = ctx->debuggingtools_get();
|
||||
if (tools.enabled) {
|
||||
vulkan_dynamic_debug_functions(ctx, nullptr);
|
||||
}
|
||||
}
|
||||
void object_vk_label(blender::gpu::VKContext* ctx, VkObjectType objType, uint64_t obj, const char* name)
|
||||
{
|
||||
VKDebuggingTools tools = ctx->debuggingtools_get();
|
||||
if (tools.enabled) {
|
||||
VkDebugUtilsObjectNameInfoEXT info = {};
|
||||
info.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;
|
||||
info.objectType = objType;
|
||||
info.objectHandle = obj;
|
||||
info.pObjectName = name;
|
||||
tools.vkSetDebugUtilsObjectNameEXT_r(ctx->device_get(), &info);
|
||||
}
|
||||
}
|
||||
void pushMarker(blender::gpu::VKContext *ctx, VkCommandBuffer cmd, const char *name)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
void setMarker(blender::gpu::VKContext *ctx, VkCommandBuffer cmd, const char *name)
|
||||
{
|
||||
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.vkCmdInsertDebugUtilsLabelEXT_r(cmd, &info);
|
||||
}
|
||||
}
|
||||
}
|
||||
void popMarker(blender::gpu::VKContext *ctx, VkCommandBuffer 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)
|
||||
{
|
||||
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.vkQueueBeginDebugUtilsLabelEXT_r(q, &info);
|
||||
}
|
||||
}
|
||||
}
|
||||
void setMarker(blender::gpu::VKContext *ctx, VkQueue q, const char *name)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (G.debug & G_DEBUG_GPU) {
|
||||
VKDebuggingTools tools = ctx->debuggingtools_get();
|
||||
if (tools.enabled) {
|
||||
tools.vkQueueEndDebugUtilsLabelEXT_r(q);
|
||||
}
|
||||
}
|
||||
}
|
||||
static void vulkan_dynamic_debug_functions(VKContext *ctx, PFN_vkGetInstanceProcAddr instload)
|
||||
{
|
||||
VKDebuggingTools &tools = ctx->debuggingtools_get();
|
||||
VkInstance instance = ctx->instance_get();
|
||||
|
||||
if (instload) {
|
||||
|
||||
tools.enabled = false;
|
||||
tools.vkCmdBeginDebugUtilsLabelEXT_r = (PFN_vkCmdBeginDebugUtilsLabelEXT)instload(
|
||||
instance, "vkCmdBeginDebugUtilsLabelEXT");
|
||||
tools.vkCmdEndDebugUtilsLabelEXT_r = (PFN_vkCmdEndDebugUtilsLabelEXT)instload(
|
||||
instance, "vkCmdEndDebugUtilsLabelEXT");
|
||||
tools.vkCmdInsertDebugUtilsLabelEXT_r = (PFN_vkCmdInsertDebugUtilsLabelEXT)instload(
|
||||
instance, "vkCmdInsertDebugUtilsLabelEXT");
|
||||
tools.vkCreateDebugUtilsMessengerEXT_r = (PFN_vkCreateDebugUtilsMessengerEXT)instload(
|
||||
instance, "vkCreateDebugUtilsMessengerEXT");
|
||||
tools.vkDestroyDebugUtilsMessengerEXT_r = (PFN_vkDestroyDebugUtilsMessengerEXT)instload(
|
||||
instance, "vkDestroyDebugUtilsMessengerEXT");
|
||||
tools.vkQueueBeginDebugUtilsLabelEXT_r = (PFN_vkQueueBeginDebugUtilsLabelEXT)instload(
|
||||
instance, "vkQueueBeginDebugUtilsLabelEXT");
|
||||
tools.vkQueueEndDebugUtilsLabelEXT_r = (PFN_vkQueueEndDebugUtilsLabelEXT)instload(
|
||||
instance, "vkQueueEndDebugUtilsLabelEXT");
|
||||
tools.vkQueueInsertDebugUtilsLabelEXT_r = (PFN_vkQueueInsertDebugUtilsLabelEXT)instload(
|
||||
instance, "vkQueueInsertDebugUtilsLabelEXT");
|
||||
tools.vkSetDebugUtilsObjectNameEXT_r = (PFN_vkSetDebugUtilsObjectNameEXT)instload(
|
||||
instance, "vkSetDebugUtilsObjectNameEXT");
|
||||
tools.vkSetDebugUtilsObjectTagEXT_r = (PFN_vkSetDebugUtilsObjectTagEXT)instload(
|
||||
instance, "vkSetDebugUtilsObjectTagEXT");
|
||||
tools.vkSubmitDebugUtilsMessageEXT_r = (PFN_vkSubmitDebugUtilsMessageEXT)instload(
|
||||
instance, "vkSubmitDebugUtilsMessageEXT");
|
||||
if (tools.vkCmdBeginDebugUtilsLabelEXT_r) {
|
||||
tools.enabled = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
tools.vkCmdBeginDebugUtilsLabelEXT_r = nullptr;
|
||||
tools.vkCmdEndDebugUtilsLabelEXT_r = nullptr;
|
||||
tools.vkCmdInsertDebugUtilsLabelEXT_r = nullptr;
|
||||
tools.vkCreateDebugUtilsMessengerEXT_r = nullptr;
|
||||
tools.vkDestroyDebugUtilsMessengerEXT_r = nullptr;
|
||||
tools.vkQueueBeginDebugUtilsLabelEXT_r = nullptr;
|
||||
tools.vkQueueEndDebugUtilsLabelEXT_r = nullptr;
|
||||
tools.vkQueueInsertDebugUtilsLabelEXT_r = nullptr;
|
||||
tools.vkSetDebugUtilsObjectNameEXT_r = nullptr;
|
||||
tools.vkSetDebugUtilsObjectTagEXT_r = nullptr;
|
||||
tools.vkSubmitDebugUtilsMessageEXT_r = nullptr;
|
||||
vnapdv marked this conversation as resolved
Jeroen Bakker
commented
use When referring to instances of the Vulkan API it is used. Eg VkCommandBuffer parameters should be named Abbreviations like 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
|
||||
tools.enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool init_vk_callbacks(VKContext *ctx, PFN_vkGetInstanceProcAddr instload)
|
||||
{
|
||||
vnapdv marked this conversation as resolved
Outdated
Jeroen Bakker
commented
`/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]`
|
||||
CLOG_ENSURE(&LOG);
|
||||
if (instload) {
|
||||
vulkan_dynamic_debug_functions(ctx, instload);
|
||||
return true;
|
||||
};
|
||||
Jeroen Bakker
commented
`obj` isn't very useful. would use `object_handle`
|
||||
return false;
|
||||
Jeroen Bakker
commented
`objType` -> `vk_object_type`
|
||||
}
|
||||
vnapdv marked this conversation as resolved
Outdated
Jeroen Bakker
commented
Add empty line between each function. Add empty line between each function.
|
||||
|
||||
void destroy_vk_callbacks(VKContext *ctx)
|
||||
{
|
||||
VKDebuggingTools tools = ctx->debuggingtools_get();
|
||||
if (tools.enabled) {
|
||||
vulkan_dynamic_debug_functions(ctx, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void object_vk_label(blender::gpu::VKContext *ctx,
|
||||
VkObjectType objType,
|
||||
uint64_t obj,
|
||||
const char *name)
|
||||
Jeroen Bakker
commented
Also check the other functions. `cmd` -> `vk_command_buffer`. No need to confuse readers with incorrect abbreviations.
Also check the other functions.
|
||||
{
|
||||
VKDebuggingTools tools = ctx->debuggingtools_get();
|
||||
if (tools.enabled) {
|
||||
VkDebugUtilsObjectNameInfoEXT info = {};
|
||||
info.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;
|
||||
info.objectType = objType;
|
||||
info.objectHandle = obj;
|
||||
info.pObjectName = name;
|
||||
tools.vkSetDebugUtilsObjectNameEXT_r(ctx->device_get(), &info);
|
||||
}
|
||||
}
|
||||
|
||||
void pushMarker(blender::gpu::VKContext *ctx, VkCommandBuffer cmd, const char *name)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setMarker(blender::gpu::VKContext *ctx, VkCommandBuffer cmd, const char *name)
|
||||
{
|
||||
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.vkCmdInsertDebugUtilsLabelEXT_r(cmd, &info);
|
||||
}
|
||||
}
|
||||
Jeroen Bakker
commented
I add Also check other functions below. `queue` -> `vk_queue`.
I add `vk_` to all Vulkan API data types to not confuse them with our internal types. Best to keep this consistent. I know not all parts already use this convention. But would want all the new code to follow it.
Also check other functions below.
|
||||
}
|
||||
|
||||
void popMarker(blender::gpu::VKContext *ctx, VkCommandBuffer 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)
|
||||
{
|
||||
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.vkQueueBeginDebugUtilsLabelEXT_r(q, &info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setMarker(blender::gpu::VKContext *ctx, VkQueue q, const char *name)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (G.debug & G_DEBUG_GPU) {
|
||||
VKDebuggingTools tools = ctx->debuggingtools_get();
|
||||
if (tools.enabled) {
|
||||
tools.vkQueueEndDebugUtilsLabelEXT_r(q);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace blender::gpu::debug
|
||||
|
|
|
@ -1,58 +1,62 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
* Copyright 2023 Blender Foundation. All rights reserved. */
|
||||
|
||||
/** \file
|
||||
* \ingroup gpu
|
||||
*/
|
||||
/** \file
|
||||
* \ingroup gpu
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "BKE_global.h"
|
||||
#include "BLI_string.h"
|
||||
|
||||
#include "vk_common.hh"
|
||||
#include <regex>
|
||||
|
||||
#include <typeindex>
|
||||
|
||||
namespace blender {
|
||||
namespace gpu {
|
||||
class VKContext;
|
||||
namespace debug {
|
||||
typedef struct VKDebuggingTools {
|
||||
bool enabled = false;
|
||||
/* Function pointer definitions .*/
|
||||
PFN_vkCreateDebugUtilsMessengerEXT vkCreateDebugUtilsMessengerEXT_r = nullptr;
|
||||
PFN_vkDestroyDebugUtilsMessengerEXT vkDestroyDebugUtilsMessengerEXT_r = nullptr;
|
||||
PFN_vkSubmitDebugUtilsMessageEXT vkSubmitDebugUtilsMessageEXT_r = nullptr;
|
||||
PFN_vkCmdBeginDebugUtilsLabelEXT vkCmdBeginDebugUtilsLabelEXT_r = nullptr;
|
||||
PFN_vkCmdEndDebugUtilsLabelEXT vkCmdEndDebugUtilsLabelEXT_r = nullptr;
|
||||
PFN_vkCmdInsertDebugUtilsLabelEXT vkCmdInsertDebugUtilsLabelEXT_r = nullptr;
|
||||
PFN_vkQueueBeginDebugUtilsLabelEXT vkQueueBeginDebugUtilsLabelEXT_r = nullptr;
|
||||
PFN_vkQueueEndDebugUtilsLabelEXT vkQueueEndDebugUtilsLabelEXT_r = nullptr;
|
||||
PFN_vkQueueInsertDebugUtilsLabelEXT vkQueueInsertDebugUtilsLabelEXT_r = nullptr;
|
||||
PFN_vkSetDebugUtilsObjectNameEXT vkSetDebugUtilsObjectNameEXT_r = nullptr;
|
||||
PFN_vkSetDebugUtilsObjectTagEXT vkSetDebugUtilsObjectTagEXT_r = nullptr;
|
||||
namespace gpu {
|
||||
class VKContext;
|
||||
namespace debug {
|
||||
typedef struct VKDebuggingTools {
|
||||
bool enabled = false;
|
||||
/* Function pointer definitions .*/
|
||||
PFN_vkCreateDebugUtilsMessengerEXT vkCreateDebugUtilsMessengerEXT_r = nullptr;
|
||||
PFN_vkDestroyDebugUtilsMessengerEXT vkDestroyDebugUtilsMessengerEXT_r = nullptr;
|
||||
PFN_vkSubmitDebugUtilsMessageEXT vkSubmitDebugUtilsMessageEXT_r = nullptr;
|
||||
PFN_vkCmdBeginDebugUtilsLabelEXT vkCmdBeginDebugUtilsLabelEXT_r = nullptr;
|
||||
PFN_vkCmdEndDebugUtilsLabelEXT vkCmdEndDebugUtilsLabelEXT_r = nullptr;
|
||||
PFN_vkCmdInsertDebugUtilsLabelEXT vkCmdInsertDebugUtilsLabelEXT_r = nullptr;
|
||||
PFN_vkQueueBeginDebugUtilsLabelEXT vkQueueBeginDebugUtilsLabelEXT_r = nullptr;
|
||||
PFN_vkQueueEndDebugUtilsLabelEXT vkQueueEndDebugUtilsLabelEXT_r = nullptr;
|
||||
PFN_vkQueueInsertDebugUtilsLabelEXT vkQueueInsertDebugUtilsLabelEXT_r = nullptr;
|
||||
PFN_vkSetDebugUtilsObjectNameEXT vkSetDebugUtilsObjectNameEXT_r = nullptr;
|
||||
PFN_vkSetDebugUtilsObjectTagEXT vkSetDebugUtilsObjectTagEXT_r = nullptr;
|
||||
|
||||
}VKDebuggingTools;
|
||||
bool init_vk_callbacks(VKContext* ctx, PFN_vkGetInstanceProcAddr instload);
|
||||
void destroy_vk_callbacks(VKContext* ctx);
|
||||
void object_vk_label(VKContext* ctx, VkObjectType objType, uint64_t obj, const char* name);
|
||||
template<typename T> void object_vk_label(VKContext* ctx, T obj, const char* name) {
|
||||
if (!(G.debug & G_DEBUG_GPU)) {
|
||||
return;
|
||||
}
|
||||
const size_t label_size = 64;
|
||||
char label[label_size];
|
||||
memset(label,0,label_size);
|
||||
static int stats = 0;
|
||||
SNPRINTF(label, "%s_%d", name, stats++);
|
||||
object_vk_label(ctx, to_vk_object_type(obj), (uint64_t)obj, (const char*)label);
|
||||
};
|
||||
|
||||
void pushMarker(VKContext *ctx, VkCommandBuffer cmd, const char *name);
|
||||
void setMarker(VKContext *ctx, VkCommandBuffer cmd, const char *name);
|
||||
void popMarker(VKContext *ctx, VkCommandBuffer cmd);
|
||||
void pushMarker(VKContext *ctx, VkQueue q, const char *name);
|
||||
void setMarker(VKContext *ctx, VkQueue q, const char *name);
|
||||
void popMarker(VKContext *ctx, VkQueue q);
|
||||
}
|
||||
}
|
||||
}
|
||||
} VKDebuggingTools;
|
||||
vnapdv marked this conversation as resolved
Outdated
Jeroen Bakker
commented
we should remove vk from the function names it is redundant in these cases we should remove vk from the function names it is redundant in these cases
|
||||
bool init_vk_callbacks(VKContext *ctx, PFN_vkGetInstanceProcAddr instload);
|
||||
void destroy_vk_callbacks(VKContext *ctx);
|
||||
void object_vk_label(VKContext *ctx, VkObjectType objType, uint64_t obj, const char *name);
|
||||
|
||||
Jeroen Bakker
commented
`obj` -> `object_handle`
|
||||
template<typename T> void object_vk_label(VKContext *ctx, T obj, const char *name)
|
||||
{
|
||||
if (!(G.debug & G_DEBUG_GPU)) {
|
||||
return;
|
||||
}
|
||||
const size_t label_size = 64;
|
||||
char label[label_size];
|
||||
memset(label, 0, label_size);
|
||||
static int stats = 0;
|
||||
SNPRINTF(label, "%s_%d", name, stats++);
|
||||
object_vk_label(ctx, to_vk_object_type(obj), (uint64_t)obj, (const char *)label);
|
||||
};
|
||||
|
||||
vnapdv marked this conversation as resolved
Outdated
Jeroen Bakker
commented
`push_marker` / `pop_marker` / `set_marker`
Jeroen Bakker
commented
Also update the definitions to match the parameter names of the implementation. Also update the definitions to match the parameter names of the implementation.
|
||||
void pushMarker(VKContext *ctx, VkCommandBuffer cmd, const char *name);
|
||||
void setMarker(VKContext *ctx, VkCommandBuffer cmd, const char *name);
|
||||
void popMarker(VKContext *ctx, VkCommandBuffer cmd);
|
||||
void pushMarker(VKContext *ctx, VkQueue q, const char *name);
|
||||
void setMarker(VKContext *ctx, VkQueue q, const char *name);
|
||||
void popMarker(VKContext *ctx, VkQueue q);
|
||||
|
||||
} // namespace debug
|
||||
} // namespace gpu
|
||||
} // namespace blender
|
||||
|
|
One empty line is enough here.
Make sure you run
make format
or have clang-format configured correctly in your IDE.