[Mesa-dev] [PATCH 2/2] mesa: fix interface matching done in validate_io

Tapani Pälli tapani.palli at intel.com
Tue Dec 8 23:48:58 PST 2015


Patch makes following changes for interface matching:

   - do not try to match builtin variables
   - handle swizzle in input name, as example 'a.z' should
     match with 'a'
   - check that amount of inputs and outputs matches

These changes make interface matching tests to work in:
   ES31-CTS.sepshaderobjs.StateInteraction

Test does not still pass completely due to errors in rendering
output. I believe this is unrelated to interface matching.

Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
---
 src/mesa/main/shader_query.cpp | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp
index 5d15006..8bfbd3f 100644
--- a/src/mesa/main/shader_query.cpp
+++ b/src/mesa/main/shader_query.cpp
@@ -1372,19 +1372,34 @@ validate_io(const struct gl_shader *input_stage,
             const struct gl_shader *output_stage, bool isES)
 {
    assert(input_stage && output_stage);
+   unsigned inputs = 0, outputs = 0;
 
    /* For each output in a, find input in b and do any required checks. */
    foreach_in_list(ir_instruction, out, input_stage->ir) {
       ir_variable *out_var = out->as_variable();
-      if (!out_var || out_var->data.mode != ir_var_shader_out)
+      if (!out_var || out_var->data.mode != ir_var_shader_out ||
+          is_gl_identifier(out_var->name))
          continue;
 
+      outputs++;
+
+      inputs = 0;
       foreach_in_list(ir_instruction, in, output_stage->ir) {
          ir_variable *in_var = in->as_variable();
-         if (!in_var || in_var->data.mode != ir_var_shader_in)
+         if (!in_var || in_var->data.mode != ir_var_shader_in ||
+             is_gl_identifier(in_var->name))
             continue;
 
-         if (strcmp(in_var->name, out_var->name) == 0) {
+         inputs++;
+
+         unsigned len = strlen(in_var->name);
+
+         /* Handle input swizzle in variable name. */
+         const char *dot = strchr(in_var->name, '.');
+         if (dot)
+            len = dot - in_var->name;
+
+         if (strncmp(in_var->name, out_var->name, len) == 0) {
             /* Since we now only validate precision, we can skip this step for
              * desktop GLSL shaders, there precision qualifier is ignored.
              *
@@ -1407,7 +1422,9 @@ validate_io(const struct gl_shader *input_stage,
          }
       }
    }
-   return true;
+
+   /* Amount should match. */
+   return (inputs == outputs);
 }
 
 /**
-- 
2.5.0



More information about the mesa-dev mailing list