r.RHICmdMaxOutstandingMemoryBeforeFlush
r.RHICmdMaxOutstandingMemoryBeforeFlush
#Overview
name: r.RHICmdMaxOutstandingMemoryBeforeFlush
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
In kilobytes. The amount of outstanding memory before the RHI will force a flush. This should generally be set high enough that it doesn\'t happen on typical frames.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.RHICmdMaxOutstandingMemoryBeforeFlush is to control the threshold of outstanding memory before the Rendering Hardware Interface (RHI) forces a flush. This setting is primarily used in the rendering system of Unreal Engine 5.
This setting variable is utilized by the RHI subsystem, which is a crucial part of Unreal Engine’s rendering pipeline. It’s specifically used in the RHICommandList functionality, which manages the execution of rendering commands.
The value of this variable is set through the console variable system in Unreal Engine. It’s defined with a default value of 256 kilobytes, but can be changed at runtime or through configuration files.
The associated variable CVarRHICmdMaxOutstandingMemoryBeforeFlush directly interacts with r.RHICmdMaxOutstandingMemoryBeforeFlush. They share the same value and purpose.
Developers must be aware that this variable affects performance and memory management in the rendering pipeline. Setting it too low might cause frequent flushes, potentially impacting performance, while setting it too high might lead to excessive memory usage before a flush occurs.
Best practices when using this variable include:
- Keeping it high enough to prevent flushes on typical frames for optimal performance.
- Adjusting it based on the specific needs of the project and target hardware capabilities.
- Monitoring its impact on performance and memory usage when modifying its value.
Regarding the associated variable CVarRHICmdMaxOutstandingMemoryBeforeFlush:
- It’s an internal representation of the r.RHICmdMaxOutstandingMemoryBeforeFlush setting.
- It’s used directly in the C++ code to check against the current outstanding memory (GLockTracker.TotalMemoryOutstanding).
- When the outstanding memory exceeds the threshold set by this variable, it triggers a flush of the RHI command list.
- This variable is particularly important when running with an RHI thread, as mentioned in the comments.
Developers should treat CVarRHICmdMaxOutstandingMemoryBeforeFlush as the internal mechanism for applying the r.RHICmdMaxOutstandingMemoryBeforeFlush setting, and modify the setting through the proper console variable interfaces rather than directly manipulating this variable.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/RHI/Private/RHICommandList.cpp:63
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarRHICmdMaxOutstandingMemoryBeforeFlush(
TEXT("r.RHICmdMaxOutstandingMemoryBeforeFlush"),
256,
TEXT("In kilobytes. The amount of outstanding memory before the RHI will force a flush. This should generally be set high enough that it doesn't happen on typical frames."));
static FAutoConsoleTaskPriority CPrio_RHIThreadOnTaskThreads(
TEXT("TaskGraph.TaskPriorities.RHIThreadOnTaskThreads"),
TEXT("Task and thread priority for when we are running 'RHI thread' tasks on any thread."),
#Associated Variable and Callsites
This variable is associated with another variable named CVarRHICmdMaxOutstandingMemoryBeforeFlush
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/RHI/Private/RHICommandList.cpp:62
Scope: file
Source code excerpt:
TEXT("Only relevant with an RHI thread. Debugging option to diagnose problems with buffered locks."));
static TAutoConsoleVariable<int32> CVarRHICmdMaxOutstandingMemoryBeforeFlush(
TEXT("r.RHICmdMaxOutstandingMemoryBeforeFlush"),
256,
TEXT("In kilobytes. The amount of outstanding memory before the RHI will force a flush. This should generally be set high enough that it doesn't happen on typical frames."));
static FAutoConsoleTaskPriority CPrio_RHIThreadOnTaskThreads(
TEXT("TaskGraph.TaskPriorities.RHIThreadOnTaskThreads"),
#Loc: <Workspace>/Engine/Source/Runtime/RHI/Private/RHICommandList.cpp:1525
Scope (from outer to inner):
file
function void FDynamicRHI::RHIUnlockBuffer
Source code excerpt:
}
if (RHICmdList.IsImmediate() && GLockTracker.TotalMemoryOutstanding > uint32(CVarRHICmdMaxOutstandingMemoryBeforeFlush.GetValueOnRenderThread()) * 1024u)
{
QUICK_SCOPE_CYCLE_COUNTER(STAT_RHIMETHOD_UnlockBuffer_FlushForMem);
// we could be loading a level or something, lets get this stuff going
RHICmdList.GetAsImmediate().ImmediateFlush(EImmediateFlushType::DispatchToRHIThread);
GLockTracker.TotalMemoryOutstanding = 0;
}