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 29, 2022
1 parent 5e33ba9 commit da3b62d
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 @@ -5677,7 +5677,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 da3b62d

Please sign in to comment.