[Mesa-dev] [PATCH 25/50] glsl: Add "built-in" functions to do 64x64 => 64 multiplication
Ian Romanick
idr at freedesktop.org
Thu Dec 1 16:17:13 UTC 2016
On 11/30/2016 12:19 PM, Matt Turner wrote:
> On 11/28, Ian Romanick wrote:
>> From: Ian Romanick <ian.d.romanick at intel.com>
[snip]
>> + if (parser->extension_list) {
>> + /* If MESA_shader_integer_functions is supported, then the
>> building
>> + * blocks required for the 64x64 => 64 multiply exist. Add
>> defines for
>> + * those functions so that they can be tested.
>> + */
>> + if (parser->extension_list->MESA_shader_integer_functions) {
>> + add_builtin_define(parser, "__have_builtin_builtin_umul64", 1);
>
> Just FYI, Clang has a similar mechanism called __has_builtin(x). It
> might be nice to match that, but not a big deal either way.
>
> http://clang.llvm.org/docs/LanguageExtensions.html#feature-checking-macros
I'll take a look at that. I'm definitely in favor of using a solution
that may be more familiar to people. I used the simple define because
it was the least typing. :)
>> + }
>> + }
>> +
>> if (explicitly_set) {
>> ralloc_asprintf_rewrite_tail(&parser->output,
>> &parser->output_length,
>> "#version %" PRIiMAX "%s%s", version,
[snip]
>> diff --git a/src/compiler/glsl/int64.glsl b/src/compiler/glsl/int64.glsl
>> new file mode 100644
>> index 0000000..f5fb010
>> --- /dev/null
>> +++ b/src/compiler/glsl/int64.glsl
>> @@ -0,0 +1,19 @@
>> +/* Compile with:
>> + *
>> + * glsl_compiler --version 140 --dump-builder int64.glsl >
>> builtin_int64.h
>> + *
>> + * Using version 1.40+ prevents built-in variables from being included.
>> + */
>
> I'm not in love with checking in generated code, but I detest the
> build-time bootstrapping... so I guess I'm okay with this.
I'd much rather build-time bootstrap, but I don't think there's any way
to make it work across the platforms that Mesa supports and
cross-builds. At least I couldn't think of a way that wasn't excruciating.
> If it were just this and sign64, I'd definitely advocate for just coding
> them directly.
This is also something of a test-run for the soft fp64 work that is
coming. We'll use a similar mechanism for that. I want to make sure we
end up with something that... we like as much as we can before it gets
too embedded.
>> +#version 140
>> +#extension GL_MESA_shader_integer_functions: require
>> +
>> +uvec2
>> +umul64(uvec2 a, uvec2 b)
>> +{
>> + uvec2 result;
>> +
>> + umulExtended(a.x, b.x, result.y, result.x);
>> + result.y += a.x * b.y + a.y * b.x;
>> +
>> + return result;
>> +}
>> --
>> 2.7.4
>>
More information about the mesa-dev
mailing list