CommandEncoder::{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 f50aa972fe
commit 87913337a6
2 files changed
+30

No files matched your search

+20
View File
@@ -442,3 +442,23 @@ impl CommandEncoder {
);
}
}
#[cfg(wgpu_core)]
impl CommandEncoder {
/// Create a new command encoder of wgpu from a wgpu-core command encoder.
///
/// # Arguments
///
/// - `core_encoder` - wgpu-core command encoder.
pub fn from_core(core_encoder: alloc::sync::Arc<wgc::command::CommandEncoder>) -> Self {
Self {
inner: crate::backend::wgpu_core::CoreCommandEncoder::from_core(core_encoder).into(),
actions: SharedDeferredCommandBufferActions::default(),
}
}
/// Returns the underlying wgpu-core command encoder if this `CommandEncoder` is on the wgpu-core backend, otherwise `None`.
pub fn as_core(&self) -> Option<alloc::sync::Arc<wgc::command::CommandEncoder>> {
self.inner.as_core_opt().map(|cd| cd.as_core())
}
}
+10
View File
@@ -498,6 +498,16 @@ impl CoreCommandEncoder {
.as_hal_mut::<A, F, R>(hal_command_encoder_callback)
}
}
pub(crate) fn from_core(core_encoder: Arc<wgc::command::CommandEncoder>) -> Self {
Self {
wgpu_command_encoder: core_encoder,
}
}
pub(crate) fn as_core(&self) -> Arc<wgc::command::CommandEncoder> {
self.wgpu_command_encoder.clone()
}
}
#[derive(Debug, Clone)]