From 0129f97174a984157e96df43b40ba4165f2de57e Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 10 Jun 2016 08:01:30 -0700 Subject: [PATCH] WIP: Strip arrayness from interface block names in some IO validation --- src/mesa/main/shader_query.cpp | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp index f64b562..37cd1de 100644 --- a/src/mesa/main/shader_query.cpp +++ b/src/mesa/main/shader_query.cpp @@ -1387,7 +1387,9 @@ _mesa_get_program_resourceiv(struct gl_shader_program *shProg, static bool validate_io(struct gl_shader_program *producer, - struct gl_shader_program *consumer) + struct gl_shader_program *consumer, + gl_shader_stage producer_stage, + gl_shader_stage consumer_stage) { if (producer == consumer) return true; @@ -1465,16 +1467,38 @@ validate_io(struct gl_shader_program *producer, } } } else { + char *consumer_name = consumer_var->name; + + if (producer_stage == MESA_SHADER_VERTEX && + (consumer_stage == MESA_SHADER_GEOMETRY || + consumer_stage == MESA_SHADER_TESS_CTRL || + consumer_stage == MESA_SHADER_TESS_EVAL) && + consumer_var->interface_type != NULL && + consumer_var->interface_type->is_array() && + !is_gl_identifier(consumer_var->name)) { + consumer_name = strdup(consumer_var->name); + + char *s = strchr(consumer_name, '['); + char *t = strchr(s, ']'); + assert(t[1] == '.'); + + strcpy(s, t + 2); + } + for (unsigned j = 0; j < num_outputs; j++) { const gl_shader_variable *const var = outputs[j]; if (!var->explicit_location && - strcmp(consumer_var->name, var->name) == 0) { + strcmp(consumer_name, var->name) == 0) { producer_var = var; match_index = j; break; } } + + if (consumer_name != consumer_var->name) { + free(consumer_name); + } } /* Section 7.4.1 (Shader Interface Matching) of the OpenGL ES 3.1 spec @@ -1581,7 +1605,9 @@ _mesa_validate_pipeline_io(struct gl_pipeline_object *pipeline) if (shProg[idx]->_LinkedShaders[idx]->Stage == MESA_SHADER_COMPUTE) break; - if (!validate_io(shProg[prev], shProg[idx])) + if (!validate_io(shProg[prev], shProg[idx], + shProg[prev]->_LinkedShaders[prev]->Stage, + shProg[idx]->_LinkedShaders[idx]->Stage)) return false; prev = idx; -- 2.5.5