r.FilmGrain.CacheTextureConstants

r.FilmGrain.CacheTextureConstants

#Overview

name: r.FilmGrain.CacheTextureConstants

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.FilmGrain.CacheTextureConstants is to control whether the constants related to film grain should be cached in the rendering system of Unreal Engine 5.

This setting variable is primarily used in the rendering subsystem of Unreal Engine 5, specifically in the post-processing module that handles tonemapping and film grain effects.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1, meaning caching is enabled by default.

The associated variable CVarFilmGrainCacheTextureConstants interacts directly with r.FilmGrain.CacheTextureConstants. They share the same value and purpose.

Developers should be aware that this variable affects the performance and memory usage of the film grain effect. When enabled (set to 1), it caches the film grain texture constants, which can improve performance by reducing the need to recalculate these constants every frame. However, it may also increase memory usage.

Best practices when using this variable include:

  1. Keep it enabled (default value of 1) for better performance in most cases.
  2. Consider disabling it (set to 0) if memory is a concern and the film grain effect is changing frequently.
  3. Profile your application with both settings to determine the optimal configuration for your specific use case.

Regarding the associated variable CVarFilmGrainCacheTextureConstants:

The purpose of CVarFilmGrainCacheTextureConstants is the same as r.FilmGrain.CacheTextureConstants. It’s the actual console variable that controls the caching of film grain texture constants.

This variable is used in the rendering subsystem, specifically in the tonemapping post-process pass.

The value is set when the engine initializes the console variables, with a default value of 1.

It interacts directly with the r.FilmGrain.CacheTextureConstants setting, as they represent the same configuration option.

Developers should be aware that this variable is checked on the render thread (GetValueOnRenderThread()), which means changes to this variable will be applied on the next frame.

Best practices for using CVarFilmGrainCacheTextureConstants are the same as those for r.FilmGrain.CacheTextureConstants, as they are essentially the same variable.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessTonemap.cpp:62

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:


TAutoConsoleVariable<int32> CVarFilmGrainCacheTextureConstants(
	TEXT("r.FilmGrain.CacheTextureConstants"), 1,
	TEXT("Wether the constants related to the film grain should be cached."),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarBackbufferQuantizationDitheringOverride(
	TEXT("r.BackbufferQuantizationDitheringOverride"), 0,
	TEXT("Override the bitdepth in bits of each channel of the backbuffer targeted by the quantization dithering. ")

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessTonemap.cpp:61

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:

	ECVF_RenderThreadSafe);

TAutoConsoleVariable<int32> CVarFilmGrainCacheTextureConstants(
	TEXT("r.FilmGrain.CacheTextureConstants"), 1,
	TEXT("Wether the constants related to the film grain should be cached."),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarBackbufferQuantizationDitheringOverride(
	TEXT("r.BackbufferQuantizationDitheringOverride"), 0,

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessTonemap.cpp:722

Scope (from outer to inner):

file
function     FScreenPassTexture AddTonemapPass

Source code excerpt:


		FRDGBufferRef FilmGrainConstantsBuffer;
		if (View.ViewState && View.ViewState->FilmGrainCache.TextureRHI == FilmGrainTextureRHI && CVarFilmGrainCacheTextureConstants.GetValueOnRenderThread() != 0)
		{
			FilmGrainConstantsBuffer = GraphBuilder.RegisterExternalBuffer(View.ViewState->FilmGrainCache.ConstantsBuffer, TEXT("FilmGrain.TextureConstants"));
		}
		else
		{
			FilmGrainConstantsBuffer = BuildFilmGrainConstants(GraphBuilder, View, FilmGrainTexture);