1e5c31af7Sopenharmony_ci#!amber 2e5c31af7Sopenharmony_ci# Copyright 2021 The Amber Authors. 3e5c31af7Sopenharmony_ci# 4e5c31af7Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License"); 5e5c31af7Sopenharmony_ci# you may not use this file except in compliance with the License. 6e5c31af7Sopenharmony_ci# You may obtain a copy of the License at 7e5c31af7Sopenharmony_ci# 8e5c31af7Sopenharmony_ci# https://www.apache.org/licenses/LICENSE-2.0 9e5c31af7Sopenharmony_ci# 10e5c31af7Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software 11e5c31af7Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS, 12e5c31af7Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13e5c31af7Sopenharmony_ci# See the License for the specific language governing permissions and 14e5c31af7Sopenharmony_ci# limitations under the License. 15e5c31af7Sopenharmony_ci 16e5c31af7Sopenharmony_ciSHADER compute compute_shader GLSL 17e5c31af7Sopenharmony_ci#version 460 18e5c31af7Sopenharmony_ci 19e5c31af7Sopenharmony_cilayout(local_size_x = 4, local_size_y = 4, local_size_z = 1) in; 20e5c31af7Sopenharmony_ci 21e5c31af7Sopenharmony_cilayout(binding = 0, r32f) uniform readonly image3D inImg; 22e5c31af7Sopenharmony_cilayout(binding = 1, r32f) uniform image3D outImg; 23e5c31af7Sopenharmony_ci 24e5c31af7Sopenharmony_civoid main() { 25e5c31af7Sopenharmony_ci // Get current pixel 26e5c31af7Sopenharmony_ci const int current_x = int(gl_GlobalInvocationID.x); 27e5c31af7Sopenharmony_ci const int current_y = int(gl_GlobalInvocationID.y); 28e5c31af7Sopenharmony_ci 29e5c31af7Sopenharmony_ci for (int idx = 0; idx < 4; ++idx) { 30e5c31af7Sopenharmony_ci vec4 result = imageLoad(inImg, ivec3(current_x, current_y, 3 - idx)); 31e5c31af7Sopenharmony_ci imageStore(outImg, ivec3(current_x, current_y, idx), result); 32e5c31af7Sopenharmony_ci } 33e5c31af7Sopenharmony_ci} 34e5c31af7Sopenharmony_ciEND 35e5c31af7Sopenharmony_ci 36e5c31af7Sopenharmony_ciIMAGE outputImage DATA_TYPE float DIM_3D WIDTH 4 HEIGHT 4 DEPTH 4 FILL 0.0 37e5c31af7Sopenharmony_ci 38e5c31af7Sopenharmony_ciIMAGE inputImage DATA_TYPE float DIM_3D WIDTH 4 HEIGHT 4 DEPTH 4 DATA 39e5c31af7Sopenharmony_ci 0.110 0.111 0.112 0.113 40e5c31af7Sopenharmony_ci 0.120 0.121 0.122 0.123 41e5c31af7Sopenharmony_ci 0.130 0.131 0.132 0.133 42e5c31af7Sopenharmony_ci 0.140 0.141 0.142 0.143 43e5c31af7Sopenharmony_ci 44e5c31af7Sopenharmony_ci 0.210 0.211 0.212 0.213 45e5c31af7Sopenharmony_ci 0.220 0.221 0.222 0.223 46e5c31af7Sopenharmony_ci 0.230 0.231 0.232 0.233 47e5c31af7Sopenharmony_ci 0.240 0.241 0.242 0.243 48e5c31af7Sopenharmony_ci 49e5c31af7Sopenharmony_ci 0.310 0.311 0.312 0.313 50e5c31af7Sopenharmony_ci 0.320 0.321 0.322 0.323 51e5c31af7Sopenharmony_ci 0.330 0.331 0.332 0.333 52e5c31af7Sopenharmony_ci 0.340 0.341 0.342 0.343 53e5c31af7Sopenharmony_ci 54e5c31af7Sopenharmony_ci 0.410 0.411 0.412 0.413 55e5c31af7Sopenharmony_ci 0.420 0.421 0.422 0.423 56e5c31af7Sopenharmony_ci 0.430 0.431 0.432 0.433 57e5c31af7Sopenharmony_ci 0.440 0.441 0.442 0.443 58e5c31af7Sopenharmony_ciEND 59e5c31af7Sopenharmony_ci 60e5c31af7Sopenharmony_ciIMAGE expectedImage DATA_TYPE float DIM_3D WIDTH 4 HEIGHT 4 DEPTH 4 DATA 61e5c31af7Sopenharmony_ci 0.410 0.411 0.412 0.413 62e5c31af7Sopenharmony_ci 0.420 0.421 0.422 0.423 63e5c31af7Sopenharmony_ci 0.430 0.431 0.432 0.433 64e5c31af7Sopenharmony_ci 0.440 0.441 0.442 0.443 65e5c31af7Sopenharmony_ci 66e5c31af7Sopenharmony_ci 0.310 0.311 0.312 0.313 67e5c31af7Sopenharmony_ci 0.320 0.321 0.322 0.323 68e5c31af7Sopenharmony_ci 0.330 0.331 0.332 0.333 69e5c31af7Sopenharmony_ci 0.340 0.341 0.342 0.343 70e5c31af7Sopenharmony_ci 71e5c31af7Sopenharmony_ci 0.210 0.211 0.212 0.213 72e5c31af7Sopenharmony_ci 0.220 0.221 0.222 0.223 73e5c31af7Sopenharmony_ci 0.230 0.231 0.232 0.233 74e5c31af7Sopenharmony_ci 0.240 0.241 0.242 0.243 75e5c31af7Sopenharmony_ci 76e5c31af7Sopenharmony_ci 0.110 0.111 0.112 0.113 77e5c31af7Sopenharmony_ci 0.120 0.121 0.122 0.123 78e5c31af7Sopenharmony_ci 0.130 0.131 0.132 0.133 79e5c31af7Sopenharmony_ci 0.140 0.141 0.142 0.143 80e5c31af7Sopenharmony_ciEND 81e5c31af7Sopenharmony_ci 82e5c31af7Sopenharmony_ciPIPELINE compute pipeline 83e5c31af7Sopenharmony_ci ATTACH compute_shader 84e5c31af7Sopenharmony_ci 85e5c31af7Sopenharmony_ci BIND BUFFER inputImage AS storage_image DESCRIPTOR_SET 0 BINDING 0 86e5c31af7Sopenharmony_ci BIND BUFFER outputImage AS storage_image DESCRIPTOR_SET 0 BINDING 1 87e5c31af7Sopenharmony_ciEND 88e5c31af7Sopenharmony_ci 89e5c31af7Sopenharmony_ciRUN pipeline 1 1 1 90e5c31af7Sopenharmony_ci 91e5c31af7Sopenharmony_ciEXPECT outputImage EQ_BUFFER expectedImage 92e5c31af7Sopenharmony_ci 93