• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!amber
2
3# Copyright 2022 Google LLC
4#
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
8#
9#     http://www.apache.org/licenses/LICENSE-2.0
10#
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.
16
17
18# A test for a coverage-gap found by the GraphicsFuzz project.
19
20# Short description: A fragment shader that covers specific LLVM code paths
21
22# The test passes because the shader always writes red.
23
24SHADER vertex variant_vertex_shader PASSTHROUGH
25
26# variant_fragment_shader is derived from the following GLSL:
27# #version 320 es
28#
29# #define _int_2 _GLF_uniform_int_values[0]
30# #define _int_1 _GLF_uniform_int_values[1]
31# #define _int_0 _GLF_uniform_int_values[2]
32# #define _float_2_0 _GLF_uniform_float_values[0]
33# #define _float_1_0 _GLF_uniform_float_values[1]
34# #define _float_0_0 _GLF_uniform_float_values[2]
35#
36# precision highp float;
37# precision highp int;
38#
39# // Contents of _GLF_uniform_int_values: [2, 1, 0]
40# layout(set = 0, binding = 0) uniform buf0
41# {
42#     int _GLF_uniform_int_values[3];
43# };
44#
45# // Contents of _GLF_uniform_float_values: [2.0, 1.0, 0.0]
46# layout(set = 0, binding = 1) uniform buf1
47# {
48#     float _GLF_uniform_float_values[3];
49# };
50#
51# layout(location = 0) out vec4 _GLF_color;
52#
53# void main()
54# {
55#     float data[3] = float[3](1.0, _float_1_0, _float_1_0);
56#
57#     // data becomes [1, 0, 0].
58#     for(int i = 1; i < 3; i++)
59#     {
60#         data[i] = _float_0_0;
61#     }
62#
63#     // data becomes [1, 2, 0].
64#     for(int i = 0; i < 3; i++)
65#     {
66#         if(data[i] < _float_1_0)
67#         {
68#             data[i] = _float_2_0;
69#             break;
70#         }
71#     }
72#
73#     // Always true.
74#     if(data[_int_0] == _float_1_0 && data[_int_1] == _float_2_0 && data[_int_2] == _float_0_0)
75#     {
76#         _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
77#     }
78#     else
79#     {
80#         _GLF_color = vec4(_int_0);
81#     }
82# }
83SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
84; SPIR-V
85; Version: 1.0
86; Generator: Khronos Glslang Reference Front End; 10
87; Bound: 123
88; Schema: 0
89               OpCapability Shader
90          %1 = OpExtInstImport "GLSL.std.450"
91               OpMemoryModel Logical GLSL450
92               OpEntryPoint Fragment %4 "main" %104
93               OpExecutionMode %4 OriginUpperLeft
94               OpSource ESSL 320
95               OpName %4 "main"
96               OpName %11 "data"
97               OpName %14 "buf1"
98               OpMemberName %14 0 "_GLF_uniform_float_values"
99               OpName %16 ""
100               OpName %27 "i"
101               OpName %45 "i"
102               OpName %69 "buf0"
103               OpMemberName %69 0 "_GLF_uniform_int_values"
104               OpName %71 ""
105               OpName %104 "_GLF_color"
106               OpDecorate %13 ArrayStride 16
107               OpMemberDecorate %14 0 Offset 0
108               OpDecorate %14 Block
109               OpDecorate %16 DescriptorSet 0
110               OpDecorate %16 Binding 1
111               OpDecorate %68 ArrayStride 16
112               OpMemberDecorate %69 0 Offset 0
113               OpDecorate %69 Block
114               OpDecorate %71 DescriptorSet 0
115               OpDecorate %71 Binding 0
116               OpDecorate %104 Location 0
117          %2 = OpTypeVoid
118          %3 = OpTypeFunction %2
119          %6 = OpTypeFloat 32
120          %7 = OpTypeInt 32 0
121          %8 = OpConstant %7 3
122          %9 = OpTypeArray %6 %8
123         %10 = OpTypePointer Function %9
124         %12 = OpConstant %6 1
125         %13 = OpTypeArray %6 %8
126         %14 = OpTypeStruct %13
127         %15 = OpTypePointer Uniform %14
128         %16 = OpVariable %15 Uniform
129         %17 = OpTypeInt 32 1
130         %18 = OpConstant %17 0
131         %19 = OpConstant %17 1
132         %20 = OpTypePointer Uniform %6
133         %26 = OpTypePointer Function %17
134         %34 = OpConstant %17 3
135         %35 = OpTypeBool
136         %38 = OpConstant %17 2
137         %41 = OpTypePointer Function %6
138         %68 = OpTypeArray %17 %8
139         %69 = OpTypeStruct %68
140         %70 = OpTypePointer Uniform %69
141         %71 = OpVariable %70 Uniform
142         %72 = OpTypePointer Uniform %17
143        %102 = OpTypeVector %6 4
144        %103 = OpTypePointer Output %102
145        %104 = OpVariable %103 Output
146          %4 = OpFunction %2 None %3
147          %5 = OpLabel
148         %11 = OpVariable %10 Function
149         %27 = OpVariable %26 Function
150         %45 = OpVariable %26 Function
151         %21 = OpAccessChain %20 %16 %18 %19
152         %22 = OpLoad %6 %21
153         %23 = OpAccessChain %20 %16 %18 %19
154         %24 = OpLoad %6 %23
155         %25 = OpCompositeConstruct %9 %12 %22 %24
156               OpStore %11 %25
157               OpStore %27 %19
158               OpBranch %28
159         %28 = OpLabel
160               OpLoopMerge %30 %31 None
161               OpBranch %32
162         %32 = OpLabel
163         %33 = OpLoad %17 %27
164         %36 = OpSLessThan %35 %33 %34
165               OpBranchConditional %36 %29 %30
166         %29 = OpLabel
167         %37 = OpLoad %17 %27
168         %39 = OpAccessChain %20 %16 %18 %38
169         %40 = OpLoad %6 %39
170         %42 = OpAccessChain %41 %11 %37
171               OpStore %42 %40
172               OpBranch %31
173         %31 = OpLabel
174         %43 = OpLoad %17 %27
175         %44 = OpIAdd %17 %43 %19
176               OpStore %27 %44
177               OpBranch %28
178         %30 = OpLabel
179               OpStore %45 %18
180               OpBranch %46
181         %46 = OpLabel
182               OpLoopMerge %48 %49 None
183               OpBranch %50
184         %50 = OpLabel
185         %51 = OpLoad %17 %45
186         %52 = OpSLessThan %35 %51 %34
187               OpBranchConditional %52 %47 %48
188         %47 = OpLabel
189         %53 = OpLoad %17 %45
190         %54 = OpAccessChain %41 %11 %53
191         %55 = OpLoad %6 %54
192         %56 = OpAccessChain %20 %16 %18 %19
193         %57 = OpLoad %6 %56
194         %58 = OpFOrdLessThan %35 %55 %57
195               OpSelectionMerge %60 None
196               OpBranchConditional %58 %59 %60
197         %59 = OpLabel
198         %61 = OpLoad %17 %45
199         %62 = OpAccessChain %20 %16 %18 %18
200         %63 = OpLoad %6 %62
201         %64 = OpAccessChain %41 %11 %61
202               OpStore %64 %63
203               OpBranch %48
204         %60 = OpLabel
205               OpBranch %49
206         %49 = OpLabel
207         %66 = OpLoad %17 %45
208         %67 = OpIAdd %17 %66 %19
209               OpStore %45 %67
210               OpBranch %46
211         %48 = OpLabel
212         %73 = OpAccessChain %72 %71 %18 %38
213         %74 = OpLoad %17 %73
214         %75 = OpAccessChain %41 %11 %74
215         %76 = OpLoad %6 %75
216         %77 = OpAccessChain %20 %16 %18 %19
217         %78 = OpLoad %6 %77
218         %79 = OpFOrdEqual %35 %76 %78
219               OpSelectionMerge %81 None
220               OpBranchConditional %79 %80 %81
221         %80 = OpLabel
222         %82 = OpAccessChain %72 %71 %18 %19
223         %83 = OpLoad %17 %82
224         %84 = OpAccessChain %41 %11 %83
225         %85 = OpLoad %6 %84
226         %86 = OpAccessChain %20 %16 %18 %18
227         %87 = OpLoad %6 %86
228         %88 = OpFOrdEqual %35 %85 %87
229               OpBranch %81
230         %81 = OpLabel
231         %89 = OpPhi %35 %79 %48 %88 %80
232               OpSelectionMerge %91 None
233               OpBranchConditional %89 %90 %91
234         %90 = OpLabel
235         %92 = OpAccessChain %72 %71 %18 %18
236         %93 = OpLoad %17 %92
237         %94 = OpAccessChain %41 %11 %93
238         %95 = OpLoad %6 %94
239         %96 = OpAccessChain %20 %16 %18 %38
240         %97 = OpLoad %6 %96
241         %98 = OpFOrdEqual %35 %95 %97
242               OpBranch %91
243         %91 = OpLabel
244         %99 = OpPhi %35 %89 %81 %98 %90
245               OpSelectionMerge %101 None
246               OpBranchConditional %99 %100 %118
247        %100 = OpLabel
248        %105 = OpAccessChain %72 %71 %18 %19
249        %106 = OpLoad %17 %105
250        %107 = OpConvertSToF %6 %106
251        %108 = OpAccessChain %72 %71 %18 %38
252        %109 = OpLoad %17 %108
253        %110 = OpConvertSToF %6 %109
254        %111 = OpAccessChain %72 %71 %18 %38
255        %112 = OpLoad %17 %111
256        %113 = OpConvertSToF %6 %112
257        %114 = OpAccessChain %72 %71 %18 %19
258        %115 = OpLoad %17 %114
259        %116 = OpConvertSToF %6 %115
260        %117 = OpCompositeConstruct %102 %107 %110 %113 %116
261               OpStore %104 %117
262               OpBranch %101
263        %118 = OpLabel
264        %119 = OpAccessChain %72 %71 %18 %38
265        %120 = OpLoad %17 %119
266        %121 = OpConvertSToF %6 %120
267        %122 = OpCompositeConstruct %102 %121 %121 %121 %121
268               OpStore %104 %122
269               OpBranch %101
270        %101 = OpLabel
271               OpReturn
272               OpFunctionEnd
273END
274
275# uniforms for variant
276
277# _GLF_uniform_float_values
278BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
279 2.0 1.0 0.0
280END
281# _GLF_uniform_int_values
282BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
283 2 1 0
284END
285
286BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
287
288PIPELINE graphics variant_pipeline
289  ATTACH variant_vertex_shader
290  ATTACH variant_fragment_shader
291  FRAMEBUFFER_SIZE 32 32
292  BIND BUFFER variant_framebuffer AS color LOCATION 0
293  BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1
294  BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
295END
296CLEAR_COLOR variant_pipeline 0 0 0 255
297
298CLEAR variant_pipeline
299RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
300
301EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255
302