r.DontLimitOnBattery
r.DontLimitOnBattery
#Overview
name: r.DontLimitOnBattery
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
0: Limit performance on devices with a battery.(default)\n1: Do not limit performance due to device having a battery.
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.DontLimitOnBattery is to control whether the engine should limit performance on devices running on battery power. This setting is primarily used for power management and performance optimization on portable devices like laptops.
This setting variable is mainly utilized by the Unreal Engine’s core subsystem and the editor module. It’s referenced in the Core and UnrealEd modules, specifically in the ConsoleManager and EditorEngine components.
The value of this variable is set through the console variable system. It’s defined as a TAutoConsoleVariable in the ConsoleManager.cpp file, with a default value of 0 (meaning performance is limited on battery by default).
The associated variable CVarDontLimitOnBattery interacts directly with r.DontLimitOnBattery. It’s used to retrieve the current value of the setting in the editor code.
Developers must be aware that this variable affects the performance and power consumption of the engine on battery-powered devices. When set to 0 (default), it limits the performance to conserve battery life. When set to 1, it allows full performance regardless of battery status.
Best practices when using this variable include:
- Consider the target platform and user experience. For battery-powered devices, leaving it at the default (0) can help extend battery life.
- For development or testing purposes where maximum performance is needed, it can be set to 1.
- Be mindful of the potential impact on battery life when changing this setting.
Regarding the associated variable CVarDontLimitOnBattery:
- It’s used to access the value of r.DontLimitOnBattery within the C++ code.
- It’s typically used in conjunction with FPlatformMisc::IsRunningOnBattery() to determine whether to limit performance.
- In the EditorEngine, it’s used to potentially limit the max tick rate to 60 Hz when running on battery, which can significantly reduce power consumption.
When working with CVarDontLimitOnBattery, developers should:
- Use it to read the current setting value, not to modify it directly.
- Be aware that changes to r.DontLimitOnBattery will be reflected in CVarDontLimitOnBattery.
- Consider caching the value if it’s accessed frequently, as console variable lookups can have a small performance cost.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/HAL/ConsoleManager.cpp:3923
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarDontLimitOnBattery(
TEXT("r.DontLimitOnBattery"),
0,
TEXT("0: Limit performance on devices with a battery.(default)\n"
"1: Do not limit performance due to device having a battery."),
ECVF_Scalability | ECVF_RenderThreadSafe);
static TAutoConsoleVariable<float> CVarViewDistanceScale(
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorEngine.cpp:2389
Scope (from outer to inner):
file
function float UEditorEngine::GetMaxTickRate
Source code excerpt:
// Laptops should throttle to 60 hz in editor to reduce battery drain
static const auto CVarDontLimitOnBattery = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.DontLimitOnBattery"));
const bool bLimitOnBattery = (FPlatformMisc::IsRunningOnBattery() && CVarDontLimitOnBattery->GetValueOnGameThread() == 0);
if( bLimitOnBattery )
{
MaxTickRate = 60.0f;
}
}
#Associated Variable and Callsites
This variable is associated with another variable named CVarDontLimitOnBattery
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorEngine.cpp:2389
Scope (from outer to inner):
file
function float UEditorEngine::GetMaxTickRate
Source code excerpt:
// Laptops should throttle to 60 hz in editor to reduce battery drain
static const auto CVarDontLimitOnBattery = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.DontLimitOnBattery"));
const bool bLimitOnBattery = (FPlatformMisc::IsRunningOnBattery() && CVarDontLimitOnBattery->GetValueOnGameThread() == 0);
if( bLimitOnBattery )
{
MaxTickRate = 60.0f;
}
}
else
#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/HAL/ConsoleManager.cpp:3922
Scope: file
Source code excerpt:
ECVF_ReadOnly);
static TAutoConsoleVariable<int32> CVarDontLimitOnBattery(
TEXT("r.DontLimitOnBattery"),
0,
TEXT("0: Limit performance on devices with a battery.(default)\n"
"1: Do not limit performance due to device having a battery."),
ECVF_Scalability | ECVF_RenderThreadSafe);