[Pixman] [PATCH 02/12] vmx: add helper functions

Siarhei Siamashka siarhei.siamashka at gmail.com
Tue Jul 14 01:40:02 PDT 2015


On Thu,  2 Jul 2015 13:04:07 +0300
Oded Gabbay <oded.gabbay at gmail.com> wrote:

> This patch adds the following helper functions for reuse of code,
> hiding BE/LE differences and maintainability.
> 
> All of the functions were defined as static force_inline.
> 
> Names were copied from pixman-sse2.c so conversion of fast-paths between
> sse2 and vmx would be easier from now on. Therefore, I tried to keep the
> input/output of the functions to be as close as possible to the sse2
> definitions.
> 
> The functions are:
> 
> - load_128_aligned       : load 128-bit from a 16-byte aligned memory
>                            address into a vector
> 
> - load_128_unaligned     : load 128-bit from memory into a vector,
>                            without guarantee of alignment for the
>                            source pointer
> 
> - save_128_aligned       : save 128-bit vector into a 16-byte aligned
>                            memory address
> 
> - create_mask_16_128     : take a 16-bit value and fill with it
>                            a new vector
> 
> - create_mask_1x32_128   : take a 32-bit pointer and fill a new
>                            vector with the 32-bit value from that pointer
> 
> - create_mask_32_128     : take a 32-bit value and fill with it
>                            a new vector
> 
> - unpack_32_1x128        : unpack 32-bit value into a vector
> 
> - unpacklo_128_16x8      : unpack the eight low 8-bit values of a vector
> 
> - unpackhi_128_16x8      : unpack the eight high 8-bit values of a vector
> 
> - unpacklo_128_8x16      : unpack the four low 16-bit values of a vector
> 
> - unpackhi_128_8x16      : unpack the four high 16-bit values of a vector
> 
> - unpack_128_2x128       : unpack the eight low 8-bit values of a vector
>                            into one vector and the eight high 8-bit
>                            values into another vector
> 
> - unpack_128_2x128_16    : unpack the four low 16-bit values of a vector
>                            into one vector and the four high 16-bit
>                            values into another vector
> 
> - unpack_565_to_8888     : unpack an RGB_565 vector to 8888 vector
> 
> - pack_1x128_32          : pack a vector and return the LSB 32-bit of it
> 
> - pack_2x128_128         : pack two vectors into one and return it
> 
> - negate_2x128           : xor two vectors with mask_00ff (separately)
> 
> - is_opaque              : returns whether all the pixels contained in
>                            the vector are opaque
> 
> - is_zero                : returns whether the vector equals 0
> 
> - is_transparent         : returns whether all the pixels
>                            contained in the vector are transparent
> 
> - expand_pixel_8_1x128   : expand an 8-bit pixel into lower 8 bytes of a
>                            vector
> 
> - expand_pixel_32_1x128  : expand a 32-bit pixel into lower 2 bytes of a
>                            vector
> 
> - expand_alpha_1x128     : expand alpha from vector and return the new
>                            vector
> 
> - expand_alpha_2x128     : expand alpha from one vector and another alpha
>                            from a second vector
> 
> - expand_alpha_rev_2x128 : expand a reversed alpha from one vector and
>                            another reversed alpha from a second vector
> 
> - pix_multiply_2x128     : do pix_multiply for two vectors (separately)
> 
> - over_2x128             : perform over op. on two vectors
> 
> - in_over_2x128          : perform in-over op. on two vectors
> 
> Signed-off-by: Oded Gabbay <oded.gabbay at gmail.com>

Acked-by: Siarhei Siamashka <siarhei.siamashka at gmail.com>

Just one question about the code. There are some places where both big
and little endian variants are identical but we still have an ifdef:

> +static force_inline vector unsigned int
> +expand_pixel_32_1x128 (uint32_t data)
> +{
> +    vector unsigned int vdata;
> +
> +    vdata = unpack_32_1x128 (data);
> +
> +#ifdef WORDS_BIGENDIAN
> +    return vec_perm (vdata, vdata,
> +		     (vector unsigned char)AVV (
> +			 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
> +			 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F));
> +#else
> +    return vec_perm (vdata, vdata,
> +		     (vector unsigned char)AVV (
> +			 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
> +			 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F));
> +#endif

Is this intentional?

-- 
Best regards,
Siarhei Siamashka


More information about the Pixman mailing list