3 # Copyright 2019 Google LLC
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
18 # A test for a bug found by GraphicsFuzz.
20 # Short description: A fragment shader with a for loop that loops only once
22 # The test passes because the shader always writes the color red. The for loop only goes through once.
24 # Optimized using spirv-opt with the following arguments:
26 # '--eliminate-local-multi-store'
27 # '--eliminate-dead-branches'
29 # '--eliminate-dead-branches'
32 # '--eliminate-dead-inserts'
33 # '--convert-local-access-chains'
35 # '--eliminate-dead-code-aggressive'
37 # '--eliminate-local-multi-store'
39 # '--eliminate-dead-branches'
40 # spirv-opt commit hash: 06407250a169c6a03b3765e86619075af1a8c187
44 SHADER vertex variant_vertex_shader PASSTHROUGH
46 # variant_fragment_shader is derived from the following GLSL:
48 # precision highp float;
50 # precision highp int;
52 # layout(location = 0) out vec4 _GLF_color;
70 # _GLF_color = vec4(1.0, 0.0, 0.0, 1.0);
74 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
77 ; Generator: Khronos Glslang Reference Front End; 7
81 %1 = OpExtInstImport "GLSL.std.450"
82 OpMemoryModel Logical GLSL450
83 OpEntryPoint Fragment %4 "main" %33
84 OpExecutionMode %4 OriginUpperLeft
88 OpName %33 "_GLF_color"
89 OpDecorate %33 Location 0
91 %3 = OpTypeFunction %2
93 %7 = OpTypeVector %6 3
94 %8 = OpTypeFunction %7
96 %16 = OpConstantComposite %7 %15 %15 %15
97 %31 = OpTypeVector %6 4
98 %32 = OpTypePointer Output %31
99 %33 = OpVariable %32 Output
100 %34 = OpConstant %6 0
101 %35 = OpConstantComposite %31 %15 %34 %34 %15
102 %4 = OpFunction %2 None %3
104 %21 = OpFunctionCall %7 %9
107 OpLoopMerge %28 %29 None
117 %9 = OpFunction %7 None %8
121 OpLoopMerge %13 %14 None
132 # uniforms for variant
135 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
137 PIPELINE graphics variant_pipeline
138 ATTACH variant_vertex_shader
139 ATTACH variant_fragment_shader
140 FRAMEBUFFER_SIZE 256 256
141 BIND BUFFER variant_framebuffer AS color LOCATION 0
143 CLEAR_COLOR variant_pipeline 0 0 0 255
145 CLEAR variant_pipeline
146 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
148 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255