r.Nanite.RasterSetupCache

r.Nanite.RasterSetupCache

#Overview

name: r.Nanite.RasterSetupCache

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.RasterSetupCache is to control the raster setup cache in Unreal Engine’s Nanite system, which is part of the rendering pipeline. This setting is specifically related to the Nanite virtualized geometry system, which is a core feature of Unreal Engine 5’s rendering capabilities.

The Nanite subsystem within the Renderer module relies on this setting variable. It is used in the NaniteCullRaster.cpp file, which suggests it’s involved in the culling and rasterization processes of Nanite geometry.

The value of this variable is set through a console variable (CVar) system. It is initialized with a default value of 1, indicating that the raster setup cache is enabled by default.

This variable interacts directly with its associated variable CVarNaniteRasterSetupCache. They share the same value and are used interchangeably in the code.

Developers must be aware that this variable affects the performance and behavior of the Nanite rendering system. Changing its value could impact rendering performance and potentially visual output.

Best practices when using this variable include:

  1. Testing thoroughly when modifying its value to ensure it doesn’t negatively impact performance or visual quality.
  2. Considering platform-specific implications, as the code checks for specific platforms before using this setting.
  3. Being cautious when disabling the raster setup cache (setting to 0), as it might have performance implications.

Regarding the associated variable CVarNaniteRasterSetupCache:

The purpose of CVarNaniteRasterSetupCache is to provide programmatic access to the r.Nanite.RasterSetupCache setting within the C++ code of the engine.

It is used in the Nanite subsystem of the Renderer module, specifically in the culling and rasterization processes.

The value of this variable is set through the console variable system, initialized with a default value of 1.

It directly interacts with r.Nanite.RasterSetupCache, sharing the same value.

Developers should be aware that this variable is used to control the behavior of the raster setup cache in runtime code. It’s accessed using the GetValueOnRenderThread() method, indicating it’s designed for use in render thread operations.

Best practices for using CVarNaniteRasterSetupCache include:

  1. Accessing its value only on the render thread to ensure thread-safety.
  2. Considering caching its value if used frequently, to avoid potential performance overhead from repeated calls to GetValueOnRenderThread().
  3. Being mindful of its impact on Nanite rendering performance when modifying its value programmatically.

#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:132

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarNaniteRasterSetupCache(
	TEXT("r.Nanite.RasterSetupCache"),
	1,
	TEXT(""),
	ECVF_RenderThreadSafe
);

TAutoConsoleVariable<float> CVarNaniteMaxPixelsPerEdge(

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<int32> CVarNaniteRasterSetupCache(
	TEXT("r.Nanite.RasterSetupCache"),
	1,
	TEXT(""),
	ECVF_RenderThreadSafe
);

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

Scope (from outer to inner):

file
function     static bool UseRasterSetupCache

Source code excerpt:

	return false;
#else
	return CVarNaniteRasterSetupCache.GetValueOnRenderThread() > 0;
#endif
}

static bool UseMeshShader(EShaderPlatform ShaderPlatform, Nanite::EPipeline Pipeline)
{
	if (!FDataDrivenShaderPlatformInfo::GetSupportsMeshShadersTier1(ShaderPlatform))