Bug 100580

Summary: Adding unreachable "return" and "continue" in a GLSL shader leads to different image
Product: Mesa Reporter: Hugues Evrard <h.evrard>
Component: Mesa coreAssignee: mesa-dev
Status: RESOLVED FIXED QA Contact: mesa-dev
Severity: normal    
Priority: medium CC: h.evrard
Version: git   
Hardware: Other   
OS: All   
URL: https://github.com/mc-imperial/shader-compiler-bugs/issues/70
Whiteboard:
i915 platform: i915 features:
Attachments: Archive with files to reproduce

Description Hugues Evrard 2017-04-05 12:31:27 UTC

    
Comment 1 Hugues Evrard 2017-04-05 12:38:44 UTC

Steps to Reproduce:
-------------------------------

0. Note: this bug is experienced on an AMD GPU (tested on Tonga, see
   below for more config details)

1. Obtain and build the latest release of get-image, a simple tool that
   creates a .png image from a fragment shader
   https://github.com/mc-imperial/get-image

2. From a terminal, execute:

   /path/to/get_image/linux_out/install/bin/get_image original.frag

   This will create output.png, which should look like original.png

3. From a terminal, execute:

   /path/to/get_image/linux_out/install/bin/get_image variant.frag

   This will create output.png, which should look like variant.png

Expected Results:
-------------------------------

Both shaders should render an image that looks like original.png. This
is because the only difference between the shader source files is the
addition, in the variant shader, of two unreachable "return" and
"continue" statements. The value of "injectionSwitch" is set to { 0.0,
1.0 }, such that the condition tested here is always false.

Diff:
```
27a28,29
> uniform vec2 injectionSwitch;
>
33a36,39
>     if(injectionSwitch.x > injectionSwitch.y)
>         {
>             return vec2(1.0);
>         }
120a127
>     c = c;
202a210,213
>                     if(injectionSwitch.x > injectionSwitch.y)
>                         {
>                             continue;
>                         }
```

Actual Results:
-------------------------------
The shaders render different images, which they should not: the red
circle completely disappear in the variant image.

Additional Information:
-------------------------------
Some info on the system where the bug was found:

- CPU: AMD A10-7850K Radeon R7, 12 Compute Cores 4C+8G
- GPU: Advanced Micro Devices, Inc. [AMD/ATI] Tonga PRO [Radeon R9 285/380]
- Mesa: 17.1.0-devel (git-08df015)
- OS: Ubuntu 16.04, Linux 4.4.0-71-generic
Comment 2 Hugues Evrard 2017-04-05 12:39:31 UTC
See: https://github.com/mc-imperial/shader-compiler-bugs/issues/70

Steps to Reproduce:
-------------------------------

0. Note: this bug is experienced on an AMD GPU (tested on Tonga, see
   below for more config details)

1. Obtain and build the latest release of get-image, a simple tool that
   creates a .png image from a fragment shader
   https://github.com/mc-imperial/get-image

2. From a terminal, execute:

   /path/to/get_image/linux_out/install/bin/get_image original.frag

   This will create output.png, which should look like original.png

3. From a terminal, execute:

   /path/to/get_image/linux_out/install/bin/get_image variant.frag

   This will create output.png, which should look like variant.png

Expected Results:
-------------------------------

Both shaders should render an image that looks like original.png. This
is because the only difference between the shader source files is the
addition, in the variant shader, of two unreachable "return" and
"continue" statements. The value of "injectionSwitch" is set to { 0.0,
1.0 }, such that the condition tested here is always false.

Diff:
```
27a28,29
> uniform vec2 injectionSwitch;
>
33a36,39
>     if(injectionSwitch.x > injectionSwitch.y)
>         {
>             return vec2(1.0);
>         }
120a127
>     c = c;
202a210,213
>                     if(injectionSwitch.x > injectionSwitch.y)
>                         {
>                             continue;
>                         }
```

Actual Results:
-------------------------------
The shaders render different images, which they should not: the red
circle completely disappear in the variant image.

Additional Information:
-------------------------------
Some info on the system where the bug was found:

- CPU: AMD A10-7850K Radeon R7, 12 Compute Cores 4C+8G
- GPU: Advanced Micro Devices, Inc. [AMD/ATI] Tonga PRO [Radeon R9 285/380]
- Mesa: 17.1.0-devel (git-08df015)
- OS: Ubuntu 16.04, Linux 4.4.0-71-generic
Comment 3 Hugues Evrard 2017-04-05 12:41:04 UTC
Created attachment 130691 [details]
Archive with files to reproduce
Comment 4 Boyan Ding 2017-04-06 05:35:07 UTC
Not reproducible with i965 or llvmpipe. More likely an AMD-specific bug.
Comment 5 Marc Dietrich 2017-04-06 11:30:22 UTC
also fine for r600 (RS780). So radeonsi specific.
Comment 6 Roland Scheidegger 2017-04-06 14:53:48 UTC
FWIW I could reproduce this with a slightly older mesa git version with llvmpipe, whereas it seems to work now. Maybe the patch mentioned in https://bugs.freedesktop.org/show_bug.cgi?id=100303 fixed this, or it was some other change.
So I think this is probably not radeon specific, but just fixed already, closing.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.