From c91cae47d23c3db3c83b4deda46af67acbe8091b Mon Sep 17 00:00:00 2001 From: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com> Date: Tue, 20 Dec 2022 15:29:43 +0100 Subject: [PATCH] [dxgi] fix `depth16Unorm` formats for nodepth and typeless (#3313) * [dxgi] fix `depth16Unorm` formats for nodepth and typeless * add changelog entry --- CHANGELOG.md | 4 ++++ wgpu-hal/src/auxil/dxgi/conv.rs | 11 ++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42e7a686c2..55d18bacea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -188,6 +188,10 @@ Additionally `Surface::get_default_config` now returns an Option and returns Non - Update ash to 0.37.1+1.3.235 to fix CI breaking by changing a call to the deprecated `debug_utils_set_object_name()` function to `set_debug_utils_object_name()` by @elabajaba in [#3273](https://github.com/gfx-rs/wgpu/pull/3273) +#### DX12 + +- Fix `depth16Unorm` formats by @teoxoy in [#3313](https://github.com/gfx-rs/wgpu/pull/3313) + ### Examples - Log adapter info in hello example on wasm target by @JolifantoBambla in [#2858](https://github.com/gfx-rs/wgpu/pull/2858) diff --git a/wgpu-hal/src/auxil/dxgi/conv.rs b/wgpu-hal/src/auxil/dxgi/conv.rs index 8eddf7678b..887a9670a4 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_D24_UNORM_S8_UINT, Tf::Depth16Unorm => DXGI_FORMAT_D16_UNORM, Tf::Depth24Plus => DXGI_FORMAT_D24_UNORM_S8_UINT, Tf::Depth24PlusStencil8 => DXGI_FORMAT_D24_UNORM_S8_UINT, @@ -101,12 +101,10 @@ pub fn map_texture_format_nosrgb(format: wgt::TextureFormat) -> dxgiformat::DXGI } } -//Note: SRV and UAV can't use the depth formats directly -//TODO: stencil views? +// Note: SRV and UAV can't use the depth formats directly 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::Depth16Unorm => dxgiformat::DXGI_FORMAT_R16_UNORM, wgt::TextureFormat::Depth32Float => dxgiformat::DXGI_FORMAT_R32_FLOAT, wgt::TextureFormat::Depth32FloatStencil8 => { dxgiformat::DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS @@ -126,8 +124,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::Depth16Unorm => dxgiformat::DXGI_FORMAT_D16_UNORM, + wgt::TextureFormat::Depth16Unorm => dxgiformat::DXGI_FORMAT_R16_TYPELESS, wgt::TextureFormat::Depth32Float => dxgiformat::DXGI_FORMAT_R32_TYPELESS, wgt::TextureFormat::Depth32FloatStencil8 => dxgiformat::DXGI_FORMAT_R32G8X24_TYPELESS, wgt::TextureFormat::Depth24Plus | wgt::TextureFormat::Depth24PlusStencil8 => {