blob: d06de3a7b6309e9e981d55877dc6ab49165def4c [file] [log] [blame]
Anthony Barbier7068f992017-10-26 15:23:08 +01001/*
2 * Copyright (c) 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
25layout(local_size_x = LOCAL_SIZE_X, local_size_y = LOCAL_SIZE_Y, local_size_z = LOCAL_SIZE_Z) in;
Anthony Barbier7068f992017-10-26 15:23:08 +010026
Joel Liangc5114d32017-12-04 15:30:53 +080027#include "helpers_cs.h"
Anthony Barbier7068f992017-10-26 15:23:08 +010028
29/** Calculate the absolute difference of two input images.
30 *
Joel Liangc5114d32017-12-04 15:30:53 +080031 * @param[in] src1_ptr Pointer to the first source image. Supported data types: U8
32 * @param[in] src1_attrs The attributes of the first source image
33 * @param[in] src2_ptr Pointer to the second source image. Supported data types: Same as @p in1_ptr
34 * @param[in] src2_attrs The attributes of the second source image
35 * @param[out] dst_ptr Pointer to the destination image. Supported data types: Same as @p in1_ptr
36 * @param[in] dst_attrs The attributes of the destination image
Anthony Barbier7068f992017-10-26 15:23:08 +010037 */
Joel Liangc5114d32017-12-04 15:30:53 +080038SHADER_PARAMS_DECLARATION
39{
40 ImageAttributes src1_attrs;
41 ImageAttributes src2_attrs;
42 ImageAttributes dst_attrs;
43};
44
45TENSOR_DECLARATION(1, src1Buffer, uint, src1_ptr, src1_shift, 2, readonly);
46TENSOR_DECLARATION(2, src2Buffer, uint, src2_ptr, src2_shift, 2, readonly);
47TENSOR_DECLARATION(3, dstBuffer, uint, dst_ptr, dst_shift, 2, writeonly);
48
Anthony Barbier7068f992017-10-26 15:23:08 +010049void main(void)
50{
Joel Liangc5114d32017-12-04 15:30:53 +080051 ImageIterator src1_iter = CONVERT_TO_IMAGE_ITERATOR(src1_attrs, src1_shift);
52 ImageIterator src2_iter = CONVERT_TO_IMAGE_ITERATOR(src2_attrs, src2_shift);
53 ImageIterator dst_iter = CONVERT_TO_IMAGE_ITERATOR(dst_attrs, dst_shift);
Anthony Barbier7068f992017-10-26 15:23:08 +010054
Joel Liangc5114d32017-12-04 15:30:53 +080055 lowp uvec4 tmp1 = LOAD_UNPACK4_CURRENT_ITEM_U8(src1_ptr, src1_iter);
56 lowp uvec4 tmp2 = LOAD_UNPACK4_CURRENT_ITEM_U8(src2_ptr, src2_iter);
57 lowp uvec4 diff = uvec4(abs(ivec4(tmp1 - tmp2)));
Anthony Barbier7068f992017-10-26 15:23:08 +010058
Joel Liangc5114d32017-12-04 15:30:53 +080059 STORE_PACK4_CURRENT_ITEM_U8(dst_ptr, dst_iter, diff);
Anthony Barbier7068f992017-10-26 15:23:08 +010060}