r.Lumen.Visualize.HardwareRayTracing.ThreadCount

r.Lumen.Visualize.HardwareRayTracing.ThreadCount

#Overview

name: r.Lumen.Visualize.HardwareRayTracing.ThreadCount

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.Lumen.Visualize.HardwareRayTracing.ThreadCount is to determine the active thread count when dispatching the raygen shader in Lumen’s hardware ray tracing visualization system. This setting is part of Unreal Engine 5’s Lumen global illumination system, specifically for its ray tracing visualization capabilities.

This setting variable is primarily used in the Lumen subsystem of Unreal Engine’s rendering module. It’s referenced in the LumenVisualizeHardwareRayTracing.cpp file, which suggests it’s part of the visualization tools for Lumen’s hardware ray tracing feature.

The value of this variable is set through a console variable (CVarLumenVisualizeHardwareRayTracingThreadCount) with a default value of 64. It can be changed at runtime through console commands or project settings.

This variable interacts with another variable named CVarLumenVisualizeHardwareRayTracingGroupCount. Together, these variables determine the total number of rays generated for visualization purposes.

Developers should be aware that this variable directly affects the performance and visual output of the Lumen visualization system. Increasing the thread count may provide more detailed visualization but at the cost of increased computational load.

Best practices when using this variable include:

  1. Adjusting it based on the target hardware capabilities.
  2. Balancing it with the GroupCount variable for optimal performance.
  3. Using it in conjunction with other Lumen visualization settings for comprehensive debugging.

Regarding the associated variable CVarLumenVisualizeHardwareRayTracingThreadCount:

This is the actual console variable that stores and manages the r.Lumen.Visualize.HardwareRayTracing.ThreadCount value. It’s defined as a TAutoConsoleVariable, which means it’s an integer value that can be changed at runtime.

The purpose of this variable is the same as r.Lumen.Visualize.HardwareRayTracing.ThreadCount - to control the thread count for ray generation in Lumen’s hardware ray tracing visualization.

This variable is used in the rendering subsystem, specifically in the Lumen module for visualization purposes.

The value is set when the variable is initialized (default 64), but can be changed through console commands or engine settings.

It interacts directly with CVarLumenVisualizeHardwareRayTracingGroupCount to determine the total number of rays generated.

Developers should be aware that this variable is marked as ECVF_RenderThreadSafe, meaning it can be safely accessed and modified from the render thread.

Best practices include using the GetValueOnRenderThread() method to access its value, as seen in the provided code snippet, to ensure thread-safe access in rendering code.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenVisualizeHardwareRayTracing.cpp:46

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarLumenVisualizeHardwareRayTracingThreadCount(
	TEXT("r.Lumen.Visualize.HardwareRayTracing.ThreadCount"),
	64,
	TEXT("Determines the active group count when dispatching raygen shader (default = 64"),
	ECVF_RenderThreadSafe
);

static TAutoConsoleVariable<int32> CVarLumenVisualizeHardwareRayTracingGroupCount(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenVisualizeHardwareRayTracing.cpp:45

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<int32> CVarLumenVisualizeHardwareRayTracingThreadCount(
	TEXT("r.Lumen.Visualize.HardwareRayTracing.ThreadCount"),
	64,
	TEXT("Determines the active group count when dispatching raygen shader (default = 64"),
	ECVF_RenderThreadSafe
);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenVisualizeHardwareRayTracing.cpp:594

Scope: file

Source code excerpt:

	// Generate rays
	// NOTE: GroupCount for emulated indirect-dispatch of raygen shaders dictates the maximum allocation size if GroupCount > MaxTileCount
	uint32 RayGenThreadCount = CVarLumenVisualizeHardwareRayTracingThreadCount.GetValueOnRenderThread();
	uint32 RayGenGroupCount = CVarLumenVisualizeHardwareRayTracingGroupCount.GetValueOnRenderThread();
	uint32 RayCount = FMath::Max(MaxTileCount, RayGenGroupCount) * FLumenVisualizeCreateRaysCS::GetThreadGroupSize1D();

	// Create rays within tiles
	FRDGBufferRef RayAllocatorBuffer = GraphBuilder.CreateBuffer(FRDGBufferDesc::CreateBufferDesc(sizeof(uint32), 1), TEXT("Lumen.Visualize.RayAllocator"));
	AddClearUAVPass(GraphBuilder, GraphBuilder.CreateUAV(RayAllocatorBuffer, PF_R32_UINT), 0);