rhi: Do not lose track of swapchains on manual destroy-create

Pick-to: 6.8
Change-Id: Ieb1c06c881dff3e1dbd0cff470d5a7c264a20d1d
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
This commit is contained in:
Laszlo Agocs 2024-11-12 12:44:57 +01:00
parent c39c3fe0cb
commit 950c61d48b
4 changed files with 7 additions and 10 deletions

View File

@ -6779,10 +6779,10 @@ bool QD3D12SwapChain::createOrResize()
QDxgiVSyncService::instance()->registerWindow(window);
if (needsRegistration) {
if (needsRegistration || !rhiD->swapchains.contains(this))
rhiD->swapchains.insert(this);
rhiD->registerResource(this);
}
rhiD->registerResource(this);
return true;
}

View File

@ -6765,7 +6765,6 @@ void QGles2SwapChain::initSwapChainRenderTarget(QGles2SwapChainRenderTarget *rt)
bool QGles2SwapChain::createOrResize()
{
// can be called multiple times due to window resizes
const bool needsRegistration = !surface || surface != m_window;
if (surface && surface != m_window)
destroy();
@ -6798,8 +6797,7 @@ bool QGles2SwapChain::createOrResize()
// The only reason to register this fairly fake gl swapchain
// object with no native resources underneath is to be able to
// implement a safe destroy().
if (needsRegistration)
rhiD->registerResource(this, false);
rhiD->registerResource(this, false);
return true;
}

View File

@ -6418,7 +6418,7 @@ bool QMetalSwapChain::createOrResize()
// else no destroy(), this is intentional
QRHI_RES_RHI(QRhiMetal);
if (needsRegistration)
if (needsRegistration || !rhiD->swapchains.contains(this))
rhiD->swapchains.insert(this);
window = m_window;
@ -6540,8 +6540,7 @@ bool QMetalSwapChain::createOrResize()
[desc release];
}
if (needsRegistration)
rhiD->registerResource(this);
rhiD->registerResource(this);
return true;
}

View File

@ -8671,7 +8671,7 @@ bool QVkSwapChain::createOrResize()
return false;
}
if (needsRegistration)
if (needsRegistration || !rhiD->swapchains.contains(this))
rhiD->swapchains.insert(this);
if (m_depthStencil && m_depthStencil->sampleCount() != m_sampleCount) {