Open DylanLukes opened 4 years ago
So what is Catalyst exactly?
OSX or iOS?
If it's OSX then it should be:
{ "osx-catalyst", "OSX Catalyst" },
Also if bx is identifying platform it should not use IOS defines to turn on off OSX features.
Also you should not use TARGET_OS_*
defines anywhere outside of platform.h
, BX_PLATFORM_OSX
could be defined in the way to identify that particular OS.
Yeah, this is a very, very rough cut. It is definitely not ideal, just a first pass.
So... Catalyst is... both. Kind of.
Catalyst is for (roughly speaking) running iPad apps on macOS. In essence, it provides versions of the iOS specific APIs such as UIKit that work on macOS. It's the iOS runtime environment, but on macOS (with an appropriately distinct ABI). I originally defined it as osx-catalyst
as you described. But it turned out this configuration shared more in common with the iOS configurations than it does with the OSX configurations.
TARGET_OS_MACCATALYST
is what xcodebuild
/xcrun
/etc define, and what Apple suggests using for macroing in/out code that is MacOS specific in Catalyst enabled projects. I initially had a distinct BX_PLATFORM_MACCATALYST
, but pruned it for simplicity. I think going back to that would be a cleaner approach.
Currently, the requirements are that you target iOS version 13+, and macOS version 10.15+. The architecture for Catalyst builds is x86_64h
(Haswell) though in practice you often need the x86_64
slice in your fat binaries as well for development purposes.
One additional problem with the setup above is that it should ideally make use of both iosPlatform
and osxPlatform
, as in the future there will likely be valid combinations beyond 13.x/10.15.x.
A note: this API is explicitly marketed towards people as a way to (e.g.) develop a game for iPad and then easily make it available on macOS. It's seems at least somewhat likely at least some current iOS bgfx
users may want support for it going forward.
Ok then it's more like tvos with some extra compile time things. It could be ios-catalyst
and then follow BX_PLATFORM_IOS
defines.
I'll clean things up once I've got some demos running and am sure it's fully functional.
How should I submit a PR when it's across two repos? Just two distinct PRs and xref them?
Also: it can't exactly follow BX_PLATFORM_IOS
defines because Catalyst (like macOS 10.15) does not support OpenGL ES in any capacity.
It might also be good to have both x86_64
and x86_64h
as options, or build and lipo
them both together. Xcode will complain if you lack either (on my machine at least, on a Haswell Mac it won't care about the missing x86_64
.)
How should I submit a PR when it's across two repos? Just two distinct PRs and xref them?
First submit bx to get all functionality you need there.
iOS will stop supporting GLES anyway at some point, it's just checking version. Idea is to identify platform iOS because it's closest to that, but have some way of disabling GLES.
Finding more than a few small hiccups as I go, I'll document them here for reference.
MTLStorageModeShared
, only MTLStorageModeManaged
and MTLStorageModePrivate
. As a result, here: https://github.com/bkaradzic/bgfx/blob/master/src/renderer_mtl.mm#L2721
Will error out on bgfx::init(...)
:
validateMTLStorageMode, line 237: error 'invalid storageMode (0). Must be one of MTLStorageModeManaged(1) MTLStorageModePrivate(2)'
There's definitely some weirdness going on. For some reason, dbgTextPrintf()
does not work... however TextVideoMem
and blitting do work otherwise, as BGFX_DEBUG_STATS
does produce output.
As far as I can tell these code paths are pretty similar, except for when the TVM is created, and I can confirm the TVM's memory looks correct. I'll try to put together a minimal failing test case.
@attilaz would be the best to add this support, since he is very familiar with all Apple platforms and author of Metal renderer.
I haven't tried catalyst, but after reading the docs from the metal renderer point of view catalyst supports the same features as macos. Because it runs on the same hardware. Windowing is similar to iOS with UI APIs instead of NS.
For example the metal gpu family is "MTLGPUFamilyMacCatalyst1" which is "A family 1 Mac GPU when running in an iOS app."
https://developer.apple.com/documentation/metal/mtlgpufamily/mtlgpufamilymaccatalyst1?language=objc
I've been continuing to try to get things working, and have found there are a good number of (mostly subtle) differences.
I'm not entirely sure BX_PLATFORM_IOS
would actually be appropriate. I'm finding myself having to write BX_PLATFORM_IOS & [!]TARGET_OS_MACCATALYST
in a good few places.
The aforementioned storage mode issue is an example of this. However, the change I made to get it working on Mac (Catalyst) has made it no longer work correctly on iPad (when build targeting catalyst). One step forward, another step back...
I'm currently trying to set up some sort of harness to run the tests/examples, but glfw can't be built for Catalyst (doesn't expose the necessary windowing APIs), so I'm trying to see if I can build glfw just for x86_64h-apple-... while still being able to link to x86_64h-apple-ios13.x-macabi.
I'm opening this as an issue rather than a PR because it's:
1) Not finalized. 2) Affects
bx
(namely,scripts/toolchain.lua
), but also requires some changes tobgfx
.All in all, building for Mac Catalyst was not too hard. It is essentially "just like" building for iOS, except:
1) The required link and build options are a little different. 2) OpenGL ES does not exist and must be conditioned out.
I haven't thoroughly tested this yet, but at the least it should provide a starting point.
As for
bgfx
itself...