glsl: dont allow gl_PerVertex to be redeclared as an array of arrays
authorTimothy Arceri <t_arceri@yahoo.com.au>
Mon, 23 Jun 2014 21:43:05 +0000 (07:43 +1000)
committerTimothy Arceri <t_arceri@yahoo.com.au>
Thu, 15 Oct 2015 09:36:01 +0000 (20:36 +1100)
V3: move patch after fixes to ast for AoA and add const to helper
as suggested by Ian

V2: move single dimensional array detection into a helper

Signed-off-by: Timothy Arceri <t_arceri@yahoo.com.au>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/glsl/ast.h
src/glsl/ast_to_hir.cpp

index 57d432d4b023ec18a6f41f74f421635da64a9436..e803e6d7675dc9800d85c22bc579798f315d750c 100644 (file)
@@ -336,6 +336,12 @@ public:
       array_dimensions.push_tail(&dim->link);
    }
 
+   const bool is_single_dimension()
+   {
+      return this->array_dimensions.tail_pred->prev != NULL &&
+             this->array_dimensions.tail_pred->prev->is_head_sentinel();
+   }
+
    virtual void print(void) const;
 
    /* This list contains objects of type ast_node containing the
index 7b54eaf439086a49620488cf1b9fd99aedcddcef..db617cb41accd8708c87e1bafd2b4ffca3ae6822 100644 (file)
@@ -6335,7 +6335,8 @@ ast_interface_block::hir(exec_list *instructions,
                              _mesa_shader_stage_to_string(state->stage));
          }
          if (this->instance_name == NULL ||
-             strcmp(this->instance_name, "gl_in") != 0 || this->array_specifier == NULL) {
+             strcmp(this->instance_name, "gl_in") != 0 || this->array_specifier == NULL ||
+             !this->array_specifier->is_single_dimension()) {
             _mesa_glsl_error(&loc, state,
                              "gl_PerVertex input must be redeclared as "
                              "gl_in[]");