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