demo.ForcePersistentLevelPriority
demo.ForcePersistentLevelPriority
#Overview
name: demo.ForcePersistentLevelPriority
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
If true, force persistent level to record first when prioritizing and using streaming level fixes.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of demo.ForcePersistentLevelPriority is to control the prioritization of the persistent level during demo recording in Unreal Engine 5. It is used in the demo recording system, which is part of the networking and replay functionality.
This setting variable is primarily utilized by the DemoNetDriver subsystem within the Engine module. It affects how levels are prioritized during the recording of gameplay demos.
The value of this variable is set as a console variable (CVar) with an initial value of 0. It can be modified at runtime through console commands or programmatically.
The associated variable CVarDemoForcePersistentLevelPriority directly interacts with demo.ForcePersistentLevelPriority. They share the same value and purpose.
Developers must be aware that when this variable is set to a non-zero value, it forces the persistent level to be recorded first when prioritizing and using streaming level fixes during demo recording. This can significantly impact the order in which game state is captured and replayed.
Best practices for using this variable include:
- Use it judiciously, as forcing persistent level priority may affect the playback quality of demos, especially in games with complex level streaming setups.
- Test thoroughly with both enabled and disabled states to ensure proper demo recording and playback in all scenarios.
- Consider performance implications, as altering the recording priority may impact frame times during demo capture.
Regarding the associated variable CVarDemoForcePersistentLevelPriority:
The purpose of CVarDemoForcePersistentLevelPriority is identical to demo.ForcePersistentLevelPriority. It is the actual TAutoConsoleVariable instance used in the C++ code to access and modify the setting.
This variable is used within the DemoNetDriver subsystem, specifically in the BuildSortedLevelPriorityOnLevels function, to determine whether to apply high priority to the persistent level during demo recording.
The value of CVarDemoForcePersistentLevelPriority is set when the console variable is initialized and can be modified through the same means as demo.ForcePersistentLevelPriority.
Developers should be aware that this variable is accessed using the GetValueOnAnyThread() method, which implies it can be safely read from any thread. However, modifications should be done carefully to avoid race conditions.
Best practices for CVarDemoForcePersistentLevelPriority include:
- Use the GetValueOnAnyThread() method for thread-safe reading of the variable.
- When modifying the value, ensure it’s done at appropriate times to avoid disrupting ongoing demo recording processes.
- Consider exposing this setting in the game’s options menu if demo recording is a user-facing feature, allowing players to optimize demo capture for their specific needs.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DemoNetDriver.cpp:140
Scope (from outer to inner):
file
namespace DemoNetDriverRecordingPrivate
Source code excerpt:
);
static TAutoConsoleVariable<int32> CVarDemoForcePersistentLevelPriority(TEXT("demo.ForcePersistentLevelPriority"), 0, TEXT("If true, force persistent level to record first when prioritizing and using streaming level fixes."));
static TAutoConsoleVariable<int32> CVarDemoDestructionInfoPriority(TEXT("demo.DestructionInfoPriority"), MAX_int32, TEXT("Replay net priority assigned to destruction infos during recording."));
static TAutoConsoleVariable<int32> CVarDemoLateDestructionInfoPrioritize(TEXT("demo.LateDestructionInfoPrioritize"), 0, TEXT("If true, process destruction infos at the end of the prioritization phase."));
static TAutoConsoleVariable<float> CVarDemoViewTargetPriorityScale(TEXT("demo.ViewTargetPriorityScale"), 3.0, TEXT("Scale view target priority by this value when prioritization is enabled."));
static TAutoConsoleVariable<float> CVarDemoMaximumRecDestructionInfoTime(TEXT("demo.MaximumRecDestructionInfoTime"), 0.2, TEXT("Maximum percentage of frame to use replicating destruction infos, if per frame limit is enabled."));
static FAutoConsoleCommandWithWorldAndArgs DemoMaxDesiredRecordTimeMS(
#Associated Variable and Callsites
This variable is associated with another variable named CVarDemoForcePersistentLevelPriority
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DemoNetDriver.cpp:140
Scope (from outer to inner):
file
namespace DemoNetDriverRecordingPrivate
Source code excerpt:
);
static TAutoConsoleVariable<int32> CVarDemoForcePersistentLevelPriority(TEXT("demo.ForcePersistentLevelPriority"), 0, TEXT("If true, force persistent level to record first when prioritizing and using streaming level fixes."));
static TAutoConsoleVariable<int32> CVarDemoDestructionInfoPriority(TEXT("demo.DestructionInfoPriority"), MAX_int32, TEXT("Replay net priority assigned to destruction infos during recording."));
static TAutoConsoleVariable<int32> CVarDemoLateDestructionInfoPrioritize(TEXT("demo.LateDestructionInfoPrioritize"), 0, TEXT("If true, process destruction infos at the end of the prioritization phase."));
static TAutoConsoleVariable<float> CVarDemoViewTargetPriorityScale(TEXT("demo.ViewTargetPriorityScale"), 3.0, TEXT("Scale view target priority by this value when prioritization is enabled."));
static TAutoConsoleVariable<float> CVarDemoMaximumRecDestructionInfoTime(TEXT("demo.MaximumRecDestructionInfoTime"), 0.2, TEXT("Maximum percentage of frame to use replicating destruction infos, if per frame limit is enabled."));
static FAutoConsoleCommandWithWorldAndArgs DemoMaxDesiredRecordTimeMS(
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DemoNetDriver.cpp:1786
Scope (from outer to inner):
file
function void UDemoNetDriver::BuildSortedLevelPriorityOnLevels
Source code excerpt:
const FDemoActorPriority* Priorities = PrioritizedActorList.GetData();
const bool bHighPriorityPersistentLevel = DemoNetDriverRecordingPrivate::CVarDemoForcePersistentLevelPriority.GetValueOnAnyThread() != 0;
for (int32 Index = 0; Index < Count;)
{
const UObject* CurrentLevel = Priorities[Index].Level;
FLevelnterval Interval;