Module: Mesa
Branch: staging/22.1
Commit: b946850b1935b4637e4fdc4c0632bf6bbe4d8b7d
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b946850b1935b4637e4fdc4c0632bf6bbe4d8b7d

Author: Mike Blumenkrantz <[email protected]>
Date:   Wed Jul 20 11:44:16 2022 -0400

zink: invoke descriptor_program_deinit for programs on context destroy

this should make multi-context shutdown more stable

affects:
glx@glx-visuals-depth -pixmap
glx@glx-visuals-stencil

cc: mesa-stable

Reviewed-by: Adam Jackson <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17658>
(cherry picked from commit 4123ee3c71461d7d045fec519130128a7fc4e643)

---

 .pick_status.json                                |  2 +-
 src/gallium/drivers/zink/ci/zink-lvp-fails.txt   |  2 --
 src/gallium/drivers/zink/zink_context.c          | 11 +++++++++++
 src/gallium/drivers/zink/zink_descriptors_lazy.c |  3 +++
 4 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 20b8f747430..f7a6e00f750 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -3172,7 +3172,7 @@
         "description": "zink: invoke descriptor_program_deinit for programs on 
context destroy",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": null
     },
diff --git a/src/gallium/drivers/zink/ci/zink-lvp-fails.txt 
b/src/gallium/drivers/zink/ci/zink-lvp-fails.txt
index d65b97c77c2..95f4a872355 100644
--- a/src/gallium/drivers/zink/ci/zink-lvp-fails.txt
+++ b/src/gallium/drivers/zink/ci/zink-lvp-fails.txt
@@ -129,9 +129,7 @@ glx@glx-copy-sub-buffer samples=2,Fail
 glx@glx-copy-sub-buffer samples=4,Fail
 glx@glx-swap-pixmap-bad,Fail
 glx@glx-visuals-depth,Crash
-glx@glx-visuals-depth -pixmap,Crash
 glx@glx-visuals-stencil,Crash
-glx@glx-visuals-stencil -pixmap,Crash
 glx@glx_arb_create_context_es2_profile@invalid opengl es version,Fail
 glx@glx_arb_create_context_no_error@no error,Fail
 glx@glx_ext_import_context@free context,Fail
diff --git a/src/gallium/drivers/zink/zink_context.c 
b/src/gallium/drivers/zink/zink_context.c
index d86d39991ad..304e1439a54 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -99,6 +99,17 @@ zink_context_destroy(struct pipe_context *pctx)
    if (ctx->batch.state && !screen->device_lost && 
VKSCR(QueueWaitIdle)(ctx->batch.state->queue) != VK_SUCCESS)
       mesa_loge("ZINK: vkQueueWaitIdle failed");
 
+   for (unsigned i = 0; i < ARRAY_SIZE(ctx->program_cache); i++) {
+      hash_table_foreach(&ctx->program_cache[i], entry) {
+         struct zink_program *pg = entry->data;
+         screen->descriptor_program_deinit(ctx, pg);
+      }
+   }
+   hash_table_foreach(&ctx->compute_program_cache, entry) {
+      struct zink_program *pg = entry->data;
+      screen->descriptor_program_deinit(ctx, pg);
+   }
+
    if (ctx->blitter)
       util_blitter_destroy(ctx->blitter);
    for (unsigned i = 0; i < ctx->fb_state.nr_cbufs; i++)
diff --git a/src/gallium/drivers/zink/zink_descriptors_lazy.c 
b/src/gallium/drivers/zink/zink_descriptors_lazy.c
index cae24c90929..e039ef28982 100644
--- a/src/gallium/drivers/zink/zink_descriptors_lazy.c
+++ b/src/gallium/drivers/zink/zink_descriptors_lazy.c
@@ -337,6 +337,8 @@ void
 zink_descriptor_program_deinit_lazy(struct zink_context *ctx, struct 
zink_program *pg)
 {
    struct zink_screen *screen = zink_screen(ctx->base.screen);
+   if (!pg->dd)
+      return;
    for (unsigned i = 0; pg->num_dsl && i < ZINK_DESCRIPTOR_TYPES; i++) {
       if (pg->dd->pool_key[i])
          pg->dd->pool_key[i]->use_count--;
@@ -344,6 +346,7 @@ zink_descriptor_program_deinit_lazy(struct zink_context 
*ctx, struct zink_progra
    if (pg->dd && pg->dd->push_template)
       VKSCR(DestroyDescriptorUpdateTemplate)(screen->dev, 
pg->dd->push_template, NULL);
    ralloc_free(pg->dd);
+   pg->dd = NULL;
 }
 
 static VkDescriptorPool

Reply via email to