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

OpenXR support? #109

Open
gigadude opened this issue Nov 3, 2020 · 2 comments
Open

OpenXR support? #109

gigadude opened this issue Nov 3, 2020 · 2 comments

Comments

@gigadude
Copy link

gigadude commented Nov 3, 2020

I'd like to add OpenXR support, opening this issue to discuss the right way to do that.

My first pass at the needed API changes for minimalist XR support:

IEngineFactory:

  • CreateOpenXRFactory(OpenXRCreateInfo* info, IOpenXRContext** ctx), called before CreateDeviceAndContextsXx to initialize the OpenXR instance and return the interface. IOpenXRContext will provide interfaces to the session lifecycle stuff, input bindings, layers, spaces etc.

ISwapChain:

  • Uint32 GetViewCount() to turn the number of views for the device (typically 2 for right, left eyes). Non-OpenXR apps will return 1.
  • OpenXRViewDesc GetOpenOpenXRViewDesc(Uint32 ViewIndex) to return the view descriptor for a given view.
  • Uint32 SelectOpenXRView(Uint32 ViewIndex) to make one of the views "current", the rest of the swapchain functions will reference the resources for that view (e,g, GetDesc, GetCurrentBackBufferRTV etc. will return parameters for the selected view). Returns the previously current view.
  • WaitFrame(FrameInfo* frame) maps to xrWaitFrame, ignored by non-XR apps.
  • BeginFrame(FrameInfo* frame) maps to xrBeginFrame, ignored by non-XR apps.
  • EndFrame(FrameInfo* frame) maps to xrEndFrame, ignored by non-XR apps. Present() will be ignored by XR apps.

The intent is to allow the same code to work in both XR and 2D mode by simply choosing to call or not call CreateOpenXRFactory.

@TheMostDiligent
Copy link
Contributor

TheMostDiligent commented Nov 5, 2020

Hi!
Thanks for looking into this.
I am not very familiar with OpenXR, so please correct me where I am wrong.
From my understanding, from the graphics point of view the only thing that connects XR application to rendering code is the swap chain. Core module only implements rendering functionality, it does not handle application-level tasks such input, app main loop, etc. So it seems that for the core module, what needs to be added is a new IEngineFactory method CreateXRSwapChain that will take the XR session and other required parameters.

Other application-specific logic does not belong to Core module. Instead, I think it should be added to tools module. There is a NativeAppBase, so probably there should be XRApp that will implement all logic like WaitFrame, BeginFrame, etc. What do you think?

@madwax
Copy link

madwax commented Mar 14, 2021

Gigadude how far have you gone with this?

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

No branches or pull requests

3 participants