From 679421628bf89067b4cbfa85530f196ca2835717 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Thu, 30 Apr 2020 15:06:08 +0200 Subject: glsl: add a is_implicit_initializer flag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Shared globals and glsl_zero_init can cause linker errors if the variable is only initialized in 1 place. This commit adds a flag to variables that have been implicitely initialized to be able in this situation to keep the explicit initialization value. Without this change the global-single-initializer-2-shaders piglit test fails when using glsl_zero_init. Reviewed-by: Marek Olšák Part-of: --- src/compiler/glsl/linker.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/compiler/glsl/linker.cpp') diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp index a49c5e6ccc2..a674726312f 100644 --- a/src/compiler/glsl/linker.cpp +++ b/src/compiler/glsl/linker.cpp @@ -1064,9 +1064,13 @@ cross_validate_globals(struct gl_context *ctx, struct gl_shader_program *prog, * no vendor actually implemented that behavior. The 4.20 * behavior matches the implemented behavior of at least one other * vendor, so we'll implement that for all GLSL versions. + * If (at least) one of these constant expressions is implicit, + * because it was added by glsl_zero_init, we skip the verification. */ if (var->constant_initializer != NULL) { - if (existing->constant_initializer != NULL) { + if (existing->constant_initializer != NULL && + !existing->data.is_implicit_initializer && + !var->data.is_implicit_initializer) { if (!var->constant_initializer->has_value(existing->constant_initializer)) { linker_error(prog, "initializers for %s " "`%s' have differing values\n", @@ -1078,7 +1082,8 @@ cross_validate_globals(struct gl_context *ctx, struct gl_shader_program *prog, * not have an initializer but a later instance does, * replace the former with the later. */ - variables->replace_variable(existing->name, var); + if (!var->data.is_implicit_initializer) + variables->replace_variable(existing->name, var); } } -- cgit v1.2.3