fix: replace Sleep with proper fence synchronization in minimal test

This commit is contained in:
2026-03-20 02:49:19 +08:00
parent e01dcfe6ed
commit b7d66a09de

View File

@@ -180,6 +180,7 @@ void ExecuteCommandList() {
void* commandLists[] = { gCommandList.GetCommandList() };
gCommandQueue.ExecuteCommandLists(1, commandLists);
gFenceValue += 1;
gCommandQueue.Signal(gFence.GetFence(), gFenceValue);
}
// Begin rendering
@@ -274,6 +275,11 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
TranslateMessage(&msg);
DispatchMessage(&msg);
} else {
// Wait for previous frame to complete before resetting
if (frameCount > 0) {
gFence.Wait(gFenceValue);
}
// Reset command list for this frame
gCommandAllocator.Reset();
gCommandList.Reset();
@@ -312,9 +318,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
// Present
gSwapChain.Present(0, 0);
// Add small delay to prevent GPU overload
Sleep(10);
}
}