zink: sync LTO compiles for GPL pipelines on shader free
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Fri, 10 Feb 2023 14:01:48 +0000 (09:01 -0500)
committerMarge Bot <emma+marge@anholt.net>
Mon, 13 Feb 2023 10:27:16 +0000 (10:27 +0000)
this avoids invalid access

affects:
KHR-Single-GL46.arrays_of_arrays_gl.InteractionStorageBuffers2

Fixes: 41ffb15de56 ("zink: implement async gfx precompile")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21246>

src/gallium/drivers/zink/zink_compiler.c

index 73b87f1..15db3e8 100644 (file)
@@ -4502,6 +4502,16 @@ zink_shader_free(struct zink_screen *screen, struct zink_shader *shader)
          simple_mtx_unlock(&prog->ctx->program_lock[idx]);
          util_queue_fence_wait(&prog->base.cache_fence);
 
+         for (unsigned r = 0; r < ARRAY_SIZE(prog->pipelines); r++) {
+            for (int i = 0; i < ARRAY_SIZE(prog->pipelines[0]); ++i) {
+               hash_table_foreach(&prog->pipelines[r][i], entry) {
+                  struct zink_gfx_pipeline_cache_entry *pc_entry = entry->data;
+
+                  util_queue_fence_wait(&pc_entry->fence);
+               }
+            }
+         }
+
          while (util_dynarray_contains(&shader->pipeline_libs, struct zink_gfx_lib_cache*)) {
             struct zink_gfx_lib_cache *libs = util_dynarray_pop(&shader->pipeline_libs, struct zink_gfx_lib_cache*);
             if (!libs->removed) {