Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / cov-loop-replace-output-color-restore-original.amber
1 #!amber
2
3 # Copyright 2022 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 coverage-gap found by the GraphicsFuzz project.
19
20 # Short description: A fragment shader that covers specific LLVM code paths
21
22 # The test passes because the shader always writes red.
23
24 SHADER vertex variant_vertex_shader PASSTHROUGH
25
26 # variant_fragment_shader is derived from the following GLSL:
27 # #version 320 es
28 # #define _int_1 _GLF_uniform_int_values[0]
29 # #define _int_0 _GLF_uniform_int_values[1]
30 #
31 # precision highp int;
32 # precision highp float;
33 #
34 # // Contents of _GLF_uniform_int_values: [1, 0]
35 # layout(set = 0, binding = 0) uniform buf0
36 # {
37 #     int _GLF_uniform_int_values[2];
38 # };
39 #
40 # // Contents of zero: 0
41 # layout(set = 0, binding = 1) uniform buf1
42 # {
43 #     int zero;
44 # };
45 #
46 # layout(location = 0) out vec4 _GLF_color;
47 #
48 # void main()
49 # {
50 #     _GLF_color = vec4(_int_1, _int_0, _int_0, 1);
51 #     int a = 1;
52 #
53 #     // Iterates until a reaches seven.
54 #     do
55 #     {
56 #         if(a++ >= 7)
57 #         {
58 #             break;
59 #         }
60 #
61 #         // v = (1, 0, 0, 1)
62 #         vec4 v = _GLF_color;
63 #
64 #         // The original value is always restored below.
65 #         _GLF_color = vec4(a);
66 #
67 #         // Always true.
68 #         if(gl_FragCoord.x >= 0.0)
69 #         {
70 #             _GLF_color = v;
71 #         }
72 #     }
73 #     while(_int_1 > zero);
74 # }
75 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
76 ; SPIR-V
77 ; Version: 1.0
78 ; Generator: Khronos Glslang Reference Front End; 10
79 ; Bound: 70
80 ; Schema: 0
81                OpCapability Shader
82           %1 = OpExtInstImport "GLSL.std.450"
83                OpMemoryModel Logical GLSL450
84                OpEntryPoint Fragment %4 "main" %9 %52
85                OpExecutionMode %4 OriginUpperLeft
86                OpSource ESSL 320
87                OpName %4 "main"
88                OpName %9 "_GLF_color"
89                OpName %14 "buf0"
90                OpMemberName %14 0 "_GLF_uniform_int_values"
91                OpName %16 ""
92                OpName %32 "a"
93                OpName %46 "v"
94                OpName %52 "gl_FragCoord"
95                OpName %64 "buf1"
96                OpMemberName %64 0 "zero"
97                OpName %66 ""
98                OpDecorate %9 Location 0
99                OpDecorate %13 ArrayStride 16
100                OpMemberDecorate %14 0 Offset 0
101                OpDecorate %14 Block
102                OpDecorate %16 DescriptorSet 0
103                OpDecorate %16 Binding 0
104                OpDecorate %52 BuiltIn FragCoord
105                OpMemberDecorate %64 0 Offset 0
106                OpDecorate %64 Block
107                OpDecorate %66 DescriptorSet 0
108                OpDecorate %66 Binding 1
109           %2 = OpTypeVoid
110           %3 = OpTypeFunction %2
111           %6 = OpTypeFloat 32
112           %7 = OpTypeVector %6 4
113           %8 = OpTypePointer Output %7
114           %9 = OpVariable %8 Output
115          %10 = OpTypeInt 32 1
116          %11 = OpTypeInt 32 0
117          %12 = OpConstant %11 2
118          %13 = OpTypeArray %10 %12
119          %14 = OpTypeStruct %13
120          %15 = OpTypePointer Uniform %14
121          %16 = OpVariable %15 Uniform
122          %17 = OpConstant %10 0
123          %18 = OpTypePointer Uniform %10
124          %22 = OpConstant %10 1
125          %29 = OpConstant %6 1
126          %31 = OpTypePointer Function %10
127          %39 = OpConstant %10 7
128          %40 = OpTypeBool
129          %45 = OpTypePointer Function %7
130          %51 = OpTypePointer Input %7
131          %52 = OpVariable %51 Input
132          %53 = OpConstant %11 0
133          %54 = OpTypePointer Input %6
134          %57 = OpConstant %6 0
135          %64 = OpTypeStruct %10
136          %65 = OpTypePointer Uniform %64
137          %66 = OpVariable %65 Uniform
138           %4 = OpFunction %2 None %3
139           %5 = OpLabel
140          %32 = OpVariable %31 Function
141          %46 = OpVariable %45 Function
142          %19 = OpAccessChain %18 %16 %17 %17
143          %20 = OpLoad %10 %19
144          %21 = OpConvertSToF %6 %20
145          %23 = OpAccessChain %18 %16 %17 %22
146          %24 = OpLoad %10 %23
147          %25 = OpConvertSToF %6 %24
148          %26 = OpAccessChain %18 %16 %17 %22
149          %27 = OpLoad %10 %26
150          %28 = OpConvertSToF %6 %27
151          %30 = OpCompositeConstruct %7 %21 %25 %28 %29
152                OpStore %9 %30
153                OpStore %32 %22
154                OpBranch %33
155          %33 = OpLabel
156                OpLoopMerge %35 %36 None
157                OpBranch %34
158          %34 = OpLabel
159          %37 = OpLoad %10 %32
160          %38 = OpIAdd %10 %37 %22
161                OpStore %32 %38
162          %41 = OpSGreaterThanEqual %40 %37 %39
163                OpSelectionMerge %43 None
164                OpBranchConditional %41 %42 %43
165          %42 = OpLabel
166                OpBranch %35
167          %43 = OpLabel
168          %47 = OpLoad %7 %9
169                OpStore %46 %47
170          %48 = OpLoad %10 %32
171          %49 = OpConvertSToF %6 %48
172          %50 = OpCompositeConstruct %7 %49 %49 %49 %49
173                OpStore %9 %50
174          %55 = OpAccessChain %54 %52 %53
175          %56 = OpLoad %6 %55
176          %58 = OpFOrdGreaterThanEqual %40 %56 %57
177                OpSelectionMerge %60 None
178                OpBranchConditional %58 %59 %60
179          %59 = OpLabel
180          %61 = OpLoad %7 %46
181                OpStore %9 %61
182                OpBranch %60
183          %60 = OpLabel
184                OpBranch %36
185          %36 = OpLabel
186          %62 = OpAccessChain %18 %16 %17 %17
187          %63 = OpLoad %10 %62
188          %67 = OpAccessChain %18 %66 %17
189          %68 = OpLoad %10 %67
190          %69 = OpSGreaterThan %40 %63 %68
191                OpBranchConditional %69 %33 %35
192          %35 = OpLabel
193                OpReturn
194                OpFunctionEnd
195 END
196
197 # uniforms for variant
198
199 # zero
200 BUFFER variant_zero DATA_TYPE int32 STD140 DATA
201  0
202 END
203 # _GLF_uniform_int_values
204 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
205  1 0
206 END
207
208 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
209
210 PIPELINE graphics variant_pipeline
211   ATTACH variant_vertex_shader
212   ATTACH variant_fragment_shader
213   FRAMEBUFFER_SIZE 32 32
214   BIND BUFFER variant_framebuffer AS color LOCATION 0
215   BIND BUFFER variant_zero AS uniform DESCRIPTOR_SET 0 BINDING 1
216   BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
217 END
218 CLEAR_COLOR variant_pipeline 0 0 0 255
219
220 CLEAR variant_pipeline
221 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
222
223 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255