Skip to content

Commit fc6c8bb

Browse files
committed
Merge pull request #99688 from akien-mga/revert-99178
Revert "Make `delay_usec` more precise on Windows to fix framepacing"
2 parents 7c9d030 + 8e1a6ea commit fc6c8bb

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

platform/windows/os_windows.cpp

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -817,22 +817,10 @@ double OS_Windows::get_unix_time() const {
817817
}
818818

819819
void OS_Windows::delay_usec(uint32_t p_usec) const {
820-
constexpr uint32_t tolerance = 1000 + 20;
821-
822-
uint64_t t0 = get_ticks_usec();
823-
uint64_t target_time = t0 + p_usec;
824-
825-
// Calculate sleep duration with a tolerance for fine-tuning.
826-
if (p_usec > tolerance) {
827-
uint32_t coarse_sleep_usec = p_usec - tolerance;
828-
if (coarse_sleep_usec >= 1000) {
829-
Sleep(coarse_sleep_usec / 1000);
830-
}
831-
}
832-
833-
// Spin-wait until we reach the precise target time.
834-
while (get_ticks_usec() < target_time) {
835-
YieldProcessor();
820+
if (p_usec < 1000) {
821+
Sleep(1);
822+
} else {
823+
Sleep(p_usec / 1000);
836824
}
837825
}
838826

0 commit comments

Comments
 (0)