aboutsummaryrefslogtreecommitdiffstats
path: root/src/amd/vulkan
diff options
context:
space:
mode:
authorSamuel Pitoiset <[email protected]>2018-11-23 17:04:14 +0100
committerSamuel Pitoiset <[email protected]>2018-11-29 10:18:42 +0100
commit7484bc894b91331553c28393cee25646dd5a47d6 (patch)
tree05ecebabf0ec2f6a747d2168b2f649e64aea5219 /src/amd/vulkan
parentf78ee19702caddde5cd1b218f6324e4e02fd5fa2 (diff)
radv: refactor the fast clear path for better re-use
Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Bas Nieuwenhuizen <[email protected]>
Diffstat (limited to 'src/amd/vulkan')
-rw-r--r--src/amd/vulkan/radv_meta_clear.c78
1 files changed, 40 insertions, 38 deletions
diff --git a/src/amd/vulkan/radv_meta_clear.c b/src/amd/vulkan/radv_meta_clear.c
index 37b743e994a..d4da614584b 100644
--- a/src/amd/vulkan/radv_meta_clear.c
+++ b/src/amd/vulkan/radv_meta_clear.c
@@ -973,27 +973,18 @@ radv_can_fast_clear_depth(struct radv_cmd_buffer *cmd_buffer,
return true;
}
-static bool
-emit_fast_htile_clear(struct radv_cmd_buffer *cmd_buffer,
+static void
+radv_fast_clear_depth(struct radv_cmd_buffer *cmd_buffer,
+ const struct radv_image_view *iview,
const VkClearAttachment *clear_att,
- const VkClearRect *clear_rect,
enum radv_cmd_flush_bits *pre_flush,
enum radv_cmd_flush_bits *post_flush)
{
- const struct radv_subpass *subpass = cmd_buffer->state.subpass;
- const uint32_t pass_att = subpass->depth_stencil_attachment.attachment;
- VkImageLayout image_layout = subpass->depth_stencil_attachment.layout;
- const struct radv_framebuffer *fb = cmd_buffer->state.framebuffer;
- const struct radv_image_view *iview = fb->attachments[pass_att].attachment;
VkClearDepthStencilValue clear_value = clear_att->clearValue.depthStencil;
VkImageAspectFlags aspects = clear_att->aspectMask;
uint32_t clear_word, flush_bits;
uint32_t htile_mask;
- if (!radv_can_fast_clear_depth(cmd_buffer, iview, image_layout, aspects,
- clear_rect, clear_value))
- return false;
-
clear_word = radv_get_htile_fast_clear_value(iview->image, clear_value);
htile_mask = radv_get_htile_mask(iview->image, aspects);
@@ -1021,8 +1012,6 @@ emit_fast_htile_clear(struct radv_cmd_buffer *cmd_buffer,
if (post_flush) {
*post_flush |= flush_bits;
}
-
- return true;
}
static nir_shader *
@@ -1440,28 +1429,18 @@ radv_can_fast_clear_color(struct radv_cmd_buffer *cmd_buffer,
}
-static bool
-emit_fast_color_clear(struct radv_cmd_buffer *cmd_buffer,
+static void
+radv_fast_clear_color(struct radv_cmd_buffer *cmd_buffer,
+ const struct radv_image_view *iview,
const VkClearAttachment *clear_att,
- const VkClearRect *clear_rect,
+ uint32_t subpass_att,
enum radv_cmd_flush_bits *pre_flush,
- enum radv_cmd_flush_bits *post_flush,
- uint32_t view_mask)
+ enum radv_cmd_flush_bits *post_flush)
{
- const struct radv_subpass *subpass = cmd_buffer->state.subpass;
- const uint32_t subpass_att = clear_att->colorAttachment;
- const uint32_t pass_att = subpass->color_attachments[subpass_att].attachment;
- VkImageLayout image_layout = subpass->color_attachments[subpass_att].layout;
- const struct radv_framebuffer *fb = cmd_buffer->state.framebuffer;
- const struct radv_image_view *iview = fb->attachments[pass_att].attachment;
VkClearColorValue clear_value = clear_att->clearValue.color;
uint32_t clear_color[2], flush_bits = 0;
uint32_t cmask_clear_value;
- if (!radv_can_fast_clear_color(cmd_buffer, iview, image_layout,
- clear_rect, clear_value, view_mask))
- return false;
-
if (pre_flush) {
cmd_buffer->state.flush_bits |= (RADV_CMD_FLAG_FLUSH_AND_INV_CB |
RADV_CMD_FLAG_FLUSH_AND_INV_CB_META) & ~ *pre_flush;
@@ -1508,8 +1487,6 @@ emit_fast_color_clear(struct radv_cmd_buffer *cmd_buffer,
radv_update_color_clear_metadata(cmd_buffer, iview->image, subpass_att,
clear_color);
-
- return true;
}
/**
@@ -1523,16 +1500,41 @@ emit_clear(struct radv_cmd_buffer *cmd_buffer,
enum radv_cmd_flush_bits *post_flush,
uint32_t view_mask)
{
- if (clear_att->aspectMask & VK_IMAGE_ASPECT_COLOR_BIT) {
- if (!emit_fast_color_clear(cmd_buffer, clear_att, clear_rect,
- pre_flush, post_flush, view_mask))
+ const struct radv_framebuffer *fb = cmd_buffer->state.framebuffer;
+ const struct radv_subpass *subpass = cmd_buffer->state.subpass;
+ VkImageAspectFlags aspects = clear_att->aspectMask;
+
+ if (aspects & VK_IMAGE_ASPECT_COLOR_BIT) {
+ const uint32_t subpass_att = clear_att->colorAttachment;
+ const uint32_t pass_att = subpass->color_attachments[subpass_att].attachment;
+ VkImageLayout image_layout = subpass->color_attachments[subpass_att].layout;
+ const struct radv_image_view *iview = fb->attachments[pass_att].attachment;
+ VkClearColorValue clear_value = clear_att->clearValue.color;
+
+ if (radv_can_fast_clear_color(cmd_buffer, iview, image_layout,
+ clear_rect, clear_value, view_mask)) {
+ radv_fast_clear_color(cmd_buffer, iview, clear_att,
+ subpass_att, pre_flush,
+ post_flush);
+ } else {
emit_color_clear(cmd_buffer, clear_att, clear_rect, view_mask);
+ }
} else {
- assert(clear_att->aspectMask & (VK_IMAGE_ASPECT_DEPTH_BIT |
- VK_IMAGE_ASPECT_STENCIL_BIT));
- if (!emit_fast_htile_clear(cmd_buffer, clear_att, clear_rect,
- pre_flush, post_flush))
+ const uint32_t pass_att = subpass->depth_stencil_attachment.attachment;
+ VkImageLayout image_layout = subpass->depth_stencil_attachment.layout;
+ const struct radv_image_view *iview = fb->attachments[pass_att].attachment;
+ VkClearDepthStencilValue clear_value = clear_att->clearValue.depthStencil;
+
+ assert(aspects & (VK_IMAGE_ASPECT_DEPTH_BIT |
+ VK_IMAGE_ASPECT_STENCIL_BIT));
+
+ if (radv_can_fast_clear_depth(cmd_buffer, iview, image_layout,
+ aspects, clear_rect, clear_value)) {
+ radv_fast_clear_depth(cmd_buffer, iview, clear_att,
+ pre_flush, post_flush);
+ } else {
emit_depthstencil_clear(cmd_buffer, clear_att, clear_rect);
+ }
}
}