summaryrefslogtreecommitdiff
path: root/src/intel/isl/isl_format.c
diff options
context:
space:
mode:
authorRafael Antognolli <rafael.antognolli@intel.com>2019-03-08 14:01:58 -0800
committerRafael Antognolli <rafael.antognolli@intel.com>2019-03-20 16:46:25 -0700
commitd97eddff25afce7a49975b9b2fab1bedb9d18843 (patch)
tree1d1e996107836cb42afcf92d449573374bcda1e6 /src/intel/isl/isl_format.c
parent7f6344a726b9e201189ace0a9d93b247729ad1d5 (diff)
intel/isl: Add isl_format_has_color_component() function.
v2: Get luminance bits from luminance component (Ken). Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Diffstat (limited to 'src/intel/isl/isl_format.c')
-rw-r--r--src/intel/isl/isl_format.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/intel/isl/isl_format.c b/src/intel/isl/isl_format.c
index 968f981cdee..b429e7779a4 100644
--- a/src/intel/isl/isl_format.c
+++ b/src/intel/isl/isl_format.c
@@ -688,6 +688,28 @@ isl_format_has_sint_channel(enum isl_format fmt)
return isl_format_has_channel_type(fmt, ISL_SINT);
}
+bool
+isl_format_has_color_component(enum isl_format fmt, int component)
+{
+ const struct isl_format_layout *fmtl = isl_format_get_layout(fmt);
+ const uint8_t intensity = fmtl->channels.i.bits;
+ const uint8_t luminance = fmtl->channels.l.bits;
+
+ switch (component) {
+ case 0:
+ return (fmtl->channels.r.bits + intensity + luminance) > 0;
+ case 1:
+ return (fmtl->channels.g.bits + intensity + luminance) > 0;
+ case 2:
+ return (fmtl->channels.b.bits + intensity + luminance) > 0;
+ case 3:
+ return (fmtl->channels.a.bits + intensity) > 0;
+ default:
+ assert(!"Invalid color component: must be 0..3");
+ return false;
+ }
+}
+
unsigned
isl_format_get_num_channels(enum isl_format fmt)
{