[Mesa-dev] [PATCH 10/16] glsl: Correctly load columns of a row-major matrix

Ian Romanick idr at freedesktop.org
Mon Jul 21 14:04:26 PDT 2014


From: Ian Romanick <ian.d.romanick at intel.com>

For a row-major matrix, the next column starts at the next element.

Fixes gles3conform failures in:

ES3-CTS.shaders.uniform_block.single_basic_array.shared.row_major_mat2
ES3-CTS.shaders.uniform_block.single_basic_array.shared.row_major_mat3
ES3-CTS.shaders.uniform_block.single_basic_array.shared.row_major_mat4
ES3-CTS.shaders.uniform_block.single_basic_array.shared.row_major_mat2x3
ES3-CTS.shaders.uniform_block.single_basic_array.shared.row_major_mat2x4
ES3-CTS.shaders.uniform_block.single_basic_array.shared.row_major_mat3x2
ES3-CTS.shaders.uniform_block.single_basic_array.shared.row_major_mat3x4
ES3-CTS.shaders.uniform_block.single_basic_array.shared.row_major_mat4x2
ES3-CTS.shaders.uniform_block.single_basic_array.shared.row_major_mat4x3
ES3-CTS.shaders.uniform_block.single_basic_array.packed.row_major_mat2
ES3-CTS.shaders.uniform_block.single_basic_array.packed.row_major_mat3
ES3-CTS.shaders.uniform_block.single_basic_array.packed.row_major_mat4
ES3-CTS.shaders.uniform_block.single_basic_array.packed.row_major_mat2x3
ES3-CTS.shaders.uniform_block.single_basic_array.packed.row_major_mat2x4
ES3-CTS.shaders.uniform_block.single_basic_array.packed.row_major_mat3x2
ES3-CTS.shaders.uniform_block.single_basic_array.packed.row_major_mat3x4
ES3-CTS.shaders.uniform_block.single_basic_array.packed.row_major_mat4x2
ES3-CTS.shaders.uniform_block.single_basic_array.packed.row_major_mat4x3
ES3-CTS.shaders.uniform_block.single_basic_array.std140.row_major_mat2
ES3-CTS.shaders.uniform_block.single_basic_array.std140.row_major_mat3
ES3-CTS.shaders.uniform_block.single_basic_array.std140.row_major_mat4
ES3-CTS.shaders.uniform_block.single_basic_array.std140.row_major_mat2x3
ES3-CTS.shaders.uniform_block.single_basic_array.std140.row_major_mat2x4
ES3-CTS.shaders.uniform_block.single_basic_array.std140.row_major_mat3x2
ES3-CTS.shaders.uniform_block.single_basic_array.std140.row_major_mat3x4
ES3-CTS.shaders.uniform_block.single_basic_array.std140.row_major_mat4x2
ES3-CTS.shaders.uniform_block.single_basic_array.std140.row_major_mat4x3
ES3-CTS.shaders.uniform_block.random.all_per_block_buffers.9

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 src/glsl/lower_ubo_reference.cpp | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/glsl/lower_ubo_reference.cpp b/src/glsl/lower_ubo_reference.cpp
index 514265f..99bfe97 100644
--- a/src/glsl/lower_ubo_reference.cpp
+++ b/src/glsl/lower_ubo_reference.cpp
@@ -333,10 +333,17 @@ lower_ubo_reference_visitor::emit_ubo_loads(ir_dereference *deref,
 	    new(mem_ctx) ir_dereference_array(deref->clone(mem_ctx, NULL),
 					      col);
 
-	 /* std140 always rounds the stride of arrays (and matrices)
-	  * to a vec4, so matrices are always 16 between columns/rows.
-	  */
-	 emit_ubo_loads(col_deref, base_offset, deref_offset + i * 16);
+         if (ubo_var->RowMajor) {
+            /* For a row-major matrix, the next column starts at the next
+             * element.
+             */
+            emit_ubo_loads(col_deref, base_offset, deref_offset + i * 4);
+         } else {
+            /* std140 always rounds the stride of arrays (and matrices) to a
+             * vec4, so matrices are always 16 between columns/rows.
+             */
+            emit_ubo_loads(col_deref, base_offset, deref_offset + i * 16);
+         }
       }
       return;
    }
-- 
1.8.1.4



More information about the mesa-dev mailing list