rhi: d3d11: Fix depth texture by porting from the d3d12 backend

The newer D3D12 backend uses DXGI formats (for the texture, DSV, SRV)
that actually work. Backport these to the D3D11 backend. Otherwise
attempting to create a render target with a D24 or D24S8 QRhiTexture
as the depth/stencil buffer won't work.

In practice this is rarely exercised since the depth-stencil is
typically a QRhiRenderBuffer that maps to a
DXGI_FORMAT_D24_UNORM_S8_UINT texture but without
D3D11_BIND_SHADER_RESOURCE. Whereas textures get the latter flag,
and things break down. At least now the usage of typeless and
typed format is uniform. It could still be questioned if D24
should actually use R24G8_TYPELESS or if the original was fine,
but for now just sync with the D3D12 backend.

Pick-to: 6.6
Change-Id: I8a0564fc42a7866dae90f49f7b557c83dffc4d6e
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
(cherry picked from commit 51106995cbf51af0c92b34119f6d254568a67540)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Laszlo Agocs 2024-02-22 18:31:25 +01:00 committed by Qt Cherry-pick Bot
parent aaba67eea9
commit 36d2fb1f9f

View File

@ -1521,9 +1521,9 @@ static inline DXGI_FORMAT toD3DTextureFormat(QRhiTexture::Format format, QRhiTex
case QRhiTexture::D16:
return DXGI_FORMAT_R16_TYPELESS;
case QRhiTexture::D24:
return DXGI_FORMAT_R24_UNORM_X8_TYPELESS;
return DXGI_FORMAT_R24G8_TYPELESS;
case QRhiTexture::D24S8:
return DXGI_FORMAT_D24_UNORM_S8_UINT;
return DXGI_FORMAT_R24G8_TYPELESS;
case QRhiTexture::D32F:
return DXGI_FORMAT_R32_TYPELESS;
@ -3236,7 +3236,7 @@ static inline DXGI_FORMAT toD3DDepthTextureDSVFormat(QRhiTexture::Format format)
case QRhiTexture::Format::D16:
return DXGI_FORMAT_D16_UNORM;
case QRhiTexture::Format::D24:
return DXGI_FORMAT_R24_UNORM_X8_TYPELESS;
return DXGI_FORMAT_D24_UNORM_S8_UINT;
case QRhiTexture::Format::D24S8:
return DXGI_FORMAT_D24_UNORM_S8_UINT;
case QRhiTexture::Format::D32F: