r.FastVRam.GlobalDistanceFieldCullGridBuffers
r.FastVRam.GlobalDistanceFieldCullGridBuffers
#Overview
name: r.FastVRam.GlobalDistanceFieldCullGridBuffers
This variable is created as a Console Variable (cvar).
- type:
Var
- help: ``
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.FastVRam.GlobalDistanceFieldCullGridBuffers is to control the memory allocation strategy for global distance field cull grid buffers in Unreal Engine’s rendering system. This setting is specifically related to the global distance field feature, which is used for various rendering techniques such as ambient occlusion, indirect lighting, and shadow calculations.
This setting variable is primarily used in the Renderer module of Unreal Engine. Based on the provided code snippets, it appears to be part of a larger system for managing fast VRAM usage across different rendering resources.
The value of this variable is set using the FASTVRAM_CVAR macro, which likely creates a console variable that can be adjusted at runtime. In the provided code, it’s initially set to 1, indicating that these buffers should use fast VRAM by default.
The r.FastVRam.GlobalDistanceFieldCullGridBuffers variable interacts with other similar variables like r.FastVRam.DistanceFieldAOScreenGridResources and r.FastVRam.ForwardLightingCullingResources. They are all part of the FFastVramConfig struct, which manages fast VRAM allocation for various rendering resources.
Developers should be aware that changing this variable will affect the memory allocation strategy for global distance field cull grid buffers. Using fast VRAM can improve performance but may compete with other resources for limited fast VRAM space.
Best practices when using this variable include:
- Carefully considering the trade-offs between performance and memory usage.
- Profiling the application to determine if using fast VRAM for these buffers provides a significant performance benefit.
- Balancing the use of fast VRAM across different rendering resources based on their impact on overall performance.
Regarding the associated variable GlobalDistanceFieldCullGridBuffers:
This is an internal variable of type EBufferUsageFlags within the FFastVramConfig struct. It directly corresponds to the r.FastVRam.GlobalDistanceFieldCullGridBuffers console variable.
The purpose of GlobalDistanceFieldCullGridBuffers is to store the actual buffer usage flags that will be applied when creating the global distance field cull grid buffers. Its value is updated in the FFastVramConfig::Update() function based on the state of the corresponding console variable.
Developers should be aware that this internal variable is what actually controls the buffer creation flags, while the console variable provides a user-friendly way to adjust the setting. Any code that needs to check whether fast VRAM should be used for these buffers should refer to this internal variable rather than directly querying the console variable.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:513
Scope: file
Source code excerpt:
FASTVRAM_CVAR(DistanceFieldAOScreenGridResources, 1);
FASTVRAM_CVAR(ForwardLightingCullingResources, 1);
FASTVRAM_CVAR(GlobalDistanceFieldCullGridBuffers, 1);
TSharedPtr<FVirtualShadowMapClipmap> FVisibleLightInfo::FindShadowClipmapForView(const FViewInfo* View) const
{
for (const auto& Clipmap : VirtualShadowMapClipmaps)
{
if (Clipmap->GetDependentView() == View)
#Associated Variable and Callsites
This variable is associated with another variable named GlobalDistanceFieldCullGridBuffers
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:513
Scope: file
Source code excerpt:
FASTVRAM_CVAR(DistanceFieldAOScreenGridResources, 1);
FASTVRAM_CVAR(ForwardLightingCullingResources, 1);
FASTVRAM_CVAR(GlobalDistanceFieldCullGridBuffers, 1);
TSharedPtr<FVirtualShadowMapClipmap> FVisibleLightInfo::FindShadowClipmapForView(const FViewInfo* View) const
{
for (const auto& Clipmap : VirtualShadowMapClipmaps)
{
if (Clipmap->GetDependentView() == View)
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:712
Scope (from outer to inner):
file
function void FFastVramConfig::Update
Source code excerpt:
bDirty |= UpdateBufferFlagFromCVar(CVarFastVRam_DistanceFieldAOScreenGridResources, DistanceFieldAOScreenGridResources);
bDirty |= UpdateBufferFlagFromCVar(CVarFastVRam_ForwardLightingCullingResources, ForwardLightingCullingResources);
bDirty |= UpdateBufferFlagFromCVar(CVarFastVRam_GlobalDistanceFieldCullGridBuffers, GlobalDistanceFieldCullGridBuffers);
// When Substrate is enable, remove Scene color from fast VRAM to leave space for material buffer which has more impact on performance
if (Substrate::IsSubstrateEnabled() && !IsForwardShadingEnabled(GMaxRHIShaderPlatform))
{
SceneColor = SceneColor & (~(TexCreate_FastVRAM | TexCreate_FastVRAMPartialAlloc));
}
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.h:2864
Scope: file
Source code excerpt:
EBufferUsageFlags DistanceFieldAOScreenGridResources;
EBufferUsageFlags ForwardLightingCullingResources;
EBufferUsageFlags GlobalDistanceFieldCullGridBuffers;
bool bDirty;
private:
bool UpdateTextureFlagFromCVar(TAutoConsoleVariable<int32>& CVar, ETextureCreateFlags& InOutValue);
bool UpdateBufferFlagFromCVar(TAutoConsoleVariable<int32>& CVar, EBufferUsageFlags& InOutValue);
};