[Metal] Add a way to create a device and queue from raw resources in wgpu-hal (#3338)

This commit is contained in:
AdrianEddy 2023-02-02 00:56:48 +01:00 committed by GitHub
parent 1e27fd4afb
commit 2562f323bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 0 deletions

View File

@ -269,6 +269,9 @@ By @jimblandy in [#3254](https://github.com/gfx-rs/wgpu/pull/3254).
- Add `MULTISAMPLE_X2`, `MULTISAMPLE_X4` and `MULTISAMPLE_X8` to `TextureFormatFeatureFlags`. By @39ali in [3140](https://github.com/gfx-rs/wgpu/pull/3140)
- Sync `TextureFormat.describe` with the spec. By @teoxoy in [3312](https://github.com/gfx-rs/wgpu/pull/3312)
#### Metal
- Add a way to create `Device` and `Queue` from raw Metal resources in wgpu-hal. By @AdrianEddy in [#3338](https://github.com/gfx-rs/wgpu/pull/3338)
### Bug Fixes
#### General

View File

@ -219,6 +219,13 @@ impl super::Device {
}
}
pub unsafe fn device_from_raw(raw: mtl::Device, features: wgt::Features) -> super::Device {
super::Device {
shared: Arc::new(super::AdapterShared::new(raw)),
features,
}
}
pub fn raw_device(&self) -> &Mutex<mtl::Device> {
&self.shared.device
}

View File

@ -286,6 +286,13 @@ pub struct Queue {
unsafe impl Send for Queue {}
unsafe impl Sync for Queue {}
impl Queue {
pub unsafe fn queue_from_raw(raw: mtl::CommandQueue) -> Self {
Self {
raw: Arc::new(Mutex::new(raw)),
}
}
}
pub struct Device {
shared: Arc<AdapterShared>,
features: wgt::Features,