[wgpu-core] Add ExternalTexture type to wgpu-core

`ExternalTexture` will form the basis of wgpu's implementation of
WebGPU's `GPUExternalTexture`. [1]

The application will be responsible for creating `Texture`(s) and
`TextureView`(s) from the external texture source and managing their
lifecycle. It may have a single RGBA texture, or it may have multiple
textures for separate Y and Cb/Cr planes. It can then create an external
texture by calling `create_external_texture()`, providing the texture
views and a descriptor. The descriptor provides the following required
information:

  * Whether the texture data is RGBA, or multiplanar or interleaved
    YCbCr.
  * The purpoted size of the external texture, which may not match the
    actual size of the underlying textures.
  * A matrix for converting from YCbCr to RGBA, if required.
  * A transform to apply to texture sample coordinates, allowing for
    rotation and crop rects.

The external texture stores a reference to the provided texture views,
and additionally owns a `Buffer`. This buffer holds data of the type
`ExternalTextureParams`, and will be provided as a uniform buffer to
shaders containing external textures. This contains information that
will be required by the shaders to handle external textures correctly.

Note that attempting to create an external texture will fail unless the
`Feature::EXTERNAL_TEXTURE` feature is enabled, which as of yet is not
supported by any HAL backends.

Additionally add the relevant API to wgpu, implemented for the
wgpu-core backend. The web and custom backends are unimplemented.

[1] https://www.w3.org/TR/webgpu/#gpuexternaltexture
This commit is contained in:
Jamie Nicol
2025-05-27 13:15:03 +01:00
committed by Jim Blandy
parent 43a4d53107
commit acfa8c5776
19 changed files with 592 additions and 28 deletions

View File

@@ -184,6 +184,14 @@ impl DeviceInterface for CustomDevice {
unimplemented!()
}
fn create_external_texture(
&self,
_desc: &wgpu::ExternalTextureDescriptor<'_>,
_planes: &[&wgpu::TextureView],
) -> wgpu::custom::DispatchExternalTexture {
unimplemented!()
}
fn create_blas(
&self,
_desc: &wgpu::CreateBlasDescriptor<'_>,