mirror of
https://github.com/stenzek/duckstation.git
synced 2026-02-15 02:44:41 +00:00
GPUDevice: Set fixed names for UBO/push constants in SPV transpiling
Ensures that name-based binding in GL succeeds.
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user