arb_gpu_shader_fp64: verify function parameter overloads

Submitted by Ilia Mirkin on June 17, 2015, 7:43 p.m.

Details

Message ID 1434570219-23944-1-git-send-email-imirkin@alum.mit.edu
State New
Headers show

Not browsing as part of any series.

Commit Message

Ilia Mirkin June 17, 2015, 7:43 p.m.
fp64 adds variants of all sorts of functions. make sure that we're still
able to resolve otherwise-ambiguous calls in the presence of gs5.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
---
 .../compiler/implicit-conversions-func.vert        | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 tests/spec/arb_gpu_shader_fp64/compiler/implicit-conversions-func.vert

Patch hide | download patch | download mbox

diff --git a/tests/spec/arb_gpu_shader_fp64/compiler/implicit-conversions-func.vert b/tests/spec/arb_gpu_shader_fp64/compiler/implicit-conversions-func.vert
new file mode 100644
index 0000000..224aecb
--- /dev/null
+++ b/tests/spec/arb_gpu_shader_fp64/compiler/implicit-conversions-func.vert
@@ -0,0 +1,22 @@ 
+// [config]
+// expect_result: pass
+// glsl_version: 1.50
+// require_extensions: GL_ARB_gpu_shader_fp64 GL_ARB_gpu_shader5
+// [end config]
+
+// Test that overloaded function selection still works in the presence
+// of new double variants. ARB_gpu_shader5 provides the overload
+// selection rules that allow the implementatino to pick one of the
+// candidates.
+
+#version 150
+#extension GL_ARB_gpu_shader_fp64: enable
+#extension GL_ARB_gpu_shader5: enable
+
+void foo(double a);
+void foo(float a);
+
+void test() {
+  mod(5, 6);
+  foo(5);
+}

Comments

On 06/17/2015 12:43 PM, Ilia Mirkin wrote:
> fp64 adds variants of all sorts of functions. make sure that we're still
> able to resolve otherwise-ambiguous calls in the presence of gs5.
> 
> Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
> ---
>  .../compiler/implicit-conversions-func.vert        | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
>  create mode 100644 tests/spec/arb_gpu_shader_fp64/compiler/implicit-conversions-func.vert
> 
> diff --git a/tests/spec/arb_gpu_shader_fp64/compiler/implicit-conversions-func.vert b/tests/spec/arb_gpu_shader_fp64/compiler/implicit-conversions-func.vert
> new file mode 100644
> index 0000000..224aecb
> --- /dev/null
> +++ b/tests/spec/arb_gpu_shader_fp64/compiler/implicit-conversions-func.vert
> @@ -0,0 +1,22 @@
> +// [config]
> +// expect_result: pass
> +// glsl_version: 1.50
> +// require_extensions: GL_ARB_gpu_shader_fp64 GL_ARB_gpu_shader5
> +// [end config]
> +
> +// Test that overloaded function selection still works in the presence
> +// of new double variants. ARB_gpu_shader5 provides the overload
> +// selection rules that allow the implementatino to pick one of the
                                     implementation

> +// candidates.
> +
> +#version 150
> +#extension GL_ARB_gpu_shader_fp64: enable
> +#extension GL_ARB_gpu_shader5: enable
> +
> +void foo(double a);
> +void foo(float a);
> +
> +void test() {
> +  mod(5, 6);
> +  foo(5);
> +}
> 

Which overload does the spec say is supposed to be used for foo(5)?  We
should provide an implementation for that overload, and make this a
linker test.
On Mon, Jun 22, 2015 at 12:22 PM, Ian Romanick <idr@freedesktop.org> wrote:
> On 06/17/2015 12:43 PM, Ilia Mirkin wrote:
>> fp64 adds variants of all sorts of functions. make sure that we're still
>> able to resolve otherwise-ambiguous calls in the presence of gs5.
>>
>> Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
>> ---
>>  .../compiler/implicit-conversions-func.vert        | 22 ++++++++++++++++++++++
>>  1 file changed, 22 insertions(+)
>>  create mode 100644 tests/spec/arb_gpu_shader_fp64/compiler/implicit-conversions-func.vert
>>
>> diff --git a/tests/spec/arb_gpu_shader_fp64/compiler/implicit-conversions-func.vert b/tests/spec/arb_gpu_shader_fp64/compiler/implicit-conversions-func.vert
>> new file mode 100644
>> index 0000000..224aecb
>> --- /dev/null
>> +++ b/tests/spec/arb_gpu_shader_fp64/compiler/implicit-conversions-func.vert
>> @@ -0,0 +1,22 @@
>> +// [config]
>> +// expect_result: pass
>> +// glsl_version: 1.50
>> +// require_extensions: GL_ARB_gpu_shader_fp64 GL_ARB_gpu_shader5
>> +// [end config]
>> +
>> +// Test that overloaded function selection still works in the presence
>> +// of new double variants. ARB_gpu_shader5 provides the overload
>> +// selection rules that allow the implementatino to pick one of the
>                                      implementation
>
>> +// candidates.
>> +
>> +#version 150
>> +#extension GL_ARB_gpu_shader_fp64: enable
>> +#extension GL_ARB_gpu_shader5: enable
>> +
>> +void foo(double a);
>> +void foo(float a);
>> +
>> +void test() {
>> +  mod(5, 6);
>> +  foo(5);
>> +}
>>
>
> Which overload does the spec say is supposed to be used for foo(5)?  We
> should provide an implementation for that overload, and make this a
> linker test.

The float one, I think. From ARB_gpu_shader5, see point #3:

     To determine whether the conversion for a single argument in one match is
     better than that for another match, the following rules are applied, in
     order:

       1. An exact match is better than a match involving any implicit
          conversion.

       2. A match involving an implicit conversion from float to double is
          better than a match involving any other implicit conversion.

       3. A match involving an implicit conversion from either int or uint to
          float is better than a match involving an implicit conversion from
          either int or uint to double.
On 06/22/2015 09:25 AM, Ilia Mirkin wrote:
> On Mon, Jun 22, 2015 at 12:22 PM, Ian Romanick <idr@freedesktop.org> wrote:
>> On 06/17/2015 12:43 PM, Ilia Mirkin wrote:
>>> fp64 adds variants of all sorts of functions. make sure that we're still
>>> able to resolve otherwise-ambiguous calls in the presence of gs5.
>>>
>>> Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
>>> ---
>>>  .../compiler/implicit-conversions-func.vert        | 22 ++++++++++++++++++++++
>>>  1 file changed, 22 insertions(+)
>>>  create mode 100644 tests/spec/arb_gpu_shader_fp64/compiler/implicit-conversions-func.vert
>>>
>>> diff --git a/tests/spec/arb_gpu_shader_fp64/compiler/implicit-conversions-func.vert b/tests/spec/arb_gpu_shader_fp64/compiler/implicit-conversions-func.vert
>>> new file mode 100644
>>> index 0000000..224aecb
>>> --- /dev/null
>>> +++ b/tests/spec/arb_gpu_shader_fp64/compiler/implicit-conversions-func.vert
>>> @@ -0,0 +1,22 @@
>>> +// [config]
>>> +// expect_result: pass
>>> +// glsl_version: 1.50
>>> +// require_extensions: GL_ARB_gpu_shader_fp64 GL_ARB_gpu_shader5
>>> +// [end config]
>>> +
>>> +// Test that overloaded function selection still works in the presence
>>> +// of new double variants. ARB_gpu_shader5 provides the overload
>>> +// selection rules that allow the implementatino to pick one of the
>>                                      implementation
>>
>>> +// candidates.
>>> +
>>> +#version 150
>>> +#extension GL_ARB_gpu_shader_fp64: enable
>>> +#extension GL_ARB_gpu_shader5: enable
>>> +
>>> +void foo(double a);
>>> +void foo(float a);
>>> +
>>> +void test() {
>>> +  mod(5, 6);
>>> +  foo(5);
>>> +}
>>>
>>
>> Which overload does the spec say is supposed to be used for foo(5)?  We
>> should provide an implementation for that overload, and make this a
>> linker test.
> 
> The float one, I think. From ARB_gpu_shader5, see point #3:

That was going to be my guess... mostly since that means the selected
overload wouldn't "change" with the addition of ARB_gpu_shader_fp64.
You can imagine a shader like:

#version 150
#extension GL_ARB_gpu_shader_fp64: enable
#extension GL_ARB_gpu_shader5: enable

#ifdef GL_ARB_gpu_shader_fp64
void foo(double a)
{
    ...
}
#endif

void foo(float a)
{
    ...
}

void main()
{
   foo(5);
}

It should be the same whether ARB_gpu_shader_fp64 is supported or not.

>      To determine whether the conversion for a single argument in one match is
>      better than that for another match, the following rules are applied, in
>      order:
> 
>        1. An exact match is better than a match involving any implicit
>           conversion.
> 
>        2. A match involving an implicit conversion from float to double is
>           better than a match involving any other implicit conversion.
> 
>        3. A match involving an implicit conversion from either int or uint to
>           float is better than a match involving an implicit conversion from
>           either int or uint to double.
>
On Mon, Jun 22, 2015 at 12:34 PM, Ian Romanick <idr@freedesktop.org> wrote:
> On 06/22/2015 09:25 AM, Ilia Mirkin wrote:
>> On Mon, Jun 22, 2015 at 12:22 PM, Ian Romanick <idr@freedesktop.org> wrote:
>>> On 06/17/2015 12:43 PM, Ilia Mirkin wrote:
>>>> fp64 adds variants of all sorts of functions. make sure that we're still
>>>> able to resolve otherwise-ambiguous calls in the presence of gs5.
>>>>
>>>> Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
>>>> ---
>>>>  .../compiler/implicit-conversions-func.vert        | 22 ++++++++++++++++++++++
>>>>  1 file changed, 22 insertions(+)
>>>>  create mode 100644 tests/spec/arb_gpu_shader_fp64/compiler/implicit-conversions-func.vert
>>>>
>>>> diff --git a/tests/spec/arb_gpu_shader_fp64/compiler/implicit-conversions-func.vert b/tests/spec/arb_gpu_shader_fp64/compiler/implicit-conversions-func.vert
>>>> new file mode 100644
>>>> index 0000000..224aecb
>>>> --- /dev/null
>>>> +++ b/tests/spec/arb_gpu_shader_fp64/compiler/implicit-conversions-func.vert
>>>> @@ -0,0 +1,22 @@
>>>> +// [config]
>>>> +// expect_result: pass
>>>> +// glsl_version: 1.50
>>>> +// require_extensions: GL_ARB_gpu_shader_fp64 GL_ARB_gpu_shader5
>>>> +// [end config]
>>>> +
>>>> +// Test that overloaded function selection still works in the presence
>>>> +// of new double variants. ARB_gpu_shader5 provides the overload
>>>> +// selection rules that allow the implementatino to pick one of the
>>>                                      implementation
>>>
>>>> +// candidates.
>>>> +
>>>> +#version 150
>>>> +#extension GL_ARB_gpu_shader_fp64: enable
>>>> +#extension GL_ARB_gpu_shader5: enable
>>>> +
>>>> +void foo(double a);
>>>> +void foo(float a);
>>>> +
>>>> +void test() {
>>>> +  mod(5, 6);
>>>> +  foo(5);
>>>> +}
>>>>
>>>
>>> Which overload does the spec say is supposed to be used for foo(5)?  We
>>> should provide an implementation for that overload, and make this a
>>> linker test.
>>
>> The float one, I think. From ARB_gpu_shader5, see point #3:
>
> That was going to be my guess... mostly since that means the selected
> overload wouldn't "change" with the addition of ARB_gpu_shader_fp64.
> You can imagine a shader like:
>
> #version 150
> #extension GL_ARB_gpu_shader_fp64: enable
> #extension GL_ARB_gpu_shader5: enable
>
> #ifdef GL_ARB_gpu_shader_fp64
> void foo(double a)
> {
>     ...
> }
> #endif
>
> void foo(float a)
> {
>     ...
> }
>
> void main()
> {
>    foo(5);
> }
>
> It should be the same whether ARB_gpu_shader_fp64 is supported or not.

Yeah, although the fun thing is that without the gs5 enable, it goes
from "working" (because GLSL <some low ver> says that you can always
implicitly convert an int to a float) without doubles to "compile
failure" with doubles because it can't resolve which overload to pick
between the float and double one. I'm not 100% sure if that's the
spec'd behaviour, but it's definitely mesa's.

  -ilia