r.RHICmdBufferWriteLocks
r.RHICmdBufferWriteLocks
#Overview
name: r.RHICmdBufferWriteLocks
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Only relevant with an RHI thread. Debugging option to diagnose problems with buffered locks.
It is referenced in 16
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.RHICmdBufferWriteLocks is to control the buffering of write locks in the RHI (Rendering Hardware Interface) command system. This setting is primarily used for debugging issues related to buffered locks when running with an RHI thread.
The r.RHICmdBufferWriteLocks variable is mainly used in the OpenGL driver and RHI subsystems of Unreal Engine. It affects the behavior of texture and buffer locking operations in the rendering pipeline.
The value of this variable is set through the console variable system, with a default value of 1 (enabled). It can be changed at runtime using console commands or through configuration files.
This variable interacts closely with the RHI command list system and the OpenGL texture and buffer locking mechanisms. It’s associated with CVarRHICmdBufferWriteLocks, which is used to access its value in the code.
Developers should be aware that:
- This variable is only relevant when using an RHI thread.
- It affects the performance and behavior of texture and buffer locking operations.
- Changing its value can help diagnose problems related to buffered locks.
Best practices when using this variable include:
- Keep it enabled (value 1) for normal operation.
- Disable it (value 0) when investigating issues related to texture or buffer locking.
- Use it in conjunction with other RHI debugging tools when troubleshooting rendering issues.
Regarding the associated variable CVarRHICmdBufferWriteLocks: The purpose of CVarRHICmdBufferWriteLocks is to provide a convenient way to access the value of r.RHICmdBufferWriteLocks within the C++ code.
It is used in the OpenGL driver and RHI subsystems to determine whether to buffer write locks or not.
The value of CVarRHICmdBufferWriteLocks is set by the console variable system and reflects the current value of r.RHICmdBufferWriteLocks.
It interacts with various texture and buffer locking functions in the OpenGL driver.
Developers should be aware that changes to r.RHICmdBufferWriteLocks will be reflected in CVarRHICmdBufferWriteLocks.
Best practices include using CVarRHICmdBufferWriteLocks->GetValueOnRenderThread() to access the current value of the setting in render thread code.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/RHI/Private/RHICommandList.cpp:58
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarRHICmdBufferWriteLocks(
TEXT("r.RHICmdBufferWriteLocks"),
1,
TEXT("Only relevant with an RHI thread. Debugging option to diagnose problems with buffered locks."));
static TAutoConsoleVariable<int32> CVarRHICmdMaxOutstandingMemoryBeforeFlush(
TEXT("r.RHICmdMaxOutstandingMemoryBeforeFlush"),
256,
#Loc: <Workspace>/Engine/Source/Runtime/OpenGLDrv/Private/OpenGLTexture.cpp:1939
Scope (from outer to inner):
file
function void* FOpenGLDynamicRHI::LockTexture2D_RenderThread
Source code excerpt:
{
check(IsInRenderingThread());
static auto* CVarRHICmdBufferWriteLocks = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.RHICmdBufferWriteLocks"));
bool bBuffer = CVarRHICmdBufferWriteLocks->GetValueOnRenderThread() > 0;
void* Result;
uint32 MipBytes = 0;
if (!bBuffer || LockMode != RLM_WriteOnly || RHICmdList.Bypass() || !IsRunningRHIInSeparateThread())
{
RHITHREAD_GLCOMMAND_PROLOGUE();
#Loc: <Workspace>/Engine/Source/Runtime/OpenGLDrv/Private/OpenGLTexture.cpp:1970
Scope (from outer to inner):
file
function void FOpenGLDynamicRHI::UnlockTexture2D_RenderThread
Source code excerpt:
{
check(IsInRenderingThread());
static auto* CVarRHICmdBufferWriteLocks = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.RHICmdBufferWriteLocks"));
bool bBuffer = CVarRHICmdBufferWriteLocks->GetValueOnRenderThread() > 0;
FTextureLockTracker::FLockParams Params = GLLockTracker.Unlock(Texture, 0, MipIndex);
if (!bBuffer || Params.LockMode != RLM_WriteOnly || RHICmdList.Bypass() || !IsRunningRHIInSeparateThread())
{
GLLockTracker.TotalMemoryOutstanding = 0;
RHITHREAD_GLCOMMAND_PROLOGUE();
#Loc: <Workspace>/Engine/Source/Runtime/OpenGLDrv/Private/OpenGLTexture.cpp:2002
Scope (from outer to inner):
file
function void* FOpenGLDynamicRHI::RHILockTextureCubeFace_RenderThread
Source code excerpt:
{
check(IsInRenderingThread());
static auto* CVarRHICmdBufferWriteLocks = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.RHICmdBufferWriteLocks"));
bool bBuffer = CVarRHICmdBufferWriteLocks->GetValueOnRenderThread() > 0;
void* Result;
uint32 MipBytes = 0;
if (!bBuffer || LockMode != RLM_WriteOnly || RHICmdList.Bypass() || !IsRunningRHIInSeparateThread())
{
RHITHREAD_GLCOMMAND_PROLOGUE();
#Loc: <Workspace>/Engine/Source/Runtime/OpenGLDrv/Private/OpenGLTexture.cpp:2027
Scope (from outer to inner):
file
function void FOpenGLDynamicRHI::RHIUnlockTextureCubeFace_RenderThread
Source code excerpt:
{
check(IsInRenderingThread());
static auto* CVarRHICmdBufferWriteLocks = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.RHICmdBufferWriteLocks"));
bool bBuffer = CVarRHICmdBufferWriteLocks->GetValueOnRenderThread() > 0;
FTextureLockTracker::FLockParams Params = GLLockTracker.Unlock(Texture, ArrayIndex, MipIndex);
if (!bBuffer || Params.LockMode != RLM_WriteOnly || RHICmdList.Bypass() || !IsRunningRHIInSeparateThread())
{
GLLockTracker.TotalMemoryOutstanding = 0;
RHITHREAD_GLCOMMAND_PROLOGUE();
#Loc: <Workspace>/Engine/Source/Runtime/OpenGLDrv/Private/OpenGLTexture.cpp:2056
Scope (from outer to inner):
file
function void* FOpenGLDynamicRHI::LockTexture2DArray_RenderThread
Source code excerpt:
{
check(IsInRenderingThread());
static auto* CVarRHICmdBufferWriteLocks = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.RHICmdBufferWriteLocks"));
bool bBuffer = CVarRHICmdBufferWriteLocks->GetValueOnRenderThread() > 0;
void* Result;
uint32 MipBytes = 0;
if (!bBuffer || LockMode != RLM_WriteOnly || RHICmdList.Bypass() || !IsRunningRHIInSeparateThread())
{
RHITHREAD_GLCOMMAND_PROLOGUE();
#Loc: <Workspace>/Engine/Source/Runtime/OpenGLDrv/Private/OpenGLTexture.cpp:2082
Scope (from outer to inner):
file
function void FOpenGLDynamicRHI::UnlockTexture2DArray_RenderThread
Source code excerpt:
{
check(IsInRenderingThread());
static auto* CVarRHICmdBufferWriteLocks = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.RHICmdBufferWriteLocks"));
bool bBuffer = CVarRHICmdBufferWriteLocks->GetValueOnRenderThread() > 0;
FTextureLockTracker::FLockParams Params = GLLockTracker.Unlock(Texture, ArrayIndex, MipIndex);
if (!bBuffer || Params.LockMode != RLM_WriteOnly || RHICmdList.Bypass() || !IsRunningRHIInSeparateThread())
{
GLLockTracker.TotalMemoryOutstanding = 0;
RHITHREAD_GLCOMMAND_PROLOGUE();
#Associated Variable and Callsites
This variable is associated with another variable named CVarRHICmdBufferWriteLocks
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/OpenGLDrv/Private/OpenGLTexture.cpp:1939
Scope (from outer to inner):
file
function void* FOpenGLDynamicRHI::LockTexture2D_RenderThread
Source code excerpt:
{
check(IsInRenderingThread());
static auto* CVarRHICmdBufferWriteLocks = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.RHICmdBufferWriteLocks"));
bool bBuffer = CVarRHICmdBufferWriteLocks->GetValueOnRenderThread() > 0;
void* Result;
uint32 MipBytes = 0;
if (!bBuffer || LockMode != RLM_WriteOnly || RHICmdList.Bypass() || !IsRunningRHIInSeparateThread())
{
RHITHREAD_GLCOMMAND_PROLOGUE();
return this->RHILockTexture2D(Texture, MipIndex, LockMode, DestStride, bLockWithinMiptail, OutLockedByteCount);
#Loc: <Workspace>/Engine/Source/Runtime/OpenGLDrv/Private/OpenGLTexture.cpp:1970
Scope (from outer to inner):
file
function void FOpenGLDynamicRHI::UnlockTexture2D_RenderThread
Source code excerpt:
{
check(IsInRenderingThread());
static auto* CVarRHICmdBufferWriteLocks = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.RHICmdBufferWriteLocks"));
bool bBuffer = CVarRHICmdBufferWriteLocks->GetValueOnRenderThread() > 0;
FTextureLockTracker::FLockParams Params = GLLockTracker.Unlock(Texture, 0, MipIndex);
if (!bBuffer || Params.LockMode != RLM_WriteOnly || RHICmdList.Bypass() || !IsRunningRHIInSeparateThread())
{
GLLockTracker.TotalMemoryOutstanding = 0;
RHITHREAD_GLCOMMAND_PROLOGUE();
this->RHIUnlockTexture2D(Texture, MipIndex, bLockWithinMiptail);
#Loc: <Workspace>/Engine/Source/Runtime/OpenGLDrv/Private/OpenGLTexture.cpp:2002
Scope (from outer to inner):
file
function void* FOpenGLDynamicRHI::RHILockTextureCubeFace_RenderThread
Source code excerpt:
{
check(IsInRenderingThread());
static auto* CVarRHICmdBufferWriteLocks = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.RHICmdBufferWriteLocks"));
bool bBuffer = CVarRHICmdBufferWriteLocks->GetValueOnRenderThread() > 0;
void* Result;
uint32 MipBytes = 0;
if (!bBuffer || LockMode != RLM_WriteOnly || RHICmdList.Bypass() || !IsRunningRHIInSeparateThread())
{
RHITHREAD_GLCOMMAND_PROLOGUE();
return this->RHILockTextureCubeFace(Texture, FaceIndex, ArrayIndex, MipIndex, LockMode, DestStride, bLockWithinMiptail);
#Loc: <Workspace>/Engine/Source/Runtime/OpenGLDrv/Private/OpenGLTexture.cpp:2027
Scope (from outer to inner):
file
function void FOpenGLDynamicRHI::RHIUnlockTextureCubeFace_RenderThread
Source code excerpt:
{
check(IsInRenderingThread());
static auto* CVarRHICmdBufferWriteLocks = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.RHICmdBufferWriteLocks"));
bool bBuffer = CVarRHICmdBufferWriteLocks->GetValueOnRenderThread() > 0;
FTextureLockTracker::FLockParams Params = GLLockTracker.Unlock(Texture, ArrayIndex, MipIndex);
if (!bBuffer || Params.LockMode != RLM_WriteOnly || RHICmdList.Bypass() || !IsRunningRHIInSeparateThread())
{
GLLockTracker.TotalMemoryOutstanding = 0;
RHITHREAD_GLCOMMAND_PROLOGUE();
this->RHIUnlockTextureCubeFace(Texture, FaceIndex, ArrayIndex, MipIndex, bLockWithinMiptail);
#Loc: <Workspace>/Engine/Source/Runtime/OpenGLDrv/Private/OpenGLTexture.cpp:2056
Scope (from outer to inner):
file
function void* FOpenGLDynamicRHI::LockTexture2DArray_RenderThread
Source code excerpt:
{
check(IsInRenderingThread());
static auto* CVarRHICmdBufferWriteLocks = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.RHICmdBufferWriteLocks"));
bool bBuffer = CVarRHICmdBufferWriteLocks->GetValueOnRenderThread() > 0;
void* Result;
uint32 MipBytes = 0;
if (!bBuffer || LockMode != RLM_WriteOnly || RHICmdList.Bypass() || !IsRunningRHIInSeparateThread())
{
RHITHREAD_GLCOMMAND_PROLOGUE();
return this->RHILockTexture2DArray(Texture, ArrayIndex, MipIndex, LockMode, DestStride, bLockWithinMiptail);
#Loc: <Workspace>/Engine/Source/Runtime/OpenGLDrv/Private/OpenGLTexture.cpp:2082
Scope (from outer to inner):
file
function void FOpenGLDynamicRHI::UnlockTexture2DArray_RenderThread
Source code excerpt:
{
check(IsInRenderingThread());
static auto* CVarRHICmdBufferWriteLocks = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.RHICmdBufferWriteLocks"));
bool bBuffer = CVarRHICmdBufferWriteLocks->GetValueOnRenderThread() > 0;
FTextureLockTracker::FLockParams Params = GLLockTracker.Unlock(Texture, ArrayIndex, MipIndex);
if (!bBuffer || Params.LockMode != RLM_WriteOnly || RHICmdList.Bypass() || !IsRunningRHIInSeparateThread())
{
GLLockTracker.TotalMemoryOutstanding = 0;
RHITHREAD_GLCOMMAND_PROLOGUE();
this->RHIUnlockTexture2DArray(Texture, ArrayIndex, MipIndex, bLockWithinMiptail);
#Loc: <Workspace>/Engine/Source/Runtime/RHI/Private/RHICommandList.cpp:57
Scope: file
Source code excerpt:
TEXT("When it can be determined, merge small parallel translate tasks based on r.RHICmdMinDrawsPerParallelCmdList."));
static TAutoConsoleVariable<int32> CVarRHICmdBufferWriteLocks(
TEXT("r.RHICmdBufferWriteLocks"),
1,
TEXT("Only relevant with an RHI thread. Debugging option to diagnose problems with buffered locks."));
static TAutoConsoleVariable<int32> CVarRHICmdMaxOutstandingMemoryBeforeFlush(
TEXT("r.RHICmdMaxOutstandingMemoryBeforeFlush"),
#Loc: <Workspace>/Engine/Source/Runtime/RHI/Private/RHICommandList.cpp:1461
Scope (from outer to inner):
file
function void* FDynamicRHI::RHILockBuffer
Source code excerpt:
if (RHICmdList.IsTopOfPipe())
{
bool bBuffer = CVarRHICmdBufferWriteLocks.GetValueOnRenderThread() > 0;
if (!bBuffer || LockMode != RLM_WriteOnly)
{
QUICK_SCOPE_CYCLE_COUNTER(STAT_RHIMETHOD_LockBuffer_FlushAndLock);
CSV_SCOPED_TIMING_STAT(RHITFlushes, LockBuffer_BottomOfPipe);
FRHICommandListScopedFlushAndExecute Flush(RHICmdList.GetAsImmediate());
#Loc: <Workspace>/Engine/Source/Runtime/RHI/Private/RHICommandList.cpp:1497
Scope (from outer to inner):
file
function void FDynamicRHI::RHIUnlockBuffer
Source code excerpt:
FLockTracker::FLockParams Params = GLockTracker.Unlock(Buffer);
bool bBuffer = CVarRHICmdBufferWriteLocks.GetValueOnRenderThread() > 0;
if (!bBuffer || Params.LockMode != RLM_WriteOnly)
{
QUICK_SCOPE_CYCLE_COUNTER(STAT_RHIMETHOD_UnlockBuffer_FlushAndUnlock);
CSV_SCOPED_TIMING_STAT(RHITFlushes, UnlockBuffer_BottomOfPipe);
FRHICommandListScopedFlushAndExecute Flush(RHICmdList.GetAsImmediate());