diff --git a/src/amd/vulkan/radv_pipeline_cache.c b/src/amd/vulkan/radv_pipeline_cache.c index a47d316af7c..4121638b08c 100644 --- a/src/amd/vulkan/radv_pipeline_cache.c +++ b/src/amd/vulkan/radv_pipeline_cache.c @@ -399,17 +399,22 @@ struct radv_ray_tracing_pipeline_cache_data { bool radv_ray_tracing_pipeline_cache_search(struct radv_device *device, struct vk_pipeline_cache *cache, struct radv_ray_tracing_pipeline *pipeline, - const VkRayTracingPipelineCreateInfoKHR *pCreateInfo) + const VkRayTracingPipelineCreateInfoKHR *pCreateInfo, + bool *found_in_application_cache) { + *found_in_application_cache = false; + if (device->cache_disabled) return false; - if (!cache) + bool *found = found_in_application_cache; + if (!cache) { cache = device->mem_cache; + found = NULL; + } - bool cache_hit = false; struct vk_pipeline_cache_object *object = - vk_pipeline_cache_lookup_object(cache, pipeline->sha1, SHA1_DIGEST_LENGTH, &radv_pipeline_ops, &cache_hit); + vk_pipeline_cache_lookup_object(cache, pipeline->sha1, SHA1_DIGEST_LENGTH, &radv_pipeline_ops, found); if (!object) return false; @@ -438,14 +443,6 @@ radv_ray_tracing_pipeline_cache_search(struct radv_device *device, struct vk_pip assert(idx == pipeline_obj->num_shaders); - if (cache_hit && cache != device->mem_cache) { - const VkPipelineCreationFeedbackCreateInfo *creation_feedback = - vk_find_struct_const(pCreateInfo->pNext, PIPELINE_CREATION_FEEDBACK_CREATE_INFO); - if (creation_feedback) - creation_feedback->pPipelineCreationFeedback->flags |= - VK_PIPELINE_CREATION_FEEDBACK_APPLICATION_PIPELINE_CACHE_HIT_BIT; - } - pipeline->base.base.cache_object = object; return complete; } diff --git a/src/amd/vulkan/radv_pipeline_cache.h b/src/amd/vulkan/radv_pipeline_cache.h index aa84f52455f..9c1a06c915e 100644 --- a/src/amd/vulkan/radv_pipeline_cache.h +++ b/src/amd/vulkan/radv_pipeline_cache.h @@ -52,7 +52,8 @@ void radv_pipeline_cache_insert(struct radv_device *device, struct vk_pipeline_c bool radv_ray_tracing_pipeline_cache_search(struct radv_device *device, struct vk_pipeline_cache *cache, struct radv_ray_tracing_pipeline *pipeline, - const VkRayTracingPipelineCreateInfoKHR *create_info); + const VkRayTracingPipelineCreateInfoKHR *pCreateInfo, + bool *found_in_application_cache); void radv_ray_tracing_pipeline_cache_insert(struct radv_device *device, struct vk_pipeline_cache *cache, struct radv_ray_tracing_pipeline *pipeline, unsigned num_stages, diff --git a/src/amd/vulkan/radv_pipeline_rt.c b/src/amd/vulkan/radv_pipeline_rt.c index 9624d646f6d..a0b8299ecbd 100644 --- a/src/amd/vulkan/radv_pipeline_rt.c +++ b/src/amd/vulkan/radv_pipeline_rt.c @@ -842,12 +842,13 @@ radv_rt_pipeline_create(VkDevice _device, VkPipelineCache _cache, const VkRayTra VK_FROM_HANDLE(radv_device, device, _device); VK_FROM_HANDLE(vk_pipeline_cache, cache, _cache); VK_FROM_HANDLE(radv_pipeline_layout, pipeline_layout, pCreateInfo->layout); + VkPipelineCreationFeedback pipeline_feedback = { + .flags = VK_PIPELINE_CREATION_FEEDBACK_VALID_BIT, + }; bool skip_shaders_cache = false; VkResult result; const VkPipelineCreationFeedbackCreateInfo *creation_feedback = vk_find_struct_const(pCreateInfo->pNext, PIPELINE_CREATION_FEEDBACK_CREATE_INFO); - if (creation_feedback) - creation_feedback->pPipelineCreationFeedback->flags = VK_PIPELINE_CREATION_FEEDBACK_VALID_BIT; int64_t pipeline_start = os_time_get_nano(); @@ -902,8 +903,14 @@ radv_rt_pipeline_create(VkDevice _device, VkPipelineCache _cache, const VkRayTra } bool cache_hit = false; - if (!skip_shaders_cache) - cache_hit = radv_ray_tracing_pipeline_cache_search(device, cache, pipeline, pCreateInfo); + if (!skip_shaders_cache) { + bool found_in_application_cache = true; + + cache_hit = + radv_ray_tracing_pipeline_cache_search(device, cache, pipeline, pCreateInfo, &found_in_application_cache); + if (cache_hit && found_in_application_cache) + pipeline_feedback.flags |= VK_PIPELINE_CREATION_FEEDBACK_APPLICATION_PIPELINE_CACHE_HIT_BIT; + } if (!cache_hit) { result = radv_rt_compile_shaders(device, cache, pCreateInfo, creation_feedback, stage_keys, pipeline, @@ -935,8 +942,10 @@ radv_rt_pipeline_create(VkDevice _device, VkPipelineCache _cache, const VkRayTra } fail: + pipeline_feedback.duration = os_time_get_nano() - pipeline_start; + if (creation_feedback) - creation_feedback->pPipelineCreationFeedback->duration = os_time_get_nano() - pipeline_start; + *creation_feedback->pPipelineCreationFeedback = pipeline_feedback; if (result == VK_SUCCESS) *pPipeline = radv_pipeline_to_handle(&pipeline->base.base);