Remove swizzle from load functions.

This commit is contained in:
Colin Murphy
2023-01-23 16:51:16 -05:00
parent ccdd08c8c9
commit ec4c61ccf9
3 changed files with 7 additions and 23 deletions
+2 -12
View File
@@ -75,12 +75,7 @@ pub(crate) unsafe fn multiply_alpha_row_inplace(row: &mut [U16x2]) {
unsafe fn multiplies_alpha_4_pixels(pixels: v128) -> v128 {
const HALF: v128 = i32x4(0x8000, 0x8000, 0x8000, 0x8000);
const MAX_ALPHA: v128 = i32x4(
0xffff0000u32 as i32,
0xffff0000u32 as i32,
0xffff0000u32 as i32,
0xffff0000u32 as i32,
);
const MAX_ALPHA: v128 = u32x4(0xffff0000u32, 0xffff0000u32, 0xffff0000u32, 0xffff0000u32);
/*
|L0 A0 | |L1 A1 | |L2 A2 | |L3 A3 |
|0001 0203| |0405 0607| |0809 1011| |1213 1415|
@@ -191,12 +186,7 @@ pub(crate) unsafe fn divide_alpha_row_inplace(row: &mut [U16x2]) {
#[inline]
unsafe fn divide_alpha_4_pixels(pixels: v128) -> v128 {
const ALPHA_MASK: v128 = i32x4(
0xffff0000u32 as i32,
0xffff0000u32 as i32,
0xffff0000u32 as i32,
0xffff0000u32 as i32,
);
const ALPHA_MASK: v128 = u32x4(0xffff0000u32, 0xffff0000u32, 0xffff0000u32, 0xffff0000u32);
const LUMA_MASK: v128 = i32x4(0xffff, 0xffff, 0xffff, 0xffff);
const ALPHA_MAX: v128 = f32x4(65535.0, 65535.0, 65535.0, 65535.0);
const ALPHA_SCALE_MAX: v128 = f32x4(2147483648f32, 2147483648f32, 2147483648f32, 2147483648f32);
+2 -2
View File
@@ -70,9 +70,9 @@ pub(crate) unsafe fn multiply_alpha_row_inplace(row: &mut [U8x4]) {
unsafe fn multiply_alpha_4_pixels(pixels: v128) -> v128 {
let zero = i64x2_splat(0);
let half = i16x8_splat(128);
let max_alpha = i32x4_splat(MAX_A);
const MAX_A: u32 = 0xff000000u32;
let max_alpha = u32x4_splat(MAX_A);
const MAX_A: i32 = 0xff000000u32 as i32;
const FACTOR_MASK: v128 = i8x16(3, 3, 3, 3, 7, 7, 7, 7, 11, 11, 11, 11, 15, 15, 15, 15);
let factor_pixels = u8x16_swizzle(pixels, FACTOR_MASK);
+3 -9
View File
@@ -10,25 +10,19 @@ pub unsafe fn load_v128<T>(buf: &[T], index: usize) -> v128 {
#[inline(always)]
pub unsafe fn loadl_i64<T>(buf: &[T], index: usize) -> v128 {
let i = buf.get_unchecked(index..).as_ptr() as *const i64;
let v = i64x2(*i, 0);
const K: v128 = i8x16(0, 1, 2, 3, 4, 5, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1);
i8x16_swizzle(v, K)
i64x2(*i, 0)
}
#[inline(always)]
pub unsafe fn loadl_i32<T>(buf: &[T], index: usize) -> v128 {
let i = buf.get_unchecked(index..).as_ptr() as *const i32;
let v = i32x4(*i, 0, 0, 0);
const K: v128 = i8x16(0, 1, 2, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
i8x16_swizzle(v, K)
i32x4(*i, 0, 0, 0)
}
#[inline(always)]
pub unsafe fn loadl_i16<T>(buf: &[T], index: usize) -> v128 {
let i = buf.get_unchecked(index..).as_ptr() as *const i16;
let v = i16x8(*i, 0, 0, 0, 0, 0, 0, 0);
const K: v128 = i8x16(0, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
i8x16_swizzle(v, K)
i16x8(*i, 0, 0, 0, 0, 0, 0, 0)
}
#[inline(always)]