Re: [Mesa-dev] [PATCH 23/29] nir: add i2d and u2d opcodes

2016-03-22 Thread Jason Ekstrand
On Mar 22, 2016 8:19 AM, "Samuel Iglesias Gonsálvez" 
wrote:
>
>
>
> On 21/03/16 23:56, Jason Ekstrand wrote:
> > On Mon, Mar 21, 2016 at 5:06 AM, Samuel Iglesias Gonsálvez <
> > sigles...@igalia.com> wrote:
> >
> >> From: Iago Toral Quiroga 
> >>
> >> ---
> >>  src/compiler/nir/glsl_to_nir.cpp | 6 ++
> >>  src/compiler/nir/nir_opcodes.py  | 2 ++
> >>  2 files changed, 8 insertions(+)
> >>
> >> diff --git a/src/compiler/nir/glsl_to_nir.cpp
> >> b/src/compiler/nir/glsl_to_nir.cpp
> >> index 952d787..d087a77 100644
> >> --- a/src/compiler/nir/glsl_to_nir.cpp
> >> +++ b/src/compiler/nir/glsl_to_nir.cpp
> >> @@ -1357,6 +1357,12 @@ nir_visitor::visit(ir_expression *ir)
> >> case ir_unop_d2i:  result = nir_d2i(, srcs[0]);   break;
> >> case ir_unop_d2u:  result = nir_d2u(, srcs[0]);   break;
> >> case ir_unop_d2b:  result = nir_d2b(, srcs[0]);   break;
> >> +   case ir_unop_i2d:
> >> +  result = supports_ints ? nir_i2d(, srcs[0]) : nir_fmov(,
> >> srcs[0]);
> >> +  break;
> >> +   case ir_unop_u2d:
> >> +  result = supports_ints ? nir_u2d(, srcs[0]) : nir_fmov(,
> >> srcs[0]);
> >>
> >
> > If you're going to be using the u2d opcode, you'd better support
integers.
> >
>
> We did the same than integer to float conversions to keep this code
> aligned with what they do.

Right.  I don't think that would be correct for hardware that doesn't have
integers anyway.  You would want an ftrunc in the non-integer case with an
abs for f2u.  NIR has yet to be used on any platforms that don't support
native integers so all those cases de-paths are dead anyway.

> We can add an assert for support_ints here and only call to nir_u2d but,
> to be consistent, we would need to do similar changes to i2d, u2f, i2f
> too in a separate patch.

Feel free to add an assert. I don't think updating the others is needed.
It's not that f2u is invalid without integers so much as no hardware that
supports doubles won't have native integers.

> What do you think?
>
> Sam
>
> >
> >> +  break;
> >> case ir_unop_i2u:
> >> case ir_unop_u2i:
> >> case ir_unop_bitcast_i2f:
> >> diff --git a/src/compiler/nir/nir_opcodes.py
> >> b/src/compiler/nir/nir_opcodes.py
> >> index a161ac1..cf6ce83 100644
> >> --- a/src/compiler/nir/nir_opcodes.py
> >> +++ b/src/compiler/nir/nir_opcodes.py
> >> @@ -164,6 +164,7 @@ unop_convert("f2u", tuint32, tfloat32, "src0") #
> >> Float-to-unsigned conversion
> >>  unop_convert("d2i", tint32, tfloat64, "src0") # Double-to-integer
> >> conversion.
> >>  unop_convert("d2u", tuint32, tfloat64, "src0") # Double-to-unsigned
> >> conversion.
> >>  unop_convert("i2f", tfloat32, tint32, "src0") # Integer-to-float
> >> conversion.
> >> +unop_convert("i2d", tfloat64, tint32, "src0") # Integer-to-double
> >> conversion.
> >>  # Float-to-boolean conversion
> >>  unop_convert("f2b", tbool, tfloat32, "src0 != 0.0f")
> >>  unop_convert("d2b", tbool, tfloat64, "src0 != 0.0")
> >> @@ -173,6 +174,7 @@ unop_convert("b2f", tfloat32, tbool, "src0 ? 1.0f :
> >> 0.0f")
> >>  unop_convert("i2b", tbool, tint32, "src0 != 0")
> >>  unop_convert("b2i", tint32, tbool, "src0 ? 1 : 0") # Boolean-to-int
> >> conversion
> >>  unop_convert("u2f", tfloat32, tuint32, "src0") # Unsigned-to-float
> >> conversion.
> >> +unop_convert("u2d", tfloat64, tuint32, "src0") # Unsigned-to-double
> >> conversion.
> >>  # double-to-float conversion
> >>  unop_convert("d2f", tfloat32, tfloat64, "src0") # Single to double
> >> precision
> >>  unop_convert("f2d", tfloat64, tfloat32, "src0") # Double to single
> >> precision
> >> --
> >> 2.5.0
> >>
> >> ___
> >> mesa-dev mailing list
> >> mesa-dev@lists.freedesktop.org
> >> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> >>
> >
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 23/29] nir: add i2d and u2d opcodes

2016-03-22 Thread Samuel Iglesias Gonsálvez


On 22/03/16 16:19, Samuel Iglesias Gonsálvez wrote:
> 
> 
> On 21/03/16 23:56, Jason Ekstrand wrote:
>> On Mon, Mar 21, 2016 at 5:06 AM, Samuel Iglesias Gonsálvez <
>> sigles...@igalia.com> wrote:
>>
>>> From: Iago Toral Quiroga 
>>>
>>> ---
>>>  src/compiler/nir/glsl_to_nir.cpp | 6 ++
>>>  src/compiler/nir/nir_opcodes.py  | 2 ++
>>>  2 files changed, 8 insertions(+)
>>>
>>> diff --git a/src/compiler/nir/glsl_to_nir.cpp
>>> b/src/compiler/nir/glsl_to_nir.cpp
>>> index 952d787..d087a77 100644
>>> --- a/src/compiler/nir/glsl_to_nir.cpp
>>> +++ b/src/compiler/nir/glsl_to_nir.cpp
>>> @@ -1357,6 +1357,12 @@ nir_visitor::visit(ir_expression *ir)
>>> case ir_unop_d2i:  result = nir_d2i(, srcs[0]);   break;
>>> case ir_unop_d2u:  result = nir_d2u(, srcs[0]);   break;
>>> case ir_unop_d2b:  result = nir_d2b(, srcs[0]);   break;
>>> +   case ir_unop_i2d:
>>> +  result = supports_ints ? nir_i2d(, srcs[0]) : nir_fmov(,
>>> srcs[0]);
>>> +  break;
>>> +   case ir_unop_u2d:
>>> +  result = supports_ints ? nir_u2d(, srcs[0]) : nir_fmov(,
>>> srcs[0]);
>>>
>>
>> If you're going to be using the u2d opcode, you'd better support integers.
>>
> 
> We did the same than integer to float conversions to keep this code
> aligned with what they do.
> 
> We can add an assert for support_ints here and only call to nir_u2d but,
> to be consistent, we would need to do similar changes to i2d, u2f, i2f
> too in a separate patch.
> 

Actually i2d would be done in this patch.

Sam

> What do you think?
> 
> Sam
> 
>>
>>> +  break;
>>> case ir_unop_i2u:
>>> case ir_unop_u2i:
>>> case ir_unop_bitcast_i2f:
>>> diff --git a/src/compiler/nir/nir_opcodes.py
>>> b/src/compiler/nir/nir_opcodes.py
>>> index a161ac1..cf6ce83 100644
>>> --- a/src/compiler/nir/nir_opcodes.py
>>> +++ b/src/compiler/nir/nir_opcodes.py
>>> @@ -164,6 +164,7 @@ unop_convert("f2u", tuint32, tfloat32, "src0") #
>>> Float-to-unsigned conversion
>>>  unop_convert("d2i", tint32, tfloat64, "src0") # Double-to-integer
>>> conversion.
>>>  unop_convert("d2u", tuint32, tfloat64, "src0") # Double-to-unsigned
>>> conversion.
>>>  unop_convert("i2f", tfloat32, tint32, "src0") # Integer-to-float
>>> conversion.
>>> +unop_convert("i2d", tfloat64, tint32, "src0") # Integer-to-double
>>> conversion.
>>>  # Float-to-boolean conversion
>>>  unop_convert("f2b", tbool, tfloat32, "src0 != 0.0f")
>>>  unop_convert("d2b", tbool, tfloat64, "src0 != 0.0")
>>> @@ -173,6 +174,7 @@ unop_convert("b2f", tfloat32, tbool, "src0 ? 1.0f :
>>> 0.0f")
>>>  unop_convert("i2b", tbool, tint32, "src0 != 0")
>>>  unop_convert("b2i", tint32, tbool, "src0 ? 1 : 0") # Boolean-to-int
>>> conversion
>>>  unop_convert("u2f", tfloat32, tuint32, "src0") # Unsigned-to-float
>>> conversion.
>>> +unop_convert("u2d", tfloat64, tuint32, "src0") # Unsigned-to-double
>>> conversion.
>>>  # double-to-float conversion
>>>  unop_convert("d2f", tfloat32, tfloat64, "src0") # Single to double
>>> precision
>>>  unop_convert("f2d", tfloat64, tfloat32, "src0") # Double to single
>>> precision
>>> --
>>> 2.5.0
>>>
>>> ___
>>> mesa-dev mailing list
>>> mesa-dev@lists.freedesktop.org
>>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>>>
>>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 23/29] nir: add i2d and u2d opcodes

2016-03-22 Thread Samuel Iglesias Gonsálvez


On 21/03/16 23:56, Jason Ekstrand wrote:
> On Mon, Mar 21, 2016 at 5:06 AM, Samuel Iglesias Gonsálvez <
> sigles...@igalia.com> wrote:
> 
>> From: Iago Toral Quiroga 
>>
>> ---
>>  src/compiler/nir/glsl_to_nir.cpp | 6 ++
>>  src/compiler/nir/nir_opcodes.py  | 2 ++
>>  2 files changed, 8 insertions(+)
>>
>> diff --git a/src/compiler/nir/glsl_to_nir.cpp
>> b/src/compiler/nir/glsl_to_nir.cpp
>> index 952d787..d087a77 100644
>> --- a/src/compiler/nir/glsl_to_nir.cpp
>> +++ b/src/compiler/nir/glsl_to_nir.cpp
>> @@ -1357,6 +1357,12 @@ nir_visitor::visit(ir_expression *ir)
>> case ir_unop_d2i:  result = nir_d2i(, srcs[0]);   break;
>> case ir_unop_d2u:  result = nir_d2u(, srcs[0]);   break;
>> case ir_unop_d2b:  result = nir_d2b(, srcs[0]);   break;
>> +   case ir_unop_i2d:
>> +  result = supports_ints ? nir_i2d(, srcs[0]) : nir_fmov(,
>> srcs[0]);
>> +  break;
>> +   case ir_unop_u2d:
>> +  result = supports_ints ? nir_u2d(, srcs[0]) : nir_fmov(,
>> srcs[0]);
>>
> 
> If you're going to be using the u2d opcode, you'd better support integers.
> 

We did the same than integer to float conversions to keep this code
aligned with what they do.

We can add an assert for support_ints here and only call to nir_u2d but,
to be consistent, we would need to do similar changes to i2d, u2f, i2f
too in a separate patch.

What do you think?

Sam

> 
>> +  break;
>> case ir_unop_i2u:
>> case ir_unop_u2i:
>> case ir_unop_bitcast_i2f:
>> diff --git a/src/compiler/nir/nir_opcodes.py
>> b/src/compiler/nir/nir_opcodes.py
>> index a161ac1..cf6ce83 100644
>> --- a/src/compiler/nir/nir_opcodes.py
>> +++ b/src/compiler/nir/nir_opcodes.py
>> @@ -164,6 +164,7 @@ unop_convert("f2u", tuint32, tfloat32, "src0") #
>> Float-to-unsigned conversion
>>  unop_convert("d2i", tint32, tfloat64, "src0") # Double-to-integer
>> conversion.
>>  unop_convert("d2u", tuint32, tfloat64, "src0") # Double-to-unsigned
>> conversion.
>>  unop_convert("i2f", tfloat32, tint32, "src0") # Integer-to-float
>> conversion.
>> +unop_convert("i2d", tfloat64, tint32, "src0") # Integer-to-double
>> conversion.
>>  # Float-to-boolean conversion
>>  unop_convert("f2b", tbool, tfloat32, "src0 != 0.0f")
>>  unop_convert("d2b", tbool, tfloat64, "src0 != 0.0")
>> @@ -173,6 +174,7 @@ unop_convert("b2f", tfloat32, tbool, "src0 ? 1.0f :
>> 0.0f")
>>  unop_convert("i2b", tbool, tint32, "src0 != 0")
>>  unop_convert("b2i", tint32, tbool, "src0 ? 1 : 0") # Boolean-to-int
>> conversion
>>  unop_convert("u2f", tfloat32, tuint32, "src0") # Unsigned-to-float
>> conversion.
>> +unop_convert("u2d", tfloat64, tuint32, "src0") # Unsigned-to-double
>> conversion.
>>  # double-to-float conversion
>>  unop_convert("d2f", tfloat32, tfloat64, "src0") # Single to double
>> precision
>>  unop_convert("f2d", tfloat64, tfloat32, "src0") # Double to single
>> precision
>> --
>> 2.5.0
>>
>> ___
>> mesa-dev mailing list
>> mesa-dev@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>>
> 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 23/29] nir: add i2d and u2d opcodes

2016-03-21 Thread Jason Ekstrand
On Mon, Mar 21, 2016 at 5:06 AM, Samuel Iglesias Gonsálvez <
sigles...@igalia.com> wrote:

> From: Iago Toral Quiroga 
>
> ---
>  src/compiler/nir/glsl_to_nir.cpp | 6 ++
>  src/compiler/nir/nir_opcodes.py  | 2 ++
>  2 files changed, 8 insertions(+)
>
> diff --git a/src/compiler/nir/glsl_to_nir.cpp
> b/src/compiler/nir/glsl_to_nir.cpp
> index 952d787..d087a77 100644
> --- a/src/compiler/nir/glsl_to_nir.cpp
> +++ b/src/compiler/nir/glsl_to_nir.cpp
> @@ -1357,6 +1357,12 @@ nir_visitor::visit(ir_expression *ir)
> case ir_unop_d2i:  result = nir_d2i(, srcs[0]);   break;
> case ir_unop_d2u:  result = nir_d2u(, srcs[0]);   break;
> case ir_unop_d2b:  result = nir_d2b(, srcs[0]);   break;
> +   case ir_unop_i2d:
> +  result = supports_ints ? nir_i2d(, srcs[0]) : nir_fmov(,
> srcs[0]);
> +  break;
> +   case ir_unop_u2d:
> +  result = supports_ints ? nir_u2d(, srcs[0]) : nir_fmov(,
> srcs[0]);
>

If you're going to be using the u2d opcode, you'd better support integers.


> +  break;
> case ir_unop_i2u:
> case ir_unop_u2i:
> case ir_unop_bitcast_i2f:
> diff --git a/src/compiler/nir/nir_opcodes.py
> b/src/compiler/nir/nir_opcodes.py
> index a161ac1..cf6ce83 100644
> --- a/src/compiler/nir/nir_opcodes.py
> +++ b/src/compiler/nir/nir_opcodes.py
> @@ -164,6 +164,7 @@ unop_convert("f2u", tuint32, tfloat32, "src0") #
> Float-to-unsigned conversion
>  unop_convert("d2i", tint32, tfloat64, "src0") # Double-to-integer
> conversion.
>  unop_convert("d2u", tuint32, tfloat64, "src0") # Double-to-unsigned
> conversion.
>  unop_convert("i2f", tfloat32, tint32, "src0") # Integer-to-float
> conversion.
> +unop_convert("i2d", tfloat64, tint32, "src0") # Integer-to-double
> conversion.
>  # Float-to-boolean conversion
>  unop_convert("f2b", tbool, tfloat32, "src0 != 0.0f")
>  unop_convert("d2b", tbool, tfloat64, "src0 != 0.0")
> @@ -173,6 +174,7 @@ unop_convert("b2f", tfloat32, tbool, "src0 ? 1.0f :
> 0.0f")
>  unop_convert("i2b", tbool, tint32, "src0 != 0")
>  unop_convert("b2i", tint32, tbool, "src0 ? 1 : 0") # Boolean-to-int
> conversion
>  unop_convert("u2f", tfloat32, tuint32, "src0") # Unsigned-to-float
> conversion.
> +unop_convert("u2d", tfloat64, tuint32, "src0") # Unsigned-to-double
> conversion.
>  # double-to-float conversion
>  unop_convert("d2f", tfloat32, tfloat64, "src0") # Single to double
> precision
>  unop_convert("f2d", tfloat64, tfloat32, "src0") # Double to single
> precision
> --
> 2.5.0
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 23/29] nir: add i2d and u2d opcodes

2016-03-21 Thread Samuel Iglesias Gonsálvez
From: Iago Toral Quiroga 

---
 src/compiler/nir/glsl_to_nir.cpp | 6 ++
 src/compiler/nir/nir_opcodes.py  | 2 ++
 2 files changed, 8 insertions(+)

diff --git a/src/compiler/nir/glsl_to_nir.cpp b/src/compiler/nir/glsl_to_nir.cpp
index 952d787..d087a77 100644
--- a/src/compiler/nir/glsl_to_nir.cpp
+++ b/src/compiler/nir/glsl_to_nir.cpp
@@ -1357,6 +1357,12 @@ nir_visitor::visit(ir_expression *ir)
case ir_unop_d2i:  result = nir_d2i(, srcs[0]);   break;
case ir_unop_d2u:  result = nir_d2u(, srcs[0]);   break;
case ir_unop_d2b:  result = nir_d2b(, srcs[0]);   break;
+   case ir_unop_i2d:
+  result = supports_ints ? nir_i2d(, srcs[0]) : nir_fmov(, srcs[0]);
+  break;
+   case ir_unop_u2d:
+  result = supports_ints ? nir_u2d(, srcs[0]) : nir_fmov(, srcs[0]);
+  break;
case ir_unop_i2u:
case ir_unop_u2i:
case ir_unop_bitcast_i2f:
diff --git a/src/compiler/nir/nir_opcodes.py b/src/compiler/nir/nir_opcodes.py
index a161ac1..cf6ce83 100644
--- a/src/compiler/nir/nir_opcodes.py
+++ b/src/compiler/nir/nir_opcodes.py
@@ -164,6 +164,7 @@ unop_convert("f2u", tuint32, tfloat32, "src0") # 
Float-to-unsigned conversion
 unop_convert("d2i", tint32, tfloat64, "src0") # Double-to-integer conversion.
 unop_convert("d2u", tuint32, tfloat64, "src0") # Double-to-unsigned conversion.
 unop_convert("i2f", tfloat32, tint32, "src0") # Integer-to-float conversion.
+unop_convert("i2d", tfloat64, tint32, "src0") # Integer-to-double conversion.
 # Float-to-boolean conversion
 unop_convert("f2b", tbool, tfloat32, "src0 != 0.0f")
 unop_convert("d2b", tbool, tfloat64, "src0 != 0.0")
@@ -173,6 +174,7 @@ unop_convert("b2f", tfloat32, tbool, "src0 ? 1.0f : 0.0f")
 unop_convert("i2b", tbool, tint32, "src0 != 0")
 unop_convert("b2i", tint32, tbool, "src0 ? 1 : 0") # Boolean-to-int conversion
 unop_convert("u2f", tfloat32, tuint32, "src0") # Unsigned-to-float conversion.
+unop_convert("u2d", tfloat64, tuint32, "src0") # Unsigned-to-double conversion.
 # double-to-float conversion
 unop_convert("d2f", tfloat32, tfloat64, "src0") # Single to double precision
 unop_convert("f2d", tfloat64, tfloat32, "src0") # Double to single precision
-- 
2.5.0

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