Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / cov-wrap-op-kill-two-branches.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 GraphicsFuzz.
19
20 # Short description: A fragment shader that covers a specific OpKill wrapping path.
21
22 # The test passes because shader always writes red.
23
24 # Optimized using spirv-opt with the following arguments:
25 # '--convert-local-access-chains'
26 # '--eliminate-dead-branches'
27 # '--merge-blocks'
28 # '--eliminate-local-single-store'
29 # '--eliminate-dead-branches'
30 # '--merge-return'
31 # '--inline-entry-points-exhaustive'
32 # '--copy-propagate-arrays'
33 # '--if-conversion'
34 # '--reduce-load-size'
35 # '--convert-local-access-chains'
36 # '--if-conversion'
37 # '--redundancy-elimination'
38 # '--if-conversion'
39 # '--simplify-instructions'
40 # '--scalar-replacement=100'
41 # '--simplify-instructions'
42 # '--if-conversion'
43 # '--eliminate-dead-inserts'
44 # '--eliminate-dead-branches'
45 # '--eliminate-dead-code-aggressive'
46 # spirv-opt commit hash: 9215c1b7df0029f27807e8c8d7ec80532ce90a87
47
48
49
50 SHADER vertex variant_vertex_shader PASSTHROUGH
51
52 # variant_fragment_shader is derived from the following GLSL:
53 # #version 310 es
54 # precision highp float;
55 # precision highp int;
56 #
57 # layout(location = 0) out vec4 _GLF_color;
58 # layout(set = 0, binding = 0) uniform buf0
59 # {
60 #     int five;
61 # };
62 #
63 # float func(float x)
64 # {
65 #     if (x > 5.0)
66 #     {
67 #         if (gl_FragCoord.x < 0.5)
68 #             discard;
69 #         else if (gl_FragCoord.y < 0.5)
70 #             discard;
71 #     }
72 #
73 #     return x + 1.0;
74 # }
75 #
76 # void main()
77 # {
78 #     float f = 0.0;
79 #
80 #     for(int i = 0; i < five; i++)
81 #         f = func(float(i));
82 #
83 #     if (f == 5.0)
84 #         _GLF_color = vec4(1, 0, 0, 1);
85 #     else
86 #         _GLF_color = vec4(0);
87 # }
88 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
89 ; SPIR-V
90 ; Version: 1.0
91 ; Generator: Khronos Glslang Reference Front End; 8
92 ; Bound: 79
93 ; Schema: 0
94                OpCapability Shader
95           %1 = OpExtInstImport "GLSL.std.450"
96                OpMemoryModel Logical GLSL450
97                OpEntryPoint Fragment %4 "main" %20 %75
98                OpExecutionMode %4 OriginUpperLeft
99                OpSource ESSL 310
100                OpName %4 "main"
101                OpName %10 "func(f1;"
102                OpName %9 "x"
103                OpName %20 "gl_FragCoord"
104                OpName %44 "f"
105                OpName %48 "i"
106                OpName %56 "buf0"
107                OpMemberName %56 0 "five"
108                OpName %58 ""
109                OpName %65 "param"
110                OpName %75 "_GLF_color"
111                OpDecorate %20 BuiltIn FragCoord
112                OpMemberDecorate %56 0 Offset 0
113                OpDecorate %56 Block
114                OpDecorate %58 DescriptorSet 0
115                OpDecorate %58 Binding 0
116                OpDecorate %75 Location 0
117           %2 = OpTypeVoid
118           %3 = OpTypeFunction %2
119           %6 = OpTypeFloat 32
120           %7 = OpTypePointer Function %6
121           %8 = OpTypeFunction %6 %7
122          %13 = OpConstant %6 5
123          %14 = OpTypeBool
124          %18 = OpTypeVector %6 4
125          %19 = OpTypePointer Input %18
126          %20 = OpVariable %19 Input
127          %21 = OpTypeInt 32 0
128          %22 = OpConstant %21 0
129          %23 = OpTypePointer Input %6
130          %26 = OpConstant %6 0.5
131          %32 = OpConstant %21 1
132          %40 = OpConstant %6 1
133          %45 = OpConstant %6 0
134          %46 = OpTypeInt 32 1
135          %47 = OpTypePointer Function %46
136          %49 = OpConstant %46 0
137          %56 = OpTypeStruct %46
138          %57 = OpTypePointer Uniform %56
139          %58 = OpVariable %57 Uniform
140          %59 = OpTypePointer Uniform %46
141          %68 = OpConstant %46 1
142          %74 = OpTypePointer Output %18
143          %75 = OpVariable %74 Output
144          %76 = OpConstantComposite %18 %40 %45 %45 %40
145          %78 = OpConstantComposite %18 %45 %45 %45 %45
146           %4 = OpFunction %2 None %3
147           %5 = OpLabel
148          %44 = OpVariable %7 Function
149          %48 = OpVariable %47 Function
150          %65 = OpVariable %7 Function
151                OpStore %44 %45
152                OpStore %48 %49
153                OpBranch %50
154          %50 = OpLabel
155          %55 = OpLoad %46 %48
156          %60 = OpAccessChain %59 %58 %49
157          %61 = OpLoad %46 %60
158          %62 = OpSLessThan %14 %55 %61
159                OpLoopMerge %52 %51 None
160                OpBranchConditional %62 %51 %52
161          %51 = OpLabel
162          %63 = OpLoad %46 %48
163          %64 = OpConvertSToF %6 %63
164                OpStore %65 %64
165          %66 = OpFunctionCall %6 %10 %65
166                OpStore %44 %66
167          %67 = OpLoad %46 %48
168          %69 = OpIAdd %46 %67 %68
169                OpStore %48 %69
170                OpBranch %50
171          %52 = OpLabel
172          %70 = OpLoad %6 %44
173          %71 = OpFOrdEqual %14 %70 %13
174                OpSelectionMerge %73 None
175                OpBranchConditional %71 %72 %77
176          %72 = OpLabel
177                OpStore %75 %76
178                OpBranch %73
179          %77 = OpLabel
180                OpStore %75 %78
181                OpBranch %73
182          %73 = OpLabel
183                OpReturn
184                OpFunctionEnd
185          %10 = OpFunction %6 None %8
186           %9 = OpFunctionParameter %7
187          %11 = OpLabel
188          %12 = OpLoad %6 %9
189          %15 = OpFOrdGreaterThan %14 %12 %13
190                OpSelectionMerge %17 None
191                OpBranchConditional %15 %16 %17
192          %16 = OpLabel
193          %24 = OpAccessChain %23 %20 %22
194          %25 = OpLoad %6 %24
195          %27 = OpFOrdLessThan %14 %25 %26
196                OpSelectionMerge %29 None
197                OpBranchConditional %27 %28 %31
198          %28 = OpLabel
199                OpKill
200          %31 = OpLabel
201          %33 = OpAccessChain %23 %20 %32
202          %34 = OpLoad %6 %33
203          %35 = OpFOrdLessThan %14 %34 %26
204                OpSelectionMerge %37 None
205                OpBranchConditional %35 %36 %37
206          %36 = OpLabel
207                OpKill
208          %37 = OpLabel
209                OpBranch %29
210          %29 = OpLabel
211                OpBranch %17
212          %17 = OpLabel
213          %39 = OpLoad %6 %9
214          %41 = OpFAdd %6 %39 %40
215                OpReturnValue %41
216                OpFunctionEnd
217 END
218
219 # uniforms for variant
220
221 # five
222 BUFFER variant_five DATA_TYPE int32 DATA
223  5
224 END
225
226 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
227
228 PIPELINE graphics variant_pipeline
229   ATTACH variant_vertex_shader
230   ATTACH variant_fragment_shader
231   FRAMEBUFFER_SIZE 256 256
232   BIND BUFFER variant_framebuffer AS color LOCATION 0
233   BIND BUFFER variant_five AS uniform DESCRIPTOR_SET 0 BINDING 0
234 END
235 CLEAR_COLOR variant_pipeline 0 0 0 255
236
237 CLEAR variant_pipeline
238 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
239
240 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255