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