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
5 changed files with 94 additions and 8 deletions
Showing only changes of commit bb7d1f0422 - Show all commits

View File

@ -863,13 +863,16 @@ GHOST_TSuccess GHOST_ContextVK::initializeDrawingContext()
auto extensions_available = getExtensionsAvailable();
vector<const char *> layers_enabled;
if (m_debug) {
enableLayer(layers_available, layers_enabled, "VK_LAYER_KHRONOS_validation", m_debug);
}
vector<const char *> extensions_device;
vector<const char *> extensions_enabled;
if (m_debug) {
enableLayer(layers_available, layers_enabled, "VK_LAYER_KHRONOS_validation", m_debug);
requireExtension(extensions_available, extensions_enabled, VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
}
vnapdv marked this conversation as resolved Outdated

One empty line is enough here.

Make sure you run make format or have clang-format configured correctly in your IDE.

One empty line is enough here. Make sure you run `make format` or have clang-format configured correctly in your IDE.
if (use_window_surface) {
const char *native_surface_extension_name = getPlatformSpecificSurfaceExtension();

View File

@ -215,6 +215,7 @@ set(VULKAN_SRC
vulkan/vk_texture.cc
vulkan/vk_uniform_buffer.cc
vulkan/vk_vertex_buffer.cc
vulkan/vk_debug.cc
vulkan/vk_backend.hh
vulkan/vk_batch.hh
@ -242,6 +243,8 @@ set(VULKAN_SRC
vulkan/vk_texture.hh
vulkan/vk_uniform_buffer.hh
vulkan/vk_vertex_buffer.hh
vulkan/vk_debug.hh
)
set(METAL_SRC

View File

@ -24,5 +24,69 @@ VkFormat to_vk_format(const eGPUTextureFormat format);
VkComponentMapping to_vk_component_mapping(const eGPUTextureFormat format);
VkImageViewType to_vk_image_view_type(const eGPUTextureType type);
VkImageType to_vk_image_type(const eGPUTextureType type);
#ifdef __cplusplus
template<typename T> VkObjectType to_vk_object_type(T vk_obj)
{
const type_info &tid = typeid(T);
#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);
VK_EQ_TYPEID(VkDevice, DEVICE);
VK_EQ_TYPEID(VkQueue, QUEUE);
VK_EQ_TYPEID(VkSemaphore, SEMAPHORE);
VK_EQ_TYPEID(VkCommandBuffer, COMMAND_BUFFER);
VK_EQ_TYPEID(VkFence, FENCE);
VK_EQ_TYPEID(VkDeviceMemory, DEVICE_MEMORY);
VK_EQ_TYPEID(VkBuffer, BUFFER);
VK_EQ_TYPEID(VkImage, IMAGE);
VK_EQ_TYPEID(VkImage, IMAGE);
VK_EQ_TYPEID(VkEvent, EVENT);
VK_EQ_TYPEID(VkQueryPool, QUERY_POOL);
VK_EQ_TYPEID(VkBufferView, BUFFER_VIEW);
VK_EQ_TYPEID(VkImageView, IMAGE_VIEW);
VK_EQ_TYPEID(VkShaderModule, SHADER_MODULE);
VK_EQ_TYPEID(VkPipelineCache, PIPELINE_CACHE);
VK_EQ_TYPEID(VkPipelineLayout, PIPELINE_LAYOUT);
VK_EQ_TYPEID(VkRenderPass, RENDER_PASS);
VK_EQ_TYPEID(VkPipeline, PIPELINE);
VK_EQ_TYPEID(VkDescriptorSetLayout, DESCRIPTOR_SET_LAYOUT);
VK_EQ_TYPEID(VkSampler, SAMPLER);
VK_EQ_TYPEID(VkDescriptorPool, DESCRIPTOR_POOL);
VK_EQ_TYPEID(VkDescriptorSet, DESCRIPTOR_SET);
VK_EQ_TYPEID(VkFramebuffer, FRAMEBUFFER);
VK_EQ_TYPEID(VkCommandPool, COMMAND_POOL);
VK_EQ_TYPEID(VkSamplerYcbcrConversion, SAMPLER_YCBCR_CONVERSION);
VK_EQ_TYPEID(VkDescriptorUpdateTemplate, DESCRIPTOR_UPDATE_TEMPLATE);
VK_EQ_TYPEID(VkSurfaceKHR, SURFACE_KHR);
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(VkVideoSessionKHR, VIDEO_SESSION_KHR);
#endif
#ifdef VK_ENABLE_BETA_EXTENSIONS
VK_EQ_TYPEID(VkVideoSessionParametersKHR, VIDEO_SESSION_PARAMETERS_KHR);
#endif
VK_EQ_TYPEID(VkCuModuleNVX, CU_MODULE_NVX);
VK_EQ_TYPEID(VkCuFunctionNVX, CU_FUNCTION_NVX);
VK_EQ_TYPEID(VkDebugUtilsMessengerEXT, DEBUG_UTILS_MESSENGER_EXT);
VK_EQ_TYPEID(VkAccelerationStructureKHR, ACCELERATION_STRUCTURE_KHR);
VK_EQ_TYPEID(VkValidationCacheEXT, VALIDATION_CACHE_EXT);
VK_EQ_TYPEID(VkAccelerationStructureNV, ACCELERATION_STRUCTURE_NV);
VK_EQ_TYPEID(VkPerformanceConfigurationINTEL, PERFORMANCE_CONFIGURATION_INTEL);
VK_EQ_TYPEID(VkDeferredOperationKHR, DEFERRED_OPERATION_KHR);
VK_EQ_TYPEID(VkIndirectCommandsLayoutNV, INDIRECT_COMMANDS_LAYOUT_NV);
VK_EQ_TYPEID(VkPrivateDataSlotEXT, PRIVATE_DATA_SLOT_EXT);
BLI_assert_unreachable();
#undef VK_EQ_TYPEID
return VK_OBJECT_TYPE_UNKNOWN;
} // namespace blender::gpu
#endif
vnapdv marked this conversation as resolved Outdated

// namespace blender::gpu can be removed.

`// namespace blender::gpu` can be removed.
} // namespace blender::gpu

View File

@ -5,6 +5,7 @@
* \ingroup gpu
*/
#include "vk_debug.hh"
#include "vk_context.hh"
#include "vk_backend.hh"
@ -31,8 +32,11 @@ VKContext::VKContext(void *ghost_window, void *ghost_context)
&vk_device_,
&vk_queue_family_,
&vk_queue_);
init_physical_device_limits();
debug::init_vk_callbacks(this, vkGetInstanceProcAddr);
init_physical_device_limits();
debug::object_vk_label(this, vk_device_, "LogicalDevice");
vnapdv marked this conversation as resolved Outdated

In the name Vk is redundant. Would use
"LogicalDevice" and "GenericQueue" is enough.

Generic as it handles compute shaders as well. In the future the plan is to have multiple queue families (async compute) as a separate queue.

In the name Vk is redundant. Would use "LogicalDevice" and "GenericQueue" is enough. Generic as it handles compute shaders as well. In the future the plan is to have multiple queue families (async compute) as a separate queue.
debug::object_vk_label(this, vk_queue_, "GraphicsQueue");
/* Initialize the memory allocator. */
VmaAllocatorCreateInfo info = {};
/* Should use same vulkan version as GHOST (1.2), but set to 1.0 as 1.2 requires
@ -57,6 +61,7 @@ VKContext::VKContext(void *ghost_window, void *ghost_context)
VKContext::~VKContext()
{
vmaDestroyAllocator(mem_allocator_);
debug::destroy_vk_callbacks(this);
Review

This break is as a chain on the device. It has no direct relationship with VKContext.

This break is as a chain on the device. It has no direct relationship with VKContext.
}
void VKContext::init_physical_device_limits()

View File

@ -8,9 +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_debug.hh"
namespace blender::gpu {
@ -30,7 +31,7 @@ class VKContext : public Context {
/** Limits of the device linked to this context. */
VkPhysicalDeviceLimits vk_physical_device_limits_;
debug::VKDebuggingTools vk_debugging_tools;
void *ghost_context_;
public:
@ -70,6 +71,11 @@ class VKContext : public Context {
return vk_physical_device_limits_;
}
VkInstance instance_get() const
{
return vk_instance_;
};
VkDevice device_get() const
{
return vk_device_;
@ -100,7 +106,12 @@ class VKContext : public Context {
return mem_allocator_;
}
private:
debug::VKDebuggingTools& debuggingtools_get()
{
return vk_debugging_tools;
}
private:
void init_physical_device_limits();
};