ComputePipeline::{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 f7ae2007a0
commit 6b7954f1c7
2 files changed
+34

No files matched your search

+22
View File
@@ -35,6 +35,28 @@ impl ComputePipeline {
}
}
#[cfg(wgpu_core)]
impl ComputePipeline {
/// Create a new compute pipeline of wgpu from a wgpu-core compute pipeline.
///
/// # Arguments
///
/// - `core_compute_pipeline` - wgpu-core compute pipeline.
pub fn from_core(
core_compute_pipeline: alloc::sync::Arc<wgc::pipeline::ComputePipeline>,
) -> Self {
Self {
inner: crate::backend::wgpu_core::CoreComputePipeline::from_core(core_compute_pipeline)
.into(),
}
}
/// Returns the underlying wgpu-core compute pipeline if this `ComputePipeline` is on the wgpu-core backend, otherwise `None`.
pub fn as_core(&self) -> Option<alloc::sync::Arc<wgc::pipeline::ComputePipeline>> {
self.inner.as_core_opt().map(|cp| cp.as_core())
}
}
/// Describes a compute pipeline.
///
/// For use with [`Device::create_compute_pipeline`].
+12
View File
@@ -513,6 +513,18 @@ pub struct CoreComputePipeline {
pub(crate) wgpu_compute_pipeline: Arc<wgc::pipeline::ComputePipeline>,
}
impl CoreComputePipeline {
pub(crate) fn from_core(core_compute_pipeline: Arc<wgc::pipeline::ComputePipeline>) -> Self {
Self {
wgpu_compute_pipeline: core_compute_pipeline,
}
}
pub(crate) fn as_core(&self) -> Arc<wgc::pipeline::ComputePipeline> {
self.wgpu_compute_pipeline.clone()
}
}
#[derive(Debug, Clone)]
pub struct CoreRenderPipeline {
pub(crate) wgpu_render_pipeline: Arc<wgc::pipeline::RenderPipeline>,