diff --git a/wgpu/src/api/render_pipeline.rs b/wgpu/src/api/render_pipeline.rs index b7312f9e1..82ed4c970 100644 --- a/wgpu/src/api/render_pipeline.rs +++ b/wgpu/src/api/render_pipeline.rs @@ -36,6 +36,28 @@ impl RenderPipeline { } } +#[cfg(wgpu_core)] +impl RenderPipeline { + /// Create a new render pipeline of wgpu from a wgpu-core render pipeline. + /// + /// # Arguments + /// + /// - `core_render_pipeline` - wgpu-core render pipeline. + pub fn from_core( + core_render_pipeline: alloc::sync::Arc, + ) -> Self { + Self { + inner: crate::backend::wgpu_core::CoreRenderPipeline::from_core(core_render_pipeline) + .into(), + } + } + + /// Returns the underlying wgpu-core render pipeline if this `RenderPipeline` is on the wgpu-core backend, otherwise `None`. + pub fn as_core(&self) -> Option> { + self.inner.as_core_opt().map(|rp| rp.as_core()) + } +} + /// Specifies an interpretation of the bytes of a vertex buffer as vertex attributes. /// /// Use this in a [`RenderPipelineDescriptor`] to describe the format of the vertex buffers that diff --git a/wgpu/src/backend/wgpu_core.rs b/wgpu/src/backend/wgpu_core.rs index e4633f1f6..3652c6e1c 100644 --- a/wgpu/src/backend/wgpu_core.rs +++ b/wgpu/src/backend/wgpu_core.rs @@ -554,6 +554,18 @@ pub struct CoreRenderPipeline { pub(crate) wgpu_render_pipeline: Arc, } +impl CoreRenderPipeline { + pub(crate) fn from_core(core_render_pipeline: Arc) -> Self { + Self { + wgpu_render_pipeline: core_render_pipeline, + } + } + + pub(crate) fn as_core(&self) -> Arc { + self.wgpu_render_pipeline.clone() + } +} + #[derive(Debug)] pub struct CoreComputePass { pass: wgc::command::ComputePass,