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 = 1) in vec4 color_in; 20layout(location = 0) out vec4 color_out; 21void main() 22{ 23 gl_Position = vec4(position.x + float(gl_InstanceIndex) * 0.5, position.y, 0, 1); 24 color_out = color_in; 25} 26END 27 28SHADER fragment frag_shader GLSL 29#version 430 30layout(location = 0) in vec4 color_in; 31layout(location = 0) out vec4 color_out; 32void main() 33{ 34 color_out = color_in; 35} 36END 37 38BUFFER position_buf DATA_TYPE vec2<float> DATA 39-1.0 1.0 40-1.0 -1.0 41-0.5 1.0 42-0.5 -1.0 43-1.0 -1.0 44-0.5 1.0 45END 46 47BUFFER color_buf DATA_TYPE R8G8B8A8_UNORM DATA 48255 0 0 255 49 0 255 0 255 50 0 0 255 255 51 0 255 255 255 52END 53 54BUFFER framebuffer FORMAT B8G8R8A8_UNORM 55 56PIPELINE graphics pipeline 57 ATTACH vtex_shader 58 ATTACH frag_shader 59 60 VERTEX_DATA position_buf LOCATION 0 RATE vertex 61 VERTEX_DATA color_buf LOCATION 1 RATE instance 62 FRAMEBUFFER_SIZE 40 40 63 BIND BUFFER framebuffer AS color LOCATION 0 64END 65 66RUN pipeline DRAW_ARRAY AS TRIANGLE_LIST START_IDX 0 COUNT 6 START_INSTANCE 0 INSTANCE_COUNT 4 67EXPECT framebuffer IDX 0 0 SIZE 10 40 EQ_RGBA 255 0 0 255 68EXPECT framebuffer IDX 10 0 SIZE 10 40 EQ_RGBA 0 255 0 255 69EXPECT framebuffer IDX 20 0 SIZE 10 40 EQ_RGBA 0 0 255 255 70EXPECT framebuffer IDX 30 0 SIZE 10 40 EQ_RGBA 0 255 255 255 71