diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c index 9ae327a5ca8..c6f90d9a33b 100644 --- a/src/amd/vulkan/radv_cmd_buffer.c +++ b/src/amd/vulkan/radv_cmd_buffer.c @@ -4207,7 +4207,7 @@ lookup_ps_epilog(struct radv_cmd_buffer *cmd_buffer) return epilog_entry->data; } - epilog = radv_create_ps_epilog(device, &key); + epilog = radv_create_ps_epilog(device, &key, NULL); struct radv_ps_epilog_key *key2 = malloc(sizeof(*key2)); if (!epilog || !key2) { radv_shader_part_unref(device, epilog); diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c index 537705fdda8..8616a135092 100644 --- a/src/amd/vulkan/radv_pipeline.c +++ b/src/amd/vulkan/radv_pipeline.c @@ -3220,7 +3220,8 @@ static bool radv_pipeline_create_ps_epilog(struct radv_graphics_pipeline *pipeline, const struct radv_pipeline_key *pipeline_key, VkGraphicsPipelineLibraryFlagBitsEXT lib_flags, - bool noop_fs) + bool noop_fs, + struct radv_shader_part_binary **ps_epilog_binary) { struct radv_device *device = pipeline->base.device; bool needs_ps_epilog = false; @@ -3241,7 +3242,8 @@ radv_pipeline_create_ps_epilog(struct radv_graphics_pipeline *pipeline, } if (needs_ps_epilog) { - pipeline->ps_epilog = radv_create_ps_epilog(device, &pipeline_key->ps.epilog); + pipeline->ps_epilog = + radv_create_ps_epilog(device, &pipeline_key->ps.epilog, ps_epilog_binary); if (!pipeline->ps_epilog) return false; } @@ -3351,6 +3353,7 @@ radv_graphics_pipeline_compile(struct radv_graphics_pipeline *pipeline, const char *noop_fs_entrypoint = "noop_fs"; struct radv_shader_binary *binaries[MESA_VULKAN_SHADER_STAGES] = {NULL}; struct radv_shader_binary *gs_copy_binary = NULL; + struct radv_shader_part_binary *ps_epilog_binary = NULL; unsigned char hash[20]; bool keep_executable_info = radv_pipeline_capture_shaders(pipeline->base.device, pCreateInfo->flags); @@ -3413,7 +3416,7 @@ radv_graphics_pipeline_compile(struct radv_graphics_pipeline *pipeline, pipeline_feedback.flags |= VK_PIPELINE_CREATION_FEEDBACK_APPLICATION_PIPELINE_CACHE_HIT_BIT; /* TODO: Add PS epilogs to the cache. */ - if (!radv_pipeline_create_ps_epilog(pipeline, pipeline_key, lib_flags, noop_fs)) + if (!radv_pipeline_create_ps_epilog(pipeline, pipeline_key, lib_flags, noop_fs, NULL)) return VK_ERROR_OUT_OF_DEVICE_MEMORY; result = VK_SUCCESS; @@ -3501,7 +3504,8 @@ radv_graphics_pipeline_compile(struct radv_graphics_pipeline *pipeline, radv_pipeline_nir_to_asm(pipeline, stages, pipeline_key, pipeline_layout, keep_executable_info, keep_statistic_info, active_nir_stages, binaries, &gs_copy_binary); - if (!radv_pipeline_create_ps_epilog(pipeline, pipeline_key, lib_flags, noop_fs)) + if (!radv_pipeline_create_ps_epilog(pipeline, pipeline_key, lib_flags, noop_fs, + &ps_epilog_binary)) return VK_ERROR_OUT_OF_DEVICE_MEMORY; if (keep_executable_info) { @@ -3546,6 +3550,7 @@ radv_graphics_pipeline_compile(struct radv_graphics_pipeline *pipeline, } free(gs_copy_binary); + free(ps_epilog_binary); for (int i = 0; i < MESA_VULKAN_SHADER_STAGES; ++i) { free(binaries[i]); if (stages[i].nir) { diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c index 97239b3c8e4..2a957138d08 100644 --- a/src/amd/vulkan/radv_shader.c +++ b/src/amd/vulkan/radv_shader.c @@ -2944,7 +2944,8 @@ fail: } struct radv_shader_part * -radv_create_ps_epilog(struct radv_device *device, const struct radv_ps_epilog_key *key) +radv_create_ps_epilog(struct radv_device *device, const struct radv_ps_epilog_key *key, + struct radv_shader_part_binary **binary_out) { struct radv_shader_part *epilog; struct radv_shader_args args = {0}; @@ -2985,7 +2986,11 @@ radv_create_ps_epilog(struct radv_device *device, const struct radv_ps_epilog_ke fprintf(stderr, "\ndisasm:\n%s\n", epilog->disasm_string); } - free(binary); + if (binary_out) { + *binary_out = binary; + } else { + free(binary); + } return epilog; diff --git a/src/amd/vulkan/radv_shader.h b/src/amd/vulkan/radv_shader.h index 8bfdd02d5f7..52a3b2ded74 100644 --- a/src/amd/vulkan/radv_shader.h +++ b/src/amd/vulkan/radv_shader.h @@ -623,7 +623,8 @@ struct radv_shader_part *radv_create_vs_prolog(struct radv_device *device, const struct radv_vs_prolog_key *key); struct radv_shader_part *radv_create_ps_epilog(struct radv_device *device, - const struct radv_ps_epilog_key *key); + const struct radv_ps_epilog_key *key, + struct radv_shader_part_binary **binary_out); void radv_shader_destroy(struct radv_device *device, struct radv_shader *shader);