// Copyright 2020, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 /*! * @file * @brief Abstracted compositor rendering target. * @author Jakob Bornecrantz * @ingroup comp_main */ #pragma once #include "xrt/xrt_compiler.h" #include "xrt/xrt_defines.h" #include "vk/vk_helpers.h" #ifdef __cplusplus extern "C" { #endif /*! * For marking timepoints on a frame's lifetime, not a async event. */ enum comp_target_timing_point { COMP_TARGET_TIMING_POINT_WAKE_UP, //init_pre_vulkan(ct); } /*! * @copydoc comp_target::init_post_vulkan * * @public @memberof comp_target * @ingroup comp_main */ static inline bool comp_target_init_post_vulkan(struct comp_target *ct, uint32_t preferred_width, uint32_t preferred_height) { return ct->init_post_vulkan(ct, preferred_width, preferred_height); } /*! * @copydoc comp_target::create_images * * @public @memberof comp_target * @ingroup comp_main */ static inline void comp_target_create_images(struct comp_target *ct, uint32_t preferred_width, uint32_t preferred_height, VkFormat preferred_color_format, VkColorSpaceKHR preferred_color_space, VkPresentModeKHR present_mode) { ct->create_images(ct, preferred_width, preferred_height, preferred_color_format, preferred_color_space, present_mode); } /*! * @copydoc comp_target::acquire * * @public @memberof comp_target * @ingroup comp_main */ static inline VkResult comp_target_acquire(struct comp_target *ct, VkSemaphore semaphore, uint32_t *out_index) { return ct->acquire(ct, semaphore, out_index); } /*! * @copydoc comp_target::present * * @public @memberof comp_target * @ingroup comp_main */ static inline VkResult comp_target_present(struct comp_target *ct, VkQueue queue, uint32_t index, VkSemaphore semaphore, uint64_t desired_present_time_ns, uint64_t present_slop_ns) { return ct->present( // ct, // queue, // index, // semaphore, // desired_present_time_ns, // present_slop_ns); // } /*! * @copydoc comp_target::flush * * @public @memberof comp_target * @ingroup comp_main */ static inline void comp_target_flush(struct comp_target *ct) { ct->flush(ct); } /*! * @copydoc comp_target::calc_frame_timings * * @public @memberof comp_target * @ingroup comp_main */ static inline void comp_target_calc_frame_timings(struct comp_target *ct, int64_t *out_frame_id, uint64_t *out_wake_up_time_ns, uint64_t *out_desired_present_time_ns, uint64_t *out_present_slop_ns, uint64_t *out_predicted_display_time_ns) { ct->calc_frame_timings( // ct, // out_frame_id, // out_wake_up_time_ns, // out_desired_present_time_ns, // out_present_slop_ns, // out_predicted_display_time_ns); // } /*! * Quick helper for marking wake up. * @copydoc comp_target::mark_timing_point * * @public @memberof comp_target * @ingroup comp_main */ static inline void comp_target_mark_wake_up(struct comp_target *ct, int64_t frame_id, uint64_t when_woke_ns) { ct->mark_timing_point(ct, COMP_TARGET_TIMING_POINT_WAKE_UP, frame_id, when_woke_ns); } /*! * Quick helper for marking begin. * @copydoc comp_target::mark_timing_point * * @public @memberof comp_target * @ingroup comp_main */ static inline void comp_target_mark_begin(struct comp_target *ct, int64_t frame_id, uint64_t when_began_ns) { ct->mark_timing_point(ct, COMP_TARGET_TIMING_POINT_BEGIN, frame_id, when_began_ns); } /*! * Quick helper for marking submit. * @copydoc comp_target::mark_timing_point * * @public @memberof comp_target * @ingroup comp_main */ static inline void comp_target_mark_submit(struct comp_target *ct, int64_t frame_id, uint64_t when_submitted_ns) { ct->mark_timing_point(ct, COMP_TARGET_TIMING_POINT_SUBMIT, frame_id, when_submitted_ns); } /*! * @copydoc comp_target::update_timings * * @public @memberof comp_target * @ingroup comp_main */ static inline VkResult comp_target_update_timings(struct comp_target *ct) { return ct->update_timings(ct); } /*! * @copydoc comp_target::set_title * * @public @memberof comp_target * @ingroup comp_main */ static inline void comp_target_set_title(struct comp_target *ct, const char *title) { ct->set_title(ct, title); } /*! * @copydoc comp_target::destroy * * Helper for calling through the function pointer: does a null check and sets * ct_ptr to null if freed. * * @public @memberof comp_target * @ingroup comp_main */ static inline void comp_target_destroy(struct comp_target **ct_ptr) { struct comp_target *ct = *ct_ptr; if (ct == NULL) { return; } ct->destroy(ct); *ct_ptr = NULL; } #ifdef __cplusplus } #endif