mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-17 04:15:44 +00:00
xrt: Do not pass in timestate into compositor
This commit is contained in:
parent
dbb5bb2acb
commit
a925af90e7
|
@ -99,8 +99,8 @@ client_gl_compositor_end_session(struct xrt_compositor *xc)
|
|||
|
||||
static void
|
||||
client_gl_compositor_wait_frame(struct xrt_compositor *xc,
|
||||
int64_t *predicted_display_time,
|
||||
int64_t *predicted_display_period)
|
||||
uint64_t *predicted_display_time,
|
||||
uint64_t *predicted_display_period)
|
||||
{
|
||||
struct client_gl_compositor *c = client_gl_compositor(xc);
|
||||
// Pipe down call into fd compositor.
|
||||
|
|
|
@ -118,8 +118,8 @@ client_vk_compositor_end_session(struct xrt_compositor *xc)
|
|||
|
||||
static void
|
||||
client_vk_compositor_wait_frame(struct xrt_compositor *xc,
|
||||
int64_t *predicted_display_time,
|
||||
int64_t *predicted_display_period)
|
||||
uint64_t *predicted_display_time,
|
||||
uint64_t *predicted_display_period)
|
||||
{
|
||||
struct client_vk_compositor *c = client_vk_compositor(xc);
|
||||
// Pipe down call into fd compositor.
|
||||
|
|
|
@ -55,6 +55,8 @@
|
|||
|
||||
#include "main/comp_compositor.h"
|
||||
|
||||
#include "xrt/xrt_gfx_fd.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <math.h>
|
||||
|
||||
|
@ -128,7 +130,7 @@ static bool
|
|||
compositor_wait_vsync_or_time(struct comp_compositor *c, int64_t wake_up_time)
|
||||
{
|
||||
|
||||
int64_t now_ns = time_state_get_now(c->timekeeping);
|
||||
int64_t now_ns = os_monotonic_get_ns();
|
||||
/*!
|
||||
* @todo this is not accurate, but it serves the purpose of not letting
|
||||
* us sleep longer than the next vsync usually
|
||||
|
@ -152,15 +154,16 @@ compositor_wait_vsync_or_time(struct comp_compositor *c, int64_t wake_up_time)
|
|||
}
|
||||
// Busy-wait for fine-grained delays.
|
||||
while (now_ns < wake_up_time) {
|
||||
now_ns = time_state_get_now(c->timekeeping);
|
||||
now_ns = os_monotonic_get_ns();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
compositor_wait_frame(struct xrt_compositor *xc,
|
||||
int64_t *predicted_display_time,
|
||||
int64_t *predicted_display_period)
|
||||
uint64_t *predicted_display_time,
|
||||
uint64_t *predicted_display_period)
|
||||
{
|
||||
struct comp_compositor *c = comp_compositor(xc);
|
||||
COMP_SPEW(c, "WAIT_FRAME");
|
||||
|
@ -168,7 +171,7 @@ compositor_wait_frame(struct xrt_compositor *xc,
|
|||
// A little bit easier to read.
|
||||
int64_t interval_ns = (int64_t)c->settings.nominal_frame_interval_ns;
|
||||
|
||||
int64_t now_ns = time_state_get_now(c->timekeeping);
|
||||
int64_t now_ns = os_monotonic_get_ns();
|
||||
if (c->last_next_display_time == 0) {
|
||||
// First frame, we'll just assume we will display immediately
|
||||
|
||||
|
@ -216,7 +219,7 @@ compositor_begin_frame(struct xrt_compositor *xc)
|
|||
{
|
||||
struct comp_compositor *c = comp_compositor(xc);
|
||||
COMP_SPEW(c, "BEGIN_FRAME");
|
||||
c->app_profiling.last_begin = time_state_get_now(c->timekeeping);
|
||||
c->app_profiling.last_begin = os_monotonic_get_ns();
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -250,7 +253,7 @@ compositor_end_frame(struct xrt_compositor *xc,
|
|||
}
|
||||
|
||||
// Record the time of this frame.
|
||||
c->last_frame_time_ns = time_state_get_now(c->timekeeping);
|
||||
c->last_frame_time_ns = os_monotonic_get_ns();
|
||||
c->app_profiling.last_end = c->last_frame_time_ns;
|
||||
|
||||
//! @todo do a time-weighted average or something.
|
||||
|
@ -754,9 +757,7 @@ compositor_init_renderer(struct comp_compositor *c)
|
|||
|
||||
|
||||
struct xrt_compositor_fd *
|
||||
xrt_gfx_provider_create_fd(struct xrt_device *xdev,
|
||||
struct time_state *timekeeping,
|
||||
bool flip_y)
|
||||
xrt_gfx_provider_create_fd(struct xrt_device *xdev, bool flip_y)
|
||||
{
|
||||
struct comp_compositor *c = U_TYPED_CALLOC(struct comp_compositor);
|
||||
|
||||
|
@ -769,7 +770,6 @@ xrt_gfx_provider_create_fd(struct xrt_device *xdev,
|
|||
c->base.base.end_frame = compositor_end_frame;
|
||||
c->base.base.destroy = compositor_destroy;
|
||||
c->xdev = xdev;
|
||||
c->timekeeping = timekeeping;
|
||||
|
||||
COMP_DEBUG(c, "Doing init %p", (void *)c);
|
||||
|
||||
|
@ -777,7 +777,7 @@ xrt_gfx_provider_create_fd(struct xrt_device *xdev,
|
|||
comp_settings_init(&c->settings, xdev);
|
||||
|
||||
c->settings.flip_y = flip_y;
|
||||
c->last_frame_time_ns = time_state_get_now(c->timekeeping);
|
||||
c->last_frame_time_ns = os_monotonic_get_ns();
|
||||
c->frame_overhead_ns = 2000000;
|
||||
//! @todo set this to an estimate that's better than 6ms
|
||||
c->expected_app_duration_ns = 6000000;
|
||||
|
|
|
@ -82,9 +82,6 @@ struct comp_compositor
|
|||
//! The device we are displaying to.
|
||||
struct xrt_device *xdev;
|
||||
|
||||
//! The timekeeping state object.
|
||||
struct time_state *timekeeping;
|
||||
|
||||
//! The settings.
|
||||
struct comp_settings settings;
|
||||
|
||||
|
|
|
@ -169,8 +169,8 @@ struct xrt_compositor
|
|||
* See xrWaitFrame.
|
||||
*/
|
||||
void (*wait_frame)(struct xrt_compositor *xc,
|
||||
int64_t *predicted_display_time,
|
||||
int64_t *predicted_display_period);
|
||||
uint64_t *predicted_display_time,
|
||||
uint64_t *predicted_display_period);
|
||||
|
||||
/*!
|
||||
* See xrBeginFrame.
|
||||
|
@ -282,8 +282,8 @@ xrt_comp_end_session(struct xrt_compositor *xc)
|
|||
*/
|
||||
XRT_MAYBE_UNUSED static void
|
||||
xrt_comp_wait_frame(struct xrt_compositor *xc,
|
||||
int64_t *predicted_display_time,
|
||||
int64_t *predicted_display_period)
|
||||
uint64_t *predicted_display_time,
|
||||
uint64_t *predicted_display_period)
|
||||
{
|
||||
xc->wait_frame(xc, predicted_display_time, predicted_display_period);
|
||||
}
|
||||
|
|
|
@ -25,9 +25,7 @@ struct time_state;
|
|||
* @ingroup xrt_iface
|
||||
*/
|
||||
struct xrt_compositor_fd *
|
||||
xrt_gfx_provider_create_fd(struct xrt_device *xdev,
|
||||
struct time_state *timekeeping,
|
||||
bool flip_y);
|
||||
xrt_gfx_provider_create_fd(struct xrt_device *xdev, bool flip_y);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -396,9 +396,15 @@ oxr_session_frame_wait(struct oxr_logger *log,
|
|||
|
||||
struct xrt_compositor *xc = sess->compositor;
|
||||
if (xc != NULL) {
|
||||
xrt_comp_wait_frame(xc, &frameState->predictedDisplayTime,
|
||||
&frameState->predictedDisplayPeriod);
|
||||
uint64_t predicted_display_time;
|
||||
uint64_t predicted_display_period;
|
||||
xrt_comp_wait_frame(xc, &predicted_display_time,
|
||||
&predicted_display_period);
|
||||
|
||||
frameState->shouldRender = should_render(sess->state);
|
||||
frameState->predictedDisplayPeriod = predicted_display_period;
|
||||
frameState->predictedDisplayTime = time_state_from_monotonic_ns(
|
||||
sess->sys->inst->timekeeping, predicted_display_time);
|
||||
} else {
|
||||
frameState->shouldRender = XR_FALSE;
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ oxr_session_populate_egl(struct oxr_logger *log,
|
|||
}
|
||||
|
||||
struct xrt_compositor_fd *xcfd =
|
||||
xrt_gfx_provider_create_fd(sys->head, sys->inst->timekeeping, true);
|
||||
xrt_gfx_provider_create_fd(sys->head, true);
|
||||
if (xcfd == NULL) {
|
||||
return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED,
|
||||
" failed create a fd compositor");
|
||||
|
|
|
@ -32,7 +32,7 @@ oxr_session_populate_gl_xlib(struct oxr_logger *log,
|
|||
struct oxr_session *sess)
|
||||
{
|
||||
struct xrt_compositor_fd *xcfd =
|
||||
xrt_gfx_provider_create_fd(sys->head, sys->inst->timekeeping, true);
|
||||
xrt_gfx_provider_create_fd(sys->head, true);
|
||||
if (xcfd == NULL) {
|
||||
return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED,
|
||||
" failed create a fd compositor");
|
||||
|
|
|
@ -26,8 +26,8 @@ oxr_session_populate_vk(struct oxr_logger *log,
|
|||
XrGraphicsBindingVulkanKHR const *next,
|
||||
struct oxr_session *sess)
|
||||
{
|
||||
struct xrt_compositor_fd *xcfd = xrt_gfx_provider_create_fd(
|
||||
sys->head, sys->inst->timekeeping, false);
|
||||
struct xrt_compositor_fd *xcfd =
|
||||
xrt_gfx_provider_create_fd(sys->head, false);
|
||||
if (xcfd == NULL) {
|
||||
return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED,
|
||||
" failed create a fd compositor");
|
||||
|
|
Loading…
Reference in a new issue