r.FastVRam.DBufferC

r.FastVRam.DBufferC

#Overview

name: r.FastVRam.DBufferC

This variable is created as a Console Variable (cvar).

It is referenced in 11 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.FastVRam.DBufferC is to control the texture creation flags for the DBufferC texture in Unreal Engine’s rendering system. This setting is specifically related to the decal buffer system, which is used for rendering decals efficiently in the deferred rendering pipeline.

The Unreal Engine subsystem that relies on this setting variable is primarily the Renderer module, specifically the deferred decal rendering system. This can be seen from the file locations where the variable is used, such as CompositionLighting/PostProcessDeferredDecals.cpp and DBufferTextures.cpp.

The value of this variable is set through a console variable (CVAR) using the FASTVRAM_CVAR macro, as seen in SceneRendering.cpp. It’s initially set to 0, but can be changed at runtime.

This variable interacts closely with other DBuffer-related variables, specifically r.FastVRam.DBufferA, r.FastVRam.DBufferB, and r.FastVRam.DBufferMask. These variables together control the creation flags for the entire DBuffer texture set used in decal rendering.

Developers must be aware that changing this variable affects the memory allocation and potentially the performance of decal rendering. The ‘FastVRam’ in the variable name suggests that it’s used to control whether this texture should be allocated in fast video memory.

Best practices when using this variable include:

  1. Only modify it if you understand the implications on memory usage and rendering performance.
  2. Consider the entire set of DBuffer variables together, as they are often used in conjunction.
  3. Profile the application’s performance and memory usage when making changes to these settings.

Regarding the associated variable DBufferC: The purpose of DBufferC is to represent one of the textures in the DBuffer system used for decal rendering. It’s typically used to store specific decal properties, such as normal or roughness information.

DBufferC is used throughout the decal rendering process, including in pass parameter setup, texture creation, and in the actual rendering of decals. It’s closely tied to DBufferA and DBufferB, forming a set of textures that together store all necessary decal information.

The value of DBufferC is set during the creation of DBuffer textures, as seen in the CreateDBufferTextures function in DBufferTextures.cpp.

Developers should be aware that DBufferC is an integral part of the decal rendering system and its proper setup and use is crucial for correct decal rendering. When working with decals, always ensure that DBufferC (along with DBufferA and DBufferB) is properly initialized and passed to the relevant shaders and render passes.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:497

Scope: file

Source code excerpt:

FASTVRAM_CVAR(DBufferA, 0);
FASTVRAM_CVAR(DBufferB, 0);
FASTVRAM_CVAR(DBufferC, 0); 
FASTVRAM_CVAR(DBufferMask, 0);
FASTVRAM_CVAR(DOFSetup, 1);
FASTVRAM_CVAR(DOFReduce, 1);
FASTVRAM_CVAR(DOFPostfilter, 1);
FASTVRAM_CVAR(PostProcessMaterial, 1);

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/CompositionLighting/PostProcessDeferredDecals.cpp:219

Scope (from outer to inner):

file
function     void GetDeferredDecalPassParameters

Source code excerpt:

		AddColorTarget(DBufferTextures.DBufferA, LoadAction);
		AddColorTarget(DBufferTextures.DBufferB, LoadAction);
		AddColorTarget(DBufferTextures.DBufferC, LoadAction);

		if (DBufferTextures.DBufferMask)
		{
			AddColorTarget(DBufferTextures.DBufferMask, LoadAction);
		}

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/CompositionLighting/PostProcessDeferredDecals.cpp:730

Scope (from outer to inner):

file
function     void AddDeferredDecalPass

Source code excerpt:

	{
		// Combine DBuffer RTWriteMasks; will end up in one texture we can load from in the base pass PS and decide whether to do the actual work or not.
		FRDGTextureRef Textures[] = { PassTextures.DBufferTextures->DBufferA, PassTextures.DBufferTextures->DBufferB, PassTextures.DBufferTextures->DBufferC };
		FRenderTargetWriteMask::Decode(GraphBuilder, View.ShaderMap, MakeArrayView(Textures), PassTextures.DBufferTextures->DBufferMask, GFastVRamConfig.DBufferMask, TEXT("DBufferMaskCombine"));
	}
}

void ExtractNormalsForNextFrameReprojection(FRDGBuilder& GraphBuilder, const FSceneTextures& SceneTextures, const TArray<FViewInfo>& Views)
{

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DBufferTextures.cpp:11

Scope (from outer to inner):

file
function     bool FDBufferTextures::IsValid

Source code excerpt:

bool FDBufferTextures::IsValid() const
{
	check(!DBufferA || (DBufferB && DBufferC));
	return HasBeenProduced(DBufferA);
}

EDecalDBufferMaskTechnique GetDBufferMaskTechnique(EShaderPlatform ShaderPlatform)
{
	const bool bWriteMaskDBufferMask = RHISupportsRenderTargetWriteMask(ShaderPlatform);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DBufferTextures.cpp:52

Scope (from outer to inner):

file
function     FDBufferTexturesDesc GetDBufferTexturesDesc

Source code excerpt:

		DBufferTexturesDesc.DBufferBDesc = Desc;

		Desc.Flags = BaseFlags | GFastVRamConfig.DBufferC;
		Desc.ClearValue = FClearValueBinding(FLinearColor(0, 0, 0, 1));
		DBufferTexturesDesc.DBufferCDesc = Desc;

		if (DBufferMaskTechnique == EDecalDBufferMaskTechnique::PerPixel)
		{
			// Note: 32bpp format is used here to utilize color compression hardware (same as other DBuffer targets).

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DBufferTextures.cpp:91

Scope (from outer to inner):

file
function     FDBufferTextures CreateDBufferTextures

Source code excerpt:

		DBufferTextures.DBufferA = GraphBuilder.CreateTexture(TexturesDesc.DBufferADesc, TEXT("DBufferA"), TextureFlags);
		DBufferTextures.DBufferB = GraphBuilder.CreateTexture(TexturesDesc.DBufferBDesc, TEXT("DBufferB"), TextureFlags);
		DBufferTextures.DBufferC = GraphBuilder.CreateTexture(TexturesDesc.DBufferCDesc, TEXT("DBufferC"), TextureFlags);

		if (DBufferMaskTechnique == EDecalDBufferMaskTechnique::PerPixel)
		{
			DBufferTextures.DBufferMask = GraphBuilder.CreateTexture(TexturesDesc.DBufferMaskDesc, TEXT("DBufferMask"));
		}
	}

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DBufferTextures.cpp:119

Scope (from outer to inner):

file
function     FDBufferParameters GetDBufferParameters

Source code excerpt:

		Parameters.DBufferATexture = DBufferTextures.DBufferA;
		Parameters.DBufferBTexture = DBufferTextures.DBufferB;
		Parameters.DBufferCTexture = DBufferTextures.DBufferC;

		if (DBufferTextures.DBufferMask)
		{
			Parameters.DBufferRenderMask = DBufferTextures.DBufferMask;
		}
	}

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DBufferTextures.h:34

Scope: file

Source code excerpt:

	FRDGTextureRef DBufferA = nullptr;
	FRDGTextureRef DBufferB = nullptr;
	FRDGTextureRef DBufferC = nullptr;
	FRDGTextureRef DBufferMask = nullptr;
};

FDBufferTexturesDesc GetDBufferTexturesDesc(FIntPoint Extent, EShaderPlatform ShaderPlatform);
FDBufferTextures CreateDBufferTextures(FRDGBuilder& GraphBuilder, FIntPoint Extent, EShaderPlatform ShaderPlatform);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:497

Scope: file

Source code excerpt:

FASTVRAM_CVAR(DBufferA, 0);
FASTVRAM_CVAR(DBufferB, 0);
FASTVRAM_CVAR(DBufferC, 0); 
FASTVRAM_CVAR(DBufferMask, 0);
FASTVRAM_CVAR(DOFSetup, 1);
FASTVRAM_CVAR(DOFReduce, 1);
FASTVRAM_CVAR(DOFPostfilter, 1);
FASTVRAM_CVAR(PostProcessMaterial, 1);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:697

Scope (from outer to inner):

file
function     void FFastVramConfig::Update

Source code excerpt:

	bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_DBufferA, DBufferA);
	bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_DBufferB, DBufferB);
	bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_DBufferC, DBufferC);
	bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_DBufferMask, DBufferMask);
	bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_DOFSetup, DOFSetup);
	bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_DOFReduce, DOFReduce);
	bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_DOFPostfilter, DOFPostfilter);
	bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_CustomDepth, CustomDepth);
	bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_ShadowPointLight, ShadowPointLight);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.h:2847

Scope: file

Source code excerpt:

	ETextureCreateFlags DBufferA;
	ETextureCreateFlags DBufferB;
	ETextureCreateFlags DBufferC;
	ETextureCreateFlags DBufferMask;
	ETextureCreateFlags DOFSetup;
	ETextureCreateFlags DOFReduce;
	ETextureCreateFlags DOFPostfilter;
	ETextureCreateFlags PostProcessMaterial;