radv: always use view format when performing subpass resolves
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Tue, 28 May 2019 08:47:12 +0000 (10:47 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 29 May 2019 06:53:46 +0000 (08:53 +0200)
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 <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_meta.h
src/amd/vulkan/radv_meta_resolve.c
src/amd/vulkan/radv_meta_resolve_cs.c

index 0bd75d6c207d9bfb25a1df6e0ce26bcaf941c4f7..4a7c37be9b3009722dfeb154f4847b1f3514e1b8 100644 (file)
@@ -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);
index 1544513a9bcf5e664302f91f661fb0a36fe2b6ab..b4551a986370bcda39d4db94fca48e1498487e3e 100644 (file)
@@ -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 });
        }
index 67df4800023dd711a9e9e9b076035b1566858d9a..b6c9e1c2b1faa9076115be2939a8c626c0570706 100644 (file)
@@ -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, &region);
        }