r.PathTracing.IndirectDispatch
r.PathTracing.IndirectDispatch
#Overview
name: r.PathTracing.IndirectDispatch
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Enables indirect dispatch (if supported by the hardware) for compacted path tracing (default: 0 (disabled))
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.PathTracing.IndirectDispatch is to enable indirect dispatch for compacted path tracing in Unreal Engine’s rendering system. This setting variable is specifically related to the path tracing feature of the engine’s renderer.
The Unreal Engine subsystem that relies on this setting variable is the Renderer module, particularly the path tracing component. This can be seen from the file location where the variable is defined and used: Engine/Source/Runtime/Renderer/Private/PathTracing.cpp
.
The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 0 (disabled) and can be changed at runtime. The associated C++ variable is CVarPathTracingIndirectDispatch
.
This variable interacts with other path tracing related variables, such as CVarPathTracingCompaction
and CVarPathTracingFlushDispatch
, as seen in the provided code excerpt.
Developers must be aware that this feature is hardware-dependent. The code checks for GRHISupportsRayTracingDispatchIndirect
before using the indirect dispatch feature, indicating that not all hardware may support this functionality.
Best practices when using this variable include:
- Ensure the target hardware supports indirect dispatch for ray tracing before enabling this feature.
- Test performance with and without this feature enabled, as its impact may vary depending on the specific scene and hardware.
- Use in conjunction with other path tracing settings for optimal results.
Regarding the associated variable CVarPathTracingIndirectDispatch:
The purpose of CVarPathTracingIndirectDispatch is to provide a programmatic way to access and modify the r.PathTracing.IndirectDispatch setting within the C++ code of the engine.
This variable is defined and used within the Renderer module, specifically in the path tracing implementation.
The value of this variable is set when the console variable is initialized, but it can be accessed and potentially modified at runtime using the GetValueOnRenderThread()
method.
CVarPathTracingIndirectDispatch interacts directly with the r.PathTracing.IndirectDispatch setting, effectively serving as its C++ representation within the engine code.
Developers should be aware that this variable is marked as render thread safe (ECVF_RenderThreadSafe), meaning it can be safely accessed from the render thread.
Best practices for using this variable include:
- Access its value using
GetValueOnRenderThread()
when in render thread context. - Don’t assume its value remains constant throughout the application’s lifetime, as it can be changed via console commands.
- Use it in conjunction with hardware capability checks (like
GRHISupportsRayTracingDispatchIndirect
) to ensure the feature is supported before attempting to use it.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracing.cpp:53
Scope: file
Source code excerpt:
TAutoConsoleVariable<int32> CVarPathTracingIndirectDispatch(
TEXT("r.PathTracing.IndirectDispatch"),
0,
TEXT("Enables indirect dispatch (if supported by the hardware) for compacted path tracing (default: 0 (disabled))"),
ECVF_RenderThreadSafe
);
TAutoConsoleVariable<int32> CVarPathTracingFlushDispatch(
#Associated Variable and Callsites
This variable is associated with another variable named CVarPathTracingIndirectDispatch
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracing.cpp:52
Scope: file
Source code excerpt:
);
TAutoConsoleVariable<int32> CVarPathTracingIndirectDispatch(
TEXT("r.PathTracing.IndirectDispatch"),
0,
TEXT("Enables indirect dispatch (if supported by the hardware) for compacted path tracing (default: 0 (disabled))"),
ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracing.cpp:2788
Scope: file
Source code excerpt:
// should we use path compaction?
const bool bUseCompaction = (bUseExperimental == false) || CVarPathTracingCompaction.GetValueOnRenderThread() != 0;
const bool bUseIndirectDispatch = GRHISupportsRayTracingDispatchIndirect && CVarPathTracingIndirectDispatch.GetValueOnRenderThread() != 0;
const int FlushRenderingCommands = CVarPathTracingFlushDispatch.GetValueOnRenderThread();
FRDGBuffer* ActivePaths[2] = {};
FRDGBuffer* NumActivePaths[2] = {};
FRDGBuffer* PathStateData = nullptr;
if (bUseCompaction || Config.UseAdaptiveSampling)