wgpu/api/
external_texture.rs

1use crate::*;
2
3/// Handle to an external texture on the GPU.
4///
5/// It can be created with [`Device::create_external_texture`].
6///
7/// Corresponds to [WebGPU `GPUExternalTexture`](https://gpuweb.github.io/gpuweb/#gpuexternaltexture).
8#[derive(Debug, Clone)]
9pub struct ExternalTexture {
10    pub(crate) inner: dispatch::DispatchExternalTexture,
11}
12#[cfg(send_sync)]
13static_assertions::assert_impl_all!(ExternalTexture: Send, Sync);
14
15crate::cmp::impl_eq_ord_hash_proxy!(ExternalTexture => .inner);
16
17impl ExternalTexture {
18    /// Destroy the associated native resources as soon as possible.
19    pub fn destroy(&self) {
20        self.inner.destroy();
21    }
22
23    /// Returns custom implementation of ExternalTexture (if custom backend and is internally T)
24    #[cfg(custom)]
25    pub fn as_custom<T: custom::ExternalTextureInterface>(&self) -> Option<&T> {
26        self.inner.as_custom()
27    }
28}
29
30/// Describes an [`ExternalTexture`].
31///
32/// For use with [`Device::create_external_texture`].
33///
34/// Corresponds to [WebGPU `GPUExternalTextureDescriptor`](
35/// https://gpuweb.github.io/gpuweb/#dictdef-gpuexternaltexturedescriptor).
36pub type ExternalTextureDescriptor<'a> = wgt::ExternalTextureDescriptor<Label<'a>>;
37static_assertions::assert_impl_all!(ExternalTextureDescriptor<'_>: Send, Sync);