// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "CoreMinimal.h" #include "Common/TargetPlatformControlsBase.h" #include "AnalyticsEventAttribute.h" #if PLATFORM_WINDOWS #include "LocalPcTargetDevice.h" #endif #if WITH_ENGINE #include "TextureResource.h" #endif #include "SteamDeck/SteamDeckDevice.h" #include "GenericWindowsTargetPlatformSettings.h" #define LOCTEXT_NAMESPACE "TGenericWindowsTargetPlatformControls" /** * Template for Windows target platforms controls */ #if PLATFORM_WINDOWS template #else template #endif class TGenericWindowsTargetPlatformControls : public TTargetPlatformControlsBase { public: typedef TTargetPlatformControlsBase TSuper; typedef TTargetPlatformSettingsBase TSuperSettings; /** O * Default constructor. */ TGenericWindowsTargetPlatformControls(ITargetPlatformSettings* TargetPlatformSettings) : TSuper(TargetPlatformSettings) { #if PLATFORM_WINDOWS // only add local device if actually running on Windows LocalDevice = MakeShareable(new TTargetDevice(*this)); // quick solution to not having WinGDK steamdeck devices if (this->PlatformName().StartsWith(TEXT("Windows"))) { // Check if we have any SteamDeck devices around SteamDevices = TSteamDeckDevice::DiscoverDevices(*this, TEXT("Proton")); } #endif GenericWindowsTargetPlatformSettings = (TSuperSettings*)TargetPlatformSettings; } public: //~ Begin ITargetPlatform Interface virtual void EnableDeviceCheck(bool OnOff) override {} virtual void GetAllDevices( TArray& OutDevices ) const override { OutDevices.Reset(); if (LocalDevice.IsValid()) { OutDevices.Add(LocalDevice); } for (const ITargetDevicePtr& SteamDeck : SteamDevices) { if (SteamDeck.IsValid()) { OutDevices.Add(SteamDeck); } } } virtual bool GenerateStreamingInstallManifest(const TMultiMap& PakchunkMap, const TSet& PakchunkIndicesInUse) const override { return true; } virtual ITargetDevicePtr GetDefaultDevice( ) const override { if (LocalDevice.IsValid()) { return LocalDevice; } return nullptr; } virtual ITargetDevicePtr GetDevice( const FTargetDeviceId& DeviceId ) { if (LocalDevice.IsValid() && (DeviceId == LocalDevice->GetId())) { return LocalDevice; } for (const ITargetDevicePtr& SteamDeck : SteamDevices) { if (SteamDeck.IsValid() && DeviceId == SteamDeck->GetId()) { return SteamDeck; } } return nullptr; } virtual bool IsRunningPlatform( ) const override { // Must be Windows platform as editor for this to be considered a running platform return PLATFORM_WINDOWS && !UE_SERVER && !UE_GAME && WITH_EDITOR && TProperties::HasEditorOnlyData(); } virtual void GetShaderCompilerDependencies(TArray& OutDependencies) const override { FTargetPlatformControlsBase::AddDependencySCArrayHelper(OutDependencies, TEXT("Binaries/ThirdParty/Windows/DirectX/x64/d3dcompiler_47.dll")); FTargetPlatformControlsBase::AddDependencySCArrayHelper(OutDependencies, TEXT("Binaries/ThirdParty/ShaderConductor/Win64/ShaderConductor.dll")); FTargetPlatformControlsBase::AddDependencySCArrayHelper(OutDependencies, TEXT("Binaries/ThirdParty/ShaderConductor/Win64/dxcompiler.dll")); FTargetPlatformControlsBase::AddDependencySCArrayHelper(OutDependencies, TEXT("Binaries/ThirdParty/ShaderConductor/Win64/dxil.dll")); } virtual void GetBuildProjectSettingKeys(FString& OutSection, TArray& InBoolKeys, TArray& InIntKeys, TArray& InStringKeys) const override { OutSection = TEXT("/Script/WindowsTargetPlatform.WindowsTargetSettings"); InStringKeys.Add(TEXT("MinimumOSVersion")); } virtual void GetPlatformSpecificProjectAnalytics( TArray& AnalyticsParamArray ) const override { TSuper::GetPlatformSpecificProjectAnalytics(AnalyticsParamArray); AppendAnalyticsEventAttributeArray(AnalyticsParamArray, TEXT("UsesRayTracing"), GenericWindowsTargetPlatformSettings->UsesRayTracing() ); TSuper::AppendAnalyticsEventConfigString(AnalyticsParamArray, TEXT("/Script/WindowsTargetPlatform.WindowsTargetSettings"), TEXT("DefaultGraphicsRHI"), GEngineIni); 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 GetTextureFormats( const UTexture* InTexture, TArray< TArray >& OutFormats) const override { if (!TProperties::IsServerOnly()) { GetDefaultTextureFormatNamePerLayer(OutFormats.AddDefaulted_GetRef(), GenericWindowsTargetPlatformSettings, this, InTexture, true, 4, true); } } virtual void GetAllTextureFormats(TArray& OutFormats) const override { if (!TProperties::IsServerOnly()) { GetAllDefaultTextureFormats(GenericWindowsTargetPlatformSettings, OutFormats); } } #endif //WITH_ENGINE virtual bool SupportsVariants() const override { return true; } virtual float GetVariantPriority() const override { return TProperties::GetVariantPriority(); } //~ End ITargetPlatform Interface private: // Holds the local device. ITargetDevicePtr LocalDevice; TArray SteamDevices; TSuperSettings* GenericWindowsTargetPlatformSettings; }; #undef LOCTEXT_NAMESPACE