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