• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!amber
2# Copyright 2021 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 460
18
19layout(local_size_x = 4, local_size_y = 4, local_size_z = 1) in;
20
21layout(binding = 0, r32f) uniform readonly image3D inImg;
22layout(binding = 1, r32f) uniform image3D outImg;
23
24void main() {
25  // Get current pixel
26  const int current_x = int(gl_GlobalInvocationID.x);
27  const int current_y = int(gl_GlobalInvocationID.y);
28
29  for (int idx = 0; idx < 4; ++idx) {
30    vec4 result = imageLoad(inImg, ivec3(current_x, current_y, 3 - idx));
31    imageStore(outImg, ivec3(current_x, current_y, idx), result);
32  }
33}
34END
35
36IMAGE outputImage DATA_TYPE float DIM_3D WIDTH 4 HEIGHT 4 DEPTH 4 FILL 0.0
37
38IMAGE inputImage DATA_TYPE float DIM_3D WIDTH 4 HEIGHT 4 DEPTH 4 DATA
39  0.110 0.111 0.112 0.113
40  0.120 0.121 0.122 0.123
41  0.130 0.131 0.132 0.133
42  0.140 0.141 0.142 0.143
43
44  0.210 0.211 0.212 0.213
45  0.220 0.221 0.222 0.223
46  0.230 0.231 0.232 0.233
47  0.240 0.241 0.242 0.243
48
49  0.310 0.311 0.312 0.313
50  0.320 0.321 0.322 0.323
51  0.330 0.331 0.332 0.333
52  0.340 0.341 0.342 0.343
53
54  0.410 0.411 0.412 0.413
55  0.420 0.421 0.422 0.423
56  0.430 0.431 0.432 0.433
57  0.440 0.441 0.442 0.443
58END
59
60IMAGE expectedImage DATA_TYPE float DIM_3D WIDTH 4 HEIGHT 4 DEPTH 4 DATA
61  0.410 0.411 0.412 0.413
62  0.420 0.421 0.422 0.423
63  0.430 0.431 0.432 0.433
64  0.440 0.441 0.442 0.443
65
66  0.310 0.311 0.312 0.313
67  0.320 0.321 0.322 0.323
68  0.330 0.331 0.332 0.333
69  0.340 0.341 0.342 0.343
70
71  0.210 0.211 0.212 0.213
72  0.220 0.221 0.222 0.223
73  0.230 0.231 0.232 0.233
74  0.240 0.241 0.242 0.243
75
76  0.110 0.111 0.112 0.113
77  0.120 0.121 0.122 0.123
78  0.130 0.131 0.132 0.133
79  0.140 0.141 0.142 0.143
80END
81
82PIPELINE compute pipeline
83  ATTACH compute_shader
84
85  BIND BUFFER inputImage AS storage_image DESCRIPTOR_SET 0 BINDING 0
86  BIND BUFFER outputImage AS storage_image DESCRIPTOR_SET 0 BINDING 1
87END
88
89RUN pipeline 1 1 1
90
91EXPECT outputImage EQ_BUFFER expectedImage
92
93