Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 27 additions & 11 deletions src/pipeline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,18 +154,34 @@ pub const STAGES_COUNT: usize = Stage::GammaCompressSrgb as usize + 1;
impl PixmapRef<'_> {
#[inline(always)]
pub(crate) fn gather(&self, index: u32x8) -> [PremultipliedColorU8; highp::STAGE_WIDTH] {
let index: [u32; 8] = bytemuck::cast(index);
let pixels = self.pixels();
[
pixels[index[0] as usize],
pixels[index[1] as usize],
pixels[index[2] as usize],
pixels[index[3] as usize],
pixels[index[4] as usize],
pixels[index[5] as usize],
pixels[index[6] as usize],
pixels[index[7] as usize],
]
cfg_if::cfg_if! {
if #[cfg(all(feature = "simd", target_feature = "avx2"))] {
#[cfg(target_arch = "x86")]
use core::arch::x86::*;
#[cfg(target_arch = "x86_64")]
use core::arch::x86_64::*;

// gather faults on oob; callers clamp indices to [0, w*h) via gather_ix.
unsafe {
let vindex: __m256i = bytemuck::cast(index);
let gathered = _mm256_i32gather_epi32::<4>(pixels.as_ptr() as *const i32, vindex);
bytemuck::cast(gathered)
}
} else {
let index: [u32; 8] = bytemuck::cast(index);
[
pixels[index[0] as usize],
pixels[index[1] as usize],
pixels[index[2] as usize],
pixels[index[3] as usize],
pixels[index[4] as usize],
pixels[index[5] as usize],
pixels[index[6] as usize],
pixels[index[7] as usize],
]
}
}
}
}

Expand Down
Loading