Skip to content

Commit 4707969

Browse files
committed
Qt 6.6.3 support (brought changes from 6.6.3)
1 parent b02fa3e commit 4707969

File tree

6 files changed

+52
-66
lines changed

6 files changed

+52
-66
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
This is Qt 6.6.2 backport that runs on Windows 7 (what?). The repository contains patched source files from the qtbase module.
1+
This is Qt 6.6.3 backport that runs on Windows 7 (what?). The repository contains patched source files from the qtbase module.
22
Approach is based on this [forum thread](https://forum.qt.io/topic/133002/qt-creator-6-0-1-and-qt-6-2-2-running-on-windows-7/60) but better: many improvements amongst important fallbacks to default Qt 6 behaviour when running on newer Windows.
33

44
You can use [our prebuild binaries](https://github.com/crystalidea/qt6windows7/releases) (we used Visual C++ 2019 with OpenSSL 3.0.13 statically linked, see [compile_win.pl](https://github.com/crystalidea/qt-build-tools/tree/master/6.6.2) script) or compile Qt yourself.

qtbase/src/gui/rhi/qrhid3d11.cpp

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -437,19 +437,13 @@ QList<int> QRhiD3D11::supportedSampleCounts() const
437437
return { 1, 2, 4, 8 };
438438
}
439439

440-
DXGI_SAMPLE_DESC QRhiD3D11::effectiveSampleCount(int sampleCount) const
440+
DXGI_SAMPLE_DESC QRhiD3D11::effectiveSampleDesc(int sampleCount) const
441441
{
442442
DXGI_SAMPLE_DESC desc;
443443
desc.Count = 1;
444444
desc.Quality = 0;
445445

446-
// Stay compatible with QSurfaceFormat and friends where samples == 0 means the same as 1.
447-
int s = qBound(1, sampleCount, 64);
448-
449-
if (!supportedSampleCounts().contains(s)) {
450-
qWarning("Attempted to set unsupported sample count %d", sampleCount);
451-
return desc;
452-
}
446+
const int s = effectiveSampleCount(sampleCount);
453447

454448
desc.Count = UINT(s);
455449
if (s > 1)
@@ -1461,9 +1455,9 @@ static inline DXGI_FORMAT toD3DTextureFormat(QRhiTexture::Format format, QRhiTex
14611455
case QRhiTexture::D16:
14621456
return DXGI_FORMAT_R16_TYPELESS;
14631457
case QRhiTexture::D24:
1464-
return DXGI_FORMAT_R24_UNORM_X8_TYPELESS;
1458+
return DXGI_FORMAT_R24G8_TYPELESS;
14651459
case QRhiTexture::D24S8:
1466-
return DXGI_FORMAT_D24_UNORM_S8_UINT;
1460+
return DXGI_FORMAT_R24G8_TYPELESS;
14671461
case QRhiTexture::D32F:
14681462
return DXGI_FORMAT_R32_TYPELESS;
14691463

@@ -3043,7 +3037,7 @@ bool QD3D11RenderBuffer::create()
30433037
return false;
30443038

30453039
QRHI_RES_RHI(QRhiD3D11);
3046-
sampleDesc = rhiD->effectiveSampleCount(m_sampleCount);
3040+
sampleDesc = rhiD->effectiveSampleDesc(m_sampleCount);
30473041

30483042
D3D11_TEXTURE2D_DESC desc = {};
30493043
desc.Width = UINT(m_pixelSize.width());
@@ -3185,7 +3179,7 @@ static inline DXGI_FORMAT toD3DDepthTextureDSVFormat(QRhiTexture::Format format)
31853179
case QRhiTexture::Format::D16:
31863180
return DXGI_FORMAT_D16_UNORM;
31873181
case QRhiTexture::Format::D24:
3188-
return DXGI_FORMAT_R24_UNORM_X8_TYPELESS;
3182+
return DXGI_FORMAT_D24_UNORM_S8_UINT;
31893183
case QRhiTexture::Format::D24S8:
31903184
return DXGI_FORMAT_D24_UNORM_S8_UINT;
31913185
case QRhiTexture::Format::D32F:
@@ -3214,7 +3208,7 @@ bool QD3D11Texture::prepareCreate(QSize *adjustedSize)
32143208
QRHI_RES_RHI(QRhiD3D11);
32153209
dxgiFormat = toD3DTextureFormat(m_format, m_flags);
32163210
mipLevelCount = uint(hasMipMaps ? rhiD->q->mipLevelsForSize(size) : 1);
3217-
sampleDesc = rhiD->effectiveSampleCount(m_sampleCount);
3211+
sampleDesc = rhiD->effectiveSampleDesc(m_sampleCount);
32183212
if (sampleDesc.Count > 1) {
32193213
if (isCube) {
32203214
qWarning("Cubemap texture cannot be multisample");
@@ -4390,7 +4384,7 @@ bool QD3D11GraphicsPipeline::create()
43904384
rastDesc.SlopeScaledDepthBias = m_slopeScaledDepthBias;
43914385
rastDesc.DepthClipEnable = true;
43924386
rastDesc.ScissorEnable = m_flags.testFlag(UsesScissor);
4393-
rastDesc.MultisampleEnable = rhiD->effectiveSampleCount(m_sampleCount).Count > 1;
4387+
rastDesc.MultisampleEnable = rhiD->effectiveSampleDesc(m_sampleCount).Count > 1;
43944388
HRESULT hr = rhiD->dev->CreateRasterizerState(&rastDesc, &rastState);
43954389
if (FAILED(hr)) {
43964390
qWarning("Failed to create rasterizer state: %s",
@@ -4857,8 +4851,12 @@ void QD3D11SwapChain::destroy()
48574851
}
48584852

48594853
QRHI_RES_RHI(QRhiD3D11);
4860-
if (rhiD)
4854+
if (rhiD) {
48614855
rhiD->unregisterResource(this);
4856+
// See Deferred Destruction Issues with Flip Presentation Swap Chains in
4857+
// https://learn.microsoft.com/en-us/windows/win32/api/d3d11/nf-d3d11-id3d11devicecontext-flush
4858+
rhiD->context->Flush();
4859+
}
48624860
}
48634861

48644862
QRhiCommandBuffer *QD3D11SwapChain::currentFrameCommandBuffer()
@@ -5074,7 +5072,7 @@ bool QD3D11SwapChain::createOrResize()
50745072
swapChainFlags |= DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING;
50755073

50765074
if (!swapChain) {
5077-
sampleDesc = rhiD->effectiveSampleCount(m_sampleCount);
5075+
sampleDesc = rhiD->effectiveSampleDesc(m_sampleCount);
50785076
colorFormat = DEFAULT_FORMAT;
50795077
srgbAdjustedColorFormat = m_flags.testFlag(sRGB) ? DEFAULT_SRGB_FORMAT : DEFAULT_FORMAT;
50805078

@@ -5187,8 +5185,11 @@ bool QD3D11SwapChain::createOrResize()
51875185
}
51885186
}
51895187
if (FAILED(hr)) {
5190-
qWarning("Failed to create D3D11 swapchain: %s",
5191-
qPrintable(QSystemError::windowsComString(hr)));
5188+
qWarning("Failed to create D3D11 swapchain: %s"
5189+
" (Width=%u Height=%u Format=%u SampleCount=%u BufferCount=%u Scaling=%u SwapEffect=%u Stereo=%u)",
5190+
qPrintable(QSystemError::windowsComString(hr)),
5191+
desc.Width, desc.Height, UINT(desc.Format), desc.SampleDesc.Count,
5192+
desc.BufferCount, UINT(desc.Scaling), UINT(desc.SwapEffect), UINT(desc.Stereo));
51925193
return false;
51935194
}
51945195
} else {

qtbase/src/gui/rhi/qrhid3d11_p.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ class QRhiD3D11 : public QRhiImplementation
738738
bool offsetOnlyChange);
739739
void resetShaderResources();
740740
void executeCommandBuffer(QD3D11CommandBuffer *cbD, QD3D11SwapChain *timestampSwapChain = nullptr);
741-
DXGI_SAMPLE_DESC effectiveSampleCount(int sampleCount) const;
741+
DXGI_SAMPLE_DESC effectiveSampleDesc(int sampleCount) const;
742742
void finishActiveReadbacks();
743743
void reportLiveObjects(ID3D11Device *device);
744744
void clearShaderCache();

qtbase/src/gui/rhi/qrhid3d12.cpp

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -469,8 +469,10 @@ void QRhiD3D12::destroy()
469469
cbvSrvUavPool.destroy();
470470

471471
for (int i = 0; i < QD3D12_FRAMES_IN_FLIGHT; ++i) {
472-
cmdAllocators[i]->Release();
473-
cmdAllocators[i] = nullptr;
472+
if (cmdAllocators[i]) {
473+
cmdAllocators[i]->Release();
474+
cmdAllocators[i] = nullptr;
475+
}
474476
}
475477

476478
if (fullFenceEvent) {
@@ -1505,6 +1507,10 @@ QRhi::FrameOpResult QRhiD3D12::endFrame(QRhiSwapChain *swapChain, QRhi::EndFrame
15051507
{
15061508
presentFlags |= DXGI_PRESENT_ALLOW_TEARING;
15071509
}
1510+
if (!swapChainD->swapChain) {
1511+
qWarning("Failed to present, no swapchain");
1512+
return QRhi::FrameOpError;
1513+
}
15081514
HRESULT hr = swapChainD->swapChain->Present(swapChainD->swapInterval, presentFlags);
15091515
if (hr == DXGI_ERROR_DEVICE_REMOVED || hr == DXGI_ERROR_DEVICE_RESET) {
15101516
qWarning("Device loss detected in Present()");
@@ -2913,24 +2919,18 @@ void QRhiD3D12::waitGpu()
29132919
}
29142920
}
29152921

2916-
DXGI_SAMPLE_DESC QRhiD3D12::effectiveSampleCount(int sampleCount, DXGI_FORMAT format) const
2922+
DXGI_SAMPLE_DESC QRhiD3D12::effectiveSampleDesc(int sampleCount, DXGI_FORMAT format) const
29172923
{
29182924
DXGI_SAMPLE_DESC desc;
29192925
desc.Count = 1;
29202926
desc.Quality = 0;
29212927

2922-
// Stay compatible with QSurfaceFormat and friends where samples == 0 means the same as 1.
2923-
int s = qBound(1, sampleCount, 64);
2924-
2925-
if (!supportedSampleCounts().contains(s)) {
2926-
qWarning("Attempted to set unsupported sample count %d", sampleCount);
2927-
return desc;
2928-
}
2928+
const int s = effectiveSampleCount(sampleCount);
29292929

29302930
if (s > 1) {
29312931
D3D12_FEATURE_DATA_MULTISAMPLE_QUALITY_LEVELS msaaInfo = {};
29322932
msaaInfo.Format = format;
2933-
msaaInfo.SampleCount = s;
2933+
msaaInfo.SampleCount = UINT(s);
29342934
if (SUCCEEDED(dev->CheckFeatureSupport(D3D12_FEATURE_MULTISAMPLE_QUALITY_LEVELS, &msaaInfo, sizeof(msaaInfo)))) {
29352935
if (msaaInfo.NumQualityLevels > 0) {
29362936
desc.Count = UINT(s);
@@ -3801,7 +3801,7 @@ bool QD3D12RenderBuffer::create()
38013801
case QRhiRenderBuffer::Color:
38023802
{
38033803
dxgiFormat = toD3DTextureFormat(backingFormat(), {});
3804-
sampleDesc = rhiD->effectiveSampleCount(m_sampleCount, dxgiFormat);
3804+
sampleDesc = rhiD->effectiveSampleDesc(m_sampleCount, dxgiFormat);
38053805
D3D12_RESOURCE_DESC resourceDesc = {};
38063806
resourceDesc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
38073807
resourceDesc.Width = UINT64(m_pixelSize.width());
@@ -3842,7 +3842,7 @@ bool QD3D12RenderBuffer::create()
38423842
case QRhiRenderBuffer::DepthStencil:
38433843
{
38443844
dxgiFormat = DS_FORMAT;
3845-
sampleDesc = rhiD->effectiveSampleCount(m_sampleCount, dxgiFormat);
3845+
sampleDesc = rhiD->effectiveSampleDesc(m_sampleCount, dxgiFormat);
38463846
D3D12_RESOURCE_DESC resourceDesc = {};
38473847
resourceDesc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
38483848
resourceDesc.Width = UINT64(m_pixelSize.width());
@@ -3998,7 +3998,7 @@ bool QD3D12Texture::prepareCreate(QSize *adjustedSize)
39983998
QRHI_RES_RHI(QRhiD3D12);
39993999
dxgiFormat = toD3DTextureFormat(m_format, m_flags);
40004000
mipLevelCount = uint(hasMipMaps ? rhiD->q->mipLevelsForSize(size) : 1);
4001-
sampleDesc = rhiD->effectiveSampleCount(m_sampleCount, dxgiFormat);
4001+
sampleDesc = rhiD->effectiveSampleDesc(m_sampleCount, dxgiFormat);
40024002
if (sampleDesc.Count > 1) {
40034003
if (isCube) {
40044004
qWarning("Cubemap texture cannot be multisample");
@@ -4152,7 +4152,7 @@ bool QD3D12Texture::create()
41524152

41534153
bool needsOptimizedClearValueSpecified = false;
41544154
UINT resourceFlags = 0;
4155-
if (m_flags.testFlag(RenderTarget)) {
4155+
if (m_flags.testFlag(RenderTarget) || sampleDesc.Count > 1) {
41564156
if (isDepth)
41574157
resourceFlags |= D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL;
41584158
else
@@ -5328,7 +5328,7 @@ bool QD3D12GraphicsPipeline::create()
53285328
}
53295329

53305330
QD3D12RenderPassDescriptor *rpD = QRHI_RES(QD3D12RenderPassDescriptor, m_renderPassDesc);
5331-
const DXGI_SAMPLE_DESC sampleDesc = rhiD->effectiveSampleCount(m_sampleCount, DXGI_FORMAT(rpD->colorFormat[0]));
5331+
const DXGI_SAMPLE_DESC sampleDesc = rhiD->effectiveSampleDesc(m_sampleCount, DXGI_FORMAT(rpD->colorFormat[0]));
53325332

53335333
D3D12_GRAPHICS_PIPELINE_STATE_DESC psoDesc = {};
53345334
psoDesc.pRootSignature = rootSig;
@@ -5951,7 +5951,7 @@ void QD3D12SwapChain::chooseFormats()
59515951
"(or Use HDR is Off in the Display Settings), ignoring HDR format request");
59525952
}
59535953
}
5954-
sampleDesc = rhiD->effectiveSampleCount(m_sampleCount, colorFormat);
5954+
sampleDesc = rhiD->effectiveSampleDesc(m_sampleCount, colorFormat);
59555955
}
59565956

59575957
bool QD3D12SwapChain::createOrResize()
@@ -5982,7 +5982,7 @@ bool QD3D12SwapChain::createOrResize()
59825982
if (!dcompTarget) {
59835983
hr = rhiD->dcompDevice->CreateTargetForHwnd(hwnd, true, &dcompTarget);
59845984
if (FAILED(hr)) {
5985-
qWarning("Failed to create Direct Compsition target for the window: %s",
5985+
qWarning("Failed to create Direct Composition target for the window: %s",
59865986
qPrintable(QSystemError::windowsComString(hr)));
59875987
}
59885988
}
@@ -6078,7 +6078,11 @@ bool QD3D12SwapChain::createOrResize()
60786078
}
60796079
}
60806080
if (FAILED(hr)) {
6081-
qWarning("Failed to create D3D12 swapchain: %s", qPrintable(QSystemError::windowsComString(hr)));
6081+
qWarning("Failed to create D3D12 swapchain: %s"
6082+
" (Width=%u Height=%u Format=%u SampleCount=%u BufferCount=%u Scaling=%u SwapEffect=%u Stereo=%u)",
6083+
qPrintable(QSystemError::windowsComString(hr)),
6084+
desc.Width, desc.Height, UINT(desc.Format), desc.SampleDesc.Count,
6085+
desc.BufferCount, UINT(desc.Scaling), UINT(desc.SwapEffect), UINT(desc.Stereo));
60826086
return false;
60836087
}
60846088

qtbase/src/plugins/platforms/windows/qwindowscontext.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,8 @@ QString QWindowsContext::classNamePrefix()
639639
# define xstr(s) str(s)
640640
# define str(s) #s
641641
str << xstr(QT_NAMESPACE);
642+
# undef str
643+
# undef xstr
642644
#endif
643645
}
644646
return result;

qtbase/src/plugins/platforms/windows/qwindowswindow.cpp

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -429,11 +429,7 @@ static inline bool windowIsAccelerated(const QWindow *w)
429429
{
430430
switch (w->surfaceType()) {
431431
case QSurface::OpenGLSurface:
432-
return true;
433-
case QSurface::RasterGLSurface:
434-
return qt_window_private(const_cast<QWindow *>(w))->compositing;
435432
case QSurface::VulkanSurface:
436-
return true;
437433
case QSurface::Direct3DSurface:
438434
return true;
439435
default:
@@ -2819,15 +2815,16 @@ void QWindowsWindow::calculateFullFrameMargins()
28192815
const auto systemMargins = testFlag(DisableNonClientScaling)
28202816
? QWindowsGeometryHint::frameOnPrimaryScreen(window(), m_data.hwnd)
28212817
: frameMargins_sys();
2818+
const QMargins actualMargins = systemMargins + customMargins();
28222819

28232820
const int yDiff = (windowRect.bottom - windowRect.top) - (clientRect.bottom - clientRect.top);
2824-
const bool typicalFrame = (systemMargins.left() == systemMargins.right())
2825-
&& (systemMargins.right() == systemMargins.bottom());
2821+
const bool typicalFrame = (actualMargins.left() == actualMargins.right())
2822+
&& (actualMargins.right() == actualMargins.bottom());
28262823

28272824
const QMargins adjustedMargins = typicalFrame ?
2828-
QMargins(systemMargins.left(), (yDiff - systemMargins.bottom()),
2829-
systemMargins.right(), systemMargins.bottom())
2830-
: systemMargins + customMargins();
2825+
QMargins(actualMargins.left(), (yDiff - actualMargins.bottom()),
2826+
actualMargins.right(), actualMargins.bottom())
2827+
: actualMargins;
28312828

28322829
setFullFrameMargins(adjustedMargins);
28332830
}
@@ -3449,24 +3446,6 @@ void QWindowsWindow::registerTouchWindow()
34493446
qErrnoWarning("RegisterTouchWindow() failed for window '%s'.", qPrintable(window()->objectName()));
34503447
}
34513448

3452-
void QWindowsWindow::aboutToMakeCurrent()
3453-
{
3454-
#ifndef QT_NO_OPENGL
3455-
// For RasterGLSurface windows, that become OpenGL windows dynamically, it might be
3456-
// time to set up some GL specifics. This is particularly important for layered
3457-
// windows (WS_EX_LAYERED due to alpha > 0).
3458-
const bool isCompositing = qt_window_private(window())->compositing;
3459-
if (isCompositing != testFlag(Compositing)) {
3460-
if (isCompositing)
3461-
setFlag(Compositing);
3462-
else
3463-
clearFlag(Compositing);
3464-
3465-
updateGLWindowSettings(window(), m_data.hwnd, m_data.flags, m_opacity);
3466-
}
3467-
#endif
3468-
}
3469-
34703449
void QWindowsWindow::setHasBorderInFullScreenStatic(QWindow *window, bool border)
34713450
{
34723451
if (QPlatformWindow *handle = window->handle())

0 commit comments

Comments
 (0)