1#!amber
2#
3# Copyright 2020 The Amber Authors.
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#     https://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
17SHADER vertex vtex_shader GLSL
18#version 430
19
20layout(location = 0) in vec4 position;
21layout(location = 0) out vec4 frag_color;
22
23layout(set = 0, binding = 0) readonly buffer block1 {
24  vec4 in_color;
25};
26
27void main() {
28  gl_Position = position;
29  frag_color = in_color;
30}
31END
32
33SHADER fragment frag_shader GLSL
34#version 430
35
36layout(location = 0) in vec4 frag_color;
37layout(location = 0) out vec4 final_color;
38
39void main() {
40  final_color = frag_color;
41}
42END
43
44BUFFER data_buf1 DATA_TYPE vec4<float> DATA  1 0  0 1 END
45BUFFER data_buf2 DATA_TYPE vec4<float> DATA  0 1  0 1 END
46BUFFER data_buf3 DATA_TYPE vec4<float> DATA  0 0  1 1 END
47BUFFER data_buf4 DATA_TYPE vec4<float> DATA .5 0 .5 1 END
48
49BUFFER frame FORMAT B8G8R8A8_UNORM
50
51PIPELINE graphics pipeline1
52  ATTACH vtex_shader
53  ATTACH frag_shader
54
55  FRAMEBUFFER_SIZE 800 600
56  BIND BUFFER frame AS color LOCATION 0
57  BIND BUFFER data_buf1 AS storage DESCRIPTOR_SET 0 BINDING 0
58END
59DERIVE_PIPELINE pipeline2 FROM pipeline1
60  BIND BUFFER data_buf2 AS storage DESCRIPTOR_SET 0 BINDING 0
61END
62DERIVE_PIPELINE pipeline3 FROM pipeline1
63  BIND BUFFER data_buf3 AS storage DESCRIPTOR_SET 0 BINDING 0
64END
65DERIVE_PIPELINE pipeline4 FROM pipeline1
66  BIND BUFFER data_buf4 AS storage DESCRIPTOR_SET 0 BINDING 0
67END
68
69CLEAR pipeline1
70RUN pipeline1 DRAW_GRID POS   0   0 SIZE 400 300 CELLS 2 3
71RUN pipeline2 DRAW_GRID POS   0 300 SIZE 400 300 CELLS 1 1
72RUN pipeline3 DRAW_GRID POS 400   0 SIZE 400 300 CELLS 100 100
73RUN pipeline4 DRAW_GRID POS 400 300 SIZE 400 300 CELLS 1 71
74
75EXPECT frame IDX   0   0 SIZE 400 300 EQ_RGBA 255   0   0 255
76EXPECT frame IDX   0 300 SIZE 400 300 EQ_RGBA   0 255   0 255
77EXPECT frame IDX 400   0 SIZE 400 300 EQ_RGBA   0   0 255 255
78EXPECT frame IDX 400 300 SIZE 400 300 EQ_RGBA 127   0 127 255 TOLERANCE 1 0 1 0
79