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