Rg11b10Float -> Rg11b10UFloat and deduplicate entries in TEXTURE_FORMAT_LIST (#6108)

* Resync `TEXTURE_FORMAT_LIST` to match `TextureFormat`

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* `Rg11b10Float` -> `Rg11b10UFloat`

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* Add changelog entry

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
Samson 2024-08-13 10:28:55 +02:00 committed by GitHub
parent 5533c37786
commit c6a3d92734
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
22 changed files with 55 additions and 44 deletions

View File

@ -62,6 +62,7 @@ Bottom level categories:
### Changes
- Reduce the amount of debug and trace logs emitted by wgpu-core and wgpu-hal. By @nical in [#6065](https://github.com/gfx-rs/wgpu/issues/6065)
- `Rg11b10Float` is renamed to `Rg11b10UFloat`. By @sagudev in [#6108](https://github.com/gfx-rs/wgpu/pull/6108)
### Dependency Updates

View File

@ -399,7 +399,7 @@ impl<'a, W> Writer<'a, W> {
| StorageFormat::Rg16Float
| StorageFormat::Rgb10a2Uint
| StorageFormat::Rgb10a2Unorm
| StorageFormat::Rg11b10Float
| StorageFormat::Rg11b10UFloat
| StorageFormat::Rg32Uint
| StorageFormat::Rg32Sint
| StorageFormat::Rg32Float => {

View File

@ -4820,7 +4820,7 @@ fn glsl_storage_format(format: crate::StorageFormat) -> Result<&'static str, Err
Sf::Rgba8Sint => "rgba8i",
Sf::Rgb10a2Uint => "rgb10_a2ui",
Sf::Rgb10a2Unorm => "rgb10_a2",
Sf::Rg11b10Float => "r11f_g11f_b10f",
Sf::Rg11b10UFloat => "r11f_g11f_b10f",
Sf::Rg32Uint => "rg32ui",
Sf::Rg32Sint => "rg32i",
Sf::Rg32Float => "rg32f",

View File

@ -132,7 +132,7 @@ impl crate::StorageFormat {
Self::Rg8Sint | Self::Rg16Sint => "int2",
Self::Rg8Uint | Self::Rg16Uint => "uint2",
Self::Rg11b10Float => "float3",
Self::Rg11b10UFloat => "float3",
Self::Rgba16Float | Self::R32Float | Self::Rg32Float | Self::Rgba32Float => "float4",
Self::Rgba8Unorm | Self::Bgra8Unorm | Self::Rgba16Unorm | Self::Rgb10a2Unorm => {

View File

@ -1170,7 +1170,7 @@ impl From<crate::StorageFormat> for spirv::ImageFormat {
Sf::Bgra8Unorm => Self::Unknown,
Sf::Rgb10a2Uint => Self::Rgb10a2ui,
Sf::Rgb10a2Unorm => Self::Rgb10A2,
Sf::Rg11b10Float => Self::R11fG11fB10f,
Sf::Rg11b10UFloat => Self::R11fG11fB10f,
Sf::Rg32Uint => Self::Rg32ui,
Sf::Rg32Sint => Self::Rg32i,
Sf::Rg32Float => Self::Rg32f,

View File

@ -2015,7 +2015,7 @@ const fn storage_format_str(format: crate::StorageFormat) -> &'static str {
Sf::Bgra8Unorm => "bgra8unorm",
Sf::Rgb10a2Uint => "rgb10a2uint",
Sf::Rgb10a2Unorm => "rgb10a2unorm",
Sf::Rg11b10Float => "rg11b10float",
Sf::Rg11b10UFloat => "rg11b10float",
Sf::Rg32Uint => "rg32uint",
Sf::Rg32Sint => "rg32sint",
Sf::Rg32Float => "rg32float",

View File

@ -397,7 +397,7 @@ fn map_image_format(word: &str) -> Option<crate::StorageFormat> {
"rgba16f" => Sf::Rgba16Float,
"rg32f" => Sf::Rg32Float,
"rg16f" => Sf::Rg16Float,
"r11f_g11f_b10f" => Sf::Rg11b10Float,
"r11f_g11f_b10f" => Sf::Rg11b10UFloat,
"r32f" => Sf::R32Float,
"r16f" => Sf::R16Float,
"rgba16" => Sf::Rgba16Unorm,

View File

@ -104,7 +104,7 @@ pub(super) fn map_image_format(word: spirv::Word) -> Result<crate::StorageFormat
Some(spirv::ImageFormat::Rgba8i) => Ok(crate::StorageFormat::Rgba8Sint),
Some(spirv::ImageFormat::Rgb10a2ui) => Ok(crate::StorageFormat::Rgb10a2Uint),
Some(spirv::ImageFormat::Rgb10A2) => Ok(crate::StorageFormat::Rgb10a2Unorm),
Some(spirv::ImageFormat::R11fG11fB10f) => Ok(crate::StorageFormat::Rg11b10Float),
Some(spirv::ImageFormat::R11fG11fB10f) => Ok(crate::StorageFormat::Rg11b10UFloat),
Some(spirv::ImageFormat::Rg32ui) => Ok(crate::StorageFormat::Rg32Uint),
Some(spirv::ImageFormat::Rg32i) => Ok(crate::StorageFormat::Rg32Sint),
Some(spirv::ImageFormat::Rg32f) => Ok(crate::StorageFormat::Rg32Float),

View File

@ -92,7 +92,7 @@ pub fn map_storage_format(word: &str, span: Span) -> Result<crate::StorageFormat
"rgba8sint" => Sf::Rgba8Sint,
"rgb10a2uint" => Sf::Rgb10a2Uint,
"rgb10a2unorm" => Sf::Rgb10a2Unorm,
"rg11b10float" => Sf::Rg11b10Float,
"rg11b10float" => Sf::Rg11b10UFloat,
"rg32uint" => Sf::Rg32Uint,
"rg32sint" => Sf::Rg32Sint,
"rg32float" => Sf::Rg32Float,

View File

@ -175,7 +175,7 @@ impl crate::StorageFormat {
Sf::Bgra8Unorm => "bgra8unorm",
Sf::Rgb10a2Uint => "rgb10a2uint",
Sf::Rgb10a2Unorm => "rgb10a2unorm",
Sf::Rg11b10Float => "rg11b10float",
Sf::Rg11b10UFloat => "rg11b10float",
Sf::Rg32Uint => "rg32uint",
Sf::Rg32Sint => "rg32sint",
Sf::Rg32Float => "rg32float",

View File

@ -615,7 +615,7 @@ pub enum StorageFormat {
// Packed 32-bit formats
Rgb10a2Uint,
Rgb10a2Unorm,
Rg11b10Float,
Rg11b10UFloat,
// 64-bit formats
Rg32Uint,

View File

@ -48,7 +48,7 @@ impl From<super::StorageFormat> for super::ScalarKind {
Sf::Bgra8Unorm => Sk::Float,
Sf::Rgb10a2Uint => Sk::Uint,
Sf::Rgb10a2Unorm => Sk::Float,
Sf::Rg11b10Float => Sk::Float,
Sf::Rg11b10UFloat => Sk::Float,
Sf::Rg32Uint => Sk::Uint,
Sf::Rg32Sint => Sk::Sint,
Sf::Rg32Float => Sk::Float,

View File

@ -26,7 +26,7 @@ static TEXTURE_FORMATS_UNCOMPRESSED_GLES_COMPAT: &[wgpu::TextureFormat] = &[
wgpu::TextureFormat::Bgra8UnormSrgb,
wgpu::TextureFormat::Rgb10a2Uint,
wgpu::TextureFormat::Rgb10a2Unorm,
wgpu::TextureFormat::Rg11b10Float,
wgpu::TextureFormat::Rg11b10UFloat,
wgpu::TextureFormat::Rg32Uint,
wgpu::TextureFormat::Rg32Sint,
wgpu::TextureFormat::Rg32Float,

View File

@ -275,7 +275,7 @@ fn map_storage_format_to_naga(format: wgt::TextureFormat) -> Option<naga::Storag
Tf::Rgb10a2Uint => Sf::Rgb10a2Uint,
Tf::Rgb10a2Unorm => Sf::Rgb10a2Unorm,
Tf::Rg11b10Float => Sf::Rg11b10Float,
Tf::Rg11b10UFloat => Sf::Rg11b10UFloat,
Tf::Rg32Uint => Sf::Rg32Uint,
Tf::Rg32Sint => Sf::Rg32Sint,
@ -331,7 +331,7 @@ fn map_storage_format_from_naga(format: naga::StorageFormat) -> wgt::TextureForm
Sf::Rgb10a2Uint => Tf::Rgb10a2Uint,
Sf::Rgb10a2Unorm => Tf::Rgb10a2Unorm,
Sf::Rg11b10Float => Tf::Rg11b10Float,
Sf::Rg11b10UFloat => Tf::Rg11b10UFloat,
Sf::Rg32Uint => Tf::Rg32Uint,
Sf::Rg32Sint => Tf::Rg32Sint,
@ -658,7 +658,7 @@ impl NumericType {
Tf::Rgba8Sint | Tf::Rgba16Sint | Tf::Rgba32Sint => {
(NumericDimension::Vector(Vs::Quad), Scalar::I32)
}
Tf::Rg11b10Float => (NumericDimension::Vector(Vs::Tri), Scalar::F32),
Tf::Rg11b10UFloat => (NumericDimension::Vector(Vs::Tri), Scalar::F32),
Tf::Stencil8
| Tf::Depth16Unorm
| Tf::Depth32Float

View File

@ -44,7 +44,7 @@ pub fn map_texture_format_failable(format: wgt::TextureFormat) -> Option<dxgifor
Tf::Rgb9e5Ufloat => DXGI_FORMAT_R9G9B9E5_SHAREDEXP,
Tf::Rgb10a2Uint => DXGI_FORMAT_R10G10B10A2_UINT,
Tf::Rgb10a2Unorm => DXGI_FORMAT_R10G10B10A2_UNORM,
Tf::Rg11b10Float => DXGI_FORMAT_R11G11B10_FLOAT,
Tf::Rg11b10UFloat => DXGI_FORMAT_R11G11B10_FLOAT,
Tf::Rg32Uint => DXGI_FORMAT_R32G32_UINT,
Tf::Rg32Sint => DXGI_FORMAT_R32G32_SINT,
Tf::Rg32Float => DXGI_FORMAT_R32G32_FLOAT,

View File

@ -1097,7 +1097,7 @@ impl crate::Adapter for super::Adapter {
Tf::Rgba8Sint => renderable | storage,
Tf::Rgb10a2Uint => renderable,
Tf::Rgb10a2Unorm => filterable_renderable,
Tf::Rg11b10Float => filterable | float_renderable,
Tf::Rg11b10UFloat => filterable | float_renderable,
Tf::Rg32Uint => renderable,
Tf::Rg32Sint => renderable,
Tf::Rg32Float => unfilterable | float_renderable | texture_float_linear,

View File

@ -45,7 +45,7 @@ impl super::AdapterShared {
glow::RGBA,
glow::UNSIGNED_INT_2_10_10_10_REV,
),
Tf::Rg11b10Float => (
Tf::Rg11b10UFloat => (
glow::R11F_G11F_B10F,
glow::RGB,
glow::UNSIGNED_INT_10F_11F_11F_REV,

View File

@ -178,7 +178,7 @@ impl crate::Adapter for super::Adapter {
flags.set(Tfc::STORAGE, pc.format_rgb10a2_unorm_all);
flags
}
Tf::Rg11b10Float => {
Tf::Rg11b10UFloat => {
let mut flags = all_caps;
flags.set(Tfc::STORAGE, pc.format_rg11b10_all);
flags
@ -1036,7 +1036,7 @@ impl super::PrivateCapabilities {
Tf::Rgba8Sint => RGBA8Sint,
Tf::Rgb10a2Uint => RGB10A2Uint,
Tf::Rgb10a2Unorm => RGB10A2Unorm,
Tf::Rg11b10Float => RG11B10Float,
Tf::Rg11b10UFloat => RG11B10Float,
Tf::Rg32Uint => RG32Uint,
Tf::Rg32Sint => RG32Sint,
Tf::Rg32Float => RG32Float,

View File

@ -36,7 +36,7 @@ impl super::PrivateCapabilities {
Tf::Rgba8Sint => F::R8G8B8A8_SINT,
Tf::Rgb10a2Uint => F::A2B10G10R10_UINT_PACK32,
Tf::Rgb10a2Unorm => F::A2B10G10R10_UNORM_PACK32,
Tf::Rg11b10Float => F::B10G11R11_UFLOAT_PACK32,
Tf::Rg11b10UFloat => F::B10G11R11_UFLOAT_PACK32,
Tf::Rg32Uint => F::R32G32_UINT,
Tf::Rg32Sint => F::R32G32_SINT,
Tf::Rg32Float => F::R32G32_SFLOAT,

View File

@ -1,6 +1,6 @@
// Lets keep these on one line
#[rustfmt::skip]
pub const TEXTURE_FORMAT_LIST: [wgpu::TextureFormat; 119] = [
pub const TEXTURE_FORMAT_LIST: [wgpu::TextureFormat; 116] = [
wgpu::TextureFormat::R8Unorm,
wgpu::TextureFormat::R8Snorm,
wgpu::TextureFormat::R8Uint,
@ -29,9 +29,10 @@ pub const TEXTURE_FORMAT_LIST: [wgpu::TextureFormat; 119] = [
wgpu::TextureFormat::Rgba8Sint,
wgpu::TextureFormat::Bgra8Unorm,
wgpu::TextureFormat::Bgra8UnormSrgb,
wgpu::TextureFormat::Rgb9e5Ufloat,
wgpu::TextureFormat::Rgb10a2Uint,
wgpu::TextureFormat::Rgb10a2Unorm,
wgpu::TextureFormat::Rg11b10Float,
wgpu::TextureFormat::Rg11b10UFloat,
wgpu::TextureFormat::Rg32Uint,
wgpu::TextureFormat::Rg32Sint,
wgpu::TextureFormat::Rg32Float,
@ -45,14 +46,10 @@ pub const TEXTURE_FORMAT_LIST: [wgpu::TextureFormat; 119] = [
wgpu::TextureFormat::Rgba32Float,
wgpu::TextureFormat::Stencil8,
wgpu::TextureFormat::Depth16Unorm,
wgpu::TextureFormat::Depth32Float,
wgpu::TextureFormat::Depth32FloatStencil8,
wgpu::TextureFormat::Depth24Plus,
wgpu::TextureFormat::Depth24PlusStencil8,
wgpu::TextureFormat::Rgb9e5Ufloat,
wgpu::TextureFormat::Rgb10a2Uint,
wgpu::TextureFormat::Rgb10a2Unorm,
wgpu::TextureFormat::Rg11b10Float,
wgpu::TextureFormat::Depth32Float,
wgpu::TextureFormat::Depth32FloatStencil8,
wgpu::TextureFormat::NV12,
wgpu::TextureFormat::Bc1RgbaUnorm,
wgpu::TextureFormat::Bc1RgbaUnormSrgb,
@ -122,6 +119,19 @@ pub const TEXTURE_FORMAT_LIST: [wgpu::TextureFormat; 119] = [
wgpu::TextureFormat::Astc { block: wgpu::AstcBlock::B12x12, channel: wgpu::AstcChannel::Hdr },
];
#[test]
fn test_uniqueness_in_texture_format_list() {
use std::collections::HashSet;
let uniq: HashSet<wgpu::TextureFormat> = TEXTURE_FORMAT_LIST.into_iter().collect();
let mut duplicated = TEXTURE_FORMAT_LIST.to_vec();
uniq.iter().for_each(|u| {
let first_occurrence = duplicated.iter().position(|el| u == el).unwrap();
duplicated.remove(first_occurrence);
});
assert_eq!(duplicated, vec![]);
}
pub fn max_texture_format_string_size() -> usize {
TEXTURE_FORMAT_LIST
.into_iter()

View File

@ -399,7 +399,7 @@ bitflags::bitflags! {
const SHADER_F16 = 1 << 8;
/// Allows for usage of textures of format [`TextureFormat::Rg11b10Float`] as a render target
/// Allows for usage of textures of format [`TextureFormat::Rg11b10UFloat`] as a render target
///
/// Supported platforms:
/// - Vulkan
@ -2515,7 +2515,7 @@ pub enum TextureFormat {
/// 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,
Rg11b10UFloat,
// Normal 64 bit formats
/// Red and green channels. 32 bit integer per channel. Unsigned in shader.
@ -2803,7 +2803,7 @@ impl<'de> Deserialize<'de> for TextureFormat {
"bgra8unorm-srgb" => TextureFormat::Bgra8UnormSrgb,
"rgb10a2uint" => TextureFormat::Rgb10a2Uint,
"rgb10a2unorm" => TextureFormat::Rgb10a2Unorm,
"rg11b10ufloat" => TextureFormat::Rg11b10Float,
"rg11b10ufloat" => TextureFormat::Rg11b10UFloat,
"rg32uint" => TextureFormat::Rg32Uint,
"rg32sint" => TextureFormat::Rg32Sint,
"rg32float" => TextureFormat::Rg32Float,
@ -2931,7 +2931,7 @@ impl Serialize for TextureFormat {
TextureFormat::Bgra8UnormSrgb => "bgra8unorm-srgb",
TextureFormat::Rgb10a2Uint => "rgb10a2uint",
TextureFormat::Rgb10a2Unorm => "rgb10a2unorm",
TextureFormat::Rg11b10Float => "rg11b10ufloat",
TextureFormat::Rg11b10UFloat => "rg11b10ufloat",
TextureFormat::Rg32Uint => "rg32uint",
TextureFormat::Rg32Sint => "rg32sint",
TextureFormat::Rg32Float => "rg32float",
@ -3161,7 +3161,7 @@ impl TextureFormat {
| Self::Rgb9e5Ufloat
| Self::Rgb10a2Uint
| Self::Rgb10a2Unorm
| Self::Rg11b10Float
| Self::Rg11b10UFloat
| Self::Rg32Uint
| Self::Rg32Sint
| Self::Rg32Float
@ -3266,7 +3266,7 @@ impl TextureFormat {
| Self::Rgb9e5Ufloat
| Self::Rgb10a2Uint
| Self::Rgb10a2Unorm
| Self::Rg11b10Float
| Self::Rg11b10UFloat
| Self::Rg32Uint
| Self::Rg32Sint
| Self::Rg32Float
@ -3384,7 +3384,7 @@ impl TextureFormat {
Self::Bgra8UnormSrgb => (msaa_resolve, attachment),
Self::Rgb10a2Uint => ( msaa, attachment),
Self::Rgb10a2Unorm => (msaa_resolve, attachment),
Self::Rg11b10Float => ( msaa, rg11b10f),
Self::Rg11b10UFloat => ( msaa, rg11b10f),
Self::Rg32Uint => ( noaa, all_flags),
Self::Rg32Sint => ( noaa, all_flags),
Self::Rg32Float => ( noaa, all_flags),
@ -3494,7 +3494,7 @@ impl TextureFormat {
| Self::Rg16Float
| Self::Rgba16Float
| Self::Rgb10a2Unorm
| Self::Rg11b10Float => Some(float),
| Self::Rg11b10UFloat => Some(float),
Self::R32Float | Self::Rg32Float | Self::Rgba32Float => Some(float32_sample_type),
@ -3624,7 +3624,7 @@ impl TextureFormat {
| Self::Rg16Sint
| Self::Rg16Float => Some(4),
Self::R32Uint | Self::R32Sint | Self::R32Float => Some(4),
Self::Rgb9e5Ufloat | Self::Rgb10a2Uint | Self::Rgb10a2Unorm | Self::Rg11b10Float => {
Self::Rgb9e5Ufloat | Self::Rgb10a2Uint | Self::Rgb10a2Unorm | Self::Rg11b10UFloat => {
Some(4)
}
@ -3726,7 +3726,7 @@ impl TextureFormat {
| Self::Rg32Float
| Self::Rgb10a2Uint
| Self::Rgb10a2Unorm
| Self::Rg11b10Float => Some(8),
| Self::Rg11b10UFloat => Some(8),
Self::Rgba32Uint | Self::Rgba32Sint | Self::Rgba32Float => Some(16),
Self::Stencil8
| Self::Depth16Unorm
@ -3808,7 +3808,7 @@ impl TextureFormat {
| Self::Rgba32Float
| Self::Rgb10a2Uint
| Self::Rgb10a2Unorm
| Self::Rg11b10Float => Some(4),
| Self::Rg11b10UFloat => Some(4),
Self::Stencil8
| Self::Depth16Unorm
| Self::Depth24Plus
@ -3897,7 +3897,7 @@ impl TextureFormat {
| Self::Rgba32Sint
| Self::Rgba32Float => 4,
Self::Rgb9e5Ufloat | Self::Rg11b10Float => 3,
Self::Rgb9e5Ufloat | Self::Rg11b10UFloat => 3,
Self::Rgb10a2Uint | Self::Rgb10a2Unorm => 4,
Self::Stencil8 | Self::Depth16Unorm | Self::Depth24Plus | Self::Depth32Float => 1,
@ -4112,7 +4112,7 @@ fn texture_format_serialize() {
"\"rgb10a2unorm\"".to_string()
);
assert_eq!(
serde_json::to_string(&TextureFormat::Rg11b10Float).unwrap(),
serde_json::to_string(&TextureFormat::Rg11b10UFloat).unwrap(),
"\"rg11b10ufloat\"".to_string()
);
assert_eq!(
@ -4409,7 +4409,7 @@ fn texture_format_deserialize() {
);
assert_eq!(
serde_json::from_str::<TextureFormat>("\"rg11b10ufloat\"").unwrap(),
TextureFormat::Rg11b10Float
TextureFormat::Rg11b10UFloat
);
assert_eq!(
serde_json::from_str::<TextureFormat>("\"rg32uint\"").unwrap(),

View File

@ -261,7 +261,7 @@ fn map_texture_format(texture_format: wgt::TextureFormat) -> webgpu_sys::GpuText
unimplemented!("Current version of web_sys is missing {texture_format:?}")
}
TextureFormat::Rgb10a2Unorm => tf::Rgb10a2unorm,
TextureFormat::Rg11b10Float => tf::Rg11b10ufloat,
TextureFormat::Rg11b10UFloat => tf::Rg11b10ufloat,
// 64-bit formats
TextureFormat::Rg32Uint => tf::Rg32uint,
TextureFormat::Rg32Sint => tf::Rg32sint,