r.Nanite.MaterialBuffers.PrimitiveDataMinSizeBytes
r.Nanite.MaterialBuffers.PrimitiveDataMinSizeBytes
#Overview
name: r.Nanite.MaterialBuffers.PrimitiveDataMinSizeBytes
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
The smallest size (in bytes) of the Nanite per-primitive material data buffer.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Nanite.MaterialBuffers.PrimitiveDataMinSizeBytes is to set the smallest size (in bytes) of the Nanite per-primitive material data buffer. This setting is primarily used in the rendering system, specifically for the Nanite geometry virtualization technology in Unreal Engine 5.
This setting variable is relied upon by the Nanite rendering subsystem within the Renderer module of Unreal Engine. It’s specifically used in the NaniteMaterialsSceneExtension, which is responsible for managing material-related data for Nanite-rendered objects.
The value of this variable is set as a console variable (CVar) with a default value of 4 * 1024 bytes (4 KB). It’s defined as read-only and render thread safe, meaning it can be safely accessed from the render thread but cannot be changed at runtime.
This variable interacts directly with its associated variable CVarNanitePrimitiveMaterialDataBufferMinSizeBytes. They share the same value and are used interchangeably in the code.
Developers must be aware that this variable affects the minimum size of the buffer used for storing per-primitive material data for Nanite objects. Setting this value too low might result in frequent buffer resizing, while setting it too high might waste memory.
Best practices when using this variable include:
- Only modify it if you have a specific need to change the minimum buffer size for Nanite primitive material data.
- Consider the memory implications when changing this value, especially on platforms with limited memory.
- Monitor performance and memory usage when adjusting this value to find the optimal setting for your specific use case.
Regarding the associated variable CVarNanitePrimitiveMaterialDataBufferMinSizeBytes:
This is the actual console variable that stores the value for r.Nanite.MaterialBuffers.PrimitiveDataMinSizeBytes. It’s used in the initialization of the PrimitiveDataBuffer in the FMaterialBuffers constructor of the FMaterialsSceneExtension class.
The purpose and usage considerations for CVarNanitePrimitiveMaterialDataBufferMinSizeBytes are identical to those of r.Nanite.MaterialBuffers.PrimitiveDataMinSizeBytes, as they represent the same setting. The main difference is that CVarNanitePrimitiveMaterialDataBufferMinSizeBytes is the actual C++ variable used in the code, while r.Nanite.MaterialBuffers.PrimitiveDataMinSizeBytes is the console command used to set or query this value.
When working with this variable, developers should use CVarNanitePrimitiveMaterialDataBufferMinSizeBytes.GetValueOnAnyThread() to retrieve its current value in C++ code, as shown in the FMaterialBuffers constructor.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/NaniteMaterialsSceneExtension.cpp:12
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarNanitePrimitiveMaterialDataBufferMinSizeBytes(
TEXT("r.Nanite.MaterialBuffers.PrimitiveDataMinSizeBytes"),
4 * 1024,
TEXT("The smallest size (in bytes) of the Nanite per-primitive material data buffer."),
ECVF_ReadOnly | ECVF_RenderThreadSafe
);
static TAutoConsoleVariable<bool> CVarNaniteMaterialBufferAsyncUpdates(
#Associated Variable and Callsites
This variable is associated with another variable named CVarNanitePrimitiveMaterialDataBufferMinSizeBytes
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/NaniteMaterialsSceneExtension.cpp:11
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<int32> CVarNanitePrimitiveMaterialDataBufferMinSizeBytes(
TEXT("r.Nanite.MaterialBuffers.PrimitiveDataMinSizeBytes"),
4 * 1024,
TEXT("The smallest size (in bytes) of the Nanite per-primitive material data buffer."),
ECVF_ReadOnly | ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/NaniteMaterialsSceneExtension.cpp:275
Scope (from outer to inner):
file
function FMaterialsSceneExtension::FMaterialBuffers::FMaterialBuffers
Source code excerpt:
FMaterialsSceneExtension::FMaterialBuffers::FMaterialBuffers() :
PrimitiveDataBuffer(
CVarNanitePrimitiveMaterialDataBufferMinSizeBytes.GetValueOnAnyThread() / 4,
TEXT("Nanite.PrimitiveMaterialData")
),
MaterialDataBuffer(
CVarNaniteMaterialDataBufferMinSizeBytes.GetValueOnAnyThread() / 4,
TEXT("Nanite.MaterialData")
)