r.SecondaryScreenPercentage.GameViewport
r.SecondaryScreenPercentage.GameViewport
#Overview
name: r.SecondaryScreenPercentage.GameViewport
The value of this variable can be defined or overridden in .ini config files. 1
.ini config file referencing this setting variable.
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Override secondary screen percentage for game viewport.\n 0: Compute secondary screen percentage = 100 / DPIScalefactor automaticaly (default);\n 1: override secondary screen percentage.
It is referenced in 6
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.SecondaryScreenPercentage.GameViewport is to control the secondary screen percentage for the game viewport in Unreal Engine 5. This setting is primarily used for rendering and performance optimization.
This setting variable is relied upon by several Unreal Engine subsystems and modules:
- The core Engine module, specifically in the GameViewportClient class.
- The nDisplay plugin, which is part of the Runtime plugins.
- The FunctionalTesting module, which is part of the Developer tools.
- The ApplicationCore module, specifically for Android platform support.
The value of this variable is set through the console variable system. It can be modified at runtime using console commands or programmatically through C++ code.
The associated variable CVarSecondaryScreenPercentage interacts directly with r.SecondaryScreenPercentage.GameViewport. They share the same value and are used interchangeably in the code.
Developers must be aware of the following when using this variable:
- The default value is 0, which means the secondary screen percentage is automatically computed as 100 / DPIScaleFactor.
- Setting a value greater than 0 will override the automatic computation.
- The value represents a percentage, so setting it to 100 means 100% (no scaling).
- The actual applied value is clamped between 0 and 100%.
Best practices when using this variable include:
- Use it for fine-tuning performance on different devices, especially mobile platforms.
- Be cautious when setting values, as it directly affects rendering quality and performance.
- Consider exposing this setting to end-users for devices with varying capabilities.
- Test thoroughly with different values to ensure optimal balance between quality and performance.
Regarding the associated variable CVarSecondaryScreenPercentage:
The purpose of CVarSecondaryScreenPercentage is to provide a C++ accessible interface for the r.SecondaryScreenPercentage.GameViewport console variable. It allows for programmatic access and modification of the secondary screen percentage value.
This variable is used primarily in the Engine module, specifically within the GameViewportClient class. It’s used to retrieve the current value of the secondary screen percentage and apply it to the ViewFamily when drawing the game viewport.
The value of CVarSecondaryScreenPercentage is set automatically when r.SecondaryScreenPercentage.GameViewport is modified, as they are directly linked.
Developers should be aware that CVarSecondaryScreenPercentage is accessed on the game thread, which means any modifications should be thread-safe.
Best practices for using CVarSecondaryScreenPercentage include:
- Use it for reading the current secondary screen percentage value in C++ code.
- Avoid frequent modifications, as it can impact performance.
- Consider caching the value if it’s accessed frequently in performance-critical code sections.
#Setting Variables
#References In INI files
Location: <Workspace>/Projects/Lyra/Config/DefaultDeviceProfiles.ini:80, section: [IOS DeviceProfile]
- INI Section:
IOS DeviceProfile
- Raw value:
83.33
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GameViewportClient.cpp:109
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarSecondaryScreenPercentage( // TODO: make it a user settings instead?
TEXT("r.SecondaryScreenPercentage.GameViewport"),
0,
TEXT("Override secondary screen percentage for game viewport.\n")
TEXT(" 0: Compute secondary screen percentage = 100 / DPIScalefactor automaticaly (default);\n")
TEXT(" 1: override secondary screen percentage."),
ECVF_Default);
#Loc: <Workspace>/Engine/Plugins/Runtime/nDisplay/Source/DisplayCluster/Private/Game/EngineClasses/Basics/DisplayClusterViewportClient.cpp:739
Scope (from outer to inner):
file
function void UDisplayClusterViewportClient::Draw
Source code excerpt:
if (ViewFamily.SupportsScreenPercentage())
{
float CustomSecondaryScreenPercentage = IConsoleManager::Get().FindConsoleVariable(TEXT("r.SecondaryScreenPercentage.GameViewport"), false)->GetFloat();
if (CustomSecondaryScreenPercentage > 0.0)
{
// Override secondary resolution fraction with CVar.
ViewFamily.SecondaryViewFraction = FMath::Min(CustomSecondaryScreenPercentage / 100.0f, 1.0f);
}
else
#Loc: <Workspace>/Engine/Source/Developer/FunctionalTesting/Private/AutomationBlueprintFunctionLibrary.cpp:251
Scope (from outer to inner):
file
function FAutomationTestScreenshotEnvSetup::FAutomationTestScreenshotEnvSetup
Source code excerpt:
, DynamicResTestScreenPercentage(TEXT("r.DynamicRes.TestScreenPercentage"))
, DynamicResOperationMode(TEXT("r.DynamicRes.OperationMode"))
, SecondaryScreenPercentage(TEXT("r.SecondaryScreenPercentage.GameViewport"))
{
}
FAutomationTestScreenshotEnvSetup::~FAutomationTestScreenshotEnvSetup()
{
}
#Loc: <Workspace>/Engine/Source/Runtime/ApplicationCore/Private/Android/AndroidWindow.cpp:613
Scope (from outer to inner):
file
function FPlatformRect FAndroidWindow::GetScreenRect
Source code excerpt:
if (IsInGameThread())
{
static IConsoleVariable* CVarSSP = IConsoleManager::Get().FindConsoleVariable(TEXT("r.SecondaryScreenPercentage.GameViewport"));
CVarSSP->Set((float)Info.SceneScaleFactor * 100.0f);
}
}
else
{
AndroidWindowUtils::ApplyContentScaleFactor(ScreenWidth, ScreenHeight);
#Associated Variable and Callsites
This variable is associated with another variable named CVarSecondaryScreenPercentage
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GameViewportClient.cpp:108
Scope: file
Source code excerpt:
ECVF_Default);
static TAutoConsoleVariable<float> CVarSecondaryScreenPercentage( // TODO: make it a user settings instead?
TEXT("r.SecondaryScreenPercentage.GameViewport"),
0,
TEXT("Override secondary screen percentage for game viewport.\n")
TEXT(" 0: Compute secondary screen percentage = 100 / DPIScalefactor automaticaly (default);\n")
TEXT(" 1: override secondary screen percentage."),
ECVF_Default);
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GameViewportClient.cpp:1515
Scope (from outer to inner):
file
function void UGameViewportClient::Draw
Source code excerpt:
if (!bStereoRendering && ViewFamily.SupportsScreenPercentage())
{
float CustomSecondaruScreenPercentage = CVarSecondaryScreenPercentage.GetValueOnGameThread();
if (CustomSecondaruScreenPercentage > 0.0)
{
// Override secondary resolution fraction with CVar.
ViewFamily.SecondaryViewFraction = FMath::Min(CustomSecondaruScreenPercentage / 100.0f, 1.0f);
}