Slate.AbsoluteIndices

Slate.AbsoluteIndices

#Overview

name: Slate.AbsoluteIndices

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 Slate.AbsoluteIndices is to control the indexing method used for rendering Slate UI elements in Unreal Engine 5. It determines whether each element’s first vertex index starts at 0 (default) or uses absolute indices.

This setting variable is primarily used by the Slate RHI (Rendering Hardware Interface) Rendering system, which is part of the Unreal Engine’s UI rendering subsystem. It’s specifically referenced in the SlateRHIRenderer module.

The value of this variable is set through a console variable (CVarSlateAbsoluteIndices) with a default value of 0. It can be changed at runtime using console commands or through code.

The associated variable CVarSlateAbsoluteIndices directly interacts with Slate.AbsoluteIndices. They share the same value and purpose.

Developers must be aware that:

  1. This setting affects how vertex indices are managed during rendering.
  2. Changing this value can impact rendering performance and compatibility with different RHIs.
  3. It’s particularly useful for RHIs that do not support BaseVertex.

Best practices when using this variable include:

  1. Leave it at the default value (0) unless there’s a specific need to change it.
  2. If changing to absolute indices (1), ensure that all related rendering code is prepared to handle this change.
  3. Test thoroughly on all target platforms when modifying this setting, as it can affect rendering behavior.

Regarding the associated variable CVarSlateAbsoluteIndices:

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/SlateRHIRenderer/Private/SlateRHIRenderingPolicy.cpp:65

Scope: file

Source code excerpt:


TAutoConsoleVariable<int32> CVarSlateAbsoluteIndices(
	TEXT("Slate.AbsoluteIndices"),
	0,
	TEXT("0: Each element first vertex index starts at 0 (default), 1: Use absolute indices, simplifies draw call setup on RHIs that do not support BaseVertex"),
	ECVF_Default
);

FSlateRHIRenderingPolicy::FSlateRHIRenderingPolicy(TSharedRef<FSlateFontServices> InSlateFontServices, TSharedRef<FSlateRHIResourceManager> InResourceManager, TOptional<int32> InitialBufferSize)

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/SlateRHIRenderer/Private/SlateRHIRenderingPolicy.cpp:64

Scope: file

Source code excerpt:

#endif

TAutoConsoleVariable<int32> CVarSlateAbsoluteIndices(
	TEXT("Slate.AbsoluteIndices"),
	0,
	TEXT("0: Each element first vertex index starts at 0 (default), 1: Use absolute indices, simplifies draw call setup on RHIs that do not support BaseVertex"),
	ECVF_Default
);

#Loc: <Workspace>/Engine/Source/Runtime/SlateRHIRenderer/Private/SlateRHIRenderingPolicy.cpp:152

Scope (from outer to inner):

file
function     void FSlateRHIRenderingPolicy::BuildRenderingBuffers

Source code excerpt:

	{
		bool bShouldShrinkResources = false;
		bool bAbsoluteIndices = CVarSlateAbsoluteIndices.GetValueOnRenderThread() != 0;

		SourceVertexBuffer.PreFillBuffer(NumVertices, bShouldShrinkResources);
		SourceIndexBuffer.PreFillBuffer(NumIndices, bShouldShrinkResources);

		RHICmdList.EnqueueLambda([
			VertexBuffer = SourceVertexBuffer.VertexBufferRHI.GetReference(),

#Loc: <Workspace>/Engine/Source/Runtime/SlateRHIRenderer/Private/SlateRHIRenderingPolicy.cpp:792

Scope: file

Source code excerpt:

#endif

	const bool bAbsoluteIndices = CVarSlateAbsoluteIndices.GetValueOnRenderThread() != 0;

	// This variable tracks the last clipping state, so that if multiple batches have the same clipping state, we don't have to do any work.
	const FSlateClippingState* LastClippingState;

	// This is the stenciling ref variable we set any time we draw, so that any stencil comparisons use the right mask id.
	uint32 StencilRef = 0;