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

Author: Erico Nunes <[email protected]>
Date:   Tue Apr 23 19:36:34 2019 +0200

lima/ppir: support nir_op_ftrunc

Support nir_op_ftrunc by turning it into a mov with a round to integer
output modifier.

Signed-off-by: Erico Nunes <[email protected]>
Reviewed-by: Qiang Yu <[email protected]>

---

 src/gallium/drivers/lima/ir/pp/lower.c | 12 ++++++++++++
 src/gallium/drivers/lima/ir/pp/nir.c   |  1 +
 src/gallium/drivers/lima/ir/pp/ppir.h  |  1 +
 3 files changed, 14 insertions(+)

diff --git a/src/gallium/drivers/lima/ir/pp/lower.c 
b/src/gallium/drivers/lima/ir/pp/lower.c
index 97243dcfa3f..ded92b150c5 100644
--- a/src/gallium/drivers/lima/ir/pp/lower.c
+++ b/src/gallium/drivers/lima/ir/pp/lower.c
@@ -389,6 +389,17 @@ static bool ppir_lower_select(ppir_block *block, ppir_node 
*node)
    return true;
 }
 
+static bool ppir_lower_trunc(ppir_block *block, ppir_node *node)
+{
+   /* Turn it into a mov with a round to integer output modifier */
+   ppir_alu_node *alu = ppir_node_to_alu(node);
+   ppir_dest *move_dest = &alu->dest;
+   move_dest->modifier = ppir_outmod_round;
+   node->op = ppir_op_mov;
+
+   return true;
+}
+
 static bool (*ppir_lower_funcs[ppir_op_num])(ppir_block *, ppir_node *) = {
    [ppir_op_const] = ppir_lower_const,
    [ppir_op_dot2] = ppir_lower_dot,
@@ -405,6 +416,7 @@ static bool (*ppir_lower_funcs[ppir_op_num])(ppir_block *, 
ppir_node *) = {
    [ppir_op_le] = ppir_lower_swap_args,
    [ppir_op_load_texture] = ppir_lower_texture,
    [ppir_op_select] = ppir_lower_select,
+   [ppir_op_trunc] = ppir_lower_trunc,
 };
 
 bool ppir_lower_prog(ppir_compiler *comp)
diff --git a/src/gallium/drivers/lima/ir/pp/nir.c 
b/src/gallium/drivers/lima/ir/pp/nir.c
index 008a5225edc..bdf54b227c6 100644
--- a/src/gallium/drivers/lima/ir/pp/nir.c
+++ b/src/gallium/drivers/lima/ir/pp/nir.c
@@ -150,6 +150,7 @@ static int nir_to_ppir_opcodes[nir_num_opcodes] = {
    [nir_op_fnot] = ppir_op_not,
    [nir_op_fcsel] = ppir_op_select,
    [nir_op_inot] = ppir_op_not,
+   [nir_op_ftrunc] = ppir_op_trunc,
 };
 
 static ppir_node *ppir_emit_alu(ppir_block *block, nir_instr *ni)
diff --git a/src/gallium/drivers/lima/ir/pp/ppir.h 
b/src/gallium/drivers/lima/ir/pp/ppir.h
index 60901018a58..71d80dc5196 100644
--- a/src/gallium/drivers/lima/ir/pp/ppir.h
+++ b/src/gallium/drivers/lima/ir/pp/ppir.h
@@ -78,6 +78,7 @@ typedef enum {
    ppir_op_mod,
    ppir_op_min,
    ppir_op_max,
+   ppir_op_trunc,
 
    ppir_op_dot2,
    ppir_op_dot3,

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

Reply via email to