Varjo Native SDK
Varjo_layers.h File Reference

Go to the source code of this file.

Functions

struct varjo_SwapChain * varjo_D3D11CreateSwapChain (struct varjo_Session *session, struct ID3D11Device *dev, struct varjo_SwapChainConfig2 *config)
 Create a D3D11 swap chain that can be used when submitting layers. More...
 
struct varjo_SwapChain * varjo_GLCreateSwapChain (struct varjo_Session *session, struct varjo_SwapChainConfig2 *config)
 Create an OpenGL swap chain that can be used when submitting layers. More...
 
struct varjo_SwapChain * varjo_D3D12CreateSwapChain (struct varjo_Session *session, struct ID3D12CommandQueue *commandQueue, struct varjo_SwapChainConfig2 *config)
 Create a D3D12 swap chain that can be used when submitting layers. More...
 
struct varjo_Texture varjo_GetSwapChainImage (struct varjo_SwapChain *swapChain, int32_t index)
 Retrieve a swap chain image with the given index. More...
 
void varjo_AcquireSwapChainImage (struct varjo_SwapChain *swapChain, int32_t *index)
 Acquire (lock) the next image in the swap chain for rendering. More...
 
void varjo_ReleaseSwapChainImage (struct varjo_SwapChain *swapChain)
 Release a swap chain image previously acquired with a call to varjo_AcquireSwapChainImage. More...
 
void varjo_FreeSwapChain (struct varjo_SwapChain *swapChain)
 Delete a swap chain object. More...
 
void varjo_BeginFrameWithLayers (struct varjo_Session *session)
 Begin rendering the frame. More...
 
void varjo_EndFrameWithLayers (struct varjo_Session *session, struct varjo_SubmitInfoLayers *submitInfo)
 Submit a set of swap chains to the compositor to be displayed. More...
 

Function Documentation

◆ varjo_AcquireSwapChainImage()

void varjo_AcquireSwapChainImage ( struct varjo_SwapChain *  swapChain,
int32_t *  index 
)

Acquire (lock) the next image in the swap chain for rendering.

This function acquires the next image in the swap chain that is available for rendering, and must be called by the client before any rendering is performed into the swap chain. The index of the acquired swap chain image will be written to the location pointed to by the index parameter. The actual texture for the swap chain can be retrieved with a call to varjo_GetSwapChainImage.

After the application is done with rendering to the swap chain image, the image must be released back to the compositor by calling varjo_ReleaseSwapChainImage. This must be done for each swap chain object that is being submitted to the compositor before calling varjo_EndFrameWithLayers.

Parameters
swapChainPointer to the varjo_SwapChain object to acquire the image from.
indexPointer to the location where the acquired swap chain image index will be written to.

◆ varjo_BeginFrameWithLayers()

void varjo_BeginFrameWithLayers ( struct varjo_Session *  session)

Begin rendering the frame.

This function should be called only from the rendering thread and before any rendering work for the given frame is done. Frame must be submitted with varjo_EndFrameWithLayers().

Parameters
sessionVarjo session handle.

◆ varjo_D3D11CreateSwapChain()

struct varjo_SwapChain* varjo_D3D11CreateSwapChain ( struct varjo_Session *  session,
struct ID3D11Device *  dev,
struct varjo_SwapChainConfig2 config 
)

Create a D3D11 swap chain that can be used when submitting layers.

A swap chain object contains the image surfaces that can be rendered into, and submitted to the Varjo Compositor for displaying. Each swap chain contains multiple images in order to perform double- or triple-buffering when compositing the image. The amount of swap chain images created is configured in the numberOfTextures member of the varjo_SwapChainConfig2 struct.

Each frame submission contains references to 1..n swap chain objects; the application is free to render all views into a single swap chain image side-by-side as an atlas, or use a separate swap chain objects for each view (or any other combination imaginable).

Use varjo_FreeSwapChain to free the created swap chain.

When using layers for submitting the images, the calls to varjo_D3D11Init and varjo_D3D11ShutDown are not required.

Possible errors:

Parameters
sessionVarjo session handle.
devPointer to D3D11 device
configPointer to varjo_SwapChainConfig2 structure describing the swap chain configuration.
Returns
Pointer to a newly created varjo_SwapChain object, or nullptr on error.

◆ varjo_D3D12CreateSwapChain()

struct varjo_SwapChain* varjo_D3D12CreateSwapChain ( struct varjo_Session *  session,
struct ID3D12CommandQueue *  commandQueue,
struct varjo_SwapChainConfig2 config 
)

Create a D3D12 swap chain that can be used when submitting layers.

A swap chain object contains the image surfaces that can be rendered into, and submitted to the Varjo Compositor for displaying. Each swap chain contains multiple images in order to perform double- or triple-buffering when compositing the image. The amount of swap chain images created is configured in the numberOfTextures member of the varjo_SwapChainConfig2 struct.

Each frame submission contains references to 1..n swap chain objects; the application is free to render all views into a single swap chain image side-by-side as an atlas, or use a separate swap chain objects for each view (or any other combination imaginable).

Use varjo_FreeSwapChain to free the created swap chain.

Possible errors:

Parameters
sessionVarjo session handle.
commandQueuePointer to D3D12 command queue with that can be used to submit graphics commands.
configPointer to varjo_SwapChainConfig2 structure describing the swap chain configuration.
Returns
Pointer to a newly created varjo_SwapChain object, or nullptr on error.

◆ varjo_EndFrameWithLayers()

void varjo_EndFrameWithLayers ( struct varjo_Session *  session,
struct varjo_SubmitInfoLayers submitInfo 
)

Submit a set of swap chains to the compositor to be displayed.

The submitInfo parameter contains the list of layers that are to be displayed. See varjo_SubmitInfoLayers documentation for more information.

varjo_SubmitInfoLayers structure will be validated. Possible errors raised from validation:

Parameters
sessionVarjo session handle.
submitInfoPointer to layer submit info structure.

◆ varjo_FreeSwapChain()

void varjo_FreeSwapChain ( struct varjo_SwapChain *  swapChain)

Delete a swap chain object.

Parameters
swapChainThe varjo_SwapChain object to be deleted.

◆ varjo_GetSwapChainImage()

struct varjo_Texture varjo_GetSwapChainImage ( struct varjo_SwapChain *  swapChain,
int32_t  index 
)

Retrieve a swap chain image with the given index.

A swap chain contains 1..n images to allow double- or triple-buffering in the compositor. This function can be used to retrieve the underlying texture object for each of those images.

The texture objects retrieved with this function are guaranteed to stay valid for the lifetime of the varjo_SwapChain object, so the application is free to query the textures at application startup time to build other dependent objects (such as Render Target Views etc).

Parameters
swapChainPointer to the varjo_SwapChain object.
indexThe index of the image to retrieve. This value must be in range [0, number of textures in the swap chain[
Returns
The swap chain image texture at the given index.

◆ varjo_GLCreateSwapChain()

struct varjo_SwapChain* varjo_GLCreateSwapChain ( struct varjo_Session *  session,
struct varjo_SwapChainConfig2 config 
)

Create an OpenGL swap chain that can be used when submitting layers.

A swap chain object contains the image surfaces that can be rendered into, and submitted to the Varjo Compositor for displaying. Each swap chain contains multiple images in order to perform double- or triple-buffering when compositing the image. The amount of swap chain images created is configured in the numberOfTextures member of the varjo_SwapChainConfig2 struct.

Each frame submission contains references to 1..n swap chain objects; the application is free to render all views into a single swap chain image side-by-side as an atlas, or use a separate swap chain objects for each view (or any other combination imaginable).

This function expects an OpenGL render context to be active for the calling thread.

When using layers for submitting the images, the calls to varjo_GLInit and varjo_GLShutDown are not required.

Use varjo_FreeSwapChain to free the created swap chain.

Possible errors:

Parameters
sessionVarjo session handle.
configPointer to varjo_SwapChainConfig2 structure describing the swap chain configuration.
Returns
Pointer to a newly created varjo_SwapChain object, or nullptr on error.

◆ varjo_ReleaseSwapChainImage()

void varjo_ReleaseSwapChainImage ( struct varjo_SwapChain *  swapChain)

Release a swap chain image previously acquired with a call to varjo_AcquireSwapChainImage.

Parameters
swapChainPointer to the varjo_SwapChain object where an image was previously acquired from.