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