Adapter::{as, from}_core

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
sagudev authored and mergify[bot] committed 2026-09-27 06:46:29 +00:00
1 parent 7014d48757
commit 89cac1d785
2 files changed
+31

No files matched your search

+21
View File
@@ -216,3 +216,24 @@ impl Adapter {
self.inner.cooperative_matrix_properties()
}
}
#[cfg(wgpu_core)]
impl Adapter {
/// Create a new adapter of wgpu from a wgpu-core adapter.
///
/// # Arguments
///
/// - `core_adapter` - wgpu-core adapter.
pub fn from_core(core_adapter: alloc::sync::Arc<wgc::instance::Adapter>) -> Self {
Self {
inner: crate::backend::wgpu_core::CoreAdapter::from_core(core_adapter).into(),
}
}
/// Get the [`wgpu_core`] adapter from this `Adapter`.
///
/// Returns `None` if the adapter is not from the `wgpu_core` backend
pub fn as_core(&self) -> Option<alloc::sync::Arc<wgc::instance::Adapter>> {
self.inner.as_core_opt().map(|adapter| adapter.as_core())
}
}
+10
View File
@@ -204,6 +204,16 @@ impl CoreAdapter {
let queue = CoreQueue { wgpu_queue: queue };
Ok((device, queue))
}
pub(crate) fn from_core(core_adapter: Arc<wgc::instance::Adapter>) -> Self {
Self {
wgpu_adapter: core_adapter,
}
}
pub(crate) fn as_core(&self) -> Arc<wgc::instance::Adapter> {
self.wgpu_adapter.clone()
}
}
#[derive(Debug, Clone)]