r.DefaultBackBufferPixelFormat

r.DefaultBackBufferPixelFormat

#Overview

name: r.DefaultBackBufferPixelFormat

The value of this variable can be defined or overridden in .ini config files. 2 .ini config files referencing this setting variable.

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

It is referenced in 24 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.DefaultBackBufferPixelFormat is to define the default pixel format for the back buffer in Unreal Engine’s rendering system. This setting variable is used to specify the color depth and format of the render target that the engine uses for final output to the display.

The associated variable CVarDefaultBackBufferPixelFormat is used to access the value of r.DefaultBackBufferPixelFormat throughout the engine code. It’s typically defined as a static const auto variable within functions that need to use this setting. This variable is used in the same way as r.DefaultBackBufferPixelFormat, but provides a convenient way to access the console variable’s value without having to look it up each time.

When using CVarDefaultBackBufferPixelFormat, developers should:

  1. Be aware that it’s accessing a global setting that could potentially be changed at runtime.
  2. Use the appropriate thread-safe getter method (GetValueOnGameThread, GetValueOnRenderThread, etc.) depending on the context where it’s being accessed.
  3. Consider caching the value if it’s being used frequently in performance-critical code, as looking up console variables can have some overhead.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseDeviceProfiles.ini:303, section: [IOS DeviceProfile]

Location: <Workspace>/Engine/Config/BaseDeviceProfiles.ini:804, section: [Android DeviceProfile]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneTextures.cpp:66

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarDefaultBackBufferPixelFormat(
	TEXT("r.DefaultBackBufferPixelFormat"),
	4,
	TEXT("Defines the default back buffer pixel format.\n")
	TEXT(" 0: 8bit RGBA\n")
	TEXT(" 1: 16bit RGBA\n")
	TEXT(" 2: Float RGB\n")
	TEXT(" 3: Float RGBA\n")

#Loc: <Workspace>/Engine/Plugins/Media/MediaIOFramework/Source/MediaIOCore/Private/FileMediaOutput.cpp:65

Scope (from outer to inner):

file
function     EPixelFormat UFileMediaOutput::GetRequestedPixelFormat

Source code excerpt:

	}

	static const auto CVarDefaultBackBufferPixelFormat = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.DefaultBackBufferPixelFormat"));
	EPixelFormat SceneTargetFormat = EDefaultBackBufferPixelFormat::Convert2PixelFormat(EDefaultBackBufferPixelFormat::FromInt(CVarDefaultBackBufferPixelFormat->GetValueOnAnyThread()));

	if (WriteOptions.Format == EDesiredImageFormat::EXR)
	{
		return SceneTargetFormat == EPixelFormat::PF_A2B10G10R10 ? PF_B8G8R8A8 : SceneTargetFormat;
	}

#Loc: <Workspace>/Engine/Plugins/Media/MediaIOFramework/Source/MediaIOCore/Private/MediaCaptureSources.h:72

Scope (from outer to inner):

file
namespace    UE::MediaCapture::Private
function     bool ValidateSceneViewport

Source code excerpt:

		}

		static const auto CVarDefaultBackBufferPixelFormat = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.DefaultBackBufferPixelFormat"));
		EPixelFormat SceneTargetFormat = EDefaultBackBufferPixelFormat::Convert2PixelFormat(EDefaultBackBufferPixelFormat::FromInt(CVarDefaultBackBufferPixelFormat->GetValueOnGameThread()));
		if (DesiredPixelFormat != SceneTargetFormat)
		{
			if (!UMediaCapture::GetSupportedRgbaSwizzleFormats().Contains(SceneTargetFormat) || !CaptureOptions.bConvertToDesiredPixelFormat)
			{
				UE_LOG(LogMediaIOCore, Error, TEXT("Can not %s the capture. The Render Target pixel format doesn't match with the requested pixel format. %sRenderTarget: %s MediaOutput: %s")

#Loc: <Workspace>/Engine/Plugins/Runtime/nDisplay/Source/SharedMemoryMedia/Private/SharedMemoryMediaOutput.cpp:27

Scope (from outer to inner):

file
function     EPixelFormat USharedMemoryMediaOutput::GetRequestedPixelFormat

Source code excerpt:

	// @todo is there a way to not have the MF render target allocated since we're not using it ?

	static const auto CVarDefaultBackBufferPixelFormat = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.DefaultBackBufferPixelFormat"));
	return EDefaultBackBufferPixelFormat::Convert2PixelFormat(EDefaultBackBufferPixelFormat::FromInt(CVarDefaultBackBufferPixelFormat->GetValueOnGameThread()));
}

EMediaCaptureConversionOperation USharedMemoryMediaOutput::GetConversionOperation(EMediaCaptureSourceType InSourceType) const
{
	return EMediaCaptureConversionOperation::CUSTOM;

#Loc: <Workspace>/Engine/Source/Runtime/D3D12RHI/Private/D3D12Viewport.cpp:810

Scope (from outer to inner):

file
function     EPixelFormat GetDefaultBackBufferPixelFormat

Source code excerpt:

EPixelFormat GetDefaultBackBufferPixelFormat()
{
	static const auto CVarDefaultBackBufferPixelFormat = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.DefaultBackBufferPixelFormat"));
	return EDefaultBackBufferPixelFormat::Convert2PixelFormat(EDefaultBackBufferPixelFormat::FromInt(CVarDefaultBackBufferPixelFormat->GetValueOnGameThread()));
}

/*==============================================================================
 *	The following RHI functions must be called from the main thread.
 *=============================================================================*/

#Loc: <Workspace>/Engine/Source/Runtime/D3D12RHI/Private/D3D12Viewport.cpp:846

Scope (from outer to inner):

file
function     void FD3D12DynamicRHI::RHIResizeViewport

Source code excerpt:

	if (PreferredPixelFormat == EPixelFormat::PF_Unknown)
	{
		static const auto CVarDefaultBackBufferPixelFormat = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.DefaultBackBufferPixelFormat"));
		PreferredPixelFormat = EDefaultBackBufferPixelFormat::Convert2PixelFormat(EDefaultBackBufferPixelFormat::FromInt(CVarDefaultBackBufferPixelFormat->GetValueOnGameThread()));
	}

	FD3D12Viewport* Viewport = FD3D12DynamicRHI::ResourceCast(ViewportRHI);
	Viewport->Resize(SizeX, SizeY, bIsFullscreen, PreferredPixelFormat);
}

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Slate/SceneViewport.cpp:2076

Scope (from outer to inner):

file
function     void FSceneViewport::InitRHI

Source code excerpt:

		TArray<FTexture2DRHIRef> BufferedSRVRHI;

		static const auto CVarDefaultBackBufferPixelFormat = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.DefaultBackBufferPixelFormat"));
		EPixelFormat SceneTargetFormat = EDefaultBackBufferPixelFormat::Convert2PixelFormat(EDefaultBackBufferPixelFormat::FromInt(CVarDefaultBackBufferPixelFormat->GetValueOnRenderThread()));
		SceneTargetFormat = RHIPreferredPixelFormatHint(SceneTargetFormat);

		if (bHDRViewport)
		{
			SceneTargetFormat = GRHIHDRDisplayOutputFormat;

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

Scope (from outer to inner):

file
function     FVulkanSwapChain::FVulkanSwapChain

Source code excerpt:

		if (InOutPixelFormat == PF_Unknown)
		{
			static const auto* CVarDefaultBackBufferPixelFormat = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.DefaultBackBufferPixelFormat"));
			InOutPixelFormat = CVarDefaultBackBufferPixelFormat ? EDefaultBackBufferPixelFormat::Convert2PixelFormat(EDefaultBackBufferPixelFormat::FromInt(CVarDefaultBackBufferPixelFormat->GetValueOnGameThread())) : PF_Unknown;
		}

		if (InOutPixelFormat != PF_Unknown)
		{
			bool bFound = false;

#Loc: <Workspace>/Engine/Source/Runtime/VulkanRHI/Private/VulkanViewport.cpp:1116

Scope (from outer to inner):

file
function     FViewportRHIRef FVulkanDynamicRHI::RHICreateViewport

Source code excerpt:

	if (PreferredPixelFormat == PF_Unknown)
	{
		static const auto* CVarDefaultBackBufferPixelFormat = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.DefaultBackBufferPixelFormat"));
		PreferredPixelFormat = EDefaultBackBufferPixelFormat::Convert2PixelFormat(EDefaultBackBufferPixelFormat::FromInt(CVarDefaultBackBufferPixelFormat->GetValueOnAnyThread()));
	}

	return new FVulkanViewport(Device, WindowHandle, SizeX, SizeY, bIsFullscreen, PreferredPixelFormat);
}

#Loc: <Workspace>/Engine/Source/Runtime/VulkanRHI/Private/VulkanViewport.cpp:1131

Scope (from outer to inner):

file
function     void FVulkanDynamicRHI::RHIResizeViewport

Source code excerpt:

	if (PreferredPixelFormat == PF_Unknown)
	{
		static const auto* CVarDefaultBackBufferPixelFormat = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.DefaultBackBufferPixelFormat"));
		PreferredPixelFormat = EDefaultBackBufferPixelFormat::Convert2PixelFormat(EDefaultBackBufferPixelFormat::FromInt(CVarDefaultBackBufferPixelFormat->GetValueOnAnyThread()));
	}

	if (Viewport->GetSizeXY() != FIntPoint(SizeX, SizeY) || Viewport->IsFullscreen() != bIsFullscreen)
	{
		FlushRenderingCommands();

#Loc: <Workspace>/Engine/Source/Runtime/Windows/D3D11RHI/Private/D3D11Viewport.cpp:667

Scope (from outer to inner):

file
function     FViewportRHIRef FD3D11DynamicRHI::RHICreateViewport

Source code excerpt:

	if (PreferredPixelFormat == EPixelFormat::PF_Unknown)
	{
		static const auto CVarDefaultBackBufferPixelFormat = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.DefaultBackBufferPixelFormat"));
		PreferredPixelFormat = EDefaultBackBufferPixelFormat::Convert2PixelFormat(EDefaultBackBufferPixelFormat::FromInt(CVarDefaultBackBufferPixelFormat->GetValueOnGameThread()));
	}

	return new FD3D11Viewport(this,(HWND)WindowHandle,SizeX,SizeY,bIsFullscreen,PreferredPixelFormat);
}

#Loc: <Workspace>/Engine/Source/Runtime/Windows/D3D11RHI/Private/D3D11Viewport.cpp:689

Scope (from outer to inner):

file
function     void FD3D11DynamicRHI::RHIResizeViewport

Source code excerpt:

	if (PreferredPixelFormat == EPixelFormat::PF_Unknown)
	{
		static const auto CVarDefaultBackBufferPixelFormat = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.DefaultBackBufferPixelFormat"));
		PreferredPixelFormat = EDefaultBackBufferPixelFormat::Convert2PixelFormat(EDefaultBackBufferPixelFormat::FromInt(CVarDefaultBackBufferPixelFormat->GetValueOnGameThread()));
	}

	FD3D11Viewport* Viewport = ResourceCast(ViewportRHI);
	Viewport->Resize(SizeX, SizeY, bIsFullscreen, PreferredPixelFormat);
}

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Plugins/Media/MediaIOFramework/Source/MediaIOCore/Private/FileMediaOutput.cpp:65

Scope (from outer to inner):

file
function     EPixelFormat UFileMediaOutput::GetRequestedPixelFormat

Source code excerpt:

	}

	static const auto CVarDefaultBackBufferPixelFormat = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.DefaultBackBufferPixelFormat"));
	EPixelFormat SceneTargetFormat = EDefaultBackBufferPixelFormat::Convert2PixelFormat(EDefaultBackBufferPixelFormat::FromInt(CVarDefaultBackBufferPixelFormat->GetValueOnAnyThread()));

	if (WriteOptions.Format == EDesiredImageFormat::EXR)
	{
		return SceneTargetFormat == EPixelFormat::PF_A2B10G10R10 ? PF_B8G8R8A8 : SceneTargetFormat;
	}
	else

#Loc: <Workspace>/Engine/Plugins/Media/MediaIOFramework/Source/MediaIOCore/Private/MediaCaptureSources.h:72

Scope (from outer to inner):

file
namespace    UE::MediaCapture::Private
function     bool ValidateSceneViewport

Source code excerpt:

		}

		static const auto CVarDefaultBackBufferPixelFormat = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.DefaultBackBufferPixelFormat"));
		EPixelFormat SceneTargetFormat = EDefaultBackBufferPixelFormat::Convert2PixelFormat(EDefaultBackBufferPixelFormat::FromInt(CVarDefaultBackBufferPixelFormat->GetValueOnGameThread()));
		if (DesiredPixelFormat != SceneTargetFormat)
		{
			if (!UMediaCapture::GetSupportedRgbaSwizzleFormats().Contains(SceneTargetFormat) || !CaptureOptions.bConvertToDesiredPixelFormat)
			{
				UE_LOG(LogMediaIOCore, Error, TEXT("Can not %s the capture. The Render Target pixel format doesn't match with the requested pixel format. %sRenderTarget: %s MediaOutput: %s")
					, bCurrentlyCapturing ? TEXT("continue") : TEXT("start")

#Loc: <Workspace>/Engine/Plugins/Runtime/nDisplay/Source/SharedMemoryMedia/Private/SharedMemoryMediaOutput.cpp:27

Scope (from outer to inner):

file
function     EPixelFormat USharedMemoryMediaOutput::GetRequestedPixelFormat

Source code excerpt:

	// @todo is there a way to not have the MF render target allocated since we're not using it ?

	static const auto CVarDefaultBackBufferPixelFormat = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.DefaultBackBufferPixelFormat"));
	return EDefaultBackBufferPixelFormat::Convert2PixelFormat(EDefaultBackBufferPixelFormat::FromInt(CVarDefaultBackBufferPixelFormat->GetValueOnGameThread()));
}

EMediaCaptureConversionOperation USharedMemoryMediaOutput::GetConversionOperation(EMediaCaptureSourceType InSourceType) const
{
	return EMediaCaptureConversionOperation::CUSTOM;
}

#Loc: <Workspace>/Engine/Source/Runtime/D3D12RHI/Private/D3D12Viewport.cpp:810

Scope (from outer to inner):

file
function     EPixelFormat GetDefaultBackBufferPixelFormat

Source code excerpt:

EPixelFormat GetDefaultBackBufferPixelFormat()
{
	static const auto CVarDefaultBackBufferPixelFormat = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.DefaultBackBufferPixelFormat"));
	return EDefaultBackBufferPixelFormat::Convert2PixelFormat(EDefaultBackBufferPixelFormat::FromInt(CVarDefaultBackBufferPixelFormat->GetValueOnGameThread()));
}

/*==============================================================================
 *	The following RHI functions must be called from the main thread.
 *=============================================================================*/
FViewportRHIRef FD3D12DynamicRHI::RHICreateViewport(void* WindowHandle, uint32 SizeX, uint32 SizeY, bool bIsFullscreen, EPixelFormat PreferredPixelFormat)

#Loc: <Workspace>/Engine/Source/Runtime/D3D12RHI/Private/D3D12Viewport.cpp:846

Scope (from outer to inner):

file
function     void FD3D12DynamicRHI::RHIResizeViewport

Source code excerpt:

	if (PreferredPixelFormat == EPixelFormat::PF_Unknown)
	{
		static const auto CVarDefaultBackBufferPixelFormat = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.DefaultBackBufferPixelFormat"));
		PreferredPixelFormat = EDefaultBackBufferPixelFormat::Convert2PixelFormat(EDefaultBackBufferPixelFormat::FromInt(CVarDefaultBackBufferPixelFormat->GetValueOnGameThread()));
	}

	FD3D12Viewport* Viewport = FD3D12DynamicRHI::ResourceCast(ViewportRHI);
	Viewport->Resize(SizeX, SizeY, bIsFullscreen, PreferredPixelFormat);
}

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Slate/SceneViewport.cpp:2076

Scope (from outer to inner):

file
function     void FSceneViewport::InitRHI

Source code excerpt:

		TArray<FTexture2DRHIRef> BufferedSRVRHI;

		static const auto CVarDefaultBackBufferPixelFormat = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.DefaultBackBufferPixelFormat"));
		EPixelFormat SceneTargetFormat = EDefaultBackBufferPixelFormat::Convert2PixelFormat(EDefaultBackBufferPixelFormat::FromInt(CVarDefaultBackBufferPixelFormat->GetValueOnRenderThread()));
		SceneTargetFormat = RHIPreferredPixelFormatHint(SceneTargetFormat);

		if (bHDRViewport)
		{
			SceneTargetFormat = GRHIHDRDisplayOutputFormat;
		}

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneTextures.cpp:65

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarDefaultBackBufferPixelFormat(
	TEXT("r.DefaultBackBufferPixelFormat"),
	4,
	TEXT("Defines the default back buffer pixel format.\n")
	TEXT(" 0: 8bit RGBA\n")
	TEXT(" 1: 16bit RGBA\n")
	TEXT(" 2: Float RGB\n")

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

Scope (from outer to inner):

file
function     FVulkanSwapChain::FVulkanSwapChain

Source code excerpt:

		if (InOutPixelFormat == PF_Unknown)
		{
			static const auto* CVarDefaultBackBufferPixelFormat = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.DefaultBackBufferPixelFormat"));
			InOutPixelFormat = CVarDefaultBackBufferPixelFormat ? EDefaultBackBufferPixelFormat::Convert2PixelFormat(EDefaultBackBufferPixelFormat::FromInt(CVarDefaultBackBufferPixelFormat->GetValueOnGameThread())) : PF_Unknown;
		}

		if (InOutPixelFormat != PF_Unknown)
		{
			bool bFound = false;
			if (GPixelFormats[InOutPixelFormat].Supported)

#Loc: <Workspace>/Engine/Source/Runtime/VulkanRHI/Private/VulkanViewport.cpp:1116

Scope (from outer to inner):

file
function     FViewportRHIRef FVulkanDynamicRHI::RHICreateViewport

Source code excerpt:

	if (PreferredPixelFormat == PF_Unknown)
	{
		static const auto* CVarDefaultBackBufferPixelFormat = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.DefaultBackBufferPixelFormat"));
		PreferredPixelFormat = EDefaultBackBufferPixelFormat::Convert2PixelFormat(EDefaultBackBufferPixelFormat::FromInt(CVarDefaultBackBufferPixelFormat->GetValueOnAnyThread()));
	}

	return new FVulkanViewport(Device, WindowHandle, SizeX, SizeY, bIsFullscreen, PreferredPixelFormat);
}

void FVulkanDynamicRHI::RHIResizeViewport(FRHIViewport* ViewportRHI, uint32 SizeX, uint32 SizeY, bool bIsFullscreen, EPixelFormat PreferredPixelFormat)

#Loc: <Workspace>/Engine/Source/Runtime/VulkanRHI/Private/VulkanViewport.cpp:1131

Scope (from outer to inner):

file
function     void FVulkanDynamicRHI::RHIResizeViewport

Source code excerpt:

	if (PreferredPixelFormat == PF_Unknown)
	{
		static const auto* CVarDefaultBackBufferPixelFormat = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.DefaultBackBufferPixelFormat"));
		PreferredPixelFormat = EDefaultBackBufferPixelFormat::Convert2PixelFormat(EDefaultBackBufferPixelFormat::FromInt(CVarDefaultBackBufferPixelFormat->GetValueOnAnyThread()));
	}

	if (Viewport->GetSizeXY() != FIntPoint(SizeX, SizeY) || Viewport->IsFullscreen() != bIsFullscreen)
	{
		FlushRenderingCommands();

#Loc: <Workspace>/Engine/Source/Runtime/Windows/D3D11RHI/Private/D3D11Viewport.cpp:667

Scope (from outer to inner):

file
function     FViewportRHIRef FD3D11DynamicRHI::RHICreateViewport

Source code excerpt:

	if (PreferredPixelFormat == EPixelFormat::PF_Unknown)
	{
		static const auto CVarDefaultBackBufferPixelFormat = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.DefaultBackBufferPixelFormat"));
		PreferredPixelFormat = EDefaultBackBufferPixelFormat::Convert2PixelFormat(EDefaultBackBufferPixelFormat::FromInt(CVarDefaultBackBufferPixelFormat->GetValueOnGameThread()));
	}

	return new FD3D11Viewport(this,(HWND)WindowHandle,SizeX,SizeY,bIsFullscreen,PreferredPixelFormat);
}

void FD3D11DynamicRHI::RHIResizeViewport(FRHIViewport* ViewportRHI,uint32 SizeX,uint32 SizeY,bool bIsFullscreen)

#Loc: <Workspace>/Engine/Source/Runtime/Windows/D3D11RHI/Private/D3D11Viewport.cpp:689

Scope (from outer to inner):

file
function     void FD3D11DynamicRHI::RHIResizeViewport

Source code excerpt:

	if (PreferredPixelFormat == EPixelFormat::PF_Unknown)
	{
		static const auto CVarDefaultBackBufferPixelFormat = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.DefaultBackBufferPixelFormat"));
		PreferredPixelFormat = EDefaultBackBufferPixelFormat::Convert2PixelFormat(EDefaultBackBufferPixelFormat::FromInt(CVarDefaultBackBufferPixelFormat->GetValueOnGameThread()));
	}

	FD3D11Viewport* Viewport = ResourceCast(ViewportRHI);
	Viewport->Resize(SizeX, SizeY, bIsFullscreen, PreferredPixelFormat);
}