From 0cd527cbc3ed92a62ad519dc7cfe5533fd2db29f Mon Sep 17 00:00:00 2001 From: Nathan Adams Date: Wed, 18 Jan 2023 22:14:21 +0100 Subject: [PATCH] Remove panic when gl.create_buffer() fails on webgl --- CHANGELOG.md | 1 + wgpu-hal/src/gles/device.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd054fcc5f..41df2d188f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -211,6 +211,7 @@ let texture = device.create_texture(&wgpu::TextureDescriptor { - Fix disallowing multisampling for float textures if otherwise supported. By @Wumpf in [#3183](https://github.com/gfx-rs/wgpu/pull/3183) - Fix a panic when creating a pipeline with opaque types other than samplers (images and atomic counters). By @James2022-rgb in [#3361](https://github.com/gfx-rs/wgpu/pull/3361) - Fix uniform buffers being empty on some vendors. By @Dinnerbone in [#3391](https://github.com/gfx-rs/wgpu/pull/3391) +- Fix a panic allocating a new buffer on webgl. By @Dinnerbone in [#3396](https://github.com/gfx-rs/wgpu/pull/3396) #### Vulkan diff --git a/wgpu-hal/src/gles/device.rs b/wgpu-hal/src/gles/device.rs index 9dae237704..c60a1bd84c 100644 --- a/wgpu-hal/src/gles/device.rs +++ b/wgpu-hal/src/gles/device.rs @@ -472,7 +472,7 @@ impl crate::Device for super::Device { map_flags |= glow::MAP_WRITE_BIT; } - let raw = Some(unsafe { gl.create_buffer() }.unwrap()); + let raw = Some(unsafe { gl.create_buffer() }.map_err(|_| crate::DeviceError::OutOfMemory)?); unsafe { gl.bind_buffer(target, raw) }; let raw_size = desc .size