From 3a5950f50174390e817c619f972b8b8ea21c6705 Mon Sep 17 00:00:00 2001 From: Bas Nieuwenhuizen Date: Mon, 5 Aug 2019 01:38:42 +0200 Subject: [PATCH] radv: Add device argument for dcc compression check. Because it is about to be generation dependent. Reviewed-by: Dave Airlie --- src/amd/vulkan/radv_cmd_buffer.c | 8 ++++---- src/amd/vulkan/radv_image.c | 3 ++- src/amd/vulkan/radv_meta_copy.c | 8 ++++---- src/amd/vulkan/radv_meta_resolve.c | 20 ++++++++++++-------- src/amd/vulkan/radv_private.h | 3 ++- 5 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c index 51186dc3b15..55b7a0a5055 100644 --- a/src/amd/vulkan/radv_cmd_buffer.c +++ b/src/amd/vulkan/radv_cmd_buffer.c @@ -1294,7 +1294,7 @@ radv_emit_fb_color_state(struct radv_cmd_buffer *cmd_buffer, uint32_t cb_color_info = cb->cb_color_info; struct radv_image *image = iview->image; - if (!radv_layout_dcc_compressed(image, layout, in_render_loop, + if (!radv_layout_dcc_compressed(cmd_buffer->device, image, layout, in_render_loop, radv_image_queue_family_mask(image, cmd_buffer->queue_family_index, cmd_buffer->queue_family_index))) { @@ -5231,7 +5231,7 @@ static void radv_init_color_image_metadata(struct radv_cmd_buffer *cmd_buffer, uint32_t value = 0xffffffffu; /* Fully expanded mode. */ bool need_decompress_pass = false; - if (radv_layout_dcc_compressed(image, dst_layout, + if (radv_layout_dcc_compressed(cmd_buffer->device, image, dst_layout, dst_render_loop, dst_queue_mask)) { value = 0x20202020u; @@ -5277,8 +5277,8 @@ static void radv_handle_color_image_transition(struct radv_cmd_buffer *cmd_buffe if (radv_dcc_enabled(image, range->baseMipLevel)) { if (src_layout == VK_IMAGE_LAYOUT_PREINITIALIZED) { radv_initialize_dcc(cmd_buffer, image, range, 0xffffffffu); - } else if (radv_layout_dcc_compressed(image, src_layout, src_render_loop, src_queue_mask) && - !radv_layout_dcc_compressed(image, dst_layout, dst_render_loop, dst_queue_mask)) { + } else if (radv_layout_dcc_compressed(cmd_buffer->device, image, src_layout, src_render_loop, src_queue_mask) && + !radv_layout_dcc_compressed(cmd_buffer->device, image, dst_layout, dst_render_loop, dst_queue_mask)) { radv_decompress_dcc(cmd_buffer, image, range); } else if (radv_layout_can_fast_clear(image, src_layout, src_render_loop, src_queue_mask) && !radv_layout_can_fast_clear(image, dst_layout, dst_render_loop, dst_queue_mask)) { diff --git a/src/amd/vulkan/radv_image.c b/src/amd/vulkan/radv_image.c index ed520833981..64b2a73bf45 100644 --- a/src/amd/vulkan/radv_image.c +++ b/src/amd/vulkan/radv_image.c @@ -1642,7 +1642,8 @@ bool radv_layout_can_fast_clear(const struct radv_image *image, return layout == VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; } -bool radv_layout_dcc_compressed(const struct radv_image *image, +bool radv_layout_dcc_compressed(const struct radv_device *device, + const struct radv_image *image, VkImageLayout layout, bool in_render_loop, unsigned queue_mask) diff --git a/src/amd/vulkan/radv_meta_copy.c b/src/amd/vulkan/radv_meta_copy.c index 42e40cfd077..5e555a506cc 100644 --- a/src/amd/vulkan/radv_meta_copy.c +++ b/src/amd/vulkan/radv_meta_copy.c @@ -191,7 +191,7 @@ meta_copy_buffer_to_image(struct radv_cmd_buffer *cmd_buffer, uint32_t queue_mask = radv_image_queue_family_mask(image, cmd_buffer->queue_family_index, cmd_buffer->queue_family_index); - bool compressed = radv_layout_dcc_compressed(image, layout, false, queue_mask); + bool compressed = radv_layout_dcc_compressed(cmd_buffer->device, image, layout, false, queue_mask); if (compressed) { radv_decompress_dcc(cmd_buffer, image, &(VkImageSubresourceRange) { .aspectMask = pRegions[r].imageSubresource.aspectMask, @@ -335,7 +335,7 @@ meta_copy_image_to_buffer(struct radv_cmd_buffer *cmd_buffer, uint32_t queue_mask = radv_image_queue_family_mask(image, cmd_buffer->queue_family_index, cmd_buffer->queue_family_index); - bool compressed = radv_layout_dcc_compressed(image, layout, false, queue_mask); + bool compressed = radv_layout_dcc_compressed(cmd_buffer->device, image, layout, false, queue_mask); if (compressed) { radv_decompress_dcc(cmd_buffer, image, &(VkImageSubresourceRange) { .aspectMask = pRegions[r].imageSubresource.aspectMask, @@ -464,11 +464,11 @@ meta_copy_image(struct radv_cmd_buffer *cmd_buffer, uint32_t dst_queue_mask = radv_image_queue_family_mask(dest_image, cmd_buffer->queue_family_index, cmd_buffer->queue_family_index); - bool dst_compressed = radv_layout_dcc_compressed(dest_image, dest_image_layout, false, dst_queue_mask); + bool dst_compressed = radv_layout_dcc_compressed(cmd_buffer->device, dest_image, dest_image_layout, false, dst_queue_mask); uint32_t src_queue_mask = radv_image_queue_family_mask(src_image, cmd_buffer->queue_family_index, cmd_buffer->queue_family_index); - bool src_compressed = radv_layout_dcc_compressed(src_image, src_image_layout, false, src_queue_mask); + bool src_compressed = radv_layout_dcc_compressed(cmd_buffer->device, src_image, src_image_layout, false, src_queue_mask); if (!src_compressed || radv_dcc_formats_compatible(b_src.format, b_dst.format)) { b_src.format = b_dst.format; diff --git a/src/amd/vulkan/radv_meta_resolve.c b/src/amd/vulkan/radv_meta_resolve.c index dc5c2c65ecd..ea3d26c8d4c 100644 --- a/src/amd/vulkan/radv_meta_resolve.c +++ b/src/amd/vulkan/radv_meta_resolve.c @@ -330,7 +330,8 @@ enum radv_resolve_method { RESOLVE_FRAGMENT, }; -static void radv_pick_resolve_method_images(struct radv_image *src_image, +static void radv_pick_resolve_method_images(struct radv_device *device, + struct radv_image *src_image, VkFormat src_format, struct radv_image *dest_image, VkImageLayout dest_image_layout, @@ -353,7 +354,7 @@ static void radv_pick_resolve_method_images(struct radv_image *src_image, dest_image->info.array_size > 1) *method = RESOLVE_COMPUTE; - if (radv_layout_dcc_compressed(dest_image, dest_image_layout, + if (radv_layout_dcc_compressed(device, dest_image, dest_image_layout, dest_render_loop, queue_mask)) { *method = RESOLVE_FRAGMENT; } else if (dest_image->planes[0].surface.micro_tile_mode != @@ -433,9 +434,10 @@ void radv_CmdResolveImage( } else resolve_method = RESOLVE_COMPUTE; - radv_pick_resolve_method_images(src_image, src_image->vk_format, - dest_image, dest_image_layout, - false, cmd_buffer, &resolve_method); + radv_pick_resolve_method_images(cmd_buffer->device, src_image, + src_image->vk_format, dest_image, + dest_image_layout, false, cmd_buffer, + &resolve_method); if (resolve_method == RESOLVE_FRAGMENT) { radv_meta_resolve_fragment_image(cmd_buffer, @@ -647,7 +649,8 @@ radv_cmd_buffer_resolve_subpass(struct radv_cmd_buffer *cmd_buffer) struct radv_image_view *dst_iview = cmd_buffer->state.attachments[dst_att.attachment].iview; - radv_pick_resolve_method_images(src_iview->image, + radv_pick_resolve_method_images(cmd_buffer->device, + src_iview->image, src_iview->vk_format, dst_iview->image, dst_att.layout, @@ -701,8 +704,9 @@ radv_cmd_buffer_resolve_subpass(struct radv_cmd_buffer *cmd_buffer) struct radv_image_view *src_iview= cmd_buffer->state.attachments[src_att.attachment].iview; struct radv_image *src_img = src_iview->image; - radv_pick_resolve_method_images(src_img, src_iview->vk_format, - dst_img, dest_att.layout, + radv_pick_resolve_method_images(cmd_buffer->device, src_img, + src_iview->vk_format, dst_img, + dest_att.layout, dest_att.in_render_loop, cmd_buffer, &resolve_method); diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h index 1d87c17032c..8f3615f2f1c 100644 --- a/src/amd/vulkan/radv_private.h +++ b/src/amd/vulkan/radv_private.h @@ -1685,7 +1685,8 @@ bool radv_layout_can_fast_clear(const struct radv_image *image, bool in_render_loop, unsigned queue_mask); -bool radv_layout_dcc_compressed(const struct radv_image *image, +bool radv_layout_dcc_compressed(const struct radv_device *device, + const struct radv_image *image, VkImageLayout layout, bool in_render_loop, unsigned queue_mask); -- 2.30.2