dzn: Only bind descriptor sets up to the used amount of the current layout
authorJesse Natalie <jenatali@microsoft.com>
Thu, 23 Mar 2023 15:33:18 +0000 (08:33 -0700)
committerMarge Bot <emma+marge@anholt.net>
Thu, 23 Mar 2023 21:48:44 +0000 (21:48 +0000)
Prevents setting a root SRV into a slot that's not declared as an SRV
in the root signature if a set is bound into a higher slot from a previous
draw/dispatch op.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21913>

src/microsoft/vulkan/dzn_cmd_buffer.c

index 0da6172..3ee1c91 100644 (file)
@@ -3106,7 +3106,7 @@ dzn_cmd_buffer_update_heaps(struct dzn_cmd_buffer *cmdbuf, uint32_t bindpoint)
          new_heap_offsets[type] = dst_heap_offset;
          update_root_desc_table[type] = true;
 
-         for (uint32_t s = 0; s < MAX_SETS; s++) {
+         for (uint32_t s = 0; s < cmdbuf->state.pipeline->root.sets_param_count; s++) {
             const struct dzn_descriptor_set *set = desc_state->sets[s].set;
             if (!set) continue;
 
@@ -3175,7 +3175,7 @@ dzn_cmd_buffer_update_heaps(struct dzn_cmd_buffer *cmdbuf, uint32_t bindpoint)
    }
 
    if (device->bindless) {
-      for (uint32_t s = 0; s < MAX_SETS; ++s) {
+      for (uint32_t s = 0; s < pipeline->root.sets_param_count; ++s) {
          const struct dzn_descriptor_set *set = desc_state->sets[s].set;
          if (!set || !set->pool->bindless.buf)
             continue;