Skip to content

Commit

Permalink
Fix incorrect offset in get_mapped_range.
Browse files Browse the repository at this point in the history
  • Loading branch information
nical committed Nov 24, 2022
1 parent d4b1d57 commit 4a1e9c2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion wgpu-core/src/device/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5688,7 +5688,10 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
max: range.end,
});
}
unsafe { Ok((ptr.as_ptr().offset(offset as isize), range_size)) }
// ptr points to the beginning of the range we mapped in map_async
// rather thant the beginning of the buffer.
let relative_offset = (offset - range.start) as isize;
unsafe { Ok((ptr.as_ptr().offset(relative_offset), range_size)) }
}
resource::BufferMapState::Idle | resource::BufferMapState::Waiting(_) => {
Err(BufferAccessError::NotMapped)
Expand Down

0 comments on commit 4a1e9c2

Please sign in to comment.