[Mesa-dev] [PATCH 17/21] i965: Define consistent interface to enable instruction result saturation.

Francisco Jerez currojerez at riseup.net
Tue Apr 28 10:08:33 PDT 2015


---
 src/mesa/drivers/dri/i965/brw_ir_fs.h    | 11 +++++++++++
 src/mesa/drivers/dri/i965/brw_ir_svec4.h | 15 +++++++++++++++
 src/mesa/drivers/dri/i965/brw_ir_vec4.h  | 11 +++++++++++
 3 files changed, 37 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_ir_fs.h b/src/mesa/drivers/dri/i965/brw_ir_fs.h
index d6f40ee..7e5083c 100644
--- a/src/mesa/drivers/dri/i965/brw_ir_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_ir_fs.h
@@ -362,4 +362,15 @@ exec_condmod(enum brw_conditional_mod mod, fs_inst *inst)
    return inst;
 }
 
+/**
+ * Clamp the result of \p inst to the saturation range of its destination
+ * datatype.
+ */
+static inline fs_inst *
+exec_saturate(bool saturate, fs_inst *inst)
+{
+   inst->saturate = saturate;
+   return inst;
+}
+
 #endif
diff --git a/src/mesa/drivers/dri/i965/brw_ir_svec4.h b/src/mesa/drivers/dri/i965/brw_ir_svec4.h
index 4be3554..508ed5e 100644
--- a/src/mesa/drivers/dri/i965/brw_ir_svec4.h
+++ b/src/mesa/drivers/dri/i965/brw_ir_svec4.h
@@ -424,6 +424,21 @@ namespace brw {
 
       return inst;
    }
+
+   /**
+    * Clamp the result of \p inst to the saturation range of its destination
+    * datatype.
+    */
+   inline svec4_inst *
+   exec_saturate(bool saturate, svec4_inst *inst)
+   {
+      for (unsigned i = 0; i < ARRAY_SIZE(inst->v); ++i) {
+         if (inst->v[i])
+            exec_saturate(saturate, inst->v[i]);
+      }
+
+      return inst;
+   }
 }
 
 #endif
diff --git a/src/mesa/drivers/dri/i965/brw_ir_vec4.h b/src/mesa/drivers/dri/i965/brw_ir_vec4.h
index c4021d8..a407ec4 100644
--- a/src/mesa/drivers/dri/i965/brw_ir_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_ir_vec4.h
@@ -363,6 +363,17 @@ exec_condmod(enum brw_conditional_mod mod, vec4_instruction *inst)
    inst->conditional_mod = mod;
    return inst;
 }
+
+/**
+ * Clamp the result of \p inst to the saturation range of its destination
+ * datatype.
+ */
+inline vec4_instruction *
+exec_saturate(bool saturate, vec4_instruction *inst)
+{
+   inst->saturate = saturate;
+   return inst;
+}
 } /* namespace brw */
 
 #endif
-- 
2.3.5



More information about the mesa-dev mailing list