r.Raytracing.DebugForceRuntimeBLAS

r.Raytracing.DebugForceRuntimeBLAS

#Overview

name: r.Raytracing.DebugForceRuntimeBLAS

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

It is referenced in 6 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.Raytracing.DebugForceRuntimeBLAS is to force the building of Bottom Level Acceleration Structures (BLAS) at runtime for ray tracing purposes in Unreal Engine 5. This setting variable is primarily used in the rendering system, specifically for ray tracing functionality.

This setting variable is utilized by the RenderCore module and the Engine module, particularly in the ray tracing geometry and static mesh streaming subsystems. The value of this variable is set through the console variable system, with a default value of 0.

The variable interacts closely with its associated variable CVarDebugForceRuntimeBLAS, which is used to retrieve the value of r.Raytracing.DebugForceRuntimeBLAS in the code. They essentially share the same value and purpose.

When using this variable, developers must be aware that:

  1. Setting it to a non-zero value will force the BLAS to be built at runtime, even if offline data is available.
  2. It can impact performance, as building BLAS at runtime is generally more expensive than using pre-built offline data.
  3. It is marked as ECVF_ReadOnly, meaning its value should not be changed during runtime.

Best practices when using this variable include:

  1. Use it primarily for debugging purposes, as indicated by its name.
  2. Be cautious about enabling it in production builds due to potential performance impacts.
  3. When enabled, ensure that the system has sufficient resources to handle runtime BLAS construction.

Regarding the associated variable CVarDebugForceRuntimeBLAS:

The purpose of CVarDebugForceRuntimeBLAS is to provide a programmatic way to access the value of r.Raytracing.DebugForceRuntimeBLAS within the C++ code. It is used in the same subsystems and for the same purpose as r.Raytracing.DebugForceRuntimeBLAS.

The value of CVarDebugForceRuntimeBLAS is set by retrieving the console variable data for r.Raytracing.DebugForceRuntimeBLAS. It interacts directly with r.Raytracing.DebugForceRuntimeBLAS and is used to control the behavior of BLAS construction in the ray tracing system.

Developers should be aware that:

  1. CVarDebugForceRuntimeBLAS is used to check the value of r.Raytracing.DebugForceRuntimeBLAS in the code.
  2. It’s typically used in conditional statements to determine whether to force runtime BLAS construction.

Best practices for using CVarDebugForceRuntimeBLAS include:

  1. Use GetValueOnAnyThread() when retrieving its value, as shown in the code examples.
  2. Consider caching its value if it’s used frequently in performance-critical sections of code.
  3. Be consistent in how you check its value across different parts of the codebase to ensure uniform behavior.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RayTracingGeometry.cpp:15

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarDebugForceRuntimeBLAS(
	TEXT("r.Raytracing.DebugForceRuntimeBLAS"),
	0,
	TEXT("Force building BLAS at runtime."),
	ECVF_ReadOnly);

FRayTracingGeometry::FRayTracingGeometry() = default;

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Streaming/StaticMeshUpdate.cpp:153

Scope (from outer to inner):

file
function     void FStaticMeshStreamIn::FIntermediateRayTracingGeometry::CreateFromCPUData

Source code excerpt:

	}

	static const auto CVarDebugForceRuntimeBLAS = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.Raytracing.DebugForceRuntimeBLAS"));
	const bool bDebugForceRuntimeBLAS = (!CVarDebugForceRuntimeBLAS) || (CVarDebugForceRuntimeBLAS->GetValueOnAnyThread() != 0);

	if (bDebugForceRuntimeBLAS && Initializer.OfflineData != nullptr)
	{
		Initializer.OfflineData->Discard();
		Initializer.OfflineData = nullptr;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Streaming/StaticMeshUpdate.cpp:153

Scope (from outer to inner):

file
function     void FStaticMeshStreamIn::FIntermediateRayTracingGeometry::CreateFromCPUData

Source code excerpt:

	}

	static const auto CVarDebugForceRuntimeBLAS = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.Raytracing.DebugForceRuntimeBLAS"));
	const bool bDebugForceRuntimeBLAS = (!CVarDebugForceRuntimeBLAS) || (CVarDebugForceRuntimeBLAS->GetValueOnAnyThread() != 0);

	if (bDebugForceRuntimeBLAS && Initializer.OfflineData != nullptr)
	{
		Initializer.OfflineData->Discard();
		Initializer.OfflineData = nullptr;
	}

#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RayTracingGeometry.cpp:14

Scope: file

Source code excerpt:

#endif

static TAutoConsoleVariable<int32> CVarDebugForceRuntimeBLAS(
	TEXT("r.Raytracing.DebugForceRuntimeBLAS"),
	0,
	TEXT("Force building BLAS at runtime."),
	ECVF_ReadOnly);

FRayTracingGeometry::FRayTracingGeometry() = default;

#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RayTracingGeometry.cpp:72

Scope (from outer to inner):

file
function     void FRayTracingGeometry::CreateRayTracingGeometryFromCPUData

Source code excerpt:

	}

	if (CVarDebugForceRuntimeBLAS.GetValueOnAnyThread() && Initializer.OfflineData != nullptr)
	{
		Initializer.OfflineData->Discard();
		Initializer.OfflineData = nullptr;
	}
	
	FRHICommandList& RHICmdList = FRHICommandListImmediate::Get();

#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RayTracingGeometry.cpp:162

Scope (from outer to inner):

file
function     void FRayTracingGeometry::CreateRayTracingGeometry

Source code excerpt:

	}

	if (CVarDebugForceRuntimeBLAS.GetValueOnAnyThread() && Initializer.OfflineData != nullptr)
	{
		Initializer.OfflineData->Discard();
		Initializer.OfflineData = nullptr;
	}

	bool bAllSegmentsAreValid = Initializer.Segments.Num() > 0 || Initializer.OfflineData;