diff options
author | Dave Airlie <[email protected]> | 2016-06-09 09:58:40 +1000 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2017-01-20 15:41:23 -0800 |
commit | 85faf5082f06ed5828c6d97bb11dd2292ad0f86a (patch) | |
tree | a023baf7501c4d84077cc6adc49160474b32df6c /src/compiler/glsl/ir_constant_expression.cpp | |
parent | a68b6ee0630552c4bae685711940d5c0a5ab10fd (diff) |
glsl: Add 64-bit integer support for constant expressions
This just adds the new operations and add 64-bit integer support to all
the existing cases where it is needed.
v2: fix some issues found in testing.
v2.1: add unreachable (Ian), add missing int/uint pack/unpack (Dave).
v3 (idr): Rebase on top of idr's series to generate
ir_expression_operation_constant.h. In addition, this version:
Adds missing support for ir_unop_bit_not, ir_binop_all_equal,
ir_binop_any_nequal, ir_binop_vector_extract,
ir_triop_vector_insert, and ir_quadop_vector.
Removes support for uint64_t from ir_unop_abs and ir_unop_sign.
v4 (idr): "cut them down later" => Remove ir_unop_b2u64 and
ir_unop_u642b. Handle these with extra i2u or u2i casts just like
uint(bool) and bool(uint) conversion is done.
Signed-off-by: Dave Airlie <[email protected]>
Signed-off-by: Ian Romanick <[email protected]>
Reviewed-by: Ian Romanick <[email protected]> [v2]
Reviewed-by: Matt Turner <[email protected]> [v3]
Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/compiler/glsl/ir_constant_expression.cpp')
-rw-r--r-- | src/compiler/glsl/ir_constant_expression.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/compiler/glsl/ir_constant_expression.cpp b/src/compiler/glsl/ir_constant_expression.cpp index 54b203aeec8..cd3cd1bb592 100644 --- a/src/compiler/glsl/ir_constant_expression.cpp +++ b/src/compiler/glsl/ir_constant_expression.cpp @@ -88,6 +88,42 @@ bitcast_f2u(float f) return u; } +static double +bitcast_u642d(uint64_t u) +{ + assert(sizeof(double) == sizeof(uint64_t)); + double d; + memcpy(&d, &u, sizeof(d)); + return d; +} + +static double +bitcast_i642d(int64_t i) +{ + assert(sizeof(double) == sizeof(int64_t)); + double d; + memcpy(&d, &i, sizeof(d)); + return d; +} + +static double +bitcast_d2u64(double d) +{ + assert(sizeof(double) == sizeof(uint64_t)); + uint64_t u; + memcpy(&u, &d, sizeof(d)); + return u; +} + +static double +bitcast_d2i64(double d) +{ + assert(sizeof(double) == sizeof(int64_t)); + int64_t i; + memcpy(&i, &d, sizeof(d)); + return i; +} + /** * Evaluate one component of a floating-point 4x8 unpacking function. */ |