wgpu::util

Trait TextureFormatExt

source
pub trait TextureFormatExt {
    // Required methods
    fn from_storage_format(storage_format: StorageFormat) -> Self;
    fn to_storage_format(&self) -> Option<StorageFormat>;
}
Expand description

Adds extra conversion functions to TextureFormat.

Required Methods§

source

fn from_storage_format(storage_format: StorageFormat) -> Self

Available on wgpu_core or naga only.

Finds the TextureFormat corresponding to the given StorageFormat.

§Examples
use wgpu::util::TextureFormatExt;
assert_eq!(wgpu::TextureFormat::from_storage_format(wgpu::naga::StorageFormat::Bgra8Unorm), wgpu::TextureFormat::Bgra8Unorm);
source

fn to_storage_format(&self) -> Option<StorageFormat>

Available on wgpu_core or naga only.

Finds the StorageFormat corresponding to the given TextureFormat. Returns None if there is no matching storage format, which typically indicates this format is not supported for storage textures.

§Examples
use wgpu::util::TextureFormatExt;
assert_eq!(wgpu::TextureFormat::Bgra8Unorm.to_storage_format(), Some(wgpu::naga::StorageFormat::Bgra8Unorm));

Object Safety§

This trait is not object safe.

Implementors§