r.Streaming.FlushDeferredMipLevelChangeCallbacksBeforeGC
r.Streaming.FlushDeferredMipLevelChangeCallbacksBeforeGC
#Overview
name: r.Streaming.FlushDeferredMipLevelChangeCallbacksBeforeGC
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Whether to flush deferred mip level change callbacks before GC.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Streaming.FlushDeferredMipLevelChangeCallbacksBeforeGC is to control whether deferred mip level change callbacks should be flushed before garbage collection in Unreal Engine’s texture streaming system.
This setting variable is primarily used in the texture streaming subsystem of Unreal Engine, specifically within the FRenderAssetStreamingManager class. It is part of the Engine module, focusing on the streaming and memory management of render assets.
The value of this variable is set through a console variable (CVar) system. It is initialized with a default value of 1, meaning it’s enabled by default. Developers can change this value at runtime using console commands or through project settings.
The associated variable CVarFlushDeferredMipLevelChangeCallbacksBeforeGC directly interacts with r.Streaming.FlushDeferredMipLevelChangeCallbacksBeforeGC. They share the same value and purpose.
Developers should be aware that this variable is marked with a TODO comment, indicating it might be temporary and subject to removal once its efficacy has been verified. This suggests that the feature is still under evaluation and might change in future engine versions.
Best practices when using this variable include:
- Monitor its impact on performance, especially during garbage collection.
- Test your game with both enabled (1) and disabled (0) states to ensure proper functionality in both scenarios.
- Keep an eye on future Unreal Engine updates, as this feature might be altered or removed.
Regarding the associated variable CVarFlushDeferredMipLevelChangeCallbacksBeforeGC:
This is the actual console variable that controls the behavior. It is used in the OnPreGarbageCollect() function of FRenderAssetStreamingManager. When enabled, it calls TickDeferredMipLevelChangeCallbacks() before garbage collection occurs.
The purpose of this variable is to ensure that any pending mip level change callbacks are processed before the garbage collector runs. This can help prevent potential issues with texture references during garbage collection.
Developers should be aware that this feature may have performance implications, as it adds an extra step before garbage collection. It’s important to profile your game with this feature both enabled and disabled to understand its impact on your specific project.
Best practices for using CVarFlushDeferredMipLevelChangeCallbacksBeforeGC include:
- Monitor garbage collection performance with this feature enabled and disabled.
- Consider disabling it if you’re not experiencing texture-related issues during garbage collection and want to optimize GC performance.
- Keep it enabled if you’re encountering problems with texture references during garbage collection.
Remember that both variables are marked as temporary and may be removed in future engine versions once their effectiveness has been fully evaluated.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Streaming/StreamingManagerTexture.cpp:78
Scope: file
Source code excerpt:
// TODO: Remove once efficacy has been verified
static TAutoConsoleVariable<int32> CVarFlushDeferredMipLevelChangeCallbacksBeforeGC(
TEXT("r.Streaming.FlushDeferredMipLevelChangeCallbacksBeforeGC"),
1,
TEXT("Whether to flush deferred mip level change callbacks before GC."),
ECVF_Default);
// TODO: Remove once these calls have been proven safe in production
static TAutoConsoleVariable<int32> CVarProcessAddedRenderAssetsAfterAsyncWork(
#Associated Variable and Callsites
This variable is associated with another variable named CVarFlushDeferredMipLevelChangeCallbacksBeforeGC
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Streaming/StreamingManagerTexture.cpp:77
Scope: file
Source code excerpt:
// TODO: Remove once efficacy has been verified
static TAutoConsoleVariable<int32> CVarFlushDeferredMipLevelChangeCallbacksBeforeGC(
TEXT("r.Streaming.FlushDeferredMipLevelChangeCallbacksBeforeGC"),
1,
TEXT("Whether to flush deferred mip level change callbacks before GC."),
ECVF_Default);
// TODO: Remove once these calls have been proven safe in production
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Streaming/StreamingManagerTexture.cpp:240
Scope (from outer to inner):
file
function void FRenderAssetStreamingManager::OnPreGarbageCollect
Source code excerpt:
QUICK_SCOPE_CYCLE_COUNTER(STAT_FRenderAssetStreamingManager_OnPreGarbageCollect);
if (CVarFlushDeferredMipLevelChangeCallbacksBeforeGC.GetValueOnGameThread() != 0)
{
TickDeferredMipLevelChangeCallbacks();
}
FRemovedRenderAssetArray RemovedRenderAssets;