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