D3D11TargetedShaderFormats

D3D11TargetedShaderFormats

#Overview

name: D3D11TargetedShaderFormats

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

It is referenced in 11 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of D3D11TargetedShaderFormats is to specify the shader formats targeted for Direct3D 11 rendering on Windows platforms. This setting is part of the rendering configuration for Unreal Engine 5.

D3D11TargetedShaderFormats is primarily used by the Windows target platform module and the rendering subsystem. It is referenced in the WindowsTargetPlatform, DetailCustomizations, and RHI (Rendering Hardware Interface) modules.

The value of this variable is typically set in the project’s configuration files, specifically in the Engine.ini file under the “/Script/WindowsTargetPlatform.WindowsTargetSettings” section.

This variable interacts with other similar variables such as D3D12TargetedShaderFormats and VulkanTargetedShaderFormats. Together, they define the targeted shader formats for different graphics APIs on Windows.

Developers should be aware that:

  1. Changes to this variable require a restart of the engine (as indicated by the ConfigRestartRequired meta tag).
  2. It affects the shader compilation process for Windows platforms.
  3. It’s part of the project’s analytics data, which helps in understanding the project’s configuration.

Best practices when using this variable include:

  1. Carefully selecting the appropriate shader formats based on the project’s requirements and target hardware.
  2. Keeping it in sync with the project’s minimum supported D3D11 feature level.
  3. Considering the performance implications of including multiple shader formats.
  4. Regularly reviewing and updating the targeted formats as new hardware capabilities become available.
  5. Coordinating changes to this variable with the overall rendering and platform strategy of the project.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEngine.ini:3162, section: [/Script/WindowsTargetPlatform.WindowsTargetSettings]

Location: <Workspace>/Projects/Lyra/Config/DefaultEngine.ini:298, section: [/Script/WindowsTargetPlatform.WindowsTargetSettings]

Location: <Workspace>/Projects/Lyra/Config/DefaultEngine.ini:299, section: [/Script/WindowsTargetPlatform.WindowsTargetSettings]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Developer/Windows/WindowsTargetPlatform/Classes/WindowsTargetSettings.h:55

Scope (from outer to inner):

file
class        class UWindowsTargetSettings : public UObject

Source code excerpt:


	UPROPERTY(EditAnywhere, config, Category = "Rendering", Meta = (ConfigRestartRequired = true))
	TArray<FString> D3D11TargetedShaderFormats;

	UPROPERTY(EditAnywhere, config, Category = "Rendering", Meta = (ConfigRestartRequired = true))
	TArray<FString> VulkanTargetedShaderFormats;

	/** The compiler version to use for this project. May be different to the chosen IDE. */
	UPROPERTY(EditAnywhere, config, Category = "Toolchain", Meta = (DisplayName = "Compiler Version"))

#Loc: <Workspace>/Engine/Source/Developer/Windows/WindowsTargetPlatform/Private/WindowsTargetPlatformClasses.cpp:56

Scope (from outer to inner):

file
function     void UWindowsTargetSettings::PostInitProperties

Source code excerpt:

	{
		AddToShaderFormatList(D3D12TargetedShaderFormats, TargetedRHIs_DEPRECATED, &FilterShaderPlatform_D3D12);
		AddToShaderFormatList(D3D11TargetedShaderFormats, TargetedRHIs_DEPRECATED, &FilterShaderPlatform_D3D11);
		AddToShaderFormatList(VulkanTargetedShaderFormats, TargetedRHIs_DEPRECATED, &FilterShaderPlatform_Vulkan);

		TargetedRHIs_DEPRECATED.Empty();
	}
}

#Loc: <Workspace>/Engine/Source/Developer/Windows/WindowsTargetPlatform/Public/GenericWindowsTargetPlatform.h:310

Scope (from outer to inner):

file
class        class TGenericWindowsTargetPlatform : public TTargetPlatformBase<TProperties>
function     virtual void GetPlatformSpecificProjectAnalytics

Source code excerpt:


		TSuper::AppendAnalyticsEventConfigArray(AnalyticsParamArray, TEXT("/Script/WindowsTargetPlatform.WindowsTargetSettings"), TEXT("D3D12TargetedShaderFormats"), GEngineIni);
		TSuper::AppendAnalyticsEventConfigArray(AnalyticsParamArray, TEXT("/Script/WindowsTargetPlatform.WindowsTargetSettings"), TEXT("D3D11TargetedShaderFormats"), GEngineIni);
		TSuper::AppendAnalyticsEventConfigArray(AnalyticsParamArray, TEXT("/Script/WindowsTargetPlatform.WindowsTargetSettings"), TEXT("VulkanTargetedShaderFormats"), GEngineIni);
		TSuper::AppendAnalyticsEventConfigArray(AnalyticsParamArray, TEXT("/Script/WindowsTargetPlatform.WindowsTargetSettings"), TEXT("TargetedRHIs"), GEngineIni, TEXT("TargetedRHIs_Deprecated") );
	}

#if WITH_ENGINE
	virtual void GetReflectionCaptureFormats(TArray<FName>& OutFormats) const override

#Loc: <Workspace>/Engine/Source/Editor/DetailCustomizations/Private/WindowsTargetSettingsDetails.cpp:205

Scope (from outer to inner):

file
function     void FWindowsTargetSettingsDetails::CustomizeDetails

Source code excerpt:

	D3D12TargetShaderFormatsDetails->CreateTargetShaderFormatsPropertyView(TargetPlatform, &GetFriendlyNameForWindowsShaderPlatformCheckbox, &FilterShaderPlatform_D3D12, ECategoryPriority::Important);

	D3D11TargetShaderFormatsDetails = MakeShareable(new FShaderFormatsPropertyDetails(&DetailBuilder, TEXT("D3D11TargetedShaderFormats"), TEXT("D3D11 Targeted Shader Formats")));
	D3D11TargetShaderFormatsDetails->CreateTargetShaderFormatsPropertyView(TargetPlatform, &GetFriendlyNameForWindowsShaderPlatformCheckbox, &FilterShaderPlatform_D3D11, ECategoryPriority::Important);

	VulkanTargetShaderFormatsDetails = MakeShareable(new FShaderFormatsPropertyDetails(&DetailBuilder, TEXT("VulkanTargetedShaderFormats"), TEXT("Vulkan Targeted Shader Formats")));
	VulkanTargetShaderFormatsDetails->CreateTargetShaderFormatsPropertyView(TargetPlatform, &GetFriendlyNameForWindowsShaderPlatformCheckbox, &FilterShaderPlatform_Vulkan, ECategoryPriority::Important);

	// Next add the splash image customization

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/RendererSettings.cpp:412

Scope (from outer to inner):

file
function     void URendererSettings::CheckForMissingShaderModels

Source code excerpt:

		};

		TArray<FString> D3D11TargetedShaderFormats;
		TArray<FString> D3D12TargetedShaderFormats;
		TArray<FString> WindowsVulkanTargetedShaderFormats;
		TArray<FString> WindowsTargetedRHIs;
		TArray<FString> LinuxVulkanTargetedShaderFormats;
		TArray<FString> LinuxTargetedRHIs;

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/RendererSettings.cpp:432

Scope (from outer to inner):

file
function     void URendererSettings::CheckForMissingShaderModels

Source code excerpt:

			else
			{
				GConfig->GetArray(TEXT("/Script/WindowsTargetPlatform.WindowsTargetSettings"), TEXT("D3D11TargetedShaderFormats"), D3D11TargetedShaderFormats, GEngineIni);
				GConfig->GetArray(TEXT("/Script/WindowsTargetPlatform.WindowsTargetSettings"), TEXT("D3D12TargetedShaderFormats"), D3D12TargetedShaderFormats, GEngineIni);
				CopySM6Format(TEXT("PCD3D_SM6"), WindowsTargetedRHIs, D3D12TargetedShaderFormats);
			}
		}
#elif PLATFORM_LINUX
		// Gather all Linux shader format settings

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/RendererSettings.cpp:446

Scope (from outer to inner):

file
function     void URendererSettings::CheckForMissingShaderModels

Source code excerpt:

#endif

		const bool bProjectUsesD3D = (D3D11TargetedShaderFormats.Num() + D3D12TargetedShaderFormats.Num()) > 0;
		const bool bProjectMissingD3DSM6 = (bProjectUsesD3D && !D3D12TargetedShaderFormats.Contains(TEXT("PCD3D_SM6")));

		const bool bProjectUsesWindowsVulkan = (WindowsVulkanTargetedShaderFormats.Num() > 0);
		const bool bProjectMissingWindowsVulkanSM6 = (bProjectUsesWindowsVulkan && !WindowsVulkanTargetedShaderFormats.Contains(TEXT("SF_VULKAN_SM6")));

		const bool bProjectUsesLinuxVulkan = (LinuxTargetedRHIs.Num() > 0) || (LinuxVulkanTargetedShaderFormats.Num() > 0);

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/StaticMesh.cpp:6725

Scope (from outer to inner):

file
function     void UStaticMesh::CheckForMissingShaderModels

Source code excerpt:

		};

		TArray<FString> D3D11TargetedShaderFormats;
		TArray<FString> D3D12TargetedShaderFormats;
		TArray<FString> WindowsVulkanTargetedShaderFormats;
		TArray<FString> WindowsTargetedRHIs;
		TArray<FString> LinuxVulkanTargetedShaderFormats;
		TArray<FString> LinuxTargetedRHIs;

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/StaticMesh.cpp:6745

Scope (from outer to inner):

file
function     void UStaticMesh::CheckForMissingShaderModels

Source code excerpt:

			else
			{
				GConfig->GetArray(TEXT("/Script/WindowsTargetPlatform.WindowsTargetSettings"), TEXT("D3D11TargetedShaderFormats"), D3D11TargetedShaderFormats, GEngineIni);
				GConfig->GetArray(TEXT("/Script/WindowsTargetPlatform.WindowsTargetSettings"), TEXT("D3D12TargetedShaderFormats"), D3D12TargetedShaderFormats, GEngineIni);
				CopySM6Format(TEXT("PCD3D_SM6"), WindowsTargetedRHIs, D3D12TargetedShaderFormats);
			}
		}
#elif PLATFORM_LINUX
		// Gather all Linux shader format settings

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/StaticMesh.cpp:6759

Scope (from outer to inner):

file
function     void UStaticMesh::CheckForMissingShaderModels

Source code excerpt:

#endif

		const bool bProjectUsesD3D = (D3D11TargetedShaderFormats.Num() + D3D12TargetedShaderFormats.Num()) > 0;
		const bool bProjectMissingD3DSM6 = (bProjectUsesD3D && !D3D12TargetedShaderFormats.Contains(TEXT("PCD3D_SM6")));

		const bool bProjectUsesWindowsVulkan = (WindowsVulkanTargetedShaderFormats.Num() > 0);
		const bool bProjectMissingWindowsVulkanSM6 = (bProjectUsesWindowsVulkan && !WindowsVulkanTargetedShaderFormats.Contains(TEXT("SF_VULKAN_SM6")));

		const bool bProjectUsesLinuxVulkan = (LinuxTargetedRHIs.Num() > 0) || (LinuxVulkanTargetedShaderFormats.Num() > 0);

#Loc: <Workspace>/Engine/Source/Runtime/RHI/Private/Windows/WindowsDynamicRHI.cpp:344

Scope (from outer to inner):

file
function     FParsedWindowsDynamicRHIConfig ParseWindowsDynamicRHIConfig

Source code excerpt:

	Config.DefaultRHI = ParseDefaultWindowsRHI();

	Config.RHIConfigs[(int32)EWindowsRHI::D3D11]  = ParseWindowsRHIConfig(TEXT("D3D11TargetedShaderFormats"));
	Config.RHIConfigs[(int32)EWindowsRHI::D3D12]  = ParseWindowsRHIConfig(TEXT("D3D12TargetedShaderFormats"));
	Config.RHIConfigs[(int32)EWindowsRHI::Vulkan] = ParseWindowsRHIConfig(TEXT("VulkanTargetedShaderFormats"));

	// Only add OpenGL support to non-client programs.
	if (!FPlatformProperties::RequiresCookedData())
	{