Fove SDK  v0.18.0
Public Member Functions | List of all members
fove.headset.Compositor Class Reference

Class that manages accesses to the compositor. More...

Inheritance diagram for fove.headset.Compositor:
Inheritance graph
[legend]
Collaboration diagram for fove.headset.Compositor:
Collaboration graph
[legend]

Public Member Functions

def __init__ (self, headset)
 Defines a compositor that can be created from a headset. More...
 
def __enter__ (self)
 Creates a compositor interface to the given headset. More...
 
def __exit__ (self, _e_type, _e_val, _traceback)
 Frees resources used by the compositor object, including memory and sockets. More...
 
def createLayer (self, layerInfo)
 Create a layer for this client. More...
 
def getAdapterId (self)
 Returns the ID of the GPU currently attached to the headset. More...
 
def getLastRenderPose (self)
 Gets the last cached pose for rendering purposes, without waiting for a new frame to arrive. More...
 
def isReady (self)
 Checks whether we are connected to a running compositor and ready to submit frames for composing. More...
 
def submit (self, submitInfo, layerCount)
 Submit a frame to the compositor. More...
 
def waitForRenderPose (self)
 Wait for the most recent pose for rendering purposes. More...
 

Detailed Description

Class that manages accesses to the compositor.

All Compositor-related API requests will be done through an instance of this class.

The class provides Compositor.__enter__ and Compositor.__exit__ methods that do relevant resource managements, and the Headset instance has a factory method that creates a compositor.

It is fine to create multiple compositors from the same headset. It is also fine for the compositor to outlive the headset passed in.

A typical use of this class would be as follows:

with Headset(ClientCapabilities.Gaze) as headset,
headset.createCompositor() as compositor:
# use compositor
pass

Constructor & Destructor Documentation

◆ __init__()

def fove.headset.Compositor.__init__ (   self,
  headset 
)

Defines a compositor that can be created from a headset.

Normally, this method is invoked through Headset.createCompositor. But unlike in the C API, the user has to call Compositor.__enter__ on the result of Compositor.__init__ or Headset.createCompositor to actually connect to a compositor.

Parameters
headsetAn instance of capi.Headset from which this compositor will be created. (Note that it is not an instance of the Headset class defined in this module.)
See also
Headset.createCompositor
Compositor.__enter__

Member Function Documentation

◆ __enter__()

def fove.headset.Compositor.__enter__ (   self)

Creates a compositor interface to the given headset.

Each call to this function creates and stores a new compositor object, which should be destroyed by calling Compositor.__exit__ on self, which is also retuned from this function.

Returns
self with a reference to a compositor object
See also
Headset.createCompositor
Compositor.__exit__

◆ __exit__()

def fove.headset.Compositor.__exit__ (   self,
  _e_type,
  _e_val,
  _traceback 
)

Frees resources used by the compositor object, including memory and sockets.

Upon return, this instance for the compositor should no longer be used.

See also
Compositor.__enter__
Headset.createCompositor

◆ createLayer()

def fove.headset.Compositor.createLayer (   self,
  layerInfo 
)

Create a layer for this client.

This function creates a layer upon which frames may be submitted to the compositor by this client.

A connection to the compositor must exist for this to pass. This means you need to wait for Compositor.isReady before calling this function. However, if connection to the compositor is lost and regained, this layer will persist. For this reason, you should not recreate your layers upon reconnection, simply create them once.

There is no way to delete a layer once created, other than to destroy the Compositor object. This is a feature we would like to add in the future.

Parameters
layerInfoThe settings for the layer to be created
Returns
A struct that holds the defaults of the newly created layer
See also
Compositor.isReady
Compositor.submit

◆ submit()

def fove.headset.Compositor.submit (   self,
  submitInfo,
  layerCount 
)

Submit a frame to the compositor.

This function takes the feed from your game engine to the compositor for output.

Parameters
submitInfoAn array of layerCount capi.CompositorLayerSubmitInfo structs, each of which provides texture data for a unique layer
layerCountThe number of layers you are submitting
Returns
True if successfully submitted, or None in case of API failure

◆ waitForRenderPose()

def fove.headset.Compositor.waitForRenderPose (   self)

Wait for the most recent pose for rendering purposes.

All compositor clients should use this function as the sole means of limiting their frame rate. This allows the client to render at the correct frame rate for the HMD display. Upon this function returning, the client should proceed directly to rendering, to reduce the chance of missing the frame. This function will return the latest pose (valid if not None) as a conveience to the caller.

In general, a client's main loop should look like:

# with compositor
while True:
Update() # Run AI, physics, etc, for the next frame
pose, err = compositor.waitForRenderPose() # Wait for the next frame, and get the pose
if pose:
Draw(pose) # Render the scene using the new pose
elif err is False:
# sleep a bit and retry
continue
else:
# permanent error
break
Returns
(Optional[capi.Pose], Optional[bool])
The first return value is the current pose if the call synced with the compositor frames; otherwise it is None.
When the first return value is None, the second return value indicates whether the error is permanent: i.e. it is False when the call to an internal API has just timed out and retry on the client side might be useful; it is otherwise True, e.g. if the Orientation capability was not registered.

◆ getLastRenderPose()

def fove.headset.Compositor.getLastRenderPose (   self)

Gets the last cached pose for rendering purposes, without waiting for a new frame to arrive.

Returns
Last cached pose, or None in case of API failure

◆ isReady()

def fove.headset.Compositor.isReady (   self)

Checks whether we are connected to a running compositor and ready to submit frames for composing.

Returns
True if we are connected to a running compositor and ready to submit frames for compositing, False if not, or else None in case of API failure

◆ getAdapterId()

def fove.headset.Compositor.getAdapterId (   self)

Returns the ID of the GPU currently attached to the headset.

For systems with multiple GPUs, submitted textures to the compositor must come from the same GPU that the compositor is using.

Returns
The adapter ID, or None in case of API failure