mc-imperial / shader-compiler-bugs

A collection of shader compiler bugs.
MIT License
49 stars 9 forks source link

Unreachable control flow instructions lead to wrong image produced #76

Open 0152la opened 7 years ago

0152la commented 7 years ago

[Shaders, screenshots, error log, reproduction steps, platform info, etc.] [ZIP]

Recipient:

recipient image

Variant:

variant image

In order to swap between the recipient and the variant shaders, comment/uncomment line 3. The colour is set in line 29 (green) or 30 (red). Line 29 should be unreachable, as the value returned in bar() should always be 1. However, in the variant, line 21 is reachable. This should be impossible, considering there is a continue being executed right before it, in line 16. The binary file shows that the compiler optimizes this to a single incorrect instruction, which directly sets the colours.

In order to run the shader, download and build the get-image-glsl tool. get_image_glfw will be built in ./out/<platform>/install/bin/. Then, ensure that the .frag and .json files are in the same directory, then run on a CLI: $ /path/to/get_image_glfw variant.frag The produced image will be saved to output.png by default. The binary can be obtained by passing --dump_bin <output_file>. Further options available to give to the get_image tool can be seen by passing the -h flag.

This issue was observed on:

The issue was also checked on the GTX770 machine on Firefox and Edge, but did not present itself (i.e. the expected red image was produced with both recipient and variant).