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 _uint_1 _GLF_uniform_uint_values[0]
32 # #define _uint_0 _GLF_uniform_uint_values[1]
33 # #define _float_8_0 _GLF_uniform_float_values[0]
34 # #define _float_1_0 _GLF_uniform_float_values[1]
35 # #define _float_2_0 _GLF_uniform_float_values[2]
36 # #define _float_3_0 _GLF_uniform_float_values[3]
37 # #define _float_4_0 _GLF_uniform_float_values[4]
38 # #define _float_5_0 _GLF_uniform_float_values[5]
39 # #define _float_6_0 _GLF_uniform_float_values[6]
40 # #define _float_7_0 _GLF_uniform_float_values[7]
41 # #define _float_9_0 _GLF_uniform_float_values[8]
42 # #define _float_10_0 _GLF_uniform_float_values[9]
44 # precision highp float;
45 # precision highp int;
47 # // Contents of _GLF_uniform_float_values: [8.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 9.0, 10.0]
48 # layout(set = 0, binding = 0) uniform buf0
50 # float _GLF_uniform_float_values[10];
53 # // Contents of _GLF_uniform_int_values: [1, 0]
54 # layout(set = 0, binding = 1) uniform buf1
56 # int _GLF_uniform_int_values[2];
59 # // Contents of _GLF_uniform_uint_values: [1, 0]
60 # layout(set = 0, binding = 2) uniform buf2
62 # uint _GLF_uniform_uint_values[2];
65 # layout(location = 0) out vec4 _GLF_color;
71 # float arr[5] = float[5](_float_1_0, _float_2_0, _float_3_0, _float_4_0, _float_5_0);
73 # arr[b] += float[5](_float_6_0, _float_7_0, _float_8_0, _float_9_0, _float_10_0)[usubBorrow(1u, 1u, a)];
76 # if(arr[_int_1] == _float_8_0 && a == _uint_0)
78 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
82 # _GLF_color = vec4(_int_0);
85 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
88 ; Generator: Khronos Glslang Reference Front End; 10
92 %1 = OpExtInstImport "GLSL.std.450"
93 OpMemoryModel Logical GLSL450
94 OpEntryPoint Fragment %4 "main" %103
95 OpExecutionMode %4 OriginUpperLeft
100 OpMemberName %11 0 "_GLF_uniform_uint_values"
104 OpMemberName %22 0 "_GLF_uniform_int_values"
108 OpMemberName %35 0 "_GLF_uniform_float_values"
111 OpName %76 "indexable"
112 OpName %103 "_GLF_color"
113 OpDecorate %10 ArrayStride 16
114 OpMemberDecorate %11 0 Offset 0
116 OpDecorate %13 DescriptorSet 0
117 OpDecorate %13 Binding 2
118 OpDecorate %21 ArrayStride 16
119 OpMemberDecorate %22 0 Offset 0
121 OpDecorate %24 DescriptorSet 0
122 OpDecorate %24 Binding 1
123 OpDecorate %34 ArrayStride 16
124 OpMemberDecorate %35 0 Offset 0
126 OpDecorate %37 DescriptorSet 0
127 OpDecorate %37 Binding 0
128 OpDecorate %103 Location 0
130 %3 = OpTypeFunction %2
132 %7 = OpTypePointer Function %6
134 %10 = OpTypeArray %6 %9
135 %11 = OpTypeStruct %10
136 %12 = OpTypePointer Uniform %11
137 %13 = OpVariable %12 Uniform
139 %15 = OpConstant %14 0
140 %16 = OpTypePointer Uniform %6
141 %19 = OpTypePointer Function %14
142 %21 = OpTypeArray %14 %9
143 %22 = OpTypeStruct %21
144 %23 = OpTypePointer Uniform %22
145 %24 = OpVariable %23 Uniform
146 %25 = OpTypePointer Uniform %14
148 %29 = OpConstant %6 5
149 %30 = OpTypeArray %28 %29
150 %31 = OpTypePointer Function %30
151 %33 = OpConstant %6 10
152 %34 = OpTypeArray %28 %33
153 %35 = OpTypeStruct %34
154 %36 = OpTypePointer Uniform %35
155 %37 = OpVariable %36 Uniform
156 %38 = OpConstant %14 1
157 %39 = OpTypePointer Uniform %28
158 %42 = OpConstant %14 2
159 %45 = OpConstant %14 3
160 %48 = OpConstant %14 4
161 %51 = OpConstant %14 5
162 %56 = OpConstant %14 6
163 %59 = OpConstant %14 7
164 %64 = OpConstant %14 8
165 %67 = OpConstant %14 9
166 %71 = OpConstant %6 1
167 %72 = OpTypeStruct %6 %6
168 %77 = OpTypePointer Function %28
170 %101 = OpTypeVector %28 4
171 %102 = OpTypePointer Output %101
172 %103 = OpVariable %102 Output
173 %4 = OpFunction %2 None %3
175 %8 = OpVariable %7 Function
176 %20 = OpVariable %19 Function
177 %32 = OpVariable %31 Function
178 %76 = OpVariable %31 Function
179 %17 = OpAccessChain %16 %13 %15 %15
182 %26 = OpAccessChain %25 %24 %15 %15
185 %40 = OpAccessChain %39 %37 %15 %38
187 %43 = OpAccessChain %39 %37 %15 %42
189 %46 = OpAccessChain %39 %37 %15 %45
191 %49 = OpAccessChain %39 %37 %15 %48
193 %52 = OpAccessChain %39 %37 %15 %51
195 %54 = OpCompositeConstruct %30 %41 %44 %47 %50 %53
198 %57 = OpAccessChain %39 %37 %15 %56
200 %60 = OpAccessChain %39 %37 %15 %59
202 %62 = OpAccessChain %39 %37 %15 %15
204 %65 = OpAccessChain %39 %37 %15 %64
206 %68 = OpAccessChain %39 %37 %15 %67
208 %70 = OpCompositeConstruct %30 %58 %61 %63 %66 %69
209 %73 = OpISubBorrow %72 %71 %71
210 %74 = OpCompositeExtract %6 %73 1
212 %75 = OpCompositeExtract %6 %73 0
214 %78 = OpAccessChain %77 %76 %75
216 %80 = OpAccessChain %77 %32 %55
218 %82 = OpFAdd %28 %81 %79
219 %83 = OpAccessChain %77 %32 %55
221 %85 = OpAccessChain %25 %24 %15 %15
223 %87 = OpAccessChain %77 %32 %86
225 %89 = OpAccessChain %39 %37 %15 %15
227 %91 = OpFOrdEqual %84 %88 %90
228 OpSelectionMerge %93 None
229 OpBranchConditional %91 %92 %93
232 %95 = OpAccessChain %16 %13 %15 %38
234 %97 = OpIEqual %84 %94 %96
237 %98 = OpPhi %84 %91 %5 %97 %92
238 OpSelectionMerge %100 None
239 OpBranchConditional %98 %99 %117
241 %104 = OpAccessChain %25 %24 %15 %15
242 %105 = OpLoad %14 %104
243 %106 = OpConvertSToF %28 %105
244 %107 = OpAccessChain %25 %24 %15 %38
245 %108 = OpLoad %14 %107
246 %109 = OpConvertSToF %28 %108
247 %110 = OpAccessChain %25 %24 %15 %38
248 %111 = OpLoad %14 %110
249 %112 = OpConvertSToF %28 %111
250 %113 = OpAccessChain %25 %24 %15 %15
251 %114 = OpLoad %14 %113
252 %115 = OpConvertSToF %28 %114
253 %116 = OpCompositeConstruct %101 %106 %109 %112 %115
257 %118 = OpAccessChain %25 %24 %15 %38
258 %119 = OpLoad %14 %118
259 %120 = OpConvertSToF %28 %119
260 %121 = OpCompositeConstruct %101 %120 %120 %120 %120
268 # uniforms for variant
270 # _GLF_uniform_uint_values
271 BUFFER variant__GLF_uniform_uint_values DATA_TYPE int32[] STD140 DATA
274 # _GLF_uniform_int_values
275 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
278 # _GLF_uniform_float_values
279 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
280 8.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 9.0 10.0
283 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
285 PIPELINE graphics variant_pipeline
286 ATTACH variant_vertex_shader
287 ATTACH variant_fragment_shader
288 FRAMEBUFFER_SIZE 32 32
289 BIND BUFFER variant_framebuffer AS color LOCATION 0
290 BIND BUFFER variant__GLF_uniform_uint_values AS uniform DESCRIPTOR_SET 0 BINDING 2
291 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
292 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
294 CLEAR_COLOR variant_pipeline 0 0 0 255
296 CLEAR variant_pipeline
297 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
299 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255