Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add visionOS support #3289

Merged
merged 1 commit into from
Jun 3, 2024
Merged

feat: add visionOS support #3289

merged 1 commit into from
Jun 3, 2024

Conversation

okwasniewski
Copy link
Contributor

Hello,

This PR adds visionOS support to bgfx. It's the continuation of this PR which added support to bx library. I've worked on this together with @mani3xis.

Apple Vision uses bgfx in single threaded mode (BGFX_CONFIG_MULTITHREADED = 0), but the example framework isn't really working nice with single threaded mode, so there might be some crashes in the examples but it works great when integrated separately.

Simulator Screenshot - Apple Vision Pro - 2024-05-09 at 11 27 58

@bkaradzic
Copy link
Owner

Follow existing file name convention when adding new files...

Copy link
Owner

@bkaradzic bkaradzic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please split this into two PRs. One where you just add BX_PLATFORM_VISIONOS defines, and after that PR one where you add new files, change scripts, etc.

src/renderer_mtl.mm Outdated Show resolved Hide resolved
@bkaradzic
Copy link
Owner

You should investigate how to avoid using 4 files for visionOS entry. Ideally only one file would be there.

@okwasniewski
Copy link
Contributor Author

Hey @bkaradzic,

I've removed "example" needed changes from this PR. I will open a separate one.

@okwasniewski
Copy link
Contributor Author

Hey @bkaradzic, is there anything more I should change in this PR?

src/renderer_mtl.mm Outdated Show resolved Hide resolved
src/renderer_mtl.mm Show resolved Hide resolved
Co-authored-by: mani3xis <mariusz.pas+dev@protonmail.com>

fix: properly set storageMode

cleanup: remove unused variables

fix crash while releasing m_drawable on visionOS

fix: remove unused timing variable

fix: file name cases, cleanup

feat: integrate visionOS into bgfx examples
@okwasniewski
Copy link
Contributor Author

okwasniewski commented Jun 3, 2024

Hey @bkaradzic! I did an initial testing integration to BabylonNative and it seems to work properly 👍🏻 Is there anything else you want to see in this PR fixed?

Here is a screenshot of Babylon Native examples running on visionOS (it's rendering a cube):

image

@bkaradzic
Copy link
Owner

LGTM! Only question about this code:

#if BX_PLATFORM_VISIONOS
        cp_layer_renderer_t m_layerRenderer;
        cp_frame_t m_frame;
        cp_drawable_t m_drawable;
#else
		CAMetalLayer* m_metalLayer;
		CAMetalLayer* m_metalLayer;
		id <CAMetalDrawable> m_drawable;
        id <CAMetalDrawable> m_drawable;
#endif

Is this cp_layer_renderer something new that's also available on other Apple platforms or it's specific to visionOS?!

@okwasniewski
Copy link
Contributor Author

LGTM! Only question about this code:

#if BX_PLATFORM_VISIONOS
        cp_layer_renderer_t m_layerRenderer;
        cp_frame_t m_frame;
        cp_drawable_t m_drawable;
#else
		CAMetalLayer* m_metalLayer;
		CAMetalLayer* m_metalLayer;
		id <CAMetalDrawable> m_drawable;
        id <CAMetalDrawable> m_drawable;
#endif

Is this cp_layer_renderer something new that's also available on other Apple platforms or it's specific to visionOS?!

It's specific to visionOS, it's unavailable on other platforms.

CleanShot 2024-06-03 at 16 41 10@2x

@bkaradzic bkaradzic merged commit 3195593 into bkaradzic:master Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants