• 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: A fragment shader that covers a specific instruction simplify path
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_2 _GLF_uniform_int_values[0]
29# #define _int_1 _GLF_uniform_int_values[1]
30# #define _int_0 _GLF_uniform_int_values[2]
31# #define _int_15 _GLF_uniform_int_values[3]
32# #define _float_1_0 _GLF_uniform_float_values[0]
33#
34# precision highp float;
35#
36# precision highp int;
37#
38# // Contents of _GLF_uniform_float_values: 1.0
39# layout(set = 0, binding = 0) uniform buf0
40# {
41#     float _GLF_uniform_float_values[1];
42# };
43#
44# // Contents of _GLF_uniform_int_values: [2, 1, 0, 15]
45# layout(set = 0, binding = 1) uniform buf1
46# {
47#     int _GLF_uniform_int_values[4];
48# };
49#
50# layout(location = 0) out vec4 _GLF_color;
51#
52# void main()
53# {
54#     vec4 data[2] = vec4[2](vec4(_float_1_0), vec4(_float_1_0));
55#
56#     int b = _int_1;
57#
58#     // This results in an undefined value, but not in undefined behavior. y becomes
59#     // undefined with some of the window coordinate values. Doesn't matter since
60#     // b's value is checked at the same time with y.
61#     int y = clamp(int(gl_FragCoord.y), _int_1 | int(gl_FragCoord.y), _int_1);
62#
63#     for (int i = _int_1; i < _int_2; i++)
64#     {
65#         if (b > _int_2 && y > _int_1)
66#         {
67#             break;
68#         }
69#         b++;
70#     }
71#
72#     if (b == _int_2)
73#     {
74#         data[clamp(_int_0, _int_1, _int_15)] =
75#             vec4(_int_1, _int_0, _int_0, _int_1);
76#     }
77#     _GLF_color = vec4(data[_int_1]);
78# }
79SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
80; SPIR-V
81; Version: 1.0
82; Generator: Khronos Glslang Reference Front End; 10
83; Bound: 127
84; Schema: 0
85               OpCapability Shader
86          %1 = OpExtInstImport "GLSL.std.450"
87               OpMemoryModel Logical GLSL450
88               OpEntryPoint Fragment %4 "main" %41 %117
89               OpExecutionMode %4 OriginUpperLeft
90               OpSource ESSL 310
91               OpName %4 "main"
92               OpName %12 "data"
93               OpName %15 "buf0"
94               OpMemberName %15 0 "_GLF_uniform_float_values"
95               OpName %17 ""
96               OpName %29 "b"
97               OpName %32 "buf1"
98               OpMemberName %32 0 "_GLF_uniform_int_values"
99               OpName %34 ""
100               OpName %39 "y"
101               OpName %41 "gl_FragCoord"
102               OpName %55 "i"
103               OpName %117 "_GLF_color"
104               OpDecorate %14 ArrayStride 16
105               OpMemberDecorate %15 0 Offset 0
106               OpDecorate %15 Block
107               OpDecorate %17 DescriptorSet 0
108               OpDecorate %17 Binding 0
109               OpDecorate %31 ArrayStride 16
110               OpMemberDecorate %32 0 Offset 0
111               OpDecorate %32 Block
112               OpDecorate %34 DescriptorSet 0
113               OpDecorate %34 Binding 1
114               OpDecorate %41 BuiltIn FragCoord
115               OpDecorate %117 Location 0
116          %2 = OpTypeVoid
117          %3 = OpTypeFunction %2
118          %6 = OpTypeFloat 32
119          %7 = OpTypeVector %6 4
120          %8 = OpTypeInt 32 0
121          %9 = OpConstant %8 2
122         %10 = OpTypeArray %7 %9
123         %11 = OpTypePointer Function %10
124         %13 = OpConstant %8 1
125         %14 = OpTypeArray %6 %13
126         %15 = OpTypeStruct %14
127         %16 = OpTypePointer Uniform %15
128         %17 = OpVariable %16 Uniform
129         %18 = OpTypeInt 32 1
130         %19 = OpConstant %18 0
131         %20 = OpTypePointer Uniform %6
132         %28 = OpTypePointer Function %18
133         %30 = OpConstant %8 4
134         %31 = OpTypeArray %18 %30
135         %32 = OpTypeStruct %31
136         %33 = OpTypePointer Uniform %32
137         %34 = OpVariable %33 Uniform
138         %35 = OpConstant %18 1
139         %36 = OpTypePointer Uniform %18
140         %40 = OpTypePointer Input %7
141         %41 = OpVariable %40 Input
142         %42 = OpTypePointer Input %6
143         %66 = OpTypeBool
144         %92 = OpConstant %18 2
145         %97 = OpConstant %18 3
146        %114 = OpTypePointer Function %7
147        %116 = OpTypePointer Output %7
148        %117 = OpVariable %116 Output
149          %4 = OpFunction %2 None %3
150          %5 = OpLabel
151         %12 = OpVariable %11 Function
152         %29 = OpVariable %28 Function
153         %39 = OpVariable %28 Function
154         %55 = OpVariable %28 Function
155         %21 = OpAccessChain %20 %17 %19 %19
156         %22 = OpLoad %6 %21
157         %23 = OpCompositeConstruct %7 %22 %22 %22 %22
158         %24 = OpAccessChain %20 %17 %19 %19
159         %25 = OpLoad %6 %24
160         %26 = OpCompositeConstruct %7 %25 %25 %25 %25
161         %27 = OpCompositeConstruct %10 %23 %26
162               OpStore %12 %27
163         %37 = OpAccessChain %36 %34 %19 %35
164         %38 = OpLoad %18 %37
165               OpStore %29 %38
166         %43 = OpAccessChain %42 %41 %13
167         %44 = OpLoad %6 %43
168         %45 = OpConvertFToS %18 %44
169         %46 = OpAccessChain %36 %34 %19 %35
170         %47 = OpLoad %18 %46
171         %48 = OpAccessChain %42 %41 %13
172         %49 = OpLoad %6 %48
173         %50 = OpConvertFToS %18 %49
174         %51 = OpBitwiseOr %18 %47 %50
175         %52 = OpAccessChain %36 %34 %19 %35
176         %53 = OpLoad %18 %52
177         %54 = OpExtInst %18 %1 SClamp %45 %51 %53
178               OpStore %39 %54
179         %56 = OpAccessChain %36 %34 %19 %35
180         %57 = OpLoad %18 %56
181               OpStore %55 %57
182               OpBranch %58
183         %58 = OpLabel
184               OpLoopMerge %60 %61 None
185               OpBranch %62
186         %62 = OpLabel
187         %63 = OpLoad %18 %55
188         %64 = OpAccessChain %36 %34 %19 %19
189         %65 = OpLoad %18 %64
190         %67 = OpSLessThan %66 %63 %65
191               OpBranchConditional %67 %59 %60
192         %59 = OpLabel
193         %68 = OpLoad %18 %29
194         %69 = OpAccessChain %36 %34 %19 %19
195         %70 = OpLoad %18 %69
196         %71 = OpSGreaterThan %66 %68 %70
197               OpSelectionMerge %73 None
198               OpBranchConditional %71 %72 %73
199         %72 = OpLabel
200         %74 = OpLoad %18 %39
201         %75 = OpAccessChain %36 %34 %19 %35
202         %76 = OpLoad %18 %75
203         %77 = OpSGreaterThan %66 %74 %76
204               OpBranch %73
205         %73 = OpLabel
206         %78 = OpPhi %66 %71 %59 %77 %72
207               OpSelectionMerge %80 None
208               OpBranchConditional %78 %79 %80
209         %79 = OpLabel
210               OpBranch %60
211         %80 = OpLabel
212         %82 = OpLoad %18 %29
213         %83 = OpIAdd %18 %82 %35
214               OpStore %29 %83
215               OpBranch %61
216         %61 = OpLabel
217         %84 = OpLoad %18 %55
218         %85 = OpIAdd %18 %84 %35
219               OpStore %55 %85
220               OpBranch %58
221         %60 = OpLabel
222         %86 = OpLoad %18 %29
223         %87 = OpAccessChain %36 %34 %19 %19
224         %88 = OpLoad %18 %87
225         %89 = OpIEqual %66 %86 %88
226               OpSelectionMerge %91 None
227               OpBranchConditional %89 %90 %91
228         %90 = OpLabel
229         %93 = OpAccessChain %36 %34 %19 %92
230         %94 = OpLoad %18 %93
231         %95 = OpAccessChain %36 %34 %19 %35
232         %96 = OpLoad %18 %95
233         %98 = OpAccessChain %36 %34 %19 %97
234         %99 = OpLoad %18 %98
235        %100 = OpExtInst %18 %1 SClamp %94 %96 %99
236        %101 = OpAccessChain %36 %34 %19 %35
237        %102 = OpLoad %18 %101
238        %103 = OpConvertSToF %6 %102
239        %104 = OpAccessChain %36 %34 %19 %92
240        %105 = OpLoad %18 %104
241        %106 = OpConvertSToF %6 %105
242        %107 = OpAccessChain %36 %34 %19 %92
243        %108 = OpLoad %18 %107
244        %109 = OpConvertSToF %6 %108
245        %110 = OpAccessChain %36 %34 %19 %35
246        %111 = OpLoad %18 %110
247        %112 = OpConvertSToF %6 %111
248        %113 = OpCompositeConstruct %7 %103 %106 %109 %112
249        %115 = OpAccessChain %114 %12 %100
250               OpStore %115 %113
251               OpBranch %91
252         %91 = OpLabel
253        %118 = OpAccessChain %36 %34 %19 %35
254        %119 = OpLoad %18 %118
255        %120 = OpAccessChain %114 %12 %119
256        %121 = OpLoad %7 %120
257        %122 = OpCompositeExtract %6 %121 0
258        %123 = OpCompositeExtract %6 %121 1
259        %124 = OpCompositeExtract %6 %121 2
260        %125 = OpCompositeExtract %6 %121 3
261        %126 = OpCompositeConstruct %7 %122 %123 %124 %125
262               OpStore %117 %126
263               OpReturn
264               OpFunctionEnd
265END
266
267# uniforms for variant
268
269# _GLF_uniform_int_values
270BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
271 2 1 0 15
272END
273# _GLF_uniform_float_values
274BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
275 1.0
276END
277
278BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
279
280PIPELINE graphics variant_pipeline
281  ATTACH variant_vertex_shader
282  ATTACH variant_fragment_shader
283  FRAMEBUFFER_SIZE 256 256
284  BIND BUFFER variant_framebuffer AS color LOCATION 0
285  BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
286  BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
287END
288CLEAR_COLOR variant_pipeline 0 0 0 255
289
290CLEAR variant_pipeline
291RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
292
293EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255
294