Skip to content

Commit da525b3

Browse files
committed
Remove the need for vkDeviceWaitIdle. (hedge-dev#1364)
From: Dario <[email protected]> Signed-off-by: Isaac Marovitz <[email protected]>
1 parent 0591633 commit da525b3

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

UnleashedRecomp/gpu/video.cpp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2028,23 +2028,20 @@ void Video::WaitForGPU()
20282028
{
20292029
g_waitForGPUCount++;
20302030

2031-
if (g_vulkan)
2031+
// Wait for all queued frames to finish.
2032+
for (size_t i = 0; i < NUM_FRAMES; i++)
20322033
{
2033-
g_device->waitIdle();
2034-
}
2035-
else
2036-
{
2037-
for (size_t i = 0; i < NUM_FRAMES; i++)
2034+
if (g_commandListStates[i])
20382035
{
2039-
if (g_commandListStates[i])
2040-
{
2041-
g_queue->waitForCommandFence(g_commandFences[i].get());
2042-
g_commandListStates[i] = false;
2043-
}
2036+
g_queue->waitForCommandFence(g_commandFences[i].get());
2037+
g_commandListStates[i] = false;
20442038
}
2045-
g_queue->executeCommandLists(nullptr, g_commandFences[0].get());
2046-
g_queue->waitForCommandFence(g_commandFences[0].get());
20472039
}
2040+
// Execute an empty command list and wait for it to end to guarantee that any remaining presentation has finished.
2041+
g_commandLists[0]->begin();
2042+
g_commandLists[0]->end();
2043+
g_queue->executeCommandLists(g_commandLists[0].get(), g_commandFences[0].get());
2044+
g_queue->waitForCommandFence(g_commandFences[0].get());
20482045
}
20492046

20502047
static uint32_t CreateDevice(uint32_t a1, uint32_t a2, uint32_t a3, uint32_t a4, uint32_t a5, be<uint32_t>* a6)

0 commit comments

Comments
 (0)