1#!amber
2# Copyright 2020 The Amber Authors.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#     https://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16SHADER vertex vtex_shader GLSL
17#version 430
18layout(location = 0) in vec2 position;
19layout(location = 0) out vec4 color_out;
20void main()
21{
22    gl_Position = vec4(position.x + float(gl_InstanceIndex) * 0.5, position.y, 0, 1);
23    vec4 colors[4];
24    colors[0] = vec4(1, 0, 0, 1);
25    colors[1] = vec4(0, 1, 0, 1);
26    colors[2] = vec4(0, 0, 1, 1);
27    colors[3] = vec4(0, 1, 1, 1);
28    color_out = colors[gl_InstanceIndex];
29}
30END
31
32SHADER fragment frag_shader GLSL
33#version 430
34layout(location = 0) in vec4 color_in;
35layout(location = 0) out vec4 color_out;
36void main()
37{
38    color_out = color_in;
39}
40END
41
42BUFFER position_buf DATA_TYPE vec2<float> DATA
43-1.0  1.0
44-1.0 -1.0
45-0.5  1.0
46-0.5 -1.0
47-1.0 -1.0
48-0.5  1.0
49END
50
51BUFFER framebuffer FORMAT B8G8R8A8_UNORM
52
53PIPELINE graphics pipeline
54  ATTACH vtex_shader
55  ATTACH frag_shader
56
57  VERTEX_DATA position_buf LOCATION 0
58  FRAMEBUFFER_SIZE 40 40
59  BIND BUFFER framebuffer AS color LOCATION 0
60END
61
62RUN pipeline DRAW_ARRAY AS TRIANGLE_LIST START_IDX 0 COUNT 6 START_INSTANCE 0 INSTANCE_COUNT 4
63EXPECT framebuffer IDX 0  0 SIZE 10 40 EQ_RGBA 255   0   0 255
64EXPECT framebuffer IDX 10 0 SIZE 10 40 EQ_RGBA   0 255   0 255
65EXPECT framebuffer IDX 20 0 SIZE 10 40 EQ_RGBA   0   0 255 255
66EXPECT framebuffer IDX 30 0 SIZE 10 40 EQ_RGBA   0 255 255 255
67