From 017170a7859ab1a5c82e8cb5991b2bbb83d70c10 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Tue, 28 May 2019 10:47:12 +0200 Subject: [PATCH] radv: always use view format when performing subpass resolves It makes sense to use the image view formats when resolving inside subpasses, while we have to use the image formats for normal resolves. Original patch by Philip Rebohle. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=110348 Signed-off-by: Samuel Pitoiset Reviewed-by: Bas Nieuwenhuizen --- src/amd/vulkan/radv_meta.h | 2 ++ src/amd/vulkan/radv_meta_resolve.c | 9 ++++++--- src/amd/vulkan/radv_meta_resolve_cs.c | 22 +++++++++++++--------- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/amd/vulkan/radv_meta.h b/src/amd/vulkan/radv_meta.h index 0bd75d6c207..4a7c37be9b3 100644 --- a/src/amd/vulkan/radv_meta.h +++ b/src/amd/vulkan/radv_meta.h @@ -183,8 +183,10 @@ void radv_expand_fmask_image_inplace(struct radv_cmd_buffer *cmd_buffer, void radv_meta_resolve_compute_image(struct radv_cmd_buffer *cmd_buffer, struct radv_image *src_image, + VkFormat src_format, VkImageLayout src_image_layout, struct radv_image *dest_image, + VkFormat dest_format, VkImageLayout dest_image_layout, uint32_t region_count, const VkImageResolve *regions); diff --git a/src/amd/vulkan/radv_meta_resolve.c b/src/amd/vulkan/radv_meta_resolve.c index 1544513a9bc..b4551a98637 100644 --- a/src/amd/vulkan/radv_meta_resolve.c +++ b/src/amd/vulkan/radv_meta_resolve.c @@ -439,8 +439,10 @@ void radv_CmdResolveImage( if (resolve_method == RESOLVE_COMPUTE) { radv_meta_resolve_compute_image(cmd_buffer, src_image, + src_image->vk_format, src_image_layout, dest_image, + dest_image->vk_format, dest_image_layout, region_count, regions); return; @@ -658,7 +660,8 @@ radv_cmd_buffer_resolve_subpass(struct radv_cmd_buffer *cmd_buffer) if (dest_att.attachment == VK_ATTACHMENT_UNUSED) continue; - struct radv_image *dst_img = cmd_buffer->state.framebuffer->attachments[dest_att.attachment].attachment->image; + struct radv_image_view *dest_iview = cmd_buffer->state.framebuffer->attachments[dest_att.attachment].attachment; + struct radv_image *dst_img = dest_iview->image; if (radv_image_has_dcc(dst_img)) { radv_initialize_dcc(cmd_buffer, dst_img, 0xffffffff); @@ -673,14 +676,14 @@ radv_cmd_buffer_resolve_subpass(struct radv_cmd_buffer *cmd_buffer) radv_cmd_buffer_set_subpass(cmd_buffer, &resolve_subpass); - VkResult ret = build_resolve_pipeline(cmd_buffer->device, radv_format_meta_fs_key(dst_img->vk_format)); + VkResult ret = build_resolve_pipeline(cmd_buffer->device, radv_format_meta_fs_key(dest_iview->vk_format)); if (ret != VK_SUCCESS) { cmd_buffer->record_result = ret; continue; } emit_resolve(cmd_buffer, - dst_img->vk_format, + dest_iview->vk_format, &(VkOffset2D) { 0, 0 }, &(VkExtent2D) { fb->width, fb->height }); } diff --git a/src/amd/vulkan/radv_meta_resolve_cs.c b/src/amd/vulkan/radv_meta_resolve_cs.c index 67df4800023..b6c9e1c2b1f 100644 --- a/src/amd/vulkan/radv_meta_resolve_cs.c +++ b/src/amd/vulkan/radv_meta_resolve_cs.c @@ -315,17 +315,17 @@ radv_device_finish_meta_resolve_compute_state(struct radv_device *device) static VkPipeline * radv_get_resolve_pipeline(struct radv_cmd_buffer *cmd_buffer, - struct radv_image *src_image) + struct radv_image_view *src_iview) { struct radv_device *device = cmd_buffer->device; struct radv_meta_state *state = &device->meta_state; - uint32_t samples = src_image->info.samples; + uint32_t samples = src_iview->image->info.samples; uint32_t samples_log2 = ffs(samples) - 1; VkPipeline *pipeline; - if (vk_format_is_int(src_image->vk_format)) + if (vk_format_is_int(src_iview->vk_format)) pipeline = &state->resolve_compute.rc[samples_log2].i_pipeline; - else if (vk_format_is_srgb(src_image->vk_format)) + else if (vk_format_is_srgb(src_iview->vk_format)) pipeline = &state->resolve_compute.rc[samples_log2].srgb_pipeline; else pipeline = &state->resolve_compute.rc[samples_log2].pipeline; @@ -334,8 +334,8 @@ radv_get_resolve_pipeline(struct radv_cmd_buffer *cmd_buffer, VkResult ret; ret = create_resolve_pipeline(device, samples, - vk_format_is_int(src_image->vk_format), - vk_format_is_srgb(src_image->vk_format), + vk_format_is_int(src_iview->vk_format), + vk_format_is_srgb(src_iview->vk_format), pipeline); if (ret != VK_SUCCESS) { cmd_buffer->record_result = ret; @@ -392,7 +392,7 @@ emit_resolve(struct radv_cmd_buffer *cmd_buffer, } }); - pipeline = radv_get_resolve_pipeline(cmd_buffer, src_iview->image); + pipeline = radv_get_resolve_pipeline(cmd_buffer, src_iview); radv_CmdBindPipeline(radv_cmd_buffer_to_handle(cmd_buffer), VK_PIPELINE_BIND_POINT_COMPUTE, *pipeline); @@ -413,8 +413,10 @@ emit_resolve(struct radv_cmd_buffer *cmd_buffer, void radv_meta_resolve_compute_image(struct radv_cmd_buffer *cmd_buffer, struct radv_image *src_image, + VkFormat src_format, VkImageLayout src_image_layout, struct radv_image *dest_image, + VkFormat dest_format, VkImageLayout dest_image_layout, uint32_t region_count, const VkImageResolve *regions) @@ -460,7 +462,7 @@ void radv_meta_resolve_compute_image(struct radv_cmd_buffer *cmd_buffer, .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, .image = radv_image_to_handle(src_image), .viewType = radv_meta_get_view_type(src_image), - .format = src_image->vk_format, + .format = src_format, .subresourceRange = { .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, .baseMipLevel = region->srcSubresource.mipLevel, @@ -476,7 +478,7 @@ void radv_meta_resolve_compute_image(struct radv_cmd_buffer *cmd_buffer, .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, .image = radv_image_to_handle(dest_image), .viewType = radv_meta_get_view_type(dest_image), - .format = vk_to_non_srgb_format(dest_image->vk_format), + .format = vk_to_non_srgb_format(dest_format), .subresourceRange = { .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, .baseMipLevel = region->dstSubresource.mipLevel, @@ -544,8 +546,10 @@ radv_cmd_buffer_resolve_subpass_cs(struct radv_cmd_buffer *cmd_buffer) radv_meta_resolve_compute_image(cmd_buffer, src_iview->image, + src_iview->vk_format, src_att.layout, dst_iview->image, + dst_iview->vk_format, dst_att.layout, 1, ®ion); } -- 2.30.2