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