fix: replace Sleep with proper fence synchronization in minimal test
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user