From 9aec76aca3307c2d00f2bcd9f37c7cf3ca181dfb Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sun, 19 Feb 2017 16:33:14 +1000 Subject: [PATCH] radv: handle layered fast clears. This iterates the fast clear flush across the layers in the specified range. It also moves the compute resolve flush into the function and builds the range in there. This fixes: dEQP-VK.geometry.layered.* regressions since fast clears. Signed-off-by: Dave Airlie Reviewed-by: Bas Nieuwenhuizen --- src/amd/vulkan/radv_cmd_buffer.c | 4 +-- src/amd/vulkan/radv_meta.h | 3 +- src/amd/vulkan/radv_meta_fast_clear.c | 56 +++++++++++++++++++---------------- src/amd/vulkan/radv_meta_resolve.c | 1 - src/amd/vulkan/radv_meta_resolve_cs.c | 8 +++++ 5 files changed, 43 insertions(+), 29 deletions(-) diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c index 661d982..ef44859 100644 --- a/src/amd/vulkan/radv_cmd_buffer.c +++ b/src/amd/vulkan/radv_cmd_buffer.c @@ -2702,7 +2702,7 @@ static void radv_handle_cmask_image_transition(struct radv_cmd_buffer *cmd_buffe radv_initialise_cmask(cmd_buffer, image, 0xffffffffu); } else if (radv_layout_can_fast_clear(image, src_layout, src_queue_mask) && !radv_layout_can_fast_clear(image, dst_layout, dst_queue_mask)) { - radv_fast_clear_flush_image_inplace(cmd_buffer, image); + radv_fast_clear_flush_image_inplace(cmd_buffer, image, range); } } @@ -2736,7 +2736,7 @@ static void radv_handle_dcc_image_transition(struct radv_cmd_buffer *cmd_buffer, radv_initialize_dcc(cmd_buffer, image, 0x20202020u); } else if (radv_layout_can_fast_clear(image, src_layout, src_queue_mask) && !radv_layout_can_fast_clear(image, dst_layout, dst_queue_mask)) { - radv_fast_clear_flush_image_inplace(cmd_buffer, image); + radv_fast_clear_flush_image_inplace(cmd_buffer, image, range); } } diff --git a/src/amd/vulkan/radv_meta.h b/src/amd/vulkan/radv_meta.h index 55f3a4b..8eb3df3 100644 --- a/src/amd/vulkan/radv_meta.h +++ b/src/amd/vulkan/radv_meta.h @@ -194,7 +194,8 @@ void radv_resummarize_depth_image_inplace(struct radv_cmd_buffer *cmd_buffer, struct radv_image *image, VkImageSubresourceRange *subresourceRange); void radv_fast_clear_flush_image_inplace(struct radv_cmd_buffer *cmd_buffer, - struct radv_image *image); + struct radv_image *image, + const VkImageSubresourceRange *subresourceRange); void radv_meta_save_graphics_reset_vport_scissor(struct radv_meta_saved_state *saved_state, struct radv_cmd_buffer *cmd_buffer); diff --git a/src/amd/vulkan/radv_meta_fast_clear.c b/src/amd/vulkan/radv_meta_fast_clear.c index 950b438..0902c45 100644 --- a/src/amd/vulkan/radv_meta_fast_clear.c +++ b/src/amd/vulkan/radv_meta_fast_clear.c @@ -412,7 +412,8 @@ emit_fast_clear_flush(struct radv_cmd_buffer *cmd_buffer, */ void radv_fast_clear_flush_image_inplace(struct radv_cmd_buffer *cmd_buffer, - struct radv_image *image) + struct radv_image *image, + const VkImageSubresourceRange *subresourceRange) { struct radv_meta_saved_state saved_state; struct radv_meta_saved_pass_state saved_pass_state; @@ -423,38 +424,42 @@ radv_fast_clear_flush_image_inplace(struct radv_cmd_buffer *cmd_buffer, radv_meta_save_pass(&saved_pass_state, cmd_buffer); radv_meta_save_graphics_reset_vport_scissor(&saved_state, cmd_buffer); - struct radv_image_view iview; - radv_image_view_init(&iview, cmd_buffer->device, - &(VkImageViewCreateInfo) { - .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, + for (uint32_t layer = 0; layer < subresourceRange->layerCount; + ++layer) { + struct radv_image_view iview; + + radv_image_view_init(&iview, cmd_buffer->device, + &(VkImageViewCreateInfo) { + .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, .image = radv_image_to_handle(image), + .viewType = radv_meta_get_view_type(image), .format = image->vk_format, .subresourceRange = { .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, .baseMipLevel = 0, .levelCount = 1, - .baseArrayLayer = 0, + .baseArrayLayer = subresourceRange->baseArrayLayer + layer, .layerCount = 1, - }, + }, }, cmd_buffer, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); - VkFramebuffer fb_h; - radv_CreateFramebuffer(device_h, - &(VkFramebufferCreateInfo) { - .sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, - .attachmentCount = 1, - .pAttachments = (VkImageView[]) { - radv_image_view_to_handle(&iview) - }, + VkFramebuffer fb_h; + radv_CreateFramebuffer(device_h, + &(VkFramebufferCreateInfo) { + .sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, + .attachmentCount = 1, + .pAttachments = (VkImageView[]) { + radv_image_view_to_handle(&iview) + }, .width = image->extent.width, .height = image->extent.height, .layers = 1 - }, - &cmd_buffer->pool->alloc, - &fb_h); + }, + &cmd_buffer->pool->alloc, + &fb_h); - radv_CmdBeginRenderPass(cmd_buffer_h, + radv_CmdBeginRenderPass(cmd_buffer_h, &(VkRenderPassBeginInfo) { .sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, .renderPass = cmd_buffer->device->meta_state.fast_clear_flush.pass, @@ -474,14 +479,15 @@ radv_fast_clear_flush_image_inplace(struct radv_cmd_buffer *cmd_buffer, }, VK_SUBPASS_CONTENTS_INLINE); - emit_fast_clear_flush(cmd_buffer, - &(VkExtent2D) { image->extent.width, image->extent.height }, - image->fmask.size > 0); - radv_CmdEndRenderPass(cmd_buffer_h); + emit_fast_clear_flush(cmd_buffer, + &(VkExtent2D) { image->extent.width, image->extent.height }, + image->fmask.size > 0); + radv_CmdEndRenderPass(cmd_buffer_h); - radv_DestroyFramebuffer(device_h, fb_h, - &cmd_buffer->pool->alloc); + radv_DestroyFramebuffer(device_h, fb_h, + &cmd_buffer->pool->alloc); + } radv_meta_restore(&saved_state, cmd_buffer); radv_meta_restore_pass(&saved_pass_state, cmd_buffer); } diff --git a/src/amd/vulkan/radv_meta_resolve.c b/src/amd/vulkan/radv_meta_resolve.c index 23ca569..288a147 100644 --- a/src/amd/vulkan/radv_meta_resolve.c +++ b/src/amd/vulkan/radv_meta_resolve.c @@ -404,7 +404,6 @@ void radv_CmdResolveImage( if (use_compute_resolve) { - radv_fast_clear_flush_image_inplace(cmd_buffer, src_image); radv_meta_resolve_compute_image(cmd_buffer, src_image, src_image_layout, diff --git a/src/amd/vulkan/radv_meta_resolve_cs.c b/src/amd/vulkan/radv_meta_resolve_cs.c index bfe4cee..9cb4ce8 100644 --- a/src/amd/vulkan/radv_meta_resolve_cs.c +++ b/src/amd/vulkan/radv_meta_resolve_cs.c @@ -350,6 +350,14 @@ void radv_meta_resolve_compute_image(struct radv_cmd_buffer *cmd_buffer, const struct VkOffset3D dstOffset = radv_sanitize_image_offset(dest_image->type, region->dstOffset); + VkImageSubresourceRange range; + range.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; + range.baseMipLevel = region->srcSubresource.mipLevel; + range.levelCount = 1; + range.baseArrayLayer = src_base_layer; + range.layerCount = region->srcSubresource.layerCount; + radv_fast_clear_flush_image_inplace(cmd_buffer, src_image, &range); + for (uint32_t layer = 0; layer < region->srcSubresource.layerCount; ++layer) { -- 2.7.4