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