llvmpipe doesn't compile a shader with an inner scope in a for loop
System information
System: Kernel: 5.11.0-18-generic x86_64 bits: 64 compiler: gcc v: 10.2.1 Desktop: GNOME 3.38.4
tk: GTK 3.24.25 wm: gnome-shell dm: GDM3 Distro: Ubuntu 21.04 (Hirsute Hippo)
CPU: Info: 6-Core model: Intel Core i7-8750H bits: 64 type: MT MCP arch: Kaby Lake note: check rev: A L2 cache: 9 MiB
flags: avx avx2 lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx bogomips: 52799
Speed: 900 MHz min/max: 800/4100 MHz Core speeds (MHz): 1: 900 2: 900 3: 900 4: 900 5: 900 6: 900 7: 900 8: 901
9: 900 10: 900 11: 900 12: 900
Graphics: Device-1: Intel CoffeeLake-H GT2 [UHD Graphics 630] vendor: ASUSTeK driver: i915 v: kernel bus ID: 00:02.0
chip ID: 8086:3e9b
Device-2: NVIDIA GP107M [GeForce GTX 1050 Ti Mobile] vendor: ASUSTeK driver: nvidia v: 460.80 bus ID: 01:00.0
chip ID: 10de:1c8c
Display: x11 server: X.Org 1.20.11 compositor: gnome-shell driver: loaded: modesetting,nvidia
unloaded: fbdev,nouveau,vesa resolution: 1: 1920x1080~120Hz 2: 1920x1080~60Hz s-dpi: 96
OpenGL: renderer: llvmpipe (LLVM 12.0.0 256 bits) v: 4.5 Mesa 21.1.7 compat-v: 3.1 direct render: Yes
Describe the issue
The following shader doesn't compile with llvmpipe while being validated with GlslangValidator.
#version 450
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
void main()
{
for(uint var_0 = 1u; var_0 < 10u; var_0 += 1u)
{
{
const vec4 var_0 = vec4(1.0);
continue;
}
}
The inner extra brackets define a new scope, contrary to the one from the for-loop, so that it is possible to redefine var_0. LLVMPipe doesn't compile the shader and report an error (in that specific version for affecting a const value). The issue disappear if the continue instruction is removed.
Reproducing the issue
The shader has been found using a testing tool called Shadertrap. Instructions are given below to reproduce it with that tool. A shader_test is also attached for convenience. shader15.shader_test
- Get or build Shadertrap:
- A build version of Shadertrap for linux can be found on Shadertrap release repository.
- To build from source, please refer to Shadertrap repository
- Ge the shader file shader15.shadertrap
- Execute the Shadertrap command
bin/shadertrap shader15.shadertrap
- Collect the buffer results in the execution folder (one file per buffer)