r.RayTracing.DebugTimingScale

r.RayTracing.DebugTimingScale

#Overview

name: r.RayTracing.DebugTimingScale

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.RayTracing.DebugTimingScale is to provide a scaling factor for ray tracing timing heat map visualization in Unreal Engine 5’s ray tracing debug system. This variable is part of the ray tracing debugging tools within the rendering system.

The Unreal Engine subsystem that relies on this setting variable is the Renderer module, specifically the ray tracing debug functionality. This can be seen from the file location “Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingDebug.cpp”.

The value of this variable is set as a console variable with a default value of 1.0f. It can be modified at runtime through the console or programmatically.

This variable interacts with other ray tracing debug variables, such as CVarRayTracingDebugPickerDomain, CVarRayTracingDebugModeOpaqueOnly, and others seen in the RenderRayTracingDebug function.

Developers must be aware that this variable directly affects the visualization of ray tracing performance. A higher value will amplify the visual representation of timing differences, while a lower value will reduce them.

Best practices when using this variable include:

  1. Use it in conjunction with other ray tracing debug tools for a comprehensive understanding of performance.
  2. Adjust the value to find the right balance between visibility of timing differences and overall readability of the heat map.
  3. Remember that this is a debug tool and should be used during development and optimization, not in shipping builds.

Regarding the associated variable CVarRayTracingDebugTimingScale:

This is the actual console variable object that stores and manages the r.RayTracing.DebugTimingScale value. It’s defined using the TAutoConsoleVariable template, which is a common pattern in Unreal Engine for creating console variables.

The CVarRayTracingDebugTimingScale variable is used in the RenderRayTracingDebug function to set the TimingScale parameter for ray tracing debug visualization. The value is retrieved using GetValueOnAnyThread() and is divided by 25000.0f to convert it to an appropriate scale for the shader.

Developers should note that changes to this console variable will take effect immediately, as it’s queried each frame during the debug rendering process. This allows for real-time adjustment of the debug visualization, which can be particularly useful when fine-tuning ray tracing performance.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingDebug.cpp:48

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarRayTracingDebugTimingScale(
	TEXT("r.RayTracing.DebugTimingScale"),
	1.0f,
	TEXT("Scaling factor for ray timing heat map visualization. (default = 1)\n")
);

static TAutoConsoleVariable<float> CVarRayTracingDebugTraversalBoxScale(
	TEXT("r.RayTracing.DebugTraversalScale.Box"),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingDebug.cpp:47

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<float> CVarRayTracingDebugTimingScale(
	TEXT("r.RayTracing.DebugTimingScale"),
	1.0f,
	TEXT("Scaling factor for ray timing heat map visualization. (default = 1)\n")
);

static TAutoConsoleVariable<float> CVarRayTracingDebugTraversalBoxScale(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingDebug.cpp:1507

Scope (from outer to inner):

file
function     void FDeferredShadingSceneRenderer::RenderRayTracingDebug

Source code excerpt:

	RayGenParameters->PickerDomain = CVarRayTracingDebugPickerDomain.GetValueOnRenderThread();
	RayGenParameters->ShouldUsePreExposure = View.Family->EngineShowFlags.Tonemapper;
	RayGenParameters->TimingScale = CVarRayTracingDebugTimingScale.GetValueOnAnyThread() / 25000.0f;
	RayGenParameters->OpaqueOnly = CVarRayTracingDebugModeOpaqueOnly.GetValueOnRenderThread();
	RayGenParameters->TriangleHitCountMaxThreshold = FMath::Clamp((float)CVarRayTracingDebugHitCountMaxThreshold.GetValueOnRenderThread(), 1, 100000);
	RayGenParameters->TriangleHitCountPerInstanceMaxThreshold = FMath::Max(1, CVarRayTracingDebugHitCountPerInstanceMaxThreshold.GetValueOnRenderThread());
	RayGenParameters->RayTracingDebugHitStatsUniformBuffer = DebugHitStatsUniformBuffer;
	RayGenParameters->LightGridPacked = View.RayTracingLightGridUniformBuffer;
	RayGenParameters->TopKMostHitInstances = CVarRayTracingDebugHitCountTopKHits.GetValueOnRenderThread();