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