Only send mapping back on unmap when MapMode = WRITE (#34054)

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
Samson 2024-10-29 19:42:07 +01:00 committed by GitHub
parent d5554235fe
commit 43d1601016
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 20 additions and 23 deletions

View file

@ -205,10 +205,15 @@ impl GPUBufferMethods for GPUBuffer {
// Step 5&7
if let Err(e) = self.channel.0.send(WebGPURequest::UnmapBuffer {
buffer_id: self.id().0,
array_buffer: IpcSharedMemory::from_bytes(mapping.data.data()),
write_back: mapping.mode >= GPUMapModeConstants::WRITE,
offset: mapping.range.start,
size: mapping.range.end - mapping.range.start,
mapping: if mapping.mode >= GPUMapModeConstants::WRITE {
Some(Mapping {
data: IpcSharedMemory::from_bytes(mapping.data.data()),
range: mapping.range.clone(),
mode: HostMap::Write,
})
} else {
None
},
}) {
warn!("Failed to send Buffer unmap ({:?}) ({})", self.buffer.0, e);
}
@ -249,8 +254,6 @@ impl GPUBufferMethods for GPUBuffer {
// Step 4
*self.pending_map.borrow_mut() = Some(promise.clone());
// Step 5
// This should be bitflags in wgpu-core
let host_map = match mode {
GPUMapModeConstants::READ => HostMap::Read,
GPUMapModeConstants::WRITE => HostMap::Write,