Monado OpenXR Runtime
render_interface.h File Reference

The NEW compositor rendering code header. More...

#include "xrt/xrt_compiler.h"
#include "xrt/xrt_defines.h"
#include "vk/vk_helpers.h"
#include "vk/vk_cmd_pool.h"
Include dependency graph for render_interface.h:

Go to the source code of this file.

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...
 

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...
 

Detailed Description