• 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 GraphicsFuzz.
19
20# Short description: A fragment shader that covers a specific DAG combiner 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# precision highp float;
29# precision highp int;
30#
31# layout(location = 0) out vec4 _GLF_color;
32# layout(set = 0, binding = 0) uniform buf0
33# {
34#     float one;
35# };
36#
37# void main()
38# {
39#     vec3 v;
40#     float f = one;
41#     int a = 1, b = 0, c = 1;
42#
43#     for (int i = 0; i < 3; i++)
44#         v[i] = f + float(i);
45#
46#     if(one == 1.0)
47#     {
48#         do
49#         {
50#             _GLF_color = vec4(0);
51#         }
52#         while ((c & (a | b)) == 0);
53#
54#         if(one == 1.0)
55#             _GLF_color = vec4(1);
56#     }
57#
58#     _GLF_color.rgb = vec3(v.x == 1.0 ? 1.0 : 0.0,
59#                           v.y == 2.0 ? 0.0 : 1.0,
60#                           v.z == 3.0 ? 0.0 : 1.0);
61#     _GLF_color.a = 1.0;
62# }
63SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
64; SPIR-V
65; Version: 1.0
66; Generator: Khronos Glslang Reference Front End; 8
67; Bound: 94
68; Schema: 0
69               OpCapability Shader
70          %1 = OpExtInstImport "GLSL.std.450"
71               OpMemoryModel Logical GLSL450
72               OpEntryPoint Fragment %4 "main" %55
73               OpExecutionMode %4 OriginUpperLeft
74               OpSource ESSL 310
75               OpName %4 "main"
76               OpName %8 "f"
77               OpName %9 "buf0"
78               OpMemberName %9 0 "one"
79               OpName %11 ""
80               OpName %18 "a"
81               OpName %20 "b"
82               OpName %21 "c"
83               OpName %22 "i"
84               OpName %34 "v"
85               OpName %55 "_GLF_color"
86               OpMemberDecorate %9 0 Offset 0
87               OpDecorate %9 Block
88               OpDecorate %11 DescriptorSet 0
89               OpDecorate %11 Binding 0
90               OpDecorate %55 Location 0
91          %2 = OpTypeVoid
92          %3 = OpTypeFunction %2
93          %6 = OpTypeFloat 32
94          %7 = OpTypePointer Function %6
95          %9 = OpTypeStruct %6
96         %10 = OpTypePointer Uniform %9
97         %11 = OpVariable %10 Uniform
98         %12 = OpTypeInt 32 1
99         %13 = OpConstant %12 0
100         %14 = OpTypePointer Uniform %6
101         %17 = OpTypePointer Function %12
102         %19 = OpConstant %12 1
103         %29 = OpConstant %12 3
104         %30 = OpTypeBool
105         %32 = OpTypeVector %6 3
106         %33 = OpTypePointer Function %32
107         %45 = OpConstant %6 1
108         %53 = OpTypeVector %6 4
109         %54 = OpTypePointer Output %53
110         %55 = OpVariable %54 Output
111         %56 = OpConstant %6 0
112         %57 = OpConstantComposite %53 %56 %56 %56 %56
113         %69 = OpConstantComposite %53 %45 %45 %45 %45
114         %70 = OpTypeInt 32 0
115         %71 = OpConstant %70 0
116         %76 = OpConstant %70 1
117         %79 = OpConstant %6 2
118         %82 = OpConstant %70 2
119         %85 = OpConstant %6 3
120         %91 = OpConstant %70 3
121         %92 = OpTypePointer Output %6
122          %4 = OpFunction %2 None %3
123          %5 = OpLabel
124          %8 = OpVariable %7 Function
125         %18 = OpVariable %17 Function
126         %20 = OpVariable %17 Function
127         %21 = OpVariable %17 Function
128         %22 = OpVariable %17 Function
129         %34 = OpVariable %33 Function
130         %15 = OpAccessChain %14 %11 %13
131         %16 = OpLoad %6 %15
132               OpStore %8 %16
133               OpStore %18 %19
134               OpStore %20 %13
135               OpStore %21 %19
136               OpStore %22 %13
137               OpBranch %23
138         %23 = OpLabel
139               OpLoopMerge %25 %26 None
140               OpBranch %27
141         %27 = OpLabel
142         %28 = OpLoad %12 %22
143         %31 = OpSLessThan %30 %28 %29
144               OpBranchConditional %31 %24 %25
145         %24 = OpLabel
146         %35 = OpLoad %12 %22
147         %36 = OpLoad %6 %8
148         %37 = OpLoad %12 %22
149         %38 = OpConvertSToF %6 %37
150         %39 = OpFAdd %6 %36 %38
151         %40 = OpAccessChain %7 %34 %35
152               OpStore %40 %39
153               OpBranch %26
154         %26 = OpLabel
155         %41 = OpLoad %12 %22
156         %42 = OpIAdd %12 %41 %19
157               OpStore %22 %42
158               OpBranch %23
159         %25 = OpLabel
160         %43 = OpAccessChain %14 %11 %13
161         %44 = OpLoad %6 %43
162         %46 = OpFOrdEqual %30 %44 %45
163               OpSelectionMerge %48 None
164               OpBranchConditional %46 %47 %48
165         %47 = OpLabel
166               OpBranch %49
167         %49 = OpLabel
168               OpLoopMerge %51 %52 None
169               OpBranch %50
170         %50 = OpLabel
171               OpStore %55 %57
172               OpBranch %52
173         %52 = OpLabel
174         %58 = OpLoad %12 %21
175         %59 = OpLoad %12 %18
176         %60 = OpLoad %12 %20
177         %61 = OpBitwiseOr %12 %59 %60
178         %62 = OpBitwiseAnd %12 %58 %61
179         %63 = OpIEqual %30 %62 %13
180               OpBranchConditional %63 %49 %51
181         %51 = OpLabel
182         %64 = OpAccessChain %14 %11 %13
183         %65 = OpLoad %6 %64
184         %66 = OpFOrdEqual %30 %65 %45
185               OpSelectionMerge %68 None
186               OpBranchConditional %66 %67 %68
187         %67 = OpLabel
188               OpStore %55 %69
189               OpBranch %68
190         %68 = OpLabel
191               OpBranch %48
192         %48 = OpLabel
193         %72 = OpAccessChain %7 %34 %71
194         %73 = OpLoad %6 %72
195         %74 = OpFOrdEqual %30 %73 %45
196         %75 = OpSelect %6 %74 %45 %56
197         %77 = OpAccessChain %7 %34 %76
198         %78 = OpLoad %6 %77
199         %80 = OpFOrdEqual %30 %78 %79
200         %81 = OpSelect %6 %80 %56 %45
201         %83 = OpAccessChain %7 %34 %82
202         %84 = OpLoad %6 %83
203         %86 = OpFOrdEqual %30 %84 %85
204         %87 = OpSelect %6 %86 %56 %45
205         %88 = OpCompositeConstruct %32 %75 %81 %87
206         %89 = OpLoad %53 %55
207         %90 = OpVectorShuffle %53 %89 %88 4 5 6 3
208               OpStore %55 %90
209         %93 = OpAccessChain %92 %55 %91
210               OpStore %93 %45
211               OpReturn
212               OpFunctionEnd
213END
214
215# uniforms for variant
216
217# one
218BUFFER variant_one DATA_TYPE float DATA
219 1.0
220END
221
222BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
223
224PIPELINE graphics variant_pipeline
225  ATTACH variant_vertex_shader
226  ATTACH variant_fragment_shader
227  FRAMEBUFFER_SIZE 256 256
228  BIND BUFFER variant_framebuffer AS color LOCATION 0
229  BIND BUFFER variant_one AS uniform DESCRIPTOR_SET 0 BINDING 0
230END
231CLEAR_COLOR variant_pipeline 0 0 0 255
232
233CLEAR variant_pipeline
234RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
235
236EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255
237