Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / struct-controlled-loop.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: Shader with loop controlled by struct
21
22 # The test passes because 'sums[0]' ends up being 0, so that the colour that is written is guaranteed to be red
23
24 # Optimized using spirv-opt with the following arguments:
25 # '--private-to-local'
26 # '--eliminate-dead-branches'
27 # '--merge-return'
28 # '--reduce-load-size'
29 # '--eliminate-dead-code-aggressive'
30 # '--ccp'
31 # '--eliminate-dead-code-aggressive'
32 # '--if-conversion'
33 # '--convert-local-access-chains'
34 # '--eliminate-dead-branches'
35 # '--merge-return'
36 # '--eliminate-local-single-store'
37 # '--ccp'
38 # '--eliminate-dead-branches'
39 # '--merge-return'
40 # '--eliminate-local-single-store'
41 # '--eliminate-dead-inserts'
42 # '--eliminate-local-multi-store'
43 # '--copy-propagate-arrays'
44 # '--combine-access-chains'
45 # '--redundancy-elimination'
46 # '--if-conversion'
47 # '--eliminate-local-multi-store'
48 # '--eliminate-dead-code-aggressive'
49 # spirv-opt commit hash: f1e5cd73f658abcc23ee96d78f2dc27c4b7028c1
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 # struct S {
60 #  int f0;
61 #  bvec3 f1;
62 # } ;
63 #
64 # layout(set = 0, binding = 0) uniform buf0 {
65 #  vec2 injectionSwitch;
66 # };
67 # layout(location = 0) out vec4 _GLF_color;
68 #
69 # void main()
70 # {
71 #  float sums[9];
72 #  for(
73 #      S ll = S(0, bvec3(true));
74 #      ll.f0 != int((injectionSwitch.y));
75 #      ll.f0 ++
76 #  )
77 #   {
78 #    sums[0] = 0.0;
79 #   }
80 #  int overall_region = 0;
81 #  _GLF_color = vec4(1.0, vec2(sums[overall_region]), 1.0);
82 # }
83 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
84 ; SPIR-V
85 ; Version: 1.0
86 ; Generator: Khronos Glslang Reference Front End; 8
87 ; Bound: 63
88 ; Schema: 0
89                OpCapability Shader
90           %1 = OpExtInstImport "GLSL.std.450"
91                OpMemoryModel Logical GLSL450
92                OpEntryPoint Fragment %4 "main" %50
93                OpExecutionMode %4 OriginUpperLeft
94                OpSource ESSL 310
95                OpName %4 "main"
96                OpName %9 "S"
97                OpMemberName %9 0 "f0"
98                OpMemberName %9 1 "f1"
99                OpName %11 "ll"
100                OpName %26 "buf0"
101                OpMemberName %26 0 "injectionSwitch"
102                OpName %28 ""
103                OpName %39 "sums"
104                OpName %50 "_GLF_color"
105                OpMemberDecorate %9 0 RelaxedPrecision
106                OpDecorate %23 RelaxedPrecision
107                OpMemberDecorate %26 0 Offset 0
108                OpDecorate %26 Block
109                OpDecorate %28 DescriptorSet 0
110                OpDecorate %28 Binding 0
111                OpDecorate %44 RelaxedPrecision
112                OpDecorate %46 RelaxedPrecision
113                OpDecorate %50 Location 0
114                OpDecorate %59 RelaxedPrecision
115                OpDecorate %60 RelaxedPrecision
116           %2 = OpTypeVoid
117           %3 = OpTypeFunction %2
118           %6 = OpTypeInt 32 1
119           %7 = OpTypeBool
120           %8 = OpTypeVector %7 3
121           %9 = OpTypeStruct %6 %8
122          %10 = OpTypePointer Function %9
123          %12 = OpConstant %6 0
124          %13 = OpConstantTrue %7
125          %14 = OpConstantComposite %8 %13 %13 %13
126          %15 = OpConstantComposite %9 %12 %14
127          %24 = OpTypeFloat 32
128          %25 = OpTypeVector %24 2
129          %26 = OpTypeStruct %25
130          %27 = OpTypePointer Uniform %26
131          %28 = OpVariable %27 Uniform
132          %29 = OpTypeInt 32 0
133          %30 = OpConstant %29 1
134          %31 = OpTypePointer Uniform %24
135          %36 = OpConstant %29 9
136          %37 = OpTypeArray %24 %36
137          %38 = OpTypePointer Function %37
138          %40 = OpConstant %24 0
139          %41 = OpTypePointer Function %24
140          %45 = OpConstant %6 1
141          %48 = OpTypeVector %24 4
142          %49 = OpTypePointer Output %48
143          %50 = OpVariable %49 Output
144          %51 = OpConstant %24 1
145           %4 = OpFunction %2 None %3
146           %5 = OpLabel
147          %11 = OpVariable %10 Function
148          %39 = OpVariable %38 Function
149                OpStore %11 %15
150                OpBranch %16
151          %16 = OpLabel
152                OpLoopMerge %18 %19 None
153                OpBranch %20
154          %20 = OpLabel
155          %59 = OpLoad %9 %11
156          %23 = OpCompositeExtract %6 %59 0
157          %32 = OpAccessChain %31 %28 %12 %30
158          %33 = OpLoad %24 %32
159          %34 = OpConvertFToS %6 %33
160          %35 = OpINotEqual %7 %23 %34
161                OpBranchConditional %35 %17 %18
162          %17 = OpLabel
163          %42 = OpAccessChain %41 %39 %12
164                OpStore %42 %40
165                OpBranch %19
166          %19 = OpLabel
167          %60 = OpLoad %9 %11
168          %44 = OpCompositeExtract %6 %60 0
169          %46 = OpIAdd %6 %44 %45
170          %61 = OpLoad %9 %11
171          %62 = OpCompositeInsert %9 %46 %61 0
172                OpStore %11 %62
173                OpBranch %16
174          %18 = OpLabel
175          %53 = OpAccessChain %41 %39 %12
176          %54 = OpLoad %24 %53
177          %55 = OpCompositeConstruct %25 %54 %54
178          %56 = OpCompositeExtract %24 %55 0
179          %57 = OpCompositeExtract %24 %55 1
180          %58 = OpCompositeConstruct %48 %51 %56 %57 %51
181                OpStore %50 %58
182                OpReturn
183                OpFunctionEnd
184 END
185
186 # uniforms for variant
187
188 # injectionSwitch
189 BUFFER variant_injectionSwitch DATA_TYPE vec2<float> DATA
190  0.0 1.0
191 END
192
193 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
194
195 PIPELINE graphics variant_pipeline
196   ATTACH variant_vertex_shader
197   ATTACH variant_fragment_shader
198   FRAMEBUFFER_SIZE 256 256
199   BIND BUFFER variant_framebuffer AS color LOCATION 0
200   BIND BUFFER variant_injectionSwitch AS uniform DESCRIPTOR_SET 0 BINDING 0
201 END
202 CLEAR_COLOR variant_pipeline 0 0 0 255
203
204 CLEAR variant_pipeline
205 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
206
207 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255