Vixen
02b45cc4
csharp
public interface IXrSession

A running connection to a headset: frames, poses and input.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

The frame loop is the runtime's, not the game's. BeginFrame blocks until the runtime says it is time to start the next frame — that is how a compositor paces an application to the display and how it inserts the latency it wants — so an XR game's outer loop is driven from here rather than from a timer. A game that renders on its own schedule and submits whenever it finishes gets judder that no amount of frame rate fixes.

Poses are predicted for the display time. LocateViews is asked for a moment in the future, and the answer is where the runtime thinks the head will be then. Locating with the wrong time — this instant, or last frame's — is a constant lag that looks exactly like a slow tracker.

Every frame between BeginFrame and EndFrame must be closed. Including the ones where nothing is drawn, and including the ones where the game threw: a runtime that is waiting for a frame that never ends stops the compositor for everybody.

Fields and properties (7)

  • XrSessionState State

    Where the session is in its lifecycle.

  • bool IsRunning

    Whether frames should be submitted at all.

  • bool HasFocus

    Whether the game should be reading input and simulating.

  • int ViewCount

    How many views a frame has.

  • XrSystemInfo System

    What the runtime said about the device.

  • XrReferenceSpace ReferenceSpace

    What poses are reported relative to.

  • ReadOnlySpan<XrView> Views

    The views located for the current frame, one per eye.

Methods (10)

  • IXrSwapchain CreateSwapchain(in XrSwapchainDescription description)

    Creates a swapchain for eye buffers.

  • bool PollEvents()

    Drains the runtime's event queue, moving State on.

  • bool BeginFrame(out XrFrameState frame)

    Waits for the runtime to want the next frame, and begins it.

  • ReadOnlySpan<XrView> LocateViews(in XrFrameState frame)

    Asks where the eyes will be when the frame is displayed.

  • bool LocateSpace(XrReferenceSpace space, in XrFrameState frame, out XrPose pose)

    Locates something the runtime tracks, in the session's reference space.

  • void EndFrame(in XrFrameState frame, ReadOnlySpan<XrCompositionView> views)

    Submits the frame.

  • void AttachActionSets(ReadOnlySpan<XrActionSet> sets)

    Attaches the action sets, after which they cannot be changed.

  • void SyncActions()

    Updates every attached action's state for this frame.

  • void ApplyHaptics(XrAction action, XrHand hand, in XrHapticPulse request)

    Plays a haptic pulse.

  • void RequestExit()

    Asks the runtime to end the session.

Used by (7)

  • IXrBackendVixen.Xr
  • NullXrBackendVixen.Xr
  • NullXrBackendTestsVixen.Xr.Tests
  • NullXrSessionVixen.Xr
  • OpenXrBackendVixen.Xr.OpenXR
  • OpenXrSessionVixen.Xr.OpenXR
  • XrTrackingSystemVixen.Xr