glsl: Use the without_array predicate to simplify some code
authorIan Romanick <ian.d.romanick@intel.com>
Sat, 19 Jul 2014 21:41:04 +0000 (14:41 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Mon, 4 Aug 2014 21:40:06 +0000 (14:40 -0700)
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com> [v1]
Reviewed-by: Timothy Arceri <t_arceri@yahoo.com.au>
src/glsl/ast_to_hir.cpp
src/glsl/glsl_types.cpp
src/glsl/link_uniforms.cpp
src/glsl/link_varyings.cpp

index 7249a06c928fcfa36c80e8c3c7aca004e0ab7829..397a575501db2867b3017426849305f2049ead95 100644 (file)
@@ -5203,8 +5203,7 @@ ast_process_structure_or_interface_block(exec_list *instructions,
                              "in uniform blocks or structures.");
          }
 
-         if (field_type->is_matrix() ||
-             (field_type->is_array() && field_type->fields.array->is_matrix())) {
+         if (field_type->without_array()->is_matrix()) {
             fields[i].row_major = block_row_major;
             if (qual->flags.q.row_major)
                fields[i].row_major = true;
index f9cd258fefa06b74f244cce16f527e0b9ae81b08..737e6dd04226b6c379fd61f9ae618dbf84d0c279 100644 (file)
@@ -872,8 +872,7 @@ glsl_type::std140_size(bool row_major) const
     *     and <R> rows, the matrix is stored identically to a row of <S>*<R>
     *     row vectors with <C> components each, according to rule (4).
     */
-   if (this->is_matrix() || (this->is_array() &&
-                            this->fields.array->is_matrix())) {
+   if (this->without_array()->is_matrix()) {
       const struct glsl_type *element_type;
       const struct glsl_type *vec_type;
       unsigned int array_len;
index 6c731976b74f1d8d1cf8fae6742d445cb808ce47..74895362c7d1fa4fe6e6ffd0c25321f5c0071d4d 100644 (file)
@@ -59,10 +59,8 @@ values_for_type(const glsl_type *type)
 void
 program_resource_visitor::process(const glsl_type *type, const char *name)
 {
-   assert(type->is_record()
-          || (type->is_array() && type->fields.array->is_record())
-          || type->is_interface()
-          || (type->is_array() && type->fields.array->is_interface()));
+   assert(type->without_array()->is_record()
+          || type->without_array()->is_interface());
 
    char *name_copy = ralloc_strdup(NULL, name);
    recursion(type, &name_copy, strlen(name), false, NULL);
@@ -136,7 +134,7 @@ program_resource_visitor::process(ir_variable *var)
        */
       recursion(var->type, &name, strlen(name), false, NULL);
       ralloc_free(name);
-   } else if (t->is_record() || (t->is_array() && t->fields.array->is_record())) {
+   } else if (t->without_array()->is_record()) {
       char *name = ralloc_strdup(NULL, var->name);
       recursion(var->type, &name, strlen(name), false, NULL);
       ralloc_free(name);
@@ -299,10 +297,8 @@ private:
    virtual void visit_field(const glsl_type *type, const char *name,
                             bool row_major)
    {
-      assert(!type->is_record());
-      assert(!(type->is_array() && type->fields.array->is_record()));
-      assert(!type->is_interface());
-      assert(!(type->is_array() && type->fields.array->is_interface()));
+      assert(!type->without_array()->is_record());
+      assert(!type->without_array()->is_interface());
 
       (void) row_major;
 
@@ -514,10 +510,8 @@ private:
    virtual void visit_field(const glsl_type *type, const char *name,
                             bool row_major, const glsl_type *record_type)
    {
-      assert(!type->is_record());
-      assert(!(type->is_array() && type->fields.array->is_record()));
-      assert(!type->is_interface());
-      assert(!(type->is_array() && type->fields.array->is_interface()));
+      assert(!type->without_array()->is_record());
+      assert(!type->without_array()->is_interface());
 
       (void) row_major;
 
@@ -590,8 +584,7 @@ private:
            this->uniforms[id].array_stride = 0;
         }
 
-        if (type->is_matrix() ||
-            (type->is_array() && type->fields.array->is_matrix())) {
+        if (type->without_array()->is_matrix()) {
            this->uniforms[id].matrix_stride = 16;
            this->uniforms[id].row_major = ubo_row_major;
         } else {
index a3fc2ae3489ce7d3545af755d0a106bfcc8ce0d1..1438a4b16c29c42a7183152fa2f6e455dc1f8afa 100644 (file)
@@ -1068,10 +1068,8 @@ private:
    virtual void visit_field(const glsl_type *type, const char *name,
                             bool row_major)
    {
-      assert(!type->is_record());
-      assert(!(type->is_array() && type->fields.array->is_record()));
-      assert(!type->is_interface());
-      assert(!(type->is_array() && type->fields.array->is_interface()));
+      assert(!type->without_array()->is_record());
+      assert(!type->without_array()->is_interface());
 
       (void) row_major;