% Test the interaction between integer constant folding and the fact % that integers are secretly considered floats in SM1-3 [pixel shader] float4 main() : SV_TARGET { uint x = 3000000000u; return float4(x, 0.0, 0.0, 0.0); } [test] todo(glsl) draw quad probe (0, 0) rgba (3.0e+009, 0.0, 0.0, 0.0) % The uint value is never casted to int on SM1-3, just casted to float and treated as such [pixel shader] float4 main() : SV_TARGET { int x = 3000000000u; return float4(x, 0.0, 0.0, 0.0); } [test] todo(glsl) draw quad if(sm<4) todo probe (0,0) rgba (3.0e+009, 0.0, 0.0, 0.0) if(sm>=4) probe (0,0) rgba (-1.29496730e+009, 0.0, 0.0, 0.0) % On SM1-5 (FXC) the literal is considered signed independently of its value and casted to uint; % on SM1-3 compilation fails because the uint would be negative [pixel shader fail(sm<4) todo(sm<4)] float4 main() : SV_TARGET { uint x = 3000000000; return float4(x, 0.0, 0.0, 0.0); } [test] todo(glsl) draw quad if(sm>=4) probe (0,0) rgba (3.0e+009, 0.0, 0.0, 0.0) [pixel shader] float4 main() : SV_TARGET { int x = 3000000000; return float4(x, 0.0, 0.0, 0.0); } [test] todo(glsl) draw quad probe (0, 0) rgba (-1.29496730e+009, 0.0, 0.0, 0.0) [pixel shader] float4 main() : SV_TARGET { return float4(3000000000u, 0.0, 0.0, 0.0); } [test] todo(glsl) draw quad probe (0, 0) rgba (3.0e+009, 0.0, 0.0, 0.0) % Unsuffixed literals can instead be considered unsigned on SM6 [pixel shader] float4 main() : SV_TARGET { return float4(3000000000, 0.0, 0.0, 0.0); } [test] todo(glsl) draw quad if(sm<6) probe (0,0) rgba (-1.29496730e+009, 0.0, 0.0, 0.0) if(sm>=6) probe (0,0) rgba (3.0e+009, 0.0, 0.0, 0.0) % Constant folding is done with uint semantics before converting to float; % so constant folding seems to happen before converting integer operations to floats [pixel shader] float4 main() : SV_TARGET { uint x = 3000000000u + 3000000000u; return float4(x, 0.0, 0.0, 0.0); } [test] todo(glsl) draw quad probe (0, 0) rgba (1.70503270e+009, 0.0, 0.0, 0.0) % SM1-3 complains that uint values must be positive, but it's not clear why this is a problem here: % the sum should be done before casting to uint, and the result of the int sum should be positive, % so it seems that the declared type of x means something on how constant folding is done. % I'm not sure what's happening for SM4 anyway [pixel shader fail(sm<4) todo(sm<4)] float4 main() : SV_TARGET { uint x = 3000000000 + 3000000000; return float4(x, 0.0, 0.0, 0.0); } [test] todo(glsl) draw quad todo probe (0,0) rgba (2.14748365e+009, 0.0, 0.0, 0.0) % Again, no idea of what's happening here [pixel shader] float4 main() : SV_TARGET { int x = 3000000000 + 3000000000; return float4(x, 0.0, 0.0, 0.0); } [test] todo(glsl) draw quad todo probe (0,0) rgba (-2.14748365e+009, 0.0, 0.0, 0.0) % This makes sense [pixel shader] float4 main() : SV_TARGET { return float4(3000000000u + 3000000000u, 0.0, 0.0, 0.0); } [test] todo(glsl) draw quad probe (0, 0) rgba (1.70503270e+009, 0.0, 0.0, 0.0) % This does not again [pixel shader] float4 main() : SV_TARGET { return float4(3000000000 + 3000000000, 0.0, 0.0, 0.0); } [test] todo(glsl) draw quad todo probe (0,0) rgba (-2.14748365e+009, 0.0, 0.0, 0.0) % Explicit float literals use float semantics, at least [pixel shader] float4 main() : SV_TARGET { float x = 3000000000.0 + 3000000000.0; return float4(x, 0.0, 0.0, 0.0); } [test] todo(glsl) draw quad probe (0, 0) rgba (6.0e+009, 0.0, 0.0, 0.0)