r.GPUScene.UploadEveryFrame
r.GPUScene.UploadEveryFrame
#Overview
name: r.GPUScene.UploadEveryFrame
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Whether to upload the entire scene\'s primitive data every frame. Useful for debugging.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.GPUScene.UploadEveryFrame is to control whether the entire scene’s primitive data is uploaded to the GPU every frame. This setting is primarily used for debugging purposes in the GPU-driven scene rendering system of Unreal Engine 5.
This setting variable is part of the rendering system, specifically the GPU Scene subsystem within the Renderer module. It’s used to manage the data transfer between CPU and GPU for scene primitives.
The value of this variable is set through the console variable system (CVarGPUSceneUploadEveryFrame). By default, it’s set to 0, meaning the feature is disabled.
This variable interacts closely with the PrimitivesToUpdate and PrimitiveDirtyState arrays in the FGPUScene class. When enabled, it forces all primitives to be marked as dirty and updated every frame, regardless of whether they’ve actually changed.
Developers must be aware that enabling this setting (setting it to 1) will significantly increase the amount of data transferred to the GPU every frame, which can impact performance. It should only be used for debugging purposes and not in production builds.
Best practices when using this variable include:
- Keep it disabled (set to 0) for normal development and production use.
- Only enable it temporarily when debugging issues related to GPU scene updates.
- Be prepared for potential performance degradation when enabled.
- Use in conjunction with other debugging tools to isolate issues in the GPU scene system.
Regarding the associated variable CVarGPUSceneUploadEveryFrame:
This is the actual console variable object that controls the r.GPUScene.UploadEveryFrame setting. It’s defined as a TAutoConsoleVariable
The purpose of CVarGPUSceneUploadEveryFrame is to provide a programmatic interface to read and modify the r.GPUScene.UploadEveryFrame setting. It’s used internally by the engine to check the current state of this setting and act accordingly.
This variable is accessed on the render thread (as indicated by the GetValueOnRenderThread() call), which is important for maintaining thread safety in the rendering system.
Developers should not interact with CVarGPUSceneUploadEveryFrame directly in most cases. Instead, they should use the r.GPUScene.UploadEveryFrame console command to change the setting. However, engine programmers working on the rendering system might need to use this variable directly in C++ code.
Best practices for using CVarGPUSceneUploadEveryFrame include:
- Always access its value on the render thread using GetValueOnRenderThread().
- Do not modify this variable directly; use the console command system instead.
- Be aware of the performance implications when the variable is set to a non-zero value.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/GPUScene.cpp:59
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarGPUSceneUploadEveryFrame(
TEXT("r.GPUScene.UploadEveryFrame"),
0,
TEXT("Whether to upload the entire scene's primitive data every frame. Useful for debugging."),
ECVF_RenderThreadSafe
);
static TAutoConsoleVariable<int32> CVarGPUSceneMaxPooledUploadBufferSize(
#Associated Variable and Callsites
This variable is associated with another variable named CVarGPUSceneUploadEveryFrame
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/GPUScene.cpp:58
Scope: file
Source code excerpt:
IMPLEMENT_SCENE_UB_STRUCT(FGPUSceneResourceParameters, GPUScene, ConstructDefault);
static TAutoConsoleVariable<int32> CVarGPUSceneUploadEveryFrame(
TEXT("r.GPUScene.UploadEveryFrame"),
0,
TEXT("Whether to upload the entire scene's primitive data every frame. Useful for debugging."),
ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/GPUScene.cpp:801
Scope (from outer to inner):
file
function void FGPUScene::UpdateInternal
Source code excerpt:
LastDeferredGPUWritePass = EGPUSceneGPUWritePass::None;
if ((CVarGPUSceneUploadEveryFrame.GetValueOnRenderThread() != 0) || bUpdateAllPrimitives)
{
PrimitivesToUpdate.Reset();
ResizeDirtyState(Scene.GetMaxPersistentPrimitiveIndex());
for (FPrimitiveSceneInfo *PrimitiveSceneInfo : Scene.Primitives)
{
PrimitiveDirtyState[PrimitiveSceneInfo->GetPersistentIndex().Index] |= EPrimitiveDirtyState::ChangedAll;