Skip to main content

strat9_kernel/framebuffer/x86/
avx512.rs

1use core::arch::x86_64::*;
2
3#[target_feature(enable = "avx512f")]
4pub unsafe fn fill_avx512(dst: *mut u32, color: u32, count: usize) {
5    let color_vec = _mm512_set1_epi32(color as i32);
6    let mut i = 0;
7
8    // Note : _mm512_stream_si512 (NT store) is not available for x86_64-unknown-none;
9    // we use _mm512_storeu_si512 (normal store) which still does 16 pixels per iteration.
10
11    while i + 16 <= count {
12        _mm512_storeu_si512(dst.add(i) as *mut __m512i, color_vec);
13        i += 16;
14    }
15
16    if i < count {
17        crate::framebuffer::generic::fill_generic(dst.add(i), color, count - i);
18    }
19}
20
21#[target_feature(enable = "avx512f")]
22pub unsafe fn blit_avx512(dst: *mut u32, src: *const u32, count: usize) {
23    let mut i = 0;
24
25    while i + 16 <= count {
26        let src_vec = _mm512_loadu_si512(src.add(i) as *const __m512i);
27        _mm512_storeu_si512(dst.add(i) as *mut __m512i, src_vec);
28        i += 16;
29    }
30
31    if i < count {
32        crate::framebuffer::generic::blit_generic(dst.add(i), src.add(i), count - i);
33    }
34}
35
36#[target_feature(enable = "avx512f")]
37pub unsafe fn blend_avx512(dst: *mut u32, src: *const u32, alpha: u8, count: usize) {
38    super::avx2::blend_avx2(dst, src, alpha, count);
39}
40
41#[target_feature(enable = "avx512f")]
42pub unsafe fn convert_bgr_to_argb_avx512(dst: *mut u32, src: *const u8, count: usize) {
43    super::avx2::convert_bgr_to_argb_avx2(dst, src, count);
44}