GPUOpen-Drivers / AMD-Gfx-Drivers

Forum for AMD OpenGL and Vulkan graphics drivers
12 stars 5 forks source link

AMD GPU hangs on a simple fragment shader program #23

Open mitdemverkaufer opened 2 months ago

mitdemverkaufer commented 2 months ago

The AMD RX 6400 GPU hangs on a simple fragment shader program. The fragment shader program should terminate reasonably quickly as all the loops have a fixed number of iterations. The program is expected to return a white square, but the GPU hangs and fails to respond.

#version 300 es
precision highp float;
precision highp int;
uniform int input1; // input1: 1
uniform int input2; // input2: 0
layout(location = 0) out vec4 color;
bool l() {
  int f = 0;
  int g = 0;
  for (int i = 0; i < 2; i++) {   // Iterates 2 times
    for (int j = input2; j < 1; j++) { // Iterates 1 time
      g = int(gl_FragCoord.x);
      if (g < input2)
        break;
    }
    f = f > 0 && g > 1 / f ? g : f;
  }
  return bool(f);
}
void main() {
  for (int i = 0; i < input1; i++)  // Iterates 1 time
    if (!l())
      break;
  color = vec4(1.0);
}

During runtime, the variable input1 and input2 are set to 1 and 0, respectively. All the loops are well-bounded, thus the program should terminate in a reasonable time. However, the GPU hangs and fails to respond.

How to reproduce

I prepared a minimal OpenGL application that simply loads the executes the fragment shader to draw a 256x256 square. You can download it here. The package also contains a detailed README file showing the environment and concrete steps to reproduce the bug. It should take less than a minute the reproduce the issue.

lubaozho commented 4 weeks ago

Thanks for reporting it, an internal bug ticket has been created to track this issue, will keep you posted on its progress. Thanks.