From a6bc2f6f533c50f7da50643aa03b907271b405df Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Wed, 7 Aug 2024 18:13:42 +0200 Subject: [PATCH] fix check for `flush_mapped_ranges` in `map_buffer` `flush_mapped_ranges` needs to be called when mappings are not coherent. We can also omit flushing for write-mapped buffers since we always flush them on unmap. --- wgpu-core/src/device/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wgpu-core/src/device/mod.rs b/wgpu-core/src/device/mod.rs index 539dfdb3d..1f890de90 100644 --- a/wgpu-core/src/device/mod.rs +++ b/wgpu-core/src/device/mod.rs @@ -349,7 +349,7 @@ fn map_buffer( (uninitialized.start - offset) as usize..(uninitialized.end - offset) as usize; mapped[fill_range].fill(0); - if mapping.is_coherent { + if !mapping.is_coherent && kind == HostMap::Read { unsafe { raw.flush_mapped_ranges(raw_buffer, iter::once(uninitialized)) }; } }