Files
wgpu-renderer/Source/Render/Pipeline/TextureFormat.rs
2021-11-23 20:09:05 -03:00

470 lines
21 KiB
Rust

use serde::{Deserialize, Serialize};
#[repr(C)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, Serialize, Deserialize)]
pub enum TextureFormat {
// Normal 8 bit formats
/// Red channel only. 8 bit integer per channel. [0, 255] converted to/from float [0, 1] in shader.
R8UNorm,
/// Red channel only. 8 bit integer per channel. [-127, 127] converted to/from float [-1, 1] in shader.
R8Norm,
/// Red channel only. 8 bit integer per channel. Unsigned in shader.
R8UInt,
/// Red channel only. 8 bit integer per channel. Signed in shader.
R8Int,
// Normal 16 bit formats
/// Red channel only. 16 bit integer per channel. Unsigned in shader.
R16UInt,
/// Red channel only. 16 bit integer per channel. Signed in shader.
R16Int,
/// Red channel only. 16 bit float per channel. Float in shader.
R16Float,
/// Red and green channels. 8 bit integer per channel. [0, 255] converted to/from float [0, 1] in shader.
Rg8UNorm,
/// Red and green channels. 8 bit integer per channel. [-127, 127] converted to/from float [-1, 1] in shader.
Rg8Norm,
/// Red and green channels. 8 bit integer per channel. Unsigned in shader.
Rg8UInt,
/// Red and green channels. 8 bit integer per channel. Signed in shader.
Rg8Int,
// Normal 32 bit formats
/// Red channel only. 32 bit integer per channel. Unsigned in shader.
R32UInt,
/// Red channel only. 32 bit integer per channel. Signed in shader.
R32Int,
/// Red channel only. 32 bit float per channel. Float in shader.
R32Float,
/// Red and green channels. 16 bit integer per channel. Unsigned in shader.
Rg16UInt,
/// Red and green channels. 16 bit integer per channel. Signed in shader.
Rg16Int,
/// Red and green channels. 16 bit float per channel. Float in shader.
Rg16Float,
/// Red, green, blue, and alpha channels. 8 bit integer per channel. [0, 255] converted to/from float [0, 1] in shader.
Rgba8UNorm,
/// Red, green, blue, and alpha channels. 8 bit integer per channel. Srgb-color [0, 255] converted to/from linear-color float [0, 1] in shader.
Rgba8UNormSrgb,
/// Red, green, blue, and alpha channels. 8 bit integer per channel. [-127, 127] converted to/from float [-1, 1] in shader.
Rgba8Norm,
/// Red, green, blue, and alpha channels. 8 bit integer per channel. Unsigned in shader.
Rgba8UInt,
/// Red, green, blue, and alpha channels. 8 bit integer per channel. Signed in shader.
Rgba8Int,
/// Blue, green, red, and alpha channels. 8 bit integer per channel. [0, 255] converted to/from float [0, 1] in shader.
Bgra8UNorm,
/// Blue, green, red, and alpha channels. 8 bit integer per channel. Srgb-color [0, 255] converted to/from linear-color float [0, 1] in shader.
Bgra8UNormSrgb,
// Packed 32 bit formats
/// Red, green, blue, and alpha channels. 10 bit integer for RGB channels, 2 bit integer for alpha channel. [0, 1023] ([0, 3] for alpha) converted to/from float [0, 1] in shader.
Rgb10a2UNorm,
/// Red, green, and blue channels. 11 bit float with no sign bit for RG channels. 10 bit float with no sign bit for blue channel. Float in shader.
Rg11b10Float,
// Normal 64 bit formats
/// Red and green channels. 32 bit integer per channel. Unsigned in shader.
Rg32UInt,
/// Red and green channels. 32 bit integer per channel. Signed in shader.
Rg32Int,
/// Red and green channels. 32 bit float per channel. Float in shader.
Rg32Float,
/// Red, green, blue, and alpha channels. 16 bit integer per channel. Unsigned in shader.
Rgba16UInt,
/// Red, green, blue, and alpha channels. 16 bit integer per channel. Signed in shader.
Rgba16Int,
/// Red, green, blue, and alpha channels. 16 bit float per channel. Float in shader.
Rgba16Float,
// Normal 128 bit formats
/// Red, green, blue, and alpha channels. 32 bit integer per channel. Unsigned in shader.
Rgba32UInt,
/// Red, green, blue, and alpha channels. 32 bit integer per channel. Signed in shader.
Rgba32Int,
/// Red, green, blue, and alpha channels. 32 bit float per channel. Float in shader.
Rgba32Float,
// Depth and stencil formats
/// Special depth format with 32 bit floating point depth.
Depth32Float,
/// Special depth format with at least 24 bit integer depth.
Depth24Plus,
/// Special depth/stencil format with at least 24 bit integer depth and 8 bits integer stencil.
Depth24PlusStencil8,
// Packed uncompressed texture formats
/// Packed unsigned float with 9 bits mantisa for each RGB component, then a common 5 bits exponent
Rgb9e5Ufloat,
// Compressed textures usable with `TEXTURE_COMPRESSION_BC` feature.
/// 4x4 block compressed texture. 8 bytes per block (4 bit/px). 4 color + alpha pallet. 5 bit R + 6 bit G + 5 bit B + 1 bit alpha.
/// [0, 63] ([0, 1] for alpha) converted to/from float [0, 1] in shader.
///
/// Also known as DXT1.
///
/// [`Features::TEXTURE_COMPRESSION_BC`] must be enabled to use this texture format.
Bc1RgbaUNorm,
/// 4x4 block compressed texture. 8 bytes per block (4 bit/px). 4 color + alpha pallet. 5 bit R + 6 bit G + 5 bit B + 1 bit alpha.
/// Srgb-color [0, 63] ([0, 1] for alpha) converted to/from linear-color float [0, 1] in shader.
///
/// Also known as DXT1.
///
/// [`Features::TEXTURE_COMPRESSION_BC`] must be enabled to use this texture format.
Bc1RgbaUNormSrgb,
/// 4x4 block compressed texture. 16 bytes per block (8 bit/px). 4 color pallet. 5 bit R + 6 bit G + 5 bit B + 4 bit alpha.
/// [0, 63] ([0, 15] for alpha) converted to/from float [0, 1] in shader.
///
/// Also known as DXT3.
///
/// [`Features::TEXTURE_COMPRESSION_BC`] must be enabled to use this texture format.
Bc2RgbaUNorm,
/// 4x4 block compressed texture. 16 bytes per block (8 bit/px). 4 color pallet. 5 bit R + 6 bit G + 5 bit B + 4 bit alpha.
/// Srgb-color [0, 63] ([0, 255] for alpha) converted to/from linear-color float [0, 1] in shader.
///
/// Also known as DXT3.
///
/// [`Features::TEXTURE_COMPRESSION_BC`] must be enabled to use this texture format.
Bc2RgbaUNormSrgb,
/// 4x4 block compressed texture. 16 bytes per block (8 bit/px). 4 color pallet + 8 alpha pallet. 5 bit R + 6 bit G + 5 bit B + 8 bit alpha.
/// [0, 63] ([0, 255] for alpha) converted to/from float [0, 1] in shader.
///
/// Also known as DXT5.
///
/// [`Features::TEXTURE_COMPRESSION_BC`] must be enabled to use this texture format.
Bc3RgbaUNorm,
/// 4x4 block compressed texture. 16 bytes per block (8 bit/px). 4 color pallet + 8 alpha pallet. 5 bit R + 6 bit G + 5 bit B + 8 bit alpha.
/// Srgb-color [0, 63] ([0, 255] for alpha) converted to/from linear-color float [0, 1] in shader.
///
/// Also known as DXT5.
///
/// [`Features::TEXTURE_COMPRESSION_BC`] must be enabled to use this texture format.
Bc3RgbaUNormSrgb,
/// 4x4 block compressed texture. 8 bytes per block (4 bit/px). 8 color pallet. 8 bit R.
/// [0, 255] converted to/from float [0, 1] in shader.
///
/// Also known as RGTC1.
///
/// [`Features::TEXTURE_COMPRESSION_BC`] must be enabled to use this texture format.
Bc4RUNorm,
/// 4x4 block compressed texture. 8 bytes per block (4 bit/px). 8 color pallet. 8 bit R.
/// [-127, 127] converted to/from float [-1, 1] in shader.
///
/// Also known as RGTC1.
///
/// [`Features::TEXTURE_COMPRESSION_BC`] must be enabled to use this texture format.
Bc4RNorm,
/// 4x4 block compressed texture. 16 bytes per block (8 bit/px). 8 color red pallet + 8 color green pallet. 8 bit RG.
/// [0, 255] converted to/from float [0, 1] in shader.
///
/// Also known as RGTC2.
///
/// [`Features::TEXTURE_COMPRESSION_BC`] must be enabled to use this texture format.
Bc5RgUNorm,
/// 4x4 block compressed texture. 16 bytes per block (8 bit/px). 8 color red pallet + 8 color green pallet. 8 bit RG.
/// [-127, 127] converted to/from float [-1, 1] in shader.
///
/// Also known as RGTC2.
///
/// [`Features::TEXTURE_COMPRESSION_BC`] must be enabled to use this texture format.
Bc5RgNorm,
/// 4x4 block compressed texture. 16 bytes per block (8 bit/px). Variable sized pallet. 16 bit unsigned float RGB. Float in shader.
///
/// Also known as BPTC (float).
///
/// [`Features::TEXTURE_COMPRESSION_BC`] must be enabled to use this texture format.
Bc6hRgbUfloat,
/// 4x4 block compressed texture. 16 bytes per block (8 bit/px). Variable sized pallet. 16 bit signed float RGB. Float in shader.
///
/// Also known as BPTC (float).
///
/// [`Features::TEXTURE_COMPRESSION_BC`] must be enabled to use this texture format.
Bc6hRgbSfloat,
/// 4x4 block compressed texture. 16 bytes per block (8 bit/px). Variable sized pallet. 8 bit integer RGBA.
/// [0, 255] converted to/from float [0, 1] in shader.
///
/// Also known as BPTC (unorm).
///
/// [`Features::TEXTURE_COMPRESSION_BC`] must be enabled to use this texture format.
Bc7RgbaUNorm,
/// 4x4 block compressed texture. 16 bytes per block (8 bit/px). Variable sized pallet. 8 bit integer RGBA.
/// Srgb-color [0, 255] converted to/from linear-color float [0, 1] in shader.
///
/// Also known as BPTC (unorm).
///
/// [`Features::TEXTURE_COMPRESSION_BC`] must be enabled to use this texture format.
Bc7RgbaUNormSrgb,
/// 4x4 block compressed texture. 8 bytes per block (4 bit/px). Complex pallet. 8 bit integer RGB.
/// [0, 255] converted to/from float [0, 1] in shader.
///
/// [`Features::TEXTURE_COMPRESSION_ETC2`] must be enabled to use this texture format.
Etc2RgbUNorm,
/// 4x4 block compressed texture. 8 bytes per block (4 bit/px). Complex pallet. 8 bit integer RGB.
/// Srgb-color [0, 255] converted to/from linear-color float [0, 1] in shader.
///
/// [`Features::TEXTURE_COMPRESSION_ETC2`] must be enabled to use this texture format.
Etc2RgbUNormSrgb,
/// 4x4 block compressed texture. 8 bytes per block (4 bit/px). Complex pallet. 8 bit integer RGB + 1 bit alpha.
/// [0, 255] ([0, 1] for alpha) converted to/from float [0, 1] in shader.
///
/// [`Features::TEXTURE_COMPRESSION_ETC2`] must be enabled to use this texture format.
Etc2RgbA1UNorm,
/// 4x4 block compressed texture. 8 bytes per block (4 bit/px). Complex pallet. 8 bit integer RGB + 1 bit alpha.
/// Srgb-color [0, 255] ([0, 1] for alpha) converted to/from linear-color float [0, 1] in shader.
///
/// [`Features::TEXTURE_COMPRESSION_ETC2`] must be enabled to use this texture format.
Etc2RgbA1UNormSrgb,
/// 4x4 block compressed texture. 16 bytes per block (8 bit/px). Complex pallet. 8 bit integer RGB + 8 bit alpha.
/// [0, 255] converted to/from float [0, 1] in shader.
///
/// [`Features::TEXTURE_COMPRESSION_ETC2`] must be enabled to use this texture format.
//Etc2RgbA8UNorm,
/// 4x4 block compressed texture. 16 bytes per block (8 bit/px). Complex pallet. 8 bit integer RGB + 8 bit alpha.
/// Srgb-color [0, 255] converted to/from linear-color float [0, 1] in shader.
///
/// [`Features::TEXTURE_COMPRESSION_ETC2`] must be enabled to use this texture format.
//Etc2RgbA8UNormSrgb,
/// 4x4 block compressed texture. 8 bytes per block (4 bit/px). Complex pallet. 8 bit integer R.
/// [0, 255] converted to/from float [0, 1] in shader.
///
/// [`Features::TEXTURE_COMPRESSION_ETC2`] must be enabled to use this texture format.
EacRUNorm,
/// 4x4 block compressed texture. 8 bytes per block (4 bit/px). Complex pallet. 8 bit integer R.
/// [-127, 127] converted to/from float [-1, 1] in shader.
///
/// [`Features::TEXTURE_COMPRESSION_ETC2`] must be enabled to use this texture format.
EacRNorm,
/// 4x4 block compressed texture. 16 bytes per block (8 bit/px). Complex pallet. 8 bit integer R + 8 bit integer G.
/// [0, 255] converted to/from float [0, 1] in shader.
///
/// [`Features::TEXTURE_COMPRESSION_ETC2`] must be enabled to use this texture format.
EacRgUNorm,
/// 4x4 block compressed texture. 16 bytes per block (8 bit/px). Complex pallet. 8 bit integer R + 8 bit integer G.
/// [-127, 127] converted to/from float [-1, 1] in shader.
///
/// [`Features::TEXTURE_COMPRESSION_ETC2`] must be enabled to use this texture format.
EacRgNorm,
/// 4x4 block compressed texture. 16 bytes per block (8 bit/px). Complex pallet. 8 bit integer RGBA.
/// [0, 255] converted to/from float [0, 1] in shader.
///
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
Astc4x4RgbaUNorm,
/// 4x4 block compressed texture. 16 bytes per block (8 bit/px). Complex pallet. 8 bit integer RGBA.
/// Srgb-color [0, 255] converted to/from linear-color float [0, 1] in shader.
///
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
Astc4x4RgbaUNormSrgb,
/// 5x4 block compressed texture. 16 bytes per block (6.4 bit/px). Complex pallet. 8 bit integer RGBA.
/// [0, 255] converted to/from float [0, 1] in shader.
///
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
Astc5x4RgbaUNorm,
/// 5x4 block compressed texture. 16 bytes per block (6.4 bit/px). Complex pallet. 8 bit integer RGBA.
/// Srgb-color [0, 255] converted to/from linear-color float [0, 1] in shader.
///
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
Astc5x4RgbaUNormSrgb,
/// 5x5 block compressed texture. 16 bytes per block (5.12 bit/px). Complex pallet. 8 bit integer RGBA.
/// [0, 255] converted to/from float [0, 1] in shader.
///
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
Astc5x5RgbaUNorm,
/// 5x5 block compressed texture. 16 bytes per block (5.12 bit/px). Complex pallet. 8 bit integer RGBA.
/// Srgb-color [0, 255] converted to/from linear-color float [0, 1] in shader.
///
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
Astc5x5RgbaUNormSrgb,
/// 6x5 block compressed texture. 16 bytes per block (4.27 bit/px). Complex pallet. 8 bit integer RGBA.
/// [0, 255] converted to/from float [0, 1] in shader.
///
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
Astc6x5RgbaUNorm,
/// 6x5 block compressed texture. 16 bytes per block (4.27 bit/px). Complex pallet. 8 bit integer RGBA.
/// Srgb-color [0, 255] converted to/from linear-color float [0, 1] in shader.
///
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
Astc6x5RgbaUNormSrgb,
/// 6x6 block compressed texture. 16 bytes per block (3.56 bit/px). Complex pallet. 8 bit integer RGBA.
/// [0, 255] converted to/from float [0, 1] in shader.
///
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
Astc6x6RgbaUNorm,
/// 6x6 block compressed texture. 16 bytes per block (3.56 bit/px). Complex pallet. 8 bit integer RGBA.
/// Srgb-color [0, 255] converted to/from linear-color float [0, 1] in shader.
///
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
Astc6x6RgbaUNormSrgb,
/// 8x5 block compressed texture. 16 bytes per block (3.2 bit/px). Complex pallet. 8 bit integer RGBA.
/// [0, 255] converted to/from float [0, 1] in shader.
///
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
Astc8x5RgbaUNorm,
/// 8x5 block compressed texture. 16 bytes per block (3.2 bit/px). Complex pallet. 8 bit integer RGBA.
/// Srgb-color [0, 255] converted to/from linear-color float [0, 1] in shader.
///
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
Astc8x5RgbaUNormSrgb,
/// 8x6 block compressed texture. 16 bytes per block (2.67 bit/px). Complex pallet. 8 bit integer RGBA.
/// [0, 255] converted to/from float [0, 1] in shader.
///
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
Astc8x6RgbaUNorm,
/// 8x6 block compressed texture. 16 bytes per block (2.67 bit/px). Complex pallet. 8 bit integer RGBA.
/// Srgb-color [0, 255] converted to/from linear-color float [0, 1] in shader.
///
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
Astc8x6RgbaUNormSrgb,
/// 10x5 block compressed texture. 16 bytes per block (2.56 bit/px). Complex pallet. 8 bit integer RGBA.
/// [0, 255] converted to/from float [0, 1] in shader.
///
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
Astc10x5RgbaUNorm,
/// 10x5 block compressed texture. 16 bytes per block (2.56 bit/px). Complex pallet. 8 bit integer RGBA.
/// Srgb-color [0, 255] converted to/from linear-color float [0, 1] in shader.
///
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
Astc10x5RgbaUNormSrgb,
/// 10x6 block compressed texture. 16 bytes per block (2.13 bit/px). Complex pallet. 8 bit integer RGBA.
/// [0, 255] converted to/from float [0, 1] in shader.
///
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
Astc10x6RgbaUNorm,
/// 10x6 block compressed texture. 16 bytes per block (2.13 bit/px). Complex pallet. 8 bit integer RGBA.
/// Srgb-color [0, 255] converted to/from linear-color float [0, 1] in shader.
///
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
Astc10x6RgbaUNormSrgb,
/// 8x8 block compressed texture. 16 bytes per block (2 bit/px). Complex pallet. 8 bit integer RGBA.
/// [0, 255] converted to/from float [0, 1] in shader.
///
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
Astc8x8RgbaUNorm,
/// 8x8 block compressed texture. 16 bytes per block (2 bit/px). Complex pallet. 8 bit integer RGBA.
/// Srgb-color [0, 255] converted to/from linear-color float [0, 1] in shader.
///
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
Astc8x8RgbaUNormSrgb,
/// 10x8 block compressed texture. 16 bytes per block (1.6 bit/px). Complex pallet. 8 bit integer RGBA.
/// [0, 255] converted to/from float [0, 1] in shader.
///
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
Astc10x8RgbaUNorm,
/// 10x8 block compressed texture. 16 bytes per block (1.6 bit/px). Complex pallet. 8 bit integer RGBA.
/// Srgb-color [0, 255] converted to/from linear-color float [0, 1] in shader.
///
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
Astc10x8RgbaUNormSrgb,
/// 10x10 block compressed texture. 16 bytes per block (1.28 bit/px). Complex pallet. 8 bit integer RGBA.
/// [0, 255] converted to/from float [0, 1] in shader.
///
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
Astc10x10RgbaUNorm,
/// 10x10 block compressed texture. 16 bytes per block (1.28 bit/px). Complex pallet. 8 bit integer RGBA.
/// Srgb-color [0, 255] converted to/from linear-color float [0, 1] in shader.
///
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
Astc10x10RgbaUNormSrgb,
/// 12x10 block compressed texture. 16 bytes per block (1.07 bit/px). Complex pallet. 8 bit integer RGBA.
/// [0, 255] converted to/from float [0, 1] in shader.
///
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
Astc12x10RgbaUNorm,
/// 12x10 block compressed texture. 16 bytes per block (1.07 bit/px). Complex pallet. 8 bit integer RGBA.
/// Srgb-color [0, 255] converted to/from linear-color float [0, 1] in shader.
///
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
Astc12x10RgbaUNormSrgb,
/// 12x12 block compressed texture. 16 bytes per block (0.89 bit/px). Complex pallet. 8 bit integer RGBA.
/// [0, 255] converted to/from float [0, 1] in shader.
///
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
Astc12x12RgbaUNorm,
/// 12x12 block compressed texture. 16 bytes per block (0.89 bit/px). Complex pallet. 8 bit integer RGBA.
/// Srgb-color [0, 255] converted to/from linear-color float [0, 1] in shader.
///
/// [`Features::TEXTURE_COMPRESSION_ASTC_LDR`] must be enabled to use this texture format.
Astc12x12RgbaUNormSrgb,
}