p.Chaos.VD.CompressionMode
p.Chaos.VD.CompressionMode
#Overview
name: p.Chaos.VD.CompressionMode
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Oodle compression mode to use, 4 is by default which equsals to ECompressionLevel::VeryFast
It is referenced in 11
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.Chaos.VD.CompressionMode is to control the Oodle compression mode used for the Chaos Visual Debugger in Unreal Engine 5. This setting variable is primarily used for optimizing data compression in the debugging and visualization system for the Chaos physics engine.
The Chaos Visual Debugger subsystem within Unreal Engine’s Experimental Chaos module relies on this setting variable. It is used specifically in the ChaosVisualDebuggerTrace.cpp file, which is part of the Chaos physics engine’s visual debugging functionality.
The value of this variable is set through a console variable (CVar) system. It is initialized with a default value of 2 and can be modified at runtime using the console command “p.Chaos.VD.CompressionMode”.
This variable interacts with the Oodle compression library, which is used to compress binary data before it is traced or sent for debugging purposes. The compression mode directly affects the performance and efficiency of the data compression process.
Developers should be aware that:
- The value of this variable corresponds to Oodle’s ECompressionLevel enum.
- A value of 4 is equivalent to ECompressionLevel::VeryFast, which is mentioned as a reference point in the comments.
- Changing this value will affect the trade-off between compression speed and compression ratio.
Best practices when using this variable include:
- Adjusting the compression mode based on the specific needs of the debugging session. Higher values may provide better compression but at the cost of increased processing time.
- Monitoring the performance impact of different compression modes during debugging sessions.
- Using lower compression modes (faster, less compression) for real-time debugging scenarios and higher modes (slower, more compression) for offline analysis if network bandwidth or storage is a concern.
Regarding the associated variable CompressionMode, it appears to be used in different contexts across the engine:
- In the RemoteControlWebSocketServer, it’s used to determine the compression mode for websocket communications.
- In the CSV Profiler, it’s used to set the compression mode for CSV output.
- In the RHI (Rendering Hardware Interface), it’s used as part of the FReadSurfaceDataFlags class to specify how surface data should be compressed or scaled when read back.
Each of these usages has its own considerations and best practices, but they all relate to managing data compression in different parts of the engine. Developers should be careful to use the appropriate CompressionMode variable for their specific context, as they are not directly related despite sharing the same name.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/ChaosVisualDebugger/ChaosVisualDebuggerTrace.cpp:50
Scope (from outer to inner):
file
namespace Chaos::VisualDebugger::Cvars
Source code excerpt:
static int32 CompressionMode = 2;
FAutoConsoleVariableRef CVarChaosVDCompressionMode(
TEXT("p.Chaos.VD.CompressionMode"),
CompressionMode,
TEXT("Oodle compression mode to use, 4 is by default which equsals to ECompressionLevel::VeryFast"));
}
/** Struct where we keep track of the geometry we are tracing */
struct FChaosVDGeometryTraceContext
#Associated Variable and Callsites
This variable is associated with another variable named CompressionMode
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/VirtualProduction/RemoteControl/Source/WebRemoteControl/Private/RemoteControlWebSocketServer.cpp:214
Scope (from outer to inner):
file
function void FRCWebSocketServer::SetClientCompressionMode
Source code excerpt:
}
Connection.CompressionMode = Mode;
break;
}
}
bool FRCWebSocketServer::Tick(float DeltaTime)
{
#Loc: <Workspace>/Engine/Plugins/VirtualProduction/RemoteControl/Source/WebRemoteControl/Private/RemoteControlWebSocketServer.cpp:257
Scope (from outer to inner):
file
function void FRCWebSocketServer::ReceivedRawPacket
Source code excerpt:
if (FWebSocketConnection* Connection = GetClientById(ClientId))
{
switch (Connection->CompressionMode)
{
case ERCWebSocketCompressionMode::ZLIB:
{
TRACE_CPUPROFILER_EVENT_SCOPE(DecompressWebSocketData);
// Read the header containing the message's uncompressed size
#Loc: <Workspace>/Engine/Plugins/VirtualProduction/RemoteControl/Source/WebRemoteControl/Private/RemoteControlWebSocketServer.cpp:343
Scope (from outer to inner):
file
function void FRCWebSocketServer::SendOnConnection
Source code excerpt:
}
switch (Connection.CompressionMode)
{
case ERCWebSocketCompressionMode::ZLIB:
{
TRACE_CPUPROFILER_EVENT_SCOPE(CompressWebSocketData);
int32 CompressedSize = InUTF8Payload.Num();
#Loc: <Workspace>/Engine/Plugins/VirtualProduction/RemoteControl/Source/WebRemoteControl/Private/RemoteControlWebSocketServer.h:191
Scope (from outer to inner):
file
class class FRCWebSocketServer
class class FWebSocketConnection
Source code excerpt:
/** Compression mode to use for this client. */
ERCWebSocketCompressionMode CompressionMode = ERCWebSocketCompressionMode::NONE;
};
private:
/** Handle to the tick delegate. */
FTSTicker::FDelegateHandle TickerHandle;
#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/ProfilingDebugging/CsvProfiler.cpp:3880
Scope (from outer to inner):
file
function void FCsvProfiler::Init
Source code excerpt:
FParse::Value(FCommandLine::Get(), TEXT("csvRepeat="), GCsvRepeatCount);
int32 CompressionMode;
if (FParse::Value(FCommandLine::Get(), TEXT("csvCompression="), CompressionMode))
{
switch (CompressionMode)
{
case 0: CVarCsvCompressionMode->Set(0); break;
case 1: CVarCsvCompressionMode->Set(1); break;
default:
UE_LOG(LogCsvProfiler, Warning, TEXT("Invalid command line compression mode \"%d\"."), CompressionMode);
break;
}
}
GCsvABTest.InitFromCommandline();
// Handle -csvExeccmds
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/ChaosVisualDebugger/ChaosVisualDebuggerTrace.cpp:48
Scope (from outer to inner):
file
namespace Chaos::VisualDebugger::Cvars
Source code excerpt:
TEXT("If true, serialized binary data will be compressed using Oodle on the fly before being traced"));
static int32 CompressionMode = 2;
FAutoConsoleVariableRef CVarChaosVDCompressionMode(
TEXT("p.Chaos.VD.CompressionMode"),
CompressionMode,
TEXT("Oodle compression mode to use, 4 is by default which equsals to ECompressionLevel::VeryFast"));
}
/** Struct where we keep track of the geometry we are tracing */
struct FChaosVDGeometryTraceContext
{
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/ChaosVisualDebugger/ChaosVisualDebuggerTrace.cpp:569
Scope (from outer to inner):
file
function void FChaosVisualDebuggerTrace::TraceBinaryData
Source code excerpt:
CompressedData.Reserve(CompressedData.Num());
FOodleCompressedArray::CompressData(CompressedData, InData.GetData(),InData.Num(), FOodleDataCompression::ECompressor::Kraken,
static_cast<FOodleDataCompression::ECompressionLevel>(Chaos::VisualDebugger::Cvars::CompressionMode));
DataViewToTrace = CompressedData;
}
const uint32 DataSize = static_cast<uint32>(DataViewToTrace.Num());
constexpr uint32 MaxChunkSize = TNumericLimits<uint16>::Max();
#Loc: <Workspace>/Engine/Source/Runtime/RHI/Public/RHITypes.h:16
Scope (from outer to inner):
file
class class FReadSurfaceDataFlags
Source code excerpt:
public:
// @param InCompressionMode defines the value input range that is mapped to output range
// The default CompressionMode of RCM_UNorm will modify values to fit in [0,1]
// it is recommended to always use RCM_MinMax instead, which leaves values unchanged
// if you do want scaling into [0,1] do it after the fact using ScaleChannelsSoMinMaxIsInZeroToOne
// @param InCubeFace defined which cubemap side is used, only required for cubemap content, then it needs to be a valid side
FReadSurfaceDataFlags(ERangeCompressionMode InCompressionMode = RCM_UNorm, ECubeFace InCubeFace = CubeFace_MAX)
:CubeFace(InCubeFace), CompressionMode(InCompressionMode)
{
}
ECubeFace GetCubeFace() const
{
return CubeFace;
#Loc: <Workspace>/Engine/Source/Runtime/RHI/Public/RHITypes.h:36
Scope (from outer to inner):
file
class class FReadSurfaceDataFlags
function ERangeCompressionMode GetCompressionMode
Source code excerpt:
ERangeCompressionMode GetCompressionMode() const
{
return CompressionMode;
}
void SetLinearToGamma(bool Value)
{
bLinearToGamma = Value;
}
#Loc: <Workspace>/Engine/Source/Runtime/RHI/Public/RHITypes.h:113
Scope (from outer to inner):
file
class class FReadSurfaceDataFlags
Source code excerpt:
ECubeFace CubeFace = CubeFace_MAX;
ERangeCompressionMode CompressionMode = RCM_UNorm;
bool bLinearToGamma = true;
float MaxDepthRange = 16000.0f;
bool bOutputStencil = false;
uint8 MipLevel = 0;
int32 ArrayIndex = 0;
uint32 GPUIndex = 0;