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); QDxgiVSyncService::instance()->registerWindow(window);
if (needsRegistration) { if (needsRegistration || !rhiD->swapchains.contains(this))
rhiD->swapchains.insert(this); rhiD->swapchains.insert(this);
rhiD->registerResource(this); rhiD->registerResource(this);
}
return true; return true;
} }

View File

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

View File

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

View File

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