mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-24 08:21:25 +01:00
change map state on unmap even on destroyed device
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
1 parent
f4455f178d
commit
33f33e3d73
1 file changed
+5
-4
@@ -1117,10 +1117,6 @@ impl Buffer {
|
||||
/// <https://gpuweb.github.io/gpuweb/#dom-gpubuffer-unmap>
|
||||
fn unmap_inner(self: &Arc<Self>) -> Option<BufferMapPendingClosure> {
|
||||
let device = &self.device;
|
||||
// We can stop here if the device is invalid because:
|
||||
// - if the device was invalid from the start it couldn't have been mapped via `map_async` anyway
|
||||
// - if the device becomes invalid it calls the callback in `poll`/`maintain`
|
||||
self.device.check_is_valid().ok()?;
|
||||
let snatch_guard = device.snatchable_lock.read();
|
||||
// We can stop here if the buffer is invalid or destroyed because:
|
||||
// - if the device was invalid from the start it couldn't have been mapped via `map_async` anyway
|
||||
@@ -1129,6 +1125,10 @@ impl Buffer {
|
||||
let map_state = mem::replace(&mut *self.map_state.write(), BufferMapState::Idle);
|
||||
match map_state {
|
||||
BufferMapState::Init { staging_buffer } => {
|
||||
if !self.device.is_valid() {
|
||||
staging_buffer.dispose();
|
||||
return None;
|
||||
}
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(ref mut trace) = *device.trace.lock() {
|
||||
use crate::device::trace::{DataKind, IntoTrace};
|
||||
@@ -1194,6 +1194,7 @@ impl Buffer {
|
||||
range,
|
||||
host,
|
||||
} => {
|
||||
self.device.check_is_valid().ok()?;
|
||||
if host == MapMode::Write {
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(ref mut trace) = *device.trace.lock() {
|
||||
|
||||
Reference in new issue
Block a user