r.Nanite.EmitMaterialPerformanceWarnings

r.Nanite.EmitMaterialPerformanceWarnings

#Overview

name: r.Nanite.EmitMaterialPerformanceWarnings

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

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.Nanite.EmitMaterialPerformanceWarnings is to enable or disable the emission of warning messages related to Nanite material performance. Specifically, it controls whether the engine should emit log and on-screen messages to warn when a Nanite material is both programmable and using either masking or pixel depth offset (PDO).

This setting variable is primarily used in the Nanite rendering system, which is part of Unreal Engine’s rendering module. Based on the callsites, it’s clear that this variable is utilized within the NaniteFeedback.cpp file, which is responsible for managing feedback and warnings related to Nanite rendering.

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 (disabled by default).

The associated variable CVarEmitMaterialPerformanceWarnings directly interacts with r.Nanite.EmitMaterialPerformanceWarnings. They share the same value and purpose.

Developers must be aware that:

  1. This variable is render thread safe, as indicated by the ECVF_RenderThreadSafe flag.
  2. When enabled (set to a non-zero value), it will generate warnings that may impact performance due to additional logging and on-screen messages.
  3. The warnings are specifically for cases where Nanite materials are both programmable and use masking or pixel depth offset.

Best practices when using this variable include:

  1. Enable it during development and testing phases to identify potential performance issues with Nanite materials.
  2. Disable it in shipping builds to avoid unnecessary overhead.
  3. Use it in conjunction with other Nanite debugging tools to optimize material performance.

Regarding the associated variable CVarEmitMaterialPerformanceWarnings:

Developers should treat CVarEmitMaterialPerformanceWarnings as the internal representation of the r.Nanite.EmitMaterialPerformanceWarnings setting, and use the appropriate thread-safe methods to access its value when working with Nanite feedback and warning systems.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/NaniteFeedback.cpp:11

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarEmitMaterialPerformanceWarnings(
	TEXT("r.Nanite.EmitMaterialPerformanceWarnings"),
	0,
	TEXT("Emit log and on-screen messages to warn when a Nanite material is both programmable and using either masking or pixel depth offset (PDO)."),
	ECVF_RenderThreadSafe
);

namespace Nanite

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/NaniteFeedback.cpp:10

Scope: file

Source code excerpt:

#define LOCTEXT_NAMESPACE "NaniteFeedbackStatus"

static TAutoConsoleVariable<int32> CVarEmitMaterialPerformanceWarnings(
	TEXT("r.Nanite.EmitMaterialPerformanceWarnings"),
	0,
	TEXT("Emit log and on-screen messages to warn when a Nanite material is both programmable and using either masking or pixel depth offset (PDO)."),
	ECVF_RenderThreadSafe
);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/NaniteFeedback.cpp:95

Scope (from outer to inner):

file
namespace    Nanite
function     FFeedbackManager::FFeedbackManager
lambda-function

Source code excerpt:

		}

		if (CVarEmitMaterialPerformanceWarnings.GetValueOnAnyThread() != 0)
		{
			FScopeLock Lock(&DelgateCallbackCS);

			for (const auto& Item : MaterialWarningItems)
			{
				if (CurrentTime - Item.Value.LastTimeSeen < 2.5f)

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/NaniteFeedback.cpp:164

Scope (from outer to inner):

file
namespace    Nanite
function     bool ShouldReportFeedbackMaterialPerformanceWarning

Source code excerpt:

bool ShouldReportFeedbackMaterialPerformanceWarning()
{
	return CVarEmitMaterialPerformanceWarnings.GetValueOnRenderThread() != 0;
}


#endif // !UE_BUILD_SHIPPING

}	// namespace Nanite