3 # Copyright 2022 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 coverage-gap found by the GraphicsFuzz project.
20 # Short description: A fragment shader that covers specific LLVM code paths
22 # The test passes because the shader always writes red.
24 SHADER vertex variant_vertex_shader PASSTHROUGH
26 # variant_fragment_shader is derived from the following GLSL:
28 # #define _int_8 _GLF_uniform_int_values[0]
29 # #define _int_0 _GLF_uniform_int_values[1]
30 # #define _int_1 _GLF_uniform_int_values[2]
31 # #define _int_2 _GLF_uniform_int_values[3]
33 # precision highp float;
34 # precision highp int;
36 # // Contents of _GLF_uniform_int_values: [8, 0, 1, 2]
37 # layout(set = 0, binding = 0) uniform buf0
39 # int _GLF_uniform_int_values[4];
42 # const int _GLF_global_loop_bound = 10;
43 # int _GLF_global_loop_count = 0;
45 # // Contents of two: 2
46 # layout(push_constant) uniform buf_push
51 # layout(location = 0) out vec4 _GLF_color;
58 # for(int i = _int_1; _GLF_global_loop_count < _GLF_global_loop_bound; i *= _int_2)
60 # _GLF_global_loop_count++;
62 # // Iterates until the global loop bound is reached. The first condition is always true because i = 1.
63 # while(min(i - 1, two) >= 1 && _GLF_global_loop_count < _GLF_global_loop_bound)
65 # _GLF_global_loop_count++;
73 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
77 # _GLF_color = vec4(_int_0);
80 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
83 ; Generator: Khronos Glslang Reference Front End; 10
87 %1 = OpExtInstImport "GLSL.std.450"
88 OpMemoryModel Logical GLSL450
89 OpEntryPoint Fragment %4 "main" %73
90 OpExecutionMode %4 OriginUpperLeft
93 OpName %8 "_GLF_global_loop_count"
96 OpMemberName %15 0 "_GLF_uniform_int_values"
100 OpMemberName %44 0 "two"
102 OpName %73 "_GLF_color"
103 OpDecorate %14 ArrayStride 16
104 OpMemberDecorate %15 0 Offset 0
106 OpDecorate %17 DescriptorSet 0
107 OpDecorate %17 Binding 0
108 OpMemberDecorate %44 0 Offset 0
110 OpDecorate %73 Location 0
112 %3 = OpTypeFunction %2
114 %7 = OpTypePointer Private %6
115 %8 = OpVariable %7 Private
117 %10 = OpTypePointer Function %6
119 %13 = OpConstant %12 4
120 %14 = OpTypeArray %6 %13
121 %15 = OpTypeStruct %14
122 %16 = OpTypePointer Uniform %15
123 %17 = OpVariable %16 Uniform
124 %18 = OpConstant %6 1
125 %19 = OpTypePointer Uniform %6
126 %23 = OpConstant %6 2
127 %32 = OpConstant %6 10
129 %44 = OpTypeStruct %6
130 %45 = OpTypePointer PushConstant %44
131 %46 = OpVariable %45 PushConstant
132 %47 = OpTypePointer PushConstant %6
133 %59 = OpConstant %6 3
135 %71 = OpTypeVector %70 4
136 %72 = OpTypePointer Output %71
137 %73 = OpVariable %72 Output
138 %4 = OpFunction %2 None %3
140 %11 = OpVariable %10 Function
141 %22 = OpVariable %10 Function
143 %20 = OpAccessChain %19 %17 %9 %18
146 %24 = OpAccessChain %19 %17 %9 %23
151 OpLoopMerge %28 %29 None
155 %34 = OpSLessThan %33 %31 %32
156 OpBranchConditional %34 %27 %28
159 %36 = OpIAdd %6 %35 %18
163 OpLoopMerge %39 %40 None
167 %43 = OpISub %6 %42 %18
168 %48 = OpAccessChain %47 %46 %9
170 %50 = OpExtInst %6 %1 SMin %43 %49
171 %51 = OpSGreaterThanEqual %33 %50 %18
173 %53 = OpSLessThan %33 %52 %32
174 %54 = OpLogicalAnd %33 %51 %53
175 OpBranchConditional %54 %38 %39
178 %56 = OpIAdd %6 %55 %18
181 %58 = OpIAdd %6 %57 %18
189 %60 = OpAccessChain %19 %17 %9 %59
192 %63 = OpIMul %6 %62 %61
197 %65 = OpAccessChain %19 %17 %9 %9
199 %67 = OpIEqual %33 %64 %66
200 OpSelectionMerge %69 None
201 OpBranchConditional %67 %68 %87
203 %74 = OpAccessChain %19 %17 %9 %23
205 %76 = OpConvertSToF %70 %75
206 %77 = OpAccessChain %19 %17 %9 %18
208 %79 = OpConvertSToF %70 %78
209 %80 = OpAccessChain %19 %17 %9 %18
211 %82 = OpConvertSToF %70 %81
212 %83 = OpAccessChain %19 %17 %9 %23
214 %85 = OpConvertSToF %70 %84
215 %86 = OpCompositeConstruct %71 %76 %79 %82 %85
219 %88 = OpAccessChain %19 %17 %9 %18
221 %90 = OpConvertSToF %70 %89
222 %91 = OpCompositeConstruct %71 %90 %90 %90 %90
230 # uniforms for variant
233 BUFFER variant_two DATA_TYPE int32 STD140 DATA
236 # _GLF_uniform_int_values
237 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
241 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
243 PIPELINE graphics variant_pipeline
244 ATTACH variant_vertex_shader
245 ATTACH variant_fragment_shader
246 FRAMEBUFFER_SIZE 32 32
247 BIND BUFFER variant_framebuffer AS color LOCATION 0
248 BIND BUFFER variant_two AS push_constant
249 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
251 CLEAR_COLOR variant_pipeline 0 0 0 255
253 CLEAR variant_pipeline
254 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
256 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255