diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-04-28 18:15:03 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-04-29 22:36:00 +0200 |
commit | 1c0a7a87e9e8dd630d35b2c3e57d45c42f6d12bd (patch) | |
tree | 6bba3482a817ecf5dcd732de633131e0b0a9416e /src/gui/rhi/qrhid3d11.cpp | |
parent | f2347077f503d103974636cae9319d127714e2e4 (diff) |
rhi: Add backing format hint to QRhiRenderBuffer
Task-number: QTBUG-83707
Change-Id: I63548f4ace70af614a2aa082663bb3ae9fbedc25
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'src/gui/rhi/qrhid3d11.cpp')
-rw-r--r-- | src/gui/rhi/qrhid3d11.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index c3c40b4cc4..8336d43ff6 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -528,9 +528,10 @@ bool QRhiD3D11::isDeviceLost() const } QRhiRenderBuffer *QRhiD3D11::createRenderBuffer(QRhiRenderBuffer::Type type, const QSize &pixelSize, - int sampleCount, QRhiRenderBuffer::Flags flags) + int sampleCount, QRhiRenderBuffer::Flags flags, + QRhiTexture::Format backingFormatHint) { - return new QD3D11RenderBuffer(this, type, pixelSize, sampleCount, flags); + return new QD3D11RenderBuffer(this, type, pixelSize, sampleCount, flags, backingFormatHint); } QRhiTexture *QRhiD3D11::createTexture(QRhiTexture::Format format, const QSize &pixelSize, @@ -2613,8 +2614,9 @@ ID3D11UnorderedAccessView *QD3D11Buffer::unorderedAccessView() } QD3D11RenderBuffer::QD3D11RenderBuffer(QRhiImplementation *rhi, Type type, const QSize &pixelSize, - int sampleCount, QRhiRenderBuffer::Flags flags) - : QRhiRenderBuffer(rhi, type, pixelSize, sampleCount, flags) + int sampleCount, QRhiRenderBuffer::Flags flags, + QRhiTexture::Format backingFormatHint) + : QRhiRenderBuffer(rhi, type, pixelSize, sampleCount, flags, backingFormatHint) { } @@ -2668,7 +2670,8 @@ bool QD3D11RenderBuffer::build() desc.Usage = D3D11_USAGE_DEFAULT; if (m_type == Color) { - dxgiFormat = DXGI_FORMAT_R8G8B8A8_UNORM; + dxgiFormat = m_backingFormatHint == QRhiTexture::UnknownFormat ? DXGI_FORMAT_R8G8B8A8_UNORM + : toD3DTextureFormat(m_backingFormatHint, {}); desc.Format = dxgiFormat; desc.BindFlags = D3D11_BIND_RENDER_TARGET; HRESULT hr = rhiD->dev->CreateTexture2D(&desc, nullptr, &tex); @@ -2721,7 +2724,10 @@ bool QD3D11RenderBuffer::build() QRhiTexture::Format QD3D11RenderBuffer::backingFormat() const { - return m_type == Color ? QRhiTexture::RGBA8 : QRhiTexture::UnknownFormat; + if (m_backingFormatHint != QRhiTexture::UnknownFormat) + return m_backingFormatHint; + else + return m_type == Color ? QRhiTexture::RGBA8 : QRhiTexture::UnknownFormat; } QD3D11Texture::QD3D11Texture(QRhiImplementation *rhi, Format format, const QSize &pixelSize, |