summaryrefslogtreecommitdiff
path: root/src/intel/isl/isl_format.c
diff options
context:
space:
mode:
authorJason Ekstrand <jason.ekstrand@intel.com>2017-02-01 11:46:54 -0800
committerJason Ekstrand <jason.ekstrand@intel.com>2017-02-02 13:33:43 -0800
commit7e6a9d9c4b59e84aad81c128ae3dce9d2f3d1167 (patch)
tree26e11d333154425c26264d0b447a9efc5423da18 /src/intel/isl/isl_format.c
parent6142e3c07c051371de27a1b41f6986e03ad30c0d (diff)
intel/isl: Add a formats_are_ccs_e_compatible helper
Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com> Reviewed-by: Chad Versace <chadversary@chromium.org> Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
Diffstat (limited to 'src/intel/isl/isl_format.c')
-rw-r--r--src/intel/isl/isl_format.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/intel/isl/isl_format.c b/src/intel/isl/isl_format.c
index ed5a0636eb4..ef6c98d50b3 100644
--- a/src/intel/isl/isl_format.c
+++ b/src/intel/isl/isl_format.c
@@ -504,6 +504,37 @@ isl_format_supports_multisampling(const struct gen_device_info *devinfo,
}
}
+/**
+ * Returns true if the two formats are "CCS_E compatible" meaning that you can
+ * render in one format with CCS_E enabled and then texture using the other
+ * format without needing a resolve.
+ *
+ * Note: Even if the formats are compatible, special care must be taken if a
+ * clear color is involved because the encoding of the clear color is heavily
+ * format-dependent.
+ */
+bool
+isl_formats_are_ccs_e_compatible(const struct gen_device_info *devinfo,
+ enum isl_format format1,
+ enum isl_format format2)
+{
+ /* They must support CCS_E */
+ if (!isl_format_supports_ccs_e(devinfo, format1) ||
+ !isl_format_supports_ccs_e(devinfo, format2))
+ return false;
+
+ const struct isl_format_layout *fmtl1 = isl_format_get_layout(format1);
+ const struct isl_format_layout *fmtl2 = isl_format_get_layout(format2);
+
+ /* The compression used by CCS is not dependent on the actual data encoding
+ * of the format but only depends on the bit-layout of the channels.
+ */
+ return fmtl1->channels.r.bits == fmtl2->channels.r.bits &&
+ fmtl1->channels.g.bits == fmtl2->channels.g.bits &&
+ fmtl1->channels.b.bits == fmtl2->channels.b.bits &&
+ fmtl1->channels.a.bits == fmtl2->channels.a.bits;
+}
+
static inline bool
isl_format_has_channel_type(enum isl_format fmt, enum isl_base_type type)
{