From 6b4fea1364c575e0aca02a8b6002700666997a07 Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Thu, 8 Aug 2024 18:17:04 +0200 Subject: [PATCH] [gl] gate usage of `glFlushMappedBufferRange` This is done in the same way as in `map_buffer` & `unmap_buffer`. --- wgpu-hal/src/gles/device.rs | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/wgpu-hal/src/gles/device.rs b/wgpu-hal/src/gles/device.rs index 3e2e308259..c651da6828 100644 --- a/wgpu-hal/src/gles/device.rs +++ b/wgpu-hal/src/gles/device.rs @@ -705,17 +705,20 @@ impl crate::Device for super::Device { I: Iterator, { if let Some(raw) = buffer.raw { - let gl = &self.shared.context.lock(); - unsafe { gl.bind_buffer(buffer.target, Some(raw)) }; - for range in ranges { - let offset_of_current_mapping = *buffer.offset_of_current_mapping.lock().unwrap(); - unsafe { - gl.flush_mapped_buffer_range( - buffer.target, - (range.start - offset_of_current_mapping) as i32, - (range.end - range.start) as i32, - ) - }; + if buffer.data.is_none() { + let gl = &self.shared.context.lock(); + unsafe { gl.bind_buffer(buffer.target, Some(raw)) }; + for range in ranges { + let offset_of_current_mapping = + *buffer.offset_of_current_mapping.lock().unwrap(); + unsafe { + gl.flush_mapped_buffer_range( + buffer.target, + (range.start - offset_of_current_mapping) as i32, + (range.end - range.start) as i32, + ) + }; + } } } }