[Mesa-dev] [PATCH v2 09/28] glsl/ir: Add builtin function support for doubles
Ian Romanick
idr at freedesktop.org
Fri Feb 6 01:12:33 PST 2015
On 02/06/2015 10:44 AM, Matt Turner wrote:
> On Thu, Feb 5, 2015 at 11:47 PM, Ian Romanick <idr at freedesktop.org> wrote:
>>> diff --git a/src/glsl/ir.h b/src/glsl/ir.h
>>> index a0f48b2..6e7c654 100644
>>> --- a/src/glsl/ir.h
>>> +++ b/src/glsl/ir.h
>>> @@ -1275,6 +1275,13 @@ enum ir_expression_operation {
>>> ir_unop_bitcast_f2u, /**< Bit-identical float-to-uint "conversion" */
>>> ir_unop_any,
>>>
>>> + ir_unop_d2f, /**< Double-to-float conversion. */
>>> + ir_unop_f2d, /**< Float-to-double conversion. */
>>> + ir_unop_d2i, /**< Double-to-integer conversion. */
>>> + ir_unop_i2d, /**< Integer-to-double conversion. */
>>> + ir_unop_d2u, /**< Double-to-unsigned conversion. */
>>> + ir_unop_u2d, /**< Unsigned-to-double conversion. */
>>> +
>>
>> These should be properly ordered with the other cast operations. Also,
>> ir_unop_d2b is missing.
>
> I had the same comment elsewhere. Apparently they're just doing d2b
> with d2f+f2b.
>
> I guess that'll just work?
Not for values smaller than can be represented in a float. Consider
this case:
uniform double d = 1e-500LF; // definitely not zero!
out vec4 piglit_fragcolor;
void main()
{
piglit_fragcolor.x = bool(d) ? 0 : 1;
pitlit_fragcolor.y = bool(float(d)) ? 0 : 1;
piglit_fragcolor.z = d != 0.0LF ? 0 : 1;
piglit_fragcolor.w = 1;
}
should result in (0, 1, 0, 1).
More information about the mesa-dev
mailing list