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_2 _GLF_uniform_int_values[0]
29 # #define _int_1 _GLF_uniform_int_values[1]
30 # #define _int_0 _GLF_uniform_int_values[2]
32 # precision highp float;
33 # precision highp int;
35 # // Contents of _GLF_uniform_int_values: [2, 1, 0]
36 # layout(set = 0, binding = 0) uniform buf0
38 # int _GLF_uniform_int_values[3];
41 # // Contents of v0: [0, 1]
42 # layout(set = 0, binding = 1) uniform buf1
47 # // Contents of v1: [2, 3]
48 # layout(set = 0, binding = 2) uniform buf2
53 # layout(location = 0) out vec4 _GLF_color;
62 # S obj = S(int[10](_int_0, _int_0, _int_0, _int_0, _int_0, _int_0, _int_0, _int_0, _int_0, _int_0));
64 # // Sets obj.arr[0..1] to 2.
65 # for(int i = v0.x; i < _int_2; i++)
67 # obj.arr[i] = _int_2;
71 # int a = obj.arr[_int_1] * (v0.x < _int_1 ? v0 : v1).y;
76 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
80 # _GLF_color = vec4(_int_0);
83 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
86 ; Generator: Khronos Glslang Reference Front End; 10
90 %1 = OpExtInstImport "GLSL.std.450"
91 OpMemoryModel Logical GLSL450
92 OpEntryPoint Fragment %4 "main" %105
93 OpExecutionMode %4 OriginUpperLeft
97 OpMemberName %10 0 "arr"
100 OpMemberName %15 0 "_GLF_uniform_int_values"
104 OpMemberName %46 0 "v0"
108 OpMemberName %87 0 "v1"
110 OpName %105 "_GLF_color"
111 OpDecorate %14 ArrayStride 16
112 OpMemberDecorate %15 0 Offset 0
114 OpDecorate %17 DescriptorSet 0
115 OpDecorate %17 Binding 0
116 OpMemberDecorate %46 0 Offset 0
118 OpDecorate %48 DescriptorSet 0
119 OpDecorate %48 Binding 1
120 OpMemberDecorate %87 0 Offset 0
122 OpDecorate %89 DescriptorSet 0
123 OpDecorate %89 Binding 2
124 OpDecorate %105 Location 0
126 %3 = OpTypeFunction %2
129 %8 = OpConstant %7 10
130 %9 = OpTypeArray %6 %8
131 %10 = OpTypeStruct %9
132 %11 = OpTypePointer Function %10
133 %13 = OpConstant %7 3
134 %14 = OpTypeArray %6 %13
135 %15 = OpTypeStruct %14
136 %16 = OpTypePointer Uniform %15
137 %17 = OpVariable %16 Uniform
138 %18 = OpConstant %6 0
139 %19 = OpConstant %6 2
140 %20 = OpTypePointer Uniform %6
141 %43 = OpTypePointer Function %6
142 %45 = OpTypeVector %6 2
143 %46 = OpTypeStruct %45
144 %47 = OpTypePointer Uniform %46
145 %48 = OpVariable %47 Uniform
146 %49 = OpConstant %7 0
148 %67 = OpConstant %6 1
149 %79 = OpTypePointer Function %45
150 %83 = OpTypePointer Uniform %45
151 %87 = OpTypeStruct %45
152 %88 = OpTypePointer Uniform %87
153 %89 = OpVariable %88 Uniform
154 %92 = OpConstant %7 1
155 %102 = OpTypeFloat 32
156 %103 = OpTypeVector %102 4
157 %104 = OpTypePointer Output %103
158 %105 = OpVariable %104 Output
159 %4 = OpFunction %2 None %3
161 %12 = OpVariable %11 Function
162 %44 = OpVariable %43 Function
163 %69 = OpVariable %43 Function
164 %80 = OpVariable %79 Function
165 %21 = OpAccessChain %20 %17 %18 %19
167 %23 = OpAccessChain %20 %17 %18 %19
169 %25 = OpAccessChain %20 %17 %18 %19
171 %27 = OpAccessChain %20 %17 %18 %19
173 %29 = OpAccessChain %20 %17 %18 %19
175 %31 = OpAccessChain %20 %17 %18 %19
177 %33 = OpAccessChain %20 %17 %18 %19
179 %35 = OpAccessChain %20 %17 %18 %19
181 %37 = OpAccessChain %20 %17 %18 %19
183 %39 = OpAccessChain %20 %17 %18 %19
185 %41 = OpCompositeConstruct %9 %22 %24 %26 %28 %30 %32 %34 %36 %38 %40
186 %42 = OpCompositeConstruct %10 %41
188 %50 = OpAccessChain %20 %48 %18 %49
193 OpLoopMerge %54 %55 None
197 %58 = OpAccessChain %20 %17 %18 %18
199 %61 = OpSLessThan %60 %57 %59
200 OpBranchConditional %61 %53 %54
203 %63 = OpAccessChain %20 %17 %18 %18
205 %65 = OpAccessChain %43 %12 %18 %62
210 %68 = OpIAdd %6 %66 %67
214 %70 = OpAccessChain %20 %17 %18 %67
216 %72 = OpAccessChain %43 %12 %18 %71
218 %74 = OpAccessChain %20 %48 %18 %49
220 %76 = OpAccessChain %20 %17 %18 %67
222 %78 = OpSLessThan %60 %75 %77
223 OpSelectionMerge %82 None
224 OpBranchConditional %78 %81 %86
226 %84 = OpAccessChain %83 %48 %18
231 %90 = OpAccessChain %83 %89 %18
236 %93 = OpAccessChain %43 %80 %92
238 %95 = OpIMul %6 %73 %94
241 %97 = OpAccessChain %20 %17 %18 %18
243 %99 = OpIEqual %60 %96 %98
244 OpSelectionMerge %101 None
245 OpBranchConditional %99 %100 %119
247 %106 = OpAccessChain %20 %17 %18 %67
248 %107 = OpLoad %6 %106
249 %108 = OpConvertSToF %102 %107
250 %109 = OpAccessChain %20 %17 %18 %19
251 %110 = OpLoad %6 %109
252 %111 = OpConvertSToF %102 %110
253 %112 = OpAccessChain %20 %17 %18 %19
254 %113 = OpLoad %6 %112
255 %114 = OpConvertSToF %102 %113
256 %115 = OpAccessChain %20 %17 %18 %67
257 %116 = OpLoad %6 %115
258 %117 = OpConvertSToF %102 %116
259 %118 = OpCompositeConstruct %103 %108 %111 %114 %117
263 %120 = OpAccessChain %20 %17 %18 %19
264 %121 = OpLoad %6 %120
265 %122 = OpConvertSToF %102 %121
266 %123 = OpCompositeConstruct %103 %122 %122 %122 %122
274 # uniforms for variant
277 BUFFER variant_v0 DATA_TYPE vec2<int32> STD140 DATA
281 BUFFER variant_v1 DATA_TYPE vec2<int32> STD140 DATA
284 # _GLF_uniform_int_values
285 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
289 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
291 PIPELINE graphics variant_pipeline
292 ATTACH variant_vertex_shader
293 ATTACH variant_fragment_shader
294 FRAMEBUFFER_SIZE 32 32
295 BIND BUFFER variant_framebuffer AS color LOCATION 0
296 BIND BUFFER variant_v0 AS uniform DESCRIPTOR_SET 0 BINDING 1
297 BIND BUFFER variant_v1 AS uniform DESCRIPTOR_SET 0 BINDING 2
298 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
300 CLEAR_COLOR variant_pipeline 0 0 0 255
302 CLEAR variant_pipeline
303 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
305 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255