r.VT.RVT.DirectCompress
r.VT.RVT.DirectCompress
#Overview
name: r.VT.RVT.DirectCompress
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Compress texture data direct to the physical texture on platforms that support it.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.VT.RVT.DirectCompress is to control whether texture data is compressed directly to the physical texture on platforms that support it. This setting is specifically related to the rendering system, particularly the Virtual Texturing (VT) subsystem for Runtime Virtual Textures (RVT).
This setting variable is primarily used in the Renderer module of Unreal Engine, specifically within the RuntimeVirtualTexture namespace. It’s part of the Virtual Texturing system, which is crucial for efficient texture management in large-scale environments.
The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1, meaning it’s enabled by default. Developers can change this value at runtime using console commands or through project settings.
This variable interacts closely with its associated variable CVarVTDirectCompress. They share the same value and purpose, with CVarVTDirectCompress being the actual TAutoConsoleVariable object that stores and manages the setting.
Developers must be aware that this setting is render thread safe (ECVF_RenderThreadSafe), meaning it can be safely changed during rendering operations. However, it’s important to note that this feature is platform-dependent, as indicated by the comment “on platforms that support it.”
Best practices when using this variable include:
- Ensuring the target platform supports direct compression before relying on this feature.
- Testing performance with this setting both enabled and disabled to determine the optimal configuration for your specific use case.
- Being cautious when changing this value at runtime, as it could impact rendering performance and memory usage.
Regarding the associated variable CVarVTDirectCompress:
The purpose of CVarVTDirectCompress is the same as r.VT.RVT.DirectCompress. It’s the actual console variable object that controls the direct compression feature for Runtime Virtual Textures.
This variable is used within the Renderer module, specifically in the RuntimeVirtualTexture namespace. It’s particularly important in the FRenderGraphSetup function, where it determines whether direct aliasing should be used for the compression pass.
The value of CVarVTDirectCompress is set through the console variable system and can be accessed using GetValueOnRenderThread() method.
CVarVTDirectCompress interacts directly with the GRHISupportsUAVFormatAliasing global variable, which checks if the current RHI (Rendering Hardware Interface) supports UAV (Unordered Access View) format aliasing.
Developers should be aware that this variable’s value is checked on the render thread, which is crucial for thread-safe operations in rendering code.
Best practices include:
- Using GetValueOnRenderThread() when accessing this variable in render thread code.
- Considering the interaction with GRHISupportsUAVFormatAliasing when implementing related features.
- Being mindful of the performance implications of enabling or disabling this feature, especially on different hardware configurations.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VT/RuntimeVirtualTextureRender.cpp:39
Scope (from outer to inner):
file
namespace RuntimeVirtualTexture
Source code excerpt:
static TAutoConsoleVariable<int32> CVarVTDirectCompress(
TEXT("r.VT.RVT.DirectCompress"),
1,
TEXT("Compress texture data direct to the physical texture on platforms that support it."),
ECVF_RenderThreadSafe);
int32 RenderCaptureNextRVTPagesDraws = 0;
static FAutoConsoleVariableRef CVarRenderCaptureNextRVTPagesDraws(
#Associated Variable and Callsites
This variable is associated with another variable named CVarVTDirectCompress
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VT/RuntimeVirtualTextureRender.cpp:38
Scope (from outer to inner):
file
namespace RuntimeVirtualTexture
Source code excerpt:
ECVF_ReadOnly);
static TAutoConsoleVariable<int32> CVarVTDirectCompress(
TEXT("r.VT.RVT.DirectCompress"),
1,
TEXT("Compress texture data direct to the physical texture on platforms that support it."),
ECVF_RenderThreadSafe);
int32 RenderCaptureNextRVTPagesDraws = 0;
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VT/RuntimeVirtualTextureRender.cpp:509
Scope (from outer to inner):
file
function FRenderGraphSetup
Source code excerpt:
// Use direct aliasing for compression pass on platforms that support it.
bDirectAliasing = bCompressedFormat && GRHISupportsUAVFormatAliasing && CVarVTDirectCompress.GetValueOnRenderThread() != 0;
// Some problems happen when we don't use ERenderTargetLoadAction::EClear:
// * Some RHI need explicit flag to avoid a fast clear (TexCreate_NoFastClear).
// * DX12 RHI has a bug with RDG transient allocator (UE-173023) so we use TexCreate_Shared to avoid that.
const ETextureCreateFlags RTNoClearHackFlags = TexCreate_NoFastClear | TexCreate_Shared;