r.SceneCulling.ValidateGPUData

r.SceneCulling.ValidateGPUData

#Overview

name: r.SceneCulling.ValidateGPUData

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.SceneCulling.ValidateGPUData is to enable validation of GPU data against CPU data in the scene culling system. This setting is used for debugging and performance analysis in the rendering pipeline of Unreal Engine 5.

This setting variable is primarily used in the Renderer module, specifically within the scene culling subsystem. It is referenced in the SceneCulling.cpp file, which is part of the runtime rendering system.

The value of this variable is set through a console variable (CVar) system. It is initialized with a default value of 0, meaning the validation is disabled by default.

The associated variable CVarValidateGPUData interacts directly with r.SceneCulling.ValidateGPUData. They share the same value and purpose.

Developers must be aware that enabling this variable (setting it to a non-zero value) will significantly impact performance. As stated in the comment, “This is quite slow and forces CPU/GPU syncs.” It should only be used for debugging and validation purposes, not in production builds or during normal development.

Best practices when using this variable include:

  1. Only enable it when actively debugging GPU data issues in the scene culling system.
  2. Disable it immediately after debugging to avoid performance impacts.
  3. Be prepared for slower performance when this is enabled, as it forces synchronization between CPU and GPU.
  4. Use it in conjunction with other debugging tools to isolate and identify issues related to GPU data in scene culling.

Regarding the associated variable CVarValidateGPUData:

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneCulling/SceneCulling.cpp:191

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarValidateGPUData(
	TEXT("r.SceneCulling.ValidateGPUData"), 
	0, 
	TEXT("Perform readback and validation of uploaded GPU-data against CPU copy. This is quite slow and forces CPU/GPU syncs."), 
	ECVF_RenderThreadSafe);


#endif

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneCulling/SceneCulling.cpp:190

Scope: file

Source code excerpt:

#if SC_ENABLE_GPU_DATA_VALIDATION

static TAutoConsoleVariable<int32> CVarValidateGPUData(
	TEXT("r.SceneCulling.ValidateGPUData"), 
	0, 
	TEXT("Perform readback and validation of uploaded GPU-data against CPU copy. This is quite slow and forces CPU/GPU syncs."), 
	ECVF_RenderThreadSafe);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneCulling/SceneCulling.cpp:2337

Scope (from outer to inner):

file
class        class FSceneCullingBuilder
function     void UploadToGPU

Source code excerpt:


#if SC_ENABLE_GPU_DATA_VALIDATION
		if (CVarValidateGPUData.GetValueOnRenderThread() != 0)
		{
			SceneCulling.CellBlockDataBuffer.ValidateGPUData(GraphBuilder, TConstArrayView<FCellBlockData>(SceneCulling.CellBlockData), 
				[this](int32 Index, const FCellBlockData& HostValue, const FCellBlockData &GPUValue) 
				{
					check(GPUValue.LevelCellSize == HostValue.LevelCellSize); 
					check(GPUValue.WorldPos.GetVector3d() == HostValue.WorldPos.GetVector3d());