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