radv: use radv_pipeline::sha1 for graphics/compute pipelines

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28829>
This commit is contained in:
Samuel Pitoiset 2024-04-19 14:02:16 +02:00 committed by Marge Bot
parent 6e24da3ad4
commit bbe52934b6
4 changed files with 15 additions and 20 deletions

View file

@ -312,7 +312,7 @@ const struct vk_pipeline_cache_object_ops radv_pipeline_ops = {
bool
radv_pipeline_cache_search(struct radv_device *device, struct vk_pipeline_cache *cache, struct radv_pipeline *pipeline,
const unsigned char *sha1, bool *found_in_application_cache)
bool *found_in_application_cache)
{
*found_in_application_cache = false;
@ -326,7 +326,7 @@ radv_pipeline_cache_search(struct radv_device *device, struct vk_pipeline_cache
}
struct vk_pipeline_cache_object *object =
vk_pipeline_cache_lookup_object(cache, sha1, SHA1_DIGEST_LENGTH, &radv_pipeline_ops, found);
vk_pipeline_cache_lookup_object(cache, pipeline->sha1, SHA1_DIGEST_LENGTH, &radv_pipeline_ops, found);
if (!object)
return false;
@ -349,8 +349,7 @@ radv_pipeline_cache_search(struct radv_device *device, struct vk_pipeline_cache
}
void
radv_pipeline_cache_insert(struct radv_device *device, struct vk_pipeline_cache *cache, struct radv_pipeline *pipeline,
const unsigned char *sha1)
radv_pipeline_cache_insert(struct radv_device *device, struct vk_pipeline_cache *cache, struct radv_pipeline *pipeline)
{
if (device->cache_disabled)
return;
@ -365,7 +364,7 @@ radv_pipeline_cache_insert(struct radv_device *device, struct vk_pipeline_cache
num_shaders += pipeline->gs_copy_shader ? 1 : 0;
struct radv_pipeline_cache_object *pipeline_obj;
pipeline_obj = radv_pipeline_cache_object_create(&device->vk, num_shaders, sha1, 0);
pipeline_obj = radv_pipeline_cache_object_create(&device->vk, num_shaders, pipeline->sha1, 0);
if (!pipeline_obj)
return;

View file

@ -44,11 +44,10 @@ struct radv_shader *radv_shader_create(struct radv_device *device, struct vk_pip
const struct radv_shader_binary *binary, bool skip_cache);
bool radv_pipeline_cache_search(struct radv_device *device, struct vk_pipeline_cache *cache,
struct radv_pipeline *pipeline, const unsigned char *sha1,
bool *found_in_application_cache);
struct radv_pipeline *pipeline, bool *found_in_application_cache);
void radv_pipeline_cache_insert(struct radv_device *device, struct vk_pipeline_cache *cache,
struct radv_pipeline *pipeline, const unsigned char *sha1);
struct radv_pipeline *pipeline);
bool radv_ray_tracing_pipeline_cache_search(struct radv_device *device, struct vk_pipeline_cache *cache,
struct radv_ray_tracing_pipeline *pipeline,

View file

@ -220,7 +220,6 @@ radv_compute_pipeline_compile(const VkComputePipelineCreateInfo *pCreateInfo, st
const VkPipelineCreationFeedbackCreateInfo *creation_feedback)
{
struct radv_shader_binary *cs_binary = NULL;
unsigned char hash[20];
bool keep_executable_info = radv_pipeline_capture_shaders(device, pipeline->base.create_flags);
bool keep_statistic_info = radv_pipeline_capture_shader_stats(device, pipeline->base.create_flags);
struct radv_shader_stage cs_stage = {0};
@ -232,9 +231,9 @@ radv_compute_pipeline_compile(const VkComputePipelineCreateInfo *pCreateInfo, st
int64_t pipeline_start = os_time_get_nano();
radv_compute_pipeline_hash(device, pCreateInfo, hash);
radv_compute_pipeline_hash(device, pCreateInfo, pipeline->base.sha1);
pipeline->base.pipeline_hash = *(uint64_t *)hash;
pipeline->base.pipeline_hash = *(uint64_t *)pipeline->base.sha1;
/* Skip the shaders cache when any of the below are true:
* - shaders are captured because it's for debugging purposes
@ -244,8 +243,7 @@ radv_compute_pipeline_compile(const VkComputePipelineCreateInfo *pCreateInfo, st
}
bool found_in_application_cache = true;
if (!skip_shaders_cache &&
radv_pipeline_cache_search(device, cache, &pipeline->base, hash, &found_in_application_cache)) {
if (!skip_shaders_cache && radv_pipeline_cache_search(device, cache, &pipeline->base, &found_in_application_cache)) {
if (found_in_application_cache)
pipeline_feedback.flags |= VK_PIPELINE_CREATION_FEEDBACK_APPLICATION_PIPELINE_CACHE_HIT_BIT;
result = VK_SUCCESS;
@ -268,7 +266,7 @@ radv_compute_pipeline_compile(const VkComputePipelineCreateInfo *pCreateInfo, st
cs_stage.feedback.duration += os_time_get_nano() - stage_start;
if (!skip_shaders_cache) {
radv_pipeline_cache_insert(device, cache, &pipeline->base, hash);
radv_pipeline_cache_insert(device, cache, &pipeline->base);
}
free(cs_binary);

View file

@ -2616,7 +2616,6 @@ radv_graphics_pipeline_compile(struct radv_graphics_pipeline *pipeline, const Vk
{
struct radv_shader_binary *binaries[MESA_VULKAN_SHADER_STAGES] = {NULL};
struct radv_shader_binary *gs_copy_binary = NULL;
unsigned char hash[20];
bool keep_executable_info = radv_pipeline_capture_shaders(device, pipeline->base.create_flags);
bool keep_statistic_info = radv_pipeline_capture_shader_stats(device, pipeline->base.create_flags);
struct radv_shader_stage stages[MESA_VULKAN_SHADER_STAGES];
@ -2650,9 +2649,10 @@ radv_graphics_pipeline_compile(struct radv_graphics_pipeline *pipeline, const Vk
radv_pipeline_load_retained_shaders(device, pipeline, pCreateInfo, stages);
if (radv_should_compute_pipeline_hash(device, pipeline, fast_linking_enabled)) {
radv_hash_shaders(device, hash, stages, MESA_VULKAN_SHADER_STAGES, pipeline_layout, &pipeline_key->gfx_state);
radv_hash_shaders(device, pipeline->base.sha1, stages, MESA_VULKAN_SHADER_STAGES, pipeline_layout,
&pipeline_key->gfx_state);
pipeline->base.pipeline_hash = *(uint64_t *)hash;
pipeline->base.pipeline_hash = *(uint64_t *)pipeline->base.sha1;
}
/* Skip the shaders cache when any of the below are true:
@ -2674,8 +2674,7 @@ radv_graphics_pipeline_compile(struct radv_graphics_pipeline *pipeline, const Vk
}
bool found_in_application_cache = true;
if (!skip_shaders_cache &&
radv_pipeline_cache_search(device, cache, &pipeline->base, hash, &found_in_application_cache)) {
if (!skip_shaders_cache && radv_pipeline_cache_search(device, cache, &pipeline->base, &found_in_application_cache)) {
if (found_in_application_cache)
pipeline_feedback.flags |= VK_PIPELINE_CREATION_FEEDBACK_APPLICATION_PIPELINE_CACHE_HIT_BIT;
@ -2718,7 +2717,7 @@ radv_graphics_pipeline_compile(struct radv_graphics_pipeline *pipeline, const Vk
pipeline->base.shaders, binaries, &pipeline->base.gs_copy_shader, &gs_copy_binary);
if (!skip_shaders_cache) {
radv_pipeline_cache_insert(device, cache, &pipeline->base, hash);
radv_pipeline_cache_insert(device, cache, &pipeline->base);
}
free(gs_copy_binary);