From 07d4054812d56afdae081294503f98c6dcaea048 Mon Sep 17 00:00:00 2001 From: zhenglin Date: Thu, 4 Jan 2018 15:50:59 +0800 Subject: APPBROWSER-370: Rewrite the normalization_layer.cs with the new common code Change-Id: I717d0ebbae5102da039b9295649aed8056e4cdfd Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/114960 Tested-by: Jenkins Reviewed-by: Joel Liang Reviewed-by: Pablo Tello --- .../GLES_COMPUTE/cs_shaders/pixelwise_mul_float.cs | 65 ++++++++-------------- 1 file changed, 24 insertions(+), 41 deletions(-) (limited to 'src/core/GLES_COMPUTE/cs_shaders/pixelwise_mul_float.cs') diff --git a/src/core/GLES_COMPUTE/cs_shaders/pixelwise_mul_float.cs b/src/core/GLES_COMPUTE/cs_shaders/pixelwise_mul_float.cs index 031687af0c..01e0f8af7c 100644 --- a/src/core/GLES_COMPUTE/cs_shaders/pixelwise_mul_float.cs +++ b/src/core/GLES_COMPUTE/cs_shaders/pixelwise_mul_float.cs @@ -23,53 +23,36 @@ */ layout(local_size_x = LOCAL_SIZE_X, local_size_y = LOCAL_SIZE_Y, local_size_z = LOCAL_SIZE_Z) in; -#include "helpers.h" -layout(std140) uniform shader_params -{ - TENSOR3D_PARAM_DECLARATION(src1); - TENSOR3D_PARAM_DECLARATION(src2); - TENSOR3D_PARAM_DECLARATION(dst); -}; - -BUFFER_DECLARATION(src1, 1, float, readonly); -BUFFER_DECLARATION(src2, 2, float, readonly); -BUFFER_DECLARATION(dst, 3, float, writeonly); +#include "helpers_cs.h" -/** Performs a pixelwise multiplication with float scale of either integer or float inputs. +/** Performs a pixelwise multiplication with float scale of float inputs. * - * @param[in] src1_ptr Pointer to the source image. Supported data types: F32 - * @param[in] src1_stride_x Stride of the source image in X dimension (in bytes) - * @param[in] src1_step_x src1_stride_x * number of elements along X processed per workitem(in bytes) - * @param[in] src1_stride_y Stride of the source image in Y dimension (in bytes) - * @param[in] src1_step_y src1_stride_y * number of elements along Y processed per workitem(in bytes) - * @param[in] src1_stride_z Stride of the source image in Y dimension (in bytes) - * @param[in] src1_step_z src1_stride_z * number of elements along Y processed per workitem(in bytes) - * @param[in] src1_offset_first_element_in_bytes The offset of the first element in the source image - * @param[in] src2_ptr Pointer to the source image. Supported data types: Same as @p src1_ptr - * @param[in] src2_stride_x Stride of the source image in X dimension (in bytes) - * @param[in] src2_step_x src2_stride_x * number of elements along X processed per workitem(in bytes) - * @param[in] src2_stride_y Stride of the source image in Y dimension (in bytes) - * @param[in] src2_step_y src2_stride_y * number of elements along Y processed per workitem(in bytes) - * @param[in] src2_stride_z Stride of the source image in Y dimension (in bytes) - * @param[in] src2_step_z src2_stride_z * number of elements along Y processed per workitem(in bytes) - * @param[in] src2_offset_first_element_in_bytes The offset of the first element in the source image - * @param[out] dst_ptr Pointer to the destination image. Supported data types: Same as @p src1_ptr - * @param[in] dst_stride_x Stride of the destination image in X dimension (in bytes) - * @param[in] dst_step_x dst_stride_x * number of elements along X processed per workitem(in bytes) - * @param[in] dst_stride_y Stride of the destination image in Y dimension (in bytes) - * @param[in] dst_step_y dst_stride_y * number of elements along Y processed per workitem(in bytes) - * @param[in] dst_stride_z Stride of the destination image in Y dimension (in bytes) - * @param[in] dst_step_z dst_stride_z * number of elements along Y processed per workitem(in bytes) - * @param[in] dst_offset_first_element_in_bytes The offset of the first element in the destination image - * @param[in] scale Float scaling factor. Supported data types: F32 + * @param[in] src1_ptr Pointer to the first source tensor. Supported data types: F32 + * @param[in] src1_attrs The attributes of the first source tensor + * @param[in] src2_ptr Pointer to the second source tensor. Supported data types: Same as @p src1_ptr + * @param[in] src2_attrs The attributes of the second source tensor + * @param[out] dst_ptr Pointer to the destination tensor. Supported data types: Same as @p src1_ptr + * @param[in] dst_attrs The attributes of the destination tensor + * @param[in] scale Float scaling factor. Supported data types: F32 */ +SHADER_PARAMS_DECLARATION +{ + Tensor3DAttributes src1_attrs; + Tensor3DAttributes src2_attrs; + Tensor3DAttributes dst_attrs; +}; +TENSOR_DECLARATION(1, src1Buffer, float, src1_ptr, src1_shift, 2, readonly); +TENSOR_DECLARATION(2, src2Buffer, float, src2_ptr, src2_shift, 2, readonly); +TENSOR_DECLARATION(3, dstBuffer, float, dst_ptr, dst_shift, 2, writeonly); + void main() { // Get pixels pointer - Tensor3D src1 = CONVERT_TO_TENSOR3D_STRUCT(src1); - Tensor3D src2 = CONVERT_TO_TENSOR3D_STRUCT(src2); - Tensor3D dst = CONVERT_TO_TENSOR3D_STRUCT(dst); + Tensor3DIterator src1_iter = CONVERT_TO_TENSOR3D_ITERATOR(src1_attrs, src1_shift); + Tensor3DIterator src2_iter = CONVERT_TO_TENSOR3D_ITERATOR(src2_attrs, src2_shift); + Tensor3DIterator dst_iter = CONVERT_TO_TENSOR3D_ITERATOR(dst_attrs, dst_shift); - dst_ptr[dst.current_offset] = (src1_ptr[src1.current_offset] * src2_ptr[src2.current_offset] * float(SCALE)); + float result = LOAD_CURRENT_ITEM(src1_ptr, src1_iter) * LOAD_CURRENT_ITEM(src2_ptr, src2_iter) * float(SCALE); + STORE_CURRENT_ITEM(dst_ptr, dst_iter, result); } -- cgit v1.2.1