radv: add support for capturing pipeline binaries

When VK_PIPELINE_CREATE_2_CAPTURE_DATA_BIT_KHR is set, implementations
shouldn't store pipeline data to an internal cache.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30812>
This commit is contained in:
Samuel Pitoiset 2024-09-02 14:30:31 +02:00 committed by Marge Bot
parent be06bfcbed
commit 96a300a3f0
3 changed files with 11 additions and 5 deletions

View file

@ -196,8 +196,9 @@ radv_compute_pipeline_compile(const VkComputePipelineCreateInfo *pCreateInfo, st
/* Skip the shaders cache when any of the below are true:
* - shaders are captured because it's for debugging purposes
* - binaries are captured for later uses
*/
if (keep_executable_info) {
if (keep_executable_info || (pipeline->base.create_flags & VK_PIPELINE_CREATE_2_CAPTURE_DATA_BIT_KHR)) {
skip_shaders_cache = true;
}

View file

@ -2908,10 +2908,12 @@ radv_graphics_pipeline_compile(struct radv_graphics_pipeline *pipeline, const Vk
/* Skip the shaders cache when any of the below are true:
* - fast-linking is enabled because it's useless to cache unoptimized pipelines
* - shaders are captured because it's for debugging purposes
* - binaries are captured for later uses
* - graphics pipeline libraries are created with the RETAIN_LINK_TIME_OPTIMIZATION flag and
* module identifiers are used (ie. no SPIR-V provided).
*/
if (fast_linking_enabled || keep_executable_info) {
if (fast_linking_enabled || keep_executable_info ||
(pipeline->base.create_flags & VK_PIPELINE_CREATE_2_CAPTURE_DATA_BIT_KHR)) {
skip_shaders_cache = true;
} else if (retain_shaders) {
assert(pipeline->base.create_flags & VK_PIPELINE_CREATE_2_LIBRARY_BIT_KHR);

View file

@ -622,9 +622,10 @@ radv_rt_compile_shaders(struct radv_device *device, struct vk_pipeline_cache *ca
(library && !has_callable) || always_inlined || (monolithic && rt_stages[idx].stage != MESA_SHADER_RAYGEN);
nir_needed &= !rt_stages[idx].nir;
if (nir_needed) {
const bool cached = !stage->key.optimisations_disabled &&
!(pipeline->base.base.create_flags & VK_PIPELINE_CREATE_2_CAPTURE_DATA_BIT_KHR);
rt_stages[idx].stack_size = stage->nir->scratch_size;
rt_stages[idx].nir = radv_pipeline_cache_nir_to_handle(device, cache, stage->nir, rt_stages[idx].sha1,
!stage->key.optimisations_disabled);
rt_stages[idx].nir = radv_pipeline_cache_nir_to_handle(device, cache, stage->nir, rt_stages[idx].sha1, cached);
}
stage->feedback.duration += os_time_get_nano() - stage_start;
@ -890,9 +891,11 @@ radv_rt_pipeline_compile(struct radv_device *device, const VkRayTracingPipelineC
/* Skip the shaders cache when any of the below are true:
* - shaders are captured because it's for debugging purposes
* - binaries are captured for later uses
* - ray history is enabled
*/
if (keep_executable_info || emit_ray_history) {
if (keep_executable_info || emit_ray_history ||
(pipeline->base.base.create_flags & VK_PIPELINE_CREATE_2_CAPTURE_DATA_BIT_KHR)) {
skip_shaders_cache = true;
}