From 04f080c4acc44e0b983961bb3d83623000dcc742 Mon Sep 17 00:00:00 2001 From: Mauro Gentile Date: Thu, 11 Aug 2022 08:53:15 +0200 Subject: [PATCH 01/10] Remove Depth24unormStencil8 not existing anymore --- wgpu/src/backend/web.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/wgpu/src/backend/web.rs b/wgpu/src/backend/web.rs index 15ed91356e..b9ef18035e 100644 --- a/wgpu/src/backend/web.rs +++ b/wgpu/src/backend/web.rs @@ -550,7 +550,6 @@ fn map_texture_format(texture_format: wgt::TextureFormat) -> web_sys::GpuTexture TextureFormat::Depth32FloatStencil8 => tf::Depth32floatStencil8, TextureFormat::Depth24Plus => tf::Depth24plus, TextureFormat::Depth24PlusStencil8 => tf::Depth24plusStencil8, - TextureFormat::Depth24UnormStencil8 => tf::Depth24unormStencil8, _ => unimplemented!(), } } From 2445158b106bbc992a86f0472e2887f9ad174b56 Mon Sep 17 00:00:00 2001 From: Mauro Gentile Date: Fri, 26 Aug 2022 14:11:35 +0200 Subject: [PATCH 02/10] Updating TextureFormats from WebGPU specs --- CHANGELOG.md | 2 +- wgpu-core/src/command/transfer.rs | 7 +++-- wgpu-core/src/conv.rs | 7 +++-- wgpu-core/src/validation.rs | 7 +++-- wgpu-hal/src/auxil/dxgi/conv.rs | 24 ++++++++++------ wgpu-hal/src/dx12/adapter.rs | 1 - wgpu-hal/src/gles/adapter.rs | 7 +++-- wgpu-hal/src/gles/conv.rs | 4 ++- wgpu-hal/src/lib.rs | 8 ++++-- wgpu-hal/src/metal/adapter.rs | 26 +++++++++++------ wgpu-hal/src/vulkan/adapter.rs | 2 +- wgpu-hal/src/vulkan/conv.rs | 3 +- wgpu-info/src/main.rs | 3 +- wgpu-types/src/lib.rs | 46 ++++++++++++++++--------------- wgpu/src/backend/web.rs | 15 ++++++++-- wgpu/tests/clear_texture.rs | 8 ++++-- 16 files changed, 105 insertions(+), 65 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e146d7d6ab..6ff0e8a015 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -330,7 +330,7 @@ DeviceDescriptor { - Return `queue_empty` for Device::poll by @xiaopengli89 in [#2643](https://github.com/gfx-rs/wgpu/pull/2643) - Add `SHADER_FLOAT16` feature by @jinleili in [#2646](https://github.com/gfx-rs/wgpu/pull/2646) - Add DEPTH32FLOAT_STENCIL8 featue by @jinleili in [#2664](https://github.com/gfx-rs/wgpu/pull/2664) -- Add DEPTH24UNORM_STENCIL8 feature by @jinleili in [#2689](https://github.com/gfx-rs/wgpu/pull/2689) +- Add DEPTH24PLUS_STENCIL8 feature by @jinleili in [#2689](https://github.com/gfx-rs/wgpu/pull/2689) - Implement submission indexes by @cwfitzgerald in [#2700](https://github.com/gfx-rs/wgpu/pull/2700) - [WebGL] Add a downlevel capability for rendering to floating point textures by @expenses in [#2729](https://github.com/gfx-rs/wgpu/pull/2729) - allow creating wgpu::Instance from wgpu_core::Instance by @i509VCB in [#2763](https://github.com/gfx-rs/wgpu/pull/2763) diff --git a/wgpu-core/src/command/transfer.rs b/wgpu-core/src/command/transfer.rs index b9c6dd4865..1994e725f1 100644 --- a/wgpu-core/src/command/transfer.rs +++ b/wgpu-core/src/command/transfer.rs @@ -314,11 +314,12 @@ pub(crate) fn validate_texture_copy_range( let extent = extent_virtual.physical_size(desc.format); match desc.format { - wgt::TextureFormat::Depth32Float + wgt::TextureFormat::Stencil8 + | wgt::TextureFormat::Depth16Unorm + | wgt::TextureFormat::Depth32Float | wgt::TextureFormat::Depth32FloatStencil8 | wgt::TextureFormat::Depth24Plus - | wgt::TextureFormat::Depth24PlusStencil8 - | wgt::TextureFormat::Depth24UnormStencil8 => { + | wgt::TextureFormat::Depth24PlusStencil8 => { if *copy_size != extent { return Err(TransferError::InvalidDepthTextureExtent); } diff --git a/wgpu-core/src/conv.rs b/wgpu-core/src/conv.rs index fd59a25eb4..8bdc70b06b 100644 --- a/wgpu-core/src/conv.rs +++ b/wgpu-core/src/conv.rs @@ -19,11 +19,12 @@ pub fn is_valid_copy_src_texture_format(format: wgt::TextureFormat) -> bool { pub fn is_valid_copy_dst_texture_format(format: wgt::TextureFormat) -> bool { use wgt::TextureFormat as Tf; match format { - Tf::Depth32Float + Tf::Stencil8 + | Tf::Depth16Unorm + | Tf::Depth32Float | Tf::Depth32FloatStencil8 | Tf::Depth24Plus - | Tf::Depth24PlusStencil8 - | Tf::Depth24UnormStencil8 => false, + | Tf::Depth24PlusStencil8 => false, _ => true, } } diff --git a/wgpu-core/src/validation.rs b/wgpu-core/src/validation.rs index aef7cc46a9..6e1ee3c3f5 100644 --- a/wgpu-core/src/validation.rs +++ b/wgpu-core/src/validation.rs @@ -704,11 +704,12 @@ impl NumericType { (NumericDimension::Vector(Vs::Quad), Sk::Sint) } Tf::Rg11b10Float => (NumericDimension::Vector(Vs::Tri), Sk::Float), - Tf::Depth32Float + Tf::Stencil8 + | Tf::Depth16Unorm + | Tf::Depth32Float | Tf::Depth32FloatStencil8 | Tf::Depth24Plus - | Tf::Depth24PlusStencil8 - | Tf::Depth24UnormStencil8 => { + | Tf::Depth24PlusStencil8 => { panic!("Unexpected depth format") } Tf::Rgb9e5Ufloat => (NumericDimension::Vector(Vs::Tri), Sk::Float), diff --git a/wgpu-hal/src/auxil/dxgi/conv.rs b/wgpu-hal/src/auxil/dxgi/conv.rs index faf42bc98a..557fae6b15 100644 --- a/wgpu-hal/src/auxil/dxgi/conv.rs +++ b/wgpu-hal/src/auxil/dxgi/conv.rs @@ -33,6 +33,7 @@ pub fn map_texture_format_failable(format: wgt::TextureFormat) -> Option DXGI_FORMAT_B8G8R8A8_UNORM, Tf::Rgba8Uint => DXGI_FORMAT_R8G8B8A8_UINT, Tf::Rgba8Sint => DXGI_FORMAT_R8G8B8A8_SINT, + Tf::Rgb9e5Ufloat => DXGI_FORMAT_R9G9B9E5_SHAREDEXP, Tf::Rgb10a2Unorm => DXGI_FORMAT_R10G10B10A2_UNORM, Tf::Rg11b10Float => DXGI_FORMAT_R11G11B10_FLOAT, Tf::Rg32Uint => DXGI_FORMAT_R32G32_UINT, @@ -46,11 +47,12 @@ pub fn map_texture_format_failable(format: wgt::TextureFormat) -> Option DXGI_FORMAT_R32G32B32A32_UINT, Tf::Rgba32Sint => DXGI_FORMAT_R32G32B32A32_SINT, Tf::Rgba32Float => DXGI_FORMAT_R32G32B32A32_FLOAT, + Tf::Stencil8 => DXGI_FORMAT_R8_UNORM, + Tf::Depth16Unorm => DXGI_FORMAT_D16_UNORM, + Tf::Depth24Plus => DXGI_FORMAT_D24_UNORM_S8_UINT, + Tf::Depth24PlusStencil8 => DXGI_FORMAT_D24_UNORM_S8_UINT, Tf::Depth32Float => DXGI_FORMAT_D32_FLOAT, Tf::Depth32FloatStencil8 => DXGI_FORMAT_D32_FLOAT_S8X24_UINT, - Tf::Depth24Plus => DXGI_FORMAT_D24_UNORM_S8_UINT, - Tf::Depth24PlusStencil8 | Tf::Depth24UnormStencil8 => DXGI_FORMAT_D24_UNORM_S8_UINT, - Tf::Rgb9e5Ufloat => DXGI_FORMAT_R9G9B9E5_SHAREDEXP, Tf::Bc1RgbaUnorm => DXGI_FORMAT_BC1_UNORM, Tf::Bc1RgbaUnormSrgb => DXGI_FORMAT_BC1_UNORM_SRGB, Tf::Bc2RgbaUnorm => DXGI_FORMAT_BC2_UNORM, @@ -103,13 +105,15 @@ pub fn map_texture_format_nosrgb(format: wgt::TextureFormat) -> dxgiformat::DXGI //TODO: stencil views? pub fn map_texture_format_nodepth(format: wgt::TextureFormat) -> dxgiformat::DXGI_FORMAT { match format { + wgt::TextureFormat::Stencil8 => dxgiformat::DXGI_FORMAT_R8_UNORM, + wgt::TextureFormat::Depth16Unorm => dxgiformat::DXGI_FORMAT_D16_UNORM, wgt::TextureFormat::Depth32Float => dxgiformat::DXGI_FORMAT_R32_FLOAT, wgt::TextureFormat::Depth32FloatStencil8 => { dxgiformat::DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS } - wgt::TextureFormat::Depth24Plus - | wgt::TextureFormat::Depth24PlusStencil8 - | wgt::TextureFormat::Depth24UnormStencil8 => dxgiformat::DXGI_FORMAT_R24_UNORM_X8_TYPELESS, + wgt::TextureFormat::Depth24Plus | wgt::TextureFormat::Depth24PlusStencil8 => { + dxgiformat::DXGI_FORMAT_R24_UNORM_X8_TYPELESS + } _ => { assert_eq!( crate::FormatAspects::from(format), @@ -122,11 +126,13 @@ pub fn map_texture_format_nodepth(format: wgt::TextureFormat) -> dxgiformat::DXG pub fn map_texture_format_depth_typeless(format: wgt::TextureFormat) -> dxgiformat::DXGI_FORMAT { match format { + wgt::TextureFormat::Stencil8 => dxgiformat::DXGI_FORMAT_R8_UNORM, + wgt::TextureFormat::Depth16Unorm => dxgiformat::DXGI_FORMAT_D16_UNORM, wgt::TextureFormat::Depth32Float => dxgiformat::DXGI_FORMAT_R32_TYPELESS, wgt::TextureFormat::Depth32FloatStencil8 => dxgiformat::DXGI_FORMAT_R32G8X24_TYPELESS, - wgt::TextureFormat::Depth24Plus - | wgt::TextureFormat::Depth24PlusStencil8 - | wgt::TextureFormat::Depth24UnormStencil8 => dxgiformat::DXGI_FORMAT_R24G8_TYPELESS, + wgt::TextureFormat::Depth24Plus | wgt::TextureFormat::Depth24PlusStencil8 => { + dxgiformat::DXGI_FORMAT_R24G8_TYPELESS + } _ => unreachable!(), } } diff --git a/wgpu-hal/src/dx12/adapter.rs b/wgpu-hal/src/dx12/adapter.rs index d17fd9b0b6..7b492dacbb 100644 --- a/wgpu-hal/src/dx12/adapter.rs +++ b/wgpu-hal/src/dx12/adapter.rs @@ -189,7 +189,6 @@ impl super::Adapter { let mut features = wgt::Features::empty() | wgt::Features::DEPTH_CLIP_CONTROL - | wgt::Features::DEPTH24UNORM_STENCIL8 | wgt::Features::DEPTH32FLOAT_STENCIL8 | wgt::Features::INDIRECT_FIRST_INSTANCE | wgt::Features::MAPPABLE_PRIMARY_BUFFERS diff --git a/wgpu-hal/src/gles/adapter.rs b/wgpu-hal/src/gles/adapter.rs index a1b88c5b24..12245740b4 100644 --- a/wgpu-hal/src/gles/adapter.rs +++ b/wgpu-hal/src/gles/adapter.rs @@ -719,11 +719,12 @@ impl crate::Adapter for super::Adapter { Tf::Rgba32Uint => renderable | storage, Tf::Rgba32Sint => renderable | storage, Tf::Rgba32Float => unfilterable | storage | float_renderable, - Tf::Depth32Float + Tf::Stencil8 + | Tf::Depth16Unorm + | Tf::Depth32Float | Tf::Depth32FloatStencil8 | Tf::Depth24Plus - | Tf::Depth24PlusStencil8 - | Tf::Depth24UnormStencil8 => depth, + | Tf::Depth24PlusStencil8 => depth, Tf::Rgb9e5Ufloat => filterable, Tf::Bc1RgbaUnorm | Tf::Bc1RgbaUnormSrgb diff --git a/wgpu-hal/src/gles/conv.rs b/wgpu-hal/src/gles/conv.rs index bf0f3bf0bd..199382fadc 100644 --- a/wgpu-hal/src/gles/conv.rs +++ b/wgpu-hal/src/gles/conv.rs @@ -56,6 +56,8 @@ impl super::AdapterShared { Tf::Rgba32Uint => (glow::RGBA32UI, glow::RGBA_INTEGER, glow::UNSIGNED_INT), Tf::Rgba32Sint => (glow::RGBA32I, glow::RGBA_INTEGER, glow::INT), Tf::Rgba32Float => (glow::RGBA32F, glow::RGBA, glow::FLOAT), + Tf::Stencil8 => (glow::R8UI, glow::STENCIL_COMPONENTS, glow::UNSIGNED_BYTE), + Tf::Depth16Unorm => (glow::DEPTH_COMPONENT16, glow::DEPTH_COMPONENT, glow::UNSIGNED_SHORT), Tf::Depth32Float => (glow::DEPTH_COMPONENT32F, glow::DEPTH_COMPONENT, glow::FLOAT), Tf::Depth32FloatStencil8 => { (glow::DEPTH32F_STENCIL8, glow::DEPTH_COMPONENT, glow::FLOAT) @@ -65,7 +67,7 @@ impl super::AdapterShared { glow::DEPTH_COMPONENT, glow::UNSIGNED_NORMALIZED, ), - Tf::Depth24PlusStencil8 | Tf::Depth24UnormStencil8 => ( + Tf::Depth24PlusStencil8 => ( glow::DEPTH24_STENCIL8, glow::DEPTH_COMPONENT, glow::UNSIGNED_INT, diff --git a/wgpu-hal/src/lib.rs b/wgpu-hal/src/lib.rs index 02d3c13af1..91a3873e07 100644 --- a/wgpu-hal/src/lib.rs +++ b/wgpu-hal/src/lib.rs @@ -611,10 +611,12 @@ impl From for FormatAspects { impl From for FormatAspects { fn from(format: wgt::TextureFormat) -> Self { match format { + wgt::TextureFormat::Stencil8 => Self::STENCIL, + wgt::TextureFormat::Depth16Unorm => Self::DEPTH, wgt::TextureFormat::Depth32Float | wgt::TextureFormat::Depth24Plus => Self::DEPTH, - wgt::TextureFormat::Depth32FloatStencil8 - | wgt::TextureFormat::Depth24PlusStencil8 - | wgt::TextureFormat::Depth24UnormStencil8 => Self::DEPTH | Self::STENCIL, + wgt::TextureFormat::Depth32FloatStencil8 | wgt::TextureFormat::Depth24PlusStencil8 => { + Self::DEPTH | Self::STENCIL + } _ => Self::COLOR, } } diff --git a/wgpu-hal/src/metal/adapter.rs b/wgpu-hal/src/metal/adapter.rs index 2b53069597..158b12f129 100644 --- a/wgpu-hal/src/metal/adapter.rs +++ b/wgpu-hal/src/metal/adapter.rs @@ -180,6 +180,21 @@ impl crate::Adapter for super::Adapter { }; flags } + Tf::Stencil8 => { + let mut flags = all_caps + | Tfc::DEPTH_STENCIL_ATTACHMENT + | Tfc::MULTISAMPLE + | msaa_resolve_apple3x_if; + flags + } + Tf::Depth16Unorm => { + let mut flags = + Tfc::DEPTH_STENCIL_ATTACHMENT | Tfc::MULTISAMPLE | msaa_resolve_apple3x_if; + if pc.format_depth16unorm { + flags |= Tfc::SAMPLED_LINEAR + } + flags + } Tf::Depth32Float | Tf::Depth32FloatStencil8 => { let mut flags = Tfc::DEPTH_STENCIL_ATTACHMENT | Tfc::MULTISAMPLE | msaa_resolve_apple3x_if; @@ -200,12 +215,6 @@ impl crate::Adapter for super::Adapter { } flags } - Tf::Depth24UnormStencil8 => { - Tfc::DEPTH_STENCIL_ATTACHMENT - | Tfc::SAMPLED_LINEAR - | Tfc::MULTISAMPLE - | Tfc::MULTISAMPLE_RESOLVE - } Tf::Rgb9e5Ufloat => { if pc.msaa_apple3 { all_caps @@ -775,7 +784,7 @@ impl super::PrivateCapabilities { features.set(F::TEXTURE_COMPRESSION_ETC2, self.format_eac_etc); features.set(F::DEPTH_CLIP_CONTROL, self.supports_depth_clip_control); - features.set(F::DEPTH24UNORM_STENCIL8, self.format_depth24_stencil8); + features.set(F::DEPTH24PLUS_STENCIL8, self.format_depth24_stencil8); features.set( F::TEXTURE_BINDING_ARRAY @@ -908,6 +917,8 @@ impl super::PrivateCapabilities { Tf::Rgba32Uint => RGBA32Uint, Tf::Rgba32Sint => RGBA32Sint, Tf::Rgba32Float => RGBA32Float, + Tf::Stencil8 => R8Unorm, + Tf::Depth16Unorm => Depth16Unorm, Tf::Depth32Float => Depth32Float, Tf::Depth32FloatStencil8 => Depth32Float_Stencil8, Tf::Depth24Plus => { @@ -924,7 +935,6 @@ impl super::PrivateCapabilities { Depth32Float_Stencil8 } } - Tf::Depth24UnormStencil8 => Depth24Unorm_Stencil8, Tf::Rgb9e5Ufloat => RGB9E5Float, Tf::Bc1RgbaUnorm => BC1_RGBA, Tf::Bc1RgbaUnormSrgb => BC1_RGBA_sRGB, diff --git a/wgpu-hal/src/vulkan/adapter.rs b/wgpu-hal/src/vulkan/adapter.rs index c45479bfc0..e841e65c61 100644 --- a/wgpu-hal/src/vulkan/adapter.rs +++ b/wgpu-hal/src/vulkan/adapter.rs @@ -568,7 +568,7 @@ impl PhysicalDeviceFeatures { ); features.set( - F::DEPTH24UNORM_STENCIL8, + F::DEPTH24PLUS_STENCIL8, supports_format( instance, phd, diff --git a/wgpu-hal/src/vulkan/conv.rs b/wgpu-hal/src/vulkan/conv.rs index dc5b915970..1dce541354 100644 --- a/wgpu-hal/src/vulkan/conv.rs +++ b/wgpu-hal/src/vulkan/conv.rs @@ -64,7 +64,8 @@ impl super::PrivateCapabilities { F::D32_SFLOAT_S8_UINT } } - Tf::Depth24UnormStencil8 => F::D24_UNORM_S8_UINT, + Tf::Stencil8 => F::R8_UNORM, + Tf::Depth16Unorm => F::D16_UNORM, Tf::Rgb9e5Ufloat => F::E5B9G9R9_UFLOAT_PACK32, Tf::Bc1RgbaUnorm => F::BC1_RGBA_UNORM_BLOCK, Tf::Bc1RgbaUnormSrgb => F::BC1_RGBA_SRGB_BLOCK, diff --git a/wgpu-info/src/main.rs b/wgpu-info/src/main.rs index 34260e10c2..b65640847a 100644 --- a/wgpu-info/src/main.rs +++ b/wgpu-info/src/main.rs @@ -50,11 +50,12 @@ mod inner { wgpu::TextureFormat::Rgba32Uint, wgpu::TextureFormat::Rgba32Sint, wgpu::TextureFormat::Rgba32Float, + wgpu::TextureFormat::Stencil8, + wgpu::TextureFormat::Depth16Unorm, wgpu::TextureFormat::Depth32Float, wgpu::TextureFormat::Depth32FloatStencil8, wgpu::TextureFormat::Depth24Plus, wgpu::TextureFormat::Depth24PlusStencil8, - wgpu::TextureFormat::Depth24UnormStencil8, wgpu::TextureFormat::Rgb9e5Ufloat, wgpu::TextureFormat::Bc1RgbaUnorm, wgpu::TextureFormat::Bc1RgbaUnormSrgb, diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index a57054cee4..e5bb7e9362 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -191,7 +191,7 @@ bitflags::bitflags! { /// /// This is a web and native feature. const DEPTH_CLIP_CONTROL = 1 << 0; - /// Allows for explicit creation of textures of format [`TextureFormat::Depth24UnormStencil8`] + /// Allows for explicit creation of textures of format [`TextureFormat::Depth24PlusStencil8`] /// /// Supported platforms: /// - Vulkan (some) @@ -199,7 +199,7 @@ bitflags::bitflags! { /// - Metal (Macs with amd GPUs) /// /// This is a web and native feature. - const DEPTH24UNORM_STENCIL8 = 1 << 1; + const DEPTH24PLUS_STENCIL8 = 1 << 1; /// Allows for explicit creation of textures of format [`TextureFormat::Depth32FloatStencil8`] /// /// Supported platforms: @@ -1862,6 +1862,9 @@ pub enum TextureFormat { Bgra8UnormSrgb, // Packed 32 bit formats + /// Packed unsigned float with 9 bits mantisa for each RGB component, then a common 5 bits exponent + #[cfg_attr(feature = "serde", serde(rename = "rgb9e5ufloat"))] + Rgb9e5Ufloat, /// 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. #[cfg_attr(feature = "serde", serde(rename = "rgb10a2unorm"))] Rgb10a2Unorm, @@ -1911,26 +1914,24 @@ pub enum TextureFormat { Rgba32Float, // Depth and stencil formats - /// Special depth format with 32 bit floating point depth. - #[cfg_attr(feature = "serde", serde(rename = "depth32float"))] - Depth32Float, - /// Special depth/stencil format with 32 bit floating point depth and 8 bits integer stencil. - #[cfg_attr(feature = "serde", serde(rename = "depth32float-stencil8"))] - Depth32FloatStencil8, + /// Stencil format with 8 bit integer stencil. + #[cfg_attr(feature = "serde", serde(rename = "stencil8"))] + Stencil8, + /// Special depth format with 16 bit integer depth. + #[cfg_attr(feature = "serde", serde(rename = "depth16unorm"))] + Depth16Unorm, /// Special depth format with at least 24 bit integer depth. #[cfg_attr(feature = "serde", serde(rename = "depth24plus"))] Depth24Plus, /// Special depth/stencil format with at least 24 bit integer depth and 8 bits integer stencil. #[cfg_attr(feature = "serde", serde(rename = "depth24plus-stencil8"))] Depth24PlusStencil8, - /// Special depth/stencil format with 24 bit integer depth and 8 bits integer stencil. - #[cfg_attr(feature = "serde", serde(rename = "depth24unorm-stencil8"))] - Depth24UnormStencil8, - - // Packed uncompressed texture formats - /// Packed unsigned float with 9 bits mantisa for each RGB component, then a common 5 bits exponent - #[cfg_attr(feature = "serde", serde(rename = "rgb9e5ufloat"))] - Rgb9e5Ufloat, + /// Special depth format with 32 bit floating point depth. + #[cfg_attr(feature = "serde", serde(rename = "depth32float"))] + Depth32Float, + /// Special depth/stencil format with 32 bit floating point depth and 8 bits integer stencil. + #[cfg_attr(feature = "serde", serde(rename = "depth32float-stencil8"))] + Depth32FloatStencil8, // 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. @@ -2129,7 +2130,7 @@ impl TextureFormat { let astc_hdr = Features::TEXTURE_COMPRESSION_ASTC_HDR; let norm16bit = Features::TEXTURE_FORMAT_16BIT_NORM; let d32_s8 = Features::DEPTH32FLOAT_STENCIL8; - let d24_s8 = Features::DEPTH24UNORM_STENCIL8; + let d24_s8 = Features::DEPTH24PLUS_STENCIL8; // Sample Types let uint = TextureSampleType::Uint; @@ -2201,6 +2202,7 @@ impl TextureFormat { Self::Bgra8UnormSrgb => ( native, float, corrected, msaa_resolve, (1, 1), 4, attachment, 4), // Packed 32 bit textures + Self::Rgb9e5Ufloat => ( native, float, linear, noaa, (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), @@ -2218,15 +2220,15 @@ impl TextureFormat { 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::Depth32FloatStencil8 =>( d32_s8, depth, linear, msaa, (1, 1), 4, attachment, 2), + Self::Stencil8 => ( native, depth, linear, msaa, (1, 1), 1, attachment, 1), + Self::Depth16Unorm => ( native, depth, linear, msaa, (1, 1), 2, 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::Depth24UnormStencil8 => ( d24_s8, depth, linear, msaa, (1, 1), 4, attachment, 2), + Self::Depth32Float => ( native, depth, linear, msaa, (1, 1), 4, attachment, 1), + Self::Depth32FloatStencil8 =>( d32_s8, depth, linear, msaa, (1, 1), 4, attachment, 2), // 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), diff --git a/wgpu/src/backend/web.rs b/wgpu/src/backend/web.rs index b9ef18035e..a6e84ccfdc 100644 --- a/wgpu/src/backend/web.rs +++ b/wgpu/src/backend/web.rs @@ -511,10 +511,12 @@ fn map_texture_format(texture_format: wgt::TextureFormat) -> web_sys::GpuTexture use web_sys::GpuTextureFormat as tf; use wgt::TextureFormat; match texture_format { + // 8-bit formats TextureFormat::R8Unorm => tf::R8unorm, TextureFormat::R8Snorm => tf::R8snorm, TextureFormat::R8Uint => tf::R8uint, TextureFormat::R8Sint => tf::R8sint, + // 16-bit formats TextureFormat::R16Uint => tf::R16uint, TextureFormat::R16Sint => tf::R16sint, TextureFormat::R16Float => tf::R16float, @@ -522,6 +524,7 @@ fn map_texture_format(texture_format: wgt::TextureFormat) -> web_sys::GpuTexture TextureFormat::Rg8Snorm => tf::Rg8snorm, TextureFormat::Rg8Uint => tf::Rg8uint, TextureFormat::Rg8Sint => tf::Rg8sint, + // 32-bit formats TextureFormat::R32Uint => tf::R32uint, TextureFormat::R32Sint => tf::R32sint, TextureFormat::R32Float => tf::R32float, @@ -535,21 +538,29 @@ fn map_texture_format(texture_format: wgt::TextureFormat) -> web_sys::GpuTexture TextureFormat::Rgba8Sint => tf::Rgba8sint, TextureFormat::Bgra8Unorm => tf::Bgra8unorm, TextureFormat::Bgra8UnormSrgb => tf::Bgra8unormSrgb, + // Packed 32-bit formats + TextureFormat::Rgb9e5Ufloat => tf::Rgb9e5ufloat, TextureFormat::Rgb10a2Unorm => tf::Rgb10a2unorm, TextureFormat::Rg11b10Float => tf::Rg11b10ufloat, + // 64-bit formats TextureFormat::Rg32Uint => tf::Rg32uint, TextureFormat::Rg32Sint => tf::Rg32sint, TextureFormat::Rg32Float => tf::Rg32float, TextureFormat::Rgba16Uint => tf::Rgba16uint, TextureFormat::Rgba16Sint => tf::Rgba16sint, TextureFormat::Rgba16Float => tf::Rgba16float, + // 128-bit formats TextureFormat::Rgba32Uint => tf::Rgba32uint, TextureFormat::Rgba32Sint => tf::Rgba32sint, TextureFormat::Rgba32Float => tf::Rgba32float, - TextureFormat::Depth32Float => tf::Depth32float, - TextureFormat::Depth32FloatStencil8 => tf::Depth32floatStencil8, + // Depth/stencil formats + TextureFormat::Stencil8 => tf::Stencil8, + TextureFormat::Depth16Unorm => tf::Depth16unorm, TextureFormat::Depth24Plus => tf::Depth24plus, TextureFormat::Depth24PlusStencil8 => tf::Depth24plusStencil8, + TextureFormat::Depth32Float => tf::Depth32float, + // "depth32float-stencil8" feature + TextureFormat::Depth32FloatStencil8 => tf::Depth32floatStencil8, _ => unimplemented!(), } } diff --git a/wgpu/tests/clear_texture.rs b/wgpu/tests/clear_texture.rs index a96922de3f..0ccc536292 100644 --- a/wgpu/tests/clear_texture.rs +++ b/wgpu/tests/clear_texture.rs @@ -41,9 +41,11 @@ static TEXTURE_FORMATS_UNCOMPRESSED: &[wgpu::TextureFormat] = &[ ]; static TEXTURE_FORMATS_DEPTH: &[wgpu::TextureFormat] = &[ - wgpu::TextureFormat::Depth32Float, + wgpu::TextureFormat::Stencil8, + wgpu::TextureFormat::Depth16Unorm, wgpu::TextureFormat::Depth24Plus, wgpu::TextureFormat::Depth24PlusStencil8, + wgpu::TextureFormat::Depth32FloatStencil8, ]; // needs TEXTURE_COMPRESSION_BC @@ -333,11 +335,11 @@ fn clear_texture_d32_s8() { fn clear_texture_d24_s8() { initialize_test( TestParameters::default() - .features(wgpu::Features::CLEAR_TEXTURE | wgpu::Features::DEPTH24UNORM_STENCIL8), + .features(wgpu::Features::CLEAR_TEXTURE | wgpu::Features::DEPTH24PLUS_STENCIL8), |ctx| { clear_texture_tests( &ctx, - &[wgpu::TextureFormat::Depth24UnormStencil8], + &[wgpu::TextureFormat::Depth24PlusStencil8], false, false, ); From bf5fe3d033ec9f3ae1ae46160c9430a4be2e5e28 Mon Sep 17 00:00:00 2001 From: Mauro Gentile Date: Fri, 26 Aug 2022 14:17:26 +0200 Subject: [PATCH 03/10] Fixing feature check --- wgpu-types/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index e5bb7e9362..0a3be9e9b2 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -2223,7 +2223,7 @@ impl TextureFormat { Self::Stencil8 => ( native, depth, linear, msaa, (1, 1), 1, attachment, 1), Self::Depth16Unorm => ( native, depth, linear, msaa, (1, 1), 2, 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::Depth24PlusStencil8 => ( d24_s8, depth, linear, msaa, (1, 1), 4, attachment, 2), Self::Depth32Float => ( native, depth, linear, msaa, (1, 1), 4, attachment, 1), Self::Depth32FloatStencil8 =>( d32_s8, depth, linear, msaa, (1, 1), 4, attachment, 2), From 9617f2885e180680d7b2c97e1d78caec9b8f8ade Mon Sep 17 00:00:00 2001 From: Mauro Gentile Date: Mon, 29 Aug 2022 07:41:51 +0200 Subject: [PATCH 04/10] Stripping out stencil8 till we do more deep tests --- CHANGELOG.md | 2 +- wgpu-core/src/command/transfer.rs | 4 ++-- wgpu-core/src/conv.rs | 4 ++-- wgpu-core/src/validation.rs | 4 ++-- wgpu-hal/src/auxil/dxgi/conv.rs | 6 +++--- wgpu-hal/src/gles/adapter.rs | 4 ++-- wgpu-hal/src/gles/conv.rs | 2 +- wgpu-hal/src/lib.rs | 2 +- wgpu-hal/src/metal/adapter.rs | 6 +++--- wgpu-hal/src/vulkan/conv.rs | 2 +- wgpu-info/src/main.rs | 2 +- wgpu-types/src/lib.rs | 6 +++--- wgpu/src/backend/web.rs | 2 +- wgpu/tests/clear_texture.rs | 2 +- 14 files changed, 24 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ff0e8a015..e146d7d6ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -330,7 +330,7 @@ DeviceDescriptor { - Return `queue_empty` for Device::poll by @xiaopengli89 in [#2643](https://github.com/gfx-rs/wgpu/pull/2643) - Add `SHADER_FLOAT16` feature by @jinleili in [#2646](https://github.com/gfx-rs/wgpu/pull/2646) - Add DEPTH32FLOAT_STENCIL8 featue by @jinleili in [#2664](https://github.com/gfx-rs/wgpu/pull/2664) -- Add DEPTH24PLUS_STENCIL8 feature by @jinleili in [#2689](https://github.com/gfx-rs/wgpu/pull/2689) +- Add DEPTH24UNORM_STENCIL8 feature by @jinleili in [#2689](https://github.com/gfx-rs/wgpu/pull/2689) - Implement submission indexes by @cwfitzgerald in [#2700](https://github.com/gfx-rs/wgpu/pull/2700) - [WebGL] Add a downlevel capability for rendering to floating point textures by @expenses in [#2729](https://github.com/gfx-rs/wgpu/pull/2729) - allow creating wgpu::Instance from wgpu_core::Instance by @i509VCB in [#2763](https://github.com/gfx-rs/wgpu/pull/2763) diff --git a/wgpu-core/src/command/transfer.rs b/wgpu-core/src/command/transfer.rs index 1994e725f1..0ebc52e289 100644 --- a/wgpu-core/src/command/transfer.rs +++ b/wgpu-core/src/command/transfer.rs @@ -314,8 +314,8 @@ pub(crate) fn validate_texture_copy_range( let extent = extent_virtual.physical_size(desc.format); match desc.format { - wgt::TextureFormat::Stencil8 - | wgt::TextureFormat::Depth16Unorm + //wgt::TextureFormat::Stencil8 | + wgt::TextureFormat::Depth16Unorm | wgt::TextureFormat::Depth32Float | wgt::TextureFormat::Depth32FloatStencil8 | wgt::TextureFormat::Depth24Plus diff --git a/wgpu-core/src/conv.rs b/wgpu-core/src/conv.rs index 8bdc70b06b..6a0da9d29a 100644 --- a/wgpu-core/src/conv.rs +++ b/wgpu-core/src/conv.rs @@ -19,8 +19,8 @@ pub fn is_valid_copy_src_texture_format(format: wgt::TextureFormat) -> bool { pub fn is_valid_copy_dst_texture_format(format: wgt::TextureFormat) -> bool { use wgt::TextureFormat as Tf; match format { - Tf::Stencil8 - | Tf::Depth16Unorm + //Tf::Stencil8 | + Tf::Depth16Unorm | Tf::Depth32Float | Tf::Depth32FloatStencil8 | Tf::Depth24Plus diff --git a/wgpu-core/src/validation.rs b/wgpu-core/src/validation.rs index 6e1ee3c3f5..a6dee7d974 100644 --- a/wgpu-core/src/validation.rs +++ b/wgpu-core/src/validation.rs @@ -704,8 +704,8 @@ impl NumericType { (NumericDimension::Vector(Vs::Quad), Sk::Sint) } Tf::Rg11b10Float => (NumericDimension::Vector(Vs::Tri), Sk::Float), - Tf::Stencil8 - | Tf::Depth16Unorm + //Tf::Stencil8 | + Tf::Depth16Unorm | Tf::Depth32Float | Tf::Depth32FloatStencil8 | Tf::Depth24Plus diff --git a/wgpu-hal/src/auxil/dxgi/conv.rs b/wgpu-hal/src/auxil/dxgi/conv.rs index 557fae6b15..fc29fa9d15 100644 --- a/wgpu-hal/src/auxil/dxgi/conv.rs +++ b/wgpu-hal/src/auxil/dxgi/conv.rs @@ -47,7 +47,7 @@ pub fn map_texture_format_failable(format: wgt::TextureFormat) -> Option DXGI_FORMAT_R32G32B32A32_UINT, Tf::Rgba32Sint => DXGI_FORMAT_R32G32B32A32_SINT, Tf::Rgba32Float => DXGI_FORMAT_R32G32B32A32_FLOAT, - Tf::Stencil8 => DXGI_FORMAT_R8_UNORM, + //Tf::Stencil8 => DXGI_FORMAT_R8_UNORM, Tf::Depth16Unorm => DXGI_FORMAT_D16_UNORM, Tf::Depth24Plus => DXGI_FORMAT_D24_UNORM_S8_UINT, Tf::Depth24PlusStencil8 => DXGI_FORMAT_D24_UNORM_S8_UINT, @@ -105,7 +105,7 @@ pub fn map_texture_format_nosrgb(format: wgt::TextureFormat) -> dxgiformat::DXGI //TODO: stencil views? pub fn map_texture_format_nodepth(format: wgt::TextureFormat) -> dxgiformat::DXGI_FORMAT { match format { - wgt::TextureFormat::Stencil8 => dxgiformat::DXGI_FORMAT_R8_UNORM, + //wgt::TextureFormat::Stencil8 => dxgiformat::DXGI_FORMAT_R8_UNORM, wgt::TextureFormat::Depth16Unorm => dxgiformat::DXGI_FORMAT_D16_UNORM, wgt::TextureFormat::Depth32Float => dxgiformat::DXGI_FORMAT_R32_FLOAT, wgt::TextureFormat::Depth32FloatStencil8 => { @@ -126,7 +126,7 @@ pub fn map_texture_format_nodepth(format: wgt::TextureFormat) -> dxgiformat::DXG pub fn map_texture_format_depth_typeless(format: wgt::TextureFormat) -> dxgiformat::DXGI_FORMAT { match format { - wgt::TextureFormat::Stencil8 => dxgiformat::DXGI_FORMAT_R8_UNORM, + //wgt::TextureFormat::Stencil8 => dxgiformat::DXGI_FORMAT_R8_UNORM, wgt::TextureFormat::Depth16Unorm => dxgiformat::DXGI_FORMAT_D16_UNORM, wgt::TextureFormat::Depth32Float => dxgiformat::DXGI_FORMAT_R32_TYPELESS, wgt::TextureFormat::Depth32FloatStencil8 => dxgiformat::DXGI_FORMAT_R32G8X24_TYPELESS, diff --git a/wgpu-hal/src/gles/adapter.rs b/wgpu-hal/src/gles/adapter.rs index 12245740b4..22ce3cc800 100644 --- a/wgpu-hal/src/gles/adapter.rs +++ b/wgpu-hal/src/gles/adapter.rs @@ -719,8 +719,8 @@ impl crate::Adapter for super::Adapter { Tf::Rgba32Uint => renderable | storage, Tf::Rgba32Sint => renderable | storage, Tf::Rgba32Float => unfilterable | storage | float_renderable, - Tf::Stencil8 - | Tf::Depth16Unorm + //Tf::Stencil8 | + Tf::Depth16Unorm | Tf::Depth32Float | Tf::Depth32FloatStencil8 | Tf::Depth24Plus diff --git a/wgpu-hal/src/gles/conv.rs b/wgpu-hal/src/gles/conv.rs index 199382fadc..2c13a7d489 100644 --- a/wgpu-hal/src/gles/conv.rs +++ b/wgpu-hal/src/gles/conv.rs @@ -56,7 +56,7 @@ impl super::AdapterShared { Tf::Rgba32Uint => (glow::RGBA32UI, glow::RGBA_INTEGER, glow::UNSIGNED_INT), Tf::Rgba32Sint => (glow::RGBA32I, glow::RGBA_INTEGER, glow::INT), Tf::Rgba32Float => (glow::RGBA32F, glow::RGBA, glow::FLOAT), - Tf::Stencil8 => (glow::R8UI, glow::STENCIL_COMPONENTS, glow::UNSIGNED_BYTE), + //Tf::Stencil8 => (glow::R8UI, glow::STENCIL_COMPONENTS, glow::UNSIGNED_BYTE), Tf::Depth16Unorm => (glow::DEPTH_COMPONENT16, glow::DEPTH_COMPONENT, glow::UNSIGNED_SHORT), Tf::Depth32Float => (glow::DEPTH_COMPONENT32F, glow::DEPTH_COMPONENT, glow::FLOAT), Tf::Depth32FloatStencil8 => { diff --git a/wgpu-hal/src/lib.rs b/wgpu-hal/src/lib.rs index 91a3873e07..be83081180 100644 --- a/wgpu-hal/src/lib.rs +++ b/wgpu-hal/src/lib.rs @@ -611,7 +611,7 @@ impl From for FormatAspects { impl From for FormatAspects { fn from(format: wgt::TextureFormat) -> Self { match format { - wgt::TextureFormat::Stencil8 => Self::STENCIL, + //wgt::TextureFormat::Stencil8 => Self::STENCIL, wgt::TextureFormat::Depth16Unorm => Self::DEPTH, wgt::TextureFormat::Depth32Float | wgt::TextureFormat::Depth24Plus => Self::DEPTH, wgt::TextureFormat::Depth32FloatStencil8 | wgt::TextureFormat::Depth24PlusStencil8 => { diff --git a/wgpu-hal/src/metal/adapter.rs b/wgpu-hal/src/metal/adapter.rs index 158b12f129..cc8a82ab6d 100644 --- a/wgpu-hal/src/metal/adapter.rs +++ b/wgpu-hal/src/metal/adapter.rs @@ -180,13 +180,13 @@ impl crate::Adapter for super::Adapter { }; flags } - Tf::Stencil8 => { + /*Tf::Stencil8 => { let mut flags = all_caps | Tfc::DEPTH_STENCIL_ATTACHMENT | Tfc::MULTISAMPLE | msaa_resolve_apple3x_if; flags - } + }*/ Tf::Depth16Unorm => { let mut flags = Tfc::DEPTH_STENCIL_ATTACHMENT | Tfc::MULTISAMPLE | msaa_resolve_apple3x_if; @@ -917,7 +917,7 @@ impl super::PrivateCapabilities { Tf::Rgba32Uint => RGBA32Uint, Tf::Rgba32Sint => RGBA32Sint, Tf::Rgba32Float => RGBA32Float, - Tf::Stencil8 => R8Unorm, + //Tf::Stencil8 => R8Unorm, Tf::Depth16Unorm => Depth16Unorm, Tf::Depth32Float => Depth32Float, Tf::Depth32FloatStencil8 => Depth32Float_Stencil8, diff --git a/wgpu-hal/src/vulkan/conv.rs b/wgpu-hal/src/vulkan/conv.rs index 1dce541354..a002fcc3f7 100644 --- a/wgpu-hal/src/vulkan/conv.rs +++ b/wgpu-hal/src/vulkan/conv.rs @@ -64,7 +64,7 @@ impl super::PrivateCapabilities { F::D32_SFLOAT_S8_UINT } } - Tf::Stencil8 => F::R8_UNORM, + //Tf::Stencil8 => F::R8_UNORM, Tf::Depth16Unorm => F::D16_UNORM, Tf::Rgb9e5Ufloat => F::E5B9G9R9_UFLOAT_PACK32, Tf::Bc1RgbaUnorm => F::BC1_RGBA_UNORM_BLOCK, diff --git a/wgpu-info/src/main.rs b/wgpu-info/src/main.rs index b65640847a..9840511491 100644 --- a/wgpu-info/src/main.rs +++ b/wgpu-info/src/main.rs @@ -50,7 +50,7 @@ mod inner { wgpu::TextureFormat::Rgba32Uint, wgpu::TextureFormat::Rgba32Sint, wgpu::TextureFormat::Rgba32Float, - wgpu::TextureFormat::Stencil8, + //wgpu::TextureFormat::Stencil8, wgpu::TextureFormat::Depth16Unorm, wgpu::TextureFormat::Depth32Float, wgpu::TextureFormat::Depth32FloatStencil8, diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index 0a3be9e9b2..8ac70f8344 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -1915,8 +1915,8 @@ pub enum TextureFormat { // Depth and stencil formats /// Stencil format with 8 bit integer stencil. - #[cfg_attr(feature = "serde", serde(rename = "stencil8"))] - Stencil8, + //#[cfg_attr(feature = "serde", serde(rename = "stencil8"))] + //Stencil8, /// Special depth format with 16 bit integer depth. #[cfg_attr(feature = "serde", serde(rename = "depth16unorm"))] Depth16Unorm, @@ -2220,7 +2220,7 @@ impl TextureFormat { Self::Rgba32Float => ( native, nearest, linear, noaa, (1, 1), 16, all_flags, 4), // Depth-stencil textures - Self::Stencil8 => ( native, depth, linear, msaa, (1, 1), 1, attachment, 1), + //Self::Stencil8 => ( native, depth, linear, msaa, (1, 1), 1, attachment, 1), Self::Depth16Unorm => ( native, depth, linear, msaa, (1, 1), 2, attachment, 1), Self::Depth24Plus => ( native, depth, linear, msaa, (1, 1), 4, attachment, 1), Self::Depth24PlusStencil8 => ( d24_s8, depth, linear, msaa, (1, 1), 4, attachment, 2), diff --git a/wgpu/src/backend/web.rs b/wgpu/src/backend/web.rs index a6e84ccfdc..970a3c987c 100644 --- a/wgpu/src/backend/web.rs +++ b/wgpu/src/backend/web.rs @@ -554,7 +554,7 @@ fn map_texture_format(texture_format: wgt::TextureFormat) -> web_sys::GpuTexture TextureFormat::Rgba32Sint => tf::Rgba32sint, TextureFormat::Rgba32Float => tf::Rgba32float, // Depth/stencil formats - TextureFormat::Stencil8 => tf::Stencil8, + //TextureFormat::Stencil8 => tf::Stencil8, TextureFormat::Depth16Unorm => tf::Depth16unorm, TextureFormat::Depth24Plus => tf::Depth24plus, TextureFormat::Depth24PlusStencil8 => tf::Depth24plusStencil8, diff --git a/wgpu/tests/clear_texture.rs b/wgpu/tests/clear_texture.rs index 0ccc536292..308b86cad9 100644 --- a/wgpu/tests/clear_texture.rs +++ b/wgpu/tests/clear_texture.rs @@ -41,7 +41,7 @@ static TEXTURE_FORMATS_UNCOMPRESSED: &[wgpu::TextureFormat] = &[ ]; static TEXTURE_FORMATS_DEPTH: &[wgpu::TextureFormat] = &[ - wgpu::TextureFormat::Stencil8, + //wgpu::TextureFormat::Stencil8, wgpu::TextureFormat::Depth16Unorm, wgpu::TextureFormat::Depth24Plus, wgpu::TextureFormat::Depth24PlusStencil8, From ba3d1045facead8ac1e028b43efab9b8e8677792 Mon Sep 17 00:00:00 2001 From: Mauro Gentile Date: Mon, 29 Aug 2022 07:56:37 +0200 Subject: [PATCH 05/10] Fixing rust fmt --- wgpu-hal/src/gles/conv.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/wgpu-hal/src/gles/conv.rs b/wgpu-hal/src/gles/conv.rs index 2c13a7d489..78fa6fbcc0 100644 --- a/wgpu-hal/src/gles/conv.rs +++ b/wgpu-hal/src/gles/conv.rs @@ -57,7 +57,11 @@ impl super::AdapterShared { Tf::Rgba32Sint => (glow::RGBA32I, glow::RGBA_INTEGER, glow::INT), Tf::Rgba32Float => (glow::RGBA32F, glow::RGBA, glow::FLOAT), //Tf::Stencil8 => (glow::R8UI, glow::STENCIL_COMPONENTS, glow::UNSIGNED_BYTE), - Tf::Depth16Unorm => (glow::DEPTH_COMPONENT16, glow::DEPTH_COMPONENT, glow::UNSIGNED_SHORT), + Tf::Depth16Unorm => ( + glow::DEPTH_COMPONENT16, + glow::DEPTH_COMPONENT, + glow::UNSIGNED_SHORT, + ), Tf::Depth32Float => (glow::DEPTH_COMPONENT32F, glow::DEPTH_COMPONENT, glow::FLOAT), Tf::Depth32FloatStencil8 => { (glow::DEPTH32F_STENCIL8, glow::DEPTH_COMPONENT, glow::FLOAT) From 197dc80e84b5c9236b61ac296dbe5b980a0f2b20 Mon Sep 17 00:00:00 2001 From: Mauro Gentile Date: Wed, 31 Aug 2022 08:07:36 +0200 Subject: [PATCH 06/10] Fixing format check --- wgpu-types/src/lib.rs | 221 +++++++++++++++++++++++++++--------------- 1 file changed, 145 insertions(+), 76 deletions(-) diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index 8ac70f8344..e625bce20d 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -2160,7 +2160,6 @@ impl TextureFormat { let all_flags = TextureUsages::all(); // See for reference - #[rustfmt::skip] // lets make a nice table let ( required_features, sample_type, @@ -2172,98 +2171,168 @@ 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::Rgb9e5Ufloat => ( native, float, linear, noaa, (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), + Self::Rgb9e5Ufloat => (native, float, linear, noaa, (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), + 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), + 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::Stencil8 => ( native, depth, linear, msaa, (1, 1), 1, attachment, 1), - Self::Depth16Unorm => ( native, depth, linear, msaa, (1, 1), 2, attachment, 1), - Self::Depth24Plus => ( native, depth, linear, msaa, (1, 1), 4, attachment, 1), - Self::Depth24PlusStencil8 => ( d24_s8, depth, linear, msaa, (1, 1), 4, attachment, 2), - Self::Depth32Float => ( native, depth, linear, msaa, (1, 1), 4, attachment, 1), - Self::Depth32FloatStencil8 =>( d32_s8, depth, linear, msaa, (1, 1), 4, attachment, 2), - - // Packed uncompressed - + //Self::Stencil8 => ( native, depth, linear, msaa, (1, 1), 1, attachment, 1), + Self::Depth16Unorm => (native, depth, linear, msaa, (1, 1), 2, attachment, 1), + Self::Depth24Plus => (native, depth, linear, msaa, (1, 1), 4, attachment, 1), + Self::Depth24PlusStencil8 => (d24_s8, depth, linear, msaa, (1, 1), 4, attachment, 2), + Self::Depth32Float => (native, depth, linear, msaa, (1, 1), 4, attachment, 1), + Self::Depth32FloatStencil8 => (d32_s8, depth, linear, msaa, (1, 1), 4, attachment, 2), + // 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), + 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 } => { From 2c3e82b4417b6252827c6dbe9dbf2cb8d39ba158 Mon Sep 17 00:00:00 2001 From: Mauro Gentile Date: Sun, 4 Sep 2022 09:21:07 +0200 Subject: [PATCH 07/10] Fixing wrong removal instead of renaming --- wgpu-hal/src/dx12/adapter.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/wgpu-hal/src/dx12/adapter.rs b/wgpu-hal/src/dx12/adapter.rs index 7b492dacbb..0e029f8424 100644 --- a/wgpu-hal/src/dx12/adapter.rs +++ b/wgpu-hal/src/dx12/adapter.rs @@ -189,6 +189,7 @@ impl super::Adapter { let mut features = wgt::Features::empty() | wgt::Features::DEPTH_CLIP_CONTROL + | wgt::Features::DEPTH24PLUS_STENCIL8 | wgt::Features::DEPTH32FLOAT_STENCIL8 | wgt::Features::INDIRECT_FIRST_INSTANCE | wgt::Features::MAPPABLE_PRIMARY_BUFFERS From 4d4e308ba98935c992ed6c80b8fbf9deec92f77a Mon Sep 17 00:00:00 2001 From: Mauro Gentile Date: Sun, 4 Sep 2022 09:49:05 +0200 Subject: [PATCH 08/10] Fix feature-specific texture formats --- wgpu/tests/clear_texture.rs | 2 - wgpu/tests/zero_init_texture_after_discard.rs | 97 ++++++++++--------- 2 files changed, 50 insertions(+), 49 deletions(-) diff --git a/wgpu/tests/clear_texture.rs b/wgpu/tests/clear_texture.rs index 308b86cad9..9abf7e043d 100644 --- a/wgpu/tests/clear_texture.rs +++ b/wgpu/tests/clear_texture.rs @@ -44,8 +44,6 @@ static TEXTURE_FORMATS_DEPTH: &[wgpu::TextureFormat] = &[ //wgpu::TextureFormat::Stencil8, wgpu::TextureFormat::Depth16Unorm, wgpu::TextureFormat::Depth24Plus, - wgpu::TextureFormat::Depth24PlusStencil8, - wgpu::TextureFormat::Depth32FloatStencil8, ]; // needs TEXTURE_COMPRESSION_BC diff --git a/wgpu/tests/zero_init_texture_after_discard.rs b/wgpu/tests/zero_init_texture_after_discard.rs index 6043d0388f..9307bc7fbd 100644 --- a/wgpu/tests/zero_init_texture_after_discard.rs +++ b/wgpu/tests/zero_init_texture_after_discard.rs @@ -110,55 +110,58 @@ fn discarding_depth_target_resets_texture_init_state_check_visible_on_copy_in_sa #[test] fn discarding_either_depth_or_stencil_aspect() { - initialize_test(TestParameters::default(), |ctx| { - let (texture, _) = create_white_texture_and_readback_buffer( - &ctx, - wgpu::TextureFormat::Depth24PlusStencil8, - ); - // TODO: How do we test this other than "doesn't crash"? We can't copy the texture to/from buffers, so we would need to do a copy in a shader - { - let mut encoder = ctx - .device - .create_command_encoder(&wgpu::CommandEncoderDescriptor::default()); - encoder.begin_render_pass(&wgpu::RenderPassDescriptor { - label: Some("Depth Discard, Stencil Load"), - color_attachments: &[], - depth_stencil_attachment: Some(wgpu::RenderPassDepthStencilAttachment { - view: &texture.create_view(&wgpu::TextureViewDescriptor::default()), - depth_ops: Some(wgpu::Operations { - load: wgpu::LoadOp::Load, - store: false, // discard! - }), - stencil_ops: Some(wgpu::Operations { - load: wgpu::LoadOp::Clear(0), - store: true, - }), - }), - }); - ctx.queue.submit([encoder.finish()]); - } - { - let mut encoder = ctx - .device - .create_command_encoder(&wgpu::CommandEncoderDescriptor::default()); - encoder.begin_render_pass(&wgpu::RenderPassDescriptor { - label: Some("Depth Load, Stencil Discard"), - color_attachments: &[], - depth_stencil_attachment: Some(wgpu::RenderPassDepthStencilAttachment { - view: &texture.create_view(&wgpu::TextureViewDescriptor::default()), - depth_ops: Some(wgpu::Operations { - load: wgpu::LoadOp::Clear(0.0), - store: true, + initialize_test( + TestParameters::default().features(wgpu::Features::DEPTH24PLUS_STENCIL8), + |ctx| { + let (texture, _) = create_white_texture_and_readback_buffer( + &ctx, + wgpu::TextureFormat::Depth24PlusStencil8, + ); + // TODO: How do we test this other than "doesn't crash"? We can't copy the texture to/from buffers, so we would need to do a copy in a shader + { + let mut encoder = ctx + .device + .create_command_encoder(&wgpu::CommandEncoderDescriptor::default()); + encoder.begin_render_pass(&wgpu::RenderPassDescriptor { + label: Some("Depth Discard, Stencil Load"), + color_attachments: &[], + depth_stencil_attachment: Some(wgpu::RenderPassDepthStencilAttachment { + view: &texture.create_view(&wgpu::TextureViewDescriptor::default()), + depth_ops: Some(wgpu::Operations { + load: wgpu::LoadOp::Load, + store: false, // discard! + }), + stencil_ops: Some(wgpu::Operations { + load: wgpu::LoadOp::Clear(0), + store: true, + }), }), - stencil_ops: Some(wgpu::Operations { - load: wgpu::LoadOp::Load, - store: false, // discard! + }); + ctx.queue.submit([encoder.finish()]); + } + { + let mut encoder = ctx + .device + .create_command_encoder(&wgpu::CommandEncoderDescriptor::default()); + encoder.begin_render_pass(&wgpu::RenderPassDescriptor { + label: Some("Depth Load, Stencil Discard"), + color_attachments: &[], + depth_stencil_attachment: Some(wgpu::RenderPassDepthStencilAttachment { + view: &texture.create_view(&wgpu::TextureViewDescriptor::default()), + depth_ops: Some(wgpu::Operations { + load: wgpu::LoadOp::Clear(0.0), + store: true, + }), + stencil_ops: Some(wgpu::Operations { + load: wgpu::LoadOp::Load, + store: false, // discard! + }), }), - }), - }); - ctx.queue.submit([encoder.finish()]); - } - }); + }); + ctx.queue.submit([encoder.finish()]); + } + }, + ); } const TEXTURE_SIZE: wgpu::Extent3d = wgpu::Extent3d { From 97ef7a8f02747f5abaf34ce585b29809e4a8cc9f Mon Sep 17 00:00:00 2001 From: Mauro Gentile Date: Tue, 20 Sep 2022 07:51:22 +0200 Subject: [PATCH 09/10] Re-adding wrongly removed rustfmt::skip --- wgpu-types/src/lib.rs | 218 ++++++++++++++---------------------------- 1 file changed, 74 insertions(+), 144 deletions(-) diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index f1fdb99ece..e4d3411eeb 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -2163,6 +2163,7 @@ impl TextureFormat { let all_flags = TextureUsages::all(); // See for reference + #[rustfmt::skip] // lets make a nice table let ( required_features, sample_type, @@ -2174,168 +2175,97 @@ 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::Rgb9e5Ufloat => (native, float, linear, noaa, (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), + 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), + 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), + 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::Stencil8 => ( native, depth, linear, msaa, (1, 1), 1, attachment, 1), - Self::Depth16Unorm => (native, depth, linear, msaa, (1, 1), 2, attachment, 1), - Self::Depth24Plus => (native, depth, linear, msaa, (1, 1), 4, attachment, 1), - Self::Depth24PlusStencil8 => (d24_s8, depth, linear, msaa, (1, 1), 4, attachment, 2), - Self::Depth32Float => (native, depth, linear, msaa, (1, 1), 4, attachment, 1), - Self::Depth32FloatStencil8 => (d32_s8, depth, linear, msaa, (1, 1), 4, attachment, 2), + Self::Depth16Unorm => ( native, depth, linear, msaa, (1, 1), 2, attachment, 1), + Self::Depth24Plus => ( native, depth, linear, msaa, (1, 1), 4, attachment, 1), + Self::Depth24PlusStencil8 => ( d24_s8, depth, linear, msaa, (1, 1), 4, attachment, 2), + Self::Depth32Float => ( native, depth, linear, msaa, (1, 1), 4, attachment, 1), + Self::Depth32FloatStencil8 =>( d32_s8, depth, linear, msaa, (1, 1), 4, attachment, 2), + + // 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), + 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 } => { From bf61f184d611623723a195d54e918a19bbc6384c Mon Sep 17 00:00:00 2001 From: Mauro Gentile Date: Tue, 20 Sep 2022 16:43:51 +0200 Subject: [PATCH 10/10] Fixing format check --- wgpu-types/src/lib.rs | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index e4d3411eeb..ab00124f61 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -2179,7 +2179,6 @@ impl TextureFormat { 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), @@ -2188,7 +2187,6 @@ impl TextureFormat { 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), @@ -2203,11 +2201,9 @@ impl TextureFormat { 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), - // 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), @@ -2215,22 +2211,18 @@ impl TextureFormat { 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), - // Depth-stencil textures Self::Depth16Unorm => ( native, depth, linear, msaa, (1, 1), 2, attachment, 1), Self::Depth24Plus => ( native, depth, linear, msaa, (1, 1), 4, attachment, 1), Self::Depth24PlusStencil8 => ( d24_s8, depth, linear, msaa, (1, 1), 4, attachment, 2), Self::Depth32Float => ( native, depth, linear, msaa, (1, 1), 4, attachment, 1), Self::Depth32FloatStencil8 =>( d32_s8, depth, linear, msaa, (1, 1), 4, attachment, 2), - // 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), @@ -2238,7 +2230,6 @@ impl TextureFormat { 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), @@ -2254,7 +2245,6 @@ impl TextureFormat { 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), @@ -2266,7 +2256,6 @@ impl TextureFormat { 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 } => { let (feature, color_space) = match channel {