From: Dave Airlie <airl...@redhat.com>

These are all the allowed 64-bit functions from ARB_gpu_shader_int64
spec.

Signed-off-by: Dave Airlie <airl...@redhat.com>
---
 src/compiler/glsl/builtin_functions.cpp | 173 +++++++++++++++++++++++++++++++-
 1 file changed, 170 insertions(+), 3 deletions(-)

diff --git a/src/compiler/glsl/builtin_functions.cpp 
b/src/compiler/glsl/builtin_functions.cpp
index db0dcb6..29999bb 100644
--- a/src/compiler/glsl/builtin_functions.cpp
+++ b/src/compiler/glsl/builtin_functions.cpp
@@ -510,6 +510,12 @@ fp64(const _mesa_glsl_parse_state *state)
 }
 
 static bool
+int64(const _mesa_glsl_parse_state *state)
+{
+   return state->has_int64();
+}
+
+static bool
 compute_shader(const _mesa_glsl_parse_state *state)
 {
    return state->stage == MESA_SHADER_COMPUTE;
@@ -704,6 +710,12 @@ private:
    B1(floatBitsToUint)
    B1(intBitsToFloat)
    B1(uintBitsToFloat)
+
+   B1(doubleBitsToInt64)
+   B1(doubleBitsToUint64)
+   B1(int64BitsToDouble)
+   B1(uint64BitsToDouble)
+
    ir_function_signature *_packUnorm2x16(builtin_available_predicate avail);
    ir_function_signature *_packSnorm2x16(builtin_available_predicate avail);
    ir_function_signature *_packUnorm4x8(builtin_available_predicate avail);
@@ -716,6 +728,10 @@ private:
    ir_function_signature *_unpackHalf2x16(builtin_available_predicate avail);
    ir_function_signature *_packDouble2x32(builtin_available_predicate avail);
    ir_function_signature *_unpackDouble2x32(builtin_available_predicate avail);
+   ir_function_signature *_packInt2x32(builtin_available_predicate avail);
+   ir_function_signature *_unpackInt2x32(builtin_available_predicate avail);
+   ir_function_signature *_packUint2x32(builtin_available_predicate avail);
+   ir_function_signature *_unpackUint2x32(builtin_available_predicate avail);
 
    BA1(length)
    BA1(distance);
@@ -1140,7 +1156,7 @@ builtin_builder::create_builtins()
                 _##NAME(glsl_type::ivec4_type), \
                 NULL);
 
-#define FID(NAME)                                \
+#define FI64(NAME)                                \
    add_function(#NAME,                          \
                 _##NAME(always_available, glsl_type::float_type), \
                 _##NAME(always_available, glsl_type::vec2_type),  \
@@ -1154,6 +1170,10 @@ builtin_builder::create_builtins()
                 _##NAME(fp64, glsl_type::dvec2_type),  \
                 _##NAME(fp64, glsl_type::dvec3_type),  \
                 _##NAME(fp64, glsl_type::dvec4_type),  \
+                _##NAME(int64, glsl_type::int64_t_type), \
+                _##NAME(int64, glsl_type::i64vec2_type),  \
+                _##NAME(int64, glsl_type::i64vec3_type),  \
+                _##NAME(int64, glsl_type::i64vec4_type),  \
                 NULL);
 
 #define FIUD(NAME)                                                 \
@@ -1176,6 +1196,14 @@ builtin_builder::create_builtins()
                 _##NAME(fp64, glsl_type::dvec2_type),  \
                 _##NAME(fp64, glsl_type::dvec3_type),  \
                 _##NAME(fp64, glsl_type::dvec4_type),  \
+                _##NAME(int64, glsl_type::int64_t_type), \
+                _##NAME(int64, glsl_type::i64vec2_type),  \
+                _##NAME(int64, glsl_type::i64vec3_type),  \
+                _##NAME(int64, glsl_type::i64vec4_type),  \
+                _##NAME(int64, glsl_type::uint64_t_type), \
+                _##NAME(int64, glsl_type::u64vec2_type),  \
+                _##NAME(int64, glsl_type::u64vec3_type),  \
+                _##NAME(int64, glsl_type::u64vec4_type),  \
                 NULL);
 
 #define IU(NAME)                                \
@@ -1217,6 +1245,14 @@ builtin_builder::create_builtins()
                 _##NAME(fp64, glsl_type::dvec2_type), \
                 _##NAME(fp64, glsl_type::dvec3_type), \
                 _##NAME(fp64, glsl_type::dvec4_type), \
+                _##NAME(int64, glsl_type::int64_t_type), \
+                _##NAME(int64, glsl_type::i64vec2_type),  \
+                _##NAME(int64, glsl_type::i64vec3_type),  \
+                _##NAME(int64, glsl_type::i64vec4_type),  \
+                _##NAME(int64, glsl_type::uint64_t_type), \
+                _##NAME(int64, glsl_type::u64vec2_type),  \
+                _##NAME(int64, glsl_type::u64vec3_type),  \
+                _##NAME(int64, glsl_type::u64vec4_type),  \
                 NULL);
 
 #define FIUD2_MIXED(NAME)                                                      
           \
@@ -1255,6 +1291,21 @@ builtin_builder::create_builtins()
                 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::dvec2_type),   
        \
                 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::dvec3_type),   
        \
                 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::dvec4_type),   
        \
+                                                                        \
+                _##NAME(int64, glsl_type::int64_t_type, 
glsl_type::int64_t_type),           \
+                _##NAME(int64, glsl_type::i64vec2_type, 
glsl_type::int64_t_type),           \
+                _##NAME(int64, glsl_type::i64vec3_type, 
glsl_type::int64_t_type),           \
+                _##NAME(int64, glsl_type::i64vec4_type, 
glsl_type::int64_t_type),           \
+                _##NAME(int64, glsl_type::i64vec2_type, 
glsl_type::i64vec2_type),           \
+                _##NAME(int64, glsl_type::i64vec3_type, 
glsl_type::i64vec3_type),           \
+                _##NAME(int64, glsl_type::i64vec4_type, 
glsl_type::i64vec4_type),           \
+                _##NAME(int64, glsl_type::uint64_t_type, 
glsl_type::uint64_t_type),           \
+                _##NAME(int64, glsl_type::u64vec2_type, 
glsl_type::uint64_t_type),           \
+                _##NAME(int64, glsl_type::u64vec3_type, 
glsl_type::uint64_t_type),           \
+                _##NAME(int64, glsl_type::u64vec4_type, 
glsl_type::uint64_t_type),           \
+                _##NAME(int64, glsl_type::u64vec2_type, 
glsl_type::u64vec2_type),           \
+                _##NAME(int64, glsl_type::u64vec3_type, 
glsl_type::u64vec3_type),           \
+                _##NAME(int64, glsl_type::u64vec4_type, 
glsl_type::u64vec4_type),           \
                 NULL);
 
    F(radians)
@@ -1289,8 +1340,8 @@ builtin_builder::create_builtins()
    F(log2)
    FD(sqrt)
    FD(inversesqrt)
-   FID(abs)
-   FID(sign)
+   FI64(abs)
+   FI64(sign)
    FD(floor)
    FD(trunc)
    FD(round)
@@ -1367,6 +1418,18 @@ builtin_builder::create_builtins()
                 _mix_sel(shader_integer_mix, glsl_type::bvec2_type, 
glsl_type::bvec2_type),
                 _mix_sel(shader_integer_mix, glsl_type::bvec3_type, 
glsl_type::bvec3_type),
                 _mix_sel(shader_integer_mix, glsl_type::bvec4_type, 
glsl_type::bvec4_type),
+
+                _mix_sel(int64, glsl_type::int64_t_type, glsl_type::bool_type),
+                _mix_sel(int64, glsl_type::i64vec2_type, 
glsl_type::bvec2_type),
+                _mix_sel(int64, glsl_type::i64vec3_type, 
glsl_type::bvec3_type),
+                _mix_sel(int64, glsl_type::i64vec4_type, 
glsl_type::bvec4_type),
+
+                _mix_sel(int64, glsl_type::uint64_t_type,  
glsl_type::bool_type),
+                _mix_sel(int64, glsl_type::u64vec2_type, 
glsl_type::bvec2_type),
+                _mix_sel(int64, glsl_type::u64vec3_type, 
glsl_type::bvec3_type),
+                _mix_sel(int64, glsl_type::u64vec4_type, 
glsl_type::bvec4_type),
+
+
                 NULL);
 
    add_function("step",
@@ -1425,6 +1488,34 @@ builtin_builder::create_builtins()
                 _uintBitsToFloat(glsl_type::uvec4_type),
                 NULL);
 
+   add_function("doubleBitsToInt64",
+                _doubleBitsToInt64(glsl_type::double_type),
+                _doubleBitsToInt64(glsl_type::dvec2_type),
+                _doubleBitsToInt64(glsl_type::dvec3_type),
+                _doubleBitsToInt64(glsl_type::dvec4_type),
+                NULL);
+
+   add_function("doubleBitsToUint64",
+                _doubleBitsToUint64(glsl_type::double_type),
+                _doubleBitsToUint64(glsl_type::dvec2_type),
+                _doubleBitsToUint64(glsl_type::dvec3_type),
+                _doubleBitsToUint64(glsl_type::dvec4_type),
+                NULL);
+
+   add_function("int64BitsToDouble",
+                _int64BitsToDouble(glsl_type::int64_t_type),
+                _int64BitsToDouble(glsl_type::i64vec2_type),
+                _int64BitsToDouble(glsl_type::i64vec3_type),
+                _int64BitsToDouble(glsl_type::i64vec4_type),
+                NULL);
+
+   add_function("uint64BitsToDouble",
+                _uint64BitsToDouble(glsl_type::uint64_t_type),
+                _uint64BitsToDouble(glsl_type::u64vec2_type),
+                _uint64BitsToDouble(glsl_type::u64vec3_type),
+                _uint64BitsToDouble(glsl_type::u64vec4_type),
+                NULL);
+
    add_function("packUnorm2x16",   
_packUnorm2x16(shader_packing_or_es3_or_gpu_shader5),   NULL);
    add_function("packSnorm2x16",   _packSnorm2x16(shader_packing_or_es3),      
            NULL);
    add_function("packUnorm4x8",    
_packUnorm4x8(shader_packing_or_es31_or_gpu_shader5),   NULL);
@@ -1438,6 +1529,10 @@ builtin_builder::create_builtins()
    add_function("packDouble2x32",    _packDouble2x32(fp64),                   
NULL);
    add_function("unpackDouble2x32",  _unpackDouble2x32(fp64),                 
NULL);
 
+   add_function("packInt2x32",     _packInt2x32(int64),                    
NULL);
+   add_function("unpackInt2x32",   _unpackInt2x32(int64),                  
NULL);
+   add_function("packUint2x32",    _packUint2x32(int64),                   
NULL);
+   add_function("unpackUint2x32",  _unpackUint2x32(int64),                 
NULL);
 
    FD(length)
    FD(distance)
@@ -3779,6 +3874,42 @@ builtin_builder::_uintBitsToFloat(const glsl_type *type)
 }
 
 ir_function_signature *
+builtin_builder::_doubleBitsToInt64(const glsl_type *type)
+{
+   ir_variable *x = in_var(type, "x");
+   MAKE_SIG(glsl_type::i64vec(type->vector_elements), shader_bit_encoding, 1, 
x);
+   body.emit(ret(bitcast_d2i64(x)));
+   return sig;
+}
+
+ir_function_signature *
+builtin_builder::_doubleBitsToUint64(const glsl_type *type)
+{
+   ir_variable *x = in_var(type, "x");
+   MAKE_SIG(glsl_type::u64vec(type->vector_elements), shader_bit_encoding, 1, 
x);
+   body.emit(ret(bitcast_d2u64(x)));
+   return sig;
+}
+
+ir_function_signature *
+builtin_builder::_int64BitsToDouble(const glsl_type *type)
+{
+   ir_variable *x = in_var(type, "x");
+   MAKE_SIG(glsl_type::dvec(type->vector_elements), shader_bit_encoding, 1, x);
+   body.emit(ret(bitcast_i642d(x)));
+   return sig;
+}
+
+ir_function_signature *
+builtin_builder::_uint64BitsToDouble(const glsl_type *type)
+{
+   ir_variable *x = in_var(type, "x");
+   MAKE_SIG(glsl_type::dvec(type->vector_elements), shader_bit_encoding, 1, x);
+   body.emit(ret(bitcast_u642d(x)));
+   return sig;
+}
+
+ir_function_signature *
 builtin_builder::_packUnorm2x16(builtin_available_predicate avail)
 {
    ir_variable *v = in_var(glsl_type::vec2_type, "v");
@@ -3888,6 +4019,42 @@ 
builtin_builder::_unpackDouble2x32(builtin_available_predicate avail)
 }
 
 ir_function_signature *
+builtin_builder::_packInt2x32(builtin_available_predicate avail)
+{
+   ir_variable *v = in_var(glsl_type::uvec2_type, "v");
+   MAKE_SIG(glsl_type::int64_t_type, avail, 1, v);
+   body.emit(ret(expr(ir_unop_pack_int_2x32, v)));
+   return sig;
+}
+
+ir_function_signature *
+builtin_builder::_unpackInt2x32(builtin_available_predicate avail)
+{
+   ir_variable *p = in_var(glsl_type::int64_t_type, "p");
+   MAKE_SIG(glsl_type::uvec2_type, avail, 1, p);
+   body.emit(ret(expr(ir_unop_unpack_int_2x32, p)));
+   return sig;
+}
+
+ir_function_signature *
+builtin_builder::_packUint2x32(builtin_available_predicate avail)
+{
+   ir_variable *v = in_var(glsl_type::uvec2_type, "v");
+   MAKE_SIG(glsl_type::uint64_t_type, avail, 1, v);
+   body.emit(ret(expr(ir_unop_pack_uint_2x32, v)));
+   return sig;
+}
+
+ir_function_signature *
+builtin_builder::_unpackUint2x32(builtin_available_predicate avail)
+{
+   ir_variable *p = in_var(glsl_type::uint64_t_type, "p");
+   MAKE_SIG(glsl_type::uvec2_type, avail, 1, p);
+   body.emit(ret(expr(ir_unop_unpack_uint_2x32, p)));
+   return sig;
+}
+
+ir_function_signature *
 builtin_builder::_length(builtin_available_predicate avail, const glsl_type 
*type)
 {
    ir_variable *x = in_var(type, "x");
-- 
2.5.5

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to