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