mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-22 14:55:05 +00:00
Make texture format info into an in-code table
This commit is contained in:
parent
129c32ffc3
commit
6979c7fe4c
@ -2012,6 +2012,7 @@ impl TextureFormat {
|
||||
let all_flags = TextureUsages::all();
|
||||
|
||||
// See <https://gpuweb.github.io/gpuweb/#texture-format-caps> for reference
|
||||
#[rustfmt::skip] // lets make a nice table
|
||||
let (
|
||||
required_features,
|
||||
sample_type,
|
||||
@ -2023,159 +2024,95 @@ impl TextureFormat {
|
||||
components,
|
||||
) = match self {
|
||||
// Normal 8 bit textures
|
||||
Self::R8Unorm => (
|
||||
native,
|
||||
float,
|
||||
linear,
|
||||
msaa_resolve,
|
||||
(1, 1),
|
||||
1,
|
||||
attachment,
|
||||
1,
|
||||
),
|
||||
Self::R8Snorm => (native, float, linear, msaa, (1, 1), 1, basic, 1),
|
||||
Self::R8Uint => (native, uint, linear, msaa, (1, 1), 1, attachment, 1),
|
||||
Self::R8Sint => (native, sint, linear, msaa, (1, 1), 1, attachment, 1),
|
||||
Self::R8Unorm => ( native, float, linear, msaa_resolve, (1, 1), 1, attachment, 1),
|
||||
Self::R8Snorm => ( native, float, linear, msaa, (1, 1), 1, basic, 1),
|
||||
Self::R8Uint => ( native, uint, linear, msaa, (1, 1), 1, attachment, 1),
|
||||
Self::R8Sint => ( native, sint, linear, msaa, (1, 1), 1, attachment, 1),
|
||||
|
||||
// Normal 16 bit textures
|
||||
Self::R16Uint => (native, uint, linear, msaa, (1, 1), 2, attachment, 1),
|
||||
Self::R16Sint => (native, sint, linear, msaa, (1, 1), 2, attachment, 1),
|
||||
Self::R16Float => (
|
||||
native,
|
||||
float,
|
||||
linear,
|
||||
msaa_resolve,
|
||||
(1, 1),
|
||||
2,
|
||||
attachment,
|
||||
1,
|
||||
),
|
||||
Self::Rg8Unorm => (
|
||||
native,
|
||||
float,
|
||||
linear,
|
||||
msaa_resolve,
|
||||
(1, 1),
|
||||
2,
|
||||
attachment,
|
||||
2,
|
||||
),
|
||||
Self::Rg8Snorm => (native, float, linear, msaa, (1, 1), 2, attachment, 2),
|
||||
Self::Rg8Uint => (native, uint, linear, msaa, (1, 1), 2, attachment, 2),
|
||||
Self::Rg8Sint => (native, sint, linear, msaa, (1, 1), 2, basic, 2),
|
||||
Self::R16Uint => ( native, uint, linear, msaa, (1, 1), 2, attachment, 1),
|
||||
Self::R16Sint => ( native, sint, linear, msaa, (1, 1), 2, attachment, 1),
|
||||
Self::R16Float => ( native, float, linear, msaa_resolve, (1, 1), 2, attachment, 1),
|
||||
Self::Rg8Unorm => ( native, float, linear, msaa_resolve, (1, 1), 2, attachment, 2),
|
||||
Self::Rg8Snorm => ( native, float, linear, msaa, (1, 1), 2, attachment, 2),
|
||||
Self::Rg8Uint => ( native, uint, linear, msaa, (1, 1), 2, attachment, 2),
|
||||
Self::Rg8Sint => ( native, sint, linear, msaa, (1, 1), 2, basic, 2),
|
||||
|
||||
// Normal 32 bit textures
|
||||
Self::R32Uint => (native, uint, linear, noaa, (1, 1), 4, all_flags, 1),
|
||||
Self::R32Sint => (native, sint, linear, noaa, (1, 1), 4, all_flags, 1),
|
||||
Self::R32Float => (native, nearest, linear, msaa, (1, 1), 4, all_flags, 1),
|
||||
Self::Rg16Uint => (native, uint, linear, msaa, (1, 1), 4, attachment, 2),
|
||||
Self::Rg16Sint => (native, sint, linear, msaa, (1, 1), 4, attachment, 2),
|
||||
Self::Rg16Float => (
|
||||
native,
|
||||
float,
|
||||
linear,
|
||||
msaa_resolve,
|
||||
(1, 1),
|
||||
4,
|
||||
attachment,
|
||||
2,
|
||||
),
|
||||
Self::Rgba8Unorm => (native, float, linear, msaa_resolve, (1, 1), 4, all_flags, 4),
|
||||
Self::Rgba8UnormSrgb => (
|
||||
native,
|
||||
float,
|
||||
corrected,
|
||||
msaa_resolve,
|
||||
(1, 1),
|
||||
4,
|
||||
attachment,
|
||||
4,
|
||||
),
|
||||
Self::Rgba8Snorm => (native, float, linear, msaa, (1, 1), 4, storage, 4),
|
||||
Self::Rgba8Uint => (native, uint, linear, msaa, (1, 1), 4, all_flags, 4),
|
||||
Self::Rgba8Sint => (native, sint, linear, msaa, (1, 1), 4, all_flags, 4),
|
||||
Self::Bgra8Unorm => (
|
||||
native,
|
||||
float,
|
||||
linear,
|
||||
msaa_resolve,
|
||||
(1, 1),
|
||||
4,
|
||||
attachment,
|
||||
4,
|
||||
),
|
||||
Self::Bgra8UnormSrgb => (
|
||||
native,
|
||||
float,
|
||||
corrected,
|
||||
msaa_resolve,
|
||||
(1, 1),
|
||||
4,
|
||||
attachment,
|
||||
4,
|
||||
),
|
||||
Self::R32Uint => ( native, uint, linear, noaa, (1, 1), 4, all_flags, 1),
|
||||
Self::R32Sint => ( native, sint, linear, noaa, (1, 1), 4, all_flags, 1),
|
||||
Self::R32Float => ( native, nearest, linear, msaa, (1, 1), 4, all_flags, 1),
|
||||
Self::Rg16Uint => ( native, uint, linear, msaa, (1, 1), 4, attachment, 2),
|
||||
Self::Rg16Sint => ( native, sint, linear, msaa, (1, 1), 4, attachment, 2),
|
||||
Self::Rg16Float => ( native, float, linear, msaa_resolve, (1, 1), 4, attachment, 2),
|
||||
Self::Rgba8Unorm => ( native, float, linear, msaa_resolve, (1, 1), 4, all_flags, 4),
|
||||
Self::Rgba8UnormSrgb => ( native, float, corrected, msaa_resolve, (1, 1), 4, attachment, 4),
|
||||
Self::Rgba8Snorm => ( native, float, linear, msaa, (1, 1), 4, storage, 4),
|
||||
Self::Rgba8Uint => ( native, uint, linear, msaa, (1, 1), 4, all_flags, 4),
|
||||
Self::Rgba8Sint => ( native, sint, linear, msaa, (1, 1), 4, all_flags, 4),
|
||||
Self::Bgra8Unorm => ( native, float, linear, msaa_resolve, (1, 1), 4, attachment, 4),
|
||||
Self::Bgra8UnormSrgb => ( native, float, corrected, msaa_resolve, (1, 1), 4, attachment, 4),
|
||||
|
||||
// Packed 32 bit textures
|
||||
Self::Rgb10a2Unorm => (
|
||||
native,
|
||||
float,
|
||||
linear,
|
||||
msaa_resolve,
|
||||
(1, 1),
|
||||
4,
|
||||
attachment,
|
||||
4,
|
||||
),
|
||||
Self::Rg11b10Float => (native, float, linear, msaa, (1, 1), 4, basic, 3),
|
||||
Self::Rgb10a2Unorm => ( native, float, linear, msaa_resolve, (1, 1), 4, attachment, 4),
|
||||
Self::Rg11b10Float => ( native, float, linear, msaa, (1, 1), 4, basic, 3),
|
||||
|
||||
// Packed 32 bit textures
|
||||
Self::Rg32Uint => (native, uint, linear, noaa, (1, 1), 8, all_flags, 2),
|
||||
Self::Rg32Sint => (native, sint, linear, noaa, (1, 1), 8, all_flags, 2),
|
||||
Self::Rg32Float => (native, nearest, linear, noaa, (1, 1), 8, all_flags, 2),
|
||||
Self::Rgba16Uint => (native, uint, linear, msaa, (1, 1), 8, all_flags, 4),
|
||||
Self::Rgba16Sint => (native, sint, linear, msaa, (1, 1), 8, all_flags, 4),
|
||||
Self::Rgba16Float => (native, float, linear, msaa_resolve, (1, 1), 8, all_flags, 4),
|
||||
// Packed 32 bit textures
|
||||
Self::Rg32Uint => ( native, uint, linear, noaa, (1, 1), 8, all_flags, 2),
|
||||
Self::Rg32Sint => ( native, sint, linear, noaa, (1, 1), 8, all_flags, 2),
|
||||
Self::Rg32Float => ( native, nearest, linear, noaa, (1, 1), 8, all_flags, 2),
|
||||
Self::Rgba16Uint => ( native, uint, linear, msaa, (1, 1), 8, all_flags, 4),
|
||||
Self::Rgba16Sint => ( native, sint, linear, msaa, (1, 1), 8, all_flags, 4),
|
||||
Self::Rgba16Float => ( native, float, linear, msaa_resolve, (1, 1), 8, all_flags, 4),
|
||||
|
||||
// Packed 32 bit textures
|
||||
Self::Rgba32Uint => (native, uint, linear, noaa, (1, 1), 16, all_flags, 4),
|
||||
Self::Rgba32Sint => (native, sint, linear, noaa, (1, 1), 16, all_flags, 4),
|
||||
Self::Rgba32Float => (native, nearest, linear, noaa, (1, 1), 16, all_flags, 4),
|
||||
// Packed 32 bit textures
|
||||
Self::Rgba32Uint => ( native, uint, linear, noaa, (1, 1), 16, all_flags, 4),
|
||||
Self::Rgba32Sint => ( native, sint, linear, noaa, (1, 1), 16, all_flags, 4),
|
||||
Self::Rgba32Float => ( native, nearest, linear, noaa, (1, 1), 16, all_flags, 4),
|
||||
|
||||
// Depth-stencil textures
|
||||
Self::Depth32Float => (native, depth, linear, msaa, (1, 1), 4, attachment, 1),
|
||||
Self::Depth24Plus => (native, depth, linear, msaa, (1, 1), 4, attachment, 1),
|
||||
Self::Depth24PlusStencil8 => (native, depth, linear, msaa, (1, 1), 4, attachment, 2),
|
||||
Self::Depth32Float => ( native, depth, linear, msaa, (1, 1), 4, attachment, 1),
|
||||
Self::Depth24Plus => ( native, depth, linear, msaa, (1, 1), 4, attachment, 1),
|
||||
Self::Depth24PlusStencil8 => ( native, depth, linear, msaa, (1, 1), 4, attachment, 2),
|
||||
|
||||
// Packed uncompressed
|
||||
Self::Rgb9e5Ufloat => (native, float, linear, noaa, (1, 1), 4, basic, 3),
|
||||
// Packed uncompressed
|
||||
Self::Rgb9e5Ufloat => ( native, float, linear, noaa, (1, 1), 4, basic, 3),
|
||||
|
||||
// Optional normalized 16-bit-per-channel formats
|
||||
Self::R16Unorm => (norm16bit, float, linear, msaa, (1, 1), 2, storage, 1),
|
||||
Self::R16Snorm => (norm16bit, float, linear, msaa, (1, 1), 2, storage, 1),
|
||||
Self::Rg16Unorm => (norm16bit, float, linear, msaa, (1, 1), 4, storage, 2),
|
||||
Self::Rg16Snorm => (norm16bit, float, linear, msaa, (1, 1), 4, storage, 2),
|
||||
Self::Rgba16Unorm => (norm16bit, float, linear, msaa, (1, 1), 8, storage, 4),
|
||||
Self::Rgba16Snorm => (norm16bit, float, linear, msaa, (1, 1), 8, storage, 4),
|
||||
|
||||
// BCn compressed textures
|
||||
Self::Bc1RgbaUnorm => (bc, float, linear, noaa, (4, 4), 8, basic, 4),
|
||||
Self::Bc1RgbaUnormSrgb => (bc, float, corrected, noaa, (4, 4), 8, basic, 4),
|
||||
Self::Bc2RgbaUnorm => (bc, float, linear, noaa, (4, 4), 16, basic, 4),
|
||||
Self::Bc2RgbaUnormSrgb => (bc, float, corrected, noaa, (4, 4), 16, basic, 4),
|
||||
Self::Bc3RgbaUnorm => (bc, float, linear, noaa, (4, 4), 16, basic, 4),
|
||||
Self::Bc3RgbaUnormSrgb => (bc, float, corrected, noaa, (4, 4), 16, basic, 4),
|
||||
Self::Bc4RUnorm => (bc, float, linear, noaa, (4, 4), 8, basic, 1),
|
||||
Self::Bc4RSnorm => (bc, float, linear, noaa, (4, 4), 8, basic, 1),
|
||||
Self::Bc5RgUnorm => (bc, float, linear, noaa, (4, 4), 16, basic, 2),
|
||||
Self::Bc5RgSnorm => (bc, float, linear, noaa, (4, 4), 16, basic, 2),
|
||||
Self::Bc6hRgbUfloat => (bc, float, linear, noaa, (4, 4), 16, basic, 3),
|
||||
Self::Bc6hRgbSfloat => (bc, float, linear, noaa, (4, 4), 16, basic, 3),
|
||||
Self::Bc7RgbaUnorm => (bc, float, linear, noaa, (4, 4), 16, basic, 4),
|
||||
Self::Bc7RgbaUnormSrgb => (bc, float, corrected, noaa, (4, 4), 16, basic, 4),
|
||||
Self::Bc1RgbaUnorm => ( bc, float, linear, noaa, (4, 4), 8, basic, 4),
|
||||
Self::Bc1RgbaUnormSrgb => ( bc, float, corrected, noaa, (4, 4), 8, basic, 4),
|
||||
Self::Bc2RgbaUnorm => ( bc, float, linear, noaa, (4, 4), 16, basic, 4),
|
||||
Self::Bc2RgbaUnormSrgb => ( bc, float, corrected, noaa, (4, 4), 16, basic, 4),
|
||||
Self::Bc3RgbaUnorm => ( bc, float, linear, noaa, (4, 4), 16, basic, 4),
|
||||
Self::Bc3RgbaUnormSrgb => ( bc, float, corrected, noaa, (4, 4), 16, basic, 4),
|
||||
Self::Bc4RUnorm => ( bc, float, linear, noaa, (4, 4), 8, basic, 1),
|
||||
Self::Bc4RSnorm => ( bc, float, linear, noaa, (4, 4), 8, basic, 1),
|
||||
Self::Bc5RgUnorm => ( bc, float, linear, noaa, (4, 4), 16, basic, 2),
|
||||
Self::Bc5RgSnorm => ( bc, float, linear, noaa, (4, 4), 16, basic, 2),
|
||||
Self::Bc6hRgbUfloat => ( bc, float, linear, noaa, (4, 4), 16, basic, 3),
|
||||
Self::Bc6hRgbSfloat => ( bc, float, linear, noaa, (4, 4), 16, basic, 3),
|
||||
Self::Bc7RgbaUnorm => ( bc, float, linear, noaa, (4, 4), 16, basic, 4),
|
||||
Self::Bc7RgbaUnormSrgb => ( bc, float, corrected, noaa, (4, 4), 16, basic, 4),
|
||||
|
||||
// ETC compressed textures
|
||||
Self::Etc2Rgb8Unorm => (etc2, float, linear, noaa, (4, 4), 8, basic, 3),
|
||||
Self::Etc2Rgb8UnormSrgb => (etc2, float, corrected, noaa, (4, 4), 8, basic, 3),
|
||||
Self::Etc2Rgb8A1Unorm => (etc2, float, linear, noaa, (4, 4), 8, basic, 4),
|
||||
Self::Etc2Rgb8A1UnormSrgb => (etc2, float, corrected, noaa, (4, 4), 8, basic, 4),
|
||||
Self::Etc2Rgba8Unorm => (etc2, float, linear, noaa, (4, 4), 16, basic, 4),
|
||||
Self::Etc2Rgba8UnormSrgb => (etc2, float, corrected, noaa, (4, 4), 16, basic, 4),
|
||||
Self::EacR11Unorm => (etc2, float, linear, noaa, (4, 4), 8, basic, 1),
|
||||
Self::EacR11Snorm => (etc2, float, linear, noaa, (4, 4), 8, basic, 1),
|
||||
Self::EacRg11Unorm => (etc2, float, linear, noaa, (4, 4), 16, basic, 2),
|
||||
Self::EacRg11Snorm => (etc2, float, linear, noaa, (4, 4), 16, basic, 2),
|
||||
Self::Etc2Rgb8Unorm => ( etc2, float, linear, noaa, (4, 4), 8, basic, 3),
|
||||
Self::Etc2Rgb8UnormSrgb => ( etc2, float, corrected, noaa, (4, 4), 8, basic, 3),
|
||||
Self::Etc2Rgb8A1Unorm => ( etc2, float, linear, noaa, (4, 4), 8, basic, 4),
|
||||
Self::Etc2Rgb8A1UnormSrgb => ( etc2, float, corrected, noaa, (4, 4), 8, basic, 4),
|
||||
Self::Etc2Rgba8Unorm => ( etc2, float, linear, noaa, (4, 4), 16, basic, 4),
|
||||
Self::Etc2Rgba8UnormSrgb => ( etc2, float, corrected, noaa, (4, 4), 16, basic, 4),
|
||||
Self::EacR11Unorm => ( etc2, float, linear, noaa, (4, 4), 8, basic, 1),
|
||||
Self::EacR11Snorm => ( etc2, float, linear, noaa, (4, 4), 8, basic, 1),
|
||||
Self::EacRg11Unorm => ( etc2, float, linear, noaa, (4, 4), 16, basic, 2),
|
||||
Self::EacRg11Snorm => ( etc2, float, linear, noaa, (4, 4), 16, basic, 2),
|
||||
|
||||
// ASTC compressed textures
|
||||
Self::Astc { block, channel } => {
|
||||
@ -2202,14 +2139,6 @@ impl TextureFormat {
|
||||
};
|
||||
(feature, float, color_space, noaa, dimensions, 16, basic, 4)
|
||||
}
|
||||
|
||||
// Optional normalized 16-bit-per-channel formats
|
||||
Self::R16Unorm => (norm16bit, float, linear, msaa, (1, 1), 2, storage, 1),
|
||||
Self::R16Snorm => (norm16bit, float, linear, msaa, (1, 1), 2, storage, 1),
|
||||
Self::Rg16Unorm => (norm16bit, float, linear, msaa, (1, 1), 4, storage, 2),
|
||||
Self::Rg16Snorm => (norm16bit, float, linear, msaa, (1, 1), 4, storage, 2),
|
||||
Self::Rgba16Unorm => (norm16bit, float, linear, msaa, (1, 1), 8, storage, 4),
|
||||
Self::Rgba16Snorm => (norm16bit, float, linear, msaa, (1, 1), 8, storage, 4),
|
||||
};
|
||||
|
||||
let mut flags = msaa_flags;
|
||||
|
Loading…
Reference in New Issue
Block a user