Monado OpenXR Runtime
Loading...
Searching...
No Matches
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/u_debug.h"
#include "util/comp_render.h"
#include "util/comp_high_level_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 "vk/vk_submit_helpers.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <math.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...
 

Macros

#define LOG_FRAME_LAG(...)   U_LOG_IFL(debug_get_log_option_comp_frame_lag_level(), u_log_get_global_level(), __VA_ARGS__)
 
#define ADD_WAIT(LIST, SEMAPHORE, STAGE, IS_TIMELINE)
 
#define ADD_SIGNAL(LIST, SEMAPHORE, IS_TIMELINE)
 

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 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_scanout_begin[XRT_MAX_VIEWS], struct xrt_pose out_world_scanout_end[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.
 
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_wait_for_present (struct comp_renderer *r, uint64_t desired_present_time_ns)
 
static void renderer_fini (struct comp_renderer *r)
 
static XRT_CHECK_RESULT VkResult dispatch_graphics (struct comp_renderer *r, struct render_gfx *render, struct chl_frame_state *frame_state, enum comp_target_fov_source fov_source)
 
static XRT_CHECK_RESULT VkResult dispatch_compute (struct comp_renderer *r, struct render_compute *render, struct chl_frame_state *frame_state, 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

◆ ADD_SIGNAL

#define ADD_SIGNAL (   LIST,
  SEMAPHORE,
  IS_TIMELINE 
)
Value:
do { \
VkSemaphore _semaphore = SEMAPHORE; \
if (_semaphore != VK_NULL_HANDLE) { \
if (IS_TIMELINE) { \
vk_semaphore_list_signal_add_timeline(&LIST, _semaphore, (uint64_t)frame_id); \
} else { \
vk_semaphore_list_signal_add_binary(&LIST, _semaphore); \
} \
} \
} while (false)

◆ ADD_WAIT

#define ADD_WAIT (   LIST,
  SEMAPHORE,
  STAGE,
  IS_TIMELINE 
)
Value:
do { \
VkSemaphore _semaphore = SEMAPHORE; \
if (_semaphore != VK_NULL_HANDLE) { \
if (IS_TIMELINE) { \
vk_semaphore_list_wait_add_timeline(&LIST, _semaphore, (uint64_t)frame_id, STAGE); \
} else { \
vk_semaphore_list_wait_add_binary(&LIST, _semaphore, STAGE); \
} \
} \
} 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()

◆ comp_renderer_draw()

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

◆ dispatch_compute()

◆ dispatch_graphics()

static XRT_CHECK_RESULT VkResult dispatch_graphics ( struct comp_renderer r,
struct render_gfx render,
struct chl_frame_state frame_state,
enum comp_target_fov_source  fov_source 
)
static

◆ 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

◆ renderer_create_renderings_and_fences()

◆ renderer_init()

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