metal: if new_texture() returns NULL, create_texture() returns an error (#3554)

This commit is contained in:
Jinlei Li 2023-03-03 20:51:38 +08:00 committed by GitHub
parent e998d7bae0
commit de695fca0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -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

View File

@ -288,6 +288,8 @@ impl crate::Device<super::Api> for super::Device {
&self,
desc: &crate::TextureDescriptor,
) -> DeviceResult<super::Texture> {
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<super::Api> 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);
}