mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-02-07 16:54:14 +01:00
[util] Expose frame rate environment variable
We'll need this in more places.
This commit is contained in:
parent
53e5c4875f
commit
55639889c7
@ -13,15 +13,11 @@ using namespace std::chrono_literals;
|
||||
namespace dxvk {
|
||||
|
||||
FpsLimiter::FpsLimiter() {
|
||||
std::string env = env::getEnvVar("DXVK_FRAME_RATE");
|
||||
auto override = getEnvironmentOverride();
|
||||
|
||||
if (!env.empty()) {
|
||||
try {
|
||||
setTargetFrameRate(std::stod(env), 0);
|
||||
m_envOverride = true;
|
||||
} catch (const std::invalid_argument&) {
|
||||
// no-op
|
||||
}
|
||||
if (override) {
|
||||
setTargetFrameRate(*override, 0);
|
||||
m_envOverride = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -128,4 +124,19 @@ namespace dxvk {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
std::optional<double> FpsLimiter::getEnvironmentOverride() {
|
||||
std::string env = env::getEnvVar("DXVK_FRAME_RATE");
|
||||
|
||||
if (!env.empty()) {
|
||||
try {
|
||||
return std::stod(env);
|
||||
} catch (const std::invalid_argument&) {
|
||||
// no op
|
||||
}
|
||||
}
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <optional>
|
||||
|
||||
#include "thread.h"
|
||||
#include "util_time.h"
|
||||
@ -39,6 +40,12 @@ namespace dxvk {
|
||||
*/
|
||||
void delay();
|
||||
|
||||
/**
|
||||
* \brief Queries environment override
|
||||
* \returns Frame rate given by environment override
|
||||
*/
|
||||
static std::optional<double> getEnvironmentOverride();
|
||||
|
||||
private:
|
||||
|
||||
using TimePoint = dxvk::high_resolution_clock::time_point;
|
||||
|
Loading…
x
Reference in New Issue
Block a user