[Mesa-dev] [PATCH 2/2] radv: only flush CB/DB metadata for subpass barriers when needed
Samuel Pitoiset
samuel.pitoiset at gmail.com
Thu Aug 23 14:04:36 UTC 2018
Shouldn't be required when the framebuffer doesn't use
CB or DB metadata.
Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
src/amd/vulkan/radv_cmd_buffer.c | 42 ++++++++++++++++++++++++--------
1 file changed, 32 insertions(+), 10 deletions(-)
diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c
index 2d66098873..933fcb9711 100644
--- a/src/amd/vulkan/radv_cmd_buffer.c
+++ b/src/amd/vulkan/radv_cmd_buffer.c
@@ -1969,7 +1969,8 @@ static void radv_stage_flush(struct radv_cmd_buffer *cmd_buffer,
static enum radv_cmd_flush_bits
radv_src_access_flush(struct radv_cmd_buffer *cmd_buffer,
VkAccessFlags src_flags,
- struct radv_image *image)
+ struct radv_image *image,
+ bool subpass)
{
bool flush_CB_meta = true, flush_DB_meta = true;
enum radv_cmd_flush_bits flush_bits = 0;
@@ -1980,6 +1981,16 @@ radv_src_access_flush(struct radv_cmd_buffer *cmd_buffer,
flush_CB_meta = false;
if (!radv_image_has_htile(image))
flush_DB_meta = false;
+ } else if (subpass) {
+ struct radv_framebuffer *framebuffer =
+ cmd_buffer->state.framebuffer;
+
+ if (framebuffer) {
+ if (!framebuffer->has_CB_metadata)
+ flush_CB_meta = false;
+ if (!framebuffer->has_DB_metadata)
+ flush_DB_meta = false;
+ }
}
for_each_bit(b, src_flags) {
@@ -2017,7 +2028,8 @@ radv_src_access_flush(struct radv_cmd_buffer *cmd_buffer,
static enum radv_cmd_flush_bits
radv_dst_access_flush(struct radv_cmd_buffer *cmd_buffer,
VkAccessFlags dst_flags,
- struct radv_image *image)
+ struct radv_image *image,
+ bool subpass)
{
bool flush_CB_meta = true, flush_DB_meta = true;
enum radv_cmd_flush_bits flush_bits = 0;
@@ -2048,6 +2060,16 @@ radv_dst_access_flush(struct radv_cmd_buffer *cmd_buffer,
image_is_coherent = true;
}
}
+ } else if (subpass) {
+ struct radv_framebuffer *framebuffer =
+ cmd_buffer->state.framebuffer;
+
+ if (framebuffer) {
+ if (!framebuffer->has_CB_metadata)
+ flush_CB_meta = false;
+ if (!framebuffer->has_DB_metadata)
+ flush_DB_meta = false;
+ }
}
for_each_bit(b, dst_flags) {
@@ -2093,10 +2115,10 @@ void radv_subpass_barrier(struct radv_cmd_buffer *cmd_buffer,
const struct radv_subpass_barrier *barrier)
{
cmd_buffer->state.flush_bits |= radv_src_access_flush(cmd_buffer, barrier->src_access_mask,
- NULL);
+ NULL, true);
radv_stage_flush(cmd_buffer, barrier->src_stage_mask);
cmd_buffer->state.flush_bits |= radv_dst_access_flush(cmd_buffer, barrier->dst_access_mask,
- NULL);
+ NULL, true);
}
static void radv_handle_subpass_image_transition(struct radv_cmd_buffer *cmd_buffer,
@@ -4282,25 +4304,25 @@ radv_barrier(struct radv_cmd_buffer *cmd_buffer,
for (uint32_t i = 0; i < memoryBarrierCount; i++) {
src_flush_bits |= radv_src_access_flush(cmd_buffer, pMemoryBarriers[i].srcAccessMask,
- NULL);
+ NULL, false);
dst_flush_bits |= radv_dst_access_flush(cmd_buffer, pMemoryBarriers[i].dstAccessMask,
- NULL);
+ NULL, false);
}
for (uint32_t i = 0; i < bufferMemoryBarrierCount; i++) {
src_flush_bits |= radv_src_access_flush(cmd_buffer, pBufferMemoryBarriers[i].srcAccessMask,
- NULL);
+ NULL, false);
dst_flush_bits |= radv_dst_access_flush(cmd_buffer, pBufferMemoryBarriers[i].dstAccessMask,
- NULL);
+ NULL, false);
}
for (uint32_t i = 0; i < imageMemoryBarrierCount; i++) {
RADV_FROM_HANDLE(radv_image, image, pImageMemoryBarriers[i].image);
src_flush_bits |= radv_src_access_flush(cmd_buffer, pImageMemoryBarriers[i].srcAccessMask,
- image);
+ image, false);
dst_flush_bits |= radv_dst_access_flush(cmd_buffer, pImageMemoryBarriers[i].dstAccessMask,
- image);
+ image, false);
}
radv_stage_flush(cmd_buffer, info->srcStageMask);
--
2.18.0
More information about the mesa-dev
mailing list