diff --git a/CHANGELOG.md b/CHANGELOG.md index da5ac74ff..c85f5a1d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -114,6 +114,9 @@ By @teoxoy in [#3436](https://github.com/gfx-rs/wgpu/pull/3436) - Treat `VK_SUBOPTIMAL_KHR` as `VK_SUCCESS` on Android. By @James2022-rgb in [#3525](https://github.com/gfx-rs/wgpu/pull/3525) +#### Metal +- `create_texture` returns an error if `new_texture` returns NULL. By @jinleili in [#3554](https://github.com/gfx-rs/wgpu/pull/3554) + ## wgpu-0.15.0 (2023-01-25) ### Major Changes diff --git a/wgpu-hal/src/metal/device.rs b/wgpu-hal/src/metal/device.rs index c80fec2b9..52cc21512 100644 --- a/wgpu-hal/src/metal/device.rs +++ b/wgpu-hal/src/metal/device.rs @@ -288,6 +288,8 @@ impl crate::Device for super::Device { &self, desc: &crate::TextureDescriptor, ) -> DeviceResult { + use foreign_types::ForeignTypeRef; + let mtl_format = self.shared.private_caps.map_format(desc.format); objc::rc::autoreleasepool(|| { @@ -321,6 +323,9 @@ impl crate::Device for super::Device { descriptor.set_storage_mode(metal::MTLStorageMode::Private); let raw = self.shared.device.lock().new_texture(&descriptor); + if raw.as_ptr().is_null() { + return Err(crate::DeviceError::OutOfMemory); + } if let Some(label) = desc.label { raw.set_label(label); }