t.MaxFPS
t.MaxFPS
#Overview
name: t.MaxFPS
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Caps FPS to the given value. Set to <= 0 to be uncapped.
It is referenced in 7
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of t.MaxFPS is to cap the frames per second (FPS) of the game or application to a specified value. It is primarily used for performance control and frame rate limiting in the Unreal Engine rendering system.
The Unreal Engine core runtime and rendering subsystems rely on this setting variable. It is also utilized by the Learning Agents Training module in the Experimental plugins.
The value of this variable is set through the console variable system. It can be set programmatically or through console commands. The initial value is set to 0.0f, which means uncapped FPS by default.
The associated variable CVarMaxFPS interacts directly with t.MaxFPS. They share the same value and purpose.
Developers must be aware that:
- Setting t.MaxFPS to a value <= 0 will result in an uncapped frame rate.
- This variable affects the entire application’s frame rate, not just specific parts.
- It may interact with other frame rate limiting mechanisms in the engine.
Best practices when using this variable include:
- Use it to maintain consistent performance across different hardware.
- Consider platform-specific requirements when setting the value.
- Be cautious when changing this value during runtime, as it may affect game behavior and physics simulations.
Regarding the associated variable CVarMaxFPS:
- It is an auto console variable that directly corresponds to t.MaxFPS.
- It is used internally by the engine to retrieve and set the max FPS value.
- The UEngine class provides GetMaxFPS() and SetMaxFPS() methods that interact with CVarMaxFPS.
- When setting the max FPS through the engine, it considers the last set reason (e.g., by constructor or scalability) to maintain proper hierarchy of settings.
Developers should use the engine’s provided methods (GetMaxFPS and SetMaxFPS) when interacting with this setting to ensure proper handling of the console variable flags and consistency across the engine.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UnrealEngine.cpp:11187
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarMaxFPS(
TEXT("t.MaxFPS"),0.f,
TEXT("Caps FPS to the given value. Set to <= 0 to be uncapped."));
// CauseHitches cvar
static TAutoConsoleVariable<int32> CVarCauseHitches(
TEXT("CauseHitches"),0,
TEXT("Causes a 200ms hitch every second. Size of the hitch is controlled by CauseHitchesHitchMS"));
#Loc: <Workspace>/Engine/Plugins/Experimental/LearningAgents/Source/LearningAgentsTraining/Private/LearningAgentsTrainer.cpp:427
Scope (from outer to inner):
file
function void ULearningAgentsTrainer::BeginTraining
Source code excerpt:
}
IConsoleVariable* MaxFPSCVar = IConsoleManager::Get().FindConsoleVariable(TEXT("t.MaxFPS"));
if (MaxFPSCVar)
{
MaxFPS = MaxFPSCVar->GetInt();
}
UGameViewportClient* ViewportClient = GetWorld() ? GetWorld()->GetGameViewport() : nullptr;
#Loc: <Workspace>/Engine/Plugins/Experimental/LearningAgents/Source/LearningAgentsTraining/Private/LearningAgentsTrainer.cpp:622
Scope (from outer to inner):
file
function void ULearningAgentsTrainer::DoneTraining
Source code excerpt:
}
IConsoleVariable* MaxFPSCVar = IConsoleManager::Get().FindConsoleVariable(TEXT("t.MaxFPS"));
if (MaxFPSCVar)
{
MaxFPSCVar->Set(MaxFPS);
}
UGameViewportClient* ViewportClient = GetWorld() ? GetWorld()->GetGameViewport() : nullptr;
#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/ProfilingDebugging/CsvProfiler.cpp:3036
Scope (from outer to inner):
file
function void FCsvProfiler::BeginFrame
Source code excerpt:
int32 TargetFPS = FPlatformMisc::GetMaxRefreshRate();
static IConsoleVariable* CsvTargetFrameRateCVar = IConsoleManager::Get().FindConsoleVariable(TEXT("csv.TargetFrameRateOverride"));
static IConsoleVariable* MaxFPSCVar = IConsoleManager::Get().FindConsoleVariable(TEXT("t.MaxFPS"));
static IConsoleVariable* SyncIntervalCVar = IConsoleManager::Get().FindConsoleVariable(TEXT("rhi.SyncInterval"));
int32 CmdLineTargetFPS = TargetFPS;
if (CsvTargetFrameRateCVar && CsvTargetFrameRateCVar->GetInt() > 0)
{
TargetFPS = CsvTargetFrameRateCVar->GetInt();
}
#Loc: <Workspace>/Engine/Source/Runtime/Launch/Private/LaunchEngineLoop.cpp:1714
Scope (from outer to inner):
file
function static void UpdateCoreCsvStats_EndFrame
Source code excerpt:
#if !UE_BUILD_SHIPPING
float TargetFPS = 30.0f;
static IConsoleVariable* MaxFPSCVar = IConsoleManager::Get().FindConsoleVariable(TEXT("t.MaxFPS"));
if (MaxFPSCVar && MaxFPSCVar->GetFloat() > 0)
{
TargetFPS = MaxFPSCVar->GetFloat();
}
CSV_CUSTOM_STAT_GLOBAL(MaxFrameTime, 1000.0f / TargetFPS, ECsvCustomStatOp::Set);
#Associated Variable and Callsites
This variable is associated with another variable named CVarMaxFPS
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UnrealEngine.cpp:11186
Scope: file
Source code excerpt:
}
static TAutoConsoleVariable<float> CVarMaxFPS(
TEXT("t.MaxFPS"),0.f,
TEXT("Caps FPS to the given value. Set to <= 0 to be uncapped."));
// CauseHitches cvar
static TAutoConsoleVariable<int32> CVarCauseHitches(
TEXT("CauseHitches"),0,
TEXT("Causes a 200ms hitch every second. Size of the hitch is controlled by CauseHitchesHitchMS"));
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UnrealEngine.cpp:11284
Scope (from outer to inner):
file
function float UEngine::GetMaxTickRate
Source code excerpt:
LastMaxTickRate = MaxTickRate;
}
else if (CVarMaxFPS.GetValueOnAnyThread() > 0)
{
MaxTickRate = CVarMaxFPS.GetValueOnAnyThread();
}
return MaxTickRate;
}
float UEngine::GetMaxFPS() const
{
return CVarMaxFPS.GetValueOnAnyThread();
}
void UEngine::SetMaxFPS(const float MaxFPS)
{
IConsoleVariable* ConsoleVariable = CVarMaxFPS.AsVariable();
const EConsoleVariableFlags LastSetReason = (EConsoleVariableFlags)(ConsoleVariable->GetFlags() & ECVF_SetByMask);
const EConsoleVariableFlags ThisSetReason = (LastSetReason == ECVF_SetByConstructor) ? ECVF_SetByScalability : LastSetReason;
ConsoleVariable->Set(MaxFPS, ThisSetReason);
}