• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!amber
2# Copyright 2019 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  uint data_set0_binding0[];
21};
22
23// push_constant compiled as std430 by glslang
24layout(push_constant) uniform block1 {
25  uint constant0[3];   // Offset:  0, array stride:  4
26  uint constant1;      //         12
27  uvec3 constant2[3];  //         16, array stride: 16
28  uint constant3;      //         64
29};
30
31void main() {
32  int offset = 0;
33  for (int i = 0; i < 3; ++i)
34    data_set0_binding0[offset++] = constant0[i];
35
36  data_set0_binding0[offset++] = constant1;
37
38  for (int i = 0; i < 3; ++i) {
39    for (int j = 0; j < 3; ++j)
40      data_set0_binding0[offset++] = constant2[i][j];
41  }
42
43  data_set0_binding0[offset++] = constant3;
44}
45END
46
47BUFFER buf0 DATA_TYPE uint32 SIZE 14 FILL 0
48BUFFER const_buf DATA_TYPE uint32 DATA
49 1  2  3  4  # constant0[3] + constant1
50 5  6  7  0  # constant2[0]
51 8  9 10  0  # constant2[1]
5211 12 13  0  # constant2[2]
5314           # constant3
54END
55
56PIPELINE compute pipeline
57  ATTACH compute_shader
58
59  BIND BUFFER buf0 AS storage DESCRIPTOR_SET 0 BINDING 0
60  BIND BUFFER const_buf AS push_constant
61END
62
63RUN pipeline 3 1 1
64
65BUFFER result DATA_TYPE uint32 DATA
66 1  2  3  4
67 5  6  7  8
68 9 10 11 12
6913 14
70END
71EXPECT buf0 EQ_BUFFER result
72