mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-25 17:01:15 +01:00
[deno] Check buffer state in content timeline
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
1 parent
e12b2c27f1
commit
06dc3fe338
1 file changed
+19
@@ -165,6 +165,25 @@ impl GPUBuffer {
|
||||
#[webidl] size: Option<u64>,
|
||||
) -> Result<(), BufferError> {
|
||||
{
|
||||
// If this.mapState is not "unmapped"
|
||||
let maybe_error = match *self.map_state.borrow() {
|
||||
BufferMapState::Unmapped => None,
|
||||
BufferMapState::Pending => {
|
||||
Some(wgpu_core::resource::BufferAccessError::MapAlreadyPending)
|
||||
}
|
||||
BufferMapState::Mapped { .. } => {
|
||||
Some(wgpu_core::resource::BufferAccessError::AlreadyMapped)
|
||||
}
|
||||
};
|
||||
if let Some(error) = maybe_error {
|
||||
// Issue the early-reject steps on the Device timeline of this.[[device]].
|
||||
// Generate a validation error.
|
||||
self
|
||||
.wgpu_device
|
||||
.handle_error_nolabel(error.clone(), "GPUBuffer.mapAsync");
|
||||
// Return a promise rejected with OperationError.
|
||||
return Err(error.into());
|
||||
}
|
||||
*self.map_state.borrow_mut() = BufferMapState::Pending;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user