radv: only copy non-NULL shaders when loaded from the cache
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 5 Jan 2023 16:58:45 +0000 (17:58 +0100)
committerMarge Bot <emma+marge@anholt.net>
Tue, 4 Apr 2023 14:47:39 +0000 (14:47 +0000)
With GPL, we don't necessarily load all stages from the same cache
entry and other stages might have been imported from libraries, so
don't overwrite them.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22264>

src/amd/vulkan/radv_pipeline_cache.c

index 89b56c0..9980a4b 100644 (file)
@@ -382,7 +382,12 @@ radv_create_shaders_from_pipeline_cache(struct radv_device *device,
       }
    }
 
-   memcpy(pipeline->shaders, entry->shaders, sizeof(entry->shaders));
+   for (int i = 0; i < MESA_VULKAN_SHADER_STAGES; i++) {
+      if (!entry->shaders[i])
+         continue;
+
+      pipeline->shaders[i] = entry->shaders[i];
+   }
 
    if (pipeline->shaders[MESA_SHADER_GEOMETRY] &&
        !pipeline->shaders[MESA_SHADER_GEOMETRY]->info.is_ngg) {