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