r.SupportDepthOnlyIndexBuffers
r.SupportDepthOnlyIndexBuffers
#Overview
name: r.SupportDepthOnlyIndexBuffers
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Enables depth-only index buffers. Saves a little time at the expense of doubling the size of index buffers.
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.SupportDepthOnlyIndexBuffers is to enable or disable the use of depth-only index buffers in Unreal Engine’s rendering system. This setting is primarily related to the rendering optimization for static meshes.
-
The r.SupportDepthOnlyIndexBuffers setting is used in the Engine module, specifically within the StaticMesh rendering system.
-
The value of this variable is set through a console variable (CVar) system. It is initialized with a default value of 1 (enabled) and can be changed at runtime through console commands.
-
This variable interacts closely with CVarSupportDepthOnlyIndexBuffers, which is the associated console variable that stores and manages the actual value.
-
Developers should be aware that enabling this feature (set to 1) can save rendering time but at the cost of doubling the size of index buffers. This trade-off between performance and memory usage should be considered based on the specific needs of the project.
-
Best practices when using this variable include:
- Evaluating the performance impact in your specific use case.
- Considering the memory implications, especially for projects with memory constraints.
- Testing thoroughly with both enabled and disabled states to ensure optimal performance.
Regarding the associated variable CVarSupportDepthOnlyIndexBuffers:
-
The purpose of CVarSupportDepthOnlyIndexBuffers is to store and manage the actual value of the r.SupportDepthOnlyIndexBuffers setting.
-
It is used in the same Engine module and StaticMesh rendering system.
-
The value is set at initialization and can be accessed through GetValueOnAnyThread() method calls.
-
This variable directly influences the behavior of static mesh rendering, particularly in the calculation of buffer sizes and the serialization of static mesh data.
-
Developers should be aware that this variable is marked as read-only and render thread safe, meaning its value should not be changed frequently during runtime.
-
Best practices for using this variable include:
- Accessing its value through the provided GetValueOnAnyThread() method.
- Considering its impact on static mesh loading and rendering when modifying related systems.
- Being cautious about changing its value during runtime, as it may affect ongoing rendering processes.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/StaticMesh.cpp:131
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarSupportDepthOnlyIndexBuffers(
TEXT("r.SupportDepthOnlyIndexBuffers"),
1,
TEXT("Enables depth-only index buffers. Saves a little time at the expense of doubling the size of index buffers."),
ECVF_ReadOnly | ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarSupportReversedIndexBuffers(
TEXT("r.SupportReversedIndexBuffers"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarSupportDepthOnlyIndexBuffers
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/StaticMesh.cpp:130
Scope: file
Source code excerpt:
TEXT("If non-zero, mobile setting for MinLOD will be stored in the cooked data for desktop platforms"));
static TAutoConsoleVariable<int32> CVarSupportDepthOnlyIndexBuffers(
TEXT("r.SupportDepthOnlyIndexBuffers"),
1,
TEXT("Enables depth-only index buffers. Saves a little time at the expense of doubling the size of index buffers."),
ECVF_ReadOnly | ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarSupportReversedIndexBuffers(
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/StaticMesh.cpp:460
Scope (from outer to inner):
file
function uint32 FStaticMeshLODResources::FStaticMeshBuffersSize::CalcBuffersSize
Source code excerpt:
{
// Assumes these two cvars don't change at runtime
const bool bEnableDepthOnlyIndexBuffer = !!CVarSupportDepthOnlyIndexBuffers.GetValueOnAnyThread();
const bool bEnableReversedIndexBuffer = !!CVarSupportReversedIndexBuffers.GetValueOnAnyThread();
return SerializedBuffersSize
- (bEnableDepthOnlyIndexBuffer ? 0 : DepthOnlyIBSize)
- (bEnableReversedIndexBuffer ? 0 : ReversedIBsSize);
}
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/StaticMesh.cpp:472
Scope (from outer to inner):
file
function void FStaticMeshLODResources::SerializeBuffers
Source code excerpt:
// If the index buffers have already been initialized, do not change the behavior since the RHI resource pointer may have been cached somewhere already.
const bool bEnableDepthOnlyIndexBuffer = bHasDepthOnlyIndices || (CVarSupportDepthOnlyIndexBuffers.GetValueOnAnyThread() == 1);
const bool bEnableReversedIndexBuffer = bHasReversedIndices || bHasReversedDepthOnlyIndices || (CVarSupportReversedIndexBuffers.GetValueOnAnyThread() == 1);
// See if the mesh wants to keep resources CPU accessible
bool bMeshCPUAcces = OwnerStaticMesh ? OwnerStaticMesh->bAllowCPUAccess : false;
// Note: this is all derived data, native versioning is not needed, but be sure to bump STATICMESH_DERIVEDDATA_VER when modifying!
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/StaticMesh.cpp:598
Scope (from outer to inner):
file
function void FStaticMeshLODResources::SerializeAvailabilityInfo
Source code excerpt:
Ar.UsingCustomVersion(FUE5ReleaseStreamObjectVersion::GUID);
bool bHasAdjacencyInfo = false;
const bool bEnableDepthOnlyIndexBuffer = !!CVarSupportDepthOnlyIndexBuffers.GetValueOnAnyThread();
const bool bEnableReversedIndexBuffer = !!CVarSupportReversedIndexBuffers.GetValueOnAnyThread();
Ar << DepthOnlyNumTriangles;
uint32 Packed;
#if WITH_EDITOR
if (Ar.IsSaving())