From 450a325858a70dc610d77d3d91c61793ce2223a2 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Mon, 17 Sep 2018 14:57:51 +0200 Subject: [PATCH] radv: do not re-create the sampler for every blits in CmdBlitImage() Signed-off-by: Samuel Pitoiset Reviewed-by: Bas Nieuwenhuizen --- src/amd/vulkan/radv_meta_blit.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/amd/vulkan/radv_meta_blit.c b/src/amd/vulkan/radv_meta_blit.c index e7962911208..ef690edb471 100644 --- a/src/amd/vulkan/radv_meta_blit.c +++ b/src/amd/vulkan/radv_meta_blit.c @@ -307,7 +307,7 @@ meta_emit_blit(struct radv_cmd_buffer *cmd_buffer, VkOffset2D dest_offset_0, VkOffset2D dest_offset_1, VkRect2D dest_box, - VkFilter blit_filter) + VkSampler sampler) { struct radv_device *device = cmd_buffer->device; uint32_t src_width = radv_minify(src_iview->image->info.width, src_iview->base_mip); @@ -331,17 +331,6 @@ meta_emit_blit(struct radv_cmd_buffer *cmd_buffer, VK_SHADER_STAGE_VERTEX_BIT, 0, 20, vertex_push_constants); - VkSampler sampler; - radv_CreateSampler(radv_device_to_handle(device), - &(VkSamplerCreateInfo) { - .sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO, - .magFilter = blit_filter, - .minFilter = blit_filter, - .addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, - .addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, - .addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, - }, &cmd_buffer->pool->alloc, &sampler); - VkFramebuffer fb; radv_CreateFramebuffer(radv_device_to_handle(device), &(VkFramebufferCreateInfo) { @@ -510,8 +499,6 @@ fail_pipeline: /* TODO: above comment is not valid for at least descriptor sets/pools, * as we may not free them till after execution finishes. Check others. */ - radv_DestroySampler(radv_device_to_handle(device), sampler, - &cmd_buffer->pool->alloc); radv_DestroyFramebuffer(radv_device_to_handle(device), fb, &cmd_buffer->pool->alloc); } @@ -550,8 +537,10 @@ void radv_CmdBlitImage( RADV_FROM_HANDLE(radv_cmd_buffer, cmd_buffer, commandBuffer); RADV_FROM_HANDLE(radv_image, src_image, srcImage); RADV_FROM_HANDLE(radv_image, dest_image, destImage); + struct radv_device *device = cmd_buffer->device; struct radv_meta_saved_state saved_state; bool old_predicating; + VkSampler sampler; /* From the Vulkan 1.0 spec: * @@ -561,6 +550,16 @@ void radv_CmdBlitImage( assert(src_image->info.samples == 1); assert(dest_image->info.samples == 1); + radv_CreateSampler(radv_device_to_handle(device), + &(VkSamplerCreateInfo) { + .sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO, + .magFilter = filter, + .minFilter = filter, + .addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, + .addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, + .addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, + }, &cmd_buffer->pool->alloc, &sampler); + radv_meta_save(&saved_state, cmd_buffer, RADV_META_SAVE_GRAPHICS_PIPELINE | RADV_META_SAVE_CONSTANTS | @@ -682,7 +681,7 @@ void radv_CmdBlitImage( dest_image, &dest_iview, destImageLayout, dest_offset_0, dest_offset_1, dest_box, - filter); + sampler); } } @@ -690,6 +689,9 @@ void radv_CmdBlitImage( cmd_buffer->state.predicating = old_predicating; radv_meta_restore(&saved_state, cmd_buffer); + + radv_DestroySampler(radv_device_to_handle(device), sampler, + &cmd_buffer->pool->alloc); } void -- 2.30.2