r.Nanite.OccludedInstancesBufferSizeMultiplier

r.Nanite.OccludedInstancesBufferSizeMultiplier

#Overview

name: r.Nanite.OccludedInstancesBufferSizeMultiplier

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.OccludedInstancesBufferSizeMultiplier is to control the size of the buffer used for occluded instances in the Nanite rendering system. This setting variable is part of Unreal Engine 5’s Nanite geometry system, which is responsible for rendering highly detailed meshes efficiently.

The Unreal Engine subsystem that relies on this setting variable is the Nanite rendering module, specifically the culling and rasterization component. This can be seen from the file location “NaniteCullRaster.cpp” where the variable is defined and used.

The value of this variable is set as a console variable with a default value of 1.0f. It can be modified at runtime through the console or configuration files.

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

Developers must be aware that this variable affects the memory allocation for occluded instances in the Nanite system. Increasing this value will allocate more memory for occluded instances, which may improve performance in scenes with many occluded objects but at the cost of higher memory usage.

Best practices when using this variable include:

  1. Keep the default value (1.0f) unless there’s a specific need to change it.
  2. If modifying, monitor performance and memory usage to find the optimal balance for your specific scene.
  3. Be cautious when increasing the value, as it directly impacts memory consumption.

Regarding the associated variable CVarNaniteOccludedInstancesBufferSizeMultiplier:

The purpose of CVarNaniteOccludedInstancesBufferSizeMultiplier is the same as r.Nanite.OccludedInstancesBufferSizeMultiplier. It’s an internal representation of the console variable used within the C++ code.

This variable is used in the Nanite renderer, specifically in the FRenderer constructor, to calculate the size of the buffer for occluded instances.

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

It interacts directly with r.Nanite.OccludedInstancesBufferSizeMultiplier, as they represent the same setting.

Developers should be aware that this variable is used in performance-critical code and affects memory allocation. Changes to this value can impact both rendering performance and memory usage.

Best practices for using this variable include:

  1. Access the value using GetValueOnRenderThread() to ensure thread-safe access.
  2. Consider the impact on memory usage when modifying this value, especially on platforms with limited memory.
  3. Profile and test thoroughly when adjusting this value to ensure optimal performance for your specific use case.

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarNaniteOccludedInstancesBufferSizeMultiplier(
	TEXT("r.Nanite.OccludedInstancesBufferSizeMultiplier"),
	1.0f,
	TEXT("DEBUG"),
	ECVF_RenderThreadSafe | ECVF_Default);

static DynamicRenderScaling::FHeuristicSettings GetDynamicNaniteScalingPrimarySettings()
{

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe | ECVF_Default);

static TAutoConsoleVariable<float> CVarNaniteOccludedInstancesBufferSizeMultiplier(
	TEXT("r.Nanite.OccludedInstancesBufferSizeMultiplier"),
	1.0f,
	TEXT("DEBUG"),
	ECVF_RenderThreadSafe | ECVF_Default);

static DynamicRenderScaling::FHeuristicSettings GetDynamicNaniteScalingPrimarySettings()

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

Scope (from outer to inner):

file
namespace    Nanite
function     FRenderer::FRenderer

Source code excerpt:

	// TODO: Might this not break if the view has overridden the InstanceSceneData?
	const uint32 NumSceneInstancesPo2 = 
		uint32(CVarNaniteOccludedInstancesBufferSizeMultiplier.GetValueOnRenderThread() *
			   FMath::RoundUpToPowerOfTwo(FMath::Max(1024u * 128u, Scene.GPUScene.GetInstanceIdUpperBoundGPU())));
	
	PageConstants.X					= Scene.GPUScene.InstanceSceneDataSOAStride;
	PageConstants.Y					= Nanite::GStreamingManager.GetMaxStreamingPages();
	
	QueueState						= GraphBuilder.CreateBuffer( FRDGBufferDesc::CreateStructuredDesc( (6*2 + 1) * sizeof(uint32), 1), TEXT("Nanite.QueueState"));