zink: handle bitsizes in get_bo_vars() analysis
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Sun, 26 Jun 2022 13:06:26 +0000 (09:06 -0400)
committerMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Tue, 5 Jul 2022 20:01:01 +0000 (16:01 -0400)
this allows it to be run repeatedly

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17239>

src/gallium/drivers/zink/zink_compiler.c

index 9ab94ef..8427ba4 100644 (file)
@@ -485,16 +485,17 @@ get_bo_vars(struct zink_shader *zs, nir_shader *shader)
       bo.first_ssbo = ffs(zs->ssbos_used) - 1;
    assert(bo.first_ssbo < PIPE_MAX_SHADER_BUFFERS);
    nir_foreach_variable_with_modes(var, shader, nir_var_mem_ssbo | nir_var_mem_ubo) {
+      unsigned idx = glsl_get_explicit_stride(glsl_get_struct_field(glsl_without_array(var->type), 0)) >> 1;
       if (var->data.mode == nir_var_mem_ssbo) {
-         assert(!bo.ssbo[32 >> 4]);
-         bo.ssbo[32 >> 4] = var;
+         assert(!bo.ssbo[idx]);
+         bo.ssbo[idx] = var;
       } else {
          if (var->data.driver_location) {
-            assert(!bo.ubo[32 >> 4]);
-            bo.ubo[32 >> 4] = var;
+            assert(!bo.ubo[idx]);
+            bo.ubo[idx] = var;
          } else {
-            assert(!bo.uniforms[32 >> 4]);
-            bo.uniforms[32 >> 4] = var;
+            assert(!bo.uniforms[idx]);
+            bo.uniforms[idx] = var;
          }
       }
    }