GPUDevice: Set fixed names for UBO/push constants in SPV transpiling

Ensures that name-based binding in GL succeeds.
This commit is contained in:
Stenzek
2025-10-27 21:47:59 +10:00
parent 4729e22573
commit 08317d9478
2 changed files with 25 additions and 0 deletions

View File

@@ -21,6 +21,8 @@ class Error;
X(spvc_compiler_install_compiler_options) \
X(spvc_compiler_require_extension) \
X(spvc_compiler_compile) \
X(spvc_compiler_set_name) \
X(spvc_compiler_set_decoration) \
X(spvc_compiler_get_decoration) \
X(spvc_resources_get_resource_list_for_type)

View File

@@ -1891,6 +1891,29 @@ bool GPUDevice::TranslateVulkanSpvToLanguage(const std::span<const u8> spirv, GP
static_cast<int>(sres));
return {};
}
if (ubos_count > 0)
{
// Set name of UBO block to match our shaders, so that drivers without binding info can still find it.
dyn_libs::spvc_compiler_set_name(scompiler, ubos[0].id, "UBOBlock");
}
if (push_constants_count > 0)
{
// Set name of push constant block to match our shaders, so that drivers without binding info can still find it.
dyn_libs::spvc_compiler_set_name(scompiler, push_constants[0].id, "PushConstants");
dyn_libs::spvc_compiler_set_decoration(scompiler, push_constants[0].id, SpvDecorationBinding, 1);
if ((sres = dyn_libs::spvc_compiler_options_set_bool(
soptions, SPVC_COMPILER_OPTION_GLSL_EMIT_PUSH_CONSTANT_AS_UNIFORM_BUFFER, SPVC_TRUE)) != SPVC_SUCCESS)
{
Error::SetStringFmt(
error,
"spvc_compiler_options_set_bool(SPVC_COMPILER_OPTION_GLSL_EMIT_PUSH_CONSTANT_AS_UNIFORM_BUFFER) failed: {}",
static_cast<int>(sres));
return {};
}
}
}
break;
#endif