r.ShaderPrint.Lock
r.ShaderPrint.Lock
#Overview
name: r.ShaderPrint.Lock
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Lock the line drawing.\n
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.ShaderPrint.Lock is to control the locking of line drawing in the shader print functionality of Unreal Engine’s rendering system. This setting is used to enable or disable the locking mechanism for shader print lines.
This setting variable is primarily used in the Renderer module of Unreal Engine, specifically within the ShaderPrint namespace. It’s part of the shader debugging and visualization system, which allows developers to print debug information directly from shaders.
The value of this variable is set through the console variable system in Unreal Engine. It’s defined as a TAutoConsoleVariable with an initial value of 0, meaning it’s disabled by default. Developers can change this value at runtime using console commands.
The associated variable CVarDrawLock interacts directly with r.ShaderPrint.Lock. They share the same value and are used interchangeably in the code. The IsDrawLocked() function checks the value of CVarDrawLock to determine if line drawing should be locked.
Developers should be aware that this variable is marked with ECVF_Cheat and ECVF_RenderThreadSafe flags. The ECVF_Cheat flag indicates that it’s intended for debugging or cheating purposes and should not be exposed to end-users. The ECVF_RenderThreadSafe flag means it can be safely accessed from the render thread.
Best practices when using this variable include:
- Only enable it when necessary for debugging shader print issues.
- Remember to disable it after debugging to avoid any potential performance impact.
- Use it in conjunction with other shader print-related variables for comprehensive debugging.
- Be cautious when changing its value in a shipping build, as it’s marked as a cheat variable.
Regarding the associated variable CVarDrawLock:
The purpose of CVarDrawLock is to provide a programmatic way to access and modify the r.ShaderPrint.Lock setting. It’s an internal representation of the console variable within the C++ code.
CVarDrawLock is used in the Renderer module, specifically in the ShaderPrint namespace. It’s primarily accessed through the GetValueOnRenderThread() method in the IsDrawLocked() function.
The value of CVarDrawLock is set when r.ShaderPrint.Lock is modified through the console variable system. They are essentially two representations of the same setting.
Developers should be aware that CVarDrawLock is a TAutoConsoleVariable
Best practices for using CVarDrawLock include:
- Use the provided IsDrawLocked() function to check its state rather than accessing it directly.
- Remember that changes to this variable will affect shader print behavior across the entire rendering system.
- Consider the thread safety implications when accessing or modifying this variable, as it’s marked as render thread safe.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShaderPrint.cpp:72
Scope (from outer to inner):
file
namespace ShaderPrint
Source code excerpt:
static TAutoConsoleVariable<int32> CVarDrawLock(
TEXT("r.ShaderPrint.Lock"),
0,
TEXT("Lock the line drawing.\n"),
ECVF_Cheat | ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarDrawOccludedLines(
TEXT("r.ShaderPrint.DrawOccludedLines"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarDrawLock
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShaderPrint.cpp:71
Scope (from outer to inner):
file
namespace ShaderPrint
Source code excerpt:
ECVF_Cheat | ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarDrawLock(
TEXT("r.ShaderPrint.Lock"),
0,
TEXT("Lock the line drawing.\n"),
ECVF_Cheat | ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarDrawOccludedLines(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShaderPrint.cpp:178
Scope (from outer to inner):
file
namespace ShaderPrint
function static bool IsDrawLocked
Source code excerpt:
static bool IsDrawLocked()
{
return CVarDrawLock.GetValueOnRenderThread() > 0;
}
// Empty buffer for binding when ShaderPrint is disabled
class FEmptyBuffer : public FBufferWithRDG
{
public: