mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-30 10:03:58 +01:00
Fix validation errors + panics on empty buffers
This commit is contained in:
1 parent
ad34c37127
commit
b0475520fa
2 files changed
+21
-15
No files matched your search
@@ -683,21 +683,25 @@ impl<B: GfxBackend> LifetimeTracker<B> {
|
||||
resource::BufferMapState::Waiting(pending_mapping) => pending_mapping,
|
||||
_ => panic!("No pending mapping."),
|
||||
};
|
||||
log::debug!("Buffer {:?} map state -> Active", buffer_id);
|
||||
let host = mapping.op.host;
|
||||
let status = match super::map_buffer(raw, buffer, mapping.sub_range.clone(), host) {
|
||||
Ok(ptr) => {
|
||||
buffer.map_state = resource::BufferMapState::Active {
|
||||
ptr,
|
||||
sub_range: mapping.sub_range,
|
||||
host,
|
||||
};
|
||||
resource::BufferMapAsyncStatus::Success
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("Mapping failed {:?}", e);
|
||||
resource::BufferMapAsyncStatus::Error
|
||||
let status = if mapping.sub_range.size.map_or(true, |x| x != 0) {
|
||||
log::debug!("Buffer {:?} map state -> Active", buffer_id);
|
||||
let host = mapping.op.host;
|
||||
match super::map_buffer(raw, buffer, mapping.sub_range.clone(), host) {
|
||||
Ok(ptr) => {
|
||||
buffer.map_state = resource::BufferMapState::Active {
|
||||
ptr,
|
||||
sub_range: mapping.sub_range,
|
||||
host,
|
||||
};
|
||||
resource::BufferMapAsyncStatus::Success
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("Mapping failed {:?}", e);
|
||||
resource::BufferMapAsyncStatus::Error
|
||||
}
|
||||
}
|
||||
} else {
|
||||
resource::BufferMapAsyncStatus::Success
|
||||
};
|
||||
pending_callbacks.push((mapping.op, status));
|
||||
}
|
||||
|
||||
@@ -2767,7 +2767,9 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
hal::memory::Dependencies::empty(),
|
||||
iter::once(transition_src).chain(iter::once(transition_dst)),
|
||||
);
|
||||
comb.copy_buffer(&stage_buffer, &buffer.raw, iter::once(region));
|
||||
if buffer.size > 0 {
|
||||
comb.copy_buffer(&stage_buffer, &buffer.raw, iter::once(region));
|
||||
}
|
||||
}
|
||||
device
|
||||
.pending_writes
|
||||
|
||||
Reference in new issue
Block a user