I found that AMD Radeon RX 6400 mis-optimizes another HLSL pixel shader program. The expected output is a white screen, but the wrong optimization causes the output color to be black. After manual debugging the compiled binary executable, I found that the compiler incorrectly optimizes the statement "c = 0.09 - h * h" to be "c = 0.09 - h". The runtime value of c is 0.1, so the correct computation should be "c = 0.09 - 0.1 * 0.1 = 0.08", but after the wrong optimization, the statement execution becomes "c = 0.09 - 0.1 = -0.01".
The code and the explanation of the code can be found in:
Configurations:
Reproduce the bug in the browser:
Prerequisite: Windows 10 system, Chrome, AMD Radeon 6400
The Chrome on Windows system by default uses Direct3D 11 as the backend to execute the OpenGL ES shader programs.
Steps:
Click the "Compile" button to compile the shader program. Then click "Pause" button to stop the variable iTime from changing. Next, click "Reset time" button to set the variable iTime to 0.
The correct output should be white. However, you would see the output as black due to the incorrect compilation.
Reproduce the bug on the desktop: