Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / return-in-loop-in-function.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 # A test for a bug found by GraphicsFuzz.
18
19 # Short description: A fragment shader with early return from loop in function
20
21 # The test passes because the fragment shader writes red. The f function always
22 # returns 1.0, so c is unchanged.
23
24 # Optimized using spirv-opt with the following arguments:
25 # '--merge-blocks'
26 # spirv-opt commit hash: 4a00a80c40484a6f6f72f48c9d34943cf8f180d4
27
28 # Derived from the following GLSL.
29
30 # Fragment shader GLSL:
31 # #version 310 es
32 #
33 # precision highp float;
34 #
35 # layout(location = 0) out vec4 _GLF_color;
36 #
37 # float f()
38 # {
39 #  for(
40 #      int i = 1;
41 #      i < 10;
42 #      i ++
43 #  )
44 #   {
45 #    if(float(i) >= 1.0)
46 #     {
47 #      return 1.0;
48 #     }
49 #   }
50 #  return 1.0;
51 # }
52 # void main()
53 # {
54 #  vec4 c = vec4(1.0, 0.0, 0.0, 1.0);
55 #  for(
56 #      int i = 0;
57 #      i < 1;
58 #      i ++
59 #  )
60 #   {
61 #    c.x = f();
62 #   }
63 #  _GLF_color = c;
64 # }
65
66 SHADER vertex variant_vertex_shader PASSTHROUGH
67
68 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
69 ; SPIR-V
70 ; Version: 1.0
71 ; Generator: Khronos Glslang Reference Front End; 7
72 ; Bound: 59
73 ; Schema: 0
74                OpCapability Shader
75           %1 = OpExtInstImport "GLSL.std.450"
76                OpMemoryModel Logical GLSL450
77                OpEntryPoint Fragment %4 "main" %56
78                OpExecutionMode %4 OriginUpperLeft
79                OpSource ESSL 310
80                OpName %4 "main"
81                OpName %8 "f("
82                OpName %12 "i"
83                OpName %36 "c"
84                OpName %39 "i"
85                OpName %56 "_GLF_color"
86                OpDecorate %12 RelaxedPrecision
87                OpDecorate %19 RelaxedPrecision
88                OpDecorate %23 RelaxedPrecision
89                OpDecorate %30 RelaxedPrecision
90                OpDecorate %31 RelaxedPrecision
91                OpDecorate %39 RelaxedPrecision
92                OpDecorate %46 RelaxedPrecision
93                OpDecorate %53 RelaxedPrecision
94                OpDecorate %54 RelaxedPrecision
95                OpDecorate %56 Location 0
96           %2 = OpTypeVoid
97           %3 = OpTypeFunction %2
98           %6 = OpTypeFloat 32
99           %7 = OpTypeFunction %6
100          %10 = OpTypeInt 32 1
101          %11 = OpTypePointer Function %10
102          %13 = OpConstant %10 1
103          %20 = OpConstant %10 10
104          %21 = OpTypeBool
105          %25 = OpConstant %6 1
106          %34 = OpTypeVector %6 4
107          %35 = OpTypePointer Function %34
108          %37 = OpConstant %6 0
109          %38 = OpConstantComposite %34 %25 %37 %37 %25
110          %40 = OpConstant %10 0
111          %49 = OpTypeInt 32 0
112          %50 = OpConstant %49 0
113          %51 = OpTypePointer Function %6
114          %55 = OpTypePointer Output %34
115          %56 = OpVariable %55 Output
116           %4 = OpFunction %2 None %3
117           %5 = OpLabel
118          %36 = OpVariable %35 Function
119          %39 = OpVariable %11 Function
120                OpStore %36 %38
121                OpStore %39 %40
122                OpBranch %41
123          %41 = OpLabel
124          %46 = OpLoad %10 %39
125          %47 = OpSLessThan %21 %46 %13
126                OpLoopMerge %43 %42 None
127                OpBranchConditional %47 %42 %43
128          %42 = OpLabel
129          %48 = OpFunctionCall %6 %8
130          %52 = OpAccessChain %51 %36 %50
131                OpStore %52 %48
132          %53 = OpLoad %10 %39
133          %54 = OpIAdd %10 %53 %13
134                OpStore %39 %54
135                OpBranch %41
136          %43 = OpLabel
137          %57 = OpLoad %34 %36
138                OpStore %56 %57
139                OpReturn
140                OpFunctionEnd
141           %8 = OpFunction %6 None %7
142           %9 = OpLabel
143          %12 = OpVariable %11 Function
144                OpStore %12 %13
145                OpBranch %14
146          %14 = OpLabel
147          %19 = OpLoad %10 %12
148          %22 = OpSLessThan %21 %19 %20
149                OpLoopMerge %16 %28 None
150                OpBranchConditional %22 %15 %16
151          %15 = OpLabel
152          %23 = OpLoad %10 %12
153          %24 = OpConvertSToF %6 %23
154          %26 = OpFOrdGreaterThanEqual %21 %24 %25
155                OpSelectionMerge %58 None
156                OpBranchConditional %26 %27 %28
157          %27 = OpLabel
158                OpReturnValue %25
159          %58 = OpLabel
160                OpBranch %28
161          %28 = OpLabel
162          %30 = OpLoad %10 %12
163          %31 = OpIAdd %10 %30 %13
164                OpStore %12 %31
165                OpBranch %14
166          %16 = OpLabel
167                OpReturnValue %25
168                OpFunctionEnd
169 END
170
171 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
172
173 PIPELINE graphics variant_pipeline
174   ATTACH variant_vertex_shader
175   ATTACH variant_fragment_shader
176   FRAMEBUFFER_SIZE 256 256
177   BIND BUFFER variant_framebuffer AS color LOCATION 0
178 END
179 CLEAR_COLOR variant_pipeline 0 0 0 255
180
181 CLEAR variant_pipeline
182 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
183
184 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255