Skip to main content

TextureFormat

Enum TextureFormat 

Source
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.

  • R8Srgb included. Not all GPU APIs support R8_SRGB (WebGPU/wgpu notably do not), but the enum models the logical format. Downstream integrations that target such an API should map R8Srgb to the nearest available format (typically R8Unorm).

  • Bgra8Srgb reserved. fovea has no SrgbBgra8 type 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

Source

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);
Source

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

Source§

fn clone(&self) -> TextureFormat

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for TextureFormat

Source§

impl Debug for TextureFormat

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for TextureFormat

Source§

impl Hash for TextureFormat

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for TextureFormat

Source§

fn eq(&self, other: &TextureFormat) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for TextureFormat

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ConvertPixelExt for T

Source§

fn then<Mid, B>(self, next: B) -> Then<Self, B, Mid>

Chain this strategy with a second strategy, producing a Then combinator that converts Src → Mid → Dst in a single step. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromLinear<T> for T

Source§

fn from_linear(acc: T) -> T

Converts a linear-space accumulator value back to this pixel type, applying rounding and clamping. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more