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