r.ShaderPrint.MaxLine

r.ShaderPrint.MaxLine

#Overview

name: r.ShaderPrint.MaxLine

This variable is created as a Console Variable (cvar).

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.ShaderPrint.MaxLine is to control the maximum number of lines that can be printed using the ShaderPrint functionality in Unreal Engine 5. This setting is primarily used for debugging and visualization purposes within the rendering system.

The Unreal Engine subsystem that relies on this setting variable is the Renderer module, specifically the ShaderPrint namespace within the rendering system. This can be seen from the file location and namespace in the provided code excerpts.

The value of this variable is set through a console variable (CVar) system. It is initialized with a default value of 32 and can be changed at runtime using console commands or through code.

The associated variable CVarMaxLineCount directly interacts with r.ShaderPrint.MaxLine. They share the same value and purpose. The CVarMaxLineCount is used in the GetMaxLineCount() function to retrieve the current maximum line count.

Developers should be aware of the following when using this variable:

  1. It affects the performance and memory usage of the ShaderPrint functionality.
  2. It has the ECVF_Cheat and ECVF_RenderThreadSafe flags, indicating it’s intended for debugging and can be safely changed on the render thread.
  3. The actual maximum line count used by the system is calculated by adding this value to GCachedShaderPrintMaxRequest.LineCount.

Best practices when using this variable include:

  1. Only increase the value when necessary for debugging purposes.
  2. Be mindful of performance implications when setting a high value.
  3. Use in conjunction with other ShaderPrint settings for comprehensive debugging.
  4. Reset to the default value (32) when not actively debugging to minimize performance impact.

Regarding the associated variable CVarMaxLineCount: The purpose of CVarMaxLineCount is to provide a programmatic interface to the r.ShaderPrint.MaxLine console variable. It allows C++ code to read and potentially modify the maximum line count for ShaderPrint.

CVarMaxLineCount is used within the Renderer module, specifically in the ShaderPrint namespace. It’s primarily accessed in the GetMaxLineCount() function.

The value of CVarMaxLineCount is set through the console variable system, mirroring r.ShaderPrint.MaxLine.

CVarMaxLineCount directly interacts with r.ShaderPrint.MaxLine, as they represent the same setting.

Developers should be aware that changes to CVarMaxLineCount will affect the ShaderPrint system’s behavior and performance.

Best practices for using CVarMaxLineCount include:

  1. Use GetValueOnAnyThread() to safely read the value from any thread.
  2. Consider thread safety when modifying the value, as it affects the render thread.
  3. Use in conjunction with other ShaderPrint-related variables for a complete debugging setup.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShaderPrint.cpp:60

Scope (from outer to inner):

file
namespace    ShaderPrint

Source code excerpt:


	static TAutoConsoleVariable<int32> CVarMaxLineCount(
		TEXT("r.ShaderPrint.MaxLine"),
		32,
		TEXT("ShaderPrint max line count.\n"),
		ECVF_Cheat | ECVF_RenderThreadSafe);

	static TAutoConsoleVariable<int32> CVarMaxTriangleCount(
		TEXT("r.ShaderPrint.MaxTriangle"),

#Associated Variable and Callsites

This variable is associated with another variable named CVarMaxLineCount. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShaderPrint.cpp:59

Scope (from outer to inner):

file
namespace    ShaderPrint

Source code excerpt:

		ECVF_Cheat | ECVF_RenderThreadSafe);

	static TAutoConsoleVariable<int32> CVarMaxLineCount(
		TEXT("r.ShaderPrint.MaxLine"),
		32,
		TEXT("ShaderPrint max line count.\n"),
		ECVF_Cheat | ECVF_RenderThreadSafe);

	static TAutoConsoleVariable<int32> CVarMaxTriangleCount(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShaderPrint.cpp:155

Scope (from outer to inner):

file
namespace    ShaderPrint
function     static uint32 GetMaxLineCount

Source code excerpt:

	static uint32 GetMaxLineCount()
	{
		return FMath::Max(CVarMaxLineCount.GetValueOnAnyThread() + int32(GCachedShaderPrintMaxRequest.LineCount), 0);
	}

	static uint32 GetMaxTriangleCount()
	{
		return FMath::Max(CVarMaxTriangleCount.GetValueOnAnyThread() + int32(GCachedShaderPrintMaxRequest.TriangleCount), 0);
	}