r.FastVRam.Downsample
r.FastVRam.Downsample
#Overview
name: r.FastVRam.Downsample
This variable is created as a Console Variable (cvar).
- type:
Var
- help: ``
It is referenced in 6
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.FastVRam.Downsample is to control the texture creation flags for downsampled textures in Unreal Engine 5’s rendering system. It specifically affects how downsampled textures are allocated in video memory.
This setting variable is primarily used by the rendering subsystem of Unreal Engine 5. Based on the callsites, it’s utilized in the post-processing pipeline, particularly in downsampling and temporal anti-aliasing (TAA) passes.
The value of this variable is set through the FASTVRAM_CVAR macro, which likely creates a console variable that can be adjusted at runtime. It’s initialized with a default value of 1.
The r.FastVRam.Downsample variable interacts with the associated variable Downsample, which is a member of the FFastVramConfig struct. The FFastVramConfig::Update() function synchronizes the value between these two variables.
Developers should be aware that changing this variable affects the memory allocation strategy for downsampled textures. It can impact performance and memory usage, especially on platforms with limited video memory.
Best practices when using this variable include:
- Only modify it if you have a good understanding of the engine’s rendering pipeline and memory management.
- Test thoroughly on target hardware after making changes, as it can affect performance and visual quality.
- Consider the trade-offs between faster access (when using fast VRAM) and potentially increased memory usage.
Regarding the associated Downsample variable:
The purpose of the Downsample variable is to store the texture creation flags for downsampled textures within the FFastVramConfig struct.
It’s used in various parts of the rendering system, particularly in post-processing passes like downsampling and temporal anti-aliasing.
The value of this variable is set in the FFastVramConfig::Update() function, which syncs it with the r.FastVRam.Downsample console variable.
This variable directly interacts with r.FastVRam.Downsample, essentially serving as its internal representation within the engine’s rendering structures.
Developers should be aware that this variable directly affects texture creation, potentially impacting both performance and memory usage.
Best practices include:
- Treat this variable as read-only in most scenarios, as it’s managed by the engine’s configuration system.
- If modifying it directly (which is generally not recommended), ensure you understand the implications on the entire rendering pipeline.
- Use this variable in conjunction with other FFastVramConfig members for a consistent approach to texture memory management across different rendering features.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:473
Scope: file
Source code excerpt:
FASTVRAM_CVAR(CircleDOF, 1);
FASTVRAM_CVAR(CombineLUTs, 1);
FASTVRAM_CVAR(Downsample, 1);
FASTVRAM_CVAR(EyeAdaptation, 1);
FASTVRAM_CVAR(Histogram, 1);
FASTVRAM_CVAR(HistogramReduce, 1);
FASTVRAM_CVAR(VelocityFlat, 1);
FASTVRAM_CVAR(VelocityMax, 1);
FASTVRAM_CVAR(MotionBlur, 1);
#Associated Variable and Callsites
This variable is associated with another variable named Downsample
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessDownsample.cpp:113
Scope (from outer to inner):
file
function FScreenPassTexture AddDownsamplePass
Source code excerpt:
Inputs.FormatOverride != PF_Unknown ? Inputs.FormatOverride : InputDesc.Format,
FClearValueBinding(FLinearColor(0, 0, 0, 0)),
/* InFlags = */ TexCreate_ShaderResource | GFastVRamConfig.Downsample | (bIsComputePass ? TexCreate_UAV : (TexCreate_RenderTargetable | TexCreate_NoFastClear)));
Desc.Extent.X = FMath::Max(1, Desc.Extent.X);
Desc.Extent.Y = FMath::Max(1, Desc.Extent.Y);
if (Inputs.UserSuppliedOutput && Translate(Inputs.UserSuppliedOutput->GetDesc()) == Desc)
{
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/TemporalAA.cpp:657
Scope (from outer to inner):
file
function FTAAOutputs AddTemporalAAPass
Source code excerpt:
Inputs.DownsampleOverrideFormat != PF_Unknown ? Inputs.DownsampleOverrideFormat : Inputs.SceneColorInput->Desc.Format,
FClearValueBinding::Black,
TexCreate_ShaderResource | TexCreate_UAV | GFastVRamConfig.Downsample);
Outputs.DownsampledSceneColor = GraphBuilder.CreateTexture(HalfResSceneColorDesc, TEXT("SceneColorHalfRes"));
}
}
RDG_GPU_STAT_SCOPE(GraphBuilder, TAA);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:473
Scope: file
Source code excerpt:
FASTVRAM_CVAR(CircleDOF, 1);
FASTVRAM_CVAR(CombineLUTs, 1);
FASTVRAM_CVAR(Downsample, 1);
FASTVRAM_CVAR(EyeAdaptation, 1);
FASTVRAM_CVAR(Histogram, 1);
FASTVRAM_CVAR(HistogramReduce, 1);
FASTVRAM_CVAR(VelocityFlat, 1);
FASTVRAM_CVAR(VelocityMax, 1);
FASTVRAM_CVAR(MotionBlur, 1);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:673
Scope (from outer to inner):
file
function void FFastVramConfig::Update
Source code excerpt:
bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_CircleDOF, CircleDOF);
bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_CombineLUTs, CombineLUTs);
bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_Downsample, Downsample);
bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_EyeAdaptation, EyeAdaptation);
bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_Histogram, Histogram);
bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_HistogramReduce, HistogramReduce);
bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_VelocityFlat, VelocityFlat);
bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_VelocityMax, VelocityMax);
bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_MotionBlur, MotionBlur);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.h:2822
Scope: file
Source code excerpt:
ETextureCreateFlags CircleDOF;
ETextureCreateFlags CombineLUTs;
ETextureCreateFlags Downsample;
ETextureCreateFlags EyeAdaptation;
ETextureCreateFlags Histogram;
ETextureCreateFlags HistogramReduce;
ETextureCreateFlags VelocityFlat;
ETextureCreateFlags VelocityMax;
ETextureCreateFlags MotionBlur;