Skip to content

Commit c91cae4

Browse files
authored
[dxgi] fix depth16Unorm formats for nodepth and typeless (#3313)
* [dxgi] fix `depth16Unorm` formats for nodepth and typeless * add changelog entry
1 parent 14886ee commit c91cae4

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,10 @@ Additionally `Surface::get_default_config` now returns an Option and returns Non
188188

189189
- 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)
190190

191+
#### DX12
192+
193+
- Fix `depth16Unorm` formats by @teoxoy in [#3313](https://github.com/gfx-rs/wgpu/pull/3313)
194+
191195
### Examples
192196

193197
- Log adapter info in hello example on wasm target by @JolifantoBambla in [#2858](https://github.com/gfx-rs/wgpu/pull/2858)

wgpu-hal/src/auxil/dxgi/conv.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub fn map_texture_format_failable(format: wgt::TextureFormat) -> Option<dxgifor
4747
Tf::Rgba32Uint => DXGI_FORMAT_R32G32B32A32_UINT,
4848
Tf::Rgba32Sint => DXGI_FORMAT_R32G32B32A32_SINT,
4949
Tf::Rgba32Float => DXGI_FORMAT_R32G32B32A32_FLOAT,
50-
//Tf::Stencil8 => DXGI_FORMAT_R8_UNORM,
50+
// Tf::Stencil8 => DXGI_FORMAT_D24_UNORM_S8_UINT,
5151
Tf::Depth16Unorm => DXGI_FORMAT_D16_UNORM,
5252
Tf::Depth24Plus => DXGI_FORMAT_D24_UNORM_S8_UINT,
5353
Tf::Depth24PlusStencil8 => DXGI_FORMAT_D24_UNORM_S8_UINT,
@@ -101,12 +101,10 @@ pub fn map_texture_format_nosrgb(format: wgt::TextureFormat) -> dxgiformat::DXGI
101101
}
102102
}
103103

104-
//Note: SRV and UAV can't use the depth formats directly
105-
//TODO: stencil views?
104+
// Note: SRV and UAV can't use the depth formats directly
106105
pub fn map_texture_format_nodepth(format: wgt::TextureFormat) -> dxgiformat::DXGI_FORMAT {
107106
match format {
108-
//wgt::TextureFormat::Stencil8 => dxgiformat::DXGI_FORMAT_R8_UNORM,
109-
wgt::TextureFormat::Depth16Unorm => dxgiformat::DXGI_FORMAT_D16_UNORM,
107+
wgt::TextureFormat::Depth16Unorm => dxgiformat::DXGI_FORMAT_R16_UNORM,
110108
wgt::TextureFormat::Depth32Float => dxgiformat::DXGI_FORMAT_R32_FLOAT,
111109
wgt::TextureFormat::Depth32FloatStencil8 => {
112110
dxgiformat::DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS
@@ -126,8 +124,7 @@ pub fn map_texture_format_nodepth(format: wgt::TextureFormat) -> dxgiformat::DXG
126124

127125
pub fn map_texture_format_depth_typeless(format: wgt::TextureFormat) -> dxgiformat::DXGI_FORMAT {
128126
match format {
129-
//wgt::TextureFormat::Stencil8 => dxgiformat::DXGI_FORMAT_R8_UNORM,
130-
wgt::TextureFormat::Depth16Unorm => dxgiformat::DXGI_FORMAT_D16_UNORM,
127+
wgt::TextureFormat::Depth16Unorm => dxgiformat::DXGI_FORMAT_R16_TYPELESS,
131128
wgt::TextureFormat::Depth32Float => dxgiformat::DXGI_FORMAT_R32_TYPELESS,
132129
wgt::TextureFormat::Depth32FloatStencil8 => dxgiformat::DXGI_FORMAT_R32G8X24_TYPELESS,
133130
wgt::TextureFormat::Depth24Plus | wgt::TextureFormat::Depth24PlusStencil8 => {

0 commit comments

Comments
 (0)