BufferArg::Persistent(self)
}
+ pub fn len(&self) -> usize {
+ self.len
+ }
+
+ pub fn as_ptr(&self) -> *mut u8 {
+ self.ptr.as_ptr()
+ }
+
pub fn copy_from<T: ?Sized>(&mut self, src: &T) {
unsafe { copy_from_with_offset(self.ptr, self.len, 0, src) }
}
pub fn copy_with_offset<T: ?Sized>(&mut self, offset: usize, src: &T) {
unsafe { copy_from_with_offset(self.ptr, self.len, offset, src) }
}
-
- pub unsafe fn copy_to_slice<T>(&self, dst: &mut [T]) {
- assert!(std::mem::size_of_val(dst) == self.len);
- std::ptr::copy(self.ptr.cast().as_ptr(), dst.as_mut_ptr(), dst.len());
- }
}
/// Transient mapped buffer that is tied to the lifetime of the current frame.
gpu.wait_idle();
- unsafe { sort_buffer.copy_to_slice(values) };
+ unsafe {
+ assert!(sort_buffer.len() == std::mem::size_of_val(values));
+ std::ptr::copy(
+ sort_buffer.as_ptr().cast_const(),
+ values.as_mut_ptr().cast(),
+ std::mem::size_of_val(values),
+ );
+ };
}
// This test requires a GPU, so ignore the test by default.