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_uniform GLSL 17#version 430 18 19layout(location = 0) in vec4 position; 20layout(location = 0) out vec4 frag_color; 21 22layout(set = 0, binding = 0) readonly uniform block0 23{ 24 vec4 in_color; 25}; 26 27void main() 28{ 29 gl_Position = position; 30 frag_color = in_color; 31} 32END 33 34SHADER vertex vtex_shader_storage GLSL 35#version 430 36 37layout(location = 0) in vec4 position; 38layout(location = 0) out vec4 frag_color; 39 40layout(set = 0, binding = 1) readonly buffer block0 41{ 42 vec4 in_color; 43}; 44 45void main() 46{ 47 gl_Position = position; 48 frag_color = in_color; 49} 50END 51 52SHADER fragment frag_shader GLSL 53#version 430 54 55layout(location = 0) in vec4 frag_color; 56layout(location = 0) out vec4 final_color; 57 58void main() 59{ 60 final_color = frag_color; 61} 62END 63 64# The Vulkan spec lists the maximum value of minStorageBufferOffsetAlignment 65# (i.e. the maximum possible alignment requirement) as 256 bytes. 66# Meaningful data is placed at this offset. 67BUFFER buf DATA_TYPE vec4<float> DATA 681.0 0.0 0.0 1.0 690.0 0.0 0.0 0.0 700.0 0.0 0.0 0.0 710.0 0.0 0.0 0.0 720.0 0.0 0.0 0.0 730.0 0.0 0.0 0.0 740.0 0.0 0.0 0.0 750.0 0.0 0.0 0.0 760.0 0.0 0.0 0.0 770.0 0.0 0.0 0.0 780.0 0.0 0.0 0.0 790.0 0.0 0.0 0.0 800.0 0.0 0.0 0.0 810.0 0.0 0.0 0.0 820.0 0.0 0.0 0.0 830.0 0.0 0.0 0.0 840.0 1.0 0.0 1.0 850.0 0.0 0.0 0.0 860.0 0.0 0.0 0.0 870.0 0.0 0.0 0.0 880.0 0.0 0.0 0.0 890.0 0.0 0.0 0.0 900.0 0.0 0.0 0.0 910.0 0.0 0.0 0.0 920.0 0.0 0.0 0.0 930.0 0.0 0.0 0.0 940.0 0.0 0.0 0.0 950.0 0.0 0.0 0.0 960.0 0.0 0.0 0.0 970.0 0.0 0.0 0.0 980.0 0.0 0.0 0.0 990.0 0.0 0.0 0.0 1000.0 0.0 1.0 1.0 101END 102 103BUFFER framebuffer FORMAT B8G8R8A8_UNORM 104 105PIPELINE graphics pipeline0 106 ATTACH vtex_shader_uniform 107 ATTACH frag_shader 108 109 # Using the maximum possible required offset alignment of 256 bytes to support all implementations. 110 BIND BUFFER buf AS uniform_dynamic DESCRIPTOR_SET 0 BINDING 0 OFFSET 256 111 BIND BUFFER framebuffer AS color LOCATION 0 112 113 FRAMEBUFFER_SIZE 256 256 114END 115 116PIPELINE graphics pipeline1 117 ATTACH vtex_shader_storage 118 ATTACH frag_shader 119 120 # Using the maximum possible required offset alignment of 256 bytes to support all implementations. 121 BIND BUFFER buf AS storage_dynamic DESCRIPTOR_SET 0 BINDING 1 OFFSET 512 122 BIND BUFFER framebuffer AS color LOCATION 0 123 124 FRAMEBUFFER_SIZE 256 256 125END 126 127CLEAR_COLOR pipeline0 0 0 0 255 128CLEAR pipeline0 129RUN pipeline0 DRAW_RECT POS 0 0 SIZE 128 128 130RUN pipeline1 DRAW_RECT POS 128 128 SIZE 128 128 131 132EXPECT framebuffer IDX 0 0 SIZE 128 128 EQ_RGBA 0 255 0 255 133EXPECT framebuffer IDX 128 0 SIZE 128 128 EQ_RGBA 0 0 0 255 134EXPECT framebuffer IDX 128 128 SIZE 128 128 EQ_RGBA 0 0 255 255 135EXPECT framebuffer IDX 0 128 SIZE 128 128 EQ_RGBA 0 0 0 255 136