r.OIT.SortedTriangles.Pool.ReleaseFrameThreshold

r.OIT.SortedTriangles.Pool.ReleaseFrameThreshold

#Overview

name: r.OIT.SortedTriangles.Pool.ReleaseFrameThreshold

This variable is created as a Console Variable (cvar).

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.OIT.SortedTriangles.Pool.ReleaseFrameThreshold is to control the release of unused buffers in the Order-Independent Transparency (OIT) system of Unreal Engine 5’s rendering pipeline. Specifically, it sets the number of frames after which unused sorted triangle buffers are released from memory.

This setting variable is primarily used by the OIT subsystem within the Renderer module of Unreal Engine 5. It’s part of the engine’s advanced rendering features, particularly for managing memory usage in scenarios involving transparent objects.

The value of this variable is set through a console variable (CVar) system, allowing it to be adjusted at runtime. It’s initialized with a default value of 100 frames.

The associated variable CVarOIT_SortedTriangles_PoolReleaseThreshold directly interacts with r.OIT.SortedTriangles.Pool.ReleaseFrameThreshold, as they represent the same setting in different contexts within the engine.

Developers should be aware that:

  1. This variable affects memory management for OIT rendering.
  2. Setting it too low might cause frequent allocation/deallocation of buffers, potentially impacting performance.
  3. Setting it too high might lead to unnecessary memory usage if there are many unused buffers.

Best practices when using this variable include:

  1. Adjusting it based on the specific needs of your project and target hardware capabilities.
  2. Monitoring performance and memory usage when modifying this value.
  3. Consider the frequency of transparent object changes in your scenes when setting this value.

Regarding the associated variable CVarOIT_SortedTriangles_PoolReleaseThreshold:

Developers should treat CVarOIT_SortedTriangles_PoolReleaseThreshold as the programmatic interface to the r.OIT.SortedTriangles.Pool.ReleaseFrameThreshold setting, using it when they need to access or modify this value within C++ code.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/OIT/OIT.cpp:39

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarOIT_SortedTriangles_PoolReleaseThreshold(
	TEXT("r.OIT.SortedTriangles.Pool.ReleaseFrameThreshold"), 
	100, 
	TEXT("Number of frame after which unused buffer are released."),
	ECVF_RenderThreadSafe);

///////////////////////////////////////////////////////////////////////////////////////////////////
// Variables: sorted pixels

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/OIT/OIT.cpp:38

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarOIT_SortedTriangles_PoolReleaseThreshold(
	TEXT("r.OIT.SortedTriangles.Pool.ReleaseFrameThreshold"), 
	100, 
	TEXT("Number of frame after which unused buffer are released."),
	ECVF_RenderThreadSafe);

///////////////////////////////////////////////////////////////////////////////////////////////////

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/OIT/OIT.cpp:303

Scope (from outer to inner):

file
function     static void TrimSortedIndexBuffers

Source code excerpt:

		{
			const int32 ElapsedFrame = FMath::Abs(int32(FrameId) - int32(LastFrameId));
			if (ElapsedFrame > CVarOIT_SortedTriangles_PoolReleaseThreshold.GetValueOnRenderThread())
			{
				DeleteQueue.Enqueue(FreeBuffers[FreeIt]);
				FreeBuffers[FreeIt] = FreeBuffers[FreeCount - 1];
				--FreeCount;
				FreeBuffers.SetNum(FreeCount);
				continue;

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/OIT/OIT.cpp:907

Scope (from outer to inner):

file
class        class FOITSortTriangleIndex_WriteOutCS : public FGlobalShader

Source code excerpt:

		// Trim unused buffers
		OITSceneData.FrameIndex = View.Family->FrameNumber;
		if (CVarOIT_SortedTriangles_Pool.GetValueOnRenderThread() > 0 && CVarOIT_SortedTriangles_PoolReleaseThreshold.GetValueOnRenderThread() > 0)
		{
			TrimSortedIndexBuffers(OITSceneData.FreeBuffers, OITSceneData.PendingDeletes, OITSceneData.FrameIndex);
		}
	}

	FOITData CreateOITData(FRDGBuilder& GraphBuilder, const FViewInfo& View, EOITPassType PassType)