From 8231f7eaa1247316da11bdd59a461b8aabb3b2b7 Mon Sep 17 00:00:00 2001 From: Bas Nieuwenhuizen Date: Fri, 8 Oct 2021 00:39:17 +0200 Subject: [PATCH] radv: Use a VkPipelineCache handle for meta shaders. Prep work for using the common vk caches. Reviewed-by: Samuel Pitoiset Part-of: --- src/amd/vulkan/radv_acceleration_structure.c | 4 +-- .../vulkan/radv_device_generated_commands.c | 2 +- src/amd/vulkan/radv_meta.c | 36 ++++++++++++------- src/amd/vulkan/radv_meta_blit.c | 2 +- src/amd/vulkan/radv_meta_blit2d.c | 6 ++-- src/amd/vulkan/radv_meta_buffer.c | 4 +-- src/amd/vulkan/radv_meta_bufimage.c | 22 ++++++------ src/amd/vulkan/radv_meta_clear.c | 6 ++-- src/amd/vulkan/radv_meta_copy_vrs_htile.c | 2 +- src/amd/vulkan/radv_meta_dcc_retile.c | 2 +- src/amd/vulkan/radv_meta_decompress.c | 4 +-- src/amd/vulkan/radv_meta_etc_decode.c | 2 +- src/amd/vulkan/radv_meta_fast_clear.c | 8 ++--- src/amd/vulkan/radv_meta_fmask_copy.c | 2 +- src/amd/vulkan/radv_meta_fmask_expand.c | 2 +- src/amd/vulkan/radv_meta_resolve.c | 2 +- src/amd/vulkan/radv_meta_resolve_cs.c | 4 +-- src/amd/vulkan/radv_meta_resolve_fs.c | 4 +-- src/amd/vulkan/radv_pipeline_cache.c | 8 ++--- src/amd/vulkan/radv_private.h | 6 +--- src/amd/vulkan/radv_query.c | 10 +++--- 21 files changed, 73 insertions(+), 65 deletions(-) diff --git a/src/amd/vulkan/radv_acceleration_structure.c b/src/amd/vulkan/radv_acceleration_structure.c index c7255e96950..d0786ff6f55 100644 --- a/src/amd/vulkan/radv_acceleration_structure.c +++ b/src/amd/vulkan/radv_acceleration_structure.c @@ -350,7 +350,7 @@ create_build_pipeline_spv(struct radv_device *device, const uint32_t *spv, uint3 }; result = radv_CreateComputePipelines(radv_device_to_handle(device), - radv_pipeline_cache_to_handle(&device->meta_state.cache), 1, + device->meta_state.cache, 1, &pipeline_info, &device->meta_state.alloc, pipeline); cleanup: @@ -421,7 +421,7 @@ radv_device_init_accel_struct_build_state(struct radv_device *device) device->meta_state.accel_struct_build.radix_sort = radv_create_radix_sort_u64(radv_device_to_handle(device), &device->meta_state.alloc, - radv_pipeline_cache_to_handle(&device->meta_state.cache)); + device->meta_state.cache); struct radix_sort_vk_sort_devaddr_info *radix_sort_info = &device->meta_state.accel_struct_build.radix_sort_info; diff --git a/src/amd/vulkan/radv_device_generated_commands.c b/src/amd/vulkan/radv_device_generated_commands.c index e8fea2294cc..69b233cac23 100644 --- a/src/amd/vulkan/radv_device_generated_commands.c +++ b/src/amd/vulkan/radv_device_generated_commands.c @@ -962,7 +962,7 @@ radv_device_init_dgc_prepare_state(struct radv_device *device) }; result = radv_CreateComputePipelines( - radv_device_to_handle(device), radv_pipeline_cache_to_handle(&device->meta_state.cache), 1, + radv_device_to_handle(device), device->meta_state.cache, 1, &pipeline_info, &device->meta_state.alloc, &device->meta_state.dgc_prepare.pipeline); if (result != VK_SUCCESS) goto cleanup; diff --git a/src/amd/vulkan/radv_meta.c b/src/amd/vulkan/radv_meta.c index 2ea349ddacd..ea55b31aa89 100644 --- a/src/amd/vulkan/radv_meta.c +++ b/src/amd/vulkan/radv_meta.c @@ -295,13 +295,19 @@ radv_load_meta_pipeline(struct radv_device *device) struct stat st; void *data = NULL; bool ret = false; + int fd = -1; + VkResult result = VK_SUCCESS; + + VkPipelineCacheCreateInfo create_info = { + .sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO, + }; if (!radv_builtin_cache_path(path)) - return false; + goto fail; - int fd = open(path, O_RDONLY); + fd = open(path, O_RDONLY); if (fd < 0) - return false; + goto fail; if (fstat(fd, &st)) goto fail; data = malloc(st.st_size); @@ -310,10 +316,18 @@ radv_load_meta_pipeline(struct radv_device *device) if (read(fd, data, st.st_size) == -1) goto fail; - ret = radv_pipeline_cache_load(&device->meta_state.cache, data, st.st_size); + create_info.initialDataSize = st.st_size; + create_info.pInitialData = data; + fail: + result = radv_CreatePipelineCache(radv_device_to_handle(device), &create_info, NULL, &device->meta_state.cache); + if (result == VK_SUCCESS) { + ret = radv_pipeline_cache_from_handle(device->meta_state.cache)->kernel_count > 0; + } + free(data); - close(fd); + if (fd >= 0) + close(fd); return ret; #endif } @@ -326,11 +340,11 @@ radv_store_meta_pipeline(struct radv_device *device) size_t size; void *data = NULL; - if (!device->meta_state.cache.modified) + if (!radv_pipeline_cache_from_handle(device->meta_state.cache)->modified) return; if (radv_GetPipelineCacheData(radv_device_to_handle(device), - radv_pipeline_cache_to_handle(&device->meta_state.cache), &size, + device->meta_state.cache, &size, NULL)) return; @@ -347,7 +361,7 @@ radv_store_meta_pipeline(struct radv_device *device) goto fail; if (radv_GetPipelineCacheData(radv_device_to_handle(device), - radv_pipeline_cache_to_handle(&device->meta_state.cache), &size, + device->meta_state.cache, &size, data)) goto fail; if (write(fd, data, size) == -1) @@ -375,8 +389,6 @@ radv_device_init_meta(struct radv_device *device) .pfnFree = meta_free, }; - device->meta_state.cache.alloc = device->meta_state.alloc; - radv_pipeline_cache_init(&device->meta_state.cache, device); bool loaded_cache = radv_load_meta_pipeline(device); bool on_demand = !loaded_cache; @@ -490,7 +502,7 @@ fail_clear: radv_device_finish_meta_clear_state(device); mtx_destroy(&device->meta_state.mtx); - radv_pipeline_cache_finish(&device->meta_state.cache); + radv_DestroyPipelineCache(radv_device_to_handle(device), device->meta_state.cache, NULL); return result; } @@ -517,7 +529,7 @@ radv_device_finish_meta(struct radv_device *device) radv_device_finish_meta_fmask_copy_state(device); radv_store_meta_pipeline(device); - radv_pipeline_cache_finish(&device->meta_state.cache); + radv_DestroyPipelineCache(radv_device_to_handle(device), device->meta_state.cache, NULL); mtx_destroy(&device->meta_state.mtx); } diff --git a/src/amd/vulkan/radv_meta_blit.c b/src/amd/vulkan/radv_meta_blit.c index 3076f9263e0..4f8ff87eaa1 100644 --- a/src/amd/vulkan/radv_meta_blit.c +++ b/src/amd/vulkan/radv_meta_blit.c @@ -816,7 +816,7 @@ build_pipeline(struct radv_device *device, VkImageAspectFlagBits aspect, const struct radv_graphics_pipeline_create_info radv_pipeline_info = {.use_rectlist = true}; result = radv_graphics_pipeline_create( - radv_device_to_handle(device), radv_pipeline_cache_to_handle(&device->meta_state.cache), + radv_device_to_handle(device), device->meta_state.cache, &vk_pipeline_info, &radv_pipeline_info, &device->meta_state.alloc, pipeline); ralloc_free(vs); ralloc_free(fs); diff --git a/src/amd/vulkan/radv_meta_blit2d.c b/src/amd/vulkan/radv_meta_blit2d.c index 7b69c7b3f60..57d4d0f3284 100644 --- a/src/amd/vulkan/radv_meta_blit2d.c +++ b/src/amd/vulkan/radv_meta_blit2d.c @@ -748,7 +748,7 @@ blit2d_init_color_pipeline(struct radv_device *device, enum blit2d_src_type src_ const struct radv_graphics_pipeline_create_info radv_pipeline_info = {.use_rectlist = true}; result = radv_graphics_pipeline_create( - radv_device_to_handle(device), radv_pipeline_cache_to_handle(&device->meta_state.cache), + radv_device_to_handle(device), device->meta_state.cache, &vk_pipeline_info, &radv_pipeline_info, &device->meta_state.alloc, &device->meta_state.blit2d[log2_samples].pipelines[src_type][fs_key]); @@ -905,7 +905,7 @@ blit2d_init_depth_only_pipeline(struct radv_device *device, enum blit2d_src_type const struct radv_graphics_pipeline_create_info radv_pipeline_info = {.use_rectlist = true}; result = radv_graphics_pipeline_create( - radv_device_to_handle(device), radv_pipeline_cache_to_handle(&device->meta_state.cache), + radv_device_to_handle(device), device->meta_state.cache, &vk_pipeline_info, &radv_pipeline_info, &device->meta_state.alloc, &device->meta_state.blit2d[log2_samples].depth_only_pipeline[src_type]); @@ -1059,7 +1059,7 @@ blit2d_init_stencil_only_pipeline(struct radv_device *device, enum blit2d_src_ty const struct radv_graphics_pipeline_create_info radv_pipeline_info = {.use_rectlist = true}; result = radv_graphics_pipeline_create( - radv_device_to_handle(device), radv_pipeline_cache_to_handle(&device->meta_state.cache), + radv_device_to_handle(device), device->meta_state.cache, &vk_pipeline_info, &radv_pipeline_info, &device->meta_state.alloc, &device->meta_state.blit2d[log2_samples].stencil_only_pipeline[src_type]); diff --git a/src/amd/vulkan/radv_meta_buffer.c b/src/amd/vulkan/radv_meta_buffer.c index a0acad84e56..343caf7305c 100644 --- a/src/amd/vulkan/radv_meta_buffer.c +++ b/src/amd/vulkan/radv_meta_buffer.c @@ -118,7 +118,7 @@ radv_device_init_meta_buffer_state(struct radv_device *device) }; result = radv_CreateComputePipelines( - radv_device_to_handle(device), radv_pipeline_cache_to_handle(&device->meta_state.cache), 1, + radv_device_to_handle(device), device->meta_state.cache, 1, &fill_vk_pipeline_info, NULL, &device->meta_state.buffer.fill_pipeline); if (result != VK_SUCCESS) goto fail; @@ -139,7 +139,7 @@ radv_device_init_meta_buffer_state(struct radv_device *device) }; result = radv_CreateComputePipelines( - radv_device_to_handle(device), radv_pipeline_cache_to_handle(&device->meta_state.cache), 1, + radv_device_to_handle(device), device->meta_state.cache, 1, ©_vk_pipeline_info, NULL, &device->meta_state.buffer.copy_pipeline); if (result != VK_SUCCESS) goto fail; diff --git a/src/amd/vulkan/radv_meta_bufimage.c b/src/amd/vulkan/radv_meta_bufimage.c index 3ee22cd0020..8991c804779 100644 --- a/src/amd/vulkan/radv_meta_bufimage.c +++ b/src/amd/vulkan/radv_meta_bufimage.c @@ -155,7 +155,7 @@ radv_device_init_meta_itob_state(struct radv_device *device) }; result = radv_CreateComputePipelines(radv_device_to_handle(device), - radv_pipeline_cache_to_handle(&device->meta_state.cache), 1, + device->meta_state.cache, 1, &vk_pipeline_info, NULL, &device->meta_state.itob.pipeline); if (result != VK_SUCCESS) goto fail; @@ -176,7 +176,7 @@ radv_device_init_meta_itob_state(struct radv_device *device) }; result = radv_CreateComputePipelines( - radv_device_to_handle(device), radv_pipeline_cache_to_handle(&device->meta_state.cache), 1, + radv_device_to_handle(device), device->meta_state.cache, 1, &vk_pipeline_info_3d, NULL, &device->meta_state.itob.pipeline_3d); if (result != VK_SUCCESS) goto fail; @@ -333,7 +333,7 @@ radv_device_init_meta_btoi_state(struct radv_device *device) }; result = radv_CreateComputePipelines(radv_device_to_handle(device), - radv_pipeline_cache_to_handle(&device->meta_state.cache), 1, + device->meta_state.cache, 1, &vk_pipeline_info, NULL, &device->meta_state.btoi.pipeline); if (result != VK_SUCCESS) goto fail; @@ -354,7 +354,7 @@ radv_device_init_meta_btoi_state(struct radv_device *device) }; result = radv_CreateComputePipelines( - radv_device_to_handle(device), radv_pipeline_cache_to_handle(&device->meta_state.cache), 1, + radv_device_to_handle(device), device->meta_state.cache, 1, &vk_pipeline_info_3d, NULL, &device->meta_state.btoi.pipeline_3d); ralloc_free(cs_3d); @@ -508,7 +508,7 @@ radv_device_init_meta_btoi_r32g32b32_state(struct radv_device *device) }; result = radv_CreateComputePipelines( - radv_device_to_handle(device), radv_pipeline_cache_to_handle(&device->meta_state.cache), 1, + radv_device_to_handle(device), device->meta_state.cache, 1, &vk_pipeline_info, NULL, &device->meta_state.btoi_r32g32b32.pipeline); fail: @@ -624,7 +624,7 @@ create_itoi_pipeline(struct radv_device *device, int samples, VkPipeline *pipeli }; result = radv_CreateComputePipelines(radv_device_to_handle(device), - radv_pipeline_cache_to_handle(&state->cache), 1, + state->cache, 1, &vk_pipeline_info, NULL, pipeline); ralloc_free(cs); return result; @@ -702,7 +702,7 @@ radv_device_init_meta_itoi_state(struct radv_device *device) }; result = radv_CreateComputePipelines( - radv_device_to_handle(device), radv_pipeline_cache_to_handle(&device->meta_state.cache), 1, + radv_device_to_handle(device), device->meta_state.cache, 1, &vk_pipeline_info_3d, NULL, &device->meta_state.itoi.pipeline_3d); ralloc_free(cs_3d); @@ -863,7 +863,7 @@ radv_device_init_meta_itoi_r32g32b32_state(struct radv_device *device) }; result = radv_CreateComputePipelines( - radv_device_to_handle(device), radv_pipeline_cache_to_handle(&device->meta_state.cache), 1, + radv_device_to_handle(device), device->meta_state.cache, 1, &vk_pipeline_info, NULL, &device->meta_state.itoi_r32g32b32.pipeline); fail: @@ -943,7 +943,7 @@ create_cleari_pipeline(struct radv_device *device, int samples, VkPipeline *pipe }; result = radv_CreateComputePipelines(radv_device_to_handle(device), - radv_pipeline_cache_to_handle(&device->meta_state.cache), 1, + device->meta_state.cache, 1, &vk_pipeline_info, NULL, pipeline); ralloc_free(cs); return result; @@ -1016,7 +1016,7 @@ radv_device_init_meta_cleari_state(struct radv_device *device) }; result = radv_CreateComputePipelines( - radv_device_to_handle(device), radv_pipeline_cache_to_handle(&device->meta_state.cache), 1, + radv_device_to_handle(device), device->meta_state.cache, 1, &vk_pipeline_info_3d, NULL, &device->meta_state.cleari.pipeline_3d); ralloc_free(cs_3d); @@ -1134,7 +1134,7 @@ radv_device_init_meta_cleari_r32g32b32_state(struct radv_device *device) }; result = radv_CreateComputePipelines( - radv_device_to_handle(device), radv_pipeline_cache_to_handle(&device->meta_state.cache), 1, + radv_device_to_handle(device), device->meta_state.cache, 1, &vk_pipeline_info, NULL, &device->meta_state.cleari_r32g32b32.pipeline); fail: diff --git a/src/amd/vulkan/radv_meta_clear.c b/src/amd/vulkan/radv_meta_clear.c index 850c5d53771..8827281a4ff 100644 --- a/src/amd/vulkan/radv_meta_clear.c +++ b/src/amd/vulkan/radv_meta_clear.c @@ -88,7 +88,7 @@ create_pipeline(struct radv_device *device, uint32_t samples, VkResult result; result = radv_graphics_pipeline_create( - device_h, radv_pipeline_cache_to_handle(&device->meta_state.cache), + device_h, device->meta_state.cache, &(VkGraphicsPipelineCreateInfo){ .sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, .pNext = dyn_state, @@ -953,7 +953,7 @@ init_meta_clear_htile_mask_state(struct radv_device *device) }; result = radv_CreateComputePipelines(radv_device_to_handle(device), - radv_pipeline_cache_to_handle(&state->cache), 1, + state->cache, 1, &pipeline_info, NULL, &state->clear_htile_mask_pipeline); fail: @@ -1033,7 +1033,7 @@ create_dcc_comp_to_single_pipeline(struct radv_device *device, bool is_msaa, VkP }; result = radv_CreateComputePipelines(radv_device_to_handle(device), - radv_pipeline_cache_to_handle(&state->cache), 1, + state->cache, 1, &pipeline_info, NULL, pipeline); ralloc_free(cs); diff --git a/src/amd/vulkan/radv_meta_copy_vrs_htile.c b/src/amd/vulkan/radv_meta_copy_vrs_htile.c index d5715d00dc8..782c02ced2c 100644 --- a/src/amd/vulkan/radv_meta_copy_vrs_htile.c +++ b/src/amd/vulkan/radv_meta_copy_vrs_htile.c @@ -203,7 +203,7 @@ radv_device_init_meta_copy_vrs_htile_state(struct radv_device *device, }; result = radv_CreateComputePipelines(radv_device_to_handle(device), - radv_pipeline_cache_to_handle(&state->cache), 1, + state->cache, 1, &pipeline_info, NULL, &state->copy_vrs_htile_pipeline); fail: ralloc_free(cs); diff --git a/src/amd/vulkan/radv_meta_dcc_retile.c b/src/amd/vulkan/radv_meta_dcc_retile.c index 681108747af..9970abb12cd 100644 --- a/src/amd/vulkan/radv_meta_dcc_retile.c +++ b/src/amd/vulkan/radv_meta_dcc_retile.c @@ -167,7 +167,7 @@ radv_device_init_meta_dcc_retile_state(struct radv_device *device, struct radeon }; result = radv_CreateComputePipelines( - radv_device_to_handle(device), radv_pipeline_cache_to_handle(&device->meta_state.cache), 1, + radv_device_to_handle(device), device->meta_state.cache, 1, &vk_pipeline_info, NULL, &device->meta_state.dcc_retile.pipeline[surf->u.gfx9.swizzle_mode]); if (result != VK_SUCCESS) goto cleanup; diff --git a/src/amd/vulkan/radv_meta_decompress.c b/src/amd/vulkan/radv_meta_decompress.c index b1c9affdec1..4c735767ec0 100644 --- a/src/amd/vulkan/radv_meta_decompress.c +++ b/src/amd/vulkan/radv_meta_decompress.c @@ -137,7 +137,7 @@ create_expand_depth_stencil_compute(struct radv_device *device) }; result = radv_CreateComputePipelines( - radv_device_to_handle(device), radv_pipeline_cache_to_handle(&device->meta_state.cache), 1, + radv_device_to_handle(device), device->meta_state.cache, 1, &vk_pipeline_info, NULL, &device->meta_state.expand_depth_stencil_compute_pipeline); if (result != VK_SUCCESS) @@ -291,7 +291,7 @@ create_pipeline(struct radv_device *device, uint32_t samples, VkPipelineLayout l }; result = radv_graphics_pipeline_create( - device_h, radv_pipeline_cache_to_handle(&device->meta_state.cache), &pipeline_create_info, + device_h, device->meta_state.cache, &pipeline_create_info, &extra, &device->meta_state.alloc, pipeline); cleanup: diff --git a/src/amd/vulkan/radv_meta_etc_decode.c b/src/amd/vulkan/radv_meta_etc_decode.c index b65d1ca0da1..4320c2a0e33 100644 --- a/src/amd/vulkan/radv_meta_etc_decode.c +++ b/src/amd/vulkan/radv_meta_etc_decode.c @@ -595,7 +595,7 @@ create_decode_pipeline(struct radv_device *device, VkPipeline *pipeline) }; result = radv_CreateComputePipelines(radv_device_to_handle(device), - radv_pipeline_cache_to_handle(&device->meta_state.cache), 1, + device->meta_state.cache, 1, &vk_pipeline_info, NULL, pipeline); if (result != VK_SUCCESS) goto fail; diff --git a/src/amd/vulkan/radv_meta_fast_clear.c b/src/amd/vulkan/radv_meta_fast_clear.c index ed8ff78a13f..b5123c5846d 100644 --- a/src/amd/vulkan/radv_meta_fast_clear.c +++ b/src/amd/vulkan/radv_meta_fast_clear.c @@ -136,7 +136,7 @@ create_dcc_compress_compute(struct radv_device *device) }; result = radv_CreateComputePipelines( - radv_device_to_handle(device), radv_pipeline_cache_to_handle(&device->meta_state.cache), 1, + radv_device_to_handle(device), device->meta_state.cache, 1, &vk_pipeline_info, NULL, &device->meta_state.fast_clear_flush.dcc_decompress_compute_pipeline); if (result != VK_SUCCESS) @@ -230,7 +230,7 @@ create_pipeline(struct radv_device *device, VkShaderModule vs_module_h, VkPipeli }; result = radv_graphics_pipeline_create( - device_h, radv_pipeline_cache_to_handle(&device->meta_state.cache), + device_h, device->meta_state.cache, &(VkGraphicsPipelineCreateInfo){ .sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, .pNext = &rendering_create_info, @@ -280,7 +280,7 @@ create_pipeline(struct radv_device *device, VkShaderModule vs_module_h, VkPipeli goto cleanup; result = radv_graphics_pipeline_create( - device_h, radv_pipeline_cache_to_handle(&device->meta_state.cache), + device_h, device->meta_state.cache, &(VkGraphicsPipelineCreateInfo){ .sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, .pNext = &rendering_create_info, @@ -330,7 +330,7 @@ create_pipeline(struct radv_device *device, VkShaderModule vs_module_h, VkPipeli goto cleanup; result = radv_graphics_pipeline_create( - device_h, radv_pipeline_cache_to_handle(&device->meta_state.cache), + device_h, device->meta_state.cache, &(VkGraphicsPipelineCreateInfo){ .sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, .pNext = &rendering_create_info, diff --git a/src/amd/vulkan/radv_meta_fmask_copy.c b/src/amd/vulkan/radv_meta_fmask_copy.c index 1dc6ab49c92..3b4eebec499 100644 --- a/src/amd/vulkan/radv_meta_fmask_copy.c +++ b/src/amd/vulkan/radv_meta_fmask_copy.c @@ -163,7 +163,7 @@ create_fmask_copy_pipeline(struct radv_device *device, int samples, VkPipeline * }; result = radv_CreateComputePipelines(radv_device_to_handle(device), - radv_pipeline_cache_to_handle(&state->cache), 1, + state->cache, 1, &vk_pipeline_info, NULL, pipeline); ralloc_free(cs); return result; diff --git a/src/amd/vulkan/radv_meta_fmask_expand.c b/src/amd/vulkan/radv_meta_fmask_expand.c index f2e11d0873c..1f3df57b12b 100644 --- a/src/amd/vulkan/radv_meta_fmask_expand.c +++ b/src/amd/vulkan/radv_meta_fmask_expand.c @@ -206,7 +206,7 @@ create_fmask_expand_pipeline(struct radv_device *device, int samples, VkPipeline }; result = radv_CreateComputePipelines(radv_device_to_handle(device), - radv_pipeline_cache_to_handle(&state->cache), 1, + state->cache, 1, &vk_pipeline_info, NULL, pipeline); ralloc_free(cs); diff --git a/src/amd/vulkan/radv_meta_resolve.c b/src/amd/vulkan/radv_meta_resolve.c index c5b04d609d7..6d3727d2f19 100644 --- a/src/amd/vulkan/radv_meta_resolve.c +++ b/src/amd/vulkan/radv_meta_resolve.c @@ -84,7 +84,7 @@ create_pipeline(struct radv_device *device, VkShaderModule vs_module_h, VkFormat }; result = radv_graphics_pipeline_create( - device_h, radv_pipeline_cache_to_handle(&device->meta_state.cache), + device_h, device->meta_state.cache, &(VkGraphicsPipelineCreateInfo){ .sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, .pNext = &rendering_create_info, diff --git a/src/amd/vulkan/radv_meta_resolve_cs.c b/src/amd/vulkan/radv_meta_resolve_cs.c index 6465e37452f..20c256e4de0 100644 --- a/src/amd/vulkan/radv_meta_resolve_cs.c +++ b/src/amd/vulkan/radv_meta_resolve_cs.c @@ -315,7 +315,7 @@ create_resolve_pipeline(struct radv_device *device, int samples, bool is_integer }; result = radv_CreateComputePipelines(radv_device_to_handle(device), - radv_pipeline_cache_to_handle(&device->meta_state.cache), 1, + device->meta_state.cache, 1, &vk_pipeline_info, NULL, pipeline); if (result != VK_SUCCESS) goto fail; @@ -361,7 +361,7 @@ create_depth_stencil_resolve_pipeline(struct radv_device *device, int samples, i }; result = radv_CreateComputePipelines(radv_device_to_handle(device), - radv_pipeline_cache_to_handle(&device->meta_state.cache), 1, + device->meta_state.cache, 1, &vk_pipeline_info, NULL, pipeline); if (result != VK_SUCCESS) goto fail; diff --git a/src/amd/vulkan/radv_meta_resolve_fs.c b/src/amd/vulkan/radv_meta_resolve_fs.c index 971a82f230b..255a40214d7 100644 --- a/src/amd/vulkan/radv_meta_resolve_fs.c +++ b/src/amd/vulkan/radv_meta_resolve_fs.c @@ -219,7 +219,7 @@ create_resolve_pipeline(struct radv_device *device, int samples_log2, VkFormat f const struct radv_graphics_pipeline_create_info radv_pipeline_info = {.use_rectlist = true}; result = radv_graphics_pipeline_create( - radv_device_to_handle(device), radv_pipeline_cache_to_handle(&device->meta_state.cache), + radv_device_to_handle(device), device->meta_state.cache, &vk_pipeline_info, &radv_pipeline_info, &device->meta_state.alloc, pipeline); ralloc_free(vs); ralloc_free(fs); @@ -508,7 +508,7 @@ create_depth_stencil_resolve_pipeline(struct radv_device *device, int samples_lo const struct radv_graphics_pipeline_create_info radv_pipeline_info = {.use_rectlist = true}; result = radv_graphics_pipeline_create( - radv_device_to_handle(device), radv_pipeline_cache_to_handle(&device->meta_state.cache), + radv_device_to_handle(device), device->meta_state.cache, &vk_pipeline_info, &radv_pipeline_info, &device->meta_state.alloc, pipeline); ralloc_free(vs); diff --git a/src/amd/vulkan/radv_pipeline_cache.c b/src/amd/vulkan/radv_pipeline_cache.c index be7da0bb1e2..9e0e445a6a0 100644 --- a/src/amd/vulkan/radv_pipeline_cache.c +++ b/src/amd/vulkan/radv_pipeline_cache.c @@ -73,7 +73,7 @@ radv_is_cache_disabled(struct radv_device *device) (device->physical_device->use_llvm ? 0 : aco_get_codegen_flags()); } -void +static void radv_pipeline_cache_init(struct radv_pipeline_cache *cache, struct radv_device *device) { vk_object_base_init(&device->vk, &cache->base, VK_OBJECT_TYPE_PIPELINE_CACHE); @@ -98,7 +98,7 @@ radv_pipeline_cache_init(struct radv_pipeline_cache *cache, struct radv_device * memset(cache->hash_table, 0, byte_size); } -void +static void radv_pipeline_cache_finish(struct radv_pipeline_cache *cache) { for (unsigned i = 0; i < cache->table_size; ++i) @@ -541,7 +541,7 @@ radv_pipeline_cache_insert_shaders(struct radv_device *device, struct radv_pipel * * Make sure to exclude meta shaders because they are stored in a different cache file. */ - if (device->physical_device->vk.disk_cache && cache != &device->meta_state.cache) { + if (device->physical_device->vk.disk_cache && cache != radv_pipeline_cache_from_handle(device->meta_state.cache)) { uint8_t disk_sha1[SHA1_DIGEST_LENGTH]; disk_cache_compute_key(device->physical_device->vk.disk_cache, sha1, SHA1_DIGEST_LENGTH, disk_sha1); @@ -576,7 +576,7 @@ radv_pipeline_cache_insert_shaders(struct radv_device *device, struct radv_pipel return; } -bool +static bool radv_pipeline_cache_load(struct radv_pipeline_cache *cache, const void *data, size_t size) { struct radv_device *device = cache->device; diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h index 40647e13078..7aaace60fa6 100644 --- a/src/amd/vulkan/radv_private.h +++ b/src/amd/vulkan/radv_private.h @@ -386,10 +386,6 @@ struct radv_shader_binary; struct radv_shader; struct radv_pipeline_shader_stack_size; -void radv_pipeline_cache_init(struct radv_pipeline_cache *cache, struct radv_device *device); -void radv_pipeline_cache_finish(struct radv_pipeline_cache *cache); -bool radv_pipeline_cache_load(struct radv_pipeline_cache *cache, const void *data, size_t size); - bool radv_create_shaders_from_pipeline_cache( struct radv_device *device, struct radv_pipeline_cache *cache, const unsigned char *sha1, struct radv_pipeline *pipeline, struct radv_pipeline_shader_stack_size **stack_sizes, @@ -445,7 +441,7 @@ radv_meta_dst_layout_to_layout(enum radv_meta_dst_layout layout) struct radv_meta_state { VkAllocationCallbacks alloc; - struct radv_pipeline_cache cache; + VkPipelineCache cache; /* * For on-demand pipeline creation, makes sure that diff --git a/src/amd/vulkan/radv_query.c b/src/amd/vulkan/radv_query.c index d160bec2634..e9d1b79e38f 100644 --- a/src/amd/vulkan/radv_query.c +++ b/src/amd/vulkan/radv_query.c @@ -818,7 +818,7 @@ radv_device_init_meta_query_state_internal(struct radv_device *device) }; result = radv_CreateComputePipelines( - radv_device_to_handle(device), radv_pipeline_cache_to_handle(&device->meta_state.cache), 1, + radv_device_to_handle(device), device->meta_state.cache, 1, &occlusion_vk_pipeline_info, NULL, &device->meta_state.query.occlusion_query_pipeline); if (result != VK_SUCCESS) goto fail; @@ -839,7 +839,7 @@ radv_device_init_meta_query_state_internal(struct radv_device *device) }; result = radv_CreateComputePipelines( - radv_device_to_handle(device), radv_pipeline_cache_to_handle(&device->meta_state.cache), 1, + radv_device_to_handle(device), device->meta_state.cache, 1, &pipeline_statistics_vk_pipeline_info, NULL, &device->meta_state.query.pipeline_statistics_query_pipeline); if (result != VK_SUCCESS) @@ -861,7 +861,7 @@ radv_device_init_meta_query_state_internal(struct radv_device *device) }; result = radv_CreateComputePipelines( - radv_device_to_handle(device), radv_pipeline_cache_to_handle(&device->meta_state.cache), 1, + radv_device_to_handle(device), device->meta_state.cache, 1, &tfb_pipeline_info, NULL, &device->meta_state.query.tfb_query_pipeline); if (result != VK_SUCCESS) goto fail; @@ -882,7 +882,7 @@ radv_device_init_meta_query_state_internal(struct radv_device *device) }; result = radv_CreateComputePipelines( - radv_device_to_handle(device), radv_pipeline_cache_to_handle(&device->meta_state.cache), 1, + radv_device_to_handle(device), device->meta_state.cache, 1, ×tamp_pipeline_info, NULL, &device->meta_state.query.timestamp_query_pipeline); if (result != VK_SUCCESS) goto fail; @@ -903,7 +903,7 @@ radv_device_init_meta_query_state_internal(struct radv_device *device) }; result = radv_CreateComputePipelines( - radv_device_to_handle(device), radv_pipeline_cache_to_handle(&device->meta_state.cache), 1, + radv_device_to_handle(device), device->meta_state.cache, 1, &pg_pipeline_info, NULL, &device->meta_state.query.pg_query_pipeline); fail: