Vulkan: Fix Shader Compilation Issue

The Specialization Shader workaround generated code that wasn't Vulkan
GLSL compliant. The uintBitsToFloat cannot be used during global const
initialization.

This is a temporary work around until we implement the Specialization
Constants for Vulkan.

Pull Request: https://projects.blender.org/blender/blender/pulls/116942
This commit is contained in:
Jeroen Bakker
2024-01-09 14:55:02 +01:00
parent 311589ce23
commit 5b969f54ca

View File

@@ -1015,9 +1015,10 @@ std::string VKShader::resources_declare(const shader::ShaderCreateInfo &info) co
ss << "const bool " << sc.name << "=" << (sc.default_value.u ? "true" : "false") << ";\n";
break;
case Type::FLOAT:
/* Use uint representation to allow exact same bit pattern even if NaN. */
ss << "const float " << sc.name << "= uintBitsToFloat("
<< std::to_string(sc.default_value.u) << "u);\n";
/* Use uint representation to allow exact same bit pattern even if NaN. uintBitsToFloat
* isn't supported during global const initialization. */
ss << "#define " << sc.name << " uintBitsToFloat(" << std::to_string(sc.default_value.u)
<< "u)\n";
break;
default:
BLI_assert_unreachable();