mirror of
https://github.com/KhronosGroup/glslang
synced 2024-11-08 19:40:06 +00:00
dba720ff94
Test/hlsl.inf.vert tests parsing and some constant math on infinities, including (-1.#INF * 0.0). By IEEE 754 rules, that result is a NaN, but its sign is not significant. The test output assumes a negative-NaN is in the generated SPIR-V. However, the math library on some platforms (like macOS 14, a.k.a. Sonoma) will produce a positive NaN instead. This PR adjusts the test so it takes the absolute value of the NaN, to ensure we the emitted SPIR-V has the NaN with a 0 for it sign bit.
17 lines
560 B
GLSL
17 lines
560 B
GLSL
float4 main() : SV_Position
|
|
{
|
|
float f1 = -1.#INF;
|
|
float f2 = 1.#INF;
|
|
float f3 = +1.#INF;
|
|
float f4 = f2 * 1.#INF + 1.#INF;
|
|
const float f5 = -1.#INF;
|
|
// An infinity times zero is a NaN.
|
|
// In IEEE 754, the sign of a NaN is significant only for
|
|
// abs, copy, negate, or copySign. Use abs(.) here to
|
|
// set the sign bit to zero. Otherwise, some platforms will
|
|
// have a 1 sign bit and others will have a 0 sign bit.
|
|
const float f6 = abs(f5 * 0.0f);
|
|
|
|
return (float4)(f1 + f2 + f3 + f4 + f5 + f6);
|
|
}
|