radv: copy the spirv module for debugging after compilation
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 6 Apr 2022 10:34:46 +0000 (12:34 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 8 Apr 2022 07:50:20 +0000 (09:50 +0200)
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15766>

src/amd/vulkan/radv_pipeline.c
src/amd/vulkan/radv_shader.c

index 5831286..cd7f017 100644 (file)
@@ -4497,6 +4497,21 @@ radv_create_shaders(struct radv_pipeline *pipeline, struct radv_pipeline_layout
       }
    }
 
+   if (keep_executable_info) {
+      for (int i = 0; i < MESA_VULKAN_SHADER_STAGES; ++i) {
+         struct radv_shader *shader = pipeline->shaders[i];
+         if (!shader)
+            continue;
+
+         if (!modules[i] || modules[i]->nir)
+            continue;
+
+         shader->spirv = malloc(modules[i]->size);
+         memcpy(shader->spirv, modules[i]->data, modules[i]->size);
+         shader->spirv_size = modules[i]->size;
+      }
+   }
+
    /* Upload shader binaries. */
    radv_upload_shaders(device, pipeline, binaries, gs_copy_binary);
 
index 542f732..17b410c 100644 (file)
@@ -2000,17 +2000,6 @@ shader_compile(struct radv_device *device, struct vk_shader_module *module,
 
    if (keep_shader_info) {
       shader->nir_string = radv_dump_nir_shaders(shaders, shader_count);
-      if (!gs_copy_shader && !trap_handler_shader && !module->nir) {
-         shader->spirv = malloc(module->size);
-         if (!shader->spirv) {
-            free(shader);
-            free(binary);
-            return NULL;
-         }
-
-         memcpy(shader->spirv, module->data, module->size);
-         shader->spirv_size = module->size;
-      }
    }
 
    /* Copy the shader binary configuration to store it in the cache. */