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 compute compute_shader GLSL 17#version 430 18 19layout(set = 0, binding = 0) buffer block0 20{ 21 vec4 data0; 22}; 23 24layout(set = 0, binding = 1) buffer block1 25{ 26 vec4 data1; 27}; 28layout(set = 0, binding = 2) buffer block2 29{ 30 vec4 data2; 31}; 32 33void main() 34{ 35 data0 = vec4(1, 2, 3, 4); 36 data1 = vec4(5, 6, 7, 8); 37 data2 = vec4(9, 10, 11, 12); 38} 39END 40 41# The Vulkan spec lists the maximum value of minStorageBufferOffsetAlignment 42# (i.e. the maximum possible alignment requirement) as 256 bytes. 43# Allocate enough space to hold one vec4 (each 16 bytes) 44# after the alignment (256 / 16 + 1). 45BUFFER buf0 DATA_TYPE vec4<float> SIZE 17 FILL 0.0 46BUFFER buf1 DATA_TYPE vec4<float> SIZE 17 FILL 0.0 47BUFFER buf2 DATA_TYPE vec4<float> SIZE 33 FILL 0.0 48 49PIPELINE compute pipeline 50 ATTACH compute_shader 51 52 BIND BUFFER buf0 AS storage_dynamic DESCRIPTOR_SET 0 BINDING 0 OFFSET 0 53 # Using the maximum possible required offset alignment of 256 bytes to support all implementations. 54 BIND BUFFER buf1 AS storage_dynamic DESCRIPTOR_SET 0 BINDING 1 OFFSET 256 55 # Same as above, but with buffer offset of 256 bytes (total offset of 512). 56 BIND BUFFER buf2 AS storage_dynamic DESCRIPTOR_SET 0 BINDING 2 OFFSET 256 DESCRIPTOR_OFFSET 256 57END 58 59RUN pipeline 1 1 1 60 61EXPECT buf0 IDX 0 EQ 1.0 2.0 3.0 4.0 62EXPECT buf1 IDX 256 EQ 5.0 6.0 7.0 8.0 63EXPECT buf2 IDX 512 EQ 9.0 10.0 11.0 12.0 64