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) readonly uniform block0
20{
21    int data0;
22};
23
24layout(set = 0, binding = 1) readonly uniform block1
25{
26    int data1;
27};
28
29layout(set = 0, binding = 2) readonly uniform block2
30{
31    int data2;
32};
33
34layout(set = 0, binding = 3) buffer result
35{
36    int res0;
37    int res1;
38    int res2;
39};
40
41void main()
42{
43    res0 = data0;
44    res1 = data1;
45    res2 = data2;
46}
47END
48
49# Here the size is in terms of items.
50BUFFER buf0 DATA_TYPE int32 SIZE 1024 SERIES_FROM 0 INC_BY 1
51BUFFER buf1 DATA_TYPE int32 SIZE 1024 SERIES_FROM 1 INC_BY 1
52BUFFER buf2 DATA_TYPE int32 SIZE 1024 SERIES_FROM 2 INC_BY 1
53BUFFER result DATA_TYPE int32 DATA
540 0 0
55END
56
57PIPELINE compute pipeline
58  ATTACH compute_shader
59
60  # Note the binding order. The offsets below are in byte offsets.
61  BIND BUFFER buf0 AS uniform_dynamic DESCRIPTOR_SET 0 BINDING 2 OFFSET 0
62  BIND BUFFER buf1 AS uniform_dynamic DESCRIPTOR_SET 0 BINDING 0 OFFSET 1024
63  BIND BUFFER buf2 AS uniform_dynamic DESCRIPTOR_SET 0 BINDING 1 OFFSET 2048
64  BIND BUFFER result AS storage DESCRIPTOR_SET 0 BINDING 3
65END
66
67RUN pipeline 1 1 1
68
69# Offset of 1024/4 = 256 items plus one since the series started from one.
70EXPECT result IDX 0 EQ 257
71# Offset of 2048/4 = 512 items plus two since the series started from two.
72EXPECT result IDX 4 EQ 514
73EXPECT result IDX 8 EQ 0
74