bIsConsole

bIsConsole

#Overview

name: bIsConsole

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

It is referenced in 8 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of bIsConsole is to identify whether the current platform is a console or not. This variable is used in various parts of the Unreal Engine codebase to adjust behavior or functionality based on whether the game is running on a console platform or not.

This setting variable is primarily used in the following Unreal Engine subsystems and modules:

  1. Material Editor
  2. Game Mode
  3. Rendering Hardware Interface (RHI)
  4. Renderer

The value of this variable is typically set based on the platform-specific information. In the RHI module, it’s parsed from a configuration section using the FGenericDataDrivenShaderPlatformInfo class.

bIsConsole interacts with other platform-specific variables such as bIsPC, bIsMetalMRT, and bIsAndroidOpenGLES. It’s often used in conjunction with these variables to determine the appropriate behavior for different platforms.

Developers should be aware that:

  1. This variable affects shader compilation and platform-specific optimizations.
  2. It’s used to determine how to handle network addresses and unique player IDs in multiplayer scenarios.
  3. It influences how certain rendering features, like Diaphragm Depth of Field, are implemented.

Best practices when using this variable include:

  1. Always use the provided accessor methods (like FDataDrivenShaderPlatformInfo::GetIsConsole()) instead of directly accessing the variable.
  2. Be cautious when making platform-specific optimizations based on this variable, as it may affect cross-platform compatibility.
  3. Consider the implications on networking and player identification when using this variable in multiplayer code.
  4. Use it in conjunction with other platform-specific variables to create a complete picture of the target platform’s capabilities.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/VulkanPC/DataDrivenPlatformInfo.ini:19, section: [ShaderPlatform VULKAN_SM5]

Location: <Workspace>/Engine/Config/VulkanPC/DataDrivenPlatformInfo.ini:150, section: [ShaderPlatform VULKAN_SM6]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Editor/MaterialEditor/Private/MaterialStats.cpp:626

Scope (from outer to inner):

file
function     void FMaterialStats::BuildShaderPlatformDB

Source code excerpt:

		if (FDataDrivenShaderPlatformInfo::IsValid(ShaderPlatform))
		{
			bool bIsConsole = FDataDrivenShaderPlatformInfo::GetIsConsole(ShaderPlatform);

			const FName ShaderFormat = LegacyShaderPlatformToShaderFormat(ShaderPlatform);
			if (TPM.FindShaderFormat(ShaderFormat) != nullptr)
			{
				const FName PlatformName = ShaderPlatformToPlatformName(ShaderPlatform);
				AddShaderPlatform(bIsConsole ? EPlatformCategoryType::Console : EPlatformCategoryType::Desktop, ShaderPlatform, PlatformName, true, PlatformName.ToString());
			}
		}
	}

}

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GameMode.cpp:618

Scope (from outer to inner):

file
function     void AGameMode::AddInactivePlayer

Source code excerpt:


			// On console, we have to check the unique net id as network address isn't valid
			const bool bIsConsole = !PLATFORM_DESKTOP;
			// Assume valid unique ids means comparison should be via this method
			const bool bHasValidUniqueId = NewPlayerState->GetUniqueId().IsValid();
			// Don't accidentally compare empty network addresses (already issue with two clients on same machine during development)
			const bool bHasValidNetworkAddress = !NewPlayerState->SavedNetworkAddress.IsEmpty();
			const bool bUseUniqueIdCheck = bIsConsole || bHasValidUniqueId;
			
			// make sure no duplicates
			for (int32 Idx = 0; Idx < InactivePlayerArray.Num(); ++Idx)
			{
				APlayerState* const CurrentPlayerState = InactivePlayerArray[Idx];
				if (!IsValid(CurrentPlayerState))

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GameMode.cpp:678

Scope (from outer to inner):

file
function     bool AGameMode::FindInactivePlayer

Source code excerpt:


	// On console, we have to check the unique net id as network address isn't valid
	const bool bIsConsole = !PLATFORM_DESKTOP;
	// Assume valid unique ids means comparison should be via this method
	const bool bHasValidUniqueId = PC->PlayerState->GetUniqueId().IsValid();
	// Don't accidentally compare empty network addresses (already issue with two clients on same machine during development)
	const bool bHasValidNetworkAddress = !PC->PlayerState->SavedNetworkAddress.IsEmpty();
	const bool bUseUniqueIdCheck = bIsConsole || bHasValidUniqueId;

	const FString NewNetworkAddress = PC->PlayerState->SavedNetworkAddress;
	const FString NewName = PC->PlayerState->GetPlayerName();
	for (int32 i=0; i < InactivePlayerArray.Num(); i++)
	{
		APlayerState* CurrentPlayerState = InactivePlayerArray[i];

#Loc: <Workspace>/Engine/Source/Runtime/RHI/Private/DataDrivenShaderPlatformInfo.cpp:201

Scope (from outer to inner):

file
function     void FGenericDataDrivenShaderPlatformInfo::ParseDataDrivenShaderInfo

Source code excerpt:

	GET_SECTION_BOOL_HELPER(bIsMetalMRT);
	GET_SECTION_BOOL_HELPER(bIsPC);
	GET_SECTION_BOOL_HELPER(bIsConsole);
	GET_SECTION_BOOL_HELPER(bIsAndroidOpenGLES);
	GET_SECTION_BOOL_HELPER(bSupportsDebugViewShaders);
	GET_SECTION_BOOL_HELPER(bSupportsMobileMultiView);
	GET_SECTION_BOOL_HELPER(bSupportsArrayTextureCompression);
	GET_SECTION_BOOL_HELPER(bSupportsDistanceFields);
	GET_SECTION_BOOL_HELPER(bSupportsDiaphragmDOF);

#Loc: <Workspace>/Engine/Source/Runtime/RHI/Private/DataDrivenShaderPlatformInfo.cpp:441

Scope (from outer to inner):

file
function     void FGenericDataDrivenShaderPlatformInfo::UpdatePreviewPlatforms

Source code excerpt:

				PREVIEW_FORCE_SETTING(bIsPC, true);
				PREVIEW_FORCE_SETTING(bSupportsDebugViewShaders, true);
				PREVIEW_FORCE_SETTING(bIsConsole, false);

				// Support for stereo features requires extra consideration. The editor may not use the same technique as the preview platform,
				// particularly MobileMultiView may be substituted by a fallback path. In order to avoid inundating real mobile platforms
				// with the properties needed for the desktop MMV fallback path, override them here with the editor ones to make MMV preview possible
				if (PreviewInfo.bSupportsMobileMultiView && !RuntimeInfo.bSupportsMobileMultiView)
				{

#Loc: <Workspace>/Engine/Source/Runtime/RHI/Public/DataDrivenShaderPlatformInfo.h:26

Scope (from outer to inner):

file
class        class FGenericDataDrivenShaderPlatformInfo

Source code excerpt:

	uint32 bIsMetalMRT : 1;
	uint32 bIsPC : 1;
	uint32 bIsConsole : 1;
	uint32 bIsAndroidOpenGLES : 1;

	uint32 bSupportsDebugViewShaders : 1;
	uint32 bSupportsMobileMultiView : 1;
	uint32 bSupportsArrayTextureCompression : 1;
	uint32 bSupportsDistanceFields : 1; // used for DFShadows and DFAO - since they had the same checks

#Loc: <Workspace>/Engine/Source/Runtime/RHI/Public/DataDrivenShaderPlatformInfo.h:221

Scope (from outer to inner):

file
class        class FGenericDataDrivenShaderPlatformInfo
function     static const bool GetIsConsole

Source code excerpt:

	{
		check(IsValid(Platform));
		return Infos[Platform].bIsConsole;
	}

	static FORCEINLINE_DEBUGGABLE const bool GetIsAndroidOpenGLES(const FStaticShaderPlatform Platform)
	{
		check(IsValid(Platform));
		return Infos[Platform].bIsAndroidOpenGLES;

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/DiaphragmDOF.cpp:430

Scope (from outer to inner):

file
namespace    anonymous
class        class FDiaphragmDOFShader : public FGlobalShader
function     static void ModifyCompilationEnvironment

Source code excerpt:


		// If on console, don't compile any dynamic CoC offset to avoid performance differences
		const bool bIsConsole = FDataDrivenShaderPlatformInfo::GetIsConsole(Parameters.Platform);
		OutEnvironment.SetDefine(TEXT("WITH_DYNAMIC_COC_OFFSET"), bIsConsole ? 0 : 1);
	}

	FDiaphragmDOFShader() {}
	FDiaphragmDOFShader(const ShaderMetaType::CompiledShaderInitializerType& Initializer)
		: FGlobalShader(Initializer)
	{ }