Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / function-with-uniform-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 uniform value as a return
21
22 # The test passes because shader always writes color red
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 # precision highp int;
31 #
32 # layout(location = 0) out vec4 _GLF_color;
33 #
34 # layout(set = 0, binding = 0) uniform buf0
35 # {
36 #   vec2 injectionSwitch;
37 # };
38 #
39 # float fx(){
40 #   if (gl_FragCoord.y >= 0.0)
41 #     return injectionSwitch.y;
42 #
43 #   while(true){
44 #     _GLF_color = vec4(1.0, 1.0, 1.0, 1.0);
45 #   };
46 # }
47 #
48 # void main()
49 # {
50 #   float x2 = 1.0;
51 #   float B = 1.0;
52 #
53 #   _GLF_color = vec4(fx(), 0.0, 0.0, 1.0);
54 #
55 #   while (x2 > 2.0){
56 #     float k0;
57 #     k0 = fx() - fx();
58 #     B = k0;
59 #     x2 = B;
60 #   }
61 # }
62 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
63 ; SPIR-V
64 ; Version: 1.0
65 ; Generator: Khronos Glslang Reference Front End; 8
66 ; Bound: 63
67 ; Schema: 0
68                OpCapability Shader
69           %1 = OpExtInstImport "GLSL.std.450"
70                OpMemoryModel Logical GLSL450
71                OpEntryPoint Fragment %4 "main" %12 %40
72                OpExecutionMode %4 OriginUpperLeft
73                OpSource ESSL 310
74                OpName %4 "main"
75                OpName %8 "fx("
76                OpName %12 "gl_FragCoord"
77                OpName %24 "buf0"
78                OpMemberName %24 0 "injectionSwitch"
79                OpName %26 ""
80                OpName %40 "_GLF_color"
81                OpName %45 "x2"
82                OpName %46 "B"
83                OpName %57 "k0"
84                OpDecorate %12 BuiltIn FragCoord
85                OpMemberDecorate %24 0 Offset 0
86                OpDecorate %24 Block
87                OpDecorate %26 DescriptorSet 0
88                OpDecorate %26 Binding 0
89                OpDecorate %40 Location 0
90           %2 = OpTypeVoid
91           %3 = OpTypeFunction %2
92           %6 = OpTypeFloat 32
93           %7 = OpTypeFunction %6
94          %10 = OpTypeVector %6 4
95          %11 = OpTypePointer Input %10
96          %12 = OpVariable %11 Input
97          %13 = OpTypeInt 32 0
98          %14 = OpConstant %13 1
99          %15 = OpTypePointer Input %6
100          %18 = OpConstant %6 0
101          %19 = OpTypeBool
102          %23 = OpTypeVector %6 2
103          %24 = OpTypeStruct %23
104          %25 = OpTypePointer Uniform %24
105          %26 = OpVariable %25 Uniform
106          %27 = OpTypeInt 32 1
107          %28 = OpConstant %27 0
108          %29 = OpTypePointer Uniform %6
109          %38 = OpConstantTrue %19
110          %39 = OpTypePointer Output %10
111          %40 = OpVariable %39 Output
112          %41 = OpConstant %6 1
113          %42 = OpConstantComposite %10 %41 %41 %41 %41
114          %44 = OpTypePointer Function %6
115          %55 = OpConstant %6 2
116           %4 = OpFunction %2 None %3
117           %5 = OpLabel
118          %45 = OpVariable %44 Function
119          %46 = OpVariable %44 Function
120          %57 = OpVariable %44 Function
121                OpStore %45 %41
122                OpStore %46 %41
123          %47 = OpFunctionCall %6 %8
124          %48 = OpCompositeConstruct %10 %47 %18 %18 %41
125                OpStore %40 %48
126                OpBranch %49
127          %49 = OpLabel
128                OpLoopMerge %51 %52 None
129                OpBranch %53
130          %53 = OpLabel
131          %54 = OpLoad %6 %45
132          %56 = OpFOrdGreaterThan %19 %54 %55
133                OpBranchConditional %56 %50 %51
134          %50 = OpLabel
135          %58 = OpFunctionCall %6 %8
136          %59 = OpFunctionCall %6 %8
137          %60 = OpFSub %6 %58 %59
138                OpStore %57 %60
139          %61 = OpLoad %6 %57
140                OpStore %46 %61
141          %62 = OpLoad %6 %46
142                OpStore %45 %62
143                OpBranch %52
144          %52 = OpLabel
145                OpBranch %49
146          %51 = OpLabel
147                OpReturn
148                OpFunctionEnd
149           %8 = OpFunction %6 None %7
150           %9 = OpLabel
151          %16 = OpAccessChain %15 %12 %14
152          %17 = OpLoad %6 %16
153          %20 = OpFOrdGreaterThanEqual %19 %17 %18
154                OpSelectionMerge %22 None
155                OpBranchConditional %20 %21 %22
156          %21 = OpLabel
157          %30 = OpAccessChain %29 %26 %28 %14
158          %31 = OpLoad %6 %30
159                OpReturnValue %31
160          %22 = OpLabel
161                OpBranch %33
162          %33 = OpLabel
163                OpLoopMerge %35 %36 None
164                OpBranch %37
165          %37 = OpLabel
166                OpBranchConditional %38 %34 %35
167          %34 = OpLabel
168                OpStore %40 %42
169                OpBranch %36
170          %36 = OpLabel
171                OpBranch %33
172          %35 = OpLabel
173          %43 = OpUndef %6
174                OpReturnValue %43
175                OpFunctionEnd
176 END
177
178 # uniforms for variant
179
180 # injectionSwitch
181 BUFFER variant_injectionSwitch DATA_TYPE vec2<float> DATA
182  0.0 1.0
183 END
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   BIND BUFFER variant_injectionSwitch AS uniform DESCRIPTOR_SET 0 BINDING 0
193 END
194 CLEAR_COLOR variant_pipeline 0 0 0 255
195
196 CLEAR variant_pipeline
197 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
198
199 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255