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 vert_shader GLSL 17#version 430 18 19layout(location = 0) in vec4 position; 20layout(location = 1) flat out vec4 frag_color; 21 22void main() { 23 gl_Position = position; 24 frag_color = position; 25} 26END 27 28SHADER fragment frag_shader GLSL 29#version 430 30layout(location = 0) out vec4 color_out; 31layout(location = 1) flat in vec4 frag_color; 32void main() { 33 ivec2 iv = ivec2(frag_color.xy * 256); 34 if ((iv.x & 64) + ((iv.y / 2) & 64) == 64) 35 color_out = vec4(1, 0, 0, 1); 36 else 37 color_out = vec4(0, 1, 1, 1); 38} 39END 40 41BUFFER framebuffer FORMAT B8G8R8A8_UNORM 42 43PIPELINE graphics my_pipeline 44 ATTACH vert_shader 45 ATTACH frag_shader 46 BIND BUFFER framebuffer AS color LOCATION 0 47END 48 49RUN my_pipeline DRAW_GRID POS 0 0 SIZE 250 250 CELLS 8 4 50EXPECT framebuffer IDX 0 0 SIZE 30 60 EQ_RGBA 0 255 255 255 51EXPECT framebuffer IDX 32 64 SIZE 30 60 EQ_RGBA 0 255 255 255 52EXPECT framebuffer IDX 32 0 SIZE 30 60 EQ_RGBA 255 0 0 255 53EXPECT framebuffer IDX 0 64 SIZE 30 60 EQ_RGBA 255 0 0 255 54 55