[Mesa-dev] [PATCH v2 24/29] i965/fs: set rounding mode when emitting affected conversion instructions

Samuel Iglesias Gonsálvez siglesias at igalia.com
Tue Dec 18 10:34:19 UTC 2018


Signed-off-by: Samuel Iglesias Gonsálvez <siglesias at igalia.com>
---
 src/intel/compiler/brw_fs_nir.cpp | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/intel/compiler/brw_fs_nir.cpp b/src/intel/compiler/brw_fs_nir.cpp
index d9376e92220..be197b5f745 100644
--- a/src/intel/compiler/brw_fs_nir.cpp
+++ b/src/intel/compiler/brw_fs_nir.cpp
@@ -653,10 +653,15 @@ emit_find_msb_using_lzd(const fs_builder &bld,
 }
 
 static brw_rnd_mode
-brw_rnd_mode_from_nir_op (const nir_op op) {
+brw_rnd_mode_from_nir_op (const nir_op op)
+{
    switch (op) {
+   case nir_op_f2f64_rtz:
+   case nir_op_f2f32_rtz:
    case nir_op_f2f16_rtz:
       return BRW_RND_MODE_RTZ;
+   case nir_op_f2f64_rtne:
+   case nir_op_f2f32_rtne:
    case nir_op_f2f16_rtne:
       return BRW_RND_MODE_RTNE;
    default:
@@ -791,6 +796,9 @@ fs_visitor::nir_emit_alu(const fs_builder &bld, nir_alu_instr *instr)
 
    case nir_op_f2f64_rtne:
    case nir_op_f2f64_rtz:
+      bld.emit(SHADER_OPCODE_RND_MODE, bld.null_reg_ud(),
+               brw_imm_d(brw_rnd_mode_from_nir_op(instr->op)));
+      /* fallthrough */
    case nir_op_f2f64:
    case nir_op_f2i64:
    case nir_op_f2u64:
@@ -908,10 +916,16 @@ fs_visitor::nir_emit_alu(const fs_builder &bld, nir_alu_instr *instr)
          bld.MOV(tmp, op[0]);
          op[0] = tmp;
       }
-      /* Fallthrough */
+      inst = bld.MOV(result, op[0]);
+      inst->saturate = instr->dest.saturate;
+      break;
 
    case nir_op_f2f32_rtne:
    case nir_op_f2f32_rtz:
+      bld.emit(SHADER_OPCODE_RND_MODE, bld.null_reg_ud(),
+               brw_imm_d(brw_rnd_mode_from_nir_op(instr->op)));
+      /* Fallthrough */
+
    case nir_op_f2f32:
    case nir_op_f2i32:
    case nir_op_f2u32:
-- 
2.19.1



More information about the mesa-dev mailing list