present: Move vblank functionality in seperate file

With the new internal flip mode API move vblank creation
and so on into a seperate file, such that it can be shared
between flip modes.

Signed-off-by: Roman Gilg <subdiff@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
This commit is contained in:
Roman Gilg 2018-03-13 16:00:36 +01:00 • committed by Adam Jackson
commit 5365ece70a
5 changed files with 261 additions and 143 deletions

View file

@ -46,17 +46,6 @@ static struct xorg_list present_flip_queue;
static void
present_execute(present_vblank_ptr vblank, uint64_t ust, uint64_t crtc_msc);
/*
* Returns:
* TRUE if the first MSC value is after the second one
* FALSE if the first MSC value is equal to or before the second one
*/
static Bool
msc_is_after(uint64_t test, uint64_t reference)
{
return (int64_t)(test - reference) > 0;
}
/*
* Returns:
* TRUE if the first MSC value is equal to or after the second one
@ -180,22 +169,6 @@ present_flip(RRCrtcPtr crtc,
return (*screen_priv->info->flip) (crtc, event_id, target_msc, pixmap, sync_flip);
}
static void
present_vblank_notify(present_vblank_ptr vblank, CARD8 kind, CARD8 mode, uint64_t ust, uint64_t crtc_msc)
{
int n;
if (vblank->window)
present_send_complete_notify(vblank->window, kind, mode, vblank->serial, ust, crtc_msc - vblank->msc_offset);
for (n = 0; n < vblank->num_notifies; n++) {
WindowPtr window = vblank->notifies[n].window;
CARD32 serial = vblank->notifies[n].serial;
if (window)
present_send_complete_notify(window, kind, mode, serial, ust, crtc_msc - vblank->msc_offset);
}
}
RRCrtcPtr
present_get_crtc(WindowPtr window)
{
@ -773,7 +746,6 @@ present_pixmap(WindowPtr window,
ScreenPtr screen = window->drawable.pScreen;
present_window_priv_ptr window_priv = present_get_window_priv(window, TRUE);
present_screen_priv_ptr screen_priv = present_screen_priv(screen);
PresentFlipReason reason = PRESENT_FLIP_REASON_UNKNOWN;
if (!window_priv)
return BadAlloc;
@ -854,81 +826,26 @@ present_pixmap(WindowPtr window,
}
}
vblank = calloc (1, sizeof (present_vblank_rec));
vblank = present_vblank_create(window,
pixmap,
serial,
valid,
update,
x_off,
y_off,
target_crtc,
wait_fence,
idle_fence,
options,
screen_priv->info ? &screen_priv->info->capabilities : NULL,
notifies,
num_notifies,
&target_msc,
crtc_msc);
if (!vblank)
return BadAlloc;
xorg_list_append(&vblank->window_list, &window_priv->vblank);
xorg_list_init(&vblank->event_queue);
vblank->screen = screen;
vblank->window = window;
vblank->pixmap = pixmap;
present_scmd_create_event_id(vblank);
if (pixmap) {
vblank->kind = PresentCompleteKindPixmap;
pixmap->refcnt++;
} else
vblank->kind = PresentCompleteKindNotifyMSC;
vblank->serial = serial;
if (valid) {
vblank->valid = RegionDuplicate(valid);
if (!vblank->valid)
goto no_mem;
}
if (update) {
vblank->update = RegionDuplicate(update);
if (!vblank->update)
goto no_mem;
}
vblank->x_off = x_off;
vblank->y_off = y_off;
vblank->target_msc = target_msc;
vblank->crtc = target_crtc;
vblank->msc_offset = window_priv->msc_offset;
vblank->notifies = notifies;
vblank->num_notifies = num_notifies;
vblank->has_suboptimal = (options & PresentOptionSuboptimal);
if (pixmap != NULL &&
!(options & PresentOptionCopy) &&
screen_priv->info) {
if (msc_is_after(target_msc, crtc_msc) &&
present_check_flip (target_crtc, window, pixmap, TRUE, valid, x_off, y_off, &reason))
{
vblank->flip = TRUE;
vblank->sync_flip = TRUE;
target_msc--;
} else if ((screen_priv->info->capabilities & PresentCapabilityAsync) &&
present_check_flip (target_crtc, window, pixmap, FALSE, valid, x_off, y_off, &reason))
{
vblank->flip = TRUE;
}
}
vblank->reason = reason;
if (wait_fence) {
vblank->wait_fence = present_fence_create(wait_fence);
if (!vblank->wait_fence)
goto no_mem;
}
if (idle_fence) {
vblank->idle_fence = present_fence_create(idle_fence);
if (!vblank->idle_fence)
goto no_mem;
}
if (pixmap)
DebugPresent(("q %lld %p %8lld: %08lx -> %08lx (crtc %p) flip %d vsync %d serial %d\n",
vblank->event_id, vblank, target_msc,
vblank->pixmap->drawable.id, vblank->window->drawable.id,
target_crtc, vblank->flip, vblank->sync_flip, vblank->serial));
xorg_list_append(&vblank->event_queue, &present_exec_queue);
vblank->queued = TRUE;
if (msc_is_after(target_msc, crtc_msc)) {
@ -942,12 +859,6 @@ present_pixmap(WindowPtr window,
present_execute(vblank, ust, crtc_msc);
return Success;
no_mem:
ret = BadAlloc;
vblank->notifies = NULL;
present_vblank_destroy(vblank);
return ret;
}
void
@ -1012,39 +923,6 @@ present_flip_destroy(ScreenPtr screen)
present_flip_idle(screen);
}
void
present_vblank_destroy(present_vblank_ptr vblank)
{
/* Remove vblank from window and screen lists */
xorg_list_del(&vblank->window_list);
DebugPresent(("\td %lld %p %8lld: %08lx -> %08lx\n",
vblank->event_id, vblank, vblank->target_msc,
vblank->pixmap ? vblank->pixmap->drawable.id : 0,
vblank->window ? vblank->window->drawable.id : 0));
/* Drop pixmap reference */
if (vblank->pixmap)
dixDestroyPixmap(vblank->pixmap, vblank->pixmap->drawable.id);
/* Free regions */
if (vblank->valid)
RegionDestroy(vblank->valid);
if (vblank->update)
RegionDestroy(vblank->update);
if (vblank->wait_fence)
present_fence_destroy(vblank->wait_fence);
if (vblank->idle_fence)
present_fence_destroy(vblank->idle_fence);
if (vblank->notifies)
present_destroy_notifies(vblank->notifies, vblank->num_notifies);
free(vblank);
}
void
present_scmd_init_mode_hooks(present_screen_priv_ptr screen_priv)
{