浏览代码

iOS SCons: static Vulkan binary usage

Add VMA to iphone platform Use linkflag for iphone building to enforce static linking. Works fine with dynamic '.framework' library
Updated xcode project to use '.a' static library
Sergey Minakov 5 年之前
父节点
当前提交
fe60815d66
共有 3 个文件被更改,包括 19 次插入22 次删除
  1. 11 10
      drivers/vulkan/SCsub
  2. 4 7
      misc/dist/ios_xcode/godot_ios.xcodeproj/project.pbxproj
  3. 4 5
      platform/iphone/detect.py

+ 11 - 10
drivers/vulkan/SCsub

@@ -22,6 +22,17 @@ if env["platform"] == "android":
     thirdparty_dir = "#thirdparty/vulkan"
     thirdparty_dir = "#thirdparty/vulkan"
     vma_sources = [thirdparty_dir + "/android/vk_mem_alloc.cpp"]
     vma_sources = [thirdparty_dir + "/android/vk_mem_alloc.cpp"]
     env_thirdparty.add_source_files(env.drivers_sources, vma_sources)
     env_thirdparty.add_source_files(env.drivers_sources, vma_sources)
+elif env["platform"] == "iphone":
+    # Use bundled Vulkan headers
+    thirdparty_dir = "#thirdparty/vulkan"
+    env.Prepend(CPPPATH=[thirdparty_dir, thirdparty_dir + "/include", thirdparty_dir + "/loader"])
+
+    # Build Vulkan memory allocator
+    env_thirdparty = env.Clone()
+    env_thirdparty.disable_warnings()
+
+    vma_sources = [thirdparty_dir + "/vk_mem_alloc.cpp"]
+    env_thirdparty.add_source_files(env.drivers_sources, vma_sources)
 elif env["builtin_vulkan"]:
 elif env["builtin_vulkan"]:
     # Use bundled Vulkan headers
     # Use bundled Vulkan headers
     thirdparty_dir = "#thirdparty/vulkan"
     thirdparty_dir = "#thirdparty/vulkan"
@@ -70,16 +81,6 @@ elif env["builtin_vulkan"]:
                 'FALLBACK_CONFIG_DIRS=\\"%s\\"' % "/etc/xdg",
                 'FALLBACK_CONFIG_DIRS=\\"%s\\"' % "/etc/xdg",
             ]
             ]
         )
         )
-    elif env["platform"] == "iphone":
-        env_thirdparty.AppendUnique(
-            CPPDEFINES=[
-                "VK_USE_PLATFORM_IOS_MVK",
-                "VULKAN_NON_CMAKE_BUILD",
-                'SYSCONFDIR=\\"%s\\"' % "/etc",
-                'FALLBACK_DATA_DIRS=\\"%s\\"' % "/usr/local/share:/usr/share",
-                'FALLBACK_CONFIG_DIRS=\\"%s\\"' % "/etc/xdg",
-            ]
-        )
     elif env["platform"] == "linuxbsd":
     elif env["platform"] == "linuxbsd":
         env_thirdparty.AppendUnique(
         env_thirdparty.AppendUnique(
             CPPDEFINES=[
             CPPDEFINES=[

+ 4 - 7
misc/dist/ios_xcode/godot_ios.xcodeproj/project.pbxproj

@@ -12,8 +12,7 @@
 		$modules_buildfile
 		$modules_buildfile
 		1FF8DBB11FBA9DE1009DE660 /* dummy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1FF8DBB01FBA9DE1009DE660 /* dummy.cpp */; };
 		1FF8DBB11FBA9DE1009DE660 /* dummy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1FF8DBB01FBA9DE1009DE660 /* dummy.cpp */; };
 		D07CD44E1C5D589C00B7FB28 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D07CD44D1C5D589C00B7FB28 /* Images.xcassets */; };
 		D07CD44E1C5D589C00B7FB28 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D07CD44D1C5D589C00B7FB28 /* Images.xcassets */; };
-		905036DA24BF7D9B00301046 /* MoltenVK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 905036D824BF7D9600301046 /* MoltenVK.framework */; };
-		905036DB24BF7D9B00301046 /* MoltenVK.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 905036D824BF7D9600301046 /* MoltenVK.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
+		9039D3BE24C093AC0020482C /* MoltenVK.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9039D3BD24C093AC0020482C /* MoltenVK.a */; };
 		9073252C24BF980B0063BCD4 /* vulkan in Resources */ = {isa = PBXBuildFile; fileRef = 905036DC24BF932E00301046 /* vulkan */; };
 		9073252C24BF980B0063BCD4 /* vulkan in Resources */ = {isa = PBXBuildFile; fileRef = 905036DC24BF932E00301046 /* vulkan */; };
 		D0BCFE4618AEBDA2004A7AAE /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = D0BCFE4418AEBDA2004A7AAE /* InfoPlist.strings */; };
 		D0BCFE4618AEBDA2004A7AAE /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = D0BCFE4418AEBDA2004A7AAE /* InfoPlist.strings */; };
 		D0BCFE7818AEBFEB004A7AAE /* $binary.pck in Resources */ = {isa = PBXBuildFile; fileRef = D0BCFE7718AEBFEB004A7AAE /* $binary.pck */; };
 		D0BCFE7818AEBFEB004A7AAE /* $binary.pck in Resources */ = {isa = PBXBuildFile; fileRef = D0BCFE7718AEBFEB004A7AAE /* $binary.pck */; };
@@ -27,8 +26,6 @@
 				dstPath = "";
 				dstPath = "";
 				dstSubfolderSpec = 10;
 				dstSubfolderSpec = 10;
 				files = (
 				files = (
-					905036DB24BF7D9B00301046 /* MoltenVK.framework in Embed Frameworks */,
-
 					$pbx_embeded_frameworks
 					$pbx_embeded_frameworks
 				);
 				);
 				name = "Embed Frameworks";
 				name = "Embed Frameworks";
@@ -42,7 +39,7 @@
 		$modules_fileref
 		$modules_fileref
 		1FF4C1881F584E6300A41E41 /* $binary.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "$binary.entitlements"; sourceTree = "<group>"; };
 		1FF4C1881F584E6300A41E41 /* $binary.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "$binary.entitlements"; sourceTree = "<group>"; };
 		1FF8DBB01FBA9DE1009DE660 /* dummy.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = dummy.cpp; sourceTree = "<group>"; };
 		1FF8DBB01FBA9DE1009DE660 /* dummy.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = dummy.cpp; sourceTree = "<group>"; };
-		905036D824BF7D9600301046 /* MoltenVK.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = MoltenVK.framework; sourceTree = "<group>"; };
+		9039D3BD24C093AC0020482C /* MoltenVK.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = MoltenVK; path = MoltenVK.a; sourceTree = "<group>"; };
 		905036DC24BF932E00301046 /* vulkan */ = {isa = PBXFileReference; lastKnownFileType = folder; name = vulkan; path = "$binary/vulkan"; sourceTree = "<group>"; };
 		905036DC24BF932E00301046 /* vulkan */ = {isa = PBXFileReference; lastKnownFileType = folder; name = vulkan; path = "$binary/vulkan"; sourceTree = "<group>"; };
 		D07CD44D1C5D589C00B7FB28 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
 		D07CD44D1C5D589C00B7FB28 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
 		D0BCFE3418AEBDA2004A7AAE /* $binary.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "$binary.app"; sourceTree = BUILT_PRODUCTS_DIR; };
 		D0BCFE3418AEBDA2004A7AAE /* $binary.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "$binary.app"; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -59,7 +56,7 @@
 			isa = PBXFrameworksBuildPhase;
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			buildActionMask = 2147483647;
 			files = (
 			files = (
-				905036DA24BF7D9B00301046 /* MoltenVK.framework in Frameworks */,
+				9039D3BE24C093AC0020482C /* MoltenVK.a in Frameworks */,
 				DEADBEEF2F582BE20003B888 /* $binary.a */,
 				DEADBEEF2F582BE20003B888 /* $binary.a */,
 				$modules_buildphase
 				$modules_buildphase
 				$additional_pbx_frameworks_build
 				$additional_pbx_frameworks_build
@@ -93,7 +90,7 @@
 		D0BCFE3618AEBDA2004A7AAE /* Frameworks */ = {
 		D0BCFE3618AEBDA2004A7AAE /* Frameworks */ = {
 			isa = PBXGroup;
 			isa = PBXGroup;
 			children = (
 			children = (
-				905036D824BF7D9600301046 /* MoltenVK.framework */,
+				9039D3BD24C093AC0020482C /* MoltenVK.a */,
 				DEADBEEF1F582BE20003B888 /* $binary.a */,
 				DEADBEEF1F582BE20003B888 /* $binary.a */,
 				$modules_buildgrp
 				$modules_buildgrp
 				$additional_pbx_frameworks_refs
 				$additional_pbx_frameworks_refs

+ 4 - 5
platform/iphone/detect.py

@@ -231,8 +231,7 @@ def configure(env):
 
 
     env.Append(CPPDEFINES=["VULKAN_ENABLED"])
     env.Append(CPPDEFINES=["VULKAN_ENABLED"])
     env.Append(LINKFLAGS=["-framework", "IOSurface"])
     env.Append(LINKFLAGS=["-framework", "IOSurface"])
-    if env["use_static_mvk"]:
-        env.Append(LINKFLAGS=["-framework", "MoltenVK"])
-        env["builtin_vulkan"] = False
-    elif not env["builtin_vulkan"]:
-        env.Append(LIBS=["vulkan"])
+
+    # Use Static Vulkan for iOS. Dynamic Framework works fine too.
+    env.Append(LINKFLAGS=["-framework", "MoltenVK"])
+    env["builtin_vulkan"] = False