From 03189a30b830fcc7773feedaf443781f9a800f0a Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Fri, 5 Jul 2019 18:37:25 +0200 Subject: [PATCH] Two ands less in NEON DXT1 compression. --- client/TracyDxt1.cpp | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/client/TracyDxt1.cpp b/client/TracyDxt1.cpp index bd14064e..035aacdd 100644 --- a/client/TracyDxt1.cpp +++ b/client/TracyDxt1.cpp @@ -369,27 +369,18 @@ static tracy_force_inline uint64_t ProcessRGB( const uint8_t* src ) uint8x8_t p01 = vmovn_u16( m1 ); uint8x16_t p0 = vcombine_u8( p00, p01 ); - uint32x4_t mask0 = vdupq_n_u32( 0x00000003 ); - uint32x4_t mask1 = vdupq_n_u32( 0x00000300 ); - uint32x4_t mask2 = vdupq_n_u32( 0x00030000 ); - uint32x4_t mask3 = vdupq_n_u32( 0x03000000 ); + uint32x4_t p1 = vorrq_u32( vshrq_n_u32( vreinterpretq_u32_u8( p0 ), 6 ), vshrq_n_u32( vreinterpretq_u32_u8( p0 ), 12 ) ); + uint32x4_t p2 = vorrq_u32( vshrq_n_u32( vreinterpretq_u32_u8( p0 ), 18 ), vreinterpretq_u32_u8( p0 ) ); + uint32x4_t p3 = vorrq_u32( p1, p2 ); + uint32x4_t p4 = vandq_u32( p3, vdupq_n_u32( 0xFF ) ); - uint32x4_t p1 = vandq_u32( vreinterpretq_u32_u8( p0 ), mask0 ); - uint32x4_t p2 = vshrq_n_u32( vandq_u32( vreinterpretq_u32_u8( p0 ), mask1 ), 6 ); - uint32x4_t p3 = vshrq_n_u32( vandq_u32( vreinterpretq_u32_u8( p0 ), mask2 ), 12 ); - uint32x4_t p4 = vshrq_n_u32( vandq_u32( vreinterpretq_u32_u8( p0 ), mask3 ), 18 ); - - uint32x4_t p5 = vorrq_u32( p1, p2 ); - uint32x4_t p6 = vorrq_u32( p3, p4 ); - uint32x4_t p7 = vorrq_u32( p5, p6 ); - - uint16x4x2_t p8 = vuzp_u16( vget_low_u16( vreinterpretq_u16_u32( p7 ) ), vget_high_u16( vreinterpretq_u16_u32( p7 ) ) ); - uint8x8x2_t p9 = vuzp_u8( vreinterpret_u8_u16( p8.val[0] ), vreinterpret_u8_u16( p8.val[0] ) ); + uint16x4x2_t p5 = vuzp_u16( vget_low_u16( vreinterpretq_u16_u32( p4 ) ), vget_high_u16( vreinterpretq_u16_u32( p4 ) ) ); + uint8x8x2_t p = vuzp_u8( vreinterpret_u8_u16( p5.val[0] ), vreinterpret_u8_u16( p5.val[0] ) ); uint32_t vmin, vmax, vp; vst1q_lane_u32( &vmin, vreinterpretq_u32_u8( min ), 0 ); vst1q_lane_u32( &vmax, vreinterpretq_u32_u8( max ), 0 ); - vst1_lane_u32( &vp, vreinterpret_u32_u8( p9.val[0] ), 0 ); + vst1_lane_u32( &vp, vreinterpret_u32_u8( p.val[0] ), 0 ); uint32_t data = 0; for( int i=0; i<4; i++ )