summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir/nir_search_helpers.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler/nir/nir_search_helpers.h')
-rw-r--r--src/compiler/nir/nir_search_helpers.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_search_helpers.h b/src/compiler/nir/nir_search_helpers.h
index 50379441265..20fdae66e2c 100644
--- a/src/compiler/nir/nir_search_helpers.h
+++ b/src/compiler/nir/nir_search_helpers.h
@@ -91,4 +91,27 @@ is_neg_power_of_two(nir_alu_instr *instr, unsigned src, unsigned num_components,
return true;
}
+static inline bool
+is_zero_to_one(nir_alu_instr *instr, unsigned src, unsigned num_components,
+ const uint8_t *swizzle)
+{
+ nir_const_value *val = nir_src_as_const_value(instr->src[src].src);
+
+ if (!val)
+ return false;
+
+ for (unsigned i = 0; i < num_components; i++) {
+ switch (nir_op_infos[instr->op].input_types[src]) {
+ case nir_type_float:
+ if (val->f32[swizzle[i]] < 0.0f || val->f32[swizzle[i]] > 1.0f)
+ return false;
+ break;
+ default:
+ return false;
+ }
+ }
+
+ return true;
+}
+
#endif /* _NIR_SEARCH_ */