r.HDR.Display.OutputDevice

r.HDR.Display.OutputDevice

#Overview

name: r.HDR.Display.OutputDevice

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

It is referenced in 12 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.HDR.Display.OutputDevice is to control the output device format for HDR (High Dynamic Range) display in Unreal Engine 5. This setting variable is primarily used in the rendering system to determine how color data should be processed and displayed on different types of output devices.

The r.HDR.Display.OutputDevice setting is used in various Unreal Engine subsystems and modules, including:

  1. Rendering Core
  2. D3D11RHI (Direct3D 11 Rendering Hardware Interface)
  3. D3D12RHI (Direct3D 12 Rendering Hardware Interface)
  4. VulkanRHI (Vulkan Rendering Hardware Interface)
  5. SlateRHI (Slate Rendering Hardware Interface)
  6. BinkMediaPlayer plugin

The value of this variable is set through the console variable system. It can be modified programmatically or through configuration files. The HDRConfigureCVars function in RenderCore.cpp is one place where this value is set based on HDR settings.

This variable interacts closely with other HDR-related variables, such as:

  1. r.HDR.EnableHDROutput
  2. r.HDR.Display.ColorGamut
  3. r.HDR.Display.OutputDevice

Developers should be aware of the following when using this variable:

  1. The value determines the color space and format used for display output.
  2. It affects how color data is processed and displayed across different platforms and display types.
  3. Incorrect settings may result in improper color reproduction or visual artifacts.

Best practices when using this variable include:

  1. Ensure it’s set correctly for the target display device and platform.
  2. Test the visual output on various display types to verify correct color reproduction.
  3. Consider platform-specific requirements and limitations when setting this value.

The associated variable CVarDisplayOutputDevice is essentially an internal representation of r.HDR.Display.OutputDevice. It’s used in the codebase to access and modify the value of r.HDR.Display.OutputDevice. Developers should use CVarDisplayOutputDevice when working with this setting in C++ code, as it provides a convenient way to access and modify the value at runtime.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderCore.cpp:363

Scope: file

Source code excerpt:


TAutoConsoleVariable<int32> CVarDisplayOutputDevice(
	TEXT("r.HDR.Display.OutputDevice"),
	0,
	TEXT("Device format of the output display:\n")
	TEXT("0: sRGB (LDR)\n")
	TEXT("1: Rec709 (LDR)\n")
	TEXT("2: Explicit gamma mapping (LDR)\n")
	TEXT("3: ACES 1000 nit ST-2084 (Dolby PQ) (HDR)\n")

#Loc: <Workspace>/Engine/Plugins/Media/BinkMedia/Source/BinkMediaPlayer/Private/BinkMovieStreamer.cpp:129

Scope (from outer to inner):

file
function     bool FBinkMovieStreamer::Tick

Source code excerpt:


		static const auto CVarHDROutputEnabled = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.HDR.EnableHDROutput"));
		static const auto CVarDisplayOutputDevice = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.HDR.Display.OutputDevice"));
		if (GRHISupportsHDROutput && CVarHDROutputEnabled->GetValueOnRenderThread() != 0)
		{
			EDisplayOutputFormat outDev = static_cast<EDisplayOutputFormat>(CVarDisplayOutputDevice->GetValueOnRenderThread());
			float DisplayMaxLuminance = HDRGetDisplayMaximumLuminance();
			switch (outDev)
			{

#Loc: <Workspace>/Engine/Source/Runtime/D3D12RHI/Private/Windows/WindowsD3D12Device.cpp:1721

Scope (from outer to inner):

file
function     void FD3D12DynamicRHI::Init

Source code excerpt:

		//	1) PF_FloatRGBA - FP16 format that allows for linear gamma. This is the current engine default.
		//					r.HDR.Display.ColorGamut = 0 (sRGB which is the same gamut as ScRGB)
		//					r.HDR.Display.OutputDevice = 5 or 6 (ScRGB)
		//	2) PF_A2B10G10R10 - Save memory vs FP16 as well as allow for possible performance improvements 
		//						in fullscreen by avoiding format conversions.
		//					r.HDR.Display.ColorGamut = 2 (Rec2020 / BT2020)
		//					r.HDR.Display.OutputDevice = 3 or 4 (ST-2084)
#if WITH_EDITOR
		GRHIHDRDisplayOutputFormat = PF_FloatRGBA;
#else
		GRHIHDRDisplayOutputFormat = PF_A2B10G10R10;
#endif
	}

#Loc: <Workspace>/Engine/Source/Runtime/D3D12RHI/Private/Windows/WindowsD3D12Viewport.cpp:480

Scope (from outer to inner):

file
function     void FD3D12Viewport::EnsureColorSpace

Source code excerpt:

	const bool bPrimaries2020 = (DisplayGamut == EDisplayColorGamut::Rec2020_D65);

	// See console variable r.HDR.Display.OutputDevice.
	switch (OutputDevice)
	{
		// Gamma 2.2
	case EDisplayOutputFormat::SDR_sRGB:
	case EDisplayOutputFormat::SDR_Rec709:
		NewColorSpace = bPrimaries2020 ? DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P2020 : DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709;

#Loc: <Workspace>/Engine/Source/Runtime/SlateRHIRenderer/Private/SlateRHIRenderer.cpp:769

Scope (from outer to inner):

file
class        class FCompositeShaderBase : public FGlobalShader
function     void SetParametersBase

Source code excerpt:

	void SetParametersBase(FRHIBatchedShaderParameters& BatchedParameters, FRHITexture* UITextureRHI, FRHITexture* UITextureWriteMaskRHI, FRHITexture* ColorSpaceLUTRHI)
	{
		static const auto CVarOutputDevice = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.HDR.Display.OutputDevice"));

		SetTextureParameter(BatchedParameters, UITexture, UISampler, TStaticSamplerState<SF_Point>::GetRHI(), UITextureRHI);
		SetTextureParameter(BatchedParameters, ColorSpaceLUT, ColorSpaceLUTSampler, TStaticSamplerState<SF_Bilinear, AM_Clamp, AM_Clamp, AM_Clamp>::GetRHI(), ColorSpaceLUTRHI);
		SetShaderValue(BatchedParameters, UILevel, CVarUILevel.GetValueOnRenderThread());
		SetShaderValue(BatchedParameters, OutputDevice, CVarOutputDevice->GetValueOnRenderThread());
		SetShaderValue(BatchedParameters, UILuminance, CVarHDRUILuminance.GetValueOnRenderThread());

#Loc: <Workspace>/Engine/Source/Runtime/SlateRHIRenderer/Private/SlateShaders.cpp:133

Scope (from outer to inner):

file
function     void FSlateElementPS::ModifyCompilationEnvironment

Source code excerpt:

void FSlateElementPS::ModifyCompilationEnvironment(const FGlobalShaderPermutationParameters& Parameters, FShaderCompilerEnvironment& OutEnvironment)
{
	static const auto CVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.HDR.Display.OutputDevice"));
	OutEnvironment.SetDefine(TEXT("USE_709"), CVar ? (CVar->GetValueOnGameThread() == (int32)EDisplayOutputFormat::SDR_Rec709) : 1);
}


/************************************************************************/
/* FSlateMaskingVertexDeclaration                                              */

#Loc: <Workspace>/Engine/Source/Runtime/VulkanRHI/Private/VulkanSwapChain.cpp:172

Scope (from outer to inner):

file
function     FVulkanSwapChain::FVulkanSwapChain

Source code excerpt:

		if (Formats[Index].colorSpace != RequestedColorSpace)
		{
			static const auto CVarHDROutputDevice = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.HDR.Display.OutputDevice"));
			EDisplayOutputFormat OutputDevice = CVarHDROutputDevice ? (EDisplayOutputFormat)CVarHDROutputDevice->GetValueOnAnyThread() : EDisplayOutputFormat::SDR_sRGB;
			switch (OutputDevice)
			{
			case EDisplayOutputFormat::SDR_sRGB:
				RequestedColorSpace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
				break;

#Loc: <Workspace>/Engine/Source/Runtime/Windows/D3D11RHI/Private/Windows/WindowsD3D11Viewport.cpp:339

Scope (from outer to inner):

file
function     inline void EnsureColorSpace

Source code excerpt:

	const bool bPrimaries2020 = (DisplayGamut == EDisplayColorGamut::Rec2020_D65);

	// See console variable r.HDR.Display.OutputDevice.
	switch (OutputDevice)
	{
		// Gamma 2.2
	case EDisplayOutputFormat::SDR_sRGB:
	case EDisplayOutputFormat::SDR_Rec709:
		NewColorSpace = bPrimaries2020 ? DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P2020 : DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Plugins/Media/BinkMedia/Source/BinkMediaPlayer/Private/BinkMovieStreamer.cpp:129

Scope (from outer to inner):

file
function     bool FBinkMovieStreamer::Tick

Source code excerpt:


		static const auto CVarHDROutputEnabled = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.HDR.EnableHDROutput"));
		static const auto CVarDisplayOutputDevice = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.HDR.Display.OutputDevice"));
		if (GRHISupportsHDROutput && CVarHDROutputEnabled->GetValueOnRenderThread() != 0)
		{
			EDisplayOutputFormat outDev = static_cast<EDisplayOutputFormat>(CVarDisplayOutputDevice->GetValueOnRenderThread());
			float DisplayMaxLuminance = HDRGetDisplayMaximumLuminance();
			switch (outDev)
			{
			// LDR
			case EDisplayOutputFormat::SDR_sRGB:
			case EDisplayOutputFormat::SDR_Rec709:

#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderCore.cpp:362

Scope: file

Source code excerpt:

	ECVF_Scalability | ECVF_RenderThreadSafe);

TAutoConsoleVariable<int32> CVarDisplayOutputDevice(
	TEXT("r.HDR.Display.OutputDevice"),
	0,
	TEXT("Device format of the output display:\n")
	TEXT("0: sRGB (LDR)\n")
	TEXT("1: Rec709 (LDR)\n")
	TEXT("2: Explicit gamma mapping (LDR)\n")

#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderCore.cpp:444

Scope (from outer to inner):

file
function     EDisplayOutputFormat HDRGetDefaultDisplayOutputFormat

Source code excerpt:

RENDERCORE_API EDisplayOutputFormat HDRGetDefaultDisplayOutputFormat()
{
	return static_cast<EDisplayOutputFormat>(FMath::Clamp(CVarDisplayOutputDevice.GetValueOnAnyThread(), 0, static_cast<int32>(EDisplayOutputFormat::MAX) - 1));
}

RENDERCORE_API EDisplayColorGamut HDRGetDefaultDisplayColorGamut()
{
	return static_cast<EDisplayColorGamut>(FMath::Clamp(CVarDisplayColorGamut.GetValueOnAnyThread(), 0, static_cast<int32>(EDisplayColorGamut::MAX) - 1));
}

#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderCore.cpp:637

Scope (from outer to inner):

file
function     void HDRConfigureCVars

Source code excerpt:

	}

	CVarDisplayOutputDevice->Set((int32)OutputDevice, ECVF_SetByDeviceProfile);
	CVarDisplayColorGamut->Set((int32)ColorGamut, ECVF_SetByDeviceProfile);

	float HDRDisplayMinLuminance = FMath::Pow(10, CVarHDRDisplayMinLuminanceLog10.GetValueOnAnyThread());
	ConfigureACESTonemapParams(GACESTonemapParams, HDRDisplayMinLuminance, CVarHDRDisplayMidLuminance.GetValueOnAnyThread(), CVarHDRDisplayMaxLuminance.GetValueOnAnyThread());
}