aboutsummaryrefslogtreecommitdiffstats
path: root/src/intel/isl/isl.c
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2017-07-17 19:48:22 -0700
committerJason Ekstrand <[email protected]>2017-07-22 20:59:22 -0700
commitd4de403f9191ed995e1684dbe50011e55cd62501 (patch)
treecd562ff18ead8db841d4b5dc77489062e7aad602 /src/intel/isl/isl.c
parentb26b2490e523443b4c967980bcc963ef9783333d (diff)
intel/isl: Add a helper for determining if a color is 0/1
Reviewed-by: Topi Pohjolainen <[email protected]>
Diffstat (limited to 'src/intel/isl/isl.c')
-rw-r--r--src/intel/isl/isl.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/intel/isl/isl.c b/src/intel/isl/isl.c
index 5465496b8f2..fba40caff41 100644
--- a/src/intel/isl/isl.c
+++ b/src/intel/isl/isl.c
@@ -268,6 +268,33 @@ isl_tiling_get_info(enum isl_tiling tiling,
};
}
+bool
+isl_color_value_is_zero_one(union isl_color_value value,
+ enum isl_format format)
+{
+ const struct isl_format_layout *fmtl = isl_format_get_layout(format);
+
+#define RETURN_FALSE_IF_NOT_0_1(c, i, field) \
+ if (fmtl->channels.c.bits && value.field[i] != 0 && value.field[i] != 1) \
+ return false
+
+ if (isl_format_has_int_channel(format)) {
+ RETURN_FALSE_IF_NOT_0_1(r, 0, u32);
+ RETURN_FALSE_IF_NOT_0_1(g, 1, u32);
+ RETURN_FALSE_IF_NOT_0_1(b, 2, u32);
+ RETURN_FALSE_IF_NOT_0_1(a, 3, u32);
+ } else {
+ RETURN_FALSE_IF_NOT_0_1(r, 0, f32);
+ RETURN_FALSE_IF_NOT_0_1(g, 1, f32);
+ RETURN_FALSE_IF_NOT_0_1(b, 2, f32);
+ RETURN_FALSE_IF_NOT_0_1(a, 3, f32);
+ }
+
+#undef RETURN_FALSE_IF_NOT_0_1
+
+ return true;
+}
+
/**
* @param[out] tiling is set only on success
*/