Monado OpenXR Runtime
render_gfx Struct Reference

The low-level resources and operations to perform layer squashing and/or mesh distortion for a single frame using graphics shaders. More...

#include <render/render_interface.h>

Collaboration diagram for render_gfx:

Public Member Functions

bool render_gfx_init (struct render_gfx *render, struct render_resources *r)
 Init struct and create resources needed for rendering. More...
 
bool render_gfx_begin (struct render_gfx *render)
 Begins the rendering, takes the vk_bundle's pool lock and leaves it locked. More...
 
bool render_gfx_end (struct render_gfx *render)
 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_fini (struct render_gfx *render)
 Frees all resources held by the rendering, does not free the struct itself. More...
 
Preparation functions - first stage
XRT_CHECK_RESULT VkResult render_gfx_mesh_alloc_and_write (struct render_gfx *render, 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...
 
XRT_CHECK_RESULT VkResult render_gfx_layer_cylinder_alloc_and_write (struct render_gfx *render, 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_layer_equirect2_alloc_and_write (struct render_gfx *render, 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_layer_projection_alloc_and_write (struct render_gfx *render, 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_layer_quad_alloc_and_write (struct render_gfx *render, 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...
 
Drawing functions - second stage
bool render_gfx_begin_target (struct render_gfx *render, struct render_gfx_target_resources *rtr, const VkClearColorValue *color)
 This function allocates everything to start a single rendering. More...
 
void render_gfx_end_target (struct render_gfx *render)
 
void render_gfx_begin_view (struct render_gfx *render, uint32_t view, const struct render_viewport_data *viewport_data)
 
void render_gfx_end_view (struct render_gfx *render)
 
void render_gfx_mesh_draw (struct render_gfx *render, 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...
 
void render_gfx_layer_cylinder (struct render_gfx *render, bool premultiplied_alpha, VkDescriptorSet descriptor_set)
 Dispatch a cylinder layer shader into the current target and view. More...
 
void render_gfx_layer_equirect2 (struct render_gfx *render, bool premultiplied_alpha, VkDescriptorSet descriptor_set)
 Dispatch a equirect2 layer shader into the current target and view. More...
 
void render_gfx_layer_projection (struct render_gfx *render, bool premultiplied_alpha, VkDescriptorSet descriptor_set)
 Dispatch a projection layer shader into the current target and view. More...
 
void render_gfx_layer_quad (struct render_gfx *render, bool premultiplied_alpha, VkDescriptorSet descriptor_set)
 Dispatch a quad layer shader into the current target and view. More...
 

Data Fields

struct render_resourcesr
 Resources that we are based on. More...
 
struct render_sub_alloc_tracker ubo_tracker
 Shared buffer that we sub-allocate UBOs from. More...
 
struct render_gfx_target_resourcesrtr
 The current target we are rendering to, can change during command building. More...
 

Detailed Description

The low-level resources and operations to perform layer squashing and/or mesh distortion for a single frame using graphics shaders.

It uses a two-stage process to render a frame. This means consumers iterate layers (or other operations) twice, within each target and view. There is a preparation stage, where the uniform buffer is sub-allocated and written. This must be completed for all layers before the actual draw stage begins. The second stage is recording the draw commands into a command buffer.

You must make equivalent calls in the same order between the two stages. The second stage additionally has render_gfx_begin_target, render_gfx_end_target, render_gfx_begin_view, and render_gfx_end_view lacked by the first stage, but if you exclude those functions, the others must line up.

Furthermore, the struct needs to be kept alive until the work has been waited on, or you get validation warnings. Either wait on the VkFence for the submit, or call vkDeviceWaitIdle/vkQueueWaitIdle on the device/queue.

See also
Comp_render_gfx

Field Documentation

◆ r

◆ rtr

◆ ubo_tracker

struct render_sub_alloc_tracker render_gfx::ubo_tracker

Shared buffer that we sub-allocate UBOs from.

Referenced by do_ubo_and_src_alloc_and_write(), and render_gfx_init().


The documentation for this struct was generated from the following file: