Module: Mesa
Branch: master
Commit: cb95065dd122a09159ecf6f00d6ae03c6014fb10
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=cb95065dd122a09159ecf6f00d6ae03c6014fb10

Author: Jason Ekstrand <[email protected]>
Date:   Thu Oct  1 10:09:35 2020 -0500

nir: Add lowering from regular ALU conversions to the intrinsic

Reviewed-by: Jesse Natalie <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6945>

---

 src/compiler/nir/nir.h                         |  1 +
 src/compiler/nir/nir_lower_convert_alu_types.c | 24 ++++++++++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index d1024175838..75da5ce43cb 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -4388,6 +4388,7 @@ bool nir_opt_simplify_convert_alu_types(nir_shader 
*shader);
 bool nir_lower_convert_alu_types(nir_shader *shader,
                                  bool (*should_lower)(nir_intrinsic_instr *));
 bool nir_lower_constant_convert_alu_types(nir_shader *shader);
+bool nir_lower_alu_covnersion_to_intrinsic(nir_shader *shader);
 bool nir_lower_int_to_float(nir_shader *shader);
 bool nir_lower_load_const_to_scalar(nir_shader *shader);
 bool nir_lower_read_invocation_to_scalar(nir_shader *shader);
diff --git a/src/compiler/nir/nir_lower_convert_alu_types.c 
b/src/compiler/nir/nir_lower_convert_alu_types.c
index d2594b8a50d..0e94949cef8 100644
--- a/src/compiler/nir/nir_lower_convert_alu_types.c
+++ b/src/compiler/nir/nir_lower_convert_alu_types.c
@@ -180,3 +180,27 @@ nir_lower_constant_convert_alu_types(nir_shader *shader)
 {
    return nir_lower_convert_alu_types(shader, is_constant);
 }
+
+static bool
+is_alu_conversion(const nir_instr *instr, UNUSED const void *_data)
+{
+   return instr->type == nir_instr_type_alu &&
+          nir_op_infos[nir_instr_as_alu(instr)->op].is_conversion;
+}
+
+static nir_ssa_def *
+lower_alu_conversion(nir_builder *b, nir_instr *instr, UNUSED void *_data)
+{
+   nir_alu_instr *alu = nir_instr_as_alu(instr);
+   return nir_convert_alu_types(b, nir_ssa_for_alu_src(b, alu, 0),
+                                nir_op_infos[alu->op].input_types[0],
+                                nir_op_infos[alu->op].output_type,
+                                nir_rounding_mode_undef, false);
+}
+
+bool
+nir_lower_alu_covnersion_to_intrinsic(nir_shader *shader)
+{
+   return nir_shader_lower_instructions(shader, is_alu_conversion,
+                                        lower_alu_conversion, NULL);
+}

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to