r.MobileReduceLoadedMips
r.MobileReduceLoadedMips
#Overview
name: r.MobileReduceLoadedMips
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Reduce loaded texture mipmaps for nonstreaming mobile platforms.\n
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.MobileReduceLoadedMips is to control the reduction of loaded texture mipmaps for non-streaming mobile platforms in Unreal Engine 5. This setting variable is part of the texture management system, specifically targeting mobile platforms.
This setting variable is primarily used in the Engine module, particularly in the texture loading and management subsystem. It’s referenced in the Texture2D.cpp file, which is responsible for handling 2D textures in the engine.
The value of this variable is set through a console variable (CVarMobileReduceLoadedMips) with a default value of 0. It can be modified at runtime through console commands or programmatically.
This variable interacts closely with another variable called r.MobileMaxLoadedMips. Together, they control the number of mipmaps loaded for textures on mobile platforms.
Developers must be aware that this variable specifically targets non-streaming mobile platforms. It’s used to reduce the number of mipmaps loaded at runtime, which can help conserve memory on mobile devices with limited resources.
Best practices when using this variable include:
- Only increase the value if you’re experiencing memory issues on mobile devices.
- Test thoroughly on various mobile devices to ensure performance improvements without significant quality loss.
- Use in conjunction with r.MobileMaxLoadedMips for fine-tuned control over texture mipmap loading.
Regarding the associated variable CVarMobileReduceLoadedMips:
The purpose of CVarMobileReduceLoadedMips is to provide a programmatic interface to control the r.MobileReduceLoadedMips setting. It’s an internal representation of the console variable used by the engine code.
This variable is used directly in the texture loading logic within the Engine module. It’s referenced in the MobileReduceLoadedMips function in Texture2D.cpp.
The value of this variable is set when the engine initializes the console variables, and it can be modified at runtime through console commands.
CVarMobileReduceLoadedMips interacts directly with CVarMobileMaxLoadedMips to determine the final number of mipmaps to load for textures.
Developers should be aware that modifying this variable directly in code will have the same effect as changing the r.MobileReduceLoadedMips console variable.
Best practices for using this variable in code include:
- Use GetValueOnAnyThread() when accessing the value to ensure thread-safe operations.
- Consider caching the value if it’s accessed frequently, as console variable lookups can have a small performance cost.
- Be cautious when modifying this value, as it can significantly impact texture memory usage and quality on mobile devices.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Texture2D.cpp:84
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarMobileReduceLoadedMips(
TEXT("r.MobileReduceLoadedMips"),
0,
TEXT("Reduce loaded texture mipmaps for nonstreaming mobile platforms.\n"),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarMobileMaxLoadedMips(
TEXT("r.MobileMaxLoadedMips"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarMobileReduceLoadedMips
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Texture2D.cpp:83
Scope: file
Source code excerpt:
TEXT("If set to 0, we won't do any flushes for streaming textures. This is safe because the texture streamer deals with these hazards explicitly."),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarMobileReduceLoadedMips(
TEXT("r.MobileReduceLoadedMips"),
0,
TEXT("Reduce loaded texture mipmaps for nonstreaming mobile platforms.\n"),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarMobileMaxLoadedMips(
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Texture2D.cpp:111
Scope (from outer to inner):
file
function static int32 MobileReduceLoadedMips
Source code excerpt:
// apply cvar options to reduce the number of mips created at runtime
// note they are still cooked &shipped
int32 NumReduceMips = FMath::Max(0, CVarMobileReduceLoadedMips.GetValueOnAnyThread());
int32 MaxLoadedMips = FMath::Clamp(CVarMobileMaxLoadedMips.GetValueOnAnyThread(), 1, GMaxTextureMipCount);
int32 NumMips = NumTotalMips;
// Reduce number of mips as requested
NumMips = FMath::Max(NumMips - NumReduceMips, 1);
// Clamp number of mips as requested