[Mesa-dev] [PATCH 34/47] glsl: Add a lowering pass for 64-bit float trunc()
Elie Tournier
tournier.elie at gmail.com
Wed Aug 23 11:08:04 UTC 2017
Signed-off-by: Elie Tournier <elie.tournier at collabora.com>
---
src/compiler/glsl/ir_optimization.h | 1 +
src/compiler/glsl/lower_64bit.cpp | 7 +++++++
src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 3 ++-
3 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/compiler/glsl/ir_optimization.h b/src/compiler/glsl/ir_optimization.h
index 7a5a30541f..3566673d30 100644
--- a/src/compiler/glsl/ir_optimization.h
+++ b/src/compiler/glsl/ir_optimization.h
@@ -75,6 +75,7 @@
#define D2F (1U << 14)
#define F2D (1U << 15)
#define SQRT64 (1U << 16)
+#define TRUNC64 (1U << 17)
/**
* \see class lower_packing_builtins_visitor
diff --git a/src/compiler/glsl/lower_64bit.cpp b/src/compiler/glsl/lower_64bit.cpp
index 3681c4f0c5..0bbcfacf2a 100644
--- a/src/compiler/glsl/lower_64bit.cpp
+++ b/src/compiler/glsl/lower_64bit.cpp
@@ -494,6 +494,13 @@ lower_64bit_visitor::handle_rvalue(ir_rvalue **rvalue)
}
break;
+ case ir_unop_trunc:
+ if (lowering(TRUNC64)) {
+ if (ir->type->base_type == GLSL_TYPE_DOUBLE)
+ *rvalue = handle_op(ir, "__builtin_ftrunc64", generate_ir::ftrunc64);
+ }
+ break;
+
case ir_unop_u2d:
if (lowering(U2D)) {
if (ir->type->base_type == GLSL_TYPE_DOUBLE)
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 474e9bcdea..f746c5531a 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -7072,7 +7072,8 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
I2D |
D2F |
F2D |
- SQRT64;
+ SQRT64 |
+ TRUNC64;
lower_64bit_double_instructions(ir, lower_inst);
}
--
2.14.1
More information about the mesa-dev
mailing list