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