diff options
author | Juan A. Suarez Romero <[email protected]> | 2018-02-05 17:38:39 +0100 |
---|---|---|
committer | Juan A. Suarez Romero <[email protected]> | 2018-02-05 18:10:43 +0100 |
commit | 4195eed961ccfe404ae81b9112189fc93a254ded (patch) | |
tree | a5b0bfb0976daf661514015ff4d6b76a3e2cf8a5 /src | |
parent | 3d14e720574ea933b172affdafd53c74a9381e9c (diff) |
glsl/linker: check same name is not used in block and outside
According with OpenGL GLSL 3.20 spec, section 4.3.9:
"It is a link-time error if any particular shader interface
contains:
- two different blocks, each having no instance name, and each
having a member of the same name, or
- a variable outside a block, and a block with no instance name,
where the variable has the same name as a member in the block."
This fixes a previous commit 9b894c8 ("glsl/linker: link-error using the
same name in unnamed block and outside") that covered this case, but
did not take in account that precision qualifiers are ignored when
comparing blocks with no instance name.
With this commit, the original tests
KHR-GL*.shaders.uniform_block.common.name_matching keep fixed, and also
dEQP-GLES31.functional.shaders.linkage.uniform.block.differing_precision
regression is fixed, which was broken by previous commit.
v2: use helper varibles (Matteo Bruni)
Fixes: 9b894c8 ("glsl/linker: link-error using the same name in unnamed block and outside")
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104668
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104777
CC: Mark Janes <[email protected]>
CC: "18.0" <[email protected]>
Tested-by: Matteo Bruni <[email protected]>
Reviewed-by: Tapani Pälli <[email protected]>
Signed-off-by: Juan A. Suarez Romero <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/glsl/linker.cpp | 53 |
1 files changed, 30 insertions, 23 deletions
diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp index ce101935b01..d3d18c248f2 100644 --- a/src/compiler/glsl/linker.cpp +++ b/src/compiler/glsl/linker.cpp @@ -1111,29 +1111,6 @@ cross_validate_globals(struct gl_shader_program *prog, return; } - /* In OpenGL GLSL 4.20 spec, section 4.3.9, page 57: - * - * "It is a link-time error if any particular shader interface - * contains: - * - * - two different blocks, each having no instance name, and each - * having a member of the same name, or - * - * - a variable outside a block, and a block with no instance name, - * where the variable has the same name as a member in the block." - */ - if (var->data.mode == existing->data.mode && - var->get_interface_type() != existing->get_interface_type()) { - linker_error(prog, "declarations for %s `%s` are in " - "%s and %s\n", - mode_string(var), var->name, - existing->get_interface_type() ? - existing->get_interface_type()->name : "outside a block", - var->get_interface_type() ? - var->get_interface_type()->name : "outside a block"); - - return; - } /* Only in GLSL ES 3.10, the precision qualifier should not match * between block members defined in matched block names within a * shader interface. @@ -1155,6 +1132,36 @@ cross_validate_globals(struct gl_shader_program *prog, mode_string(var), var->name); } } + + /* In OpenGL GLSL 3.20 spec, section 4.3.9: + * + * "It is a link-time error if any particular shader interface + * contains: + * + * - two different blocks, each having no instance name, and each + * having a member of the same name, or + * + * - a variable outside a block, and a block with no instance name, + * where the variable has the same name as a member in the block." + */ + const glsl_type *var_itype = var->get_interface_type(); + const glsl_type *existing_itype = existing->get_interface_type(); + if (var_itype != existing_itype) { + if (!var_itype || !existing_itype) { + linker_error(prog, "declarations for %s `%s` are inside block " + "`%s` and outside a block", + mode_string(var), var->name, + var_itype ? var_itype->name : existing_itype->name); + return; + } else if (strcmp(var_itype->name, existing_itype->name) != 0) { + linker_error(prog, "declarations for %s `%s` are inside blocks " + "`%s` and `%s`", + mode_string(var), var->name, + existing_itype->name, + var_itype->name); + return; + } + } } else variables->add_variable(var); } |