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_SwapChain * varjo_VKCreateSwapChain (struct varjo_Session *session, struct VkDevice_T *device, uint32_t queueFamilyIndex, uint32_t queueIndex, struct varjo_SwapChainConfig2 *config)
 Create a Vulkan 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...
 
void varjo_SetMirrorConfig (struct varjo_Session *session, struct varjo_MirrorView *mirrorViews, uint32_t count)
 Configures where Compositor should render mirror views. More...
 
void varjo_ResetMirrorConfig (struct varjo_Session *session)
 Resets mirror config, effectively disabling mirror view feature. 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.

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.

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.

◆ varjo_ResetMirrorConfig()

void varjo_ResetMirrorConfig ( struct varjo_Session *  session)

Resets mirror config, effectively disabling mirror view feature.

Parameters
sessionVarjo session handle

◆ varjo_SetMirrorConfig()

void varjo_SetMirrorConfig ( struct varjo_Session *  session,
struct varjo_MirrorView mirrorViews,
uint32_t  count 
)

Configures where Compositor should render mirror views.

Multiple views are supported. varjo_MirrorView structures defines viewport where view should be rendered, and and index of the view.

Parameters
sessionVarjo session handle.
mirrorViewsstructs defining mirror views (viewport defines target viewports in a given swapchain, and viewIndex defines which view needs to be rendered (0 - left, 1 - right,) see varjo_GetViewCount() and varjo_GetViewDescription().
count

◆ varjo_VKCreateSwapChain()

struct varjo_SwapChain* varjo_VKCreateSwapChain ( struct varjo_Session *  session,
struct VkDevice_T *  device,
uint32_t  queueFamilyIndex,
uint32_t  queueIndex,
struct varjo_SwapChainConfig2 config 
)

Create a Vulkan 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.
deviceVulkan device, associated with physical device returned from varjo_GetPhysicalDeviceVk
queueFamilyIndexIndex of a Vulkan queue family that supports graphics operations
queueIndexIndex of a Vulkan queue within the family that will be used for image synchronization
configPointer to varjo_SwapChainConfig2 structure describing the swap chain configuration.
Returns
Pointer to a newly created varjo_SwapChain object, or nullptr on error.