rhi.SyncAllowVariable
rhi.SyncAllowVariable
#Overview
name: rhi.SyncAllowVariable
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
When 1, allows the RHI to use variable refresh rate, if supported by the output hardware.
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:
- Testing the game with both enabled and disabled states to ensure proper behavior across different hardware setups.
- Considering the target hardware and audience when deciding whether to allow variable refresh rate.
- Providing an in-game option for users to toggle this setting if their hardware supports it.
Regarding the associated variable CVarRHISyncAllowVariable:
- It’s a TAutoConsoleVariable
, which means it can be changed at runtime through console commands. - It’s used in the RHIGetSyncAllowVariable() function, which returns a boolean value based on whether CVarRHISyncAllowVariable is non-zero.
- Developers can use RHIGetSyncAllowVariable() to check the current state of this setting in their code.
- When modifying this variable, developers should be aware that it may affect the game’s performance and visual smoothness, especially on variable refresh rate displays.
#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);