r.Mobile.ForceDepthResolve

r.Mobile.ForceDepthResolve

#Overview

name: r.Mobile.ForceDepthResolve

This variable is created as a Console Variable (cvar).

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.Mobile.ForceDepthResolve is to control how the depth buffer is resolved in mobile rendering scenarios within Unreal Engine 5.

This setting variable is primarily used in the mobile rendering system, specifically in the MobileShadingRenderer module. It affects how the depth buffer is handled during the rendering process on mobile platforms.

The value of this variable is set through a console variable (CVar) named CVarMobileForceDepthResolve. It’s defined in the MobileShadingRenderer.cpp file and can be set at runtime or through configuration files.

The variable interacts with the rendering process, particularly in the InitViews function of the FMobileSceneRenderer class. It determines whether the depth buffer should be forcibly resolved.

Developers must be aware that:

  1. This setting has two possible values: 0 (default) and 1.
  2. When set to 0, the depth buffer is resolved by switching out render targets.
  3. When set to 1, the depth buffer is resolved by switching out render targets and drawing with the depth texture.

Best practices when using this variable include:

  1. Only change this setting if you’re experiencing issues with depth buffer resolution on mobile platforms.
  2. Be aware that forcing depth resolve (setting to 1) may have performance implications.
  3. Test thoroughly on target mobile devices after changing this setting to ensure it doesn’t negatively impact performance or visual quality.

Regarding the associated variable CVarMobileForceDepthResolve:

This is the actual console variable that controls the r.Mobile.ForceDepthResolve setting. It’s defined as a TAutoConsoleVariable, which means it’s an integer value that can be changed at runtime.

The purpose of CVarMobileForceDepthResolve is to provide a way to modify the r.Mobile.ForceDepthResolve setting dynamically, either through console commands or configuration files.

This variable is used in the same MobileShadingRenderer module and is directly accessed in the InitViews function to determine whether depth resolution should be forced.

Developers should be aware that:

  1. This variable can be modified at runtime, allowing for dynamic adjustment of the depth resolution behavior.
  2. It’s marked with ECVF_Scalability and ECVF_RenderThreadSafe flags, indicating it’s safe to modify on the render thread and can be used for scalability purposes.

Best practices for using CVarMobileForceDepthResolve include:

  1. Use console commands or configuration files to modify this variable rather than hardcoding values.
  2. Consider exposing this setting in your game’s graphics options menu for advanced users or debugging purposes.
  3. Monitor performance when changing this value, especially on lower-end mobile devices.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/MobileShadingRenderer.cpp:78

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarMobileForceDepthResolve(
	TEXT("r.Mobile.ForceDepthResolve"),
	0,
	TEXT("0: Depth buffer is resolved by switching out render targets. (Default)\n")
	TEXT("1: Depth buffer is resolved by switching out render targets and drawing with the depth texture.\n"),
	ECVF_Scalability | ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarMobileAdrenoOcclusionMode(

#Associated Variable and Callsites

This variable is associated with another variable named CVarMobileForceDepthResolve. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/MobileShadingRenderer.cpp:77

Scope: file

Source code excerpt:

uint32 GetShadowQuality();

static TAutoConsoleVariable<int32> CVarMobileForceDepthResolve(
	TEXT("r.Mobile.ForceDepthResolve"),
	0,
	TEXT("0: Depth buffer is resolved by switching out render targets. (Default)\n")
	TEXT("1: Depth buffer is resolved by switching out render targets and drawing with the depth texture.\n"),
	ECVF_Scalability | ECVF_RenderThreadSafe);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/MobileShadingRenderer.cpp:576

Scope (from outer to inner):

file
function     void FMobileSceneRenderer::InitViews

Source code excerpt:

	// Whether we need to store depth for post-processing
	// On PowerVR we see flickering of shadows and depths not updating correctly if targets are discarded.
	const bool bForceDepthResolve = (CVarMobileForceDepthResolve.GetValueOnRenderThread() == 1);
	const bool bSeparateTranslucencyActive = IsMobileSeparateTranslucencyActive(Views.GetData(), Views.Num()); 
	const bool bPostProcessUsesSceneDepth = PostProcessUsesSceneDepth(Views[0]) || IsMobileDistortionActive(Views[0]);
	const bool bRequireSeparateViewPass = Views.Num() > 1 && !Views[0].bIsMobileMultiViewEnabled;
	bRequiresMultiPass = RequiresMultiPass(NumMSAASamples, ShaderPlatform);

	bKeepDepthContent =