Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / similar-nested-ifs.amber
1 #!amber
2
3 # Copyright 2019 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 bug found by GraphicsFuzz.
19
20 # Short description: A fragment shader with similar nested ifs and loops
21
22 # The test passes because most of the shader does not execute; the shader writes the color red.
23
24 SHADER vertex variant_vertex_shader PASSTHROUGH
25
26 # variant_fragment_shader is derived from the following GLSL:
27 # #version 310 es
28 # precision highp float;
29 #
30 # layout(set = 0, binding = 0) uniform buf0
31 # {
32 #   vec2 injectionSwitch;
33 # };
34 # layout(location = 0) out vec4 _GLF_color;
35 #
36 # float gv;
37 #
38 # void main()
39 # {
40 #   float lv = (1.0 > injectionSwitch.y) ? abs(gv) : 260.0;
41 #   if (int(lv) < 250)
42 #   {
43 #     if (int(lv) < 180)
44 #     {
45 #       clamp(lv, 1.0, 1.0);
46 #     }
47 #     else if (gl_FragCoord.y < 0.0) // always false
48 #     {
49 #       if (int(lv) < 210)
50 #       {
51 #         do
52 #         {
53 #         } while (true);
54 #       }
55 #       int GLF_live5_looplimiter6;
56 #       for (
57 #           int GLF_live5r = 0;
58 #           true;
59 #           1)
60 #       {
61 #         if (GLF_live5_looplimiter6 >= 6)
62 #         {
63 #           break;
64 #         }
65 #         GLF_live5_looplimiter6++;
66 #       }
67 #     }
68 #   }
69 #   _GLF_color = vec4(1.0, 0.0, 0.0, 1.0);
70 # }
71 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
72 ; SPIR-V
73 ; Version: 1.0
74 ; Generator: Khronos Glslang Reference Front End; 7
75 ; Bound: 89
76 ; Schema: 0
77                OpCapability Shader
78           %1 = OpExtInstImport "GLSL.std.450"
79                OpMemoryModel Logical GLSL450
80                OpEntryPoint Fragment %4 "main" %50 %87
81                OpExecutionMode %4 OriginUpperLeft
82                OpSource ESSL 310
83                OpName %4 "main"
84                OpName %8 "lv"
85                OpName %11 "buf0"
86                OpMemberName %11 0 "injectionSwitch"
87                OpName %13 ""
88                OpName %27 "gv"
89                OpName %50 "gl_FragCoord"
90                OpName %70 "GLF_live5r"
91                OpName %76 "GLF_live5_looplimiter6"
92                OpName %87 "_GLF_color"
93                OpMemberDecorate %11 0 Offset 0
94                OpDecorate %11 Block
95                OpDecorate %13 DescriptorSet 0
96                OpDecorate %13 Binding 0
97                OpDecorate %50 BuiltIn FragCoord
98                OpDecorate %70 RelaxedPrecision
99                OpDecorate %76 RelaxedPrecision
100                OpDecorate %77 RelaxedPrecision
101                OpDecorate %83 RelaxedPrecision
102                OpDecorate %85 RelaxedPrecision
103                OpDecorate %87 Location 0
104           %2 = OpTypeVoid
105           %3 = OpTypeFunction %2
106           %6 = OpTypeFloat 32
107           %7 = OpTypePointer Function %6
108           %9 = OpConstant %6 1
109          %10 = OpTypeVector %6 2
110          %11 = OpTypeStruct %10
111          %12 = OpTypePointer Uniform %11
112          %13 = OpVariable %12 Uniform
113          %14 = OpTypeInt 32 1
114          %15 = OpConstant %14 0
115          %16 = OpTypeInt 32 0
116          %17 = OpConstant %16 1
117          %18 = OpTypePointer Uniform %6
118          %21 = OpTypeBool
119          %26 = OpTypePointer Private %6
120          %27 = OpVariable %26 Private
121          %31 = OpConstant %6 260
122          %35 = OpConstant %14 250
123          %41 = OpConstant %14 180
124          %48 = OpTypeVector %6 4
125          %49 = OpTypePointer Input %48
126          %50 = OpVariable %49 Input
127          %51 = OpTypePointer Input %6
128          %54 = OpConstant %6 0
129          %60 = OpConstant %14 210
130          %68 = OpConstantTrue %21
131          %69 = OpTypePointer Function %14
132          %78 = OpConstant %14 6
133          %84 = OpConstant %14 1
134          %86 = OpTypePointer Output %48
135          %87 = OpVariable %86 Output
136          %88 = OpConstantComposite %48 %9 %54 %54 %9
137           %4 = OpFunction %2 None %3
138           %5 = OpLabel
139           %8 = OpVariable %7 Function
140          %23 = OpVariable %7 Function
141          %70 = OpVariable %69 Function
142          %76 = OpVariable %69 Function
143          %19 = OpAccessChain %18 %13 %15 %17
144          %20 = OpLoad %6 %19
145          %22 = OpFOrdGreaterThan %21 %9 %20
146                OpSelectionMerge %25 None
147                OpBranchConditional %22 %24 %30
148          %24 = OpLabel
149          %28 = OpLoad %6 %27
150          %29 = OpExtInst %6 %1 FAbs %28
151                OpStore %23 %29
152                OpBranch %25
153          %30 = OpLabel
154                OpStore %23 %31
155                OpBranch %25
156          %25 = OpLabel
157          %32 = OpLoad %6 %23
158                OpStore %8 %32
159          %33 = OpLoad %6 %8
160          %34 = OpConvertFToS %14 %33
161          %36 = OpSLessThan %21 %34 %35
162                OpSelectionMerge %38 None
163                OpBranchConditional %36 %37 %38
164          %37 = OpLabel
165          %39 = OpLoad %6 %8
166          %40 = OpConvertFToS %14 %39
167          %42 = OpSLessThan %21 %40 %41
168                OpSelectionMerge %44 None
169                OpBranchConditional %42 %43 %47
170          %43 = OpLabel
171          %45 = OpLoad %6 %8
172          %46 = OpExtInst %6 %1 FClamp %45 %9 %9
173                OpBranch %44
174          %47 = OpLabel
175          %52 = OpAccessChain %51 %50 %17
176          %53 = OpLoad %6 %52
177          %55 = OpFOrdLessThan %21 %53 %54
178                OpSelectionMerge %57 None
179                OpBranchConditional %55 %56 %57
180          %56 = OpLabel
181          %58 = OpLoad %6 %8
182          %59 = OpConvertFToS %14 %58
183          %61 = OpSLessThan %21 %59 %60
184                OpSelectionMerge %63 None
185                OpBranchConditional %61 %62 %63
186          %62 = OpLabel
187                OpBranch %64
188          %64 = OpLabel
189                OpLoopMerge %66 %67 None
190                OpBranch %65
191          %65 = OpLabel
192                OpBranch %67
193          %67 = OpLabel
194                OpBranchConditional %68 %64 %66
195          %66 = OpLabel
196                OpBranch %63
197          %63 = OpLabel
198                OpStore %70 %15
199                OpBranch %71
200          %71 = OpLabel
201                OpLoopMerge %73 %74 None
202                OpBranch %75
203          %75 = OpLabel
204                OpBranchConditional %68 %72 %73
205          %72 = OpLabel
206          %77 = OpLoad %14 %76
207          %79 = OpSGreaterThanEqual %21 %77 %78
208                OpSelectionMerge %81 None
209                OpBranchConditional %79 %80 %81
210          %80 = OpLabel
211                OpBranch %73
212          %81 = OpLabel
213          %83 = OpLoad %14 %76
214          %85 = OpIAdd %14 %83 %84
215                OpStore %76 %85
216                OpBranch %74
217          %74 = OpLabel
218                OpBranch %71
219          %73 = OpLabel
220                OpBranch %57
221          %57 = OpLabel
222                OpBranch %44
223          %44 = OpLabel
224                OpBranch %38
225          %38 = OpLabel
226                OpStore %87 %88
227                OpReturn
228                OpFunctionEnd
229 END
230
231 # uniforms for variant
232
233 # injectionSwitch
234 BUFFER variant_injectionSwitch DATA_TYPE vec2<float> DATA
235  0.0 1.0
236 END
237
238 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
239
240 PIPELINE graphics variant_pipeline
241   ATTACH variant_vertex_shader
242   ATTACH variant_fragment_shader
243   FRAMEBUFFER_SIZE 256 256
244   BIND BUFFER variant_framebuffer AS color LOCATION 0
245   BIND BUFFER variant_injectionSwitch AS uniform DESCRIPTOR_SET 0 BINDING 0
246 END
247 CLEAR_COLOR variant_pipeline 0 0 0 255
248
249 CLEAR variant_pipeline
250 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
251
252 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255