radv: only flush CB meta in pipeline image barriers when needed
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 5 Jul 2018 10:54:18 +0000 (12:54 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 5 Jul 2018 15:20:16 +0000 (17:20 +0200)
If the given image doesn't enable CMASK, FMASK or DCC that's
useless to flush CB metadata.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_cmd_buffer.c
src/amd/vulkan/radv_private.h

index da6748edff2774627be9a4563463899a809af601..b7519dce49cb39adcbb00a6ef990a84b3e2f17eb 100644 (file)
@@ -1978,8 +1978,10 @@ radv_src_access_flush(struct radv_cmd_buffer *cmd_buffer,
                        flush_bits |= RADV_CMD_FLAG_WRITEBACK_GLOBAL_L2;
                        break;
                case VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT:
-                       flush_bits |= RADV_CMD_FLAG_FLUSH_AND_INV_CB |
-                                     RADV_CMD_FLAG_FLUSH_AND_INV_CB_META;
+                       flush_bits |= RADV_CMD_FLAG_FLUSH_AND_INV_CB;
+                       if (!image || (image && radv_image_has_CB_metadata(image))) {
+                               flush_bits |= RADV_CMD_FLAG_FLUSH_AND_INV_CB_META;
+                       }
                        break;
                case VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT:
                        flush_bits |= RADV_CMD_FLAG_FLUSH_AND_INV_DB;
index 0a34d79a206b57093fdbaaa2c41438a240df187a..4e4b3a6037a8b4ef245f62c04d5c5da0b9ad62b5 100644 (file)
@@ -1486,6 +1486,17 @@ radv_dcc_enabled(const struct radv_image *image, unsigned level)
               level < image->surface.num_dcc_levels;
 }
 
+/**
+ * Return whether the image has CB metadata.
+ */
+static inline bool
+radv_image_has_CB_metadata(const struct radv_image *image)
+{
+       return radv_image_has_cmask(image) ||
+              radv_image_has_fmask(image) ||
+              radv_image_has_dcc(image);
+}
+
 /**
  * Return whether the image has HTILE metadata for depth surfaces.
  */