i965/vs: Fix matNxM vertex attributes where M != 4.
authorKenneth Graunke <kenneth@whitecape.org>
Thu, 2 Jul 2015 03:13:00 +0000 (20:13 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Tue, 7 Jul 2015 23:44:22 +0000 (16:44 -0700)
Matrix vertex attributes have their columns padded out to vec4s, which
I was failing to account for.  Scalar NIR expects them to be packed,
however.

Fixes 1256 dEQP tests on Broadwell.

Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Tested-by: Mark Janes <mark.a.janes@intel.com>
Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
src/mesa/drivers/dri/i965/brw_fs_nir.cpp

index e01dfa88d521340eb486d2c2dbe3398b1a1ca61f..5d1ea21884a38cefe830fce9073fd991b61ffd2f 100644 (file)
@@ -91,12 +91,19 @@ fs_visitor::nir_setup_inputs(nir_shader *shader)
           * So, we need to copy from fs_reg(ATTR, var->location) to
           * offset(nir_inputs, var->data.driver_location).
           */
-         unsigned components = var->type->without_array()->components();
+         const glsl_type *const t = var->type->without_array();
+         const unsigned components = t->components();
+         const unsigned cols = t->matrix_columns;
+         const unsigned elts = t->vector_elements;
          unsigned array_length = var->type->is_array() ? var->type->length : 1;
          for (unsigned i = 0; i < array_length; i++) {
-            for (unsigned j = 0; j < components; j++) {
-               bld.MOV(retype(offset(input, bld, components * i + j), type),
-                       offset(fs_reg(ATTR, var->data.location + i, type), bld, j));
+            for (unsigned j = 0; j < cols; j++) {
+               for (unsigned k = 0; k < elts; k++) {
+                  bld.MOV(offset(retype(input, type), bld,
+                                 components * i + elts * j + k),
+                          offset(fs_reg(ATTR, var->data.location + i, type),
+                                 bld, 4 * j + k));
+               }
             }
          }
          break;