Monado OpenXR Runtime
|
CS renderer control and dispatch - uses compute shaders. More...
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... | |
CS renderer control and dispatch - uses compute shaders.
Depends on render_compute (often called crc
)
|
inlinestatic |
#include <compositor/util/comp_render.h>
Add view to the common data, as required by the CS renderer.
[in,out] | data | Common render dispatch data, will be updated |
world_pose | New world pose of this view. Populates comp_render_view_data::world_pose | |
eye_pose | New eye pose of this view Populates comp_render_view_data::eye_pose | |
fov | Assigned 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_data | Where in the image to render the view Populates comp_render_view_data::layer_viewport_data | |
layer_norm_rect | How to transform when sampling from the scratch image. Populates comp_render_view_data::layer_norm_rect | |
image | Scratch image for this view Populates comp_render_view_data::image | |
srgb_view | SRGB image view into the scratch image Populates comp_render_view_data::srgb_view | |
unorm_view | UNORM image view into the scratch image, CS specific | |
target_viewport_data | Distortion target viewport data (aka target) Populates comp_render_view_data::target_viewport_data |
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:
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
After call layouts:
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
VK_IMAGE_LAYOUT_PRESENT_SRC_KHR
layers
must implement comp_swapchain in addition to just xrt_swapchain, as this function downcasts to comp_swapchain !crc | Compute renderer object | |
[in] | layers | Layers to render, see note. |
[in] | layer_count | Number of elements in layers array. |
[in] | d | Common render dispatch data |
References comp_render_dispatch_data::fast_path.
|
inlinestatic |
#include <compositor/util/comp_render.h>
Initialize structure for use of the CS renderer.
data | Common render dispatch data. Will be zeroed and initialized. |
target_image | Image to render into |
target_unorm_view | Corresponding image view |
fast_path | Whether we will use the "fast path" avoiding layer squashing. |
do_timewarp | Whether timewarp (reprojection) will be performed. |
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:
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
VK_IMAGE_LAYOUT_GENERAL
layers
must implement comp_swapchain in addition to just xrt_swapchain, as this function downcasts to comp_swapchain !crc | Compute renderer object |
view_index | Index of the view |
layers | Layers to render, see note. |
layer_count | Number 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
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.
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 laying defined by transition_to
.
Expected layouts:
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
After call layouts:
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
transition_to
layers
must implement comp_swapchain in addition to just xrt_swapchain, as this function downcasts to comp_swapchain !crc | Compute renderer object | |
[in] | layers | Layers to render, see note. |
[in] | layer_count | Number of elements in layers array. |
[in] | d | Common render dispatch data |
[in] | transition_to | Desired image layout for target images |