pub enum TextureFormat {
Show 13 variants
R8Unorm,
R8Srgb,
Rg8Unorm,
Rgba8Unorm,
Rgba8Srgb,
Bgra8Unorm,
Bgra8Srgb,
R16Unorm,
Rg16Unorm,
Rgba16Unorm,
R32Float,
Rg32Float,
Rgba32Float,
}Expand description
Exhaustive GPU texture format descriptors for fovea pixel types.
This enum is always available (no feature flag required). It is a pure Rust data type that downstream consumers (egui, bevy, raw Vulkan, wgpu) can match on directly.
Adding a variant is semver-major.
§Design decisions
-
No 3-channel formats. GPU APIs generally do not support 3-channel textures (
Rgb8,Bgr8,RgbF32). Users must convert to 4-channel before GPU upload. This is explicit per fovea Philosophy #4. -
R8Srgbincluded. Not all GPU APIs supportR8_SRGB(WebGPU/wgpu notably do not), but the enum models the logical format. Downstream integrations that target such an API should mapR8Srgbto the nearest available format (typicallyR8Unorm). -
Bgra8Srgbreserved. fovea has noSrgbBgra8type today, but the format is common in GPU APIs. Included for forward-compatibility.
§Examples
use fovea_display::TextureFormat;
let fmt = TextureFormat::Rgba8Srgb;
assert_eq!(fmt.bytes_per_pixel(), 4);
assert_eq!(fmt.channel_count(), 4);Variants§
R8Unorm
Single-channel 8-bit unsigned normalized (linear). Maps to Mono8.
R8Srgb
Single-channel 8-bit sRGB. Maps to SrgbMono8.
Rg8Unorm
Two-channel 8-bit unsigned normalized. Maps to MonoA8.
Rgba8Unorm
Four-channel 8-bit unsigned normalized (linear). Maps to Rgba8.
Rgba8Srgb
Four-channel 8-bit sRGB with alpha. Maps to Srgba8.
Bgra8Unorm
Four-channel 8-bit BGRA unsigned normalized (linear). Maps to Bgra8.
Bgra8Srgb
Four-channel 8-bit BGRA sRGB. Reserved for future SrgbBgra8.
R16Unorm
Single-channel 16-bit unsigned normalized. Maps to Mono16.
Rg16Unorm
Two-channel 16-bit unsigned normalized. Maps to MonoA16.
Rgba16Unorm
Four-channel 16-bit unsigned normalized. Maps to Rgba16.
R32Float
Single-channel 32-bit float. Maps to MonoF32.
Rg32Float
Two-channel 32-bit float. Maps to MonoAF32.
Rgba32Float
Four-channel 32-bit float. Maps to RgbaF32.
Implementations§
Source§impl TextureFormat
impl TextureFormat
Sourcepub const fn bytes_per_pixel(&self) -> usize
pub const fn bytes_per_pixel(&self) -> usize
Returns the total number of bytes per pixel for this format.
§Examples
use fovea_display::TextureFormat;
assert_eq!(TextureFormat::R8Unorm.bytes_per_pixel(), 1);
assert_eq!(TextureFormat::Rg16Unorm.bytes_per_pixel(), 4);
assert_eq!(TextureFormat::Rgba32Float.bytes_per_pixel(), 16);Sourcepub const fn channel_count(&self) -> usize
pub const fn channel_count(&self) -> usize
Returns the number of channels in this format.
§Examples
use fovea_display::TextureFormat;
assert_eq!(TextureFormat::R8Unorm.channel_count(), 1);
assert_eq!(TextureFormat::Rg8Unorm.channel_count(), 2);
assert_eq!(TextureFormat::Rgba8Srgb.channel_count(), 4);Trait Implementations§
Source§impl Clone for TextureFormat
impl Clone for TextureFormat
Source§fn clone(&self) -> TextureFormat
fn clone(&self) -> TextureFormat
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for TextureFormat
Source§impl Debug for TextureFormat
impl Debug for TextureFormat
impl Eq for TextureFormat
Source§impl Hash for TextureFormat
impl Hash for TextureFormat
Source§impl PartialEq for TextureFormat
impl PartialEq for TextureFormat
Source§fn eq(&self, other: &TextureFormat) -> bool
fn eq(&self, other: &TextureFormat) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for TextureFormat
Auto Trait Implementations§
impl Freeze for TextureFormat
impl RefUnwindSafe for TextureFormat
impl Send for TextureFormat
impl Sync for TextureFormat
impl Unpin for TextureFormat
impl UnsafeUnpin for TextureFormat
impl UnwindSafe for TextureFormat
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> ConvertPixelExt for T
impl<T> ConvertPixelExt for T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.