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