r.VRS.EnableSoftware
r.VRS.EnableSoftware
#Overview
name: r.VRS.EnableSoftware
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Generate 2x2 tile size software shading rate images when possible for use with nanite CS. Works even when r.VRS.Enable = 0 or Tier 2 VRS is unsupported by the hardware.0: Off, 1: On
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.VRS.EnableSoftware is to control the generation of 2x2 tile size software shading rate images for use with Nanite CS (Compute Shader) in Unreal Engine 5’s Variable Rate Shading (VRS) system.
This setting variable is primarily used in the Renderer subsystem of Unreal Engine 5, specifically within the Variable Rate Shading feature. It’s part of the rendering optimization techniques that aim to improve performance by varying the shading rate across different parts of the image.
The value of this variable is set through the console variable system in Unreal Engine. It’s defined as a TAutoConsoleVariable with an initial value of 0 (off).
The associated variable CVarVRSSoftwareImage directly interacts with r.VRS.EnableSoftware. They share the same value and purpose.
Developers should be aware of the following when using this variable:
- It enables software-based VRS even when hardware VRS is not supported or enabled.
- It works independently of the main VRS setting (r.VRS.Enable).
- It’s specifically designed for use with Nanite CS.
Best practices when using this variable include:
- Only enable it when you need software-based VRS, especially in scenarios where hardware VRS is not available.
- Monitor performance impacts, as software-based solutions may have different performance characteristics compared to hardware-based ones.
- Use in conjunction with other VRS settings for optimal results.
Regarding the associated variable CVarVRSSoftwareImage:
- It’s purpose is identical to r.VRS.EnableSoftware.
- It’s used within the FVariableRateShadingImageManager class to determine if software VRS is enabled.
- The value is checked on the render thread using GetValueOnRenderThread().
- It’s used in conjunction with hardware VRS checks to determine the overall VRS state for a frame.
Developers should treat CVarVRSSoftwareImage as the internal representation of the r.VRS.EnableSoftware setting, and use it when implementing VRS-related functionality in the renderer.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VariableRateShading/VariableRateShadingImageManager.cpp:66
Scope: file
Source code excerpt:
TAutoConsoleVariable<int32> CVarVRSSoftwareImage(
TEXT("r.VRS.EnableSoftware"),
0,
TEXT("Generate 2x2 tile size software shading rate images when possible for use with nanite CS. Works even when r.VRS.Enable = 0 or Tier 2 VRS is unsupported by the hardware.")
TEXT("0: Off, 1: On"),
ECVF_RenderThreadSafe);
#Associated Variable and Callsites
This variable is associated with another variable named CVarVRSSoftwareImage
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VariableRateShading/VariableRateShadingImageManager.cpp:65
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe);
TAutoConsoleVariable<int32> CVarVRSSoftwareImage(
TEXT("r.VRS.EnableSoftware"),
0,
TEXT("Generate 2x2 tile size software shading rate images when possible for use with nanite CS. Works even when r.VRS.Enable = 0 or Tier 2 VRS is unsupported by the hardware.")
TEXT("0: Off, 1: On"),
ECVF_RenderThreadSafe);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VariableRateShading/VariableRateShadingImageManager.cpp:333
Scope (from outer to inner):
file
class class FDebugVariableRateShadingCS : public FGlobalShader
Source code excerpt:
bool FVariableRateShadingImageManager::IsSoftwareVRSEnabled()
{
return CVarVRSSoftwareImage.GetValueOnRenderThread() > 0;
}
bool FVariableRateShadingImageManager::IsVRSEnabledForFrame()
{
return bHardwareVRSEnabledForFrame || bSoftwareVRSEnabledForFrame;
}
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VariableRateShading/VariableRateShadingImageManager.cpp:469
Scope (from outer to inner):
file
class class FDebugVariableRateShadingCS : public FGlobalShader
Source code excerpt:
{
bHardwareVRSEnabledForFrame = IsHardwareVRSSupported() && IsHardwareVRSEnabled();
bSoftwareVRSEnabledForFrame = IsSoftwareVRSSupported() && CVarVRSSoftwareImage.GetValueOnRenderThread() != 0;
if (!IsVRSEnabledForFrame())
{
return;
}
// If no generators or forced rate are active, bail