diff --git a/wgpu/src/api/device.rs b/wgpu/src/api/device.rs index 99ed5071df9..0796fec2c0d 100644 --- a/wgpu/src/api/device.rs +++ b/wgpu/src/api/device.rs @@ -47,6 +47,15 @@ impl Device { } } + #[cfg(custom)] + /// Convert Device into custom implementation. + /// + /// This is useful for wrapping the an existing device implementation to + /// implement a new custom device interface + pub fn into_custom(self) -> crate::dispatch::DispatchDevice { + self.inner + } + /// Constructs a stub device for testing using [`Backend::Noop`]. /// /// This is a convenience function which avoids the configuration, `async`, and fallibility diff --git a/wgpu/src/api/instance.rs b/wgpu/src/api/instance.rs index 0d9818f78d9..3308e6de3e8 100644 --- a/wgpu/src/api/instance.rs +++ b/wgpu/src/api/instance.rs @@ -206,6 +206,15 @@ impl Instance { } } + #[cfg(custom)] + /// Convert Instance into custom implementation. + /// + /// This is useful for wrapping the an existing instance implementation to + /// implement a new custom instance interface + pub fn into_custom(self) -> crate::dispatch::DispatchInstance { + self.inner + } + #[cfg(custom)] /// Returns custom implementation of Instance (if custom backend and is internally T) pub fn as_custom(&self) -> Option<&T> { diff --git a/wgpu/src/api/queue.rs b/wgpu/src/api/queue.rs index 0932a314950..e3e21ee74b8 100644 --- a/wgpu/src/api/queue.rs +++ b/wgpu/src/api/queue.rs @@ -33,6 +33,15 @@ impl Queue { inner: dispatch::DispatchQueue::custom(queue), } } + + #[cfg(custom)] + /// Convert Queue into custom implementation. + /// + /// This is useful for wrapping the an existing queue implementation to + /// implement a new custom queue interface + pub fn into_custom(self) -> crate::dispatch::DispatchQueue { + self.inner + } } /// Identifier for a particular call to [`Queue::submit`]. Can be used