r.ShaderPrint.MaxTriangle
r.ShaderPrint.MaxTriangle
#Overview
name: r.ShaderPrint.MaxTriangle
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
ShaderPrint max triangle count.\n
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.ShaderPrint.MaxTriangle is to set the maximum number of triangles that can be rendered using the ShaderPrint functionality in Unreal Engine’s rendering system. This setting is primarily used for debugging and visualization purposes within the rendering pipeline.
This setting variable is relied upon by the Renderer module of Unreal Engine, specifically within the ShaderPrint namespace. The ShaderPrint system is likely used for debugging shaders and visualizing shader-related information directly in the game viewport.
The value of this variable is set through a console variable (CVar) system, which allows it to be changed at runtime. It’s initialized with a default value of 32 triangles.
The associated variable CVarMaxTriangleCount directly interacts with r.ShaderPrint.MaxTriangle. They share the same value and purpose.
Developers must be aware of the following when using this variable:
- It’s marked with ECVF_Cheat and ECVF_RenderThreadSafe flags, indicating it’s intended for development/debug use and is safe to modify from the render thread.
- The actual maximum triangle count used by the system is calculated by adding this value to GCachedShaderPrintMaxRequest.TriangleCount, ensuring it’s never negative.
- Changing this value affects the memory allocation for shader print functionality, so setting it too high might impact performance or memory usage.
Best practices when using this variable include:
- Use it judiciously, primarily for debugging purposes.
- Be mindful of potential performance impacts when increasing the value significantly.
- Consider the needs of your specific debugging scenario when adjusting the value.
Regarding the associated variable CVarMaxTriangleCount:
- It’s a TAutoConsoleVariable
that directly corresponds to r.ShaderPrint.MaxTriangle. - It’s used in the GetMaxTriangleCount() function to retrieve the current maximum triangle count.
- When working with shader print functionality, developers should use this variable to read or modify the maximum triangle count.
- The same considerations and best practices apply to CVarMaxTriangleCount as to r.ShaderPrint.MaxTriangle.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShaderPrint.cpp:66
Scope (from outer to inner):
file
namespace ShaderPrint
Source code excerpt:
static TAutoConsoleVariable<int32> CVarMaxTriangleCount(
TEXT("r.ShaderPrint.MaxTriangle"),
32,
TEXT("ShaderPrint max triangle count.\n"),
ECVF_Cheat | ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarDrawLock(
TEXT("r.ShaderPrint.Lock"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarMaxTriangleCount
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShaderPrint.cpp:65
Scope (from outer to inner):
file
namespace ShaderPrint
Source code excerpt:
ECVF_Cheat | ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarMaxTriangleCount(
TEXT("r.ShaderPrint.MaxTriangle"),
32,
TEXT("ShaderPrint max triangle count.\n"),
ECVF_Cheat | ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarDrawLock(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShaderPrint.cpp:160
Scope (from outer to inner):
file
namespace ShaderPrint
function static uint32 GetMaxTriangleCount
Source code excerpt:
static uint32 GetMaxTriangleCount()
{
return FMath::Max(CVarMaxTriangleCount.GetValueOnAnyThread() + int32(GCachedShaderPrintMaxRequest.TriangleCount), 0);
}
// Returns the number of uints used for counters, a line element, and a triangle elements
static uint32 GetCountersUintSize() { return 4; }
static uint32 GetPackedLineUintSize() { return 8; }
static uint32 GetPackedTriangleUintSize() { return 12; }