Fix building macOS/iOS with the latest Vulkan SDK
This commit is contained in:
@@ -202,13 +202,25 @@ bool iOSPlatformTools::OnPostProcess(CookingData& data)
|
||||
if (EditorUtilities::FormatAppPackageName(appIdentifier))
|
||||
return true;
|
||||
|
||||
// Copy fresh Gradle project template
|
||||
// Copy fresh XCode project template
|
||||
if (FileSystem::CopyDirectory(data.OriginalOutputPath, platformDataPath / TEXT("Project"), true))
|
||||
{
|
||||
LOG(Error, "Failed to deploy XCode project to {0} from {1}", data.OriginalOutputPath, platformDataPath);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Fix MoltenVK lib (copied from VulkanSDK xcframework)
|
||||
FileSystem::MoveFile(data.DataOutputPath / TEXT("libMoltenVK.dylib"), data.DataOutputPath / TEXT("MoltenVK"), true);
|
||||
{
|
||||
// Fix rpath to point into dynamic library (rather than framework location)
|
||||
CreateProcessSettings procSettings;
|
||||
procSettings.HiddenWindow = true;
|
||||
procSettings.WorkingDirectory = data.DataOutputPath;
|
||||
procSettings.FileName = TEXT("/usr/bin/install_name_tool");
|
||||
procSettings.Arguments = TEXT("-id \"@rpath/libMoltenVK.dylib\" libMoltenVK.dylib");
|
||||
Platform::CreateProcess(procSettings);
|
||||
}
|
||||
|
||||
// Format project template files
|
||||
Dictionary<String, String> configReplaceMap;
|
||||
configReplaceMap[TEXT("${AppName}")] = appName;
|
||||
|
||||
@@ -133,6 +133,59 @@ public sealed class VulkanSdk : Sdk
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds any runtime dependency files to the build that uses Vulkan SDK.
|
||||
/// </summary>
|
||||
/// <param name="platform">Build options.</param>
|
||||
public void AddDependencyFiles(BuildOptions options)
|
||||
{
|
||||
switch (options.Platform.Target)
|
||||
{
|
||||
case TargetPlatform.Mac:
|
||||
case TargetPlatform.iOS:
|
||||
{
|
||||
// MoltenVK
|
||||
var platformName = options.Platform.Target == TargetPlatform.iOS ? "iOS" : "macOS";
|
||||
var location1 = Path.Combine(RootPath, "../MoltenVK/dylib/" + platformName);
|
||||
if (Directory.Exists(location1))
|
||||
{
|
||||
// Initial location
|
||||
options.DependencyFiles.Add(Path.Combine(location1, "libMoltenVK.dylib"));
|
||||
options.DependencyFiles.Add(Path.Combine(location1, "MoltenVK_icd.json"));
|
||||
return;
|
||||
}
|
||||
|
||||
// New location from SDK 1.3.275
|
||||
if (options.Platform.Target == TargetPlatform.iOS)
|
||||
{
|
||||
var location2 = Path.Combine(RootPath, "../iOS/lib/MoltenVK.xcframework/ios-arm64/MoltenVK.framework");
|
||||
var location3 = Path.Combine(RootPath, "../iOS/share/vulkan/icd.d");
|
||||
if (Directory.Exists(location2) && Directory.Exists(location3))
|
||||
{
|
||||
// iOS
|
||||
options.DependencyFiles.Add(Path.Combine(location2, "MoltenVK"));
|
||||
options.DependencyFiles.Add(Path.Combine(location3, "MoltenVK_icd.json"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var location2 = Path.Combine(RootPath, "lib");
|
||||
var location3 = Path.Combine(RootPath, "share/vulkan/icd.d");
|
||||
if (Directory.Exists(location2) && Directory.Exists(location3))
|
||||
{
|
||||
// macOS
|
||||
options.DependencyFiles.Add(Path.Combine(location2, "libMoltenVK.dylib"));
|
||||
options.DependencyFiles.Add(Path.Combine(location3, "MoltenVK_icd.json"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
Log.Error($"Missing MoltenVK files for {platformName} in VulkanSDK '{RootPath}'");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
5
Source/ThirdParty/volk/volk.Build.cs
vendored
5
Source/ThirdParty/volk/volk.Build.cs
vendored
@@ -42,16 +42,13 @@ public class volk : ThirdPartyModule
|
||||
break;
|
||||
case TargetPlatform.Mac:
|
||||
options.PublicDefinitions.Add("VK_USE_PLATFORM_MACOS_MVK");
|
||||
options.DependencyFiles.Add(Path.Combine(VulkanSdk.Instance.RootPath, "../MoltenVK/dylib/macOS/libMoltenVK.dylib"));
|
||||
options.DependencyFiles.Add(Path.Combine(VulkanSdk.Instance.RootPath, "../MoltenVK/dylib/macOS/MoltenVK_icd.json"));
|
||||
break;
|
||||
case TargetPlatform.iOS:
|
||||
options.PublicDefinitions.Add("VK_USE_PLATFORM_IOS_MVK");
|
||||
options.DependencyFiles.Add(Path.Combine(VulkanSdk.Instance.RootPath, "../MoltenVK/dylib/iOS/libMoltenVK.dylib"));
|
||||
options.DependencyFiles.Add(Path.Combine(VulkanSdk.Instance.RootPath, "../MoltenVK/dylib/iOS/MoltenVK_icd.json"));
|
||||
break;
|
||||
default: throw new InvalidPlatformException(options.Platform.Target);
|
||||
}
|
||||
VulkanSdk.Instance.AddDependencyFiles(options);
|
||||
|
||||
string includesFolderPath;
|
||||
if (VulkanSdk.Instance.TryGetIncludePath(options.Platform.Target, out includesFolderPath))
|
||||
|
||||
Reference in New Issue
Block a user