From d0bb62a157807732f301aaaa01d14ee5f37edcdc Mon Sep 17 00:00:00 2001 From: Robin Cramer <73714848+R-Cramer4@users.noreply.github.com> Date: Thu, 9 Oct 2025 11:22:54 -0400 Subject: [PATCH] Added from_custom to texture (#8315) --- CHANGELOG.md | 5 +++++ wgpu/src/api/texture.rs | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 23fd1c475..ac01874cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -72,6 +72,11 @@ SamplerDescriptor { ... } ``` +### Changes + +#### General + +- Texture now has `from_custom`. By @R-Cramer4 in [#8315](https://github.com/gfx-rs/wgpu/pull/8315). ### Bug Fixes diff --git a/wgpu/src/api/texture.rs b/wgpu/src/api/texture.rs index 98136ece4..2f1034331 100644 --- a/wgpu/src/api/texture.rs +++ b/wgpu/src/api/texture.rs @@ -69,6 +69,22 @@ impl Texture { self.inner.as_custom() } + #[cfg(custom)] + /// Creates a texture from already created custom implementation with the given description + pub fn from_custom( + texture: T, + desc: &TextureDescriptor<'_>, + ) -> Self { + Self { + inner: dispatch::DispatchTexture::custom(texture), + descriptor: TextureDescriptor { + label: None, + view_formats: &[], + ..desc.clone() + }, + } + } + /// Creates a view of this texture, specifying an interpretation of its texels and /// possibly a subset of its layers and mip levels. ///