Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / for-loop-with-return.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 a for loop that loops only once
21
22 # The test passes because the shader always writes the color red. The for loop only goes through once.
23
24 # Optimized using spirv-opt with the following arguments:
25 # '--vector-dce'
26 # '--eliminate-local-multi-store'
27 # '--eliminate-dead-branches'
28 # '--merge-blocks'
29 # '--eliminate-dead-branches'
30 # '--merge-blocks'
31 # '--ccp'
32 # '--eliminate-dead-inserts'
33 # '--convert-local-access-chains'
34 # '--vector-dce'
35 # '--eliminate-dead-code-aggressive'
36 # '--vector-dce'
37 # '--eliminate-local-multi-store'
38 # '--if-conversion'
39 # '--eliminate-dead-branches'
40 # spirv-opt commit hash: 06407250a169c6a03b3765e86619075af1a8c187
41
42
43
44 SHADER vertex variant_vertex_shader PASSTHROUGH
45
46 # variant_fragment_shader is derived from the following GLSL:
47 # #version 310 es
48 # precision highp float;
49 #
50 # precision highp int;
51 #
52 # layout(location = 0) out vec4 _GLF_color;
53 #
54 # vec3 mand()
55 # {
56 #   do
57 #   {
58 #     return vec3(1.0);
59 #   } while (true);
60 # }
61 # void main()
62 # {
63 #   mand();
64 #
65 #   for (
66 #       int i = 1;
67 #       true;
68 #       1)
69 #   {
70 #     _GLF_color = vec4(1.0, 0.0, 0.0, 1.0);
71 #     return;
72 #   }
73 # }
74 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
75 ; SPIR-V
76 ; Version: 1.0
77 ; Generator: Khronos Glslang Reference Front End; 7
78 ; Bound: 36
79 ; Schema: 0
80                OpCapability Shader
81           %1 = OpExtInstImport "GLSL.std.450"
82                OpMemoryModel Logical GLSL450
83                OpEntryPoint Fragment %4 "main" %33
84                OpExecutionMode %4 OriginUpperLeft
85                OpSource ESSL 310
86                OpName %4 "main"
87                OpName %9 "mand("
88                OpName %33 "_GLF_color"
89                OpDecorate %33 Location 0
90           %2 = OpTypeVoid
91           %3 = OpTypeFunction %2
92           %6 = OpTypeFloat 32
93           %7 = OpTypeVector %6 3
94           %8 = OpTypeFunction %7
95          %15 = OpConstant %6 1
96          %16 = OpConstantComposite %7 %15 %15 %15
97          %31 = OpTypeVector %6 4
98          %32 = OpTypePointer Output %31
99          %33 = OpVariable %32 Output
100          %34 = OpConstant %6 0
101          %35 = OpConstantComposite %31 %15 %34 %34 %15
102           %4 = OpFunction %2 None %3
103           %5 = OpLabel
104          %21 = OpFunctionCall %7 %9
105                OpBranch %26
106          %26 = OpLabel
107                OpLoopMerge %28 %29 None
108                OpBranch %27
109          %27 = OpLabel
110                OpStore %33 %35
111                OpReturn
112          %29 = OpLabel
113                OpBranch %26
114          %28 = OpLabel
115                OpUnreachable
116                OpFunctionEnd
117           %9 = OpFunction %7 None %8
118          %10 = OpLabel
119                OpBranch %11
120          %11 = OpLabel
121                OpLoopMerge %13 %14 None
122                OpBranch %12
123          %12 = OpLabel
124                OpReturnValue %16
125          %14 = OpLabel
126                OpBranch %11
127          %13 = OpLabel
128                OpUnreachable
129                OpFunctionEnd
130 END
131
132 # uniforms for variant
133
134
135 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
136
137 PIPELINE graphics variant_pipeline
138   ATTACH variant_vertex_shader
139   ATTACH variant_fragment_shader
140   FRAMEBUFFER_SIZE 256 256
141   BIND BUFFER variant_framebuffer AS color LOCATION 0
142 END
143 CLEAR_COLOR variant_pipeline 0 0 0 255
144
145 CLEAR variant_pipeline
146 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
147
148 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255