mesa/st/nir: fix driver_location for arrays of image/sampler
authorRob Clark <robdclark@gmail.com>
Mon, 11 Jun 2018 18:49:12 +0000 (14:49 -0400)
committerRob Clark <robdclark@gmail.com>
Tue, 19 Jun 2018 17:02:28 +0000 (13:02 -0400)
We can have arrays of images or samplers.  But I forgot to handle that
case long ago.  Suprised no one complained yet.

Signed-off-by: Rob Clark <robdclark@gmail.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/mesa/state_tracker/st_glsl_to_nir.cpp

index c8c2ef6cffda26be7f44d1f567bccb781707a58b..3fc04c7b8b70547f58d644bd541b1da196f3c719 100644 (file)
@@ -272,12 +272,15 @@ st_nir_assign_uniform_locations(struct gl_context *ctx,
           uniform->interface_type != NULL)
          continue;
 
-      if (!uniform->data.bindless &&
-          (uniform->type->is_sampler() || uniform->type->is_image())) {
-         if (uniform->type->is_sampler())
-            loc = shaderidx++;
-         else
-            loc = imageidx++;
+      const struct glsl_type *type = glsl_without_array(uniform->type);
+      if (!uniform->data.bindless && (type->is_sampler() || type->is_image())) {
+         if (type->is_sampler()) {
+            loc = shaderidx;
+            shaderidx += type_size(uniform->type);
+         } else {
+            loc = imageidx;
+            imageidx += type_size(uniform->type);
+         }
       } else if (strncmp(uniform->name, "gl_", 3) == 0) {
          const gl_state_index16 *const stateTokens = uniform->state_slots[0].tokens;
          /* This state reference has already been setup by ir_to_mesa, but we'll
@@ -285,7 +288,6 @@ st_nir_assign_uniform_locations(struct gl_context *ctx,
           */
 
          unsigned comps;
-         const struct glsl_type *type = glsl_without_array(uniform->type);
          if (glsl_type_is_struct(type)) {
             comps = 4;
          } else {