[Mesa-dev] [PATCH 2/3] st/glsl_to_nir: fix driver location for packed doubles

Timothy Arceri tarceri at itsqueeze.com
Wed Mar 21 03:50:08 UTC 2018


---
 src/mesa/state_tracker/st_glsl_to_nir.cpp | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index afb6120d9d..b01be622f7 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -141,16 +141,23 @@ st_nir_assign_var_locations(struct exec_list *var_list, unsigned *size,
          type = glsl_get_array_element(type);
       }
 
+      unsigned var_size = type_size(type);
+
       /* Builtins don't allow component packing so we only need to worry about
        * user defined varyings sharing the same location.
        */
       bool processed = false;
       if (var->data.location >= base) {
          unsigned glsl_location = var->data.location - base;
-         if (processed_locs[var->data.index] & ((uint64_t)1 << glsl_location))
-            processed = true;
-         else
-            processed_locs[var->data.index] |= ((uint64_t)1 << glsl_location);
+
+         for (unsigned i = 0; i < var_size; i++) {
+            if (processed_locs[var->data.index] &
+                ((uint64_t)1 << (glsl_location + i)))
+               processed = true;
+            else
+               processed_locs[var->data.index] |=
+                  ((uint64_t)1 << (glsl_location + i));
+         }
       }
 
       /* Because component packing allows varyings to share the same location
@@ -162,9 +169,12 @@ st_nir_assign_var_locations(struct exec_list *var_list, unsigned *size,
          continue;
       }
 
-      assigned_locations[var->data.location] = location;
+      for (unsigned i = 0; i < var_size; i++) {
+         assigned_locations[var->data.location + i] = location + i;
+      }
+
       var->data.driver_location = location;
-      location += type_size(type);
+      location += var_size;
    }
 
    *size += location;
-- 
2.14.3



More information about the mesa-dev mailing list