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