diff --git a/src/nouveau/nil/copy.rs b/src/nouveau/nil/copy.rs index 8b2ea42ab18..f4f706138de 100644 --- a/src/nouveau/nil/copy.rs +++ b/src/nouveau/nil/copy.rs @@ -45,12 +45,14 @@ trait CopyGOB { // No bounding box for this one unsafe fn copy_whole_gob(tiled: usize, linear: LinearPointer) { - Self::copy_gob( - tiled, - linear, - Offset4D::new(0, 0, 0, 0), - Offset4D::new(0, 0, 0, 0) + Self::GOB_EXTENT_B, - ); + unsafe { + Self::copy_gob( + tiled, + linear, + Offset4D::new(0, 0, 0, 0), + Offset4D::new(0, 0, 0, 0) + Self::GOB_EXTENT_B, + ); + } } } @@ -84,16 +86,20 @@ impl CopyGOB for C { let tiled = tiled + (offset as usize); let linear = linear.at(Offset4D::new(x, y, z, 0)); if x >= start.x && x + C::LINE_WIDTH_B <= end.x { - C::copy_whole_line(tiled as *mut _, linear as *mut _); + unsafe { + C::copy_whole_line(tiled as *mut _, linear as *mut _); + } } else if x + C::LINE_WIDTH_B >= start.x && x < end.x { let start = (std::cmp::max(x, start.x) - x) as usize; let end = std::cmp::min(end.x - x, C::LINE_WIDTH_B) as usize; - C::copy( - (tiled + start) as *mut _, - (linear + start) as *mut _, - end - start, - ); + unsafe { + C::copy( + (tiled + start) as *mut _, + (linear + start) as *mut _, + end - start, + ); + } } } }); @@ -103,7 +109,9 @@ impl CopyGOB for C { Self::for_each_gob_line(|offset, x, y, z| { let tiled = tiled + (offset as usize); let linear = linear.at(Offset4D::new(x, y, z, 0)); - C::copy_whole_line(tiled as *mut _, linear as *mut _); + unsafe { + C::copy_whole_line(tiled as *mut _, linear as *mut _); + } }); } } @@ -114,10 +122,14 @@ trait CopyBytes { unsafe fn copy(tiled: *mut u8, linear: *mut u8, bytes: usize); unsafe fn copy_16b(tiled: *mut [u8; 16], linear: *mut [u8; 16]) { - Self::copy(tiled as *mut _, linear as *mut _, 16); + unsafe { + Self::copy(tiled as *mut _, linear as *mut _, 16); + } } unsafe fn copy_8b(tiled: *mut [u8; 8], linear: *mut [u8; 8]) { - Self::copy(tiled as *mut _, linear as *mut _, 8); + unsafe { + Self::copy(tiled as *mut _, linear as *mut _, 8); + } } } @@ -132,11 +144,15 @@ impl CopyGOBLines for CopyGOBFermi { const X_DIVISOR: u32 = C::X_DIVISOR; unsafe fn copy(tiled: *mut u8, linear: *mut u8, bytes: usize) { - C::copy(tiled, linear, bytes); + unsafe { + C::copy(tiled, linear, bytes); + } } unsafe fn copy_whole_line(tiled: *mut u8, linear: *mut u8) { - C::copy_16b(tiled as *mut _, linear as *mut _); + unsafe { + C::copy_16b(tiled as *mut _, linear as *mut _); + } } #[inline(always)] @@ -176,11 +192,15 @@ impl CopyGOBLines for CopyGOBTuring2D { const X_DIVISOR: u32 = C::X_DIVISOR; unsafe fn copy(tiled: *mut u8, linear: *mut u8, bytes: usize) { - C::copy(tiled, linear, bytes); + unsafe { + C::copy(tiled, linear, bytes); + } } unsafe fn copy_whole_line(tiled: *mut u8, linear: *mut u8) { - C::copy_16b(tiled as *mut _, linear as *mut _); + unsafe { + C::copy_16b(tiled as *mut _, linear as *mut _); + } } #[inline(always)] @@ -220,11 +240,15 @@ impl CopyGOBLines for CopyGOBBlackwell2D2BPP { const X_DIVISOR: u32 = C::X_DIVISOR; unsafe fn copy(tiled: *mut u8, linear: *mut u8, bytes: usize) { - C::copy(tiled, linear, bytes); + unsafe { + C::copy(tiled, linear, bytes); + } } unsafe fn copy_whole_line(tiled: *mut u8, linear: *mut u8) { - C::copy_16b(tiled as *mut _, linear as *mut _); + unsafe { + C::copy_16b(tiled as *mut _, linear as *mut _); + } } #[inline(always)] @@ -264,11 +288,15 @@ impl CopyGOBLines for CopyGOBBlackwell2D1BPP { const X_DIVISOR: u32 = C::X_DIVISOR; unsafe fn copy(tiled: *mut u8, linear: *mut u8, bytes: usize) { - C::copy(tiled, linear, bytes); + unsafe { + C::copy(tiled, linear, bytes); + } } unsafe fn copy_whole_line(tiled: *mut u8, linear: *mut u8) { - C::copy_8b(tiled as *mut _, linear as *mut _); + unsafe { + C::copy_8b(tiled as *mut _, linear as *mut _); + } } #[inline(always)] @@ -522,7 +550,7 @@ unsafe fn copy_tile( if start.is_aligned_to(CG::GOB_EXTENT_B) && end.is_aligned_to(CG::GOB_EXTENT_B) { - for_each_extent4d_aligned(start, end, CG::GOB_EXTENT_B, |gob| { + for_each_extent4d_aligned(start, end, CG::GOB_EXTENT_B, |gob| unsafe { CG::copy_whole_gob(tile_ptr.at(gob), linear.offset(gob)); }); } else { @@ -532,9 +560,13 @@ unsafe fn copy_tile( if start == Offset4D::new(0, 0, 0, 0) && end == Offset4D::new(0, 0, 0, 0) + CG::GOB_EXTENT_B { - CG::copy_whole_gob(tiled, linear); + unsafe { + CG::copy_whole_gob(tiled, linear); + } } else { - CG::copy_gob(tiled, linear, start, end); + unsafe { + CG::copy_gob(tiled, linear, start, end); + } } }); } @@ -562,7 +594,9 @@ unsafe fn copy_tiled( for_each_extent4d(start, end, tile_extent_B, |tile, start, end| { let tile_ptr = level_tiled_ptr.at(tile); let linear = linear.offset(tile); - copy_tile::(tiling, tile_ptr, linear, start, end); + unsafe { + copy_tile::(tiling, tile_ptr, linear, start, end); + } }); } @@ -573,7 +607,9 @@ impl CopyBytes for RawCopyToTiled { unsafe fn copy(tiled: *mut u8, linear: *mut u8, bytes: usize) { // This is backwards from memcpy - std::ptr::copy_nonoverlapping(linear, tiled, bytes); + unsafe { + std::ptr::copy_nonoverlapping(linear, tiled, bytes); + } } } @@ -584,7 +620,9 @@ impl CopyBytes for RawCopyToLinear { unsafe fn copy(tiled: *mut u8, linear: *mut u8, bytes: usize) { // This is backwards from memcpy - std::ptr::copy_nonoverlapping(tiled, linear, bytes); + unsafe { + std::ptr::copy_nonoverlapping(tiled, linear, bytes); + } } } @@ -610,48 +648,50 @@ pub unsafe extern "C" fn nil_copy_linear_to_tiled( linear_plane_stride_B, ); - match tiling.gob_type { - GOBType::Blackwell16Bit => { - copy_tiled::>( - *tiling, - level_extent_B, - tiled_dst, - linear_pointer, - offset_B, - end_B, - ); + unsafe { + match tiling.gob_type { + GOBType::Blackwell16Bit => { + copy_tiled::>( + *tiling, + level_extent_B, + tiled_dst, + linear_pointer, + offset_B, + end_B, + ); + } + GOBType::Blackwell8Bit => { + copy_tiled::>( + *tiling, + level_extent_B, + tiled_dst, + linear_pointer, + offset_B, + end_B, + ); + } + GOBType::TuringColor2D => { + copy_tiled::>( + *tiling, + level_extent_B, + tiled_dst, + linear_pointer, + offset_B, + end_B, + ); + } + GOBType::FermiColor => { + copy_tiled::>( + *tiling, + level_extent_B, + tiled_dst, + linear_pointer, + offset_B, + end_B, + ); + } + _ => panic!("Unsupported GOB type"), } - GOBType::Blackwell8Bit => { - copy_tiled::>( - *tiling, - level_extent_B, - tiled_dst, - linear_pointer, - offset_B, - end_B, - ); - } - GOBType::TuringColor2D => { - copy_tiled::>( - *tiling, - level_extent_B, - tiled_dst, - linear_pointer, - offset_B, - end_B, - ); - } - GOBType::FermiColor => { - copy_tiled::>( - *tiling, - level_extent_B, - tiled_dst, - linear_pointer, - offset_B, - end_B, - ); - } - _ => panic!("Unsupported GOB type"), } } @@ -677,47 +717,49 @@ pub unsafe extern "C" fn nil_copy_tiled_to_linear( linear_plane_stride_B, ); - match tiling.gob_type { - GOBType::Blackwell16Bit => { - copy_tiled::>( - *tiling, - level_extent_B, - tiled_src, - linear_pointer, - offset_B, - end_B, - ); + unsafe { + match tiling.gob_type { + GOBType::Blackwell16Bit => { + copy_tiled::>( + *tiling, + level_extent_B, + tiled_src, + linear_pointer, + offset_B, + end_B, + ); + } + GOBType::Blackwell8Bit => { + copy_tiled::>( + *tiling, + level_extent_B, + tiled_src, + linear_pointer, + offset_B, + end_B, + ); + } + GOBType::TuringColor2D => { + copy_tiled::>( + *tiling, + level_extent_B, + tiled_src, + linear_pointer, + offset_B, + end_B, + ); + } + GOBType::FermiColor => { + copy_tiled::>( + *tiling, + level_extent_B, + tiled_src, + linear_pointer, + offset_B, + end_B, + ); + } + _ => panic!("Unsupported GOB type"), } - GOBType::Blackwell8Bit => { - copy_tiled::>( - *tiling, - level_extent_B, - tiled_src, - linear_pointer, - offset_B, - end_B, - ); - } - GOBType::TuringColor2D => { - copy_tiled::>( - *tiling, - level_extent_B, - tiled_src, - linear_pointer, - offset_B, - end_B, - ); - } - GOBType::FermiColor => { - copy_tiled::>( - *tiling, - level_extent_B, - tiled_src, - linear_pointer, - offset_B, - end_B, - ); - } - _ => panic!("Unsupported GOB type"), } }