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