mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-04-28 05:11:37 +00:00
Fix loading thread breaking waitable swap chain order.
This commit is contained in:
parent
27427f7950
commit
0abbb751e4
1 changed files with 20 additions and 2 deletions
|
|
@ -2173,10 +2173,23 @@ static void ProcDrawImGui(const RenderCommand& cmd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We have to check for this to properly handle the following situation:
|
||||||
|
// 1. Wait on swap chain.
|
||||||
|
// 2. Create loading thread.
|
||||||
|
// 3. Loading thread also waits on swap chain.
|
||||||
|
// 4. Loading thread presents and quits.
|
||||||
|
// 5. After the loading thread quits, application also presents.
|
||||||
|
static bool g_pendingWaitOnSwapChain = true;
|
||||||
|
|
||||||
void Video::WaitOnSwapChain()
|
void Video::WaitOnSwapChain()
|
||||||
{
|
{
|
||||||
if (g_swapChainValid)
|
if (g_pendingWaitOnSwapChain)
|
||||||
g_swapChain->wait();
|
{
|
||||||
|
if (g_swapChainValid)
|
||||||
|
g_swapChain->wait();
|
||||||
|
|
||||||
|
g_pendingWaitOnSwapChain = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool g_shouldPrecompilePipelines;
|
static bool g_shouldPrecompilePipelines;
|
||||||
|
|
@ -2207,10 +2220,15 @@ void Video::Present()
|
||||||
|
|
||||||
if (g_swapChainValid)
|
if (g_swapChainValid)
|
||||||
{
|
{
|
||||||
|
if (g_pendingWaitOnSwapChain)
|
||||||
|
g_swapChain->wait(); // Never gonna happen outside loading threads as explained above.
|
||||||
|
|
||||||
RenderCommandSemaphore* signalSemaphores[] = { g_renderSemaphores[g_frame].get() };
|
RenderCommandSemaphore* signalSemaphores[] = { g_renderSemaphores[g_frame].get() };
|
||||||
g_swapChainValid = g_swapChain->present(g_backBufferIndex, signalSemaphores, std::size(signalSemaphores));
|
g_swapChainValid = g_swapChain->present(g_backBufferIndex, signalSemaphores, std::size(signalSemaphores));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_pendingWaitOnSwapChain = true;
|
||||||
|
|
||||||
g_frame = g_nextFrame;
|
g_frame = g_nextFrame;
|
||||||
g_nextFrame = (g_frame + 1) % NUM_FRAMES;
|
g_nextFrame = (g_frame + 1) % NUM_FRAMES;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue