[Mesa-dev] [PATCH 23/59] glsl: Add 64-bit integer functions. (v2)

Ian Romanick idr at freedesktop.org
Thu Oct 27 02:50:36 UTC 2016


On 10/26/2016 01:45 PM, Matt Turner wrote:
> On Tue, Oct 25, 2016 at 5:59 PM, Ian Romanick <idr at freedesktop.org> wrote:
>> From: Dave Airlie <airlied at redhat.com>
>>
>> These are all the allowed 64-bit functions from ARB_gpu_shader_int64
>> spec.
>>
>> v2: restrict int64/double functions better.
>>
>> Signed-off-by: Dave Airlie <airlied at redhat.com>
>> Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
>> ---
>>  src/compiler/glsl/builtin_functions.cpp | 179 +++++++++++++++++++++++++++++++-
>>  1 file changed, 176 insertions(+), 3 deletions(-)
>>
>> diff --git a/src/compiler/glsl/builtin_functions.cpp b/src/compiler/glsl/builtin_functions.cpp
>> index 3e4bcbb..8ccb5d9 100644
>> --- a/src/compiler/glsl/builtin_functions.cpp
>> +++ b/src/compiler/glsl/builtin_functions.cpp
>> @@ -532,6 +532,18 @@ fp64(const _mesa_glsl_parse_state *state)
>>  }
>>
>>  static bool
>> +int64(const _mesa_glsl_parse_state *state)
>> +{
>> +   return state->has_int64();
>> +}
>> +
>> +static bool
>> +int64_fp64(const _mesa_glsl_parse_state *state)
>> +{
>> +   return state->has_int64() && state->has_double();
>> +}
>> +
>> +static bool
>>  compute_shader(const _mesa_glsl_parse_state *state)
>>  {
>>     return state->stage == MESA_SHADER_COMPUTE;
>> @@ -723,6 +735,12 @@ private:
>>     B1(floatBitsToUint)
>>     B1(intBitsToFloat)
>>     B1(uintBitsToFloat)
>> +
>> +   BA1(doubleBitsToInt64)
>> +   BA1(doubleBitsToUint64)
>> +   BA1(int64BitsToDouble)
>> +   BA1(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);
>> @@ -735,6 +753,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);
>> @@ -1184,7 +1206,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),  \
>> @@ -1198,6 +1220,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)                                                 \
>> @@ -1220,6 +1246,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)                                \
>> @@ -1261,6 +1295,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)                                                                 \
>> @@ -1299,6 +1341,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)
>> @@ -1333,8 +1390,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)
>> @@ -1411,6 +1468,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),
>> +
>> +
> 
> Two extra newlines.

Fixed locally.

>>                  NULL);



More information about the mesa-dev mailing list