Monado OpenXR Runtime
|
Rendering helper that is used by the compositor to render. More...
Modules | |
Comp_render_gfx | |
GFX renderer control and dispatch - uses graphics shaders. | |
Comp_render_cs | |
CS renderer control and dispatch - uses compute shaders. | |
Files | |
file | render_buffer.c |
Buffer functions. | |
file | render_compute.c |
The compositor compute based rendering code. | |
file | render_distortion.c |
Code for handling distortion resources (not shaders). | |
file | render_gfx.c |
The NEW compositor rendering code header. | |
file | render_interface.h |
The NEW compositor rendering code header. | |
file | render_resources.c |
Shared resources for rendering. | |
file | render_shaders.c |
Shader loading code. | |
file | render_sub_alloc.c |
Sub allocation functions. | |
file | render_util.c |
The compositor compute based rendering code. | |
Data Structures | |
struct | render_shaders |
Holds all shaders. More... | |
struct | render_buffer |
Helper struct holding a buffer and its memory. More... | |
struct | render_sub_alloc |
Per frame sub-allocation into a buffer, used to reduce the number of UBO objects we need to create. More... | |
struct | render_sub_alloc_tracker |
A per-frame tracker of sub-allocation out of a buffer, used to reduce the number of UBO objects we need to create. More... | |
struct | render_resources |
Holds all pools and static resources for rendering. More... | |
struct | render_scratch_color_image |
Small helper struct to hold a scratch image, intended to be used with the compute pipeline where both srgb and unorm views are needed. More... | |
struct | render_scratch_images |
Helper struct to hold scratch images. More... | |
struct | render_viewport_data |
The pure data information about a view that the renderer is rendering to. More... | |
struct | render_gfx_render_pass |
A render pass while not depending on a VkFramebuffer does depend on the format of the target image(s), and other options for the render pass. More... | |
struct | render_gfx_target_resources |
Each rendering (render_gfx) render to one or more targets (render_gfx_target_resources), the target points to one render pass and its pipelines (render_gfx_render_pass). More... | |
struct | render_gfx |
A rendering is used to create command buffers needed to do one frame of compositor rendering, it holds onto resources used by the command buffer. More... | |
struct | render_gfx_mesh_ubo_data |
UBO data that is sent to the mesh shaders. More... | |
struct | render_gfx_layer_cylinder_data |
UBO data that is sent to the layer cylinder shader. More... | |
struct | render_gfx_layer_equirect2_data |
UBO data that is sent to the layer equirect2 shader. More... | |
struct | render_gfx_layer_projection_data |
UBO data that is sent to the layer projection shader. More... | |
struct | render_gfx_layer_quad_data |
UBO data that is sent to the layer quad shader. More... | |
struct | render_compute |
A compute rendering is used to create command buffers needed to do one frame of compositor rendering using compute shaders, it holds onto resources used by the command buffer. More... | |
struct | render_compute_blit_push_data |
Push data that is sent to the blit shader. More... | |
struct | render_compute_layer_ubo_data |
UBO data that is sent to the compute layer shaders. More... | |
struct | render_compute_distortion_ubo_data |
UBO data that is sent to the compute distortion shaders. More... | |
struct | comp_render_view_data |
The input data needed for a single view, shared between both GFX and CS paths. More... | |
struct | comp_render_dispatch_data |
The input data needed for a complete layer squashing distortion rendering to a target. More... | |
Macros | |
#define | RENDER_ALWAYS_SAFE_UBO_ALIGNMENT (256) |
The value minUniformBufferOffsetAlignment is defined by the Vulkan spec as having a max value of 256. More... | |
#define | RENDER_MAX_LAYERS (XRT_MAX_LAYERS) |
Max number of layers for layer squasher, can be different from XRT_MAX_LAYERS as the render module is separate from the compositor. More... | |
#define | RENDER_MAX_IMAGES_SIZE (RENDER_MAX_LAYERS * XRT_MAX_VIEWS) |
Max number of images that can be given at a single time to the layer squasher in a single dispatch. More... | |
#define | RENDER_MAX_IMAGES_COUNT (RENDER_MAX_LAYERS * r->view_count) |
#define | RENDER_MAX_LAYER_RUNS_SIZE (XRT_MAX_VIEWS) |
Maximum number of times that the layer squasher shader can run per render_compute. More... | |
#define | RENDER_MAX_LAYER_RUNS_COUNT (r->view_count) |
#define | RENDER_DISTORTION_IMAGE_DIMENSIONS (128) |
Distortion image dimension in pixels. More... | |
#define | RENDER_DISTORTION_IMAGES_SIZE (3 * XRT_MAX_VIEWS) |
How many distortion images we have, one for each channel (3 rgb) and per view. More... | |
#define | RENDER_DISTORTION_IMAGES_COUNT (3 * r->view_count) |
#define | RENDER_BINDING_LAYER_SHARED_UBO 0 |
The binding that the layer projection and quad shader have their UBO on. More... | |
#define | RENDER_BINDING_LAYER_SHARED_SRC 1 |
The binding that the shared layer fragment shader has its source on. More... | |
Functions | |
void | render_calc_time_warp_matrix (const struct xrt_pose *src_pose, const struct xrt_fov *src_fov, const struct xrt_pose *new_pose, struct xrt_matrix_4x4 *matrix) |
Calculates a timewarp matrix which takes in NDC coords and gives out results in [-1, 1] space that needs a perspective divide. More... | |
void | render_calc_uv_to_tangent_lengths_rect (const struct xrt_fov *fov, struct xrt_normalized_rect *out_rect) |
This function constructs a transformation in the form of a normalized rect that lets you go from a UV coordinate on a projection plane to the a point on the tangent plane. More... | |
bool | render_shaders_load (struct render_shaders *s, struct vk_bundle *vk) |
Loads all of the shaders that the compositor uses. More... | |
void | render_shaders_close (struct render_shaders *s, struct vk_bundle *vk) |
Unload and cleanup shaders. More... | |
VkResult | render_buffer_init (struct vk_bundle *vk, struct render_buffer *buffer, VkBufferUsageFlags usage_flags, VkMemoryPropertyFlags memory_property_flags, VkDeviceSize size) |
Initialize a buffer. More... | |
VkResult | render_buffer_init_exportable (struct vk_bundle *vk, struct render_buffer *buffer, VkBufferUsageFlags usage_flags, VkMemoryPropertyFlags memory_property_flags, VkDeviceSize size) |
Initialize a buffer, making it exportable. More... | |
void | render_buffer_close (struct vk_bundle *vk, struct render_buffer *buffer) |
Frees all resources that this buffer has, but does not free the buffer itself. More... | |
VkResult | render_buffer_map (struct vk_bundle *vk, struct render_buffer *buffer) |
Maps the memory, sets render_buffer::mapped to the memory. More... | |
void | render_buffer_unmap (struct vk_bundle *vk, struct render_buffer *buffer) |
Unmaps the memory. More... | |
VkResult | render_buffer_map_and_write (struct vk_bundle *vk, struct render_buffer *buffer, void *data, VkDeviceSize size) |
Maps the buffer, and copies the given data to the buffer. More... | |
VkResult | render_buffer_write (struct vk_bundle *vk, struct render_buffer *buffer, void *data, VkDeviceSize size) |
Writes the given data to the buffer, will map it temporarily if not mapped. More... | |
void | render_sub_alloc_tracker_init (struct render_sub_alloc_tracker *rsat, struct render_buffer *buffer) |
Init a render_sub_alloc_tracker struct from a render_buffer, the caller is responsible for keeping buffer alive while the sub allocator is being used. More... | |
XRT_CHECK_RESULT VkResult | render_sub_alloc_ubo_alloc_and_get_ptr (struct vk_bundle *vk, struct render_sub_alloc_tracker *rsat, VkDeviceSize size, void **out_ptr, struct render_sub_alloc *out_rsa) |
Allocate enough memory (with constraints of UBOs) of size , return the pointer to the mapped memory or null if the buffer wasn't allocated. More... | |
XRT_CHECK_RESULT VkResult | render_sub_alloc_ubo_alloc_and_write (struct vk_bundle *vk, struct render_sub_alloc_tracker *rsat, const void *ptr, VkDeviceSize size, struct render_sub_alloc *out_rsa) |
Allocate enough memory (with constraints of UBOs) to hold the memory in ptr and copy that memory to the buffer using the CPU. More... | |
void | render_resources::render_resources_close (struct render_resources *r) |
Free all pools and static resources, does not free the struct itself. More... | |
bool | render_resources::render_distortion_images_ensure (struct render_resources *r, struct vk_bundle *vk, struct xrt_device *xdev, bool pre_rotate) |
Creates or recreates the compute distortion textures if necessary. More... | |
void | render_resources::render_distortion_images_close (struct render_resources *r) |
Free distortion images. More... | |
bool | render_resources::render_resources_get_timestamps (struct render_resources *r, uint64_t *out_gpu_start_ns, uint64_t *out_gpu_end_ns) |
Returns the timestamps for when the latest GPU work started and stopped that was submitted using render_gfx or render_compute cmd buf builders. More... | |
bool | render_resources::render_resources_get_duration (struct render_resources *r, uint64_t *out_gpu_duration_ns) |
Returns the duration for the latest GPU work that was submitted using render_gfx or render_compute cmd buf builders. More... | |
bool | render_scratch_images::render_scratch_images_ensure (struct render_resources *r, struct render_scratch_images *rsi, VkExtent2D extent) |
Ensure that the scratch images are created and have the given extent. More... | |
void | render_scratch_images::render_scratch_images_close (struct render_resources *r, struct render_scratch_images *rsi) |
Close all resources on the given render_scratch_images. More... | |
bool | render_gfx_render_pass::render_gfx_render_pass_init (struct render_gfx_render_pass *rgrp, struct render_resources *r, VkFormat format, VkAttachmentLoadOp load_op, VkImageLayout final_layout) |
Creates all resources held by the render pass. More... | |
void | render_gfx_render_pass::render_gfx_render_pass_close (struct render_gfx_render_pass *rgrp) |
Frees all resources held by the render pass, does not free the struct itself. More... | |
bool | render_gfx_target_resources::render_gfx_target_resources_init (struct render_gfx_target_resources *rtr, struct render_resources *r, struct render_gfx_render_pass *rgrp, VkImageView target, VkExtent2D extent) |
Init a target resource struct, caller has to keep target alive until closed. More... | |
void | render_gfx_target_resources::render_gfx_target_resources_close (struct render_gfx_target_resources *rtr) |
Frees all resources held by the target, does not free the struct itself. More... | |
bool | render_gfx::render_gfx_init (struct render_gfx *rr, struct render_resources *r) |
Init struct and create resources needed for rendering. More... | |
bool | render_gfx::render_gfx_begin (struct render_gfx *rr) |
Begins the rendering, takes the vk_bundle's pool lock and leaves it locked. More... | |
bool | render_gfx::render_gfx_end (struct render_gfx *rr) |
Frees any unneeded resources and ends the command buffer so it can be used, also unlocks the vk_bundle's pool lock that was taken by begin. More... | |
void | render_gfx::render_gfx_fini (struct render_gfx *rr) |
Frees all resources held by the rendering, does not free the struct itself. More... | |
bool | render_compute::render_compute_init (struct render_compute *crc, struct render_resources *r) |
Init struct and create resources needed for compute rendering. More... | |
void | render_compute::render_compute_fini (struct render_compute *crc) |
Frees all resources held by the compute rendering, does not free the struct itself. More... | |
bool | render_compute::render_compute_begin (struct render_compute *crc) |
Begin the compute command buffer building, takes the vk_bundle's pool lock and leaves it locked. More... | |
bool | render_compute::render_compute_end (struct render_compute *crc) |
Frees any unneeded resources and ends the command buffer so it can be used, also unlocks the vk_bundle's pool lock that was taken by begin. More... | |
void | render_compute::render_compute_layers (struct render_compute *crc, VkDescriptorSet descriptor_set, VkBuffer ubo, VkSampler src_samplers[((XRT_MAX_LAYERS) *XRT_MAX_VIEWS)], VkImageView src_image_views[((XRT_MAX_LAYERS) *XRT_MAX_VIEWS)], uint32_t num_srcs, VkImageView target_image_view, const struct render_viewport_data *view, bool timewarp) |
Updates the given descriptor_set and dispatches the layer shader. More... | |
void | render_compute::render_compute_projection_timewarp (struct render_compute *crc, VkSampler src_samplers[XRT_MAX_VIEWS], VkImageView src_image_views[XRT_MAX_VIEWS], const struct xrt_normalized_rect src_rects[XRT_MAX_VIEWS], const struct xrt_pose src_poses[XRT_MAX_VIEWS], const struct xrt_fov src_fovs[XRT_MAX_VIEWS], const struct xrt_pose new_poses[XRT_MAX_VIEWS], VkImage target_image, VkImageView target_image_view, const struct render_viewport_data views[XRT_MAX_VIEWS]) |
void | render_compute::render_compute_projection (struct render_compute *crc, VkSampler src_samplers[XRT_MAX_VIEWS], VkImageView src_image_views[XRT_MAX_VIEWS], const struct xrt_normalized_rect src_rects[XRT_MAX_VIEWS], VkImage target_image, VkImageView target_image_view, const struct render_viewport_data views[XRT_MAX_VIEWS]) |
void | render_compute::render_compute_clear (struct render_compute *crc, VkImage target_image, VkImageView target_image_view, const struct render_viewport_data views[XRT_MAX_VIEWS]) |
Drawing functions | |
bool | render_gfx::render_gfx_begin_target (struct render_gfx *rr, struct render_gfx_target_resources *rtr, const VkClearColorValue *color) |
This function allocates everything to start a single rendering. More... | |
void | render_gfx::render_gfx_end_target (struct render_gfx *rr) |
void | render_gfx::render_gfx_begin_view (struct render_gfx *rr, uint32_t view, const struct render_viewport_data *viewport_data) |
void | render_gfx::render_gfx_end_view (struct render_gfx *rr) |
XRT_CHECK_RESULT VkResult | render_gfx::render_gfx_mesh_alloc_and_write (struct render_gfx *rr, const struct render_gfx_mesh_ubo_data *data, VkSampler src_sampler, VkImageView src_image_view, VkDescriptorSet *out_descriptor_set) |
Allocate needed resources for one mesh shader dispatch, will also update the descriptor set, UBO will be filled out with the given data argument. More... | |
void | render_gfx::render_gfx_mesh_draw (struct render_gfx *rr, uint32_t mesh_index, VkDescriptorSet descriptor_set, bool do_timewarp) |
Dispatch one mesh shader instance, using the give mesh_index as source for mesh geometry, timewarp selectable via do_timewarp . More... | |
XRT_CHECK_RESULT VkResult | render_gfx::render_gfx_layer_cylinder_alloc_and_write (struct render_gfx *rr, const struct render_gfx_layer_cylinder_data *data, VkSampler src_sampler, VkImageView src_image_view, VkDescriptorSet *out_descriptor_set) |
Allocate and write a UBO and descriptor_set to be used for cylinder layer rendering, the content of data need to be valid at the time of the call. More... | |
XRT_CHECK_RESULT VkResult | render_gfx::render_gfx_layer_equirect2_alloc_and_write (struct render_gfx *rr, const struct render_gfx_layer_equirect2_data *data, VkSampler src_sampler, VkImageView src_image_view, VkDescriptorSet *out_descriptor_set) |
Allocate and write a UBO and descriptor_set to be used for equirect2 layer rendering, the content of data need to be valid at the time of the call. More... | |
XRT_CHECK_RESULT VkResult | render_gfx::render_gfx_layer_projection_alloc_and_write (struct render_gfx *rr, const struct render_gfx_layer_projection_data *data, VkSampler src_sampler, VkImageView src_image_view, VkDescriptorSet *out_descriptor_set) |
Allocate and write a UBO and descriptor_set to be used for projection layer rendering, the content of data need to be valid at the time of the call. More... | |
XRT_CHECK_RESULT VkResult | render_gfx::render_gfx_layer_quad_alloc_and_write (struct render_gfx *rr, const struct render_gfx_layer_quad_data *data, VkSampler src_sampler, VkImageView src_image_view, VkDescriptorSet *out_descriptor_set) |
Allocate and write a UBO and descriptor_set to be used for quad layer rendering, the content of data need to be valid at the time of the call. More... | |
void | render_gfx::render_gfx_layer_cylinder (struct render_gfx *rr, bool premultiplied_alpha, VkDescriptorSet descriptor_set) |
Dispatch a cylinder layer shader into the current target and view, allocate descriptor_set and ubo with render_gfx_layer_cylinder_alloc_and_write. More... | |
void | render_gfx::render_gfx_layer_equirect2 (struct render_gfx *rr, bool premultiplied_alpha, VkDescriptorSet descriptor_set) |
Dispatch a equirect2 layer shader into the current target and view, allocate descriptor_set and ubo with render_gfx_layer_equirect2_alloc_and_write. More... | |
void | render_gfx::render_gfx_layer_projection (struct render_gfx *rr, bool premultiplied_alpha, VkDescriptorSet descriptor_set) |
Dispatch a projection layer shader into the current target and view, allocate descriptor_set and ubo with render_gfx_layer_projection_alloc_and_write. More... | |
void | render_gfx::render_gfx_layer_quad (struct render_gfx *rr, bool premultiplied_alpha, VkDescriptorSet descriptor_set) |
Dispatch a quad layer shader into the current target and view, allocate descriptor_set and ubo with render_gfx_layer_quad_alloc_and_write. More... | |
Rendering helper that is used by the compositor to render.
Renders, aka "layer squashers" and distortion application.
Two parallel implementations of the render module exist:
Their abilities are effectively equivalent, although the graphics version disregards depth data, while the compute shader does use it somewhat.
#define RENDER_ALWAYS_SAFE_UBO_ALIGNMENT (256) |
#include <compositor/render/render_interface.h>
The value minUniformBufferOffsetAlignment
is defined by the Vulkan spec as having a max value of 256.
Use this value to safely figure out sizes and alignment of UBO sub-allocation. It is also the max for 'nonCoherentAtomSize` which if we need to do flushing is what we need to align UBOs to.
https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkPhysicalDeviceLimits.html https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#limits-minmax
#define RENDER_BINDING_LAYER_SHARED_SRC 1 |
#include <compositor/render/render_interface.h>
The binding that the shared layer fragment shader has its source on.
#define RENDER_BINDING_LAYER_SHARED_UBO 0 |
#include <compositor/render/render_interface.h>
The binding that the layer projection and quad shader have their UBO on.
#define RENDER_DISTORTION_IMAGE_DIMENSIONS (128) |
#include <compositor/render/render_interface.h>
Distortion image dimension in pixels.
#define RENDER_DISTORTION_IMAGES_SIZE (3 * XRT_MAX_VIEWS) |
#include <compositor/render/render_interface.h>
How many distortion images we have, one for each channel (3 rgb) and per view.
#define RENDER_MAX_IMAGES_SIZE (RENDER_MAX_LAYERS * XRT_MAX_VIEWS) |
#include <compositor/render/render_interface.h>
Max number of images that can be given at a single time to the layer squasher in a single dispatch.
#define RENDER_MAX_LAYER_RUNS_SIZE (XRT_MAX_VIEWS) |
#include <compositor/render/render_interface.h>
Maximum number of times that the layer squasher shader can run per render_compute.
Since you run the layer squasher shader once per view this is essentially the same as number of views. But if you were to do two or more different compositions it is not the maximum number of views per composition (which is this number divided by number of composition).
#define RENDER_MAX_LAYERS (XRT_MAX_LAYERS) |
#include <compositor/render/render_interface.h>
Max number of layers for layer squasher, can be different from XRT_MAX_LAYERS as the render module is separate from the compositor.
void render_buffer_close | ( | struct vk_bundle * | vk, |
struct render_buffer * | buffer | ||
) |
#include <compositor/render/render_interface.h>
Frees all resources that this buffer has, but does not free the buffer itself.
References render_buffer::buffer, D, DF, render_buffer::memory, and U_ZERO.
Referenced by render_resources::render_resources_close().
VkResult render_buffer_init | ( | struct vk_bundle * | vk, |
struct render_buffer * | buffer, | ||
VkBufferUsageFlags | usage_flags, | ||
VkMemoryPropertyFlags | memory_property_flags, | ||
VkDeviceSize | size | ||
) |
#include <compositor/render/render_interface.h>
Initialize a buffer.
VkResult render_buffer_init_exportable | ( | struct vk_bundle * | vk, |
struct render_buffer * | buffer, | ||
VkBufferUsageFlags | usage_flags, | ||
VkMemoryPropertyFlags | memory_property_flags, | ||
VkDeviceSize | size | ||
) |
#include <compositor/render/render_interface.h>
Initialize a buffer, making it exportable.
References vk_cb_get_buffer_external_handle_type().
VkResult render_buffer_map | ( | struct vk_bundle * | vk, |
struct render_buffer * | buffer | ||
) |
#include <compositor/render/render_interface.h>
Maps the memory, sets render_buffer::mapped to the memory.
References render_buffer::memory.
VkResult render_buffer_map_and_write | ( | struct vk_bundle * | vk, |
struct render_buffer * | buffer, | ||
void * | data, | ||
VkDeviceSize | size | ||
) |
#include <compositor/render/render_interface.h>
Maps the buffer, and copies the given data to the buffer.
void render_buffer_unmap | ( | struct vk_bundle * | vk, |
struct render_buffer * | buffer | ||
) |
#include <compositor/render/render_interface.h>
Unmaps the memory.
References render_buffer::memory.
VkResult render_buffer_write | ( | struct vk_bundle * | vk, |
struct render_buffer * | buffer, | ||
void * | data, | ||
VkDeviceSize | size | ||
) |
#include <compositor/render/render_interface.h>
Writes the given data to the buffer, will map it temporarily if not mapped.
void render_calc_time_warp_matrix | ( | const struct xrt_pose * | src_pose, |
const struct xrt_fov * | src_fov, | ||
const struct xrt_pose * | new_pose, | ||
struct xrt_matrix_4x4 * | matrix | ||
) |
#include <compositor/render/render_interface.h>
Calculates a timewarp matrix which takes in NDC coords and gives out results in [-1, 1] space that needs a perspective divide.
References calc_projection(), xrt_matrix_4x4_f64::m_mat4_f64_invert(), xrt_matrix_4x4_f64::m_mat4_f64_multiply(), and xrt_matrix_4x4_f64::m_mat4_f64_orientation().
void render_calc_uv_to_tangent_lengths_rect | ( | const struct xrt_fov * | fov, |
struct xrt_normalized_rect * | out_rect | ||
) |
#include <compositor/render/render_interface.h>
This function constructs a transformation in the form of a normalized rect that lets you go from a UV coordinate on a projection plane to the a point on the tangent plane.
An example is that the UV coordinate (0, 0)
would be transformed to (tan(angle_left), tan(fov.angle_up))
. The tangent plane (aka tangent space) is really the tangent of the angle, aka length at unit distance.
For the trivial case of an fov with 45 degrees angles, that is where the tangent length are 1
(aka tan(45)
), the transformation would go from [0 .. 1]
to [-1 .. 1]
the expected returns are x = -1
, y = -1
, w = 2
and h = 2
.
param fov The fov of the projection image. param[out] out_rect Transformation from UV to tangent lengths.
bool render_compute_begin | ( | struct render_compute * | crc | ) |
Begin the compute command buffer building, takes the vk_bundle's pool lock and leaves it locked.
References render_resources::cmd, render_compute::r, VK_CHK_WITH_RET, and vk_from_crc().
bool render_compute_end | ( | struct render_compute * | crc | ) |
Frees any unneeded resources and ends the command buffer so it can be used, also unlocks the vk_bundle's pool lock that was taken by begin.
References render_resources::cmd, render_compute::r, VK_CHK_WITH_RET, and vk_from_crc().
void render_compute_fini | ( | struct render_compute * | crc | ) |
Frees all resources held by the compute rendering, does not free the struct itself.
References ARRAY_SIZE, render_resources::descriptor_pool, render_compute::layer_descriptor_sets, render_compute::r, render_compute::shared_descriptor_set, and vk_from_crc().
bool render_compute_init | ( | struct render_compute * | crc, |
struct render_resources * | r | ||
) |
Init struct and create resources needed for compute rendering.
References render_compute::r, and render_resources::vk.
void render_compute_layers | ( | struct render_compute * | crc, |
VkDescriptorSet | descriptor_set, | ||
VkBuffer | ubo, | ||
VkSampler | src_samplers[((XRT_MAX_LAYERS) *XRT_MAX_VIEWS)], | ||
VkImageView | src_image_views[((XRT_MAX_LAYERS) *XRT_MAX_VIEWS)], | ||
uint32_t | num_srcs, | ||
VkImageView | target_image_view, | ||
const struct render_viewport_data * | view, | ||
bool | timewarp | ||
) |
Updates the given descriptor_set
and dispatches the layer shader.
Unlike other dispatch functions below this function doesn't do any layer barriers before or after dispatching, this is to allow the callee to batch any such image transitions.
Expected layouts:
void render_distortion_images_close | ( | struct render_resources * | r | ) |
Free distortion images.
References render_resources::vk.
Referenced by render_resources::render_distortion_images_ensure(), and render_resources::render_resources_close().
bool render_distortion_images_ensure | ( | struct render_resources * | r, |
struct vk_bundle * | vk, | ||
struct xrt_device * | xdev, | ||
bool | pre_rotate | ||
) |
Creates or recreates the compute distortion textures if necessary.
References render_resources::image_views, render_resources::pre_rotated, and render_resources::render_distortion_images_close().
bool render_gfx_begin | ( | struct render_gfx * | rr | ) |
Begins the rendering, takes the vk_bundle's pool lock and leaves it locked.
References render_resources::cmd, render_gfx::r, VK_CHK_WITH_RET, and vk_from_rr().
bool render_gfx_begin_target | ( | struct render_gfx * | rr, |
struct render_gfx_target_resources * | rtr, | ||
const VkClearColorValue * | color | ||
) |
This function allocates everything to start a single rendering.
This is the first function you call when you start rendering, you follow up with a call to render_gfx_begin_view.
References render_gfx_target_resources::framebuffer, render_gfx_render_pass::render_pass, render_gfx_target_resources::rgrp, render_gfx::rtr, and vk_from_rr().
bool render_gfx_end | ( | struct render_gfx * | rr | ) |
Frees any unneeded resources and ends the command buffer so it can be used, also unlocks the vk_bundle's pool lock that was taken by begin.
References render_resources::cmd, render_gfx::r, VK_CHK_WITH_RET, and vk_from_rr().
void render_gfx_fini | ( | struct render_gfx * | rr | ) |
Frees all resources held by the rendering, does not free the struct itself.
References render_gfx::r, U_ZERO, render_resources::ubo_and_src_descriptor_pool, render_resources::vk, and vk_from_rr().
bool render_gfx_init | ( | struct render_gfx * | rr, |
struct render_resources * | r | ||
) |
Init struct and create resources needed for rendering.
References render_gfx::r, render_sub_alloc_tracker_init(), render_resources::shared_ubo, and render_gfx::ubo_tracker.
void render_gfx_layer_cylinder | ( | struct render_gfx * | rr, |
bool | premultiplied_alpha, | ||
VkDescriptorSet | descriptor_set | ||
) |
Dispatch a cylinder layer shader into the current target and view, allocate descriptor_set
and ubo with render_gfx_layer_cylinder_alloc_and_write.
References render_resources::pipeline, render_gfx_target_resources::rgrp, and render_gfx::rtr.
XRT_CHECK_RESULT VkResult render_gfx_layer_cylinder_alloc_and_write | ( | struct render_gfx * | rr, |
const struct render_gfx_layer_cylinder_data * | data, | ||
VkSampler | src_sampler, | ||
VkImageView | src_image_view, | ||
VkDescriptorSet * | out_descriptor_set | ||
) |
Allocate and write a UBO and descriptor_set to be used for cylinder layer rendering, the content of data
need to be valid at the time of the call.
void render_gfx_layer_equirect2 | ( | struct render_gfx * | rr, |
bool | premultiplied_alpha, | ||
VkDescriptorSet | descriptor_set | ||
) |
Dispatch a equirect2 layer shader into the current target and view, allocate descriptor_set
and ubo with render_gfx_layer_equirect2_alloc_and_write.
References render_resources::pipeline, render_gfx_target_resources::rgrp, and render_gfx::rtr.
XRT_CHECK_RESULT VkResult render_gfx_layer_equirect2_alloc_and_write | ( | struct render_gfx * | rr, |
const struct render_gfx_layer_equirect2_data * | data, | ||
VkSampler | src_sampler, | ||
VkImageView | src_image_view, | ||
VkDescriptorSet * | out_descriptor_set | ||
) |
Allocate and write a UBO and descriptor_set to be used for equirect2 layer rendering, the content of data
need to be valid at the time of the call.
void render_gfx_layer_projection | ( | struct render_gfx * | rr, |
bool | premultiplied_alpha, | ||
VkDescriptorSet | descriptor_set | ||
) |
Dispatch a projection layer shader into the current target and view, allocate descriptor_set
and ubo with render_gfx_layer_projection_alloc_and_write.
References render_resources::pipeline, render_gfx_target_resources::rgrp, and render_gfx::rtr.
XRT_CHECK_RESULT VkResult render_gfx_layer_projection_alloc_and_write | ( | struct render_gfx * | rr, |
const struct render_gfx_layer_projection_data * | data, | ||
VkSampler | src_sampler, | ||
VkImageView | src_image_view, | ||
VkDescriptorSet * | out_descriptor_set | ||
) |
Allocate and write a UBO and descriptor_set to be used for projection layer rendering, the content of data
need to be valid at the time of the call.
void render_gfx_layer_quad | ( | struct render_gfx * | rr, |
bool | premultiplied_alpha, | ||
VkDescriptorSet | descriptor_set | ||
) |
Dispatch a quad layer shader into the current target and view, allocate descriptor_set
and ubo with render_gfx_layer_quad_alloc_and_write.
References render_resources::pipeline, render_gfx_target_resources::rgrp, and render_gfx::rtr.
XRT_CHECK_RESULT VkResult render_gfx_layer_quad_alloc_and_write | ( | struct render_gfx * | rr, |
const struct render_gfx_layer_quad_data * | data, | ||
VkSampler | src_sampler, | ||
VkImageView | src_image_view, | ||
VkDescriptorSet * | out_descriptor_set | ||
) |
Allocate and write a UBO and descriptor_set to be used for quad layer rendering, the content of data
need to be valid at the time of the call.
XRT_CHECK_RESULT VkResult render_gfx_mesh_alloc_and_write | ( | struct render_gfx * | rr, |
const struct render_gfx_mesh_ubo_data * | data, | ||
VkSampler | src_sampler, | ||
VkImageView | src_image_view, | ||
VkDescriptorSet * | out_descriptor_set | ||
) |
Allocate needed resources for one mesh shader dispatch, will also update the descriptor set, UBO will be filled out with the given data
argument.
Uses the render_sub_alloc_tracker of the render_gfx and the descriptor pool of render_resources, both of which will be reset once closed, so don't save any reference to these objects beyond the frame.
void render_gfx_mesh_draw | ( | struct render_gfx * | rr, |
uint32_t | mesh_index, | ||
VkDescriptorSet | descriptor_set, | ||
bool | do_timewarp | ||
) |
Dispatch one mesh shader instance, using the give mesh_index
as source for mesh geometry, timewarp selectable via do_timewarp
.
References ARRAY_SIZE, render_buffer::buffer, render_resources::cmd, render_resources::pipeline, render_gfx_render_pass::pipeline, render_resources::pipeline_layout, render_gfx_render_pass::pipeline_timewarp, render_gfx::r, render_gfx_target_resources::rgrp, render_gfx::rtr, render_resources::vk, and vk_from_rr().
void render_gfx_render_pass_close | ( | struct render_gfx_render_pass * | rgrp | ) |
Frees all resources held by the render pass, does not free the struct itself.
References D, render_gfx_render_pass::pipeline, render_gfx_render_pass::pipeline_timewarp, render_gfx_render_pass::render_pass, U_ZERO, and render_resources::vk.
bool render_gfx_render_pass_init | ( | struct render_gfx_render_pass * | rgrp, |
struct render_resources * | r, | ||
VkFormat | format, | ||
VkAttachmentLoadOp | load_op, | ||
VkImageLayout | final_layout | ||
) |
Creates all resources held by the render pass.
References render_resources::vk.
Referenced by renderer_create_renderings_and_fences().
void render_gfx_target_resources_close | ( | struct render_gfx_target_resources * | rtr | ) |
Frees all resources held by the target, does not free the struct itself.
References D, render_gfx_target_resources::framebuffer, U_ZERO, and vk_from_rtr().
bool render_gfx_target_resources_init | ( | struct render_gfx_target_resources * | rtr, |
struct render_resources * | r, | ||
struct render_gfx_render_pass * | rgrp, | ||
VkImageView | target, | ||
VkExtent2D | extent | ||
) |
Init a target resource struct, caller has to keep target alive until closed.
References render_gfx_target_resources::r, and render_resources::vk.
void render_resources_close | ( | struct render_resources * | r | ) |
Free all pools and static resources, does not free the struct itself.
References render_resources::clamp_to_border_black, render_resources::clamp_to_edge, D, render_resources::descriptor_pool, render_resources::descriptor_set_layout, DF, render_resources::distortion_pool, render_resources::mock, render_resources::non_timewarp_pipeline, render_resources::pipeline, render_resources::pipeline_cache, render_resources::pipeline_layout, render_buffer_close(), render_resources::render_distortion_images_close(), render_resources::repeat, render_resources::shared_ubo, render_resources::timewarp_pipeline, render_resources::ubo, render_resources::ubo_and_src_descriptor_pool, render_resources::ubos, render_resources::view_count, render_resources::vk, and vk_cmd_pool::vk_cmd_pool_destroy().
bool render_resources_get_duration | ( | struct render_resources * | r, |
uint64_t * | out_gpu_duration_ns | ||
) |
Returns the duration for the latest GPU work that was submitted using render_gfx or render_compute cmd buf builders.
Behaviour for this function is undefined if the GPU has not completed before calling this function, so make sure to call vkQueueWaitIdle or wait on the fence that the work was submitted with have fully completed.
References vk_bundle::timestamp_period, and render_resources::vk.
bool render_resources_get_timestamps | ( | struct render_resources * | r, |
uint64_t * | out_gpu_start_ns, | ||
uint64_t * | out_gpu_end_ns | ||
) |
Returns the timestamps for when the latest GPU work started and stopped that was submitted using render_gfx or render_compute cmd buf builders.
Returned in the same time domain as returned by os_monotonic_get_ns . Behaviour for this function is undefined if the GPU has not completed before calling this function, so make sure to call vkQueueWaitIdle or wait on the fence that the work was submitted with have fully completed. See other limitation mentioned for vk_convert_timestamps_to_host_ns .
References render_resources::vk, and vk_convert_timestamps_to_host_ns().
void render_scratch_images_close | ( | struct render_resources * | r, |
struct render_scratch_images * | rsi | ||
) |
Close all resources on the given render_scratch_images.
References render_resources::view_count, and render_resources::vk.
Referenced by render_scratch_images::render_scratch_images_ensure().
bool render_scratch_images_ensure | ( | struct render_resources * | r, |
struct render_scratch_images * | rsi, | ||
VkExtent2D | extent | ||
) |
Ensure that the scratch images are created and have the given extent.
References render_scratch_images::render_scratch_images_close(), and render_resources::view_count.
void render_shaders_close | ( | struct render_shaders * | s, |
struct vk_bundle * | vk | ||
) |
bool render_shaders_load | ( | struct render_shaders * | s, |
struct vk_bundle * | vk | ||
) |
#include <compositor/render/render_interface.h>
Loads all of the shaders that the compositor uses.
void render_sub_alloc_tracker_init | ( | struct render_sub_alloc_tracker * | rsat, |
struct render_buffer * | buffer | ||
) |
#include <compositor/render/render_interface.h>
Init a render_sub_alloc_tracker struct from a render_buffer, the caller is responsible for keeping buffer
alive while the sub allocator is being used.
References render_buffer::buffer, render_sub_alloc_tracker::buffer, render_sub_alloc_tracker::mapped, render_buffer::size, render_sub_alloc_tracker::total_size, and render_sub_alloc_tracker::used.
Referenced by render_gfx::render_gfx_init().
XRT_CHECK_RESULT VkResult render_sub_alloc_ubo_alloc_and_get_ptr | ( | struct vk_bundle * | vk, |
struct render_sub_alloc_tracker * | rsat, | ||
VkDeviceSize | size, | ||
void ** | out_ptr, | ||
struct render_sub_alloc * | out_rsa | ||
) |
#include <compositor/render/render_interface.h>
Allocate enough memory (with constraints of UBOs) of size
, return the pointer to the mapped memory or null if the buffer wasn't allocated.
References render_sub_alloc_tracker::total_size, and render_sub_alloc_tracker::used.
XRT_CHECK_RESULT VkResult render_sub_alloc_ubo_alloc_and_write | ( | struct vk_bundle * | vk, |
struct render_sub_alloc_tracker * | rsat, | ||
const void * | ptr, | ||
VkDeviceSize | size, | ||
struct render_sub_alloc * | out_rsa | ||
) |
#include <compositor/render/render_interface.h>
Allocate enough memory (with constraints of UBOs) to hold the memory in ptr
and copy that memory to the buffer using the CPU.
References render_sub_alloc_tracker::mapped.
Referenced by do_ubo_and_src_alloc_and_write().