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 18 19layout(location = 0) in vec4 position; 20layout(location = 1) in vec4 vert_color; 21layout(location = 0) out vec4 frag_color; 22 23void main() { 24 gl_Position = position; 25 frag_color = vert_color; 26} 27END 28SHADER fragment frag_shader GLSL 29#version 430 30 31layout(location = 0) in vec4 frag_color; 32layout(location = 0) out vec4 final_color; 33 34void main() { 35 final_color = frag_color; 36} 37END 38 39BUFFER position_buf DATA_TYPE R8G8_SNORM DATA 40-128 -128 41 0 0 42-128 0 43-128 -128 44 0 0 45 0 -128 46 47 0 -128 48 127 0 49 0 0 50 0 -128 51 127 0 52 127 -128 53 54 0 0 55 127 127 56 0 127 57 0 0 58 127 127 59 127 0 60 61-128 0 62 0 127 63-128 127 64-128 0 65 0 127 66 0 0 67END 68 69BUFFER vert_color DATA_TYPE R8G8B8A8_UNORM DATA 70255 0 0 255 71255 0 0 255 72255 0 0 255 73255 0 0 255 74255 0 0 255 75255 0 0 255 76 77 0 255 0 255 78 0 255 0 255 79 0 255 0 255 80 0 255 0 255 81 0 255 0 255 82 0 255 0 255 83 84 0 0 255 255 85 0 0 255 255 86 0 0 255 255 87 0 0 255 255 88 0 0 255 255 89 0 0 255 255 90 91 0 255 255 255 92 0 255 255 255 93 0 255 255 255 94 0 255 255 255 95 0 255 255 255 96 0 255 255 255 97END 98 99IMAGE framebuffer FORMAT B8G8R8A8_UNORM DIM_2D WIDTH 64 HEIGHT 64 100 101PIPELINE graphics pipeline0 102 ATTACH vtex_shader 103 ATTACH frag_shader 104 VERTEX_DATA position_buf LOCATION 0 105 VERTEX_DATA vert_color LOCATION 1 106 BIND BUFFER framebuffer AS color LOCATION 0 107 FRAMEBUFFER_SIZE 64 64 108END 109 110PIPELINE graphics pipeline1 111 ATTACH vtex_shader 112 ATTACH frag_shader 113 VERTEX_DATA position_buf LOCATION 0 OFFSET 12 114 VERTEX_DATA vert_color LOCATION 1 OFFSET 24 115 BIND BUFFER framebuffer AS color LOCATION 0 116 FRAMEBUFFER_SIZE 64 64 117END 118 119PIPELINE graphics pipeline2 120 ATTACH vtex_shader 121 ATTACH frag_shader 122 VERTEX_DATA position_buf LOCATION 0 OFFSET 24 123 VERTEX_DATA vert_color LOCATION 1 OFFSET 48 124 BIND BUFFER framebuffer AS color LOCATION 0 125 FRAMEBUFFER_SIZE 64 64 126END 127 128PIPELINE graphics pipeline3 129 ATTACH vtex_shader 130 ATTACH frag_shader 131 VERTEX_DATA position_buf LOCATION 0 OFFSET 36 132 VERTEX_DATA vert_color LOCATION 1 OFFSET 72 133 BIND BUFFER framebuffer AS color LOCATION 0 134 FRAMEBUFFER_SIZE 64 64 135END 136 137CLEAR pipeline0 138 139RUN pipeline0 DRAW_ARRAY AS TRIANGLE_LIST START_IDX 0 COUNT 6 140RUN pipeline1 DRAW_ARRAY AS TRIANGLE_LIST START_IDX 0 COUNT 6 141RUN pipeline2 DRAW_ARRAY AS TRIANGLE_LIST START_IDX 0 COUNT 6 142RUN pipeline3 DRAW_ARRAY AS TRIANGLE_LIST START_IDX 0 COUNT 6 143 144EXPECT framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255 145EXPECT framebuffer IDX 32 0 SIZE 32 32 EQ_RGBA 0 255 0 255 146EXPECT framebuffer IDX 32 32 SIZE 32 32 EQ_RGBA 0 0 255 255 147EXPECT framebuffer IDX 0 32 SIZE 32 32 EQ_RGBA 0 255 255 255 148