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