r.Decal.Visibility.Multithreaded
r.Decal.Visibility.Multithreaded
#Overview
name: r.Decal.Visibility.Multithreaded
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Whether to build visible decal list using multithreading. 0=disabled, 1=enabled (default)
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Decal.Visibility.Multithreaded is to control whether the visible decal list is built using multithreading in Unreal Engine’s rendering system.
This setting variable is primarily used in the Renderer module of Unreal Engine, specifically in the decal rendering subsystem. Based on the callsites, it’s evident that this variable is crucial for the decal visibility determination process.
The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of true, meaning multithreaded decal visibility is enabled by default.
The associated variable CVarDecalVisibilityMultithreaded directly interacts with r.Decal.Visibility.Multithreaded. They share the same value and purpose.
Developers must be aware that this variable affects the performance and behavior of decal rendering. When enabled (set to 1 or true), the engine will use multithreading to build the list of visible decals, which can potentially improve performance on multi-core systems.
Best practices when using this variable include:
- Leave it enabled (default) for most scenarios, as it’s likely to provide better performance.
- If experiencing issues specifically related to decal rendering or visibility, developers might try disabling it for debugging purposes.
- Consider the target hardware when deciding whether to keep this enabled or disabled in shipping builds.
Regarding the associated variable CVarDecalVisibilityMultithreaded:
The purpose of CVarDecalVisibilityMultithreaded is identical to r.Decal.Visibility.Multithreaded. It’s the actual C++ variable that controls the multithreaded decal visibility feature.
This variable is defined in the Renderer module and is used directly in the decal rendering code. It’s defined as a TAutoConsoleVariable
The value of CVarDecalVisibilityMultithreaded is set initially to true, but can be modified during runtime.
It interacts directly with the rendering code. For example, in the provided code snippet, it’s used in a condition to determine whether to use multithreading for decal visibility calculations:
if (CVarDecalVisibilityMultithreaded.GetValueOnRenderThread() && FApp::ShouldUseThreadingForPerformance())
Developers should be aware that changes to this variable will take effect on the render thread, as indicated by the ECVF_RenderThreadSafe flag used in its declaration.
Best practices for using CVarDecalVisibilityMultithreaded include:
- Use the console variable r.Decal.Visibility.Multithreaded to modify this setting during development or debugging.
- Be cautious when changing this value at runtime, as it could impact rendering performance.
- When accessing the value in code, always use GetValueOnRenderThread() to ensure thread-safe access.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DecalRenderingShared.cpp:25
Scope: file
Source code excerpt:
static TAutoConsoleVariable<bool> CVarDecalVisibilityMultithreaded(
TEXT("r.Decal.Visibility.Multithreaded"),
true,
TEXT("Whether to build visible decal list using multithreading. 0=disabled, 1=enabled (default)"),
ECVF_RenderThreadSafe);
template<> struct TIsPODType<FTransientDecalRenderData> { enum { Value = true }; };
#Associated Variable and Callsites
This variable is associated with another variable named CVarDecalVisibilityMultithreaded
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DecalRenderingShared.cpp:24
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<bool> CVarDecalVisibilityMultithreaded(
TEXT("r.Decal.Visibility.Multithreaded"),
true,
TEXT("Whether to build visible decal list using multithreading. 0=disabled, 1=enabled (default)"),
ECVF_RenderThreadSafe);
template<> struct TIsPODType<FTransientDecalRenderData> { enum { Value = true }; };
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DecalRenderingShared.cpp:351
Scope (from outer to inner):
file
function FTransientDecalRenderDataList BuildVisibleDecalList
Source code excerpt:
// Build a list of decals that need to be rendered for this view
if (CVarDecalVisibilityMultithreaded.GetValueOnRenderThread() && FApp::ShouldUseThreadingForPerformance())
{
struct FVisibleDecalListContext
{
TChunkedArray<FTransientDecalRenderData> VisibleDecals;
};