r.Nanite.MeshShaderRasterization

r.Nanite.MeshShaderRasterization

#Overview

name: r.Nanite.MeshShaderRasterization

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.MeshShaderRasterization is to control the usage of mesh shaders for hardware rasterization in Unreal Engine’s Nanite system. This setting is specifically related to the rendering system, particularly the Nanite geometry virtualization technology.

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

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1, meaning mesh shader rasterization is enabled by default if the hardware supports it.

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

Developers must be aware that this variable is render thread safe (ECVF_RenderThreadSafe), meaning it can be safely accessed from the render thread without causing race conditions.

Best practices when using this variable include:

  1. Ensure the target hardware supports mesh shaders before relying on this feature.
  2. Consider performance implications when enabling or disabling mesh shader rasterization.
  3. Use in conjunction with other Nanite-related settings for optimal performance.

Regarding the associated variable CVarNaniteMeshShaderRasterization:

The purpose of CVarNaniteMeshShaderRasterization is identical to r.Nanite.MeshShaderRasterization. It’s an internal representation of the console variable in C++ code.

This variable is used in the Nanite subsystem of the rendering module, specifically in the NaniteCullRaster.cpp file.

The value is set when the engine initializes the console variable system, with a default value of 1.

It directly interacts with the r.Nanite.MeshShaderRasterization console variable, as they represent the same setting.

Developers should be aware that this variable is accessed using GetValueOnAnyThread(), which suggests it’s designed for multi-threaded access.

Best practices include using this variable for runtime checks of the mesh shader rasterization setting, especially when determining whether to use mesh shaders in the rendering pipeline.

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarNaniteMeshShaderRasterization(
	TEXT("r.Nanite.MeshShaderRasterization"),
	1,
	TEXT("If available, use mesh shaders for hardware rasterization."),
	ECVF_RenderThreadSafe
);

static TAutoConsoleVariable<int32> CVarNanitePrimShaderRasterization(

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<int32> CVarNaniteMeshShaderRasterization(
	TEXT("r.Nanite.MeshShaderRasterization"),
	1,
	TEXT("If available, use mesh shaders for hardware rasterization."),
	ECVF_RenderThreadSafe
);

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

Scope (from outer to inner):

file
function     static bool UseMeshShader

Source code excerpt:


	// We require tier1 support to utilize primitive attributes
	const bool bSupported = CVarNaniteMeshShaderRasterization.GetValueOnAnyThread() != 0 && GRHISupportsMeshShadersTier1 && (!bAllowGlobalClipPlane || bMSSupportsClipDistance);
	return bSupported;
}

static bool UsePrimitiveShader()
{
	return CVarNanitePrimShaderRasterization.GetValueOnAnyThread() != 0 && GRHISupportsPrimitiveShaders;