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