r.Nanite.MaxPatchesPerGroup
r.Nanite.MaxPatchesPerGroup
#Overview
name: r.Nanite.MaxPatchesPerGroup
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Maximum number of patches to process per patch rasterizer group.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Nanite.MaxPatchesPerGroup is to control the maximum number of patches processed per patch rasterizer group in the Nanite rendering system. This setting is crucial for optimizing the performance and efficiency of Nanite’s virtualized geometry system.
This setting variable is primarily used by the Nanite subsystem within Unreal Engine’s rendering module. Specifically, it’s utilized in the NaniteCullRaster component, which is responsible for culling and rasterizing Nanite geometry.
The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 5, but can be changed at runtime or through configuration files.
The associated variable CVarNaniteMaxPatchesPerGroup directly interacts with r.Nanite.MaxPatchesPerGroup. They share the same value and purpose, with CVarNaniteMaxPatchesPerGroup being the actual C++ variable used in the code to access and modify the setting.
Developers must be aware that this variable directly impacts the performance and quality of Nanite rendering. Setting it too high might lead to performance issues, while setting it too low could potentially reduce the visual quality or efficiency of the Nanite system.
Best practices when using this variable include:
- Avoiding setting it to 0, as the code ensures a minimum value of 1.
- Considering the hardware capabilities of target platforms, as the effective value is capped by the GPU’s wave size.
- Profiling and testing different values to find the optimal balance between performance and visual quality for your specific use case.
Regarding the associated variable CVarNaniteMaxPatchesPerGroup:
The purpose of CVarNaniteMaxPatchesPerGroup is to provide a programmatic interface to the r.Nanite.MaxPatchesPerGroup setting within the C++ code of Unreal Engine.
This variable is used directly in the Nanite rendering subsystem, specifically in the NaniteCullRaster component.
The value of CVarNaniteMaxPatchesPerGroup is set through the CVar system, initialized with the same default value of 5 as r.Nanite.MaxPatchesPerGroup.
It interacts directly with the r.Nanite.MaxPatchesPerGroup setting, essentially serving as its in-code representation.
Developers should be aware that changes to CVarNaniteMaxPatchesPerGroup will directly affect the Nanite rendering process. It’s used in performance-critical code paths, so modifications should be made carefully.
Best practices for using CVarNaniteMaxPatchesPerGroup include:
- Using GetValueOnRenderThread() to access its value safely from the render thread.
- Considering the interaction with GRHIMinimumWaveSize when determining the effective value.
- Potentially exposing it as a user-configurable setting for advanced users or for debugging purposes.
#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:167
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarNaniteMaxPatchesPerGroup(
TEXT("r.Nanite.MaxPatchesPerGroup"),
5,
TEXT("Maximum number of patches to process per patch rasterizer group."),
ECVF_RenderThreadSafe
);
// 0 : Disabled
#Associated Variable and Callsites
This variable is associated with another variable named CVarNaniteMaxPatchesPerGroup
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/NaniteCullRaster.cpp:166
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<int32> CVarNaniteMaxPatchesPerGroup(
TEXT("r.Nanite.MaxPatchesPerGroup"),
5,
TEXT("Maximum number of patches to process per patch rasterizer group."),
ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/NaniteCullRaster.cpp:455
Scope (from outer to inner):
file
function static uint32 GetMaxPatchesPerGroup
Source code excerpt:
static uint32 GetMaxPatchesPerGroup()
{
return (uint32)FMath::Max(1, FMath::Min(CVarNaniteMaxPatchesPerGroup.GetValueOnRenderThread(), GRHIMinimumWaveSize / 3));
}
static bool UseAsyncComputeForShadowMaps(const FViewFamilyInfo& ViewFamily)
{
// Automatically disabled when Lumen async is enabled, as it then delays graphics pipe too much and regresses overall frame performance
return CVarNaniteAsyncRasterizeShadowDepths.GetValueOnRenderThread() != 0 && !Lumen::UseAsyncCompute(ViewFamily);