CriticalPathStall.AfterInitViews

CriticalPathStall.AfterInitViews

#Overview

name: CriticalPathStall.AfterInitViews

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 CriticalPathStall.AfterInitViews is to introduce an intentional delay after the InitViews process in the rendering pipeline. This is a debug option used for critical path analysis and forcing changes in the critical path of the rendering process.

This setting variable is primarily used in the Renderer module of Unreal Engine, specifically within the deferred shading renderer system. The FDeferredShadingSceneRenderer class relies on this variable for debugging purposes.

The value of this variable is set through a console variable (CVar) system, which allows runtime modification. It’s defined using TAutoConsoleVariable, meaning it stores a floating-point value.

The associated variable CVarStallInitViews directly interacts with CriticalPathStall.AfterInitViews. They share the same value and purpose, with CVarStallInitViews being the C++ representation of the console variable.

Developers must be aware that:

  1. This variable is only active in non-shipping builds (#if !UE_BUILD_SHIPPING).
  2. The value represents a time in milliseconds.
  3. Using this variable will intentionally slow down the rendering process, which can impact performance.

Best practices when using this variable include:

  1. Only use it for debugging and performance analysis purposes.
  2. Be cautious with high values as they can significantly impact frame rates.
  3. Remember to reset the value to 0 after debugging to avoid unintended performance impacts.
  4. Use in conjunction with profiling tools to get a comprehensive view of the rendering pipeline’s performance.

Regarding the associated variable CVarStallInitViews:

When working with CVarStallInitViews, developers should follow the same best practices as with CriticalPathStall.AfterInitViews, and be aware that modifying one will affect the other, as they represent the same underlying value.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DeferredShadingRenderer.cpp:1128

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarStallInitViews(
	TEXT("CriticalPathStall.AfterInitViews"),
	0.0f,
	TEXT("Sleep for the given time after InitViews. Time is given in ms. This is a debug option used for critical path analysis and forcing a change in the critical path."));

void FDeferredShadingSceneRenderer::CommitFinalPipelineState()
{
	// Family pipeline state

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DeferredShadingRenderer.cpp:1127

Scope: file

Source code excerpt:

}

static TAutoConsoleVariable<float> CVarStallInitViews(
	TEXT("CriticalPathStall.AfterInitViews"),
	0.0f,
	TEXT("Sleep for the given time after InitViews. Time is given in ms. This is a debug option used for critical path analysis and forcing a change in the critical path."));

void FDeferredShadingSceneRenderer::CommitFinalPipelineState()
{

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DeferredShadingRenderer.cpp:1710

Scope (from outer to inner):

file
function     void FDeferredShadingSceneRenderer::Render

Source code excerpt:


#if !UE_BUILD_SHIPPING
	if (CVarStallInitViews.GetValueOnRenderThread() > 0.0f)
	{
		SCOPE_CYCLE_COUNTER(STAT_InitViews_Intentional_Stall);
		FPlatformProcess::Sleep(CVarStallInitViews.GetValueOnRenderThread() / 1000.0f);
	}
#endif

	extern TSet<IPersistentViewUniformBufferExtension*> PersistentViewUniformBufferExtensions;

	for (IPersistentViewUniformBufferExtension* Extension : PersistentViewUniformBufferExtensions)