Fix command buffer memory leak

d3d11
Caleb Cornett 2023-10-26 21:39:15 -05:00 committed by cosmonaut
parent 6a1c4ba80f
commit ce3b222529
1 changed files with 21 additions and 2 deletions

View File

@ -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);
}