linker: Use the matrix layout information in ir_variable and glsl_type for UBO layout
authorIan Romanick <ian.d.romanick@intel.com>
Fri, 18 Jul 2014 19:18:21 +0000 (12:18 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Mon, 4 Aug 2014 21:40:07 +0000 (14:40 -0700)
Use the data that is stored in the ir_variable and the glsl_type to
determine whether or not a UBO member is row-major.

Fixes gles3conform failures in:

ES3-CTS.shaders.uniform_block.instance_array_basic_type.shared.row_major_mat2
ES3-CTS.shaders.uniform_block.instance_array_basic_type.shared.row_major_mat3
ES3-CTS.shaders.uniform_block.instance_array_basic_type.shared.row_major_mat4
ES3-CTS.shaders.uniform_block.instance_array_basic_type.shared.row_major_mat2x3
ES3-CTS.shaders.uniform_block.instance_array_basic_type.shared.row_major_mat2x4
ES3-CTS.shaders.uniform_block.instance_array_basic_type.shared.row_major_mat3x2
ES3-CTS.shaders.uniform_block.instance_array_basic_type.shared.row_major_mat3x4
ES3-CTS.shaders.uniform_block.instance_array_basic_type.shared.row_major_mat4x2
ES3-CTS.shaders.uniform_block.instance_array_basic_type.shared.row_major_mat4x3
ES3-CTS.shaders.uniform_block.instance_array_basic_type.packed.row_major_mat2
ES3-CTS.shaders.uniform_block.instance_array_basic_type.packed.row_major_mat3
ES3-CTS.shaders.uniform_block.instance_array_basic_type.packed.row_major_mat4
ES3-CTS.shaders.uniform_block.instance_array_basic_type.packed.row_major_mat2x3
ES3-CTS.shaders.uniform_block.instance_array_basic_type.packed.row_major_mat2x4
ES3-CTS.shaders.uniform_block.instance_array_basic_type.packed.row_major_mat3x2
ES3-CTS.shaders.uniform_block.instance_array_basic_type.packed.row_major_mat3x4
ES3-CTS.shaders.uniform_block.instance_array_basic_type.packed.row_major_mat4x2
ES3-CTS.shaders.uniform_block.instance_array_basic_type.packed.row_major_mat4x3
ES3-CTS.shaders.uniform_block.instance_array_basic_type.std140.row_major_mat2
ES3-CTS.shaders.uniform_block.instance_array_basic_type.std140.row_major_mat3
ES3-CTS.shaders.uniform_block.instance_array_basic_type.std140.row_major_mat4
ES3-CTS.shaders.uniform_block.instance_array_basic_type.std140.row_major_mat2x3
ES3-CTS.shaders.uniform_block.instance_array_basic_type.std140.row_major_mat2x4
ES3-CTS.shaders.uniform_block.instance_array_basic_type.std140.row_major_mat3x2
ES3-CTS.shaders.uniform_block.instance_array_basic_type.std140.row_major_mat3x4
ES3-CTS.shaders.uniform_block.instance_array_basic_type.std140.row_major_mat4x2
ES3-CTS.shaders.uniform_block.instance_array_basic_type.std140.row_major_mat4x3
ES3-CTS.shaders.uniform_block.random.nested_structs_arrays.2
ES3-CTS.shaders.uniform_block.random.nested_structs_instance_arrays.5
ES3-CTS.shaders.uniform_block.random.nested_structs_instance_arrays.9

Causes gles3conform failures in:

ES3-CTS.shaders.uniform_block.random.basic_types.8
ES3-CTS.shaders.uniform_block.random.basic_arrays.3
ES3-CTS.shaders.uniform_block.random.basic_instance_arrays.0
ES3-CTS.shaders.uniform_block.random.basic_instance_arrays.2
ES3-CTS.shaders.uniform_block.random.all_per_block_buffers.13
ES3-CTS.shaders.uniform_block.random.all_per_block_buffers.18
ES3-CTS.shaders.uniform_block.random.all_shared_buffer.4

These failures will be fixed shortly.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
src/glsl/link_uniforms.cpp

index ecd414b8ceb41c2b946bf56956f38af54e1372b8..3251097bc304c9a3bf962b06db01bffac0a0543c 100644 (file)
@@ -445,7 +445,6 @@ public:
           */
          if (var->is_interface_instance()) {
             ubo_byte_offset = 0;
-            ubo_row_major = false;
          } else {
             const struct gl_uniform_block *const block =
                &prog->UniformBlocks[ubo_block_index];
@@ -455,7 +454,6 @@ public:
             const struct gl_uniform_buffer_variable *const ubo_var =
                &block->Uniforms[var->data.location];
 
-            ubo_row_major = ubo_var->RowMajor;
             ubo_byte_offset = ubo_var->Offset;
          }
 
@@ -470,7 +468,6 @@ public:
 
    int ubo_block_index;
    int ubo_byte_offset;
-   bool ubo_row_major;
    gl_shader_stage shader_type;
 
 private:
@@ -536,8 +533,6 @@ private:
       assert(!type->without_array()->is_record());
       assert(!type->without_array()->is_interface());
 
-      (void) row_major;
-
       unsigned id;
       bool found = this->map->get(id, name);
       assert(found);
@@ -594,25 +589,25 @@ private:
         this->uniforms[id].block_index = this->ubo_block_index;
 
         const unsigned alignment = record_type
-           ? record_type->std140_base_alignment(ubo_row_major)
-           : type->std140_base_alignment(ubo_row_major);
+           ? record_type->std140_base_alignment(row_major)
+           : type->std140_base_alignment(row_major);
         this->ubo_byte_offset = glsl_align(this->ubo_byte_offset, alignment);
         this->uniforms[id].offset = this->ubo_byte_offset;
-        this->ubo_byte_offset += type->std140_size(ubo_row_major);
+        this->ubo_byte_offset += type->std140_size(row_major);
 
          if (last_field)
             this->ubo_byte_offset = glsl_align(this->ubo_byte_offset, 16);
 
         if (type->is_array()) {
            this->uniforms[id].array_stride =
-              glsl_align(type->fields.array->std140_size(ubo_row_major), 16);
+              glsl_align(type->fields.array->std140_size(row_major), 16);
         } else {
            this->uniforms[id].array_stride = 0;
         }
 
         if (type->without_array()->is_matrix()) {
            this->uniforms[id].matrix_stride = 16;
-           this->uniforms[id].row_major = ubo_row_major;
+           this->uniforms[id].row_major = row_major;
         } else {
            this->uniforms[id].matrix_stride = 0;
            this->uniforms[id].row_major = false;