forked from google/angle
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add iOS build support, fix Metal command buffer leaks.
- Loading branch information
Showing
7 changed files
with
199 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
diff --git a/src/libANGLE/renderer/metal/ProgramMtl.mm b/src/libANGLE/renderer/metal/ProgramMtl.mm | ||
index 04fc45023..b2a4f3f96 100644 | ||
--- a/src/libANGLE/renderer/metal/ProgramMtl.mm | ||
+++ b/src/libANGLE/renderer/metal/ProgramMtl.mm | ||
@@ -350,7 +350,7 @@ void InitArgumentBufferEncoder(mtl::Context *context, | ||
if (encoder->metalArgBufferEncoder) | ||
{ | ||
encoder->bufferPool.initialize(context, encoder->metalArgBufferEncoder.get().encodedLength, | ||
- mtl::kArgumentBufferOffsetAlignment, 0); | ||
+ mtl::kArgumentBufferOffsetAlignment, 10); | ||
} | ||
} | ||
|
||
diff --git a/src/libANGLE/renderer/metal/ProvokingVertexHelper.mm b/src/libANGLE/renderer/metal/ProvokingVertexHelper.mm | ||
index 3c3b47be1..0a186b63a 100644 | ||
--- a/src/libANGLE/renderer/metal/ProvokingVertexHelper.mm | ||
+++ b/src/libANGLE/renderer/metal/ProvokingVertexHelper.mm | ||
@@ -101,7 +101,7 @@ static inline gl::PrimitiveMode getNewPrimitiveMode(const uint fixIndexBufferKey | ||
} | ||
ProvokingVertexHelper::ProvokingVertexHelper(ContextMtl *context) : mIndexBuffers(false) | ||
{ | ||
- mIndexBuffers.initialize(context, kInitialIndexBufferSize, mtl::kIndexBufferOffsetAlignment, 0); | ||
+ mIndexBuffers.initialize(context, kInitialIndexBufferSize, mtl::kIndexBufferOffsetAlignment, 10); | ||
} | ||
|
||
void ProvokingVertexHelper::onDestroy(ContextMtl *context) | ||
diff --git a/src/libANGLE/renderer/metal/VertexArrayMtl.mm b/src/libANGLE/renderer/metal/VertexArrayMtl.mm | ||
index 1d30b2534..50e894ac3 100644 | ||
--- a/src/libANGLE/renderer/metal/VertexArrayMtl.mm | ||
+++ b/src/libANGLE/renderer/metal/VertexArrayMtl.mm | ||
@@ -198,7 +198,7 @@ VertexArrayMtl::VertexArrayMtl(const gl::VertexArrayState &state, ContextMtl *co | ||
/** maxBuffers */ 10 * mtl::kMaxVertexAttribs); | ||
|
||
mDynamicIndexData.initialize(context, kDynamicIndexDataSize, mtl::kIndexBufferOffsetAlignment, | ||
- 0); | ||
+ 10); | ||
} | ||
VertexArrayMtl::~VertexArrayMtl() {} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import os | ||
import sys | ||
import subprocess | ||
from SCons.Variables import * | ||
|
||
if sys.version_info < (3,): | ||
|
||
def decode_utf8(x): | ||
return x | ||
|
||
else: | ||
import codecs | ||
|
||
def decode_utf8(x): | ||
return codecs.utf_8_decode(x)[0] | ||
|
||
|
||
def has_ios_osxcross(): | ||
return "OSXCROSS_IOS" in os.environ | ||
|
||
|
||
def options(opts): | ||
opts.Add(BoolVariable("ios_simulator", "Target iOS Simulator", False)) | ||
opts.Add(BoolVariable("ios_static", "Build iOS library", True)) | ||
opts.Add("ios_min_version", "Target minimum iphoneos/iphonesimulator version", "12.0") | ||
opts.Add( | ||
"IOS_TOOLCHAIN_PATH", | ||
"Path to iOS toolchain", | ||
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain", | ||
) | ||
opts.Add("IOS_SDK_PATH", "Path to the iOS SDK", "") | ||
|
||
if has_ios_osxcross(): | ||
opts.Add("ios_triple", "Triple for ios toolchain", "") | ||
|
||
|
||
def exists(env): | ||
return sys.platform == "darwin" or has_ios_osxcross() | ||
|
||
|
||
def generate(env): | ||
if env["arch"] not in ("universal", "arm64", "x86_64"): | ||
raise ValueError("Only universal, arm64, and x86_64 are supported on iOS. Exiting.") | ||
|
||
if env["ios_simulator"]: | ||
sdk_name = "iphonesimulator" | ||
env.Append(CCFLAGS=["-mios-simulator-version-min=" + env["ios_min_version"]]) | ||
else: | ||
sdk_name = "iphoneos" | ||
env.Append(CCFLAGS=["-miphoneos-version-min=" + env["ios_min_version"]]) | ||
|
||
if sys.platform == "darwin": | ||
if env["IOS_SDK_PATH"] == "": | ||
try: | ||
env["IOS_SDK_PATH"] = decode_utf8( | ||
subprocess.check_output(["xcrun", "--sdk", sdk_name, "--show-sdk-path"]).strip() | ||
) | ||
except (subprocess.CalledProcessError, OSError): | ||
raise ValueError( | ||
"Failed to find SDK path while running xcrun --sdk {} --show-sdk-path.".format(sdk_name) | ||
) | ||
|
||
compiler_path = env["IOS_TOOLCHAIN_PATH"] + "/usr/bin/" | ||
env["CC"] = compiler_path + "clang" | ||
env["CXX"] = compiler_path + "clang++" | ||
env["AR"] = compiler_path + "ar" | ||
env["RANLIB"] = compiler_path + "ranlib" | ||
env["SHLIBSUFFIX"] = ".dylib" | ||
env["ENV"]["PATH"] = env["IOS_TOOLCHAIN_PATH"] + "/Developer/usr/bin/:" + env["ENV"]["PATH"] | ||
|
||
else: | ||
# OSXCross | ||
compiler_path = "$IOS_TOOLCHAIN_PATH/usr/bin/${ios_triple}" | ||
env["CC"] = compiler_path + "clang" | ||
env["CXX"] = compiler_path + "clang++" | ||
env["AR"] = compiler_path + "ar" | ||
env["RANLIB"] = compiler_path + "ranlib" | ||
env["SHLIBSUFFIX"] = ".dylib" | ||
|
||
env.Prepend( | ||
CPPPATH=[ | ||
"$IOS_SDK_PATH/usr/include", | ||
"$IOS_SDK_PATH/System/Library/Frameworks/AudioUnit.framework/Headers", | ||
] | ||
) | ||
|
||
env.Append(CCFLAGS=["-stdlib=libc++"]) | ||
|
||
binpath = os.path.join(env["IOS_TOOLCHAIN_PATH"], "usr", "bin") | ||
if binpath not in env["ENV"]["PATH"]: | ||
env.PrependENVPath("PATH", binpath) | ||
|
||
if env["arch"] == "universal": | ||
if env["ios_simulator"]: | ||
env.Append(LINKFLAGS=["-arch", "x86_64", "-arch", "arm64"]) | ||
env.Append(CCFLAGS=["-arch", "x86_64", "-arch", "arm64"]) | ||
else: | ||
env.Append(LINKFLAGS=["-arch", "arm64"]) | ||
env.Append(CCFLAGS=["-arch", "arm64"]) | ||
else: | ||
env.Append(LINKFLAGS=["-arch", env["arch"]]) | ||
env.Append(CCFLAGS=["-arch", env["arch"]]) | ||
|
||
env.Append(CCFLAGS=["-isysroot", env["IOS_SDK_PATH"]]) | ||
env.Append(LINKFLAGS=["-isysroot", env["IOS_SDK_PATH"], "-F" + env["IOS_SDK_PATH"]]) | ||
|
||
env.Append(CPPDEFINES=["IOS_ENABLED", "UNIX_ENABLED"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters