Skip to content

Commit

Permalink
metal: if new_texture() returns NULL, create_texture() returns an…
Browse files Browse the repository at this point in the history
… error
  • Loading branch information
jinleili committed Mar 3, 2023
1 parent e998d7b commit fe69d8e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions wgpu-hal/src/metal/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(|| {
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit fe69d8e

Please sign in to comment.