bkaradzic / bgfx

Cross-platform, graphics API agnostic, "Bring Your Own Engine/Framework" style rendering library.
https://bkaradzic.github.io/bgfx/overview.html
BSD 2-Clause "Simplified" License
14.59k stars 1.92k forks source link

feat: add visionOS support #3289

Closed okwasniewski closed 3 weeks ago

okwasniewski commented 1 month ago

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 commented 1 month ago

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

bkaradzic commented 1 month ago

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

okwasniewski commented 1 month ago

Hey @bkaradzic,

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

okwasniewski commented 1 month ago

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

okwasniewski commented 3 weeks ago

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 commented 3 weeks ago

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 commented 3 weeks ago

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