diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2022-01-05 15:48:46 +0100 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2022-01-11 22:38:35 +0100 |
commit | cdfbe7092304c3677e8fae95892f53852a90adfc (patch) | |
tree | bd6cb326fd2d0cf3edbb9254021f2d4f36efbb75 /src/gui/rhi/qrhid3d11.cpp | |
parent | 0be28d103089a1c5e196e6e722878f495dfc53ce (diff) |
rhi: Improve the handling of HDR capable texture formats
Add some sort of autotest for both RGBA16F and the new RGB10A2. The
latter is introduced particularly because ideally we should have a
texture format that corresponds to the D3D/Vulkan swapchain color
buffer format with HDR10.
Change-Id: I1e1bbb7c7e32cb3db89275900811c0bcaeac39d6
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/gui/rhi/qrhid3d11.cpp')
-rw-r--r-- | src/gui/rhi/qrhid3d11.cpp | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index eaaf0c6991..04544bc3b2 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -1237,6 +1237,9 @@ static inline DXGI_FORMAT toD3DTextureFormat(QRhiTexture::Format format, QRhiTex case QRhiTexture::R32F: return DXGI_FORMAT_R32_FLOAT; + case QRhiTexture::RGB10A2: + return DXGI_FORMAT_R10G10B10A2_UNORM; + case QRhiTexture::D16: return DXGI_FORMAT_R16_TYPELESS; case QRhiTexture::D24: @@ -1290,7 +1293,7 @@ static inline DXGI_FORMAT toD3DTextureFormat(QRhiTexture::Format format, QRhiTex } } -static inline QRhiTexture::Format colorTextureFormatFromDxgiFormat(DXGI_FORMAT format, QRhiTexture::Flags *flags) +static inline QRhiTexture::Format swapchainReadbackTextureFormat(DXGI_FORMAT format, QRhiTexture::Flags *flags) { switch (format) { case DXGI_FORMAT_R8G8B8A8_UNORM: @@ -1305,16 +1308,14 @@ static inline QRhiTexture::Format colorTextureFormatFromDxgiFormat(DXGI_FORMAT f if (flags) (*flags) |= QRhiTexture::sRGB; return QRhiTexture::BGRA8; - case DXGI_FORMAT_R8_UNORM: - return QRhiTexture::R8; - case DXGI_FORMAT_R8G8_UNORM: - return QRhiTexture::RG8; - case DXGI_FORMAT_R16_UNORM: - return QRhiTexture::R16; - case DXGI_FORMAT_R16G16_UNORM: - return QRhiTexture::RG16; - default: // this cannot assert, must warn and return unknown - qWarning("DXGI_FORMAT %d is not a recognized uncompressed color format", format); + case DXGI_FORMAT_R16G16B16A16_FLOAT: + return QRhiTexture::RGBA16F; + case DXGI_FORMAT_R32G32B32A32_FLOAT: + return QRhiTexture::RGBA32F; + case DXGI_FORMAT_R10G10B10A2_UNORM: + return QRhiTexture::RGB10A2; + default: + qWarning("DXGI_FORMAT %d cannot be read back", format); break; } return QRhiTexture::UnknownFormat; @@ -1594,7 +1595,7 @@ void QRhiD3D11::enqueueResourceUpdates(QRhiCommandBuffer *cb, QRhiResourceUpdate src = swapChainD->backBufferTex; dxgiFormat = swapChainD->colorFormat; pixelSize = swapChainD->pixelSize; - format = colorTextureFormatFromDxgiFormat(dxgiFormat, nullptr); + format = swapchainReadbackTextureFormat(dxgiFormat, nullptr); if (format == QRhiTexture::UnknownFormat) continue; } |