radv: allow to return the PS epilog binary to the pipeline

To add it to the shaders cache.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21897>
This commit is contained in:
Samuel Pitoiset
2023-03-10 16:04:57 +01:00
committed by Marge Bot
parent eba315d2bf
commit 83c20b95dd
4 changed files with 19 additions and 8 deletions

View File

@@ -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);

View File

@@ -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) {

View File

@@ -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);
}
if (binary_out) {
*binary_out = binary;
} else {
free(binary);
}
return epilog;

View File

@@ -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);