mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
Merge #1744
1744: hal/dx12: fix depth formats and pipeline layout r=kvark a=kvark **Connections** Closes #1727 **Description** There were 2 problems. One was that the reversing of the pipeline layout was done wrong (again). I don't know how it still worked on one of my machines :/ The other was that the backend relied on the depth format reinterpretation without using a typeless format. This is OK on higher-level platforms, but we should be doing it more careful. I tried to approach this maximally efficient: we only use the typeless format if all of the following are true: 1. it's a depth/stencil format 2. it needs to be seen as SRV/UAV So in the case of a simple depth texture, we are still going to be using a fully-qualified format, and therefore get all of the benefit of HW compression on it. **Testing** Ran the examples on Intel Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com>
This commit is contained in:
commit
c1a305c006
@ -121,6 +121,9 @@ impl super::Adapter {
|
|||||||
hr == 0 && features2.DepthBoundsTestSupported != 0
|
hr == 0 && features2.DepthBoundsTestSupported != 0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Note: `D3D12_FEATURE_D3D12_OPTIONS3::CastingFullyTypedFormatSupported` can be checked
|
||||||
|
// to know if we can skip "typeless" formats entirely.
|
||||||
|
|
||||||
let private_caps = super::PrivateCapabilities {
|
let private_caps = super::PrivateCapabilities {
|
||||||
instance_flags,
|
instance_flags,
|
||||||
heterogeneous_resource_heaps: options.ResourceHeapTier
|
heterogeneous_resource_heaps: options.ResourceHeapTier
|
||||||
|
|||||||
@ -129,6 +129,16 @@ 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::Depth32Float => dxgiformat::DXGI_FORMAT_R32_TYPELESS,
|
||||||
|
wgt::TextureFormat::Depth24Plus | wgt::TextureFormat::Depth24PlusStencil8 => {
|
||||||
|
dxgiformat::DXGI_FORMAT_R24G8_TYPELESS
|
||||||
|
}
|
||||||
|
_ => unreachable!(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn map_index_format(format: wgt::IndexFormat) -> dxgiformat::DXGI_FORMAT {
|
pub fn map_index_format(format: wgt::IndexFormat) -> dxgiformat::DXGI_FORMAT {
|
||||||
match format {
|
match format {
|
||||||
wgt::IndexFormat::Uint16 => dxgiformat::DXGI_FORMAT_R16_UINT,
|
wgt::IndexFormat::Uint16 => dxgiformat::DXGI_FORMAT_R16_UINT,
|
||||||
|
|||||||
@ -393,8 +393,20 @@ impl crate::Device<super::Api> for super::Device {
|
|||||||
Height: desc.size.height,
|
Height: desc.size.height,
|
||||||
DepthOrArraySize: desc.size.depth_or_array_layers as u16,
|
DepthOrArraySize: desc.size.depth_or_array_layers as u16,
|
||||||
MipLevels: desc.mip_level_count as u16,
|
MipLevels: desc.mip_level_count as u16,
|
||||||
//TODO: map to surface format to allow view casting
|
Format: if crate::FormatAspects::from(desc.format).contains(crate::FormatAspects::COLOR)
|
||||||
Format: conv::map_texture_format(desc.format),
|
|| !desc.usage.intersects(
|
||||||
|
crate::TextureUses::RESOURCE
|
||||||
|
| crate::TextureUses::STORAGE_READ
|
||||||
|
| crate::TextureUses::STORAGE_WRITE,
|
||||||
|
) {
|
||||||
|
conv::map_texture_format(desc.format)
|
||||||
|
} else {
|
||||||
|
// This branch is needed if it's a depth texture, and it's ever needed to be viewed as SRV or UAV,
|
||||||
|
// because then we'd create a non-depth format view of it.
|
||||||
|
// Note: we can skip this branch if
|
||||||
|
// `D3D12_FEATURE_D3D12_OPTIONS3::CastingFullyTypedFormatSupported`
|
||||||
|
conv::map_texture_format_depth_typeless(desc.format)
|
||||||
|
},
|
||||||
SampleDesc: dxgitype::DXGI_SAMPLE_DESC {
|
SampleDesc: dxgitype::DXGI_SAMPLE_DESC {
|
||||||
Count: desc.sample_count,
|
Count: desc.sample_count,
|
||||||
Quality: 0,
|
Quality: 0,
|
||||||
@ -912,6 +924,8 @@ impl crate::Device<super::Api> for super::Device {
|
|||||||
bind_group_infos.push(info);
|
bind_group_infos.push(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Note: we populated them in reverse
|
||||||
|
bind_group_infos.reverse();
|
||||||
// Ensure that we didn't reallocate!
|
// Ensure that we didn't reallocate!
|
||||||
debug_assert_eq!(ranges.len(), total_non_dynamic_entries);
|
debug_assert_eq!(ranges.len(), total_non_dynamic_entries);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user