• 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) uniform block0 {
20  float data_set0_binding0[3];
21};
22
23layout(set = 1, binding = 2) uniform block1 {
24  float data_set1_binding2[3];
25};
26
27layout(set = 2, binding = 1) buffer block2 {
28  float data_set2_binding1[3];
29};
30
31layout(set = 2, binding = 3) buffer block3 {
32  float data_set2_binding3[3];
33};
34
35void main() {
36  const uint index = gl_WorkGroupID.x;
37  data_set2_binding1[index] = 10.0f * data_set0_binding0[index] +
38                              data_set1_binding2[index];
39  data_set2_binding3[index] += data_set1_binding2[index];
40}
41END
42
43# GLSLang gerates STD140 layout. Need to pad to 16 bytes per item.
44BUFFER buf0 DATA_TYPE float DATA
451 0 0 0
462 0 0 0
473 0 0 0
48END
49
50# GLSLang gerates STD140 layout. Need to pad to 16 bytes per item.
51BUFFER buf1 DATA_TYPE float DATA
524 0 0 0
535 0 0 0
546 0 0 0
55END
56
57BUFFER buf2 DATA_TYPE vec3<float> DATA 21.0 22.0 23.0 END
58BUFFER buf3 DATA_TYPE vec3<float> DATA  0.7  0.8  0.9 END
59
60PIPELINE compute pipeline
61  ATTACH compute_shader
62
63  BIND BUFFER buf0 AS uniform DESCRIPTOR_SET 0 BINDING 0
64  BIND BUFFER buf1 AS uniform DESCRIPTOR_SET 1 BINDING 2
65  BIND BUFFER buf2 AS storage DESCRIPTOR_SET 2 BINDING 1
66  BIND BUFFER buf3 AS storage DESCRIPTOR_SET 2 BINDING 3
67END
68
69RUN pipeline 3 1 1
70
71EXPECT buf2 IDX 0 EQ 14.0 25.0 36.0
72EXPECT buf3 IDX 0 EQ  4.7  5.8  6.9
73