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:
29 # #define _int_1 _GLF_uniform_int_values[0]
30 # #define _int_0 _GLF_uniform_int_values[1]
31 # #define _int_2 _GLF_uniform_int_values[2]
33 # precision highp float;
34 # precision highp int;
36 # // Contents of _GLF_uniform_int_values: [1, 0, 2]
37 # layout(set = 0, binding = 0) uniform buf0
39 # int _GLF_uniform_int_values[3];
42 # layout(location = 0) out vec4 _GLF_color;
46 # int arr[10] = int[10](_int_1, _int_1, _int_1, _int_1, _int_1, _int_1, _int_1, _int_1, _int_1, _int_1);
47 # ivec2 v = ivec2(_int_1);
51 # if(arr[_int_1] == _int_1)
59 # // Modulus of a negative value is undefined, but this is never executed.
60 # if(-5 % a >= _int_1)
62 # arr[v.x + v.y] = _int_0;
67 # // arr[2] becomes two.
68 # arr[v.x + v.y] = _int_2;
72 # if(a == _int_2 && arr[_int_2] == _int_2)
74 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
78 # _GLF_color = vec4(_int_0);
81 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
84 ; Generator: Khronos Glslang Reference Front End; 10
88 %1 = OpExtInstImport "GLSL.std.450"
89 OpMemoryModel Logical GLSL450
90 OpEntryPoint Fragment %4 "main" %113
91 OpExecutionMode %4 OriginUpperLeft
96 OpMemberName %14 0 "_GLF_uniform_int_values"
100 OpName %113 "_GLF_color"
101 OpDecorate %13 ArrayStride 16
102 OpMemberDecorate %14 0 Offset 0
104 OpDecorate %16 DescriptorSet 0
105 OpDecorate %16 Binding 0
106 OpDecorate %113 Location 0
108 %3 = OpTypeFunction %2
111 %8 = OpConstant %7 10
112 %9 = OpTypeArray %6 %8
113 %10 = OpTypePointer Function %9
114 %12 = OpConstant %7 3
115 %13 = OpTypeArray %6 %12
116 %14 = OpTypeStruct %13
117 %15 = OpTypePointer Uniform %14
118 %16 = OpVariable %15 Uniform
119 %17 = OpConstant %6 0
120 %18 = OpTypePointer Uniform %6
121 %40 = OpTypeVector %6 2
122 %41 = OpTypePointer Function %40
123 %46 = OpTypePointer Function %6
124 %48 = OpConstant %6 1
126 %66 = OpConstant %6 -5
127 %74 = OpConstant %7 0
128 %77 = OpConstant %7 1
129 %90 = OpConstant %6 2
130 %110 = OpTypeFloat 32
131 %111 = OpTypeVector %110 4
132 %112 = OpTypePointer Output %111
133 %113 = OpVariable %112 Output
134 %4 = OpFunction %2 None %3
136 %11 = OpVariable %10 Function
137 %42 = OpVariable %41 Function
138 %47 = OpVariable %46 Function
139 %19 = OpAccessChain %18 %16 %17 %17
141 %21 = OpAccessChain %18 %16 %17 %17
143 %23 = OpAccessChain %18 %16 %17 %17
145 %25 = OpAccessChain %18 %16 %17 %17
147 %27 = OpAccessChain %18 %16 %17 %17
149 %29 = OpAccessChain %18 %16 %17 %17
151 %31 = OpAccessChain %18 %16 %17 %17
153 %33 = OpAccessChain %18 %16 %17 %17
155 %35 = OpAccessChain %18 %16 %17 %17
157 %37 = OpAccessChain %18 %16 %17 %17
159 %39 = OpCompositeConstruct %9 %20 %22 %24 %26 %28 %30 %32 %34 %36 %38
161 %43 = OpAccessChain %18 %16 %17 %17
163 %45 = OpCompositeConstruct %40 %44 %44
166 %49 = OpAccessChain %18 %16 %17 %17
168 %51 = OpAccessChain %46 %11 %50
170 %53 = OpAccessChain %18 %16 %17 %17
172 %56 = OpIEqual %55 %52 %54
173 OpSelectionMerge %58 None
174 OpBranchConditional %56 %57 %58
177 %60 = OpIAdd %6 %59 %48
181 %61 = OpAccessChain %18 %16 %17 %17
183 %63 = OpIEqual %55 %62 %17
184 OpSelectionMerge %65 None
185 OpBranchConditional %63 %64 %84
188 %68 = OpSMod %6 %66 %67
189 %69 = OpAccessChain %18 %16 %17 %17
191 %71 = OpSGreaterThanEqual %55 %68 %70
192 OpSelectionMerge %73 None
193 OpBranchConditional %71 %72 %73
195 %75 = OpAccessChain %46 %42 %74
197 %78 = OpAccessChain %46 %42 %77
199 %80 = OpIAdd %6 %76 %79
200 %81 = OpAccessChain %18 %16 %17 %48
202 %83 = OpAccessChain %46 %11 %80
208 %85 = OpAccessChain %46 %42 %74
210 %87 = OpAccessChain %46 %42 %77
212 %89 = OpIAdd %6 %86 %88
213 %91 = OpAccessChain %18 %16 %17 %90
215 %93 = OpAccessChain %46 %11 %89
220 %95 = OpAccessChain %18 %16 %17 %90
222 %97 = OpIEqual %55 %94 %96
223 OpSelectionMerge %99 None
224 OpBranchConditional %97 %98 %99
226 %100 = OpAccessChain %18 %16 %17 %90
227 %101 = OpLoad %6 %100
228 %102 = OpAccessChain %46 %11 %101
229 %103 = OpLoad %6 %102
230 %104 = OpAccessChain %18 %16 %17 %90
231 %105 = OpLoad %6 %104
232 %106 = OpIEqual %55 %103 %105
235 %107 = OpPhi %55 %97 %65 %106 %98
236 OpSelectionMerge %109 None
237 OpBranchConditional %107 %108 %127
239 %114 = OpAccessChain %18 %16 %17 %17
240 %115 = OpLoad %6 %114
241 %116 = OpConvertSToF %110 %115
242 %117 = OpAccessChain %18 %16 %17 %48
243 %118 = OpLoad %6 %117
244 %119 = OpConvertSToF %110 %118
245 %120 = OpAccessChain %18 %16 %17 %48
246 %121 = OpLoad %6 %120
247 %122 = OpConvertSToF %110 %121
248 %123 = OpAccessChain %18 %16 %17 %17
249 %124 = OpLoad %6 %123
250 %125 = OpConvertSToF %110 %124
251 %126 = OpCompositeConstruct %111 %116 %119 %122 %125
255 %128 = OpAccessChain %18 %16 %17 %48
256 %129 = OpLoad %6 %128
257 %130 = OpConvertSToF %110 %129
258 %131 = OpCompositeConstruct %111 %130 %130 %130 %130
266 # uniforms for variant
268 # _GLF_uniform_int_values
269 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
273 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
275 PIPELINE graphics variant_pipeline
276 ATTACH variant_vertex_shader
277 ATTACH variant_fragment_shader
278 FRAMEBUFFER_SIZE 32 32
279 BIND BUFFER variant_framebuffer AS color LOCATION 0
280 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
282 CLEAR_COLOR variant_pipeline 0 0 0 255
284 CLEAR variant_pipeline
285 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
287 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255