Add debug name for PSO catching on D3D12/Vulkan during profiling incl. Development builds

This commit is contained in:
Wojtek Figat
2025-07-28 23:08:26 +02:00
parent ad6764e6d7
commit 17c0892ff1
8 changed files with 95 additions and 47 deletions

View File

@@ -238,14 +238,14 @@ static VKAPI_ATTR VkBool32 VKAPI_PTR DebugUtilsCallback(VkDebugUtilsMessageSever
LOG(Info, "[Vulkan] {0} {1}:{2} {3}", type, severity, callbackData->messageIdNumber, message);
}
#if BUILD_DEBUG
#if !BUILD_RELEASE
if (auto* context = (GPUContextVulkan*)GPUDevice::Instance->GetMainContext())
{
if (auto* state = (GPUPipelineStateVulkan*)context->GetState())
{
const StringAnsi vsName = state->DebugDesc.VS ? state->DebugDesc.VS->GetName() : StringAnsi::Empty;
const StringAnsi psName = state->DebugDesc.PS ? state->DebugDesc.PS->GetName() : StringAnsi::Empty;
LOG(Warning, "[Vulkan] Error during rendering with VS={}, PS={}", String(vsName), String(psName));
GPUPipelineState::DebugName name;
state->GetDebugName(name);
LOG(Warning, "[Vulkan] Error during rendering with {}", String(name.Get(), name.Count() - 1));
}
}
#endif

View File

@@ -90,6 +90,8 @@ ComputePipelineStateVulkan* GPUShaderProgramCSVulkan::GetOrCreateState()
{
if (_pipelineState)
return _pipelineState;
PROFILE_CPU();
ZoneText(*_name, _name.Length());
// Create pipeline layout
DescriptorSetLayoutInfoVulkan descriptorSetLayoutInfo;
@@ -110,7 +112,7 @@ ComputePipelineStateVulkan* GPUShaderProgramCSVulkan::GetOrCreateState()
// Create pipeline object
VkPipeline pipeline;
const VkResult result = vkCreateComputePipelines(_device->Device, _device->PipelineCache, 1, &desc, nullptr, &pipeline);
VkResult result = vkCreateComputePipelines(_device->Device, _device->PipelineCache, 1, &desc, nullptr, &pipeline);
LOG_VULKAN_RESULT(result);
if (result != VK_SUCCESS)
return nullptr;
@@ -220,7 +222,12 @@ VkPipeline GPUPipelineStateVulkan::GetState(RenderPassVulkan* renderPass, GPUVer
#endif
return pipeline;
}
PROFILE_CPU_NAMED("Create Pipeline");
PROFILE_CPU();
#if !BUILD_RELEASE
DebugName name;
GetDebugName(name);
ZoneText(name.Get(), name.Count() - 1);
#endif
// Bind vertex input
VkPipelineVertexInputStateCreateInfo vertexInputCreateInfo;
@@ -310,10 +317,8 @@ VkPipeline GPUPipelineStateVulkan::GetState(RenderPassVulkan* renderPass, GPUVer
LOG_VULKAN_RESULT(result);
if (result != VK_SUCCESS)
{
#if BUILD_DEBUG
const StringAnsi vsName = DebugDesc.VS ? DebugDesc.VS->GetName() : StringAnsi::Empty;
const StringAnsi psName = DebugDesc.PS ? DebugDesc.PS->GetName() : StringAnsi::Empty;
LOG(Error, "vkCreateGraphicsPipelines failed for VS={0}, PS={1}", String(vsName), String(psName));
#if !BUILD_RELEASE
LOG(Error, "vkCreateGraphicsPipelines failed for {}", String(name.Get(), name.Count() - 1));
#endif
return VK_NULL_HANDLE;
}