| #!amber |
| # Copyright 2020 The Amber Authors. |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); |
| # you may not use this file except in compliance with the License. |
| # You may obtain a copy of the License at |
| # |
| # https://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| |
| SHADER compute compute_shader GLSL |
| #version 430 |
| |
| layout(set = 0, binding = 0) readonly uniform block0 |
| { |
| int data0; |
| }; |
| |
| layout(set = 0, binding = 1) readonly uniform block1 |
| { |
| int data1; |
| }; |
| |
| layout(set = 0, binding = 2) readonly uniform block2 |
| { |
| int data2; |
| }; |
| |
| layout(set = 0, binding = 3) buffer result |
| { |
| int res0; |
| int res1; |
| int res2; |
| }; |
| |
| void main() |
| { |
| res0 = data0; |
| res1 = data1; |
| res2 = data2; |
| } |
| END |
| |
| # Here the size is in terms of items. |
| BUFFER buf0 DATA_TYPE int32 SIZE 1024 SERIES_FROM 0 INC_BY 1 |
| BUFFER buf1 DATA_TYPE int32 SIZE 1024 SERIES_FROM 1 INC_BY 1 |
| BUFFER buf2 DATA_TYPE int32 SIZE 1024 SERIES_FROM 2 INC_BY 1 |
| BUFFER result DATA_TYPE int32 DATA |
| 0 0 0 |
| END |
| |
| PIPELINE compute pipeline |
| ATTACH compute_shader |
| |
| # Note the binding order. The offsets below are in byte offsets. |
| BIND BUFFER buf0 AS uniform_dynamic DESCRIPTOR_SET 0 BINDING 2 OFFSET 0 |
| BIND BUFFER buf1 AS uniform_dynamic DESCRIPTOR_SET 0 BINDING 0 OFFSET 1024 |
| BIND BUFFER buf2 AS uniform_dynamic DESCRIPTOR_SET 0 BINDING 1 OFFSET 2048 |
| BIND BUFFER result AS storage DESCRIPTOR_SET 0 BINDING 3 |
| END |
| |
| RUN pipeline 1 1 1 |
| |
| # Offset of 1024/4 = 256 items plus one since the series started from one. |
| EXPECT result IDX 0 EQ 257 |
| # Offset of 2048/4 = 512 items plus two since the series started from two. |
| EXPECT result IDX 4 EQ 514 |
| EXPECT result IDX 8 EQ 0 |