Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/fps_limiter.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@ class fpsLimiter {
bool use_early;
bool active = false;

fpsLimiter(bool use_early) : use_early(use_early) {
fpsLimiter(bool use_early, size_t idx = 0) : use_early(use_early) {
auto& fps_limit = get_params()->fps_limit;
if (fps_limit.empty())
return;

active = true;
fps_limits_idx = idx < fps_limit.size() ? idx : 0;

float tar = fps_limit[fps_limits_idx];
target = tar <= 0.0f ? 0 : int64_t(1'000'000'000.0f / tar);
Expand Down Expand Up @@ -78,6 +79,10 @@ class fpsLimiter {
SPDLOG_DEBUG("Changed fps limit to {}", next_target);
}

size_t limit_index() const {
return fps_limits_idx;
}

int current_limit() {
auto& v = get_params()->fps_limit;
return v[fps_limits_idx];
Expand Down
8 changes: 7 additions & 1 deletion src/overlay_params.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1220,10 +1220,16 @@ parse_overlay_config(struct overlay_params *params,
config_cv.notify_one();
}

auto prev_params = g_params.load(std::memory_order_acquire);
auto snapshot = std::make_shared<overlay_params>(*params);
g_params.store(std::move(snapshot), std::memory_order_release);

fps_limiter = std::make_unique<fpsLimiter>(params->fps_limit_method ? false : true);
// a preset switch keeps the limit picked with toggle_fps_limit, unless the preset changes fps_limit
size_t fps_limits_idx = 0;
if (use_existing_preset && fps_limiter && prev_params && prev_params->fps_limit == params->fps_limit)
fps_limits_idx = fps_limiter->limit_index();

fps_limiter = std::make_unique<fpsLimiter>(params->fps_limit_method ? false : true, fps_limits_idx);

if (!gpus)
gpus = std::make_unique<GPUS>();
Expand Down
Loading