summaryrefslogtreecommitdiffstats
path: root/src/gui/rhi/qrhid3d11_p_p.h
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2022-07-15 11:07:34 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2022-08-03 19:06:19 +0200
commit3ee65daa74f36434b5a3d78b509247511d7867e1 (patch)
treea85fc15d9bf456948465c10d159f2b990cd6cdb1 /src/gui/rhi/qrhid3d11_p_p.h
parent71e3840f3a36eb176fe5896c4fbc888a00968ad3 (diff)
rhi: d3d: Switch to DirectComposition for semi-transparent windows
A window with alpha > 0 is no longer forced to using a legacy, non-flip swapchain. Instead, the Win8+ DirectComposition API is used in that case to get a properly composited semi-transparent window. The remainings of the non-flip model swapchain support, that was left after purging Windows 7 in order to support semi-transparent windows, is now gone completely. Setting QT_D3D_NO_FLIP has no effect from now on. DXGIFactory2 and flip model swapchains are now always required and in use. There is one downside when it comes to the swap effect: for semi-transparent windows we will be stuck with SCALING_STRETCH as SCALING_NONE is not supported on this path. Using NONE over STRETCH was preferable for typical Qt applications because user interfaces typically look "nicer" during resize without stretching when ending up with a size-mismatched Present. For normal (non-translucent) windows this will continue to be the case, but enabling alpha will now move back to SCALING_STRETCH implicitly. In addition, it looks like AlphaMode is ignored when using CreateSwapChainForComposition. Setting DXGI_ALPHA_MODE_STRAIGHT fails always whereas other values lead to an identical looking (with transparency) result. Therefore we just set it to DXGI_ALPHA_MODE_PREMULTIPLIED regaredless of which QRhiSwapChain alpha flag is set. Fixes: QTBUG-105271 Change-Id: Ie7a584e1656ccfdb506489ea21c41706f57c4018 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/gui/rhi/qrhid3d11_p_p.h')
-rw-r--r--src/gui/rhi/qrhid3d11_p_p.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/gui/rhi/qrhid3d11_p_p.h b/src/gui/rhi/qrhid3d11_p_p.h
index 46e8d658f3..50ea3fbbfe 100644
--- a/src/gui/rhi/qrhid3d11_p_p.h
+++ b/src/gui/rhi/qrhid3d11_p_p.h
@@ -22,6 +22,7 @@
#include <d3d11_1.h>
#include <dxgi1_6.h>
+#include <dcomp.h>
QT_BEGIN_NAMESPACE
@@ -551,6 +552,8 @@ struct QD3D11SwapChain : public QRhiSwapChain
ID3D11Query *timestampDisjointQuery[BUFFER_COUNT];
ID3D11Query *timestampQuery[BUFFER_COUNT * 2];
UINT swapInterval = 1;
+ IDCompositionTarget *dcompTarget = nullptr;
+ IDCompositionVisual *dcompVisual = nullptr;
};
class QRhiD3D11 : public QRhiImplementation
@@ -681,6 +684,7 @@ public:
void clearShaderCache();
QByteArray compileHlslShaderSource(const QShader &shader, QShader::Variant shaderVariant, uint flags,
QString *error, QShaderKey *usedShaderKey);
+ bool ensureDirectCompositionDevice();
QRhi::Flags rhiFlags;
bool debugLayer = false;
@@ -692,7 +696,7 @@ public:
ID3DUserDefinedAnnotation *annotations = nullptr;
IDXGIAdapter1 *activeAdapter = nullptr;
IDXGIFactory1 *dxgiFactory = nullptr;
- bool supportsFlipSwapchain = false;
+ IDCompositionDevice *dcompDevice = nullptr;
bool supportsAllowTearing = false;
bool forceFlipDiscard = false;
bool deviceLost = false;