1#!amber 2# Copyright 2019 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# Full frame 41-128 -128 42 127 127 43-128 127 44-128 -128 45 127 127 46 127 -128 47 48# Half frame 49 0 -128 50 127 127 51 0 127 52 0 -128 53 127 127 54 127 -128 55 56# Quarter frame 57-128 0 58 0 127 59-128 127 60-128 0 61 0 127 62 0 0 63 64# Quarter frame 65 0 0 66 127 127 67 0 127 68 0 0 69 127 127 70 127 0 71END 72 73BUFFER vert_color DATA_TYPE R8G8B8A8_UNORM DATA 74255 0 0 0 75255 0 0 0 76255 0 0 0 77255 0 0 0 78255 0 0 0 79255 0 0 0 80 81 0 255 0 0 82 0 255 0 0 83 0 255 0 0 84 0 255 0 0 85 0 255 0 0 86 0 255 0 0 87 88 0 0 255 0 89 0 0 255 0 90 0 0 255 0 91 0 0 255 0 92 0 0 255 0 93 0 0 255 0 94 95127 127 127 0 96127 127 127 0 97127 127 127 0 98127 127 127 0 99127 127 127 0 100127 127 127 0 101END 102 103BUFFER framebuffer FORMAT B8G8R8A8_UNORM 104 105PIPELINE graphics pipeline 106 ATTACH vtex_shader 107 ATTACH frag_shader 108 109 VERTEX_DATA position_buf LOCATION 0 110 VERTEX_DATA vert_color LOCATION 1 111 112 BIND BUFFER framebuffer AS color LOCATION 0 113END 114 115CLEAR pipeline 116 117RUN pipeline DRAW_ARRAY AS TRIANGLE_LIST START_IDX 0 COUNT 6 118EXPECT framebuffer IDX 0 0 SIZE 250 250 EQ_RGBA 255 0 0 0 119 120RUN pipeline DRAW_ARRAY AS TRIANGLE_LIST START_IDX 6 COUNT 6 121EXPECT framebuffer IDX 0 0 SIZE 125 250 EQ_RGBA 255 0 0 0 122EXPECT framebuffer IDX 125 0 SIZE 125 250 EQ_RGBA 0 255 0 0 123 124RUN pipeline DRAW_ARRAY AS TRIANGLE_LIST START_IDX 12 COUNT 6 125EXPECT framebuffer IDX 0 0 SIZE 125 125 EQ_RGBA 255 0 0 0 126EXPECT framebuffer IDX 125 0 SIZE 125 250 EQ_RGBA 0 255 0 0 127EXPECT framebuffer IDX 0 125 SIZE 125 125 EQ_RGBA 0 0 255 0 128 129RUN pipeline DRAW_ARRAY AS TRIANGLE_LIST START_IDX 18 COUNT 6 130EXPECT framebuffer IDX 0 0 SIZE 125 125 EQ_RGBA 255 0 0 0 131EXPECT framebuffer IDX 125 0 SIZE 125 125 EQ_RGBA 0 255 0 0 132EXPECT framebuffer IDX 0 125 SIZE 125 125 EQ_RGBA 0 0 255 0 133EXPECT framebuffer IDX 125 125 SIZE 125 125 EQ_RGBA 127 127 127 0 134