From bb745776b77ca4f2027b57f03869d073ed6deac5 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Thu, 18 Jul 2024 15:54:37 +0200 Subject: [PATCH] radv/meta: create btoi r32g32b32 pipeline on-demand when needed Signed-off-by: Samuel Pitoiset Part-of: --- src/amd/vulkan/meta/radv_meta_bufimage.c | 37 ++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/src/amd/vulkan/meta/radv_meta_bufimage.c b/src/amd/vulkan/meta/radv_meta_bufimage.c index 65ff4655932..e54168eff64 100644 --- a/src/amd/vulkan/meta/radv_meta_bufimage.c +++ b/src/amd/vulkan/meta/radv_meta_bufimage.c @@ -344,7 +344,28 @@ create_btoi_r32g32b32_pipeline(struct radv_device *device, VkPipeline *pipeline) } static VkResult -radv_device_init_meta_btoi_r32g32b32_state(struct radv_device *device) +get_btoi_r32g32b32_pipeline(struct radv_device *device, VkPipeline *pipeline_out) +{ + struct radv_meta_state *state = &device->meta_state; + VkResult result = VK_SUCCESS; + + mtx_lock(&state->mtx); + + if (!state->btoi_r32g32b32.pipeline) { + result = create_btoi_r32g32b32_pipeline(device, &state->btoi_r32g32b32.pipeline); + if (result != VK_SUCCESS) + goto fail; + } + + *pipeline_out = state->btoi_r32g32b32.pipeline; + +fail: + mtx_unlock(&state->mtx); + return result; +} + +static VkResult +radv_device_init_meta_btoi_r32g32b32_state(struct radv_device *device, bool on_demand) { VkResult result; @@ -378,6 +399,9 @@ radv_device_init_meta_btoi_r32g32b32_state(struct radv_device *device) if (result != VK_SUCCESS) return result; + if (on_demand) + return VK_SUCCESS; + return create_btoi_r32g32b32_pipeline(device, &device->meta_state.btoi_r32g32b32.pipeline); } @@ -867,7 +891,7 @@ radv_device_init_meta_bufimage_state(struct radv_device *device, bool on_demand) if (result != VK_SUCCESS) return result; - result = radv_device_init_meta_btoi_r32g32b32_state(device); + result = radv_device_init_meta_btoi_r32g32b32_state(device, on_demand); if (result != VK_SUCCESS) return result; @@ -1190,11 +1214,18 @@ radv_meta_buffer_to_image_cs_r32g32b32(struct radv_cmd_buffer *cmd_buffer, struc struct radv_meta_blit2d_surf *dst, struct radv_meta_blit2d_rect *rect) { struct radv_device *device = radv_cmd_buffer_device(cmd_buffer); - VkPipeline pipeline = device->meta_state.btoi_r32g32b32.pipeline; struct radv_buffer_view src_view, dst_view; unsigned dst_offset = 0; + VkPipeline pipeline; unsigned stride; VkBuffer buffer; + VkResult result; + + result = get_btoi_r32g32b32_pipeline(device, &pipeline); + if (result != VK_SUCCESS) { + vk_command_buffer_set_error(&cmd_buffer->vk, result); + return; + } /* This special btoi path for R32G32B32 formats will write the linear * image as a buffer with the same underlying memory. The compute