r.SplineMesh.SceneTextures.InstanceIDUploadCopy

r.SplineMesh.SceneTextures.InstanceIDUploadCopy

#Overview

name: r.SplineMesh.SceneTextures.InstanceIDUploadCopy

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.SplineMesh.SceneTextures.InstanceIDUploadCopy is to control the behavior of instance ID buffer uploads for spline mesh scene textures in the rendering system. Specifically, it determines whether a copy of the registered instance IDs should be made during buffer upload.

This setting variable is primarily used in the Renderer module of Unreal Engine 5, specifically within the spline mesh scene resources subsystem. It affects how instance IDs are handled when uploading data to GPU buffers for rendering spline meshes.

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

The associated variable CVarSplineMeshSceneTexturesInstanceIDUploadCopy directly interacts with this setting. It is used to retrieve the current value of the setting on the render thread.

Developers should be aware that this variable affects performance and memory usage. When set to true, it creates a copy of the instance IDs during buffer upload, which may increase memory usage but could potentially improve performance in certain scenarios by avoiding data races or ensuring data consistency.

Best practices when using this variable include:

  1. Consider the trade-off between memory usage and potential performance benefits.
  2. Profile your application with both true and false settings to determine the optimal configuration for your specific use case.
  3. Be cautious when changing this value at runtime, as it may impact rendering performance.

Regarding the associated variable CVarSplineMeshSceneTexturesInstanceIDUploadCopy:

The purpose of CVarSplineMeshSceneTexturesInstanceIDUploadCopy is to provide a programmatic interface to access and modify the r.SplineMesh.SceneTextures.InstanceIDUploadCopy setting.

This variable is used within the Renderer module, specifically in the spline mesh scene resources implementation.

The value of this variable is set when the console variable is created, with a default value of true. It can be modified through console commands or programmatically.

This variable directly controls the behavior of the r.SplineMesh.SceneTextures.InstanceIDUploadCopy setting and is used to retrieve its value on the render thread.

Developers should be aware that changes to this variable will immediately affect the behavior of instance ID buffer uploads for spline mesh scene textures.

Best practices for using this variable include:

  1. Use GetValueOnRenderThread() when accessing the value in render thread code to ensure thread-safety.
  2. Consider exposing this setting in your application’s graphics options if spline mesh performance is critical to your project.
  3. Document any changes to this variable in your project, as it may impact rendering behavior and performance.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SplineMeshSceneResources.cpp:37

Scope: file

Source code excerpt:


static TAutoConsoleVariable<bool> CVarSplineMeshSceneTexturesInstanceIDUploadCopy(
	TEXT("r.SplineMesh.SceneTextures.InstanceIDUploadCopy"),
	true,
	TEXT("When true, will make a copy of the registered instance IDs on buffer upload."),
	ECVF_RenderThreadSafe
);

BEGIN_SHADER_PARAMETER_STRUCT(FSplineMeshSceneResourceParameters, RENDERER_API)

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SplineMeshSceneResources.cpp:36

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<bool> CVarSplineMeshSceneTexturesInstanceIDUploadCopy(
	TEXT("r.SplineMesh.SceneTextures.InstanceIDUploadCopy"),
	true,
	TEXT("When true, will make a copy of the registered instance IDs on buffer upload."),
	ECVF_RenderThreadSafe
);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SplineMeshSceneResources.cpp:295

Scope (from outer to inner):

file
function     FRDGBufferSRVRef FSplineMeshSceneExtension::GetInstanceIdLookupSRV

Source code excerpt:

	{
		// Upload the contents
		const ERDGInitialDataFlags Flags = CVarSplineMeshSceneTexturesInstanceIDUploadCopy.GetValueOnRenderThread() ?
			ERDGInitialDataFlags::None : ERDGInitialDataFlags::NoCopy;
		GraphBuilder.QueueBufferUpload<uint32>(InstanceIdLookup, RegisteredInstanceIds, Flags);
	}

	bInstanceLookupDirty = false;
	return GraphBuilder.CreateSRV(InstanceIdLookup);