r.Mobile.DesiredResX

r.Mobile.DesiredResX

#Overview

name: r.Mobile.DesiredResX

This variable is created as a Console Variable (cvar).

It is referenced in 7 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.Mobile.DesiredResX is to set the desired mobile X resolution for the longest axis in Unreal Engine 5. It is primarily used for controlling the rendering resolution on mobile devices.

This setting variable is utilized by several Unreal Engine subsystems and modules, including:

  1. The Core module (ConsoleManager.cpp)
  2. The ApplicationCore module (AndroidWindow.cpp, IOSWindow.cpp, IOSWindow.h, AndroidWindowUtils.h)
  3. The Launch module (AndroidEventManager.cpp)

The value of this variable is typically set through the console or configuration files. It can also be modified at runtime through the console variable system.

This variable interacts closely with other related variables, such as:

Developers should be aware of the following when using this variable:

  1. Setting a non-zero value will use that value for the X resolution, and the Y resolution will be calculated to maintain the aspect ratio.
  2. It works in conjunction with r.Mobile.DesiredResY, and they should be considered together for proper resolution control.
  3. The variable’s effect may be platform-specific, with different behaviors on Android and iOS.

Best practices when using this variable include:

  1. Consider the target devices’ capabilities and screen sizes when setting the value.
  2. Test the application on various devices to ensure the chosen resolution works well across different screen sizes and aspect ratios.
  3. Use in combination with r.Mobile.DesiredResY for fine-grained control over the rendering resolution.
  4. Be aware of the performance implications of increasing the resolution, especially on lower-end mobile devices.
  5. Consider using this variable in conjunction with dynamic resolution scaling for optimal performance across different devices.

#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:3889

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarMobileDesiredResX(
	TEXT("r.Mobile.DesiredResX"),
	0,
	TEXT("Desired mobile X resolution (longest axis) (non-zero == use for X, calculate Y to retain aspect ratio)"),
	ECVF_Default);

static TAutoConsoleVariable<int32> CVarMobileDesiredResY(
	TEXT("r.Mobile.DesiredResY"),

#Loc: <Workspace>/Engine/Source/Runtime/ApplicationCore/Private/Android/AndroidWindow.cpp:565

Scope (from outer to inner):

file
function     FPlatformRect FAndroidWindow::GetScreenRect

Source code excerpt:

	}

	static IConsoleVariable* CVarResX = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Mobile.DesiredResX"));
	static IConsoleVariable* CVarResY = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Mobile.DesiredResY"));
	int32 RequestedResX = bIsOculusMobileApp ? 0 : CVarResX->GetInt();
	int32 RequestedResY = bIsOculusMobileApp ? 0 : CVarResY->GetInt();

	FString CmdLineMDRes;
	if (FParse::Value(FCommandLine::Get(), TEXT("mobileresx="), CmdLineMDRes, false))

#Loc: <Workspace>/Engine/Source/Runtime/ApplicationCore/Private/IOS/IOSWindow.cpp:72

Scope: file

Source code excerpt:

	if ((CVar->GetFlags() & ECVF_SetByMask) == ECVF_SetByConsole)
	{
		IConsoleVariable* CVarResX = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Mobile.DesiredResX"));
		IConsoleVariable* CVarResY = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Mobile.DesiredResY"));
		
		// If CVarResX/Y needs to be reset, let that CVar callback handle the layout change
		bool OtherCVarChanged = false;
		if (CVarResX && CVarResX->GetInt() != 0)
		{

#Loc: <Workspace>/Engine/Source/Runtime/ApplicationCore/Private/IOS/IOSWindow.h:33

Scope (from outer to inner):

file
function     class APPLICATIONCORE_API FIOSWindow : public FGenericWindow { public: ~FIOSWindow

Source code excerpt:

	virtual bool GetFullScreenInfo( int32& X, int32& Y, int32& Width, int32& Height ) const override;

	/** Callbacks for Cvar changes "r.MobileContentScaleFactor" and "r.Mobile.DesiredResX/Y" respectively */
	static void OnScaleFactorChanged(IConsoleVariable* CVar);
	static void OnConsoleResolutionChanged(IConsoleVariable* CVar);
		
protected:
	/** @return true if the native window is currently in fullscreen mode, false otherwise */
	virtual EWindowMode::Type GetWindowMode() const override { return EWindowMode::Fullscreen; }

#Loc: <Workspace>/Engine/Source/Runtime/ApplicationCore/Public/Android/AndroidWindowUtils.h:38

Scope (from outer to inner):

file
namespace    AndroidWindowUtils
function     void ApplyContentScaleFactor

Source code excerpt:

		float RequestedContentScaleFactor = CVarScale->GetFloat();

		static IConsoleVariable* CVarResX = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Mobile.DesiredResX"));
		static IConsoleVariable* CVarResY = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Mobile.DesiredResY"));
		int32 RequestedResX = CVarResX->GetInt();
		int32 RequestedResY = CVarResY->GetInt();

		FString CmdLineCSF;
		if (FParse::Value(FCommandLine::Get(), TEXT("mcsf="), CmdLineCSF, false))

#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/IOS/IOSPlatformMisc.cpp:76

Scope (from outer to inner):

file
function     void FIOSPlatformMisc::PlatformInit

Source code excerpt:

{
	// PlatformInit() starts the UI thread which creates the framebuffer and it requires
	// "r.MobileContentScaleFactor" and "r.Mobile.DesiredResX/Y" to be available before 
	// it's creation, so need to cache those value now.
	[[IOSAppDelegate GetDelegate] LoadScreenResolutionModifiers];
		
	FAppEntry::PlatformInit();

	// Increase the maximum number of simultaneously open files

#Loc: <Workspace>/Engine/Source/Runtime/Launch/Private/Android/AndroidEventManager.cpp:214

Scope (from outer to inner):

file
function     FAppEventManager::FAppEventManager

Source code excerpt:

	CVarScale->SetOnChangedCallback(FConsoleVariableDelegate::CreateStatic(&FAppEventManager::OnScaleFactorChanged));

	IConsoleVariable* CVarResX = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Mobile.DesiredResX"));
	if (CVarResX != nullptr)
	{
		CVarResX->SetOnChangedCallback(FConsoleVariableDelegate::CreateStatic(&FAppEventManager::OnScaleFactorChanged));
	}

	IConsoleVariable* CVarResY = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Mobile.DesiredResY"));