summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElie Tournier <tournier.elie@gmail.com>2017-08-10 17:32:44 +0100
committerDave Airlie <airlied@redhat.com>2018-01-18 14:16:26 +1000
commita68c4cea396b5ebf0b9d92fe375f1c7f01a088dc (patch)
tree662bd1c80b7e2c55092e65faf751fb155dd2ed2d
parentf46e4f1c9c94694a8f9d8dc91a746e82130ee668 (diff)
glsl: Add a lowering pass for 64-bit float d2i()
Signed-off-by: Elie Tournier <elie.tournier@collabora.com>
-rw-r--r--src/compiler/glsl/ir_optimization.h1
-rw-r--r--src/compiler/glsl/lower_64bit.cpp7
-rw-r--r--src/mesa/state_tracker/st_glsl_to_tgsi.cpp3
3 files changed, 10 insertions, 1 deletions
diff --git a/src/compiler/glsl/ir_optimization.h b/src/compiler/glsl/ir_optimization.h
index 068e05fa4e4..dace4a24075 100644
--- a/src/compiler/glsl/ir_optimization.h
+++ b/src/compiler/glsl/ir_optimization.h
@@ -70,6 +70,7 @@
#define ADD64 (1U << 9)
#define D2U (1U << 10)
#define U2D (1U << 11)
+#define D2I (1U << 12)
/**
* \see class lower_packing_builtins_visitor
diff --git a/src/compiler/glsl/lower_64bit.cpp b/src/compiler/glsl/lower_64bit.cpp
index 38b0420baa5..41255094ecb 100644
--- a/src/compiler/glsl/lower_64bit.cpp
+++ b/src/compiler/glsl/lower_64bit.cpp
@@ -436,6 +436,13 @@ lower_64bit_visitor::handle_rvalue(ir_rvalue **rvalue)
}
break;
+ case ir_unop_d2i:
+ if (lowering(D2I)) {
+ if (ir->type->base_type == GLSL_TYPE_INT)
+ *rvalue = handle_op(ir, "__builtin_fp64_to_int", generate_ir::fp64_to_int);
+ }
+ break;
+
case ir_unop_d2u:
if (lowering(D2U)) {
if (ir->type->base_type == GLSL_TYPE_UINT)
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 86fff916bb5..a29c7e80a8b 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -6980,7 +6980,8 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
ADD64 |
MUL64 |
D2U |
- U2D;
+ U2D |
+ D2I;
lower_64bit_double_instructions(ir, lower_inst);
}