r.Nanite.FastVisBufferClear
r.Nanite.FastVisBufferClear
#Overview
name: r.Nanite.FastVisBufferClear
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Whether the fast clear optimization is enabled. Set to 2 for tile clear.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Nanite.FastVisBufferClear is to control the visibility buffer clearing optimization in the Nanite rendering system of Unreal Engine 5. It determines whether and how the fast clear optimization is enabled for the visibility buffer.
This setting variable is primarily used by the Nanite rendering system, which is part of Unreal Engine 5’s renderer module. Specifically, it’s utilized in the NaniteCullRaster component of the renderer.
The value of this variable is set through a console variable (CVarNaniteFastVisBufferClear) in the engine’s configuration. It can be set to 0, 1, or 2:
- 0: Disables the fast clear optimization
- 1: Enables pixel-based clear (default)
- 2: Enables tile-based clear
The associated variable CVarNaniteFastVisBufferClear directly interacts with r.Nanite.FastVisBufferClear. They share the same value and purpose.
Developers should be aware that this variable affects the performance of the Nanite rendering system. The fast clear optimization can potentially improve rendering performance, especially for complex scenes with many Nanite-enabled objects.
Best practices when using this variable include:
- Generally, leave it at the default value (1) unless specific performance issues are encountered.
- If performance issues arise in scenes with many Nanite objects, experiment with setting it to 2 (tile-based clear) to see if it improves performance.
- Only disable it (set to 0) if you encounter visual artifacts that may be related to the visibility buffer clearing process.
Regarding the associated variable CVarNaniteFastVisBufferClear:
The purpose of CVarNaniteFastVisBufferClear is identical to r.Nanite.FastVisBufferClear. It’s the actual console variable that controls the fast visibility buffer clear optimization in the Nanite rendering system.
This variable is used directly in the Nanite namespace, specifically in the AddClearVisBufferPass function of the NaniteCullRaster component.
The value of CVarNaniteFastVisBufferClear is set when the engine initializes its console variables, but it can be changed at runtime through console commands.
CVarNaniteFastVisBufferClear interacts directly with the rendering code that determines whether to use the fast clear optimization and which type of clear to use (pixel-based or tile-based).
Developers should be aware that changes to this variable will immediately affect the Nanite rendering pipeline. It’s thread-safe for the render thread, as indicated by the ECVF_RenderThreadSafe flag.
Best practices for using CVarNaniteFastVisBufferClear include:
- Use console commands to experiment with different values in real-time to assess performance impacts.
- Monitor performance metrics when changing this value to understand its impact on your specific scene or game.
- Consider exposing this setting to end-users as an advanced graphics option if your game heavily relies on Nanite rendering and could benefit from user-tunable performance optimizations.
#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:177
Scope: file
Source code excerpt:
// 2 : Tile Clear
static TAutoConsoleVariable<int32> CVarNaniteFastVisBufferClear(
TEXT("r.Nanite.FastVisBufferClear"),
1,
TEXT("Whether the fast clear optimization is enabled. Set to 2 for tile clear."),
ECVF_RenderThreadSafe
);
// Support a max of 3 unique materials per visible cluster (i.e. if all clusters are fast path and use full range, never run out of space).
#Associated Variable and Callsites
This variable is associated with another variable named CVarNaniteFastVisBufferClear
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/NaniteCullRaster.cpp:176
Scope: file
Source code excerpt:
// 1 : Pixel Clear
// 2 : Tile Clear
static TAutoConsoleVariable<int32> CVarNaniteFastVisBufferClear(
TEXT("r.Nanite.FastVisBufferClear"),
1,
TEXT("Whether the fast clear optimization is enabled. Set to 2 for tile clear."),
ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/NaniteCullRaster.cpp:4754
Scope (from outer to inner):
file
namespace Nanite
function void AddClearVisBufferPass
Source code excerpt:
}
const bool bUseFastClear = CVarNaniteFastVisBufferClear.GetValueOnRenderThread() != 0 && (RectMinMaxBufferSRV == nullptr && NumRects == 0 && ExternalDepthBuffer == nullptr);
if (bUseFastClear)
{
// TODO: Don't currently support offset views.
checkf(TextureRect.Min.X == 0 && TextureRect.Min.Y == 0, TEXT("Viewport offset support is not implemented."));
const bool bTiled = (CVarNaniteFastVisBufferClear.GetValueOnRenderThread() == 2);
FRasterClearCS::FParameters* PassParameters = GraphBuilder.AllocParameters<FRasterClearCS::FParameters>();
PassParameters->ClearRect = FUint32Vector4((uint32)TextureRect.Min.X, (uint32)TextureRect.Min.Y, (uint32)TextureRect.Max.X, (uint32)TextureRect.Max.Y);
PassParameters->RasterParameters = RasterContext.Parameters;
FRasterClearCS::FPermutationDomain PermutationVectorCS;