Files
UnrealEngineUWP/Engine/Source/Developer/Mac/MacTargetPlatform/Private/MacTargetPlatformModule.cpp
Mark Satterthwaite ae9401146d Remove all support for Metal prior to Metal 1.2 on iOS/tvOS and Metal 2.0 on macOS. This permits some fairly radical simplifications and removal of a number of workarounds.
- All Buffer<>/RWBuffer<> objects are now bound as texture2d or texture_buffer, unless they are 3-component, in which case they are bound as raw T* buffer pointers.
- 3-component Buffer/RWBuffer objects should now work - Metal needed to use packed_* types internally as normal 3-component types in Metal are the same size as 4-component types which is different to HLSL. This is untested as we have no such example.
- Texture Gather/GatherCompare operations have been fixed and should now work.
- Remove all the TypedBufferFormat function-constant specialisation infrastructure and metadata as it is no longer necessary.
- Remove all the raw-conversion for 1, 2 and 4 component vector types as it is no longer required.
- Fixed input qualifiers (centroid, linear, etc.) for Fragment shader inputs - they should now work.
- Remove a bunch of Metal specific shader changes due to buffer type casting and swizzling that will now just work.
- Use the BGRA vertex format for FColor on Metal when available (everywhere but iOS/tvOS 10 using Metal 1.2).
- Simplify ShouldCompilePermutation & similar functions now that we have fewer versions to support.

#rb none
#jira N/A

[CL 4729845 by Mark Satterthwaite in Dev-Rendering branch]
2019-01-15 18:01:31 -05:00

129 lines
3.1 KiB
C++

// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#include "CoreMinimal.h"
#include "GenericMacTargetPlatform.h"
#include "Modules/ModuleManager.h"
#include "ISettingsModule.h"
#include "Interfaces/ITargetPlatformModule.h"
#include "Modules/ModuleManager.h"
#include "MacTargetSettings.h"
#include "UObject/Package.h"
#include "UObject/WeakObjectPtr.h"
#define LOCTEXT_NAMESPACE "FMacTargetPlatformModule"
/**
* Holds the target platform singleton.
*/
static ITargetPlatform* Singleton = NULL;
/**
* Module for Mac as a target platform
*/
class FMacTargetPlatformModule
: public ITargetPlatformModule
{
public:
/**
* Destructor.
*/
~FMacTargetPlatformModule()
{
Singleton = NULL;
}
public:
// Begin ITargetPlatformModule interface
virtual ITargetPlatform* GetTargetPlatform() override
{
if (Singleton == NULL)
{
Singleton = new TGenericMacTargetPlatform<true, false, false>();
}
return Singleton;
}
// End ITargetPlatformModule interface
public:
// Begin IModuleInterface interface
virtual void StartupModule() override
{
TargetSettings = NewObject<UMacTargetSettings>(GetTransientPackage(), "MacTargetSettings", RF_Standalone);
// We need to manually load the config properties here, as this module is loaded before the UObject system is setup to do this
GConfig->GetArray(TEXT("/Script/MacTargetPlatform.MacTargetSettings"), TEXT("TargetedRHIs"), TargetSettings->TargetedRHIs, GEngineIni);
int32 Value = 1;
GConfig->GetInt(TEXT("/Script/MacTargetPlatform.MacTargetSettings"), TEXT("MaxShaderLanguageVersion"), Value, GEngineIni);
TargetSettings->MaxShaderLanguageVersion = FMath::Max(Value, 3);
if (!GConfig->GetBool(TEXT("/Script/MacTargetPlatform.MacTargetSettings"), TEXT("UseFastIntrinsics"), TargetSettings->UseFastIntrinsics, GEngineIni))
{
TargetSettings->UseFastIntrinsics = false;
}
if (!GConfig->GetBool(TEXT("/Script/MacTargetPlatform.MacTargetSettings"), TEXT("EnableMathOptimisations"), TargetSettings->EnableMathOptimisations, GEngineIni))
{
TargetSettings->EnableMathOptimisations = true;
}
TargetSettings->AddToRoot();
ISettingsModule* SettingsModule = FModuleManager::GetModulePtr<ISettingsModule>("Settings");
if (SettingsModule != nullptr)
{
SettingsModule->RegisterSettings("Project", "Platforms", "Mac",
LOCTEXT("TargetSettingsName", "Mac"),
LOCTEXT("TargetSettingsDescription", "Settings and resources for Mac platform"),
TargetSettings
);
}
}
virtual void ShutdownModule() override
{
ISettingsModule* SettingsModule = FModuleManager::GetModulePtr<ISettingsModule>("Settings");
if (SettingsModule != nullptr)
{
SettingsModule->UnregisterSettings("Project", "Platforms", "Mac");
}
if (!GExitPurge)
{
// If we're in exit purge, this object has already been destroyed
TargetSettings->RemoveFromRoot();
}
else
{
TargetSettings = NULL;
}
}
// End IModuleInterface interface
private:
// Holds the target settings.
UMacTargetSettings* TargetSettings;
};
#undef LOCTEXT_NAMESPACE
IMPLEMENT_MODULE( FMacTargetPlatformModule, MacTargetPlatform);