Skip to content

Commit

Permalink
inline for deref for both direct/web backend
Browse files Browse the repository at this point in the history
  • Loading branch information
Wumpf committed Dec 19, 2022
1 parent 62df12e commit 570b01c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions wgpu/src/backend/direct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2507,6 +2507,7 @@ impl std::ops::Deref for QueueWriteBuffer {
}

impl std::ops::DerefMut for QueueWriteBuffer {
#[inline]
fn deref_mut(&mut self) -> &mut Self::Target {
use crate::BufferMappedRangeSlice;
self.mapping.slice_mut()
Expand All @@ -2523,10 +2524,12 @@ unsafe impl Send for BufferMappedRange {}
unsafe impl Sync for BufferMappedRange {}

impl crate::BufferMappedRangeSlice for BufferMappedRange {
#[inline]
fn slice(&self) -> &[u8] {
unsafe { slice::from_raw_parts(self.ptr, self.size) }
}

#[inline]
fn slice_mut(&mut self) -> &mut [u8] {
unsafe { slice::from_raw_parts_mut(self.ptr, self.size) }
}
Expand Down
2 changes: 2 additions & 0 deletions wgpu/src/backend/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2527,10 +2527,12 @@ pub struct BufferMappedRange {
}

impl crate::BufferMappedRangeSlice for BufferMappedRange {
#[inline]
fn slice(&self) -> &[u8] {
&self.temporary_mapping
}

#[inline]
fn slice_mut(&mut self) -> &mut [u8] {
&mut self.temporary_mapping
}
Expand Down

0 comments on commit 570b01c

Please sign in to comment.