Fix #130776: OpenGL: Use explicit uniform locations

Ensure uniform locations are the same across specialization constants
shader variations.

Pull Request: https://projects.blender.org/blender/blender/pulls/131116
This commit is contained in:
Miguel Pozo
2024-11-29 15:47:51 +01:00
parent 9a4b232bd5
commit 8504c12fa9

View File

@@ -598,12 +598,15 @@ std::string GLShader::resources_declare(const ShaderCreateInfo &info) const
print_resource_alias(ss, res);
}
ss << "\n/* Push Constants. */\n";
int location = 0;
for (const ShaderCreateInfo::PushConst &uniform : info.push_constants_) {
ss << "layout( location = " << location << ") ";
ss << "uniform " << to_string(uniform.type) << " " << uniform.name;
if (uniform.array_size > 0) {
ss << "[" << uniform.array_size << "]";
}
ss << ";\n";
location += std::max(1, uniform.array_size);
}
#if 0 /* #95278: This is not be enough to prevent some compilers think it is recursive. */
for (const ShaderCreateInfo::PushConst &uniform : info.push_constants_) {