[GPU] Add hard FPS limit without vsync

This commit is contained in:
Mateusz Dukat 2024-03-10 16:24:17 +01:00
parent 1ff3dc4d10
commit bf5c7f67ea
3 changed files with 17 additions and 1 deletions

View File

@ -22,6 +22,13 @@ DEFINE_bool(vsync, true, "Enable VSYNC.", "GPU");
DEFINE_uint64(vsync_fps, 60, "VSYNC frames per second", "GPU");
DEFINE_uint64(hard_fps, 60,
"Hard FPS lock, ignored when vsync is used. "
"Game will never exceed this value", "GPU");
DEFINE_bool(hard_fps_enable, false,
"Enable hard FPS lock, ignored if vsync is enabled", "GPU");
DEFINE_bool(
gpu_allow_invalid_fetch_constants, true,
"Allow texture and vertex fetch constants with invalid type - generally "

View File

@ -20,6 +20,9 @@ DECLARE_bool(vsync);
DECLARE_uint64(vsync_fps);
DECLARE_uint64(hard_fps);
DECLARE_bool(hard_fps_enable);
DECLARE_bool(gpu_allow_invalid_fetch_constants);
DECLARE_bool(half_pixel_offset);

View File

@ -133,8 +133,14 @@ X_STATUS GraphicsSystem::Setup(cpu::Processor* processor,
threading::NanoSleep(estimated_nanoseconds);
}
}
if (!cvars::vsync) {
xe::threading::Sleep(std::chrono::milliseconds(1));
if (cvars::hard_fps_enable) {
uint64_t hard_frame_sleep_time = 1000000000 / cvars::hard_fps;
xe::threading::NanoSleep(hard_frame_sleep_time);
} else {
xe::threading::Sleep(std::chrono::milliseconds(1));
}
}
}
return 0;