zink: fix pool overflow handling on batch reset
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Wed, 12 Oct 2022 15:51:14 +0000 (11:51 -0400)
committerMarge Bot <emma+marge@anholt.net>
Thu, 13 Oct 2022 03:02:59 +0000 (03:02 +0000)
this mechanism worked off the previous iteration of descriptor updating,
in which pools were stored in a set to the batch state and could be iterated
normally

now, however, they're stored as a sparse array, and so the dynarray util for getting
the number of elements cannot be used

instead, use the calculated size for the array like every other accessor for
the pools to ensure correct indexing

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

src/gallium/drivers/zink/zink_descriptors.c

index 5ac4df5..1d3aaa5 100644 (file)
@@ -994,8 +994,7 @@ zink_batch_descriptor_reset(struct zink_screen *screen, struct zink_batch_state
 {
    for (unsigned i = 0; i < ZINK_DESCRIPTOR_TYPES; i++) {
       struct zink_descriptor_pool_multi **mpools = bs->dd.pools[i].data;
-      unsigned count = util_dynarray_num_elements(&bs->dd.pools[i], struct zink_descriptor_pool_multi *);
-      for (unsigned j = 0; j < count; j++) {
+      for (unsigned j = 0; j < bs->dd.pool_size[i]; j++) {
          struct zink_descriptor_pool_multi *mpool = mpools[j];
          if (!mpool)
             continue;