From 36d2fb1f9f5b8887cc901b7803b81aef459d87be Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 22 Feb 2024 18:31:25 +0100 Subject: [PATCH] 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 (cherry picked from commit 51106995cbf51af0c92b34119f6d254568a67540) Reviewed-by: Qt Cherry-pick Bot --- src/gui/rhi/qrhid3d11.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index a233d7ce5bd..e2dc53f3394 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -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: