[Mesa-dev] [PATCH 03/30] intel/isl: Add a helper for determining if a color is 0/1
Jason Ekstrand
jason at jlekstrand.net
Fri May 26 23:30:07 UTC 2017
---
src/intel/isl/isl.c | 19 +++++++++++++++++++
src/intel/isl/isl.h | 4 ++++
2 files changed, 23 insertions(+)
diff --git a/src/intel/isl/isl.c b/src/intel/isl/isl.c
index 321850e..4eec2fd 100644
--- a/src/intel/isl/isl.c
+++ b/src/intel/isl/isl.c
@@ -267,6 +267,25 @@ isl_tiling_get_info(const struct isl_device *dev,
return true;
}
+bool
+isl_color_value_is_zero_one(union isl_color_value value,
+ enum isl_format format)
+{
+ if (isl_format_has_int_channel(format)) {
+ for (unsigned i = 0; i < 4; i++) {
+ if (value.u32[i] != 0 && value.u32[i] != 1)
+ return false;
+ }
+ } else {
+ for (unsigned i = 0; i < 4; i++) {
+ if (value.f32[i] != 0.0f && value.f32[i] != 1.0f)
+ return false;
+ }
+ }
+
+ return true;
+}
+
/**
* @param[out] tiling is set only on success
*/
diff --git a/src/intel/isl/isl.h b/src/intel/isl/isl.h
index acc9e77..b9d8fa8 100644
--- a/src/intel/isl/isl.h
+++ b/src/intel/isl/isl.h
@@ -1370,6 +1370,10 @@ isl_extent4d(uint32_t width, uint32_t height, uint32_t depth,
return e;
}
+bool isl_color_value_is_zero_one(union isl_color_value value,
+ enum isl_format format);
+
+
#define isl_surf_init(dev, surf, ...) \
isl_surf_init_s((dev), (surf), \
&(struct isl_surf_init_info) { __VA_ARGS__ });
--
2.5.0.400.gff86faf
More information about the mesa-dev
mailing list