glsl: fix subroutine uniform .length().
authorDave Airlie <airlied@redhat.com>
Tue, 17 May 2016 03:07:40 +0000 (13:07 +1000)
committerDave Airlie <airlied@redhat.com>
Mon, 23 May 2016 06:19:57 +0000 (16:19 +1000)
This fixes .length() on subroutine uniform arrays, if
we don't find the identifier normally, we look up the corresponding
subroutine identifier instead.

Fixes:
GL45-CTS.shader_subroutine.arrays_of_arrays_of_uniforms
GL45-CTS.shader_subroutine.arrayed_subroutine_uniforms

Reviewed-by: Chris Forbes <chrisforbes@google.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
src/compiler/glsl/ast_to_hir.cpp

index 434734d09afeea70ada545363c762c84fb930041..ecd1327e358190d74c45616625b508b4d3c99ad7 100644 (file)
@@ -1917,6 +1917,14 @@ ast_expression::do_hir(exec_list *instructions,
       ir_variable *var =
          state->symbols->get_variable(this->primary_expression.identifier);
 
+      if (var == NULL) {
+         /* the identifier might be a subroutine name */
+         char *sub_name;
+         sub_name = ralloc_asprintf(ctx, "%s_%s", _mesa_shader_stage_to_subroutine_prefix(state->stage), this->primary_expression.identifier);
+         var = state->symbols->get_variable(sub_name);
+         ralloc_free(sub_name);
+      }
+
       if (var != NULL) {
          var->data.used = true;
          result = new(ctx) ir_dereference_variable(var);