diff --git a/window/src/bitmaps/mod.rs b/window/src/bitmaps/mod.rs index eec39c3e9..577889ec0 100644 --- a/window/src/bitmaps/mod.rs +++ b/window/src/bitmaps/mod.rs @@ -105,65 +105,6 @@ impl Texture2d for SrgbTexture2d { } } -#[cfg(target_arch = "x86_64")] -mod avx { - use super::*; - #[inline] - fn align_lo(size: usize, align: usize) -> usize { - size & !(align - 1) - } - - #[allow(dead_code)] - #[inline] - fn is_aligned(size: usize, align: usize) -> bool { - size == align_lo(size, align) - } - - /// # Safety - /// It is up to the caller to ensure that the destination pointer, - /// stride, width and height all result in valid memory operations. - #[allow(clippy::cast_ptr_alignment)] - pub unsafe fn fill_pixel( - mut dest: *mut u8, - stride_bytes: usize, - width_pixels: usize, - height_pixels: usize, - color: Color, - ) { - // This holds 8 copies of the pixel value - let bgra256 = std::arch::x86_64::_mm256_set1_epi32(color.0 as _); - let aligned_width = align_lo(width_pixels, 8); - - if is_aligned(dest as usize, 32) && is_aligned(stride_bytes, 32) { - for _row in 0..height_pixels { - for col in (0..aligned_width).step_by(8) { - std::arch::x86_64::_mm256_store_si256(dest.add(4 * col) as *mut _, bgra256); - } - if width_pixels != aligned_width { - std::arch::x86_64::_mm256_storeu_si256( - dest.add(4 * (width_pixels - 8)) as *mut _, - bgra256, - ); - } - dest = dest.add(stride_bytes); - } - } else { - for _row in 0..height_pixels { - for col in (0..aligned_width).step_by(8) { - std::arch::x86_64::_mm256_storeu_si256(dest.add(4 * col) as *mut _, bgra256); - } - if width_pixels != aligned_width { - std::arch::x86_64::_mm256_storeu_si256( - dest.add(4 * (width_pixels - 8)) as *mut _, - bgra256, - ); - } - dest = dest.add(stride_bytes); - } - } - } -} - /// A bitmap in big endian bgra32 color format with abstract /// storage filled in by the trait implementation. pub trait BitmapImage { @@ -245,17 +186,6 @@ pub trait BitmapImage { /// Clear the entire image to the specific color fn clear(&mut self, color: Color) { - #[cfg(target_arch = "x86_64")] - { - let (width, height) = self.image_dimensions(); - if is_x86_feature_detected!("avx") && width >= 8 { - unsafe { - avx::fill_pixel(self.pixel_data_mut(), width * 4, width, height, color); - } - return; - } - } - for c in self.pixels_mut() { *c = color.0; } @@ -272,26 +202,6 @@ pub trait BitmapImage { } let dest_y = rect.origin.y.max(0) as usize; - #[cfg(target_arch = "x86_64")] - { - if is_x86_feature_detected!("avx") - && max_x.saturating_sub(dest_x) >= 8 - && max_y.saturating_sub(dest_y) > 0 - { - unsafe { - avx::fill_pixel( - self.pixel_data_mut() - .add(4 * ((dest_y * dim_width) + dest_x)), - dim_width * 4, - max_x - dest_x, - max_y - dest_y, - color, - ); - } - return; - } - } - for y in dest_y..max_y { let range = self.horizontal_pixel_range_mut(dest_x, max_x, y); for c in range {