Monado OpenXR Runtime
comp_renderer.c File Reference

Compositor rendering code. More...

#include "render/render_interface.h"
#include "xrt/xrt_defines.h"
#include "xrt/xrt_frame.h"
#include "xrt/xrt_compositor.h"
#include "xrt/xrt_results.h"
#include "os/os_time.h"
#include "math/m_api.h"
#include "math/m_matrix_2x2.h"
#include "math/m_space.h"
#include "util/u_misc.h"
#include "util/u_trace_marker.h"
#include "util/u_distortion_mesh.h"
#include "util/u_sink.h"
#include "util/u_var.h"
#include "util/u_frame_times_widget.h"
#include "util/comp_render.h"
#include "main/comp_frame.h"
#include "main/comp_mirror_to_debug_gui.h"
#include "vk/vk_helpers.h"
#include "vk/vk_cmd.h"
#include "vk/vk_image_readback_to_xf_pool.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <math.h>
#include <inttypes.h>
Include dependency graph for comp_renderer.c:

Data Structures

struct  comp_renderer
 Holds associated vulkan objects and state to render with a distortion. More...
 
struct  comp_scratch_view_state
 
struct  comp_render_scratch_state
 

Macros

#define CHAIN(STRUCT, NEXT)
 
#define WAIT_SEMAPHORE_COUNT   1
 

Enumerations

enum  comp_target_fov_source { COMP_TARGET_FOV_SOURCE_DISTORTION , COMP_TARGET_FOV_SOURCE_DEVICE_VIEWS }
 What is the source of the FoV values used for the final image that the compositor produces and is sent to the hardware (or software). More...
 

Functions

static void scratch_get_init (struct comp_render_scratch_state *crss, struct comp_renderer *r, uint32_t view_count)
 
static void scratch_get_fini (struct comp_render_scratch_state *crss, struct comp_renderer *r, uint32_t view_count)
 
static void renderer_wait_queue_idle (struct comp_renderer *r)
 
static void calc_viewport_data (struct comp_renderer *r, struct render_viewport_data out_viewport_data[XRT_MAX_VIEWS], size_t view_count)
 
static void calc_vertex_rot_data (struct comp_renderer *r, struct xrt_matrix_2x2 out_vertex_rots[XRT_MAX_VIEWS], size_t view_count)
 
static void calc_pose_data (struct comp_renderer *r, enum comp_target_fov_source fov_source, struct xrt_fov out_fovs[XRT_MAX_VIEWS], struct xrt_pose out_world[XRT_MAX_VIEWS], struct xrt_pose out_eye[XRT_MAX_VIEWS], uint32_t view_count)
 
static void renderer_build_rendering_target_resources (struct comp_renderer *r, struct render_gfx_target_resources *rtr, uint32_t index)
 
static void renderer_create_renderings_and_fences (struct comp_renderer *r)
 
static void renderer_close_renderings_and_fences (struct comp_renderer *r)
 
static void renderer_init (struct comp_renderer *r, struct comp_compositor *c, VkExtent2D scratch_extent)
 Create renderer and initialize non-image-dependent members. More...
 
static void renderer_wait_for_last_fence (struct comp_renderer *r)
 
static XRT_CHECK_RESULT VkResult renderer_submit_queue (struct comp_renderer *r, VkCommandBuffer cmd, VkPipelineStageFlags pipeline_stage_flag)
 
static void renderer_acquire_swapchain_image (struct comp_renderer *r)
 
static void renderer_resize (struct comp_renderer *r)
 
static void renderer_present_swapchain_image (struct comp_renderer *r, uint64_t desired_present_time_ns, uint64_t present_slop_ns)
 
static void renderer_fini (struct comp_renderer *r)
 
static XRT_CHECK_RESULT VkResult dispatch_graphics (struct comp_renderer *r, struct render_gfx *rr, struct comp_render_scratch_state *crss, enum comp_target_fov_source fov_source)
 
static XRT_CHECK_RESULT VkResult dispatch_compute (struct comp_renderer *r, struct render_compute *crc, struct comp_render_scratch_state *crss, enum comp_target_fov_source fov_source)
 
XRT_CHECK_RESULT xrt_result_t comp_renderer_draw (struct comp_renderer *r)
 
struct comp_renderercomp_renderer_create (struct comp_compositor *c, VkExtent2D scratch_extent)
 
void comp_renderer_destroy (struct comp_renderer **ptr_r)
 
void comp_renderer_add_debug_vars (struct comp_renderer *self)
 

Detailed Description

Macro Definition Documentation

◆ CHAIN

#define CHAIN (   STRUCT,
  NEXT 
)
Value:
do { \
(STRUCT).pNext = NEXT; \
NEXT = (VkBaseInStructure *)&(STRUCT); \
} while (false)

Enumeration Type Documentation

◆ comp_target_fov_source

What is the source of the FoV values used for the final image that the compositor produces and is sent to the hardware (or software).

Enumerator
COMP_TARGET_FOV_SOURCE_DISTORTION 

The FoV values used for the final target is taken from the distortion information on the xrt_hmd_parts struct.

COMP_TARGET_FOV_SOURCE_DEVICE_VIEWS 

The FoV values used for the final target is taken from the those returned from the device's get_views.

Function Documentation

◆ calc_pose_data()

static void calc_pose_data ( struct comp_renderer r,
enum comp_target_fov_source  fov_source,
struct xrt_fov  out_fovs[XRT_MAX_VIEWS],
struct xrt_pose  out_world[XRT_MAX_VIEWS],
struct xrt_pose  out_eye[XRT_MAX_VIEWS],
uint32_t  view_count 
)
static
Todo:
get actual ipd_meters

◆ comp_renderer_draw()

XRT_CHECK_RESULT xrt_result_t comp_renderer_draw ( struct comp_renderer r)
Todo:
This should be discard.

◆ dispatch_compute()

static XRT_CHECK_RESULT VkResult dispatch_compute ( struct comp_renderer r,
struct render_compute crc,
struct comp_render_scratch_state crss,
enum comp_target_fov_source  fov_source 
)
static
Precondition
render_compute_init(crc, &c->nr)

◆ dispatch_graphics()

static XRT_CHECK_RESULT VkResult dispatch_graphics ( struct comp_renderer r,
struct render_gfx rr,
struct comp_render_scratch_state crss,
enum comp_target_fov_source  fov_source 
)
static
Precondition
render_gfx_init(rr, &c->nr)

◆ renderer_build_rendering_target_resources()

static void renderer_build_rendering_target_resources ( struct comp_renderer r,
struct render_gfx_target_resources rtr,
uint32_t  index 
)
static
Precondition
comp_target_has_images(r->c->target)

Referenced by renderer_create_renderings_and_fences().

◆ renderer_create_renderings_and_fences()

◆ renderer_init()

static void renderer_init ( struct comp_renderer r,
struct comp_compositor c,
VkExtent2D  scratch_extent 
)
static

Create renderer and initialize non-image-dependent members.

Referenced by comp_renderer::comp_renderer_create().