• 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 specific NIR code paths
21
22# The test passes because the shader always writes red.
23
24SHADER vertex texgen_vert PASSTHROUGH
25
26SHADER fragment texgen_frag GLSL
27#version 430
28precision highp float;
29
30layout(location = 0) out vec4 _GLF_color;
31
32void main()
33{
34 _GLF_color = vec4(
35 gl_FragCoord.x * (1.0 / 256.0),
36 (int(gl_FragCoord.x) ^ int(gl_FragCoord.y)) * (1.0 / 256.0),
37 gl_FragCoord.y * (1.0 / 256.0),
38 1.0);
39}
40END
41BUFFER default_texture FORMAT B8G8R8A8_UNORM
42
43PIPELINE graphics texgen_pipeline
44  ATTACH texgen_vert
45  ATTACH texgen_frag
46  FRAMEBUFFER_SIZE 256 256
47  BIND BUFFER default_texture AS color LOCATION 0
48END
49
50CLEAR_COLOR texgen_pipeline 0 0 0 255
51CLEAR texgen_pipeline
52RUN texgen_pipeline DRAW_RECT POS 0 0  SIZE 256 256
53
54SHADER vertex variant_vertex_shader PASSTHROUGH
55
56# variant_fragment_shader is derived from the following GLSL:
57# #version 320 es
58# #define _int_100 _GLF_uniform_int_values[0]
59# #define _int_0 _GLF_uniform_int_values[1]
60# #define _int_1 _GLF_uniform_int_values[2]
61# #define _float_0_0 _GLF_uniform_float_values[0]
62# #define _float_1_0 _GLF_uniform_float_values[1]
63# #define _float_256_0 _GLF_uniform_float_values[2]
64#
65# precision highp int;
66# precision highp float;
67#
68# // Contents of _GLF_uniform_float_values: [0.0, 1.0, 256.0]
69# layout(set = 0, binding = 0) uniform buf0
70# {
71#     float _GLF_uniform_float_values[3];
72# };
73# // Contents of _GLF_uniform_int_values: [100, 0, 1]
74# layout(set = 0, binding = 1) uniform buf1
75# {
76#     int _GLF_uniform_int_values[3];
77# };
78# layout(location = 0) out vec4 _GLF_color;
79#
80# layout(set = 0, binding = 2) uniform sampler2D tex;
81#
82# void main()
83# {
84#     vec4 texel = texture(tex, vec2(_float_0_0));
85#     vec4 texelCopy = texel;
86#
87#     // Sample from different location than texelCopy which should
88#     // result in different color value too.
89#     for(int i = _int_0; i < _int_100; i++)
90#         texel = texture(tex, vec2(_float_1_0 / _float_256_0));
91#
92#     // Always true.
93#     if(texelCopy != texel)
94#         _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
95#     else
96#         _GLF_color = vec4(_int_0);
97# }
98SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
99; SPIR-V
100; Version: 1.0
101; Generator: Khronos Glslang Reference Front End; 10
102; Bound: 89
103; Schema: 0
104               OpCapability Shader
105          %1 = OpExtInstImport "GLSL.std.450"
106               OpMemoryModel Logical GLSL450
107               OpEntryPoint Fragment %4 "main" %70
108               OpExecutionMode %4 OriginUpperLeft
109               OpSource ESSL 320
110               OpName %4 "main"
111               OpName %9 "texel"
112               OpName %13 "tex"
113               OpName %18 "buf0"
114               OpMemberName %18 0 "_GLF_uniform_float_values"
115               OpName %20 ""
116               OpName %29 "texelCopy"
117               OpName %32 "i"
118               OpName %34 "buf1"
119               OpMemberName %34 0 "_GLF_uniform_int_values"
120               OpName %36 ""
121               OpName %70 "_GLF_color"
122               OpDecorate %13 RelaxedPrecision
123               OpDecorate %13 DescriptorSet 0
124               OpDecorate %13 Binding 2
125               OpDecorate %14 RelaxedPrecision
126               OpDecorate %17 ArrayStride 16
127               OpMemberDecorate %18 0 Offset 0
128               OpDecorate %18 Block
129               OpDecorate %20 DescriptorSet 0
130               OpDecorate %20 Binding 0
131               OpDecorate %27 RelaxedPrecision
132               OpDecorate %28 RelaxedPrecision
133               OpDecorate %33 ArrayStride 16
134               OpMemberDecorate %34 0 Offset 0
135               OpDecorate %34 Block
136               OpDecorate %36 DescriptorSet 0
137               OpDecorate %36 Binding 1
138               OpDecorate %51 RelaxedPrecision
139               OpDecorate %58 RelaxedPrecision
140               OpDecorate %59 RelaxedPrecision
141               OpDecorate %70 Location 0
142          %2 = OpTypeVoid
143          %3 = OpTypeFunction %2
144          %6 = OpTypeFloat 32
145          %7 = OpTypeVector %6 4
146          %8 = OpTypePointer Function %7
147         %10 = OpTypeImage %6 2D 0 0 0 1 Unknown
148         %11 = OpTypeSampledImage %10
149         %12 = OpTypePointer UniformConstant %11
150         %13 = OpVariable %12 UniformConstant
151         %15 = OpTypeInt 32 0
152         %16 = OpConstant %15 3
153         %17 = OpTypeArray %6 %16
154         %18 = OpTypeStruct %17
155         %19 = OpTypePointer Uniform %18
156         %20 = OpVariable %19 Uniform
157         %21 = OpTypeInt 32 1
158         %22 = OpConstant %21 0
159         %23 = OpTypePointer Uniform %6
160         %26 = OpTypeVector %6 2
161         %31 = OpTypePointer Function %21
162         %33 = OpTypeArray %21 %16
163         %34 = OpTypeStruct %33
164         %35 = OpTypePointer Uniform %34
165         %36 = OpVariable %35 Uniform
166         %37 = OpConstant %21 1
167         %38 = OpTypePointer Uniform %21
168         %49 = OpTypeBool
169         %54 = OpConstant %21 2
170         %64 = OpTypeVector %49 4
171         %69 = OpTypePointer Output %7
172         %70 = OpVariable %69 Output
173          %4 = OpFunction %2 None %3
174          %5 = OpLabel
175          %9 = OpVariable %8 Function
176         %29 = OpVariable %8 Function
177         %32 = OpVariable %31 Function
178         %14 = OpLoad %11 %13
179         %24 = OpAccessChain %23 %20 %22 %22
180         %25 = OpLoad %6 %24
181         %27 = OpCompositeConstruct %26 %25 %25
182         %28 = OpImageSampleImplicitLod %7 %14 %27
183               OpStore %9 %28
184         %30 = OpLoad %7 %9
185               OpStore %29 %30
186         %39 = OpAccessChain %38 %36 %22 %37
187         %40 = OpLoad %21 %39
188               OpStore %32 %40
189               OpBranch %41
190         %41 = OpLabel
191               OpLoopMerge %43 %44 None
192               OpBranch %45
193         %45 = OpLabel
194         %46 = OpLoad %21 %32
195         %47 = OpAccessChain %38 %36 %22 %22
196         %48 = OpLoad %21 %47
197         %50 = OpSLessThan %49 %46 %48
198               OpBranchConditional %50 %42 %43
199         %42 = OpLabel
200         %51 = OpLoad %11 %13
201         %52 = OpAccessChain %23 %20 %22 %37
202         %53 = OpLoad %6 %52
203         %55 = OpAccessChain %23 %20 %22 %54
204         %56 = OpLoad %6 %55
205         %57 = OpFDiv %6 %53 %56
206         %58 = OpCompositeConstruct %26 %57 %57
207         %59 = OpImageSampleImplicitLod %7 %51 %58
208               OpStore %9 %59
209               OpBranch %44
210         %44 = OpLabel
211         %60 = OpLoad %21 %32
212         %61 = OpIAdd %21 %60 %37
213               OpStore %32 %61
214               OpBranch %41
215         %43 = OpLabel
216         %62 = OpLoad %7 %29
217         %63 = OpLoad %7 %9
218         %65 = OpFUnordNotEqual %64 %62 %63
219         %66 = OpAny %49 %65
220               OpSelectionMerge %68 None
221               OpBranchConditional %66 %67 %84
222         %67 = OpLabel
223         %71 = OpAccessChain %38 %36 %22 %54
224         %72 = OpLoad %21 %71
225         %73 = OpConvertSToF %6 %72
226         %74 = OpAccessChain %38 %36 %22 %37
227         %75 = OpLoad %21 %74
228         %76 = OpConvertSToF %6 %75
229         %77 = OpAccessChain %38 %36 %22 %37
230         %78 = OpLoad %21 %77
231         %79 = OpConvertSToF %6 %78
232         %80 = OpAccessChain %38 %36 %22 %54
233         %81 = OpLoad %21 %80
234         %82 = OpConvertSToF %6 %81
235         %83 = OpCompositeConstruct %7 %73 %76 %79 %82
236               OpStore %70 %83
237               OpBranch %68
238         %84 = OpLabel
239         %85 = OpAccessChain %38 %36 %22 %37
240         %86 = OpLoad %21 %85
241         %87 = OpConvertSToF %6 %86
242         %88 = OpCompositeConstruct %7 %87 %87 %87 %87
243               OpStore %70 %88
244               OpBranch %68
245         %68 = OpLabel
246               OpReturn
247               OpFunctionEnd
248END
249
250# uniforms for variant
251
252# tex
253SAMPLER variant_tex
254
255# _GLF_uniform_int_values
256BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
257 100 0 1
258END
259# _GLF_uniform_float_values
260BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
261 0.0 1.0 256.0
262END
263
264BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
265
266PIPELINE graphics variant_pipeline
267  ATTACH variant_vertex_shader
268  ATTACH variant_fragment_shader
269  FRAMEBUFFER_SIZE 256 256
270  BIND BUFFER variant_framebuffer AS color LOCATION 0
271  BIND BUFFER default_texture AS combined_image_sampler SAMPLER variant_tex DESCRIPTOR_SET 0 BINDING 2
272  BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
273  BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
274END
275CLEAR_COLOR variant_pipeline 0 0 0 255
276
277CLEAR variant_pipeline
278RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
279
280EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255
281