rhi.SyncAllowVariable

rhi.SyncAllowVariable

#Overview

name: rhi.SyncAllowVariable

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 rhi.SyncAllowVariable is to control whether the RHI (Rendering Hardware Interface) is allowed to use variable refresh rate, if supported by the output hardware.

This setting variable is primarily used by the RHI subsystem of Unreal Engine 5. It’s part of the rendering system, specifically dealing with display synchronization.

The value of this variable is set through a console variable (CVar) named CVarRHISyncAllowVariable. It’s initialized with a default value of 1, meaning variable refresh rate is allowed by default.

The associated variable CVarRHISyncAllowVariable interacts directly with rhi.SyncAllowVariable. They essentially represent the same setting, with CVarRHISyncAllowVariable being the actual CVar implementation.

Developers should be aware that this variable affects how the game synchronizes with the display. When set to 1, it allows for variable refresh rates, which can provide smoother gameplay on supported hardware. However, it may not be suitable for all scenarios or hardware configurations.

Best practices when using this variable include:

  1. Testing the game with both enabled and disabled states to ensure proper behavior across different hardware setups.
  2. Considering the target hardware and audience when deciding whether to allow variable refresh rate.
  3. Providing an in-game option for users to toggle this setting if their hardware supports it.

Regarding the associated variable CVarRHISyncAllowVariable:

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/RHI/Private/RHIUtilities.cpp:121

Scope: file

Source code excerpt:


TAutoConsoleVariable<int32> CVarRHISyncAllowVariable(
	TEXT("rhi.SyncAllowVariable"),
	1,
	TEXT("When 1, allows the RHI to use variable refresh rate, if supported by the output hardware."),
	ECVF_Default
);

float GRHIFrameTimeMS = 0.0f;

#Loc: <Workspace>/Engine/Source/Runtime/RHI/Public/RHIUtilities.h:624

Scope: file

Source code excerpt:

extern RHI_API void RHIGetPresentThresholds(float& OutTopPercent, float& OutBottomPercent);

/** Returns the value of the rhi.SyncAllowVariable CVar. */
extern RHI_API bool RHIGetSyncAllowVariable();

/** Signals the completion of the specified task graph event when the given frame has flipped. */
UE_DEPRECATED(5.4, "RHICompleteGraphEventOnFlip is replaced with RHITriggerTaskEventOnFlip")
inline void RHICompleteGraphEventOnFlip(uint64 PresentIndex, FGraphEventRef Event) { checkNoEntry(); }

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/RHI/Private/RHIUtilities.cpp:120

Scope: file

Source code excerpt:

#endif

TAutoConsoleVariable<int32> CVarRHISyncAllowVariable(
	TEXT("rhi.SyncAllowVariable"),
	1,
	TEXT("When 1, allows the RHI to use variable refresh rate, if supported by the output hardware."),
	ECVF_Default
);

#Loc: <Workspace>/Engine/Source/Runtime/RHI/Private/RHIUtilities.cpp:531

Scope (from outer to inner):

file
function     bool RHIGetSyncAllowVariable

Source code excerpt:

bool RHIGetSyncAllowVariable()
{
	return CVarRHISyncAllowVariable.GetValueOnAnyThread() != 0;
}

void RHIGetPresentThresholds(float& OutTopPercent, float& OutBottomPercent)
{
	OutTopPercent = FMath::Clamp(CVarRHIPresentThresholdTop.GetValueOnAnyThread(), 0.0f, 1.0f);
	OutBottomPercent = FMath::Clamp(CVarRHIPresentThresholdBottom.GetValueOnAnyThread(), 0.0f, 1.0f);