r.DynamicRes.GPUTimingMeasureMethod

r.DynamicRes.GPUTimingMeasureMethod

#Overview

name: r.DynamicRes.GPUTimingMeasureMethod

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.DynamicRes.GPUTimingMeasureMethod is to select the method used for measuring GPU timings in Unreal Engine’s dynamic resolution system. This setting variable is part of the rendering system, specifically for performance measurement and optimization.

This setting variable is primarily used in the Dynamic Resolution subsystem of Unreal Engine. Based on the callsites, it’s implemented in the Engine module, within the DynamicResolution.cpp file.

The value of this variable is set through a console variable (CVar) system. It’s defined as a TAutoConsoleVariable with a default value of 0, which means it uses the same method as the stat unit for GPU timing measurements by default.

The associated variable CVarTimingMeasureModel interacts directly with r.DynamicRes.GPUTimingMeasureMethod. They share the same value and are used interchangeably in the code.

Developers must be aware that this variable affects how GPU timings are measured, which can impact the accuracy and performance of the dynamic resolution system. There are two options available: 0: Uses the same method as the stat unit (default) 1: Uses timestamp queries

Best practices when using this variable include:

  1. Consider the trade-offs between the two measurement methods. Timestamp queries (option 1) might provide more accurate results but could have a slight performance overhead.
  2. Ensure that the chosen method is supported on all target platforms for your game.
  3. Test the impact of both options on your specific use case to determine which provides the best balance of accuracy and performance.
  4. Be consistent in using either the console variable name (r.DynamicRes.GPUTimingMeasureMethod) or the associated C++ variable name (CVarTimingMeasureModel) throughout your codebase to avoid confusion.

Regarding the associated variable CVarTimingMeasureModel:

The purpose of CVarTimingMeasureModel is identical to r.DynamicRes.GPUTimingMeasureMethod, as they are essentially the same variable with different access points.

It’s used in the same Dynamic Resolution subsystem within the Engine module.

The value is set through the TAutoConsoleVariable system, just like r.DynamicRes.GPUTimingMeasureMethod.

It interacts directly with r.DynamicRes.GPUTimingMeasureMethod, sharing the same value.

Developers should be aware that this variable is the C++ representation of the console variable and is used to access the timing measurement method setting within the code.

Best practices for using CVarTimingMeasureModel include:

  1. Use GetValueOnRenderThread() when accessing this variable from the render thread to ensure thread-safe access.
  2. Be aware that changes to this variable at runtime will affect the dynamic resolution system’s behavior.
  3. Consider caching the value if it’s accessed frequently to avoid potential performance impacts from repeated CVar lookups.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DynamicResolution.cpp:128

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarTimingMeasureModel(
	TEXT("r.DynamicRes.GPUTimingMeasureMethod"),
	0,
	TEXT("Selects the method to use to measure GPU timings.\n")
	TEXT(" 0: Same as stat unit (default);\n 1: Timestamp queries."),
	ECVF_RenderThreadSafe | ECVF_Default);

static TAutoConsoleVariable<int32> CVarUpperBoundQuantization(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DynamicResolution.cpp:127

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe | ECVF_Default);

static TAutoConsoleVariable<int32> CVarTimingMeasureModel(
	TEXT("r.DynamicRes.GPUTimingMeasureMethod"),
	0,
	TEXT("Selects the method to use to measure GPU timings.\n")
	TEXT(" 0: Same as stat unit (default);\n 1: Timestamp queries."),
	ECVF_RenderThreadSafe | ECVF_Default);

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DynamicResolution.cpp:766

Scope (from outer to inner):

file
class        class FDefaultDynamicResolutionStateProxy
function     void BeginFrame

Source code excerpt:

		float PrevRHIThreadTimeMs = FPlatformTime::ToMilliseconds(GRHIThreadTime);

		bUseTimeQueriesThisFrame = GSupportsTimestampRenderQueries && CVarTimingMeasureModel.GetValueOnRenderThread() == 1;

		if (bUseTimeQueriesThisFrame)
		{
			// Create the query pool
			if (!QueryPool.IsValid())
				QueryPool = RHICreateRenderQueryPool(RQT_AbsoluteTime);