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