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