From ab635b024b6e51efb2e350773bbce8a98e6b1c19 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Fri, 6 Aug 2021 15:00:11 +0200 Subject: [PATCH] radv: pass the HTILE buffer to radv_copy_vrs_htile() Will be used to use a global HTILE buffer without an image. Signed-off-by: Samuel Pitoiset Reviewed-by: Bas Nieuwenhuizen Part-of: --- src/amd/vulkan/radv_cmd_buffer.c | 23 +++++++++++++++++++---- src/amd/vulkan/radv_meta.h | 3 ++- src/amd/vulkan/radv_meta_copy_vrs_htile.c | 14 ++++---------- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c index a013d58..3cf3dbc 100644 --- a/src/amd/vulkan/radv_cmd_buffer.c +++ b/src/amd/vulkan/radv_cmd_buffer.c @@ -5142,14 +5142,22 @@ radv_cmd_buffer_begin_subpass(struct radv_cmd_buffer *cmd_buffer, uint32_t subpa */ int ds_idx = subpass->depth_stencil_attachment->attachment; struct radv_image_view *ds_iview = cmd_buffer->state.attachments[ds_idx].iview; + struct radv_image *ds_image = ds_iview->image; VkExtent2D extent = { - .width = ds_iview->image->info.width, - .height = ds_iview->image->info.height, + .width = ds_image->info.width, + .height = ds_image->info.height, }; + /* HTILE buffer */ + uint64_t htile_offset = ds_image->offset + ds_image->planes[0].surface.meta_offset; + uint64_t htile_size = ds_image->planes[0].surface.meta_slice_size; + struct radv_buffer htile_buffer = {.bo = ds_image->bo, + .offset = htile_offset, + .size = htile_size}; + /* Copy the VRS rates to the HTILE buffer. */ - radv_copy_vrs_htile(cmd_buffer, vrs_iview->image, &extent, ds_iview->image, true); + radv_copy_vrs_htile(cmd_buffer, vrs_iview->image, &extent, ds_image, &htile_buffer, true); } else { /* When a subpass uses a VRS attachment without binding a depth/stencil attachment, we have * to copy the VRS rates to our internal HTILE buffer. @@ -5158,13 +5166,20 @@ radv_cmd_buffer_begin_subpass(struct radv_cmd_buffer *cmd_buffer, uint32_t subpa struct radv_image *ds_image = radv_cmd_buffer_get_vrs_image(cmd_buffer); if (ds_image) { + /* HTILE buffer */ + uint64_t htile_offset = ds_image->offset + ds_image->planes[0].surface.meta_offset; + uint64_t htile_size = ds_image->planes[0].surface.meta_slice_size; + struct radv_buffer htile_buffer = {.bo = ds_image->bo, + .offset = htile_offset, + .size = htile_size}; + VkExtent2D extent = { .width = MIN2(fb->width, ds_image->info.width), .height = MIN2(fb->height, ds_image->info.height), }; /* Copy the VRS rates to the HTILE buffer. */ - radv_copy_vrs_htile(cmd_buffer, vrs_iview->image, &extent, ds_image, false); + radv_copy_vrs_htile(cmd_buffer, vrs_iview->image, &extent, ds_image, &htile_buffer, false); } } } diff --git a/src/amd/vulkan/radv_meta.h b/src/amd/vulkan/radv_meta.h index 30c5652..7500b89 100644 --- a/src/amd/vulkan/radv_meta.h +++ b/src/amd/vulkan/radv_meta.h @@ -220,7 +220,8 @@ void radv_retile_dcc(struct radv_cmd_buffer *cmd_buffer, struct radv_image *imag void radv_expand_fmask_image_inplace(struct radv_cmd_buffer *cmd_buffer, struct radv_image *image, const VkImageSubresourceRange *subresourceRange); void radv_copy_vrs_htile(struct radv_cmd_buffer *cmd_buffer, struct radv_image *vrs_image, - VkExtent2D *extent, struct radv_image *dst_image, bool read_htile_value); + VkExtent2D *extent, struct radv_image *dst_image, + struct radv_buffer *htile_buffer, bool read_htile_value); void radv_meta_resolve_compute_image(struct radv_cmd_buffer *cmd_buffer, struct radv_image *src_image, VkFormat src_format, diff --git a/src/amd/vulkan/radv_meta_copy_vrs_htile.c b/src/amd/vulkan/radv_meta_copy_vrs_htile.c index aa5d584..ad89967 100644 --- a/src/amd/vulkan/radv_meta_copy_vrs_htile.c +++ b/src/amd/vulkan/radv_meta_copy_vrs_htile.c @@ -220,7 +220,8 @@ fail: void radv_copy_vrs_htile(struct radv_cmd_buffer *cmd_buffer, struct radv_image *vrs_image, - VkExtent2D *extent, struct radv_image *dst_image, bool read_htile_value) + VkExtent2D *extent, struct radv_image *dst_image, + struct radv_buffer *htile_buffer, bool read_htile_value) { struct radv_device *device = cmd_buffer->device; struct radv_meta_state *state = &device->meta_state; @@ -249,13 +250,6 @@ radv_copy_vrs_htile(struct radv_cmd_buffer *cmd_buffer, struct radv_image *vrs_i radv_CmdBindPipeline(radv_cmd_buffer_to_handle(cmd_buffer), VK_PIPELINE_BIND_POINT_COMPUTE, state->copy_vrs_htile_pipeline); - /* HTILE buffer */ - uint64_t htile_offset = dst_image->offset + dst_image->planes[0].surface.meta_offset; - uint64_t htile_size = dst_image->planes[0].surface.meta_slice_size; - struct radv_buffer htile_buffer = {.bo = dst_image->bo, - .offset = htile_offset, - .size = htile_size}; - radv_image_view_init(&vrs_iview, cmd_buffer->device, &(VkImageViewCreateInfo){ .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, @@ -292,9 +286,9 @@ radv_copy_vrs_htile(struct radv_cmd_buffer *cmd_buffer, struct radv_image *vrs_i .dstArrayElement = 0, .descriptorCount = 1, .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, - .pBufferInfo = &(VkDescriptorBufferInfo){.buffer = radv_buffer_to_handle(&htile_buffer), + .pBufferInfo = &(VkDescriptorBufferInfo){.buffer = radv_buffer_to_handle(htile_buffer), .offset = 0, - .range = htile_size}}}); + .range = htile_buffer->size}}}); const unsigned constants[3] = { dst_image->planes[0].surface.meta_pitch, dst_image->planes[0].surface.meta_slice_size, -- 2.7.4