pebble-engine 0.17.0

A modular, ECS-style graphics/app framework for Rust.
Documentation
//! Mirrors `wgpu::TextureFormat` exactly (every variant, including the
//! nested `Astc` block/channel), so a texture's format never needs a raw
//! `wgpu::TextureFormat` — not even for exotic/compressed formats. Convert
//! either direction via `.into()`.

/// ASTC block dimensions — mirrors `wgpu::AstcBlock`.
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub enum AstcBlock {
    B4x4,
    B5x4,
    B5x5,
    B6x5,
    B6x6,
    B8x5,
    B8x6,
    B8x8,
    B10x5,
    B10x6,
    B10x8,
    B10x10,
    B12x10,
    B12x12,
}

impl From<AstcBlock> for wgpu::AstcBlock {
    fn from(value: AstcBlock) -> Self {
        match value {
            AstcBlock::B4x4 => Self::B4x4,
            AstcBlock::B5x4 => Self::B5x4,
            AstcBlock::B5x5 => Self::B5x5,
            AstcBlock::B6x5 => Self::B6x5,
            AstcBlock::B6x6 => Self::B6x6,
            AstcBlock::B8x5 => Self::B8x5,
            AstcBlock::B8x6 => Self::B8x6,
            AstcBlock::B8x8 => Self::B8x8,
            AstcBlock::B10x5 => Self::B10x5,
            AstcBlock::B10x6 => Self::B10x6,
            AstcBlock::B10x8 => Self::B10x8,
            AstcBlock::B10x10 => Self::B10x10,
            AstcBlock::B12x10 => Self::B12x10,
            AstcBlock::B12x12 => Self::B12x12,
        }
    }
}

impl From<wgpu::AstcBlock> for AstcBlock {
    fn from(value: wgpu::AstcBlock) -> Self {
        match value {
            wgpu::AstcBlock::B4x4 => Self::B4x4,
            wgpu::AstcBlock::B5x4 => Self::B5x4,
            wgpu::AstcBlock::B5x5 => Self::B5x5,
            wgpu::AstcBlock::B6x5 => Self::B6x5,
            wgpu::AstcBlock::B6x6 => Self::B6x6,
            wgpu::AstcBlock::B8x5 => Self::B8x5,
            wgpu::AstcBlock::B8x6 => Self::B8x6,
            wgpu::AstcBlock::B8x8 => Self::B8x8,
            wgpu::AstcBlock::B10x5 => Self::B10x5,
            wgpu::AstcBlock::B10x6 => Self::B10x6,
            wgpu::AstcBlock::B10x8 => Self::B10x8,
            wgpu::AstcBlock::B10x10 => Self::B10x10,
            wgpu::AstcBlock::B12x10 => Self::B12x10,
            wgpu::AstcBlock::B12x12 => Self::B12x12,
        }
    }
}

/// ASTC RGBA channel — mirrors `wgpu::AstcChannel`.
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub enum AstcChannel {
    Unorm,
    UnormSrgb,
    Hdr,
}

impl From<AstcChannel> for wgpu::AstcChannel {
    fn from(value: AstcChannel) -> Self {
        match value {
            AstcChannel::Unorm => Self::Unorm,
            AstcChannel::UnormSrgb => Self::UnormSrgb,
            AstcChannel::Hdr => Self::Hdr,
        }
    }
}

impl From<wgpu::AstcChannel> for AstcChannel {
    fn from(value: wgpu::AstcChannel) -> Self {
        match value {
            wgpu::AstcChannel::Unorm => Self::Unorm,
            wgpu::AstcChannel::UnormSrgb => Self::UnormSrgb,
            wgpu::AstcChannel::Hdr => Self::Hdr,
        }
    }
}

/// GPU texel storage format — mirrors `wgpu::TextureFormat` exactly (same
/// variants, same names).
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub enum TextureFormat {
    R8Unorm,
    R8Snorm,
    R8Uint,
    R8Sint,
    R16Uint,
    R16Sint,
    R16Unorm,
    R16Snorm,
    R16Float,
    Rg8Unorm,
    Rg8Snorm,
    Rg8Uint,
    Rg8Sint,
    R32Uint,
    R32Sint,
    R32Float,
    Rg16Uint,
    Rg16Sint,
    Rg16Unorm,
    Rg16Snorm,
    Rg16Float,
    Rgba8Unorm,
    Rgba8UnormSrgb,
    Rgba8Snorm,
    Rgba8Uint,
    Rgba8Sint,
    Bgra8Unorm,
    Bgra8UnormSrgb,
    Rgb9e5Ufloat,
    Rgb10a2Uint,
    Rgb10a2Unorm,
    Rg11b10Ufloat,
    R64Uint,
    Rg32Uint,
    Rg32Sint,
    Rg32Float,
    Rgba16Uint,
    Rgba16Sint,
    Rgba16Unorm,
    Rgba16Snorm,
    Rgba16Float,
    Rgba32Uint,
    Rgba32Sint,
    Rgba32Float,
    Stencil8,
    Depth16Unorm,
    Depth24Plus,
    Depth24PlusStencil8,
    Depth32Float,
    Depth32FloatStencil8,
    NV12,
    P010,
    Bc1RgbaUnorm,
    Bc1RgbaUnormSrgb,
    Bc2RgbaUnorm,
    Bc2RgbaUnormSrgb,
    Bc3RgbaUnorm,
    Bc3RgbaUnormSrgb,
    Bc4RUnorm,
    Bc4RSnorm,
    Bc5RgUnorm,
    Bc5RgSnorm,
    Bc6hRgbUfloat,
    Bc6hRgbFloat,
    Bc7RgbaUnorm,
    Bc7RgbaUnormSrgb,
    Etc2Rgb8Unorm,
    Etc2Rgb8UnormSrgb,
    Etc2Rgb8A1Unorm,
    Etc2Rgb8A1UnormSrgb,
    Etc2Rgba8Unorm,
    Etc2Rgba8UnormSrgb,
    EacR11Unorm,
    EacR11Snorm,
    EacRg11Unorm,
    EacRg11Snorm,
    Astc { block: AstcBlock, channel: AstcChannel },
}

impl From<TextureFormat> for wgpu::TextureFormat {
    fn from(format: TextureFormat) -> Self {
        match format {
            TextureFormat::R8Unorm => Self::R8Unorm,
            TextureFormat::R8Snorm => Self::R8Snorm,
            TextureFormat::R8Uint => Self::R8Uint,
            TextureFormat::R8Sint => Self::R8Sint,
            TextureFormat::R16Uint => Self::R16Uint,
            TextureFormat::R16Sint => Self::R16Sint,
            TextureFormat::R16Unorm => Self::R16Unorm,
            TextureFormat::R16Snorm => Self::R16Snorm,
            TextureFormat::R16Float => Self::R16Float,
            TextureFormat::Rg8Unorm => Self::Rg8Unorm,
            TextureFormat::Rg8Snorm => Self::Rg8Snorm,
            TextureFormat::Rg8Uint => Self::Rg8Uint,
            TextureFormat::Rg8Sint => Self::Rg8Sint,
            TextureFormat::R32Uint => Self::R32Uint,
            TextureFormat::R32Sint => Self::R32Sint,
            TextureFormat::R32Float => Self::R32Float,
            TextureFormat::Rg16Uint => Self::Rg16Uint,
            TextureFormat::Rg16Sint => Self::Rg16Sint,
            TextureFormat::Rg16Unorm => Self::Rg16Unorm,
            TextureFormat::Rg16Snorm => Self::Rg16Snorm,
            TextureFormat::Rg16Float => Self::Rg16Float,
            TextureFormat::Rgba8Unorm => Self::Rgba8Unorm,
            TextureFormat::Rgba8UnormSrgb => Self::Rgba8UnormSrgb,
            TextureFormat::Rgba8Snorm => Self::Rgba8Snorm,
            TextureFormat::Rgba8Uint => Self::Rgba8Uint,
            TextureFormat::Rgba8Sint => Self::Rgba8Sint,
            TextureFormat::Bgra8Unorm => Self::Bgra8Unorm,
            TextureFormat::Bgra8UnormSrgb => Self::Bgra8UnormSrgb,
            TextureFormat::Rgb9e5Ufloat => Self::Rgb9e5Ufloat,
            TextureFormat::Rgb10a2Uint => Self::Rgb10a2Uint,
            TextureFormat::Rgb10a2Unorm => Self::Rgb10a2Unorm,
            TextureFormat::Rg11b10Ufloat => Self::Rg11b10Ufloat,
            TextureFormat::R64Uint => Self::R64Uint,
            TextureFormat::Rg32Uint => Self::Rg32Uint,
            TextureFormat::Rg32Sint => Self::Rg32Sint,
            TextureFormat::Rg32Float => Self::Rg32Float,
            TextureFormat::Rgba16Uint => Self::Rgba16Uint,
            TextureFormat::Rgba16Sint => Self::Rgba16Sint,
            TextureFormat::Rgba16Unorm => Self::Rgba16Unorm,
            TextureFormat::Rgba16Snorm => Self::Rgba16Snorm,
            TextureFormat::Rgba16Float => Self::Rgba16Float,
            TextureFormat::Rgba32Uint => Self::Rgba32Uint,
            TextureFormat::Rgba32Sint => Self::Rgba32Sint,
            TextureFormat::Rgba32Float => Self::Rgba32Float,
            TextureFormat::Stencil8 => Self::Stencil8,
            TextureFormat::Depth16Unorm => Self::Depth16Unorm,
            TextureFormat::Depth24Plus => Self::Depth24Plus,
            TextureFormat::Depth24PlusStencil8 => Self::Depth24PlusStencil8,
            TextureFormat::Depth32Float => Self::Depth32Float,
            TextureFormat::Depth32FloatStencil8 => Self::Depth32FloatStencil8,
            TextureFormat::NV12 => Self::NV12,
            TextureFormat::P010 => Self::P010,
            TextureFormat::Bc1RgbaUnorm => Self::Bc1RgbaUnorm,
            TextureFormat::Bc1RgbaUnormSrgb => Self::Bc1RgbaUnormSrgb,
            TextureFormat::Bc2RgbaUnorm => Self::Bc2RgbaUnorm,
            TextureFormat::Bc2RgbaUnormSrgb => Self::Bc2RgbaUnormSrgb,
            TextureFormat::Bc3RgbaUnorm => Self::Bc3RgbaUnorm,
            TextureFormat::Bc3RgbaUnormSrgb => Self::Bc3RgbaUnormSrgb,
            TextureFormat::Bc4RUnorm => Self::Bc4RUnorm,
            TextureFormat::Bc4RSnorm => Self::Bc4RSnorm,
            TextureFormat::Bc5RgUnorm => Self::Bc5RgUnorm,
            TextureFormat::Bc5RgSnorm => Self::Bc5RgSnorm,
            TextureFormat::Bc6hRgbUfloat => Self::Bc6hRgbUfloat,
            TextureFormat::Bc6hRgbFloat => Self::Bc6hRgbFloat,
            TextureFormat::Bc7RgbaUnorm => Self::Bc7RgbaUnorm,
            TextureFormat::Bc7RgbaUnormSrgb => Self::Bc7RgbaUnormSrgb,
            TextureFormat::Etc2Rgb8Unorm => Self::Etc2Rgb8Unorm,
            TextureFormat::Etc2Rgb8UnormSrgb => Self::Etc2Rgb8UnormSrgb,
            TextureFormat::Etc2Rgb8A1Unorm => Self::Etc2Rgb8A1Unorm,
            TextureFormat::Etc2Rgb8A1UnormSrgb => Self::Etc2Rgb8A1UnormSrgb,
            TextureFormat::Etc2Rgba8Unorm => Self::Etc2Rgba8Unorm,
            TextureFormat::Etc2Rgba8UnormSrgb => Self::Etc2Rgba8UnormSrgb,
            TextureFormat::EacR11Unorm => Self::EacR11Unorm,
            TextureFormat::EacR11Snorm => Self::EacR11Snorm,
            TextureFormat::EacRg11Unorm => Self::EacRg11Unorm,
            TextureFormat::EacRg11Snorm => Self::EacRg11Snorm,
            TextureFormat::Astc { block, channel } => Self::Astc { block: block.into(), channel: channel.into() },
        }
    }
}

impl From<wgpu::TextureFormat> for TextureFormat {
    fn from(format: wgpu::TextureFormat) -> Self {
        match format {
            wgpu::TextureFormat::R8Unorm => Self::R8Unorm,
            wgpu::TextureFormat::R8Snorm => Self::R8Snorm,
            wgpu::TextureFormat::R8Uint => Self::R8Uint,
            wgpu::TextureFormat::R8Sint => Self::R8Sint,
            wgpu::TextureFormat::R16Uint => Self::R16Uint,
            wgpu::TextureFormat::R16Sint => Self::R16Sint,
            wgpu::TextureFormat::R16Unorm => Self::R16Unorm,
            wgpu::TextureFormat::R16Snorm => Self::R16Snorm,
            wgpu::TextureFormat::R16Float => Self::R16Float,
            wgpu::TextureFormat::Rg8Unorm => Self::Rg8Unorm,
            wgpu::TextureFormat::Rg8Snorm => Self::Rg8Snorm,
            wgpu::TextureFormat::Rg8Uint => Self::Rg8Uint,
            wgpu::TextureFormat::Rg8Sint => Self::Rg8Sint,
            wgpu::TextureFormat::R32Uint => Self::R32Uint,
            wgpu::TextureFormat::R32Sint => Self::R32Sint,
            wgpu::TextureFormat::R32Float => Self::R32Float,
            wgpu::TextureFormat::Rg16Uint => Self::Rg16Uint,
            wgpu::TextureFormat::Rg16Sint => Self::Rg16Sint,
            wgpu::TextureFormat::Rg16Unorm => Self::Rg16Unorm,
            wgpu::TextureFormat::Rg16Snorm => Self::Rg16Snorm,
            wgpu::TextureFormat::Rg16Float => Self::Rg16Float,
            wgpu::TextureFormat::Rgba8Unorm => Self::Rgba8Unorm,
            wgpu::TextureFormat::Rgba8UnormSrgb => Self::Rgba8UnormSrgb,
            wgpu::TextureFormat::Rgba8Snorm => Self::Rgba8Snorm,
            wgpu::TextureFormat::Rgba8Uint => Self::Rgba8Uint,
            wgpu::TextureFormat::Rgba8Sint => Self::Rgba8Sint,
            wgpu::TextureFormat::Bgra8Unorm => Self::Bgra8Unorm,
            wgpu::TextureFormat::Bgra8UnormSrgb => Self::Bgra8UnormSrgb,
            wgpu::TextureFormat::Rgb9e5Ufloat => Self::Rgb9e5Ufloat,
            wgpu::TextureFormat::Rgb10a2Uint => Self::Rgb10a2Uint,
            wgpu::TextureFormat::Rgb10a2Unorm => Self::Rgb10a2Unorm,
            wgpu::TextureFormat::Rg11b10Ufloat => Self::Rg11b10Ufloat,
            wgpu::TextureFormat::R64Uint => Self::R64Uint,
            wgpu::TextureFormat::Rg32Uint => Self::Rg32Uint,
            wgpu::TextureFormat::Rg32Sint => Self::Rg32Sint,
            wgpu::TextureFormat::Rg32Float => Self::Rg32Float,
            wgpu::TextureFormat::Rgba16Uint => Self::Rgba16Uint,
            wgpu::TextureFormat::Rgba16Sint => Self::Rgba16Sint,
            wgpu::TextureFormat::Rgba16Unorm => Self::Rgba16Unorm,
            wgpu::TextureFormat::Rgba16Snorm => Self::Rgba16Snorm,
            wgpu::TextureFormat::Rgba16Float => Self::Rgba16Float,
            wgpu::TextureFormat::Rgba32Uint => Self::Rgba32Uint,
            wgpu::TextureFormat::Rgba32Sint => Self::Rgba32Sint,
            wgpu::TextureFormat::Rgba32Float => Self::Rgba32Float,
            wgpu::TextureFormat::Stencil8 => Self::Stencil8,
            wgpu::TextureFormat::Depth16Unorm => Self::Depth16Unorm,
            wgpu::TextureFormat::Depth24Plus => Self::Depth24Plus,
            wgpu::TextureFormat::Depth24PlusStencil8 => Self::Depth24PlusStencil8,
            wgpu::TextureFormat::Depth32Float => Self::Depth32Float,
            wgpu::TextureFormat::Depth32FloatStencil8 => Self::Depth32FloatStencil8,
            wgpu::TextureFormat::NV12 => Self::NV12,
            wgpu::TextureFormat::P010 => Self::P010,
            wgpu::TextureFormat::Bc1RgbaUnorm => Self::Bc1RgbaUnorm,
            wgpu::TextureFormat::Bc1RgbaUnormSrgb => Self::Bc1RgbaUnormSrgb,
            wgpu::TextureFormat::Bc2RgbaUnorm => Self::Bc2RgbaUnorm,
            wgpu::TextureFormat::Bc2RgbaUnormSrgb => Self::Bc2RgbaUnormSrgb,
            wgpu::TextureFormat::Bc3RgbaUnorm => Self::Bc3RgbaUnorm,
            wgpu::TextureFormat::Bc3RgbaUnormSrgb => Self::Bc3RgbaUnormSrgb,
            wgpu::TextureFormat::Bc4RUnorm => Self::Bc4RUnorm,
            wgpu::TextureFormat::Bc4RSnorm => Self::Bc4RSnorm,
            wgpu::TextureFormat::Bc5RgUnorm => Self::Bc5RgUnorm,
            wgpu::TextureFormat::Bc5RgSnorm => Self::Bc5RgSnorm,
            wgpu::TextureFormat::Bc6hRgbUfloat => Self::Bc6hRgbUfloat,
            wgpu::TextureFormat::Bc6hRgbFloat => Self::Bc6hRgbFloat,
            wgpu::TextureFormat::Bc7RgbaUnorm => Self::Bc7RgbaUnorm,
            wgpu::TextureFormat::Bc7RgbaUnormSrgb => Self::Bc7RgbaUnormSrgb,
            wgpu::TextureFormat::Etc2Rgb8Unorm => Self::Etc2Rgb8Unorm,
            wgpu::TextureFormat::Etc2Rgb8UnormSrgb => Self::Etc2Rgb8UnormSrgb,
            wgpu::TextureFormat::Etc2Rgb8A1Unorm => Self::Etc2Rgb8A1Unorm,
            wgpu::TextureFormat::Etc2Rgb8A1UnormSrgb => Self::Etc2Rgb8A1UnormSrgb,
            wgpu::TextureFormat::Etc2Rgba8Unorm => Self::Etc2Rgba8Unorm,
            wgpu::TextureFormat::Etc2Rgba8UnormSrgb => Self::Etc2Rgba8UnormSrgb,
            wgpu::TextureFormat::EacR11Unorm => Self::EacR11Unorm,
            wgpu::TextureFormat::EacR11Snorm => Self::EacR11Snorm,
            wgpu::TextureFormat::EacRg11Unorm => Self::EacRg11Unorm,
            wgpu::TextureFormat::EacRg11Snorm => Self::EacRg11Snorm,
            wgpu::TextureFormat::Astc { block, channel } => Self::Astc { block: block.into(), channel: channel.into() },
        }
    }
}