r.DiscardUnusedQuality
r.DiscardUnusedQuality
#Overview
name: r.DiscardUnusedQuality
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:
Whether to keep or discard unused quality level shadermaps in memory.\n0: keep all quality levels in memory. (default)\n1: Discard unused quality levels on load.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.DiscardUnusedQuality is to control whether unused quality level shadermaps are kept in memory or discarded during loading.
This setting variable is primarily used in the rendering system, specifically for material and shader management. It is part of the Engine module, as evidenced by its location in the Material.cpp file within the Engine source directory.
The value of this variable is set through a console variable (CVar) system. It is defined as a TAutoConsoleVariable with an initial value of 0, which means by default, all quality levels are kept in memory.
The associated variable CVarDiscardUnusedQualityLevels directly interacts with r.DiscardUnusedQuality. They share the same value and purpose.
Developers must be aware that:
- This variable is read-only (ECVF_ReadOnly), meaning it cannot be changed at runtime.
- It has two possible values:
- 0: Keep all quality levels in memory (default)
- 1: Discard unused quality levels on load
Best practices when using this variable include:
- Consider the memory implications of keeping all quality levels vs. discarding unused ones.
- Be aware that changing this setting might affect runtime performance and memory usage.
- Test thoroughly with different quality settings to ensure proper behavior across all supported quality levels.
Regarding the associated variable CVarDiscardUnusedQualityLevels:
- It is used to actually retrieve the value of the r.DiscardUnusedQuality setting in the code.
- It’s accessed using the GetValueOnAnyThread() method, which suggests it’s safe to call from any thread.
- The value is used to determine whether to discard unused quality levels when processing serialized inline shader maps.
Developers should note that changing this setting could impact the behavior of the ProcessSerializedInlineShaderMaps function, potentially affecting shader loading and memory usage in the engine.
#Setting Variables
#References In INI files
Location: <Workspace>/Projects/Lyra/Config/DefaultDeviceProfiles.ini:49, section: [Mobile DeviceProfile]
- INI Section:
Mobile DeviceProfile
- Raw value:
1
- 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/Materials/Material.cpp:723
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarDiscardUnusedQualityLevels(
TEXT("r.DiscardUnusedQuality"),
0,
TEXT("Whether to keep or discard unused quality level shadermaps in memory.\n")
TEXT("0: keep all quality levels in memory. (default)\n")
TEXT("1: Discard unused quality levels on load."),
ECVF_ReadOnly);
#Associated Variable and Callsites
This variable is associated with another variable named CVarDiscardUnusedQualityLevels
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Materials/Material.cpp:722
Scope: file
Source code excerpt:
}
static TAutoConsoleVariable<int32> CVarDiscardUnusedQualityLevels(
TEXT("r.DiscardUnusedQuality"),
0,
TEXT("Whether to keep or discard unused quality level shadermaps in memory.\n")
TEXT("0: keep all quality levels in memory. (default)\n")
TEXT("1: Discard unused quality levels on load."),
ECVF_ReadOnly);
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Materials/Material.cpp:841
Scope (from outer to inner):
file
function void ProcessSerializedInlineShaderMaps
Source code excerpt:
}
const bool bDiscardUnusedQualityLevels = CVarDiscardUnusedQualityLevels.GetValueOnAnyThread() != 0;
const EMaterialQualityLevel::Type ActiveQualityLevel = GetCachedScalabilityCVars().MaterialQualityLevel;
checkf(!(STORE_ONLY_ACTIVE_SHADERMAPS && LoadedResources.Num() > 1),
TEXT("STORE_ONLY_ACTIVE_SHADERMAPS is set, but %d shader maps were loaded, expected at most 1"), LoadedResources.Num());
for (int32 ResourceIndex = 0; ResourceIndex < LoadedResources.Num(); ResourceIndex++)