r.Nanite.TestPrecacheDrawSkipping

r.Nanite.TestPrecacheDrawSkipping

#Overview

name: r.Nanite.TestPrecacheDrawSkipping

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.Nanite.TestPrecacheDrawSkipping is to simulate a scenario where all programmable raster draws are not precached yet in the Nanite rendering system of Unreal Engine 5. This setting is primarily used for testing and debugging purposes within the Nanite rendering pipeline.

This setting variable is used in the Nanite subsystem of Unreal Engine’s rendering module. Specifically, it’s referenced in the NaniteCullRaster.cpp file, which is part of the Nanite rendering implementation.

The value of this variable is set through a console variable (CVarNaniteTestPrecacheDrawSkipping) using the TAutoConsoleVariable template. It’s initialized with a default value of 0, meaning the feature is disabled by default.

The associated variable CVarNaniteTestPrecacheDrawSkipping directly interacts with r.Nanite.TestPrecacheDrawSkipping. They share the same value and purpose.

Developers must be aware that enabling this variable (setting it to 1) will simulate a scenario where all programmable raster draws are treated as if they are not precached. This can significantly impact rendering performance and should only be used for testing or debugging purposes.

Best practices when using this variable include:

  1. Only enable it when specifically testing precache draw skipping behavior.
  2. Remember to disable it (set to 0) after testing to restore normal rendering behavior.
  3. Use it in conjunction with other Nanite debugging tools and variables for comprehensive testing.
  4. Be prepared for potential performance degradation when enabled.

Regarding the associated variable CVarNaniteTestPrecacheDrawSkipping:

The purpose of CVarNaniteTestPrecacheDrawSkipping is to provide programmatic access to the r.Nanite.TestPrecacheDrawSkipping setting within the C++ code of the Nanite renderer.

This variable is used in the Nanite rendering subsystem, specifically in the DispatchHW function of the FRenderer class.

The value of CVarNaniteTestPrecacheDrawSkipping is set through the console variable system and can be accessed at runtime using the GetValueOnRenderThread() method.

CVarNaniteTestPrecacheDrawSkipping directly interacts with r.Nanite.TestPrecacheDrawSkipping, as they represent the same setting.

Developers should be aware that this variable is checked on the render thread, which means changes to its value will affect rendering behavior in real-time.

Best practices for using CVarNaniteTestPrecacheDrawSkipping include:

  1. Access its value using GetValueOnRenderThread() when in render thread code.
  2. Use it in conjunction with other render thread safe operations.
  3. Consider the performance implications of frequently querying this value in performance-critical code paths.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/NaniteCullRaster.cpp:322

Scope: file

Source code excerpt:

// Set to 1 to pretend all programmable raster draws are not precached yet
TAutoConsoleVariable<int32> CVarNaniteTestPrecacheDrawSkipping(
	TEXT("r.Nanite.TestPrecacheDrawSkipping"),
	0,
	TEXT("Set to 1 to pretend all programmable raster draws are not precached yet."),
	ECVF_RenderThreadSafe
);

static bool UseRasterSetupCache()

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/NaniteCullRaster.cpp:321

Scope: file

Source code excerpt:


// Set to 1 to pretend all programmable raster draws are not precached yet
TAutoConsoleVariable<int32> CVarNaniteTestPrecacheDrawSkipping(
	TEXT("r.Nanite.TestPrecacheDrawSkipping"),
	0,
	TEXT("Set to 1 to pretend all programmable raster draws are not precached yet."),
	ECVF_RenderThreadSafe
);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/NaniteCullRaster.cpp:2514

Scope (from outer to inner):

file
namespace    Nanite
class        class FRenderer : public FSceneRenderingAllocatorObject< FRenderer >, public IRenderer
function     void DispatchHW

Source code excerpt:

		{
			const bool bAllowPrecacheSkip = GSkipDrawOnPSOPrecaching != 0;
			const bool bTestPrecacheSkip = CVarNaniteTestPrecacheDrawSkipping.GetValueOnRenderThread() != 0;

			if (DispatchList.Indirections.Num() > 0)
			{
				FRHIRenderPassInfo RPInfo;
				RPInfo.ResolveRect = FResolveRect(ViewRect);