diff --git a/src/Refresh_Driver_D3D11.c b/src/Refresh_Driver_D3D11.c index 9b47552..2b8ef9c 100644 --- a/src/Refresh_Driver_D3D11.c +++ b/src/Refresh_Driver_D3D11.c @@ -2483,8 +2483,6 @@ static void D3D11_Submit( renderer->submittedCommandBuffers[renderer->submittedCommandBufferCount] = d3d11CommandBuffer; renderer->submittedCommandBufferCount += 1; - SDL_UnlockMutex(renderer->contextLock); - /* Present, if applicable */ if (d3d11CommandBuffer->swapchainData) { @@ -2495,6 +2493,27 @@ static void D3D11_Submit( ); } + /* Check if we can perform any cleanups */ + for (int32_t i = renderer->submittedCommandBufferCount - 1; i >= 0; i -= 1) + { + BOOL queryData; + + res = ID3D11DeviceContext_GetData( + renderer->immediateContext, + (ID3D11Asynchronous*) renderer->submittedCommandBuffers[i]->completionQuery, + &queryData, + sizeof(queryData), + 0 + ); + if (res == S_OK) + { + D3D11_INTERNAL_CleanCommandBuffer( + renderer, + renderer->submittedCommandBuffers[i] + ); + } + } + SDL_UnlockMutex(renderer->contextLock); }