diff --git a/internal/core/graphics/image.rs b/internal/core/graphics/image.rs index 2c97607e4..191c34992 100644 --- a/internal/core/graphics/image.rs +++ b/internal/core/graphics/image.rs @@ -991,47 +991,21 @@ impl BorrowedOpenGLTextureBuilder { } } -#[cfg(feature = "unstable-wgpu-24")] -#[derive(Debug)] -#[non_exhaustive] -/// This enum describes the possible errors that can occur when importing a WGPU texture, -/// via [`Image::try_from()`]. -pub enum WGPUTextureImportError { - /// The texture format is not supported. The only supported format is Rgba8Unorm and Rgba8UnormSrgb. - InvalidFormat, - /// The texture usage must include TEXTURE_BINDING as well as RENDER_ATTACHMENT. - InvalidUsage, -} - -#[cfg(feature = "unstable-wgpu-24")] -impl core::fmt::Display for WGPUTextureImportError { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - match self { - WGPUTextureImportError::InvalidFormat => f.write_str( - "The texture format is not supported. The only supported format is Rgba8Unorm and Rgba8UnormSrgb", - ), - WGPUTextureImportError::InvalidUsage => f.write_str( - "The texture usage must include TEXTURE_BINDING as well as RENDER_ATTACHMENT", - ), - } - } -} - #[cfg(feature = "unstable-wgpu-24")] impl TryFrom for Image { - type Error = WGPUTextureImportError; + type Error = crate::graphics::wgpu_24::TextureImportError; fn try_from(texture: wgpu_24::Texture) -> Result { if texture.format() != wgpu_24::TextureFormat::Rgba8Unorm && texture.format() != wgpu_24::TextureFormat::Rgba8UnormSrgb { - return Err(WGPUTextureImportError::InvalidFormat); + return Err(Self::Error::InvalidFormat); } let usages = texture.usage(); if !usages.contains(wgpu_24::TextureUsages::TEXTURE_BINDING) || !usages.contains(wgpu_24::TextureUsages::RENDER_ATTACHMENT) { - return Err(WGPUTextureImportError::InvalidUsage); + return Err(Self::Error::InvalidUsage); } Ok(Self(ImageInner::WGPUTexture(WGPUTexture::WGPU24Texture(texture)))) } diff --git a/internal/core/graphics/wgpu_24.rs b/internal/core/graphics/wgpu_24.rs index f67c2f85d..620e5e6f0 100644 --- a/internal/core/graphics/wgpu_24.rs +++ b/internal/core/graphics/wgpu_24.rs @@ -82,3 +82,27 @@ impl Default for WGPUConfiguration { Self::Automatic(WGPUSettings::default()) } } + +#[derive(Debug)] +#[non_exhaustive] +/// This enum describes the possible errors that can occur when importing a WGPU texture, +/// via [`Image::try_from()`](super::Image::try_from()). +pub enum TextureImportError { + /// The texture format is not supported. The only supported format is Rgba8Unorm and Rgba8UnormSrgb. + InvalidFormat, + /// The texture usage must include TEXTURE_BINDING as well as RENDER_ATTACHMENT. + InvalidUsage, +} + +impl core::fmt::Display for TextureImportError { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + match self { + TextureImportError::InvalidFormat => f.write_str( + "The texture format is not supported. The only supported format is Rgba8Unorm and Rgba8UnormSrgb", + ), + TextureImportError::InvalidUsage => f.write_str( + "The texture usage must include TEXTURE_BINDING as well as RENDER_ATTACHMENT", + ), + } + } +}