zink: unref programs last in batch reset
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Sun, 4 Oct 2020 14:19:28 +0000 (10:19 -0400)
committerMarge Bot <eric+marge@anholt.net>
Thu, 25 Feb 2021 04:52:42 +0000 (04:52 +0000)
we're going to want to make sure all other resources have been handled
at this point so that we can make some better decisions in this block
based on descriptor usage

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

src/gallium/drivers/zink/zink_batch.c

index ef69074..40764fb 100644 (file)
@@ -25,16 +25,6 @@ zink_reset_batch(struct zink_context *ctx, struct zink_batch *batch)
       zink_fence_finish(screen, &ctx->base, batch->fence, PIPE_TIMEOUT_INFINITE);
 
    zink_framebuffer_reference(screen, &batch->fb, NULL);
-   set_foreach(batch->programs, entry) {
-      if (batch->batch_id == ZINK_COMPUTE_BATCH_ID) {
-         struct zink_compute_program *comp = (struct zink_compute_program*)entry->key;
-         zink_compute_program_reference(screen, &comp, NULL);
-      } else {
-         struct zink_gfx_program *prog = (struct zink_gfx_program*)entry->key;
-         zink_gfx_program_reference(screen, &prog, NULL);
-      }
-   }
-   _mesa_set_clear(batch->programs, NULL);
 
    /* unref all used resources */
    set_foreach(batch->resources, entry) {
@@ -62,6 +52,17 @@ zink_reset_batch(struct zink_context *ctx, struct zink_batch *batch)
    util_dynarray_clear(&batch->zombie_samplers);
    util_dynarray_clear(&batch->persistent_resources);
 
+   set_foreach(batch->programs, entry) {
+      if (batch->batch_id == ZINK_COMPUTE_BATCH_ID) {
+         struct zink_compute_program *comp = (struct zink_compute_program*)entry->key;
+         zink_compute_program_reference(screen, &comp, NULL);
+      } else {
+         struct zink_gfx_program *prog = (struct zink_gfx_program*)entry->key;
+         zink_gfx_program_reference(screen, &prog, NULL);
+      }
+   }
+   _mesa_set_clear(batch->programs, NULL);
+
    if (vkResetDescriptorPool(screen->dev, batch->descpool, 0) != VK_SUCCESS)
       fprintf(stderr, "vkResetDescriptorPool failed\n");