diff options
author | Rafael Antognolli <[email protected]> | 2019-03-08 14:01:58 -0800 |
---|---|---|
committer | Rafael Antognolli <[email protected]> | 2019-03-20 16:46:25 -0700 |
commit | d97eddff25afce7a49975b9b2fab1bedb9d18843 (patch) | |
tree | 1d1e996107836cb42afcf92d449573374bcda1e6 /src/intel | |
parent | 7f6344a726b9e201189ace0a9d93b247729ad1d5 (diff) |
intel/isl: Add isl_format_has_color_component() function.
v2: Get luminance bits from luminance component (Ken).
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/intel')
-rw-r--r-- | src/intel/isl/isl.h | 3 | ||||
-rw-r--r-- | src/intel/isl/isl_format.c | 22 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/intel/isl/isl.h b/src/intel/isl/isl.h index a792e18e5d1..6790ba002ad 100644 --- a/src/intel/isl/isl.h +++ b/src/intel/isl/isl.h @@ -1503,6 +1503,9 @@ isl_format_has_int_channel(enum isl_format fmt) isl_format_has_sint_channel(fmt); } +bool isl_format_has_color_component(enum isl_format fmt, + int component) ATTRIBUTE_CONST; + unsigned isl_format_get_num_channels(enum isl_format fmt); uint32_t isl_format_get_depth_format(enum isl_format fmt, bool has_stencil); 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) { |