r.BasePassWriteDepthEvenWithFullPrepass
r.BasePassWriteDepthEvenWithFullPrepass
#Overview
name: r.BasePassWriteDepthEvenWithFullPrepass
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
0 to allow a readonly base pass, which skips an MSAA depth resolve, and allows masked materials to get EarlyZ (writing to depth while doing clip() disables EarlyZ) (default)\n1 to force depth writes in the base pass. Useful for debugging when the prepass and base pass don\'t match what they render.
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.BasePassWriteDepthEvenWithFullPrepass is to control depth writing behavior in the base pass of the rendering pipeline. It is primarily used in the rendering system of Unreal Engine 5.
This setting variable is utilized by the Renderer module, specifically in the scene rendering subsystem. It affects how depth is handled during the base pass, which is a crucial part of the rendering process.
The value of this variable is set through a console variable (CVarBasePassWriteDepthEvenWithFullPrepass) in the Renderer module. By default, it is set to 0, allowing for a read-only base pass.
This variable interacts closely with other rendering-related variables, such as those controlling MSAA (Multisample Anti-Aliasing) and the early Z pass. It’s part of a group of settings that determine how depth and stencil operations are performed during rendering.
Developers must be aware that changing this variable can have significant impacts on rendering performance and visual output. When set to 1, it forces depth writes in the base pass, which can be useful for debugging but may impact performance in normal scenarios.
Best practices for using this variable include:
- Leaving it at the default value (0) for normal rendering scenarios.
- Only enabling it (setting to 1) when debugging discrepancies between the prepass and base pass rendering.
- Considering its interaction with MSAA and early Z pass settings when modifying it.
Regarding the associated variable CVarBasePassWriteDepthEvenWithFullPrepass:
This is the actual console variable that controls the r.BasePassWriteDepthEvenWithFullPrepass setting. It’s defined as a TAutoConsoleVariable
The purpose of this variable is the same as r.BasePassWriteDepthEvenWithFullPrepass, as they are essentially two representations of the same setting.
This variable is used in the UpdateEarlyZPassModeCVarSinkFunction to determine if the early Z pass mode needs to be updated based on changes in various rendering settings, including this one.
It’s also used in the GetDefaultBasePassDepthStencilAccess function to determine the depth/stencil access mode for the base pass.
Developers should be aware that changes to this console variable will directly affect the rendering pipeline’s behavior regarding depth writes in the base pass. It’s important to use this variable judiciously and primarily for debugging purposes, as changing it can impact both performance and rendering accuracy.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RendererScene.cpp:134
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarBasePassWriteDepthEvenWithFullPrepass(
TEXT("r.BasePassWriteDepthEvenWithFullPrepass"),
0,
TEXT("0 to allow a readonly base pass, which skips an MSAA depth resolve, and allows masked materials to get EarlyZ (writing to depth while doing clip() disables EarlyZ) (default)\n")
TEXT("1 to force depth writes in the base pass. Useful for debugging when the prepass and base pass don't match what they render."));
int32 GVisibilitySkipAlwaysVisible = 1;
static FAutoConsoleVariableRef CVarVisibilitySkipAlwaysVisible(
#Associated Variable and Callsites
This variable is associated with another variable named CVarBasePassWriteDepthEvenWithFullPrepass
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RendererScene.cpp:133
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<int32> CVarBasePassWriteDepthEvenWithFullPrepass(
TEXT("r.BasePassWriteDepthEvenWithFullPrepass"),
0,
TEXT("0 to allow a readonly base pass, which skips an MSAA depth resolve, and allows masked materials to get EarlyZ (writing to depth while doing clip() disables EarlyZ) (default)\n")
TEXT("1 to force depth writes in the base pass. Useful for debugging when the prepass and base pass don't match what they render."));
int32 GVisibilitySkipAlwaysVisible = 1;
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RendererScene.cpp:1374
Scope (from outer to inner):
file
function static void UpdateEarlyZPassModeCVarSinkFunction
Source code excerpt:
static int32 CachedMSAACount = CVarMSAACount->GetValueOnGameThread();
static int32 CachedEarlyZPass = CVarEarlyZPass.GetValueOnGameThread();
static int32 CachedBasePassWriteDepthEvenWithFullPrepass = CVarBasePassWriteDepthEvenWithFullPrepass.GetValueOnGameThread();
const int32 AntiAliasingMethod = CVarAntiAliasingMethod->GetValueOnGameThread();
const int32 MSAACount = CVarMSAACount->GetValueOnGameThread();
const int32 EarlyZPass = CVarEarlyZPass.GetValueOnGameThread();
const int32 BasePassWriteDepthEvenWithFullPrepass = CVarBasePassWriteDepthEvenWithFullPrepass.GetValueOnGameThread();
// Switching between MSAA and another AA in forward shading mode requires EarlyZPassMode to update.
if (AntiAliasingMethod != CachedAntiAliasingMethod
|| MSAACount != CachedMSAACount
|| EarlyZPass != CachedEarlyZPass
|| BasePassWriteDepthEvenWithFullPrepass != CachedBasePassWriteDepthEvenWithFullPrepass)
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RendererScene.cpp:4653
Scope (from outer to inner):
file
function FExclusiveDepthStencil::Type FScene::GetDefaultBasePassDepthStencilAccess
Source code excerpt:
const EShaderPlatform ShaderPlatform = GetFeatureLevelShaderPlatform(InFeatureLevel);
if (ShouldForceFullDepthPass(ShaderPlatform)
&& CVarBasePassWriteDepthEvenWithFullPrepass.GetValueOnAnyThread() == 0)
{
BasePassDepthStencilAccess = FExclusiveDepthStencil::DepthRead_StencilWrite;
}
}
return BasePassDepthStencilAccess;