Monado OpenXR Runtime

CS renderer control and dispatch - uses compute shaders. More...

Collaboration diagram for Comp_render_cs:

Functions

static void comp_render_cs_initial_init (struct comp_render_dispatch_data *data, VkImage target_image, VkImageView target_unorm_view, bool fast_path, bool do_timewarp)
 Initialize structure for use of the CS renderer. More...
 
static void comp_render_cs_add_view (struct comp_render_dispatch_data *data, const struct xrt_pose *world_pose, const struct xrt_pose *eye_pose, const struct xrt_fov *fov, const struct render_viewport_data *layer_viewport_data, const struct xrt_normalized_rect *layer_norm_rect, VkImage image, VkImageView srgb_view, VkImageView unorm_view, const struct render_viewport_data *target_viewport_data)
 Add view to the common data, as required by the CS renderer. More...
 
void comp_render_cs_layer (struct render_compute *crc, uint32_t view_index, const struct comp_layer *layers, const uint32_t layer_count, const struct xrt_normalized_rect *pre_transform, const struct xrt_pose *world_pose, const struct xrt_pose *eye_pose, const VkImage target_image, const VkImageView target_image_view, const struct render_viewport_data *target_view, bool do_timewarp)
 Dispatch the layer squasher for a single view. More...
 
void comp_render_cs_layers (struct render_compute *crc, const struct comp_layer *layers, const uint32_t layer_count, const struct comp_render_dispatch_data *d, VkImageLayout transition_to)
 Dispatch the layer squasher, on any number of views. More...
 
void comp_render_cs_dispatch (struct render_compute *crc, const struct comp_layer *layers, const uint32_t layer_count, const struct comp_render_dispatch_data *d)
 Write commands to crc to do a full composition with distortion. More...
 

Detailed Description

CS renderer control and dispatch - uses compute shaders.

Depends on render_compute (often called crc)

Function Documentation

◆ comp_render_cs_add_view()

static void comp_render_cs_add_view ( struct comp_render_dispatch_data data,
const struct xrt_pose world_pose,
const struct xrt_pose eye_pose,
const struct xrt_fov fov,
const struct render_viewport_data layer_viewport_data,
const struct xrt_normalized_rect layer_norm_rect,
VkImage  image,
VkImageView  srgb_view,
VkImageView  unorm_view,
const struct render_viewport_data target_viewport_data 
)
inlinestatic

#include <compositor/util/comp_render.h>

Add view to the common data, as required by the CS renderer.

Parameters
[in,out]dataCommon render dispatch data, will be updated
world_poseNew world pose of this view. Populates comp_render_view_data::world_pose
eye_poseNew eye pose of this view Populates comp_render_view_data::eye_pose
fovAssigned to fov in the view data, and used to compute comp_render_view_data::target_pre_transform Populates comp_render_view_data::fov
layer_viewport_dataWhere in the image to render the view Populates comp_render_view_data::layer_viewport_data
layer_norm_rectHow to transform when sampling from the scratch image. Populates comp_render_view_data::layer_norm_rect
imageScratch image for this view Populates comp_render_view_data::image
srgb_viewSRGB image view into the scratch image Populates comp_render_view_data::srgb_view
unorm_viewUNORM image view into the scratch image, CS specific
target_viewport_dataDistortion target viewport data (aka target) Populates comp_render_view_data::target_viewport_data

◆ comp_render_cs_dispatch()

void comp_render_cs_dispatch ( struct render_compute crc,
const struct comp_layer layers,
const uint32_t  layer_count,
const struct comp_render_dispatch_data d 
)

#include <compositor/util/comp_render.h>

Write commands to crc to do a full composition with distortion.

Helper function that takes a set of layers, new device poses, a scratch images and writes the needed commands to the render_compute to do a full composition with distortion. The scratch images are optionally used to squash layers should it not be possible to do a fast_path. Will insert barriers to change the scratch images and target images to the needed layout.

Expected layouts:

  • Layer images: VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
  • Scratch images: Any
  • Target image: Any

After call layouts:

  • Layer images: VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
  • Scratch images: VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
  • Target image: VK_IMAGE_LAYOUT_PRESENT_SRC_KHR
Note
Swapchains in the layers must implement comp_swapchain in addition to just xrt_swapchain, as this function downcasts to comp_swapchain !
Parameters
crcCompute renderer object
[in]layersLayers to render, see note.
[in]layer_countNumber of elements in layers array.
[in]dCommon render dispatch data

References comp_render_dispatch_data::fast_path.

◆ comp_render_cs_initial_init()

static void comp_render_cs_initial_init ( struct comp_render_dispatch_data data,
VkImage  target_image,
VkImageView  target_unorm_view,
bool  fast_path,
bool  do_timewarp 
)
inlinestatic

#include <compositor/util/comp_render.h>

Initialize structure for use of the CS renderer.

Parameters
dataCommon render dispatch data. Will be zeroed and initialized.
target_imageImage to render into
target_unorm_viewCorresponding image view
fast_pathWhether we will use the "fast path" avoiding layer squashing.
do_timewarpWhether timewarp (reprojection) will be performed.

◆ comp_render_cs_layer()

void comp_render_cs_layer ( struct render_compute crc,
uint32_t  view_index,
const struct comp_layer layers,
const uint32_t  layer_count,
const struct xrt_normalized_rect pre_transform,
const struct xrt_pose world_pose,
const struct xrt_pose eye_pose,
const VkImage  target_image,
const VkImageView  target_image_view,
const struct render_viewport_data target_view,
bool  do_timewarp 
)

#include <compositor/util/comp_render.h>

Dispatch the layer squasher for a single view.

All source layer images and target image needs to be in the correct image layout, no barrier is inserted at all. The view_index argument is needed to grab a pre-allocated UBO from the render_resources and to correctly select left/right data from various layers.

Expected layouts:

  • Layer images: VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
  • Target images: VK_IMAGE_LAYOUT_GENERAL
Note
Swapchains in the layers must implement comp_swapchain in addition to just xrt_swapchain, as this function downcasts to comp_swapchain !
Parameters
crcCompute renderer object
view_indexIndex of the view
layersLayers to render, see note.
layer_countNumber of elements in layers array.
pre_transform
world_pose
eye_pose
target_image
target_image_view
target_view
do_timewarp

Stop compositing layers if device's sampled image limit is reached. For most hardware this isn't a problem, most have well over 32 max samplers. But notably the RPi4 only have 16 which is a limit we may run into. But if you got 16+ layers on a RPi4 you have more problems then max samplers.

Exit loop if shader cannot receive more image samplers

Todo:
: If Vulkan 1.2, use VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT and skip this

References render_resources::clamp_to_border_black, render_resources::clamp_to_edge, xrt_matrix_4x4::math_matrix_4x4_view_from_pose(), render_compute::r, RENDER_MAX_IMAGES_SIZE, and render_resources::ubos.

◆ comp_render_cs_layers()

void comp_render_cs_layers ( struct render_compute crc,
const struct comp_layer layers,
const uint32_t  layer_count,
const struct comp_render_dispatch_data d,
VkImageLayout  transition_to 
)

#include <compositor/util/comp_render.h>

Dispatch the layer squasher, on any number of views.

All source layer images needs to be in the correct image layout, no barrier is inserted for them. The target images are barriered from undefined to general so they can be written to, then to the layout defined by transition_to.

Expected layouts:

  • Layer images: VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
  • Target images: Any

After call layouts:

  • Layer images: VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
  • Target images: transition_to
Note
Swapchains in the layers must implement comp_swapchain in addition to just xrt_swapchain, as this function downcasts to comp_swapchain !
Parameters
crcCompute renderer object
[in]layersLayers to render, see note.
[in]layer_countNumber of elements in layers array.
[in]dCommon render dispatch data
[in]transition_toDesired image layout for target images