[Mesa-dev] [PATCH v3 03/44] nir: add auxiliary functions to detect if a mode is enabled

Samuel Iglesias Gonsálvez siglesias at igalia.com
Wed Feb 6 10:44:32 UTC 2019


Signed-off-by: Samuel Iglesias Gonsálvez <siglesias at igalia.com>
---
 src/compiler/nir/nir.h | 66 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)

diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 740c64d2a94..a84c46507e2 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -877,6 +877,72 @@ nir_get_nir_type_for_glsl_type(const struct glsl_type *type)
 nir_op nir_type_conversion_op(nir_alu_type src, nir_alu_type dst,
                               nir_rounding_mode rnd);
 
+static inline bool
+nir_is_float_control_signed_zero_inf_nan_preserve(unsigned execution_mode, unsigned bit_size)
+{
+   switch(bit_size) {
+   case 16:
+      if (execution_mode & SHADER_SIGNED_ZERO_INF_NAN_PRESERVE_FP16)
+         return true;
+      break;
+   case 32:
+      if (execution_mode & SHADER_SIGNED_ZERO_INF_NAN_PRESERVE_FP32)
+         return true;
+      break;
+   case 64:
+      if (execution_mode & SHADER_SIGNED_ZERO_INF_NAN_PRESERVE_FP64)
+         return true;
+      break;
+   default:
+      break;
+   }
+   return false;
+}
+
+static inline bool
+nir_is_rounding_mode_rtne(unsigned execution_mode, unsigned bit_size)
+{
+   switch(bit_size) {
+   case 16:
+      if (execution_mode & SHADER_ROUNDING_MODE_RTE_FP16)
+         return true;
+      break;
+   case 32:
+      if (execution_mode & SHADER_ROUNDING_MODE_RTE_FP32)
+         return true;
+      break;
+   case 64:
+      if (execution_mode & SHADER_ROUNDING_MODE_RTE_FP64)
+         return true;
+      break;
+   default:
+      break;
+   }
+   return false;
+}
+
+static inline bool
+nir_is_rounding_mode_rtz(unsigned execution_mode, unsigned bit_size)
+{
+   switch(bit_size) {
+   case 16:
+      if (execution_mode & SHADER_ROUNDING_MODE_RTZ_FP16)
+         return true;
+      break;
+   case 32:
+      if (execution_mode & SHADER_ROUNDING_MODE_RTZ_FP32)
+         return true;
+      break;
+   case 64:
+      if (execution_mode & SHADER_ROUNDING_MODE_RTZ_FP64)
+         return true;
+      break;
+   default:
+      break;
+   }
+   return false;
+}
+
 typedef enum {
    NIR_OP_IS_COMMUTATIVE = (1 << 0),
    NIR_OP_IS_ASSOCIATIVE = (1 << 1),
-- 
2.19.1



More information about the mesa-dev mailing list