2023-03-23 16:37:52 +01:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later
|
2023-02-22 10:16:42 +01:00
|
|
|
* Copyright 2023 Blender Foundation. */
|
2023-03-23 16:37:52 +01:00
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
|
* \ingroup gpu
|
|
|
|
|
*/
|
|
|
|
|
|
2023-04-21 12:32:40 +02:00
|
|
|
#include "BKE_global.h"
|
|
|
|
|
|
2023-03-23 16:37:52 +01:00
|
|
|
#include "vk_backend.hh"
|
|
|
|
|
#include "vk_context.hh"
|
2023-04-21 12:32:40 +02:00
|
|
|
#include "vk_debug.hh"
|
2023-03-23 16:37:52 +01:00
|
|
|
|
|
|
|
|
namespace blender::gpu {
|
2023-04-21 12:49:36 +02:00
|
|
|
void VKContext::debug_group_begin(const char *name, int)
|
|
|
|
|
{
|
2023-05-04 10:06:48 +02:00
|
|
|
const VKDevice &device = VKBackend::get().device_get();
|
|
|
|
|
debug::push_marker(device, name);
|
2023-04-21 12:49:36 +02:00
|
|
|
}
|
2023-03-23 16:37:52 +01:00
|
|
|
|
2023-04-21 12:49:36 +02:00
|
|
|
void VKContext::debug_group_end()
|
|
|
|
|
{
|
2023-05-04 10:06:48 +02:00
|
|
|
const VKDevice &device = VKBackend::get().device_get();
|
|
|
|
|
debug::pop_marker(device);
|
2023-04-21 12:49:36 +02:00
|
|
|
}
|
2023-03-23 16:37:52 +01:00
|
|
|
|
|
|
|
|
bool VKContext::debug_capture_begin()
|
|
|
|
|
{
|
2023-05-04 10:06:48 +02:00
|
|
|
return VKBackend::get().debug_capture_begin();
|
2023-03-23 16:37:52 +01:00
|
|
|
}
|
|
|
|
|
|
2023-05-04 10:06:48 +02:00
|
|
|
bool VKBackend::debug_capture_begin()
|
2023-03-23 16:37:52 +01:00
|
|
|
{
|
|
|
|
|
#ifdef WITH_RENDERDOC
|
2023-05-04 10:06:48 +02:00
|
|
|
return renderdoc_api_.start_frame_capture(device_get().instance_get(), nullptr);
|
2023-03-23 16:37:52 +01:00
|
|
|
#else
|
|
|
|
|
return false;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VKContext::debug_capture_end()
|
|
|
|
|
{
|
2023-05-04 10:06:48 +02:00
|
|
|
VKBackend::get().debug_capture_end();
|
2023-03-23 16:37:52 +01:00
|
|
|
}
|
|
|
|
|
|
2023-05-04 10:06:48 +02:00
|
|
|
void VKBackend::debug_capture_end()
|
2023-03-23 16:37:52 +01:00
|
|
|
{
|
|
|
|
|
#ifdef WITH_RENDERDOC
|
2023-05-04 10:06:48 +02:00
|
|
|
renderdoc_api_.end_frame_capture(device_get().instance_get(), nullptr);
|
2023-03-23 16:37:52 +01:00
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void *VKContext::debug_capture_scope_create(const char * /*name*/)
|
|
|
|
|
{
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool VKContext::debug_capture_scope_begin(void * /*scope*/)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-29 16:50:54 +02:00
|
|
|
void VKContext::debug_capture_scope_end(void * /*scope*/) {}
|
2023-03-23 16:37:52 +01:00
|
|
|
} // namespace blender::gpu
|
2023-04-21 12:32:40 +02:00
|
|
|
|
|
|
|
|
namespace blender::gpu::debug {
|
|
|
|
|
|
2023-05-04 10:06:48 +02:00
|
|
|
void VKDebuggingTools::init(VkInstance vk_instance)
|
|
|
|
|
{
|
|
|
|
|
PFN_vkGetInstanceProcAddr instance_proc_addr = vkGetInstanceProcAddr;
|
|
|
|
|
enabled = false;
|
|
|
|
|
vkCmdBeginDebugUtilsLabelEXT_r = (PFN_vkCmdBeginDebugUtilsLabelEXT)instance_proc_addr(
|
|
|
|
|
vk_instance, "vkCmdBeginDebugUtilsLabelEXT");
|
|
|
|
|
vkCmdEndDebugUtilsLabelEXT_r = (PFN_vkCmdEndDebugUtilsLabelEXT)instance_proc_addr(
|
|
|
|
|
vk_instance, "vkCmdEndDebugUtilsLabelEXT");
|
|
|
|
|
vkCmdInsertDebugUtilsLabelEXT_r = (PFN_vkCmdInsertDebugUtilsLabelEXT)instance_proc_addr(
|
|
|
|
|
vk_instance, "vkCmdInsertDebugUtilsLabelEXT");
|
|
|
|
|
vkCreateDebugUtilsMessengerEXT_r = (PFN_vkCreateDebugUtilsMessengerEXT)instance_proc_addr(
|
|
|
|
|
vk_instance, "vkCreateDebugUtilsMessengerEXT");
|
|
|
|
|
vkDestroyDebugUtilsMessengerEXT_r = (PFN_vkDestroyDebugUtilsMessengerEXT)instance_proc_addr(
|
|
|
|
|
vk_instance, "vkDestroyDebugUtilsMessengerEXT");
|
|
|
|
|
vkQueueBeginDebugUtilsLabelEXT_r = (PFN_vkQueueBeginDebugUtilsLabelEXT)instance_proc_addr(
|
|
|
|
|
vk_instance, "vkQueueBeginDebugUtilsLabelEXT");
|
|
|
|
|
vkQueueEndDebugUtilsLabelEXT_r = (PFN_vkQueueEndDebugUtilsLabelEXT)instance_proc_addr(
|
|
|
|
|
vk_instance, "vkQueueEndDebugUtilsLabelEXT");
|
|
|
|
|
vkQueueInsertDebugUtilsLabelEXT_r = (PFN_vkQueueInsertDebugUtilsLabelEXT)instance_proc_addr(
|
|
|
|
|
vk_instance, "vkQueueInsertDebugUtilsLabelEXT");
|
|
|
|
|
vkSetDebugUtilsObjectNameEXT_r = (PFN_vkSetDebugUtilsObjectNameEXT)instance_proc_addr(
|
|
|
|
|
vk_instance, "vkSetDebugUtilsObjectNameEXT");
|
|
|
|
|
vkSetDebugUtilsObjectTagEXT_r = (PFN_vkSetDebugUtilsObjectTagEXT)instance_proc_addr(
|
|
|
|
|
vk_instance, "vkSetDebugUtilsObjectTagEXT");
|
|
|
|
|
vkSubmitDebugUtilsMessageEXT_r = (PFN_vkSubmitDebugUtilsMessageEXT)instance_proc_addr(
|
|
|
|
|
vk_instance, "vkSubmitDebugUtilsMessageEXT");
|
|
|
|
|
if (vkCmdBeginDebugUtilsLabelEXT_r) {
|
|
|
|
|
enabled = true;
|
2023-04-21 12:32:40 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-04 10:06:48 +02:00
|
|
|
void VKDebuggingTools::deinit()
|
2023-04-21 12:32:40 +02:00
|
|
|
{
|
2023-05-04 10:06:48 +02:00
|
|
|
vkCmdBeginDebugUtilsLabelEXT_r = nullptr;
|
|
|
|
|
vkCmdEndDebugUtilsLabelEXT_r = nullptr;
|
|
|
|
|
vkCmdInsertDebugUtilsLabelEXT_r = nullptr;
|
|
|
|
|
vkCreateDebugUtilsMessengerEXT_r = nullptr;
|
|
|
|
|
vkDestroyDebugUtilsMessengerEXT_r = nullptr;
|
|
|
|
|
vkQueueBeginDebugUtilsLabelEXT_r = nullptr;
|
|
|
|
|
vkQueueEndDebugUtilsLabelEXT_r = nullptr;
|
|
|
|
|
vkQueueInsertDebugUtilsLabelEXT_r = nullptr;
|
|
|
|
|
vkSetDebugUtilsObjectNameEXT_r = nullptr;
|
|
|
|
|
vkSetDebugUtilsObjectTagEXT_r = nullptr;
|
|
|
|
|
vkSubmitDebugUtilsMessageEXT_r = nullptr;
|
|
|
|
|
enabled = false;
|
2023-04-21 12:32:40 +02:00
|
|
|
}
|
|
|
|
|
|
2023-05-04 10:06:48 +02:00
|
|
|
void object_label(VkObjectType vk_object_type, uint64_t object_handle, const char *name)
|
2023-04-21 12:32:40 +02:00
|
|
|
{
|
|
|
|
|
if (G.debug & G_DEBUG_GPU) {
|
2023-05-04 10:06:48 +02:00
|
|
|
const VKDevice &device = VKBackend::get().device_get();
|
|
|
|
|
const VKDebuggingTools &debugging_tools = device.debugging_tools_get();
|
2023-04-21 12:32:40 +02:00
|
|
|
if (debugging_tools.enabled) {
|
2023-05-11 13:01:56 +02:00
|
|
|
const VKDevice &device = VKBackend::get().device_get();
|
2023-04-21 12:32:40 +02:00
|
|
|
VkDebugUtilsObjectNameInfoEXT info = {};
|
|
|
|
|
info.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;
|
|
|
|
|
info.objectType = vk_object_type;
|
|
|
|
|
info.objectHandle = object_handle;
|
|
|
|
|
info.pObjectName = name;
|
2023-05-04 10:06:48 +02:00
|
|
|
debugging_tools.vkSetDebugUtilsObjectNameEXT_r(device.device_get(), &info);
|
2023-04-21 12:32:40 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-04 10:06:48 +02:00
|
|
|
void push_marker(VkCommandBuffer vk_command_buffer, const char *name)
|
2023-04-21 12:32:40 +02:00
|
|
|
{
|
|
|
|
|
if (G.debug & G_DEBUG_GPU) {
|
2023-05-04 10:06:48 +02:00
|
|
|
const VKDevice &device = VKBackend::get().device_get();
|
|
|
|
|
const VKDebuggingTools &debugging_tools = device.debugging_tools_get();
|
2023-04-21 12:32:40 +02:00
|
|
|
if (debugging_tools.enabled) {
|
|
|
|
|
VkDebugUtilsLabelEXT info = {};
|
|
|
|
|
info.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT;
|
|
|
|
|
info.pLabelName = name;
|
|
|
|
|
debugging_tools.vkCmdBeginDebugUtilsLabelEXT_r(vk_command_buffer, &info);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-04 10:06:48 +02:00
|
|
|
void set_marker(VkCommandBuffer vk_command_buffer, const char *name)
|
2023-04-21 12:32:40 +02:00
|
|
|
{
|
|
|
|
|
if (G.debug & G_DEBUG_GPU) {
|
2023-05-04 10:06:48 +02:00
|
|
|
const VKDevice &device = VKBackend::get().device_get();
|
|
|
|
|
const VKDebuggingTools &debugging_tools = device.debugging_tools_get();
|
2023-04-21 12:32:40 +02:00
|
|
|
if (debugging_tools.enabled) {
|
|
|
|
|
VkDebugUtilsLabelEXT info = {};
|
|
|
|
|
info.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT;
|
|
|
|
|
info.pLabelName = name;
|
|
|
|
|
debugging_tools.vkCmdInsertDebugUtilsLabelEXT_r(vk_command_buffer, &info);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-04 10:06:48 +02:00
|
|
|
void pop_marker(VkCommandBuffer vk_command_buffer)
|
2023-04-21 12:32:40 +02:00
|
|
|
{
|
|
|
|
|
if (G.debug & G_DEBUG_GPU) {
|
2023-05-04 10:06:48 +02:00
|
|
|
const VKDevice &device = VKBackend::get().device_get();
|
|
|
|
|
const VKDebuggingTools &debugging_tools = device.debugging_tools_get();
|
2023-04-21 12:32:40 +02:00
|
|
|
if (debugging_tools.enabled) {
|
|
|
|
|
debugging_tools.vkCmdEndDebugUtilsLabelEXT_r(vk_command_buffer);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-04 10:06:48 +02:00
|
|
|
void push_marker(const VKDevice &device, const char *name)
|
2023-04-21 12:32:40 +02:00
|
|
|
{
|
|
|
|
|
if (G.debug & G_DEBUG_GPU) {
|
2023-05-04 10:06:48 +02:00
|
|
|
const VKDebuggingTools &debugging_tools = device.debugging_tools_get();
|
2023-04-21 12:32:40 +02:00
|
|
|
if (debugging_tools.enabled) {
|
|
|
|
|
VkDebugUtilsLabelEXT info = {};
|
|
|
|
|
info.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT;
|
|
|
|
|
info.pLabelName = name;
|
2023-05-04 10:06:48 +02:00
|
|
|
debugging_tools.vkQueueBeginDebugUtilsLabelEXT_r(device.queue_get(), &info);
|
2023-04-21 12:32:40 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-04 10:06:48 +02:00
|
|
|
void set_marker(const VKDevice &device, const char *name)
|
2023-04-21 12:32:40 +02:00
|
|
|
{
|
|
|
|
|
if (G.debug & G_DEBUG_GPU) {
|
2023-05-04 10:06:48 +02:00
|
|
|
const VKDebuggingTools &debugging_tools = device.debugging_tools_get();
|
2023-04-21 12:32:40 +02:00
|
|
|
if (debugging_tools.enabled) {
|
|
|
|
|
VkDebugUtilsLabelEXT info = {};
|
|
|
|
|
info.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT;
|
|
|
|
|
info.pLabelName = name;
|
2023-05-04 10:06:48 +02:00
|
|
|
debugging_tools.vkQueueInsertDebugUtilsLabelEXT_r(device.queue_get(), &info);
|
2023-04-21 12:32:40 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-04 10:06:48 +02:00
|
|
|
void pop_marker(const VKDevice &device)
|
2023-04-21 12:32:40 +02:00
|
|
|
{
|
|
|
|
|
if (G.debug & G_DEBUG_GPU) {
|
2023-05-04 10:06:48 +02:00
|
|
|
const VKDebuggingTools &debugging_tools = device.debugging_tools_get();
|
2023-04-21 12:32:40 +02:00
|
|
|
if (debugging_tools.enabled) {
|
2023-05-04 10:06:48 +02:00
|
|
|
debugging_tools.vkQueueEndDebugUtilsLabelEXT_r(device.queue_get());
|
2023-04-21 12:32:40 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-05-04 10:06:48 +02:00
|
|
|
|
2023-04-21 12:32:40 +02:00
|
|
|
} // namespace blender::gpu::debug
|