Commit 30a08e58 authored by Roman Gilg's avatar Roman Gilg

Use buf struct and flip buffers

parent 29ec0062
Pipeline #27076 failed with stages
in 2 minutes and 29 seconds
......@@ -90,43 +90,37 @@ present_comp_is_target(present_window_priv_ptr window_priv)
}
static void
present_comp_cleanup_auto_pixmap_front(present_window_priv_ptr window_priv)
present_comp_cleanup_auto_buf(present_auto_buf_ptr buf)
{
if (window_priv->auto_pixmap_front) {
if (window_priv->auto_driver_data_front) {
ScreenPtr screen = window_priv->window->drawable.pScreen;
present_screen_priv_ptr screen_priv = present_screen_priv(screen);
(*screen_priv->info->clear_pixmap)(window_priv->auto_driver_data_front);
window_priv->auto_driver_data_front = NULL;
} else {
present_pixmap_idle(window_priv->auto_pixmap_front,
window_priv->window,
window_priv->auto_serial_front,
window_priv->auto_idle_fence_front);
}
dixDestroyPixmap(window_priv->auto_pixmap_front, window_priv->auto_pixmap_front->drawable.id);
if (!buf->pixmap)
return;
if (buf->driver_data) {
ScreenPtr screen = buf->pixmap->drawable.pScreen;
present_screen_priv_ptr screen_priv = present_screen_priv(screen);
(*screen_priv->info->clear_pixmap)(buf->driver_data);
} else {
present_pixmap_idle(buf->pixmap,
buf->window,
buf->serial,
buf->idle_fence);
}
present_fence_destroy(window_priv->auto_idle_fence_front);
window_priv->auto_pixmap_front = NULL;
window_priv->auto_serial_front = 0;
window_priv->auto_idle_fence_front = NULL;
dixDestroyPixmap(buf->pixmap, buf->pixmap->drawable.id);
present_fence_destroy(buf->idle_fence);
memset(buf, 0, sizeof(present_auto_buf_rec));
}
static void
present_comp_cleanup_auto_pixmap_front(present_window_priv_ptr window_priv)
{
present_comp_cleanup_auto_buf(&window_priv->auto_bufs[0]);
}
static void
present_comp_cleanup_auto_pixmap_back(present_window_priv_ptr window_priv)
{
if (window_priv->auto_pixmap_back) {
present_pixmap_idle(window_priv->auto_pixmap_back,
window_priv->window,
window_priv->auto_serial_back,
window_priv->auto_idle_fence_back);
dixDestroyPixmap(window_priv->auto_pixmap_back, window_priv->auto_pixmap_back->drawable.id);
}
present_fence_destroy(window_priv->auto_idle_fence_back);
window_priv->auto_pixmap_back = NULL;
window_priv->auto_serial_back = 0;
window_priv->auto_idle_fence_back = NULL;
present_comp_cleanup_auto_buf(&window_priv->auto_bufs[1]);
}
static void
......@@ -141,9 +135,9 @@ present_comp_update_auto_pixmap_front(present_vblank_ptr vblank, present_window_
{
present_comp_cleanup_auto_pixmap_front(window_priv);
window_priv->auto_pixmap_front = vblank->pixmap;
window_priv->auto_serial_front = vblank->serial;
window_priv->auto_idle_fence_front = vblank->idle_fence;
window_priv->auto_bufs[0].pixmap = vblank->pixmap;
window_priv->auto_bufs[0].serial = vblank->serial;
window_priv->auto_bufs[0].idle_fence = vblank->idle_fence;
vblank->pixmap->refcnt++;
}
......@@ -172,7 +166,7 @@ present_comp_auto_client(present_vblank_ptr vblank)
if (!target_priv)
return FALSE;
if (!target_priv->auto_pixmap_front)
if (!target_priv->auto_bufs[1].pixmap)
return FALSE;
target_vblank = present_comp_queued(target_priv, vblank->target_msc);
......@@ -207,14 +201,14 @@ present_comp_auto_client(present_vblank_ptr vblank)
// present_copy_region(&window_priv->window->drawable, &vblank->pixmap->drawable, vblank->update, vblank->x_off, vblank->y_off);
// TODO: calculate x_off, y_off from window positions / difference
present_copy_region(&target_priv->auto_pixmap_front->drawable,
present_copy_region(&target_priv->auto_bufs[1].pixmap->drawable,
&vblank->pixmap->drawable,
NULL,
window_priv->window->drawable.x, window_priv->window->drawable.y);
/* Create a new internal Present run with the updated composite window */
screen_priv->present_pixmap(target,
target_priv->auto_pixmap_front,
target_priv->auto_bufs[1].pixmap,
0,
NULL,
NULL,
......@@ -251,7 +245,7 @@ present_comp_to_manager(present_window_priv_ptr window_priv)
{
ErrorF("present_comp_to_manager: window: %p\n", window_priv->window);
present_copy_region(&window_priv->window->drawable,
&window_priv->auto_pixmap_front->drawable,
&window_priv->auto_bufs[0].pixmap->drawable,
NULL,
window_priv->window->drawable.x, window_priv->window->drawable.y); // TODO: 0, 0?
......@@ -267,11 +261,11 @@ present_comp_auto_composite_client(present_vblank_ptr vblank, present_window_pri
{
DrawablePtr drawable = &window_priv->window->drawable;
if (window_priv->auto_pixmap_front)
drawable = &window_priv->auto_pixmap_front->drawable;
if (window_priv->auto_bufs[0].pixmap)
drawable = &window_priv->auto_bufs[0].pixmap->drawable;
window_priv->auto_scanout_target = vblank->window;
ErrorF("present_comp_auto_composite_client %p %p\n", window_priv->auto_pixmap_front, vblank->window);
ErrorF("present_comp_auto_composite_client %p %p\n", window_priv->auto_bufs[0].pixmap, vblank->window);
// TODO: calculate x_off, y_off from window positions / difference
present_copy_region(&vblank->pixmap->drawable,
......@@ -281,37 +275,52 @@ present_comp_auto_composite_client(present_vblank_ptr vblank, present_window_pri
}
static void
present_comp_update_auto_target(present_vblank_ptr vblank)
present_comp_setup_driver_buffer(present_vblank_ptr vblank, present_auto_buf_ptr buf)
{
ScreenPtr screen = vblank->screen;
present_screen_priv_ptr screen_priv = present_screen_priv(screen);
present_window_priv_ptr window_priv = present_window_priv(vblank->window);
/* Cleanup old front buffer. This is random,
* we could also set the back buffer and switch them.
*/
present_comp_cleanup_auto_pixmap_front(window_priv);
if (buf->pixmap) {
if (buf->pixmap->drawable.width == vblank->pixmap->drawable.width &&
buf->pixmap->drawable.height == vblank->pixmap->drawable.height) {
/* We can just reuse the current buffer. */
return;
}
present_comp_cleanup_auto_buf(buf);
}
/* Set new front buffer */
window_priv->auto_pixmap_front = (*screen_priv->info->create_pixmap)
/* Allocate new front buffer. */
buf->pixmap = (*screen_priv->info->create_pixmap)
(vblank->crtc,
window_priv->auto_driver_data_front,
buf->driver_data,
vblank->pixmap->drawable.width,
vblank->pixmap->drawable.height);
}
static void
present_comp_update_auto_target(present_vblank_ptr vblank)
{
present_window_priv_ptr window_priv = present_window_priv(vblank->window);
ErrorF("present_comp_update_auto_target: auto_pixmap_front: %p\n", window_priv->auto_pixmap_front);
present_comp_setup_driver_buffer(vblank, &window_priv->auto_bufs[0]);
present_comp_setup_driver_buffer(vblank, &window_priv->auto_bufs[1]);
if (!window_priv->auto_pixmap_front)
// TODO: error handling
if (!window_priv->auto_bufs[0].pixmap || !window_priv->auto_bufs[1].pixmap)
// TODO: error handling?
return;
present_copy_region(&window_priv->auto_pixmap_front->drawable,
ErrorF("present_comp_update_auto_target: auto_pixmap_front: %p\n", window_priv->auto_bufs[0].pixmap);
present_copy_region(&window_priv->auto_bufs[0].pixmap->drawable,
&vblank->pixmap->drawable,
NULL,
0, 0);
// window_priv->auto_serial_front = vblank->serial;
// window_priv->auto_idle_fence_front = vblank->idle_fence;
//TODO: don't do a second copy here?
present_copy_region(&window_priv->auto_bufs[1].pixmap->drawable,
&vblank->pixmap->drawable,
NULL,
0, 0);
}
/* On compositor Present execute auto composite client windows into it.
......@@ -323,7 +332,7 @@ present_comp_execute_target(present_vblank_ptr vblank)
present_window_priv_ptr window_priv, tmp;
ErrorF("present_comp_execute_target: window: %p\n", vblank->window);
ErrorF("present_comp_execute_target: is_target: %d auto_comp: %d auto_pixmap: %d\n", present_comp_is_target(target_priv), vblank->auto_comp, !!target_priv->auto_pixmap_front);
ErrorF("present_comp_execute_target: is_target: %d auto_comp: %d auto_pixmap: %d\n", present_comp_is_target(target_priv), vblank->auto_comp, !!target_priv->auto_bufs[0].pixmap);
if (!present_comp_is_target(target_priv))
return;
......@@ -332,23 +341,18 @@ present_comp_execute_target(present_vblank_ptr vblank)
/* vblank is product of an auto-composited client change, just
* switch around front and back buffers.
*/
assert(target_priv->auto_pixmap_front);
// assert(target_priv->auto_pixmap_back);
// assert(target_priv->auto_pixmap_back == vblank->pixmap);
// target_priv->auto_pixmap_back = target_priv->auto_pixmap_front;
// target_priv->auto_pixmap_front = vblank->pixmap;
present_auto_buf_rec buf_tmp;
// target_priv->auto_serial_back = target_priv->auto_serial_front;
// target_priv->auto_serial_front = vblank->serial;
assert(target_priv->auto_bufs[0].pixmap);
// target_priv->auto_idle_fence_back = target_priv->auto_idle_fence_front;
// target_priv->auto_idle_fence_front = vblank->idle_fence;
buf_tmp = target_priv->auto_bufs[0];
target_priv->auto_bufs[0] = target_priv->auto_bufs[1];
target_priv->auto_bufs[1] = buf_tmp;
return;
}
/* Update auto pixmap */
/* Update auto pixmaps. */
present_comp_update_auto_target(vblank);
// TODO: do this not here, but already earlier on present_comp_set_auto_list?
......@@ -377,14 +381,14 @@ present_comp_execute_target(present_vblank_ptr vblank)
}
static int
present_comp_set_parent_auto_list(present_window_priv_ptr parent, int nwindows, Window *windows)
present_comp_set_parent_auto_list(ClientPtr client, present_window_priv_ptr parent, int nwindows, Window *windows)
{
present_window_priv_ptr window_priv;
WindowPtr window;
int i, rc;
for (i = 0; i < nwindows; i++) {
rc = dixLookupWindow(&window, windows[i], NULL, DixReadAccess);
rc = dixLookupWindow(&window, windows[i], client, DixReadAccess);
if (rc != Success)
return rc;
......@@ -421,7 +425,7 @@ present_comp_set_auto_list(ClientPtr client, WindowPtr target, int nwindows, Win
/* reset the render list */
xorg_list_del(&target_priv->auto_render_head);
rc = present_comp_set_parent_auto_list(target_priv, nwindows, windows);
rc = present_comp_set_parent_auto_list(client, target_priv, nwindows, windows);
if (rc != Success)
xorg_list_del(&target_priv->auto_render_head);
......
......@@ -221,6 +221,15 @@ typedef struct present_event {
int mask;
} present_event_rec;
typedef struct present_auto_buf *present_auto_buf_ptr;
typedef struct present_auto_buf {
WindowPtr window;
PixmapPtr pixmap; /* Compositor copy for subsequent client updates */
CARD32 serial;
struct present_fence *idle_fence;
void *driver_data;
} present_auto_buf_rec;
struct present_window_priv {
WindowPtr window;
present_event_ptr events;
......@@ -240,14 +249,7 @@ struct present_window_priv {
WindowPtr auto_scanout_target;
WindowPtr auto_render_target;
PixmapPtr auto_pixmap_front; /* Compositor copy for subsequent client updates */
CARD32 auto_serial_front;
struct present_fence *auto_idle_fence_front;
void *auto_driver_data_front;
PixmapPtr auto_pixmap_back; /* Compositor copy for subsequent client updates */
CARD32 auto_serial_back;
struct present_fence *auto_idle_fence_back;
present_auto_buf_rec auto_bufs[2];
/* Used for window flips */
uint64_t event_id;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment