r.Histogram.UseAtomic
r.Histogram.UseAtomic
#Overview
name: r.Histogram.UseAtomic
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Uses atomic to speed up the generation of the histogram.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Histogram.UseAtomic is to control whether atomic operations are used to speed up the generation of the histogram in Unreal Engine’s rendering system.
This setting variable is primarily used in the rendering subsystem of Unreal Engine, specifically in the post-processing module that handles histogram generation.
The value of this variable is set through the console variable system in Unreal Engine. It is defined as a TAutoConsoleVariable with a default value of 1 (enabled).
The associated variable CVarUseAtomicHistogram directly interacts with r.Histogram.UseAtomic. They share the same value and purpose.
Developers should be aware that this variable affects the performance and potentially the accuracy of histogram generation in the rendering pipeline. When enabled (set to 1), it uses atomic operations which can speed up the process but may have different behavior on various hardware.
Best practices when using this variable include:
- Testing the performance impact on target hardware with both settings (0 and 1).
- Considering the trade-off between speed and potential accuracy differences.
- Being cautious when changing this value during runtime, as it may affect frame rate or visual consistency.
Regarding the associated variable CVarUseAtomicHistogram:
The purpose of CVarUseAtomicHistogram is identical to r.Histogram.UseAtomic. It’s an internal representation of the console variable within the C++ code.
This variable is used directly in the rendering code to determine whether to use the atomic histogram generation pass or not. It’s checked in the AddHistogramPass function to decide which histogram generation method to use.
The value of CVarUseAtomicHistogram is set automatically by the console variable system when r.Histogram.UseAtomic is modified.
Developers should treat CVarUseAtomicHistogram as the in-code representation of the r.Histogram.UseAtomic setting. When writing C++ code that needs to check this setting, they should use CVarUseAtomicHistogram.GetValueOnRenderThread() to get the current value.
Best practices for using CVarUseAtomicHistogram include:
- Always access its value using the GetValueOnRenderThread() method when in render thread code.
- Avoid directly modifying this variable; instead, change the r.Histogram.UseAtomic console variable.
- Consider caching the value if it’s used frequently in performance-critical sections to avoid repeated calls to GetValueOnRenderThread().
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessHistogram.cpp:14
Scope: file
Source code excerpt:
TAutoConsoleVariable<int32> CVarUseAtomicHistogram(
TEXT("r.Histogram.UseAtomic"), 1,
TEXT("Uses atomic to speed up the generation of the histogram."),
ECVF_RenderThreadSafe);
namespace
{
class FHistogramCS : public FGlobalShader
#Associated Variable and Callsites
This variable is associated with another variable named CVarUseAtomicHistogram
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessHistogram.cpp:13
Scope: file
Source code excerpt:
#include "DataDrivenShaderPlatformInfo.h"
TAutoConsoleVariable<int32> CVarUseAtomicHistogram(
TEXT("r.Histogram.UseAtomic"), 1,
TEXT("Uses atomic to speed up the generation of the histogram."),
ECVF_RenderThreadSafe);
namespace
{
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessHistogram.cpp:452
Scope (from outer to inner):
file
function FRDGTextureRef AddHistogramPass
Source code excerpt:
FRDGBufferRef EyeAdaptationBuffer)
{
if (CVarUseAtomicHistogram.GetValueOnRenderThread() == 1)
{
return AddHistogramAtomicPass(
GraphBuilder,
View,
EyeAdaptationParameters,
SceneColor,