From e3533b3bf150847091510482c310a4e5337a5b3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tapani=20P=C3=A4lli?= Date: Wed, 6 Jun 2018 14:19:16 +0300 Subject: [PATCH] glsl/linker: validate attribute aliasing before optimizations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Patch does a 'dry run' of assign_attribute_or_color_locations before optimizations to catch cases where we have aliasing of unused attributes which is forbidden by the GLSL ES 3.0 specification. Signed-off-by: Tapani Pälli Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106833 --- src/compiler/glsl/linker.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp index 3ce78fe6428..61edaab4204 100644 --- a/src/compiler/glsl/linker.cpp +++ b/src/compiler/glsl/linker.cpp @@ -2611,7 +2611,8 @@ static bool assign_attribute_or_color_locations(void *mem_ctx, gl_shader_program *prog, struct gl_constants *constants, - unsigned target_index) + unsigned target_index, + bool do_assignment) { /* Maximum number of generic locations. This corresponds to either the * maximum number of draw buffers or the maximum number of generic @@ -2974,6 +2975,9 @@ assign_attribute_or_color_locations(void *mem_ctx, num_attr++; } + if (!do_assignment) + return true; + if (target_index == MESA_SHADER_VERTEX) { unsigned total_attribs_size = _mesa_bitcount(used_locations & SAFE_MASK_FROM_INDEX(max_index)) + @@ -4643,12 +4647,12 @@ link_varyings_and_uniforms(unsigned first, unsigned last, } if (!assign_attribute_or_color_locations(mem_ctx, prog, &ctx->Const, - MESA_SHADER_VERTEX)) { + MESA_SHADER_VERTEX, true)) { return false; } if (!assign_attribute_or_color_locations(mem_ctx, prog, &ctx->Const, - MESA_SHADER_FRAGMENT)) { + MESA_SHADER_FRAGMENT, true)) { return false; } @@ -5018,6 +5022,14 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) lower_tess_level(prog->_LinkedShaders[i]); } + /* Verify attribute aliasing. */ + if (i == MESA_SHADER_VERTEX) { + if (!assign_attribute_or_color_locations(mem_ctx, prog, &ctx->Const, + MESA_SHADER_VERTEX, false)) { + goto done; + } + } + /* Call opts before lowering const arrays to uniforms so we can const * propagate any elements accessed directly. */ -- 2.14.4