On Fri Feb 23 19:36:48 2024 +0000, Francisco Casas wrote:
Please disregard my hypothesis B. I tried that and it didn't work. In fact you even mentioned:
% Constant folding is done with uint semantics before converting to float; % so constant folding seems to happen before converting integer operations to floats
but maybe there is a lot more going on, for instance, notice this shader: https://shader-playground.timjones.io/df675e96acb6d16bb77dc0ebdf69dfb2 Constant folding is even preempting catastrophic cancellation.
Okay, I think that what happens is that float constants use double arithmetic! And this is also true for SM4.
This test can be added, albeit I am not sure if in `sm1-const-folding.shader_test`. ``` % Float constants use double arithmetic on all shader models. [pixel shader] float4 main() : SV_TARGET { float x = (200000000000.0f + 1.0f) - 200000000000.0f ; return x; }
[test] draw quad probe all rgba (1.0, 1.0, 1.0, 1.0) ```