mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-21 15:00:57 +01:00
Device::{as,from}_core
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
1 parent
89cac1d785
commit
ef4d18d4b2
2 files changed
+29
No files matched your search
@@ -926,6 +926,25 @@ impl Device {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(wgpu_core)]
|
||||
impl Device {
|
||||
/// Create a new device of wgpu from a wgpu-core device.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// - `core_device` - wgpu-core device.
|
||||
pub fn from_core(core_device: alloc::sync::Arc<wgc::device::Device>) -> Self {
|
||||
Self {
|
||||
inner: crate::backend::wgpu_core::CoreDevice::from_core(core_device).into(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the underlying wgpu-core device if this `Device` is on the wgpu-core backend, otherwise `None`.
|
||||
pub fn as_core(&self) -> Option<alloc::sync::Arc<wgc::device::Device>> {
|
||||
self.inner.as_core_opt().map(|cd| cd.as_core())
|
||||
}
|
||||
}
|
||||
|
||||
/// The operation requires the GLES backend on WebGL, but this [`Device`] is
|
||||
/// using a different backend.
|
||||
///
|
||||
|
||||
@@ -277,6 +277,16 @@ impl CoreDevice {
|
||||
use wgc::resource::ParentDevice as _;
|
||||
texture.wgpu_texture.same_device(&self.wgpu_device).is_ok()
|
||||
}
|
||||
|
||||
pub(crate) fn from_core(core_device: Arc<wgc::device::Device>) -> Self {
|
||||
Self {
|
||||
wgpu_device: core_device,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn as_core(&self) -> Arc<wgc::device::Device> {
|
||||
self.wgpu_device.clone()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
||||
Reference in new issue
Block a user