zhenglin | 926d5e1 | 2017-12-21 15:36:50 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016, 2017 ARM Limited. |
| 3 | * |
| 4 | * SPDX-License-Identifier: MIT |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and associated documentation files (the "Software"), to |
| 8 | * deal in the Software without restriction, including without limitation the |
| 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 10 | * sell copies of the Software, and to permit persons to whom the Software is |
| 11 | * furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in all |
| 14 | * copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | * SOFTWARE. |
| 23 | */ |
| 24 | |
| 25 | layout(local_size_x = LOCAL_SIZE_X, local_size_y = LOCAL_SIZE_Y, local_size_z = LOCAL_SIZE_Z) in; |
| 26 | |
| 27 | #include "helpers_cs.h" |
| 28 | |
| 29 | precision mediump float; |
| 30 | #define ADD(x, y) (x) + (y) |
| 31 | |
| 32 | /** This function add two images. |
| 33 | * |
| 34 | * @param[in] src1_ptr Pointer to the first source image. Supported data types: F16 |
| 35 | * @param[in] src1_attrs The attributes of the first source image |
| 36 | * @param[in] src2_ptr Pointer to the second source image. Supported data types: Same as @p src1_ptr |
| 37 | * @param[in] src2_attrs The attributes of the second source image |
| 38 | * @param[out] dst_ptr Pointer to the destination image. Supported data types: Same as @p src1_ptr |
| 39 | * @param[in] dst_attrs The attributes of the destination image |
| 40 | */ |
| 41 | SHADER_PARAMS_DECLARATION |
| 42 | { |
| 43 | ImageAttributes src1_attrs; |
| 44 | ImageAttributes src2_attrs; |
| 45 | ImageAttributes dst_attrs; |
| 46 | }; |
| 47 | |
| 48 | TENSOR_DECLARATION(1, src1Buffer, uvec4, src1_ptr, src1_shift, 4, readonly); |
| 49 | TENSOR_DECLARATION(2, src2Buffer, uvec4, src2_ptr, src2_shift, 4, readonly); |
| 50 | TENSOR_DECLARATION(3, dstBuffer, uvec4, dst_ptr, dst_shift, 4, writeonly); |
| 51 | |
| 52 | void main(void) |
| 53 | { |
| 54 | ImageIterator src1_iter = CONVERT_TO_IMAGE_ITERATOR(src1_attrs, src1_shift); |
| 55 | ImageIterator src2_iter = CONVERT_TO_IMAGE_ITERATOR(src2_attrs, src2_shift); |
| 56 | ImageIterator dst_iter = CONVERT_TO_IMAGE_ITERATOR(dst_attrs, dst_shift); |
| 57 | |
| 58 | vec4 tmp1[2] = LOAD_UNPACK8_CURRENT_ITEM_HALF(src1_ptr, src1_iter); |
| 59 | vec4 tmp2[2] = LOAD_UNPACK8_CURRENT_ITEM_HALF(src2_ptr, src2_iter); |
| 60 | vec4 addition[2]; |
| 61 | addition[0] = ADD(tmp1[0], tmp2[0]); |
| 62 | addition[1] = ADD(tmp1[1], tmp2[1]); |
| 63 | |
| 64 | STORE_PACK8_CURRENT_ITEM_HALF(dst_ptr, dst_iter, addition); |
| 65 | } |