mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-21 23:11:01 +01:00
Texture::{as, from}_core
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
1 parent
7dad9fe416
commit
adaa8eaa51
2 files changed
+29
No files matched your search
@@ -197,6 +197,25 @@ impl Texture {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(wgpu_core)]
|
||||
impl Texture {
|
||||
/// Create a new texture of wgpu from a wgpu-core texture.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// - `core_texture` - wgpu-core texture.
|
||||
pub fn from_core(core_texture: alloc::sync::Arc<wgc::resource::Texture>) -> Self {
|
||||
Self {
|
||||
inner: crate::backend::wgpu_core::CoreTexture::from_core(core_texture).into(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the underlying wgpu-core texture if this `Texture` is on the wgpu-core backend, otherwise `None`.
|
||||
pub fn as_core(&self) -> Option<alloc::sync::Arc<wgc::resource::Texture>> {
|
||||
self.inner.as_core_opt().map(|cd| cd.as_core())
|
||||
}
|
||||
}
|
||||
|
||||
/// Describes a [`Texture`].
|
||||
///
|
||||
/// For use with [`Device::create_texture`].
|
||||
|
||||
@@ -324,6 +324,16 @@ impl CoreTexture {
|
||||
pub unsafe fn as_hal<A: hal::Api>(&self) -> Option<impl Deref<Target = A::Texture>> {
|
||||
unsafe { self.wgpu_texture.clone().as_hal::<A>() }
|
||||
}
|
||||
|
||||
pub(crate) fn from_core(core_texture: Arc<wgc::resource::Texture>) -> Self {
|
||||
Self {
|
||||
wgpu_texture: core_texture,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn as_core(&self) -> Arc<wgc::resource::Texture> {
|
||||
self.wgpu_texture.clone()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
||||
Reference in new issue
Block a user