demo.RecordHz
demo.RecordHz
#Overview
name: demo.RecordHz
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:
Maximum number of demo frames recorded per second
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of demo.RecordHz is to control the maximum number of demo frames recorded per second in Unreal Engine’s demo recording system. This setting variable is primarily used for the networking and replay system of Unreal Engine.
Based on the callsites, this setting variable is mainly used in the DemoNetDriver module, which is part of Unreal Engine’s networking subsystem. It’s specifically utilized in the demo recording and playback functionality.
The value of this variable is set as a console variable with a default value of 8 frames per second. It can be modified at runtime through the console or configuration files.
There are several other variables that interact with demo.RecordHz:
- demo.MinRecordHz: Sets the minimum number of demo frames recorded per second.
- CVarDemoRecordHz: This is the associated C++ variable that directly corresponds to demo.RecordHz.
Developers must be aware of the following when using this variable:
- It sets an upper limit on the recording frame rate, which can affect the fidelity of the recorded demo.
- It interacts with demo.MinRecordHz, and the engine ensures that the maximum value is always greater than or equal to the minimum value.
- The actual value used in the engine is accessed through CVarDemoRecordHz.GetValueOnAnyThread().
Best practices when using this variable include:
- Balance between demo fidelity and file size by adjusting this value appropriately.
- Consider the game’s requirements and target platforms when setting this value.
- Test thoroughly with different values to ensure optimal performance and replay quality.
Regarding the associated variable CVarDemoRecordHz:
The purpose of CVarDemoRecordHz is to provide a C++ interface to the demo.RecordHz console variable. It allows the engine code to access and modify the RecordHz value programmatically.
This variable is used in the same subsystems as demo.RecordHz, primarily in the DemoNetDriver and ReplayHelper modules.
The value of CVarDemoRecordHz is set when the console variable demo.RecordHz is initialized or modified.
Developers should be aware that:
- Changes to demo.RecordHz will be reflected in CVarDemoRecordHz.
- The value should be accessed using GetValueOnAnyThread() to ensure thread-safety.
Best practices for using CVarDemoRecordHz include:
- Use it consistently throughout the codebase when referring to the maximum demo record rate.
- Consider caching the value if it’s accessed frequently in performance-critical sections of code.
- Be aware of potential race conditions when modifying or reading this value in a multi-threaded environment.
#Setting Variables
#References In INI files
Location: <Workspace>/Projects/Lyra/Config/DefaultEngine.ini:156, section: [ConsoleVariables]
- INI Section:
ConsoleVariables
- Raw value:
60.0
- 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/DemoNetDriver.cpp:45
Scope: file
Source code excerpt:
#endif
TAutoConsoleVariable<float> CVarDemoRecordHz( TEXT( "demo.RecordHz" ), 8, TEXT( "Maximum number of demo frames recorded per second" ) );
TAutoConsoleVariable<float> CVarDemoMinRecordHz(TEXT("demo.MinRecordHz"), 0, TEXT("Minimum number of demo frames recorded per second (use with care)"));
static TAutoConsoleVariable<float> CVarDemoTimeDilation( TEXT( "demo.TimeDilation" ), -1.0f, TEXT( "Override time dilation during demo playback (-1 = don't override)" ) );
static TAutoConsoleVariable<float> CVarDemoSkipTime( TEXT( "demo.SkipTime" ), 0, TEXT( "Skip fixed amount of network replay time (in seconds)" ) );
TAutoConsoleVariable<int32> CVarEnableCheckpoints( TEXT( "demo.EnableCheckpoints" ), 1, TEXT( "Whether or not checkpoints save on the server" ) );
static TAutoConsoleVariable<float> CVarGotoTimeInSeconds( TEXT( "demo.GotoTimeInSeconds" ), -1, TEXT( "For testing only, jump to a particular time" ) );
static TAutoConsoleVariable<int32> CVarDemoFastForwardDestroyTearOffActors( TEXT( "demo.FastForwardDestroyTearOffActors" ), 1, TEXT( "If true, the driver will destroy any torn-off actors immediately while fast-forwarding a replay." ) );
#Associated Variable and Callsites
This variable is associated with another variable named CVarDemoRecordHz
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DemoNetDriver.cpp:45
Scope: file
Source code excerpt:
#endif
TAutoConsoleVariable<float> CVarDemoRecordHz( TEXT( "demo.RecordHz" ), 8, TEXT( "Maximum number of demo frames recorded per second" ) );
TAutoConsoleVariable<float> CVarDemoMinRecordHz(TEXT("demo.MinRecordHz"), 0, TEXT("Minimum number of demo frames recorded per second (use with care)"));
static TAutoConsoleVariable<float> CVarDemoTimeDilation( TEXT( "demo.TimeDilation" ), -1.0f, TEXT( "Override time dilation during demo playback (-1 = don't override)" ) );
static TAutoConsoleVariable<float> CVarDemoSkipTime( TEXT( "demo.SkipTime" ), 0, TEXT( "Skip fixed amount of network replay time (in seconds)" ) );
TAutoConsoleVariable<int32> CVarEnableCheckpoints( TEXT( "demo.EnableCheckpoints" ), 1, TEXT( "Whether or not checkpoints save on the server" ) );
static TAutoConsoleVariable<float> CVarGotoTimeInSeconds( TEXT( "demo.GotoTimeInSeconds" ), -1, TEXT( "For testing only, jump to a particular time" ) );
static TAutoConsoleVariable<int32> CVarDemoFastForwardDestroyTearOffActors( TEXT( "demo.FastForwardDestroyTearOffActors" ), 1, TEXT( "If true, the driver will destroy any torn-off actors immediately while fast-forwarding a replay." ) );
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DemoNetDriver.cpp:2169
Scope (from outer to inner):
file
function void UDemoNetDriver::TickDemoRecordFrame
Source code excerpt:
float MinRecordHz = CVarDemoMinRecordHz.GetValueOnAnyThread();
float MaxRecordHz = CVarDemoRecordHz.GetValueOnAnyThread();
if (MaxRecordHz < MinRecordHz)
{
Swap(MinRecordHz, MaxRecordHz);
}
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/ReplayHelper.cpp:28
Scope: file
Source code excerpt:
extern TAutoConsoleVariable<int32> CVarDemoUseNetRelevancy;
extern TAutoConsoleVariable<int32> CVarDemoClientRecordAsyncEndOfFrame;
extern TAutoConsoleVariable<float> CVarDemoRecordHz;
extern TAutoConsoleVariable<float> CVarDemoMinRecordHz;
CSV_DECLARE_CATEGORY_EXTERN(Demo);
FReplayHelper::FReplayHelper()
: CurrentLevelIndex(0)
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/ReplayHelper.cpp:282
Scope (from outer to inner):
file
function void FReplayHelper::WriteNetworkDemoHeader
Source code excerpt:
DemoHeader.MinRecordHz = CVarDemoMinRecordHz.GetValueOnAnyThread();
DemoHeader.MaxRecordHz = CVarDemoRecordHz.GetValueOnAnyThread();
DemoHeader.Platform = FPlatformProperties::PlatformName();
DemoHeader.BuildConfig = FApp::GetBuildConfiguration();
DemoHeader.BuildTarget = FApp::GetBuildTargetType();
if (FNetworkReplayDelegates::GetOverridableVersionDataForHeaderWrite.IsBound())