Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / cov-return-partly-undefined-vector-from-array.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 specific NIR code paths
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 320 es
28 #
29 # #define _int_1 _GLF_uniform_int_values[0]
30 # #define _int_0 _GLF_uniform_int_values[1]
31 # #define _float_5_0 _GLF_uniform_float_values[0]
32 # #define _float_1_0 _GLF_uniform_float_values[1]
33 #
34 # precision highp int;
35 # precision highp float;
36 #
37 # // Contents of _GLF_uniform_float_values: [5.0, 1.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: [1, 0]
44 # layout(set = 0, binding = 1) uniform buf1
45 # {
46 #     int _GLF_uniform_int_values[2];
47 # };
48 #
49 # layout(location = 0) out vec4 _GLF_color;
50 #
51 # vec2 func()
52 # {
53 #     vec2 v;
54 #     v.y = _float_5_0;
55 #     int a = 2;
56 #     return vec2[3](vec2(_float_1_0), vec2(_float_1_0), v)[a];
57 # }
58 #
59 # void main()
60 # {
61 #     if(func().y == _float_5_0)
62 #     {
63 #         _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
64 #     }
65 #     else
66 #     {
67 #         _GLF_color = vec4(_int_0);
68 #     }
69 # }
70 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
71 ; SPIR-V
72 ; Version: 1.0
73 ; Generator: Khronos Glslang Reference Front End; 10
74 ; Bound: 82
75 ; Schema: 0
76                OpCapability Shader
77           %1 = OpExtInstImport "GLSL.std.450"
78                OpMemoryModel Logical GLSL450
79                OpEntryPoint Fragment %4 "main" %58
80                OpExecutionMode %4 OriginUpperLeft
81                OpSource ESSL 320
82                OpName %4 "main"
83                OpName %9 "func("
84                OpName %12 "v"
85                OpName %16 "buf0"
86                OpMemberName %16 0 "_GLF_uniform_float_values"
87                OpName %18 ""
88                OpName %28 "a"
89                OpName %43 "indexable"
90                OpName %58 "_GLF_color"
91                OpName %60 "buf1"
92                OpMemberName %60 0 "_GLF_uniform_int_values"
93                OpName %62 ""
94                OpDecorate %15 ArrayStride 16
95                OpMemberDecorate %16 0 Offset 0
96                OpDecorate %16 Block
97                OpDecorate %18 DescriptorSet 0
98                OpDecorate %18 Binding 0
99                OpDecorate %58 Location 0
100                OpDecorate %59 ArrayStride 16
101                OpMemberDecorate %60 0 Offset 0
102                OpDecorate %60 Block
103                OpDecorate %62 DescriptorSet 0
104                OpDecorate %62 Binding 1
105           %2 = OpTypeVoid
106           %3 = OpTypeFunction %2
107           %6 = OpTypeFloat 32
108           %7 = OpTypeVector %6 2
109           %8 = OpTypeFunction %7
110          %11 = OpTypePointer Function %7
111          %13 = OpTypeInt 32 0
112          %14 = OpConstant %13 2
113          %15 = OpTypeArray %6 %14
114          %16 = OpTypeStruct %15
115          %17 = OpTypePointer Uniform %16
116          %18 = OpVariable %17 Uniform
117          %19 = OpTypeInt 32 1
118          %20 = OpConstant %19 0
119          %21 = OpTypePointer Uniform %6
120          %24 = OpConstant %13 1
121          %25 = OpTypePointer Function %6
122          %27 = OpTypePointer Function %19
123          %29 = OpConstant %19 2
124          %30 = OpConstant %19 1
125          %38 = OpConstant %13 3
126          %39 = OpTypeArray %7 %38
127          %42 = OpTypePointer Function %39
128          %52 = OpTypeBool
129          %56 = OpTypeVector %6 4
130          %57 = OpTypePointer Output %56
131          %58 = OpVariable %57 Output
132          %59 = OpTypeArray %19 %14
133          %60 = OpTypeStruct %59
134          %61 = OpTypePointer Uniform %60
135          %62 = OpVariable %61 Uniform
136          %63 = OpTypePointer Uniform %19
137           %4 = OpFunction %2 None %3
138           %5 = OpLabel
139          %48 = OpFunctionCall %7 %9
140          %49 = OpCompositeExtract %6 %48 1
141          %50 = OpAccessChain %21 %18 %20 %20
142          %51 = OpLoad %6 %50
143          %53 = OpFOrdEqual %52 %49 %51
144                OpSelectionMerge %55 None
145                OpBranchConditional %53 %54 %77
146          %54 = OpLabel
147          %64 = OpAccessChain %63 %62 %20 %20
148          %65 = OpLoad %19 %64
149          %66 = OpConvertSToF %6 %65
150          %67 = OpAccessChain %63 %62 %20 %30
151          %68 = OpLoad %19 %67
152          %69 = OpConvertSToF %6 %68
153          %70 = OpAccessChain %63 %62 %20 %30
154          %71 = OpLoad %19 %70
155          %72 = OpConvertSToF %6 %71
156          %73 = OpAccessChain %63 %62 %20 %20
157          %74 = OpLoad %19 %73
158          %75 = OpConvertSToF %6 %74
159          %76 = OpCompositeConstruct %56 %66 %69 %72 %75
160                OpStore %58 %76
161                OpBranch %55
162          %77 = OpLabel
163          %78 = OpAccessChain %63 %62 %20 %30
164          %79 = OpLoad %19 %78
165          %80 = OpConvertSToF %6 %79
166          %81 = OpCompositeConstruct %56 %80 %80 %80 %80
167                OpStore %58 %81
168                OpBranch %55
169          %55 = OpLabel
170                OpReturn
171                OpFunctionEnd
172           %9 = OpFunction %7 None %8
173          %10 = OpLabel
174          %12 = OpVariable %11 Function
175          %28 = OpVariable %27 Function
176          %43 = OpVariable %42 Function
177          %22 = OpAccessChain %21 %18 %20 %20
178          %23 = OpLoad %6 %22
179          %26 = OpAccessChain %25 %12 %24
180                OpStore %26 %23
181                OpStore %28 %29
182          %31 = OpAccessChain %21 %18 %20 %30
183          %32 = OpLoad %6 %31
184          %33 = OpCompositeConstruct %7 %32 %32
185          %34 = OpAccessChain %21 %18 %20 %30
186          %35 = OpLoad %6 %34
187          %36 = OpCompositeConstruct %7 %35 %35
188          %37 = OpLoad %7 %12
189          %40 = OpCompositeConstruct %39 %33 %36 %37
190          %41 = OpLoad %19 %28
191                OpStore %43 %40
192          %44 = OpAccessChain %11 %43 %41
193          %45 = OpLoad %7 %44
194                OpReturnValue %45
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  1 0
203 END
204 # _GLF_uniform_float_values
205 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
206  5.0 1.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