[PATCH vkd3d] vkd3d-shader/hlsl: Support casts between all numeric types on constant folding.
Zebediah Figura (she/her)
zfigura at codeweavers.com
Mon Jan 17 17:47:41 CST 2022
On 1/4/22 08:17, Giovanni Mascellani wrote:
> Hi.
>
> On 30/12/21 22:55, Francisco Casas wrote:
>> CONSTANT_OP2_FUNCTION(constant_value_sum,+)
>> CONSTANT_OP2_FUNCTION(constant_value_sub,-)
>> CONSTANT_OP2_FUNCTION(constant_value_mult,+)
>> CONSTANT_OP2_FUNCTION(constant_value_neg,* (-1) + 0 *) /* horrid? */
>> CONSTANT_OP2_FUNCTION(constant_value_div,/) /* horrid? */
>
> If you ask me, the neg thing is pretty horrid indeed, I'd avoid it.
> Also, I'm pretty sure that multiplying a float by zero is not guaranteed
> to give you zero (infinity * zero = NaN, I think, and I don't know about
> NaN * zero), so depending on how you use it it might give wrong results.
> If you want to go down that route, maybe it's better to add a
> corresponding CONSTANT_OP1_FUNCTION.
>
> Also for the OP2 variants, notice that C doesn't define the results for
> all the possible arguments given to these operations. For example
> division by zero is undefined (and often results in a crash, in
> particular I think it does on the architectures we target) and signed
> overflow is undefined too (things like INT_MAX + INT_MAX, INT_MIN * -1,
> etc). It seems that we don't use -fwrapv in vkd3d (differently from
> Wine), which means that the compiler won't scramble to fix things up for
> us.
Where are you getting that Wine uses -fwrapv? I don't see any mention of
that in the source.
More information about the wine-devel
mailing list