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