OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef WebGLImageConversionMSA_h |
| 6 #define WebGLImageConversionMSA_h |
| 7 |
| 8 #if HAVE(MIPS_MSA_INTRINSICS) |
| 9 |
| 10 #include "platform/cpu/mips/CommonMacrosMSA.h" |
| 11 |
| 12 namespace blink { |
| 13 |
| 14 namespace SIMD { |
| 15 |
| 16 #define SEPERATE_RGBA_FRM_16BIT_5551INPUT(in, out_r, out_g, out_b, out_a) \ |
| 17 cnst31 = (v8u16)__msa_ldi_h(0x1F); \ |
| 18 cnst7 = (v8u16)__msa_ldi_h(0x7); \ |
| 19 cnst1 = (v8u16)__msa_ldi_h(0x1); \ |
| 20 out_r = (v8u16)SRLI_H(in, 11); \ |
| 21 out_g = ((v8u16)SRLI_H(in, 6)) & cnst31; \ |
| 22 out_b = ((v8u16)SRLI_H(in, 1)) & cnst31; \ |
| 23 out_a = in & cnst1; \ |
| 24 out_r = ((v8u16)SLLI_H(out_r, 3)) | (out_r & cnst7); \ |
| 25 out_g = ((v8u16)SLLI_H(out_g, 3)) | (out_g & cnst7); \ |
| 26 out_b = ((v8u16)SLLI_H(out_b, 3)) | (out_b & cnst7); \ |
| 27 out_a = (v8u16)CEQI_H((v8i16)out_a, 1); \ |
| 28 |
| 29 ALWAYS_INLINE void unpackOneRowOfRGBA5551ToRGBA8MSA(const uint16_t*& source, uin
t8_t*& destination, unsigned& pixelsPerRow) |
| 30 { |
| 31 unsigned i; |
| 32 v8u16 src0, src1, src2, src3; |
| 33 v8u16 src0r, src0g, src0b, src0a, src1r, src1g, src1b, src1a; |
| 34 v8u16 src2r, src2g, src2b, src2a, src3r, src3g, src3b, src3a; |
| 35 v8u16 cnst31, cnst7, cnst1; |
| 36 v16u8 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; |
| 37 v16u8 dst8, dst9, dst10, dst11, dst12, dst13, dst14, dst15; |
| 38 v16u8 out0, out1, out2, out3, out4, out5, out6, out7; |
| 39 |
| 40 for (i = (pixelsPerRow >> 5); i--;) { |
| 41 LD_UH4(source, 8, src0, src1, src2, src3); |
| 42 SEPERATE_RGBA_FRM_16BIT_5551INPUT(src0, src0r, src0g, src0b, src0a); |
| 43 SEPERATE_RGBA_FRM_16BIT_5551INPUT(src1, src1r, src1g, src1b, src1a); |
| 44 SEPERATE_RGBA_FRM_16BIT_5551INPUT(src2, src2r, src2g, src2b, src2a); |
| 45 SEPERATE_RGBA_FRM_16BIT_5551INPUT(src3, src3r, src3g, src3b, src3a); |
| 46 ILVRL_B2_UB(src0g, src0r, dst0, dst1); |
| 47 ILVRL_B2_UB(src0a, src0b, dst2, dst3); |
| 48 ILVRL_B2_UB(src1g, src1r, dst4, dst5); |
| 49 ILVRL_B2_UB(src1a, src1b, dst6, dst7); |
| 50 ILVRL_B2_UB(src2g, src2r, dst8, dst9); |
| 51 ILVRL_B2_UB(src2a, src2b, dst10, dst11); |
| 52 ILVRL_B2_UB(src3g, src3r, dst12, dst13); |
| 53 ILVRL_B2_UB(src3a, src3b, dst14, dst15); |
| 54 ILVEV_H2_UB(dst0, dst2, dst1, dst3, out0, out1); |
| 55 ILVEV_H2_UB(dst4, dst6, dst5, dst7, out2, out3); |
| 56 ILVEV_H2_UB(dst8, dst10, dst9, dst11, out4, out5); |
| 57 ILVEV_H2_UB(dst12, dst14, dst13, dst15, out6, out7); |
| 58 ST_UB8(out0, out1, out2, out3, out4, out5, out6, out7, destination, 16); |
| 59 } |
| 60 |
| 61 if (pixelsPerRow & 31) { |
| 62 if ((pixelsPerRow & 16) && (pixelsPerRow & 8)) { |
| 63 LD_UH3(source, 8, src0, src1, src2); |
| 64 SEPERATE_RGBA_FRM_16BIT_5551INPUT(src0, src0r, src0g, src0b, src0a); |
| 65 SEPERATE_RGBA_FRM_16BIT_5551INPUT(src1, src1r, src1g, src1b, src1a); |
| 66 SEPERATE_RGBA_FRM_16BIT_5551INPUT(src2, src2r, src2g, src2b, src2a); |
| 67 ILVRL_B2_UB(src0g, src0r, dst0, dst1); |
| 68 ILVRL_B2_UB(src0a, src0b, dst2, dst3); |
| 69 ILVRL_B2_UB(src1g, src1r, dst4, dst5); |
| 70 ILVRL_B2_UB(src1a, src1b, dst6, dst7); |
| 71 ILVRL_B2_UB(src2g, src2r, dst8, dst9); |
| 72 ILVRL_B2_UB(src2a, src2b, dst10, dst11); |
| 73 ILVEV_H2_UB(dst0, dst2, dst1, dst3, out0, out1); |
| 74 ILVEV_H2_UB(dst4, dst6, dst5, dst7, out2, out3); |
| 75 ILVEV_H2_UB(dst8, dst10, dst9, dst11, out4, out5); |
| 76 ST_UB6(out0, out1, out2, out3, out4, out5, destination, 16); |
| 77 } else if (pixelsPerRow & 16) { |
| 78 LD_UH2(source, 8, src0, src1); |
| 79 SEPERATE_RGBA_FRM_16BIT_5551INPUT(src0, src0r, src0g, src0b, src0a); |
| 80 SEPERATE_RGBA_FRM_16BIT_5551INPUT(src1, src1r, src1g, src1b, src1a); |
| 81 ILVRL_B2_UB(src0g, src0r, dst0, dst1); |
| 82 ILVRL_B2_UB(src0a, src0b, dst2, dst3); |
| 83 ILVRL_B2_UB(src1g, src1r, dst4, dst5); |
| 84 ILVRL_B2_UB(src1a, src1b, dst6, dst7); |
| 85 ILVEV_H2_UB(dst0, dst2, dst1, dst3, out0, out1); |
| 86 ILVEV_H2_UB(dst4, dst6, dst5, dst7, out2, out3); |
| 87 ST_UB4(out0, out1, out2, out3, destination, 16); |
| 88 } else if (pixelsPerRow & 8) { |
| 89 src0 = LD_UH(source); |
| 90 source += 8; |
| 91 SEPERATE_RGBA_FRM_16BIT_5551INPUT(src0, src0r, src0g, src0b, src0a); |
| 92 ILVRL_B2_UB(src0g, src0r, dst0, dst1); |
| 93 ILVRL_B2_UB(src0a, src0b, dst2, dst3); |
| 94 ILVEV_H2_UB(dst0, dst2, dst1, dst3, out0, out1); |
| 95 ST_UB2(out0, out1, destination, 16); |
| 96 } |
| 97 } |
| 98 |
| 99 pixelsPerRow &= 7; |
| 100 } |
| 101 |
| 102 } // namespace SIMD |
| 103 |
| 104 } // namespace blink |
| 105 |
| 106 #endif // HAVE(MIPS_MSA_INTRINSICS) |
| 107 |
| 108 #endif // WebGLImageConversionMSA_h |
OLD | NEW |