VulkanDevice: Add env var for non-semantic debug info

Backport of 070068366f
This commit is contained in:
Stenzek 2024-04-14 14:42:55 +10:00
parent 8a3ba53204
commit e9107bd140
No known key found for this signature in database
2 changed files with 16 additions and 4 deletions

View File

@ -23,6 +23,7 @@
#include "fmt/format.h"
#include "xxhash.h"
#include <cstdlib>
#include <limits>
#include <mutex>
@ -395,8 +396,17 @@ bool VulkanDevice::SelectDeviceExtensions(ExtensionList* extension_list, bool en
m_optional_extensions.vk_khr_dynamic_rendering &&
SupportsExtension(VK_KHR_DYNAMIC_RENDERING_LOCAL_READ_EXTENSION_NAME, false);
m_optional_extensions.vk_khr_push_descriptor = SupportsExtension(VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME, false);
m_optional_extensions.vk_khr_shader_non_semantic_info =
SupportsExtension(VK_KHR_SHADER_NON_SEMANTIC_INFO_EXTENSION_NAME, false);
// glslang generates debug info instructions before phi nodes at the beginning of blocks when non-semantic debug info
// is enabled, triggering errors by spirv-val. Gate it by an environment variable if you want source debugging until
// this is fixed.
if (const char* val = std::getenv("USE_NON_SEMANTIC_DEBUG_INFO");
val && StringUtil::FromChars<bool>(val).value_or(false))
{
m_optional_extensions.vk_khr_shader_non_semantic_info =
SupportsExtension(VK_KHR_SHADER_NON_SEMANTIC_INFO_EXTENSION_NAME, false);
}
m_optional_extensions.vk_ext_external_memory_host =
SupportsExtension(VK_EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME, false);

View File

@ -65,9 +65,11 @@ std::unique_ptr<GPUShader> VulkanDevice::CreateShaderFromSource(GPUShaderStage s
if (m_debug_device)
{
options.SetOptimizationLevel(shaderc_optimization_level_zero);
options.SetGenerateDebugInfo();
if (m_optional_extensions.vk_khr_shader_non_semantic_info)
options.SetGenerateDebugInfo();
options.SetEmitNonSemanticDebugInfo();
options.SetOptimizationLevel(shaderc_optimization_level_zero);
}
else
{