Fwd: [PATCH 5/5] xwayland: Pixmap flips of child windows on sub-surfaces

2017-08-30 Thread Roman Gilg
Sorry, apparently I didn't understand your explanation the last time. Can
you explain why non-Present requests need to see the sub-surface contents?
And how they see the contents of normal Wayland surfaces?

I don't see much of a difference in here. Both objects are black boxes in
terms of X and the only interfaces are input events and buffer content
delivery.


On Wed, Aug 30, 2017 at 4:10 AM, Michel Dänzer  wrote:

> On 30/08/17 12:24 AM, Roman Gilg wrote:
> > This patch enables Pixmap flips for child windows via Wayland
> > sub-surfaces.
>
> That can't be done so easily for the reasons I've explained before
> (basically, non-Present requests would need to "see" the subsurface
> contents as well), so I'm afraid I have to NAK this patch in this form.
>
>
> --
> Earthling Michel Dänzer   |   http://www.amd.com
> Libre software enthusiast | Mesa and X developer
>
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH 4/5] xwayland: Use Present's flips per window mode

2017-08-30 Thread Roman Gilg
I reread the mail by Pekka from the last mail chain and apparently have
remembered it wrong. I thought he said that it's fine the way I did it.
What I could do instead as he explained, is listen for the wl_display.sync
callback after each buffer commit in xwayland-present.c.

That would mean at this point the Wayland server has processed the commit
request and at some later point will eventually display the buffer on the
screen (as long as Xwayland doesn't commit a new buffer before that).

On Wed, Aug 30, 2017 at 4:34 AM, Michel Dänzer  wrote:

> On 30/08/17 12:24 AM, Roman Gilg wrote:
> >
> > There is a small change to the window mode in Present as well, that now
> > calls flip_executed at the end of processing the flip with the
> > calculated damage. Xwayland then commits the new buffer.
>
> As discussed before, I'd prefer if Xwayland instead only called
> present_event_notify once it's received some kind of feedback from the
> Wayland compositor that it has processed the "flip". There's no such
> thing as an "immediate flip".
>
>
> --
> Earthling Michel Dänzer   |   http://www.amd.com
> Libre software enthusiast | Mesa and X developer
>
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH 3/5] present: Add mode for pixmap flips per window

2017-08-30 Thread Roman Gilg
On Wed, Aug 30, 2017 at 4:35 AM, Michel Dänzer  wrote:

> On 30/08/17 12:24 AM, Roman Gilg wrote:
> > This patch adds a new mode to the internal flip mode API, that
> > enables per window flips on capable hardware platforms.
> >
> > Pixmap flips are possible for every window with a parent window and
> > without redirection.
>
> This sentence is a bit confusing. In rootless mode, a toplevel window
> has no parent, but may use flips, right?


The restriction to only allow a window W with a parent to flip is there, so
that we can use the parent window's window pixmap on unflip to restore W's
window pixmap. It was somewhat a late addition to the code because I had
problems with "saving" W's original pixmap. Basically I increased the saved
pixmap's refcnt when doing that, but on restore this pixmap often was
already unreffed by the original creator. So I had to add a condition to
only unref in Present for recnt > 1 (otherwise the pixmap would have been
freed afterwards and could not act as the window pixmap after unflip).

To remove this condition I opted for only allowing window flips for windows
with parent. In this case it's clear what to restore: The parent window's
window pixmap. I did this because in my test applications (only tested with
KWin though) a window requesting pixmap flips never was the toplevel
window, so I assumed in this case the restriction is not limiting.

What could be added in the future is a condition to save the original
window's pixmap in the case of windows without parent and otherwise restore
from the parent window's window pixmap.

> Besides the per window flips the new mode diverges from the old
> > screen flipping by holding back the PresentIdleNotify event for a
> > flipped pixmaps of a preceding frame until present_winmode_event_notify
> > is called once more.
>
> As discussed before, this should be kept separate from the flip mode, as
> it would also be useful with per-screen flips.
>
> My suggestion was to add a PresentCapability* flag for this. If the
> driver sets this flag, it will call present_event_notify separately when
> the flip completes for the target CRTC and when the previous buffer can
> be re-used.


With the new flip mode API it is easy to add this functionality to screen
flip mode later on - and share the code with the window flip mode if
applicable. I just did it not yet with this patch set to leave the screen
flip mode functionality completely unchanged. Instead, if wished for, this
could go in a separate patch.
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH 0/5] Improve Present support in Xwayland with per window flips

2017-08-30 Thread Roman Gilg
On Wed, Aug 30, 2017 at 4:42 AM, Michel Dänzer  wrote:

>
> Hi Roman,
>
>
> On 30/08/17 12:24 AM, Roman Gilg wrote:
> >
> > Originating from the bug report
> >
> > https://bugs.freedesktop.org/show_bug.cgi?id=99702
> >
> > and my own observations with Xwayland misbehaving when outscanning on
> overlay planes, this patch series aims at improving Present support in
> Xwayland.
> >
> > For that it introduces an internal flip mode API to Present, with that
> it's possible to try other Pixmap flips than just for a whole screen like
> before. For Xwayland we add a flip mode per window, but for example in the
> future we could also try to add a mode for flips per CRTC. Anyway the idea
> is to clearly separate different flip modes with their own code paths.
> >
> > In Xwayland we flip per window, and also with the last patch in the
> series use sub-surfaces for that in order to flip on child windows. In my
> tests this was still somewhat fragile.
>
> I made some high level comments based on commit logs. I haven't reviewed
> the patches in detail yet, because it seems difficult unless at least
> some of them are split up:
>
> * Moving code without any functional changes should be in its own patch,
>   not intermixed with functional changes.
>

What do you mean exactly? I put the code moving of present.c to
present_execute.c and present_vblank.c in the separate patch 2. Or should
it not be part of this patch set at all? Or do you mean the moving of code
in patch 1 to present_scrmode.c?

* Only one logical change per patch.


Can you give an example? What do you mean by a logical change. I
partitioned my changes such that they form functional units and such that
every patch is self-contained, i.e. such that the Xserver can work even if
the later ones won't get pushed.

> * Mutter: Neverball framerate capped to 120 (probably Mutter doesn't
> release buffers faster)
>
> Was that with PresentOptionAsync (e.g. via "V-Sync" disabled in the game
> settings, or e.g. vblank_mode=0)? Without PresentOptionAsync, the
> intention is for the presentation frame rate to match the scanout
> refresh rate.


PresentOptionAsync is always on in Xwayland. And I disabled V-Sync in game
(set vblank_mode=0). Although that in game setting makes with my current
patches no difference, since V-Sync regressed for now with this patch
series and only works again when later some mechanism for queuing vblanks,
for example by using the Presentation Time protocol, is added.
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH 03/19] present: Move vblank functionality in seperate file

2018-01-29 Thread Roman Gilg
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 
---
 present/Makefile.am  |   3 +-
 present/meson.build  |   1 +
 present/present_priv.h   |  44 ++-
 present/present_scmd.c   | 153 
 present/present_vblank.c | 197 +++
 5 files changed, 258 insertions(+), 140 deletions(-)
 create mode 100644 present/present_vblank.c

diff --git a/present/Makefile.am b/present/Makefile.am
index 3b458fd..3d3d38d 100644
--- a/present/Makefile.am
+++ b/present/Makefile.am
@@ -13,6 +13,7 @@ libpresent_la_SOURCES = \
present_priv.h \
present_request.c \
present_scmd.c \
-   present_screen.c
+   present_screen.c \
+   present_vblank.c
 
 sdk_HEADERS = present.h presentext.h
diff --git a/present/meson.build b/present/meson.build
index bbe0de5..801e810 100644
--- a/present/meson.build
+++ b/present/meson.build
@@ -7,6 +7,7 @@ srcs_present = [
 'present_request.c',
 'present_scmd.c',
 'present_screen.c',
+'present_vblank.c',
 ]
 
 libxserver_present = static_library('libxserver_present',
diff --git a/present/present_priv.h b/present/present_priv.h
index 0ab05cf..36dd12f 100644
--- a/present/present_priv.h
+++ b/present/present_priv.h
@@ -176,6 +176,17 @@ present_window_priv_ptr
 present_get_window_priv(WindowPtr window, Bool create);
 
 /*
+ * 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 inline Bool
+msc_is_after(uint64_t test, uint64_t reference)
+{
+return (int64_t)(test - reference) > 0;
+}
+
+/*
  * present.c
  */
 void
@@ -319,9 +330,6 @@ void
 present_abort_vblank(ScreenPtr screen, RRCrtcPtr crtc, uint64_t event_id, 
uint64_t msc);
 
 void
-present_vblank_destroy(present_vblank_ptr vblank);
-
-void
 present_flip_destroy(ScreenPtr screen);
 
 void
@@ -346,4 +354,34 @@ present_scmd_init_mode_hooks(present_screen_priv_ptr 
screen_priv);
  * present_screen.c
  */
 
+/*
+ * present_vblank.c
+ */
+void
+present_vblank_notify(present_vblank_ptr vblank, CARD8 kind, CARD8 mode, 
uint64_t ust, uint64_t crtc_msc);
+
+present_vblank_ptr
+present_vblank_create(WindowPtr window,
+  PixmapPtr pixmap,
+  CARD32 serial,
+  RegionPtr valid,
+  RegionPtr update,
+  int16_t x_off,
+  int16_t y_off,
+  RRCrtcPtr target_crtc,
+  SyncFence *wait_fence,
+  SyncFence *idle_fence,
+  uint32_t options,
+  const uint32_t *capabilities,
+  present_notify_ptr notifies,
+  int num_notifies,
+  uint64_t *target_msc,
+  uint64_t crtc_msc);
+
+void
+present_vblank_scrap(present_vblank_ptr vblank);
+
+void
+present_vblank_destroy(present_vblank_ptr vblank);
+
 #endif /*  _PRESENT_PRIV_H_ */
diff --git a/present/present_scmd.c b/present/present_scmd.c
index 464d122..68a6828 100644
--- a/present/present_scmd.c
+++ b/present/present_scmd.c
@@ -48,17 +48,6 @@ 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
  * FALSE if the first MSC value is before the second one
  */
@@ -171,22 +160,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)
 {
@@ -835,79 +808,26 @@ present_pixmap(WindowPtr window,
 }
 }
 
-vblank = calloc (1, sizeof (present_vblank_rec));
+vblank = present_vblank_create(window,
+   pixmap,
+   serial,
+   val

[PATCH 02/19] present: Preliminary internal flip mode API

2018-01-29 Thread Roman Gilg
Add some basic function hooks to our future present-internal flip mode API,
that will allow us to share functionality in between modes and move more code
in separate files.

Signed-off-by: Roman Gilg 
---
 present/present_priv.h   | 26 +++---
 present/present_scmd.c   | 20 ++--
 present/present_screen.c |  4 +++-
 3 files changed, 44 insertions(+), 6 deletions(-)

diff --git a/present/present_priv.h b/present/present_priv.h
index 48bbcdc..0ab05cf 100644
--- a/present/present_priv.h
+++ b/present/present_priv.h
@@ -83,6 +83,20 @@ struct present_vblank {
 Boolabort_flip; /* aborting this flip */
 };
 
+/*
+ * Mode hooks
+ */
+typedef Bool (*present_priv_check_flip_ptr)(RRCrtcPtr crtc,
+WindowPtr window,
+PixmapPtr pixmap,
+Bool sync_flip,
+RegionPtr valid,
+int16_t x_off,
+int16_t y_off);
+typedef void (*present_priv_check_flip_window_ptr)(WindowPtr window);
+
+typedef void (*present_priv_create_event_id_ptr)(present_vblank_ptr vblank);
+
 typedef struct present_screen_priv {
 CloseScreenProcPtr  CloseScreen;
 ConfigNotifyProcPtr ConfigNotify;
@@ -103,6 +117,12 @@ typedef struct present_screen_priv {
 Boolflip_sync;
 
 present_screen_info_ptr info;
+
+/* Mode hooks */
+present_priv_check_flip_ptr check_flip;
+present_priv_check_flip_window_ptr  check_flip_window;
+
+present_priv_create_event_id_ptrcreate_event_id;
 } present_screen_priv_rec, *present_screen_priv_ptr;
 
 #define wrap(priv,real,mem,func) {\
@@ -310,9 +330,6 @@ present_restore_screen_pixmap(ScreenPtr screen);
 void
 present_set_abort_flip(ScreenPtr screen);
 
-void
-present_check_flip_window(WindowPtr window);
-
 RRCrtcPtr
 present_get_crtc(WindowPtr window);
 
@@ -322,6 +339,9 @@ present_query_capabilities(RRCrtcPtr crtc);
 Bool
 present_init(void);
 
+void
+present_scmd_init_mode_hooks(present_screen_priv_ptr screen_priv);
+
 /*
  * present_screen.c
  */
diff --git a/present/present_scmd.c b/present/present_scmd.c
index 33e8ce2..464d122 100644
--- a/present/present_scmd.c
+++ b/present/present_scmd.c
@@ -68,6 +68,12 @@ msc_is_equal_or_after(uint64_t test, uint64_t reference)
 return (int64_t)(test - reference) >= 0;
 }
 
+static void
+present_scmd_create_event_id(present_vblank_ptr vblank)
+{
+vblank->event_id = ++present_event_id;
+}
+
 static inline PixmapPtr
 present_flip_pending_pixmap(ScreenPtr screen)
 {
@@ -510,7 +516,7 @@ present_event_notify(uint64_t event_id, uint64_t ust, 
uint64_t msc)
  * 'window' is being reconfigured. Check to see if it is involved
  * in flipping and clean up as necessary
  */
-void
+static void
 present_check_flip_window (WindowPtr window)
 {
 ScreenPtr   screen = window->drawable.pScreen;
@@ -839,7 +845,8 @@ present_pixmap(WindowPtr window,
 vblank->screen = screen;
 vblank->window = window;
 vblank->pixmap = pixmap;
-vblank->event_id = ++present_event_id;
+present_scmd_create_event_id(vblank);
+
 if (pixmap) {
 vblank->kind = PresentCompleteKindPixmap;
 pixmap->refcnt++;
@@ -1017,6 +1024,15 @@ present_vblank_destroy(present_vblank_ptr vblank)
 free(vblank);
 }
 
+void
+present_scmd_init_mode_hooks(present_screen_priv_ptr screen_priv)
+{
+screen_priv->check_flip =   &present_check_flip;
+screen_priv->check_flip_window  =   &present_check_flip_window;
+
+screen_priv->create_event_id=   &present_scmd_create_event_id;
+}
+
 Bool
 present_init(void)
 {
diff --git a/present/present_screen.c b/present/present_screen.c
index 9d03c8a..454cc53 100644
--- a/present/present_screen.c
+++ b/present/present_screen.c
@@ -161,7 +161,7 @@ present_clip_notify(WindowPtr window, int dx, int dy)
 ScreenPtr screen = window->drawable.pScreen;
 present_screen_priv_ptr screen_priv = present_screen_priv(screen);
 
-present_check_flip_window(window);
+screen_priv->check_flip_window(window);
 unwrap(screen_priv, screen, ClipNotify)
 if (screen->ClipNotify)
 screen->ClipNotify (window, dx, dy);
@@ -194,6 +194,8 @@ present_screen_init(ScreenPtr screen, 
present_screen_info_ptr info)
 
 dixSetPrivate(&screen->devPrivates, &present_screen_private_key, 
screen_priv);
 
+present_scmd_init_mode_hooks(screen_priv);
+
 present_fake_screen_init(screen);
 }
 
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Per window flips in Present with support for them in Xwayland

2018-01-29 Thread Roman Gilg
This is a follow up on my work as GSoC project in 2017. The patches have been
split up and some functionality has been removed in order to stabalize the
patches.

In contrast to my earlier patches
https://lists.x.org/archives/xorg-devel/2017-August/054422.html
with this patch the new window flip mode in present for now still always copies
the flip pixmap content back to the main window pixmap.

Doing this solves several problems, but of course does not improve performance.
But with the provided implementation in Xwayland at least any tearing should go
away. This can be observed very clearly in Weston. Also direct scanout of a
committed wl_buffer is made possible with this procedure, since buffer release
events are respected.

Currently there is also the possibility missing to queue vblank events and
flips on windows with smaller size than the associated xwl_window are not yet
supported.

My plan for the last point was to use subsurfaces. I have a patch for that,
which works nicely on Weston, but leads to some weird corruption in Mesa when
used with KWin. I will describe this problem in some separate mail as a RFC.

This is though independent of this patch set here, which hopefully can still be
merged for 1.20.

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH 01/19] present: Move screen flip functionality in separate file

2018-01-29 Thread Roman Gilg
As a preperation for future flip mode alternatives move most of the
functionality from 'present.c' into a separate file.

Leave some functions needed by future other flip modes in 'present.c'.

Signed-off-by: Roman Gilg 
---
 present/Makefile.am|1 +
 present/meson.build|1 +
 present/present.c  | 1002 +-
 present/present_priv.h |  116 +++---
 present/present_scmd.c | 1027 
 5 files changed, 1098 insertions(+), 1049 deletions(-)
 create mode 100644 present/present_scmd.c

diff --git a/present/Makefile.am b/present/Makefile.am
index 7fea669..3b458fd 100644
--- a/present/Makefile.am
+++ b/present/Makefile.am
@@ -12,6 +12,7 @@ libpresent_la_SOURCES = \
present_notify.c \
present_priv.h \
present_request.c \
+   present_scmd.c \
present_screen.c
 
 sdk_HEADERS = present.h presentext.h
diff --git a/present/meson.build b/present/meson.build
index a4296ca..bbe0de5 100644
--- a/present/meson.build
+++ b/present/meson.build
@@ -5,6 +5,7 @@ srcs_present = [
 'present_fence.c',
 'present_notify.c',
 'present_request.c',
+'present_scmd.c',
 'present_screen.c',
 ]
 
diff --git a/present/present.c b/present/present.c
index 176e89c..ca2b414 100644
--- a/present/present.c
+++ b/present/present.c
@@ -26,51 +26,11 @@
 
 #include "present_priv.h"
 #include 
-#include 
-#include 
-#ifdef MONOTONIC_CLOCK
-#include 
-#endif
-
-static uint64_t present_event_id;
-static struct xorg_list present_exec_queue;
-static struct xorg_list present_flip_queue;
-
-#if 0
-#define DebugPresent(x) ErrorF x
-#else
-#define DebugPresent(x)
-#endif
-
-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
- * FALSE if the first MSC value is before the second one
- */
-static Bool
-msc_is_equal_or_after(uint64_t test, uint64_t reference)
-{
-return (int64_t)(test - reference) >= 0;
-}
 
 /*
  * Copies the update region from a pixmap to the target drawable
  */
-static void
+void
 present_copy_region(DrawablePtr drawable,
 PixmapPtr pixmap,
 RegionPtr update,
@@ -103,120 +63,7 @@ present_copy_region(DrawablePtr drawable,
 FreeScratchGC(gc);
 }
 
-static inline PixmapPtr
-present_flip_pending_pixmap(ScreenPtr screen)
-{
-present_screen_priv_ptr screen_priv = present_screen_priv(screen);
-
-if (!screen_priv)
-return NULL;
-
-if (!screen_priv->flip_pending)
-return NULL;
-
-return screen_priv->flip_pending->pixmap;
-}
-
-static Bool
-present_check_flip(RRCrtcPtrcrtc,
-   WindowPtrwindow,
-   PixmapPtrpixmap,
-   Bool sync_flip,
-   RegionPtrvalid,
-   int16_t  x_off,
-   int16_t  y_off)
-{
-ScreenPtr   screen = window->drawable.pScreen;
-PixmapPtr   window_pixmap;
-WindowPtr   root = screen->root;
-present_screen_priv_ptr screen_priv = present_screen_priv(screen);
-
-if (!screen_priv)
-return FALSE;
-
-if (!screen_priv->info)
-return FALSE;
-
-if (!crtc)
-return FALSE;
-
-/* Check to see if the driver supports flips at all */
-if (!screen_priv->info->flip)
-return FALSE;
-
-/* Make sure the window hasn't been redirected with Composite */
-window_pixmap = screen->GetWindowPixmap(window);
-if (window_pixmap != screen->GetScreenPixmap(screen) &&
-window_pixmap != screen_priv->flip_pixmap &&
-window_pixmap != present_flip_pending_pixmap(screen))
-return FALSE;
-
-/* Check for full-screen window */
-if (!RegionEqual(&window->clipList, &root->winSize)) {
-return FALSE;
-}
-
-/* Source pixmap must align with window exactly */
-if (x_off || y_off) {
-return FALSE;
-}
-
-/* Make sure the area marked as valid fills the screen */
-if (valid && !RegionEqual(valid, &root->winSize)) {
-return FALSE;
-}
-
-/* Does the window match the pixmap exactly? */
-if (window->drawable.x != 0 || window->drawable.y != 0 ||
-#ifdef COMPOSITE
-window->drawable.x != pixmap->screen_x || window->drawable.y != 
pixmap->screen_y ||
-#endif
-window->drawable.width != pixmap->drawable.width

[PATCH 08/19] present: Add more hooks to internal flip mode API

2018-01-29 Thread Roman Gilg
Add hooks to query caps, get crtcs, abort vblanks and destroy
a flip.

Signed-off-by: Roman Gilg 
---
 present/present.c| 28 
 present/present_priv.h   | 33 +
 present/present_scmd.c   | 38 ++
 present/present_screen.c |  6 --
 4 files changed, 71 insertions(+), 34 deletions(-)

diff --git a/present/present.c b/present/present.c
index 505d3ea..908575e 100644
--- a/present/present.c
+++ b/present/present.c
@@ -38,6 +38,34 @@ msc_is_equal_or_after(uint64_t test, uint64_t reference)
 return (int64_t)(test - reference) >= 0;
 }
 
+uint32_t
+present_query_capabilities(RRCrtcPtr crtc)
+{
+present_screen_priv_ptr screen_priv;
+
+if (!crtc)
+return 0;
+
+screen_priv = present_screen_priv(crtc->pScreen);
+
+if (!screen_priv)
+return 0;
+
+return screen_priv->query_capabilities(screen_priv);
+}
+
+RRCrtcPtr
+present_get_crtc(WindowPtr window)
+{
+ScreenPtr   screen = window->drawable.pScreen;
+present_screen_priv_ptr screen_priv = present_screen_priv(screen);
+
+if (!screen_priv)
+return NULL;
+
+return screen_priv->get_crtc(screen_priv, window);
+}
+
 /*
  * Copies the update region from a pixmap to the target drawable
  */
diff --git a/present/present_priv.h b/present/present_priv.h
index 2c32457..b242e96 100644
--- a/present/present_priv.h
+++ b/present/present_priv.h
@@ -83,9 +83,15 @@ struct present_vblank {
 Boolabort_flip; /* aborting this flip */
 };
 
+typedef struct present_screen_priv present_screen_priv_rec, 
*present_screen_priv_ptr;
+
 /*
  * Mode hooks
  */
+typedef uint32_t 
(*present_priv_query_capabilities_ptr)(present_screen_priv_ptr screen_priv);
+typedef RRCrtcPtr (*present_priv_get_crtc_ptr)(present_screen_priv_ptr 
screen_priv,
+   WindowPtr window);
+
 typedef Bool (*present_priv_check_flip_ptr)(RRCrtcPtr crtc,
 WindowPtr window,
 PixmapPtr pixmap,
@@ -121,7 +127,13 @@ typedef int (*present_priv_queue_vblank_ptr)(ScreenPtr 
screen,
 typedef void (*present_priv_flush_ptr)(WindowPtr window);
 typedef void (*present_priv_re_execute_ptr)(present_vblank_ptr vblank);
 
-typedef struct present_screen_priv {
+typedef void (*present_priv_abort_vblank_ptr)(ScreenPtr screen,
+  RRCrtcPtr crtc,
+  uint64_t event_id,
+  uint64_t msc);
+typedef void (*present_priv_flip_destroy_ptr)(ScreenPtr screen);
+
+struct present_screen_priv {
 CloseScreenProcPtr  CloseScreen;
 ConfigNotifyProcPtr ConfigNotify;
 DestroyWindowProcPtrDestroyWindow;
@@ -143,6 +155,9 @@ typedef struct present_screen_priv {
 present_screen_info_ptr info;
 
 /* Mode hooks */
+present_priv_query_capabilities_ptr query_capabilities;
+present_priv_get_crtc_ptr   get_crtc;
+
 present_priv_check_flip_ptr check_flip;
 present_priv_check_flip_window_ptr  check_flip_window;
 
@@ -153,7 +168,9 @@ typedef struct present_screen_priv {
 present_priv_flush_ptr  flush;
 present_priv_re_execute_ptr re_execute;
 
-} present_screen_priv_rec, *present_screen_priv_ptr;
+present_priv_abort_vblank_ptr   abort_vblank;
+present_priv_flip_destroy_ptr   flip_destroy;
+};
 
 #define wrap(priv,real,mem,func) {\
 priv->mem = real->mem; \
@@ -219,6 +236,12 @@ msc_is_after(uint64_t test, uint64_t reference)
 /*
  * present.c
  */
+uint32_t
+present_query_capabilities(RRCrtcPtr crtc);
+
+RRCrtcPtr
+present_get_crtc(WindowPtr window);
+
 void
 present_copy_region(DrawablePtr drawable,
 PixmapPtr pixmap,
@@ -387,12 +410,6 @@ present_restore_screen_pixmap(ScreenPtr screen);
 void
 present_set_abort_flip(ScreenPtr screen);
 
-RRCrtcPtr
-present_get_crtc(WindowPtr window);
-
-uint32_t
-present_query_capabilities(RRCrtcPtr crtc);
-
 Bool
 present_init(void);
 
diff --git a/present/present_scmd.c b/present/present_scmd.c
index 3146ecb..73c9f52 100644
--- a/present/present_scmd.c
+++ b/present/present_scmd.c
@@ -149,34 +149,18 @@ present_flip(RRCrtcPtr crtc,
 return (*screen_priv->info->flip) (crtc, event_id, target_msc, pixmap, 
sync_flip);
 }
 
-RRCrtcPtr
-present_get_crtc(WindowPtr window)
+static RRCrtcPtr
+present_scmd_get_crtc(present_screen_priv_ptr screen_priv, WindowPtr window)
 {
-ScreenPtr   screen = window->drawable.pScreen;
-present_screen_priv_ptr screen_priv = present_screen_priv(screen);
-
-if (!screen_priv)
-return NULL;
-
 if (!screen_priv->info)
 return NULL;
 
 return (*screen_priv->info->get_crtc)(window);
 }
 
-uint32_t
-present_query_capabi

[PATCH 11/19] present: Add flip_idler vblank property

2018-01-29 Thread Roman Gilg
Introduce vblank property for flip modes, that demand explicite
allowance by the driver for vblanks to become idle.

Signed-off-by: Roman Gilg 
---
 present/present_priv.h   | 1 +
 present/present_vblank.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/present/present_priv.h b/present/present_priv.h
index a071941..6a02c74 100644
--- a/present/present_priv.h
+++ b/present/present_priv.h
@@ -79,6 +79,7 @@ struct present_vblank {
 Boolrequeue;/* on queue, but target_msc has 
changed */
 Boolflip;   /* planning on using flip */
 Boolflip_ready; /* wants to flip, but waiting for 
previous flip or unflip */
+Boolflip_idler; /* driver explicitly permitted idling 
*/
 Boolsync_flip;  /* do flip synchronous to vblank */
 Boolabort_flip; /* aborting this flip */
 };
diff --git a/present/present_vblank.c b/present/present_vblank.c
index 0f1c3e6..00bb65c 100644
--- a/present/present_vblank.c
+++ b/present/present_vblank.c
@@ -104,6 +104,7 @@ present_vblank_create(WindowPtr window,
 vblank->msc_offset = window_priv->msc_offset;
 vblank->notifies = notifies;
 vblank->num_notifies = num_notifies;
+vblank->flip_idler = FALSE;
 
 if (pixmap != NULL &&
 !(options & PresentOptionCopy) &&
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH 10/19] present: Add present_window_priv properties for window flip mode

2018-01-29 Thread Roman Gilg
For window flip mode data about flips needs to be stored per window.
Add properties to 'present_window_priv' and initialize them on creation.

Signed-off-by: Roman Gilg 
---
 present/present_priv.h   | 11 +++
 present/present_screen.c |  6 ++
 2 files changed, 17 insertions(+)

diff --git a/present/present_priv.h b/present/present_priv.h
index b242e96..a071941 100644
--- a/present/present_priv.h
+++ b/present/present_priv.h
@@ -201,12 +201,23 @@ typedef struct present_event {
 } present_event_rec;
 
 typedef struct present_window_priv {
+WindowPtr  window;
 present_event_ptr  events;
 RRCrtcPtr  crtc;/* Last reported CRTC from get_ust_msc 
*/
 uint64_t   msc_offset;
 uint64_t   msc; /* Last reported MSC from the current 
crtc */
 struct xorg_list   vblank;
 struct xorg_list   notifies;
+
+/* Used for window flips */
+uint64_t   event_id;
+struct xorg_list   exec_queue;
+struct xorg_list   flip_queue;
+struct xorg_list   idle_queue;
+
+present_vblank_ptr flip_pending;
+present_vblank_ptr flip_active;
+uint64_t   unflip_event_id;
 } present_window_priv_rec, *present_window_priv_ptr;
 
 #define PresentCrtcNeverSet ((RRCrtcPtr) 1)
diff --git a/present/present_screen.c b/present/present_screen.c
index 868eaf8..d6c9a5e 100644
--- a/present/present_screen.c
+++ b/present/present_screen.c
@@ -45,6 +45,12 @@ present_get_window_priv(WindowPtr window, Bool create)
 return NULL;
 xorg_list_init(&window_priv->vblank);
 xorg_list_init(&window_priv->notifies);
+
+xorg_list_init(&window_priv->exec_queue);
+xorg_list_init(&window_priv->flip_queue);
+xorg_list_init(&window_priv->idle_queue);
+
+window_priv->window = window;
 window_priv->crtc = PresentCrtcNeverSet;
 dixSetPrivate(&window->devPrivates, &present_window_private_key, 
window_priv);
 return window_priv;
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH 13/19] present: Add driver facing window flip mode hooks

2018-01-29 Thread Roman Gilg
To enable special functionality of window flips introduce for window flips
a separate set of driver facing function hooks.

Signed-off-by: Roman Gilg 
---
 present/present.h  | 43 +++
 present/present_priv.h |  1 +
 2 files changed, 44 insertions(+)

diff --git a/present/present.h b/present/present.h
index aab2e16..fcf7675 100644
--- a/present/present.h
+++ b/present/present.h
@@ -36,6 +36,7 @@ typedef RRCrtcPtr (*present_get_crtc_ptr) (WindowPtr window);
 /* Return the current ust/msc for 'crtc'
  */
 typedef int (*present_get_ust_msc_ptr) (RRCrtcPtr crtc, uint64_t *ust, 
uint64_t *msc);
+typedef int (*present_wnmd_get_ust_msc_ptr) (WindowPtr window, uint64_t *ust, 
uint64_t *msc);
 
 /* Queue callback on 'crtc' for time 'msc'. Call present_event_notify with 
'event_id'
  * at or after 'msc'. Return false if it didn't happen (which might occur if 
'crtc'
@@ -44,12 +45,20 @@ typedef int (*present_get_ust_msc_ptr) (RRCrtcPtr crtc, 
uint64_t *ust, uint64_t
 typedef Bool (*present_queue_vblank_ptr) (RRCrtcPtr crtc,
   uint64_t event_id,
   uint64_t msc);
+typedef Bool (*present_wnmd_queue_vblank_ptr) (WindowPtr window,
+   RRCrtcPtr crtc,
+   uint64_t event_id,
+   uint64_t msc);
 
 /* Abort pending vblank. The extension is no longer interested in
  * 'event_id' which was to be notified at 'msc'. If possible, the
  * driver is free to de-queue the notification.
  */
 typedef void (*present_abort_vblank_ptr) (RRCrtcPtr crtc, uint64_t event_id, 
uint64_t msc);
+typedef void (*present_wnmd_abort_vblank_ptr) (WindowPtr window,
+   RRCrtcPtr crtc,
+   uint64_t event_id,
+   uint64_t msc);
 
 /* Flush pending drawing on 'window' to the hardware.
  */
@@ -75,6 +84,19 @@ typedef Bool (*present_flip_ptr) (RRCrtcPtr crtc,
   uint64_t target_msc,
   PixmapPtr pixmap,
   Bool sync_flip);
+/* Flip pixmap for window, return false if it didn't happen.
+ *
+ * Like present_flip_ptr, additionaly with:
+ *
+ * 'window' used for synchronization.
+ *
+ */
+typedef Bool (*present_wnmd_flip_ptr) (WindowPtr window,
+   RRCrtcPtr crtc,
+   uint64_t event_id,
+   uint64_t target_msc,
+   PixmapPtr pixmap,
+   Bool sync_flip);
 
 /* "unflip" back to the regular screen scanout buffer
  *
@@ -82,6 +104,12 @@ typedef Bool (*present_flip_ptr) (RRCrtcPtr crtc,
  */
 typedef void (*present_unflip_ptr) (ScreenPtr screen,
 uint64_t event_id);
+/* "unflip" back to the regular window scanout buffer
+ *
+ * present_event_notify should be called with 'event_id' when the unflip 
occurs.
+ */
+typedef void (*present_wnmd_unflip_ptr) (WindowPtr window,
+ uint64_t event_id);
 
 #define PRESENT_SCREEN_INFO_VERSION0
 
@@ -100,6 +128,21 @@ typedef struct present_screen_info {
 
 } present_screen_info_rec, *present_screen_info_ptr;
 
+typedef struct present_wnmd_info {
+uint32_tversion;
+
+present_get_crtc_ptrget_crtc;
+present_wnmd_get_ust_msc_ptrget_ust_msc;
+present_wnmd_queue_vblank_ptr   queue_vblank;
+present_wnmd_abort_vblank_ptr   abort_vblank;
+present_flush_ptr   flush;
+uint32_tcapabilities;
+present_check_flip_ptr  check_flip;
+present_wnmd_flip_ptr   flip;
+present_wnmd_unflip_ptr unflip;
+
+} present_wnmd_info_rec, *present_wnmd_info_ptr;
+
 /*
  * Called when 'event_id' occurs. 'ust' and 'msc' indicate when the
  * event actually happened
diff --git a/present/present_priv.h b/present/present_priv.h
index 231170d..9656380 100644
--- a/present/present_priv.h
+++ b/present/present_priv.h
@@ -158,6 +158,7 @@ struct present_screen_priv {
 Boolflip_sync;
 
 present_screen_info_ptr info;
+present_wnmd_info_ptr   wnmd_info;
 
 /* Mode hooks */
 present_priv_query_capabilities_ptr query_capabilities;
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH 07/19] present: Move timings adjustment in common part of flip mode API

2018-01-29 Thread Roman Gilg
To reduce future code duplication refactor timings adjustment out
as a separate function.

Signed-off-by: Roman Gilg 
---
 present/present.c  | 38 ++
 present/present_priv.h |  7 +++
 present/present_scmd.c | 34 +-
 3 files changed, 50 insertions(+), 29 deletions(-)

diff --git a/present/present.c b/present/present.c
index f8146fa..505d3ea 100644
--- a/present/present.c
+++ b/present/present.c
@@ -28,6 +28,17 @@
 #include 
 
 /*
+ * Returns:
+ * TRUE if the first MSC value is equal to or after the second one
+ * FALSE if the first MSC value is before the second one
+ */
+static Bool
+msc_is_equal_or_after(uint64_t test, uint64_t reference)
+{
+return (int64_t)(test - reference) >= 0;
+}
+
+/*
  * Copies the update region from a pixmap to the target drawable
  */
 void
@@ -74,6 +85,33 @@ present_pixmap_idle(PixmapPtr pixmap, WindowPtr window, 
CARD32 serial, struct pr
 }
 }
 
+void
+present_adjust_timings(uint32_t options,
+   uint64_t *crtc_msc,
+   uint64_t *target_msc,
+   uint64_t divisor,
+   uint64_t remainder)
+{
+/* Adjust target_msc to match modulus
+ */
+if (msc_is_equal_or_after(*crtc_msc, *target_msc)) {
+if (divisor != 0) {
+*target_msc = *crtc_msc - (*crtc_msc % divisor) + remainder;
+if (options & PresentOptionAsync) {
+if (msc_is_after(*crtc_msc, *target_msc))
+*target_msc += divisor;
+} else {
+if (msc_is_equal_or_after(*crtc_msc, *target_msc))
+*target_msc += divisor;
+}
+} else {
+*target_msc = *crtc_msc;
+if (!(options & PresentOptionAsync))
+(*target_msc)++;
+}
+}
+}
+
 int
 present_pixmap(WindowPtr window,
PixmapPtr pixmap,
diff --git a/present/present_priv.h b/present/present_priv.h
index 92cc1ba..2c32457 100644
--- a/present/present_priv.h
+++ b/present/present_priv.h
@@ -228,6 +228,13 @@ present_copy_region(DrawablePtr drawable,
 void
 present_pixmap_idle(PixmapPtr pixmap, WindowPtr window, CARD32 serial, struct 
present_fence *present_fence);
 
+void
+present_adjust_timings(uint32_t options,
+   uint64_t *crtc_msc,
+   uint64_t *target_msc,
+   uint64_t divisor,
+   uint64_t remainder);
+
 int
 present_pixmap(WindowPtr window,
PixmapPtr pixmap,
diff --git a/present/present_scmd.c b/present/present_scmd.c
index e414b3b..3146ecb 100644
--- a/present/present_scmd.c
+++ b/present/present_scmd.c
@@ -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 equal to or after the second one
- * FALSE if the first MSC value is before the second one
- */
-static Bool
-msc_is_equal_or_after(uint64_t test, uint64_t reference)
-{
-return (int64_t)(test - reference) >= 0;
-}
-
 static void
 present_scmd_create_event_id(present_vblank_ptr vblank)
 {
@@ -700,24 +689,11 @@ present_scmd_pixmap(WindowPtr window,
 window_priv->msc = crtc_msc;
 }
 
-/* Adjust target_msc to match modulus
- */
-if (msc_is_equal_or_after(crtc_msc, target_msc)) {
-if (divisor != 0) {
-target_msc = crtc_msc - (crtc_msc % divisor) + remainder;
-if (options & PresentOptionAsync) {
-if (msc_is_after(crtc_msc, target_msc))
-target_msc += divisor;
-} else {
-if (msc_is_equal_or_after(crtc_msc, target_msc))
-target_msc += divisor;
-}
-} else {
-target_msc = crtc_msc;
-if (!(options & PresentOptionAsync))
-target_msc++;
-}
-}
+present_adjust_timings(options,
+   &crtc_msc,
+   &target_msc,
+   divisor,
+   remainder);
 
 /*
  * Look for a matching presentation already on the list and
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH 09/19] present: Refactor present_screen_init

2018-01-29 Thread Roman Gilg
To initialize easily different flip modes, refactor
'present_screen_init'.

Signed-off-by: Roman Gilg 
---
 present/present_screen.c | 46 +-
 1 file changed, 33 insertions(+), 13 deletions(-)

diff --git a/present/present_screen.c b/present/present_screen.c
index 98f701a..868eaf8 100644
--- a/present/present_screen.c
+++ b/present/present_screen.c
@@ -170,32 +170,52 @@ present_clip_notify(WindowPtr window, int dx, int dy)
 wrap(screen_priv, screen, ClipNotify, present_clip_notify);
 }
 
+static Bool
+present_screen_register_priv_keys(void)
+{
+if (!dixRegisterPrivateKey(&present_screen_private_key, PRIVATE_SCREEN, 0))
+return FALSE;
+
+if (!dixRegisterPrivateKey(&present_window_private_key, PRIVATE_WINDOW, 0))
+return FALSE;
+
+return TRUE;
+}
+
+static present_screen_priv_ptr
+present_screen_priv_init(ScreenPtr screen)
+{
+present_screen_priv_ptr screen_priv;
+
+screen_priv = calloc(1, sizeof (present_screen_priv_rec));
+if (!screen_priv)
+return NULL;
+
+wrap(screen_priv, screen, CloseScreen, present_close_screen);
+wrap(screen_priv, screen, DestroyWindow, present_destroy_window);
+wrap(screen_priv, screen, ConfigNotify, present_config_notify);
+wrap(screen_priv, screen, ClipNotify, present_clip_notify);
+
+dixSetPrivate(&screen->devPrivates, &present_screen_private_key, 
screen_priv);
+
+return screen_priv;
+}
+
 /*
  * Initialize a screen for use with present
  */
 int
 present_screen_init(ScreenPtr screen, present_screen_info_ptr info)
 {
-if (!dixRegisterPrivateKey(&present_screen_private_key, PRIVATE_SCREEN, 0))
-return FALSE;
-
-if (!dixRegisterPrivateKey(&present_window_private_key, PRIVATE_WINDOW, 0))
+if (!present_screen_register_priv_keys())
 return FALSE;
 
 if (!present_screen_priv(screen)) {
-present_screen_priv_ptr screen_priv = calloc(1, sizeof 
(present_screen_priv_rec));
+present_screen_priv_ptr screen_priv = present_screen_priv_init(screen);
 if (!screen_priv)
 return FALSE;
 
-wrap(screen_priv, screen, CloseScreen, present_close_screen);
-wrap(screen_priv, screen, DestroyWindow, present_destroy_window);
-wrap(screen_priv, screen, ConfigNotify, present_config_notify);
-wrap(screen_priv, screen, ClipNotify, present_clip_notify);
-
 screen_priv->info = info;
-
-dixSetPrivate(&screen->devPrivates, &present_screen_private_key, 
screen_priv);
-
 present_scmd_init_mode_hooks(screen_priv);
 
 present_fake_screen_init(screen);
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH 12/19] present: Adapt flip mode API hooks for window flip mode

2018-01-29 Thread Roman Gilg
Flipping pixmaps per window needs additional arguments in the
flip mode API. Add these as preperation for window flip mode.

Signed-off-by: Roman Gilg 
---
 present/present_execute.c |  2 ++
 present/present_priv.h| 10 +++---
 present/present_scmd.c|  8 +---
 present/present_screen.c  |  2 +-
 present/present_vblank.c  |  2 +-
 5 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/present/present_execute.c b/present/present_execute.c
index e45e547..e0c755a 100644
--- a/present/present_execute.c
+++ b/present/present_execute.c
@@ -52,6 +52,7 @@ present_execute_wait(present_vblank_ptr vblank, uint64_t 
crtc_msc)
 vblank->requeue = FALSE;
 if (msc_is_after(vblank->target_msc, crtc_msc) &&
 Success == screen_priv->queue_vblank(screen,
+ window,
  vblank->crtc,
  vblank->event_id,
  vblank->target_msc))
@@ -77,6 +78,7 @@ present_execute_copy(present_vblank_ptr vblank, uint64_t 
crtc_msc)
 /* If present_flip failed, we may have to requeue for the target MSC */
 if (vblank->target_msc == crtc_msc + 1 &&
 Success == screen_priv->queue_vblank(screen,
+ window,
  vblank->crtc,
  vblank->event_id,
  vblank->target_msc)) {
diff --git a/present/present_priv.h b/present/present_priv.h
index 6a02c74..231170d 100644
--- a/present/present_priv.h
+++ b/present/present_priv.h
@@ -85,6 +85,7 @@ struct present_vblank {
 };
 
 typedef struct present_screen_priv present_screen_priv_rec, 
*present_screen_priv_ptr;
+typedef struct present_window_priv present_window_priv_rec, 
*present_window_priv_ptr;
 
 /*
  * Mode hooks
@@ -119,9 +120,11 @@ typedef int (*present_priv_pixmap_ptr)(WindowPtr window,
present_notify_ptr notifies,
int num_notifies);
 
-typedef void (*present_priv_create_event_id_ptr)(present_vblank_ptr vblank);
+typedef void (*present_priv_create_event_id_ptr)(present_window_priv_ptr 
window_priv,
+ present_vblank_ptr vblank);
 
 typedef int (*present_priv_queue_vblank_ptr)(ScreenPtr screen,
+ WindowPtr window,
  RRCrtcPtr crtc,
  uint64_t event_id,
  uint64_t msc);
@@ -129,6 +132,7 @@ typedef void (*present_priv_flush_ptr)(WindowPtr window);
 typedef void (*present_priv_re_execute_ptr)(present_vblank_ptr vblank);
 
 typedef void (*present_priv_abort_vblank_ptr)(ScreenPtr screen,
+  WindowPtr window,
   RRCrtcPtr crtc,
   uint64_t event_id,
   uint64_t msc);
@@ -201,7 +205,7 @@ typedef struct present_event {
 int mask;
 } present_event_rec;
 
-typedef struct present_window_priv {
+struct present_window_priv {
 WindowPtr  window;
 present_event_ptr  events;
 RRCrtcPtr  crtc;/* Last reported CRTC from get_ust_msc 
*/
@@ -219,7 +223,7 @@ typedef struct present_window_priv {
 present_vblank_ptr flip_pending;
 present_vblank_ptr flip_active;
 uint64_t   unflip_event_id;
-} present_window_priv_rec, *present_window_priv_ptr;
+};
 
 #define PresentCrtcNeverSet ((RRCrtcPtr) 1)
 
diff --git a/present/present_scmd.c b/present/present_scmd.c
index 73c9f52..ef7d8e9 100644
--- a/present/present_scmd.c
+++ b/present/present_scmd.c
@@ -47,7 +47,8 @@ static void
 present_execute(present_vblank_ptr vblank, uint64_t ust, uint64_t crtc_msc);
 
 static void
-present_scmd_create_event_id(present_vblank_ptr vblank)
+present_scmd_create_event_id(present_window_priv_ptr window_priv,
+ present_vblank_ptr vblank)
 {
 vblank->event_id = ++present_event_id;
 }
@@ -195,6 +196,7 @@ present_flush(WindowPtr window)
 
 static int
 present_queue_vblank(ScreenPtr screen,
+ WindowPtr window,
  RRCrtcPtr crtc,
  uint64_t event_id,
  uint64_t msc)
@@ -737,7 +739,7 @@ present_scmd_pixmap(WindowPtr window,
 xorg_list_append(&vblank->event_queue, &present_exec_queue);
 vblank->queued = TRUE;
 if (msc_is_after(target_msc, crtc_msc)) {
-ret = present_queue_vblank(screen, target_crtc, vblank->event_id, 
target_msc);
+ret = present_queue_vblank(screen, window, tar

[PATCH 04/19] present: Add flip mode API hooks for several functions

2018-01-29 Thread Roman Gilg
Add 'queue_vblank', 'flush' and 're_execute' hooks, that
are supposed to be shared with other flip modes.

Signed-off-by: Roman Gilg 
---
 present/present_priv.h | 12 
 present/present_scmd.c |  3 +++
 2 files changed, 15 insertions(+)

diff --git a/present/present_priv.h b/present/present_priv.h
index 36dd12f..b1dd82d 100644
--- a/present/present_priv.h
+++ b/present/present_priv.h
@@ -97,6 +97,13 @@ typedef void (*present_priv_check_flip_window_ptr)(WindowPtr 
window);
 
 typedef void (*present_priv_create_event_id_ptr)(present_vblank_ptr vblank);
 
+typedef int (*present_priv_queue_vblank_ptr)(ScreenPtr screen,
+ RRCrtcPtr crtc,
+ uint64_t event_id,
+ uint64_t msc);
+typedef void (*present_priv_flush_ptr)(WindowPtr window);
+typedef void (*present_priv_re_execute_ptr)(present_vblank_ptr vblank);
+
 typedef struct present_screen_priv {
 CloseScreenProcPtr  CloseScreen;
 ConfigNotifyProcPtr ConfigNotify;
@@ -123,6 +130,11 @@ typedef struct present_screen_priv {
 present_priv_check_flip_window_ptr  check_flip_window;
 
 present_priv_create_event_id_ptrcreate_event_id;
+
+present_priv_queue_vblank_ptr   queue_vblank;
+present_priv_flush_ptr  flush;
+present_priv_re_execute_ptr re_execute;
+
 } present_screen_priv_rec, *present_screen_priv_ptr;
 
 #define wrap(priv,real,mem,func) {\
diff --git a/present/present_scmd.c b/present/present_scmd.c
index 68a6828..a64a0c7 100644
--- a/present/present_scmd.c
+++ b/present/present_scmd.c
@@ -912,6 +912,9 @@ present_scmd_init_mode_hooks(present_screen_priv_ptr 
screen_priv)
 screen_priv->check_flip_window  =   &present_check_flip_window;
 
 screen_priv->create_event_id=   &present_scmd_create_event_id;
+screen_priv->queue_vblank   =   &present_queue_vblank;
+screen_priv->flush  =   &present_flush;
+screen_priv->re_execute =   &present_re_execute;
 }
 
 Bool
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH 06/19] present: Add flip mode API hook for present_pixmap

2018-01-29 Thread Roman Gilg
Make present_pixmap a common function callable by any
flip mode.

Signed-off-by: Roman Gilg 
---
 present/present.c  | 57 ++
 present/present_priv.h | 68 +++---
 present/present_scmd.c | 54 ++-
 3 files changed, 119 insertions(+), 60 deletions(-)

diff --git a/present/present.c b/present/present.c
index ca2b414..f8146fa 100644
--- a/present/present.c
+++ b/present/present.c
@@ -73,3 +73,60 @@ present_pixmap_idle(PixmapPtr pixmap, WindowPtr window, 
CARD32 serial, struct pr
 present_send_idle_notify(window, serial, pixmap, present_fence);
 }
 }
+
+int
+present_pixmap(WindowPtr window,
+   PixmapPtr pixmap,
+   CARD32 serial,
+   RegionPtr valid,
+   RegionPtr update,
+   int16_t x_off,
+   int16_t y_off,
+   RRCrtcPtr target_crtc,
+   SyncFence *wait_fence,
+   SyncFence *idle_fence,
+   uint32_t options,
+   uint64_t window_msc,
+   uint64_t divisor,
+   uint64_t remainder,
+   present_notify_ptr notifies,
+   int num_notifies)
+{
+ScreenPtr   screen = window->drawable.pScreen;
+present_screen_priv_ptr screen_priv = present_screen_priv(screen);
+
+return screen_priv->present_pixmap(window,
+   pixmap,
+   serial,
+   valid,
+   update,
+   x_off,
+   y_off,
+   target_crtc,
+   wait_fence,
+   idle_fence,
+   options,
+   window_msc,
+   divisor,
+   remainder,
+   notifies,
+   num_notifies);
+}
+
+int
+present_notify_msc(WindowPtr window,
+   CARD32 serial,
+   uint64_t target_msc,
+   uint64_t divisor,
+   uint64_t remainder)
+{
+return present_pixmap(window,
+  NULL,
+  serial,
+  NULL, NULL,
+  0, 0,
+  NULL,
+  NULL, NULL,
+  divisor == 0 ? PresentOptionAsync : 0,
+  target_msc, divisor, remainder, NULL, 0);
+}
diff --git a/present/present_priv.h b/present/present_priv.h
index 4e9c6c7..92cc1ba 100644
--- a/present/present_priv.h
+++ b/present/present_priv.h
@@ -95,6 +95,23 @@ typedef Bool (*present_priv_check_flip_ptr)(RRCrtcPtr crtc,
 int16_t y_off);
 typedef void (*present_priv_check_flip_window_ptr)(WindowPtr window);
 
+typedef int (*present_priv_pixmap_ptr)(WindowPtr window,
+   PixmapPtr pixmap,
+   CARD32 serial,
+   RegionPtr valid,
+   RegionPtr update,
+   int16_t x_off,
+   int16_t y_off,
+   RRCrtcPtr target_crtc,
+   SyncFence *wait_fence,
+   SyncFence *idle_fence,
+   uint32_t options,
+   uint64_t window_msc,
+   uint64_t divisor,
+   uint64_t remainder,
+   present_notify_ptr notifies,
+   int num_notifies);
+
 typedef void (*present_priv_create_event_id_ptr)(present_vblank_ptr vblank);
 
 typedef int (*present_priv_queue_vblank_ptr)(ScreenPtr screen,
@@ -129,6 +146,7 @@ typedef struct present_screen_priv {
 present_priv_check_flip_ptr check_flip;
 present_priv_check_flip_window_ptr  check_flip_window;
 
+present_priv_pixmap_ptr present_pixmap;
 present_priv_create_event_id_ptrcreate_event_id;
 
 present_priv_queue_vblank_ptr   queue_vblank;
@@ -210,6 +228,31 @@ present_copy_region(DrawablePtr drawable,
 void
 present_pixmap_idle(PixmapPtr pixmap, WindowPtr window, CARD32 serial, struct 
present_fence *present_fence);
 
+int
+present_pixmap(WindowPtr window,
+   PixmapPtr pixmap,
+   CARD32 serial,
+   RegionPtr valid,
+   RegionPtr update,
+   int16_t

[PATCH 14/19] present: Add window flip mode

2018-01-29 Thread Roman Gilg
In contrast to screen flip mode this mode currently:
* supports flips per windows (these windows need to have the same size
  as their parent windows with the same pixmap),
* always copies back to the original pixmap instead of pure flips, while
  giving the driver the flip pixmap provided by the application,
* sends pixmap idle signals to the client only after the driver has given
  and additional event notify.

This patch only introduces the new mode as a stub. It additionally needs a
driver hook, such that it can get initialized and appropriate cleanup
functions.

Signed-off-by: Roman Gilg 
---
 present/Makefile.am|   3 +-
 present/meson.build|   1 +
 present/present.h  |   6 +
 present/present_priv.h |   9 +
 present/present_wnmd.c | 672 +
 5 files changed, 690 insertions(+), 1 deletion(-)
 create mode 100644 present/present_wnmd.c

diff --git a/present/Makefile.am b/present/Makefile.am
index 55ad295..542f4ca 100644
--- a/present/Makefile.am
+++ b/present/Makefile.am
@@ -15,6 +15,7 @@ libpresent_la_SOURCES = \
present_request.c \
present_scmd.c \
present_screen.c \
-   present_vblank.c
+   present_vblank.c \
+   present_wnmd.c
 
 sdk_HEADERS = present.h presentext.h
diff --git a/present/meson.build b/present/meson.build
index 5e1dd3c..ad4fcff 100644
--- a/present/meson.build
+++ b/present/meson.build
@@ -9,6 +9,7 @@ srcs_present = [
 'present_scmd.c',
 'present_screen.c',
 'present_vblank.c',
+'present_wnmd.c',
 ]
 
 libxserver_present = static_library('libxserver_present',
diff --git a/present/present.h b/present/present.h
index fcf7675..7929cf9 100644
--- a/present/present.h
+++ b/present/present.h
@@ -149,6 +149,12 @@ typedef struct present_wnmd_info {
  */
 extern _X_EXPORT void
 present_event_notify(uint64_t event_id, uint64_t ust, uint64_t msc);
+/*
+ * Called when 'event_id' occurs for 'window'.
+ * 'ust' and 'msc' indicate when the event actually happened
+ */
+extern _X_EXPORT void
+present_wnmd_event_notify(WindowPtr window, uint64_t event_id, uint64_t ust, 
uint64_t msc);
 
 /* 'crtc' has been turned off, so any pending events will never occur.
  */
diff --git a/present/present_priv.h b/present/present_priv.h
index 9656380..a542b62 100644
--- a/present/present_priv.h
+++ b/present/present_priv.h
@@ -467,4 +467,13 @@ present_vblank_scrap(present_vblank_ptr vblank);
 void
 present_vblank_destroy(present_vblank_ptr vblank);
 
+/*
+ * present_wnmd.c
+ */
+void
+present_wnmd_set_abort_flip(WindowPtr window);
+
+void
+present_wnmd_init_mode_hooks(present_screen_priv_ptr screen_priv);
+
 #endif /*  _PRESENT_PRIV_H_ */
diff --git a/present/present_wnmd.c b/present/present_wnmd.c
new file mode 100644
index 000..c428232
--- /dev/null
+++ b/present/present_wnmd.c
@@ -0,0 +1,672 @@
+/*
+ * Copyright © 2018 Roman Gilg
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include 
+#endif
+
+#include "present_priv.h"
+
+/*
+ * Window flip mode
+ *
+ * Provides per-window flips. Flips can be processed on windows that
+ * have the same size as their parents, which they share their pixmap with.
+ *
+ * A flip still requires a copy currently, since the original pixmap needs
+ * to be updated with the new pixmap content. Just a flip of all windows
+ * to the new pixmap is diffcult, because the original pixmap might not be
+ * controlled by the Xserver.
+ *
+ */
+
+static void
+present_wnmd_execute(present_vblank_ptr vblank, uint64_t ust, uint64_t 
crtc_msc);
+
+static void
+present_wnmd_create_event_id(present_window_priv_ptr window_priv, 
present_vblank_ptr vblank)
+{
+vblank->event_id = ++window_priv->event_id;
+}
+
+static uint

[PATCH 17/19] present: Add exported init function of window flip mode

2018-01-29 Thread Roman Gilg
Allow drivers now to initialize window flip mode.

Signed-off-by: Roman Gilg 
---
 present/present.h|  2 ++
 present/present_screen.c | 23 ++-
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/present/present.h b/present/present.h
index b9e7839..eb2f0ca 100644
--- a/present/present.h
+++ b/present/present.h
@@ -164,6 +164,8 @@ present_event_abandon(RRCrtcPtr crtc);
 
 extern _X_EXPORT Bool
 present_screen_init(ScreenPtr screen, present_screen_info_ptr info);
+extern _X_EXPORT Bool
+present_wnmd_screen_init(ScreenPtr screen, present_wnmd_info_ptr info);
 
 typedef void (*present_complete_notify_proc)(WindowPtr window,
  CARD8 kind,
diff --git a/present/present_screen.c b/present/present_screen.c
index 8ad14ad..c7e37c5 100644
--- a/present/present_screen.c
+++ b/present/present_screen.c
@@ -239,7 +239,28 @@ present_screen_priv_init(ScreenPtr screen)
 }
 
 /*
- * Initialize a screen for use with present
+ * Initialize a screen for use with present in window flip mode (wnmd)
+ */
+int
+present_wnmd_screen_init(ScreenPtr screen, present_wnmd_info_ptr info)
+{
+if (!present_screen_register_priv_keys())
+return FALSE;
+
+if (!present_screen_priv(screen)) {
+present_screen_priv_ptr screen_priv = present_screen_priv_init(screen);
+if (!screen_priv)
+return FALSE;
+
+screen_priv->wnmd_info = info;
+present_wnmd_init_mode_hooks(screen_priv);
+}
+
+return TRUE;
+}
+
+/*
+ * Initialize a screen for use with present in default screen flip mode (scmd)
  */
 int
 present_screen_init(ScreenPtr screen, present_screen_info_ptr info)
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH 05/19] present: Refactor execute in separate file

2018-01-29 Thread Roman Gilg
To be shared by multiple flip modes, refactor execute functionality,
such that logical chunks can go in new separate file.

Signed-off-by: Roman Gilg 
---
 present/Makefile.am   |   1 +
 present/meson.build   |   1 +
 present/present_execute.c | 116 ++
 present/present_priv.h|  12 +
 present/present_scmd.c|  66 +++---
 5 files changed, 136 insertions(+), 60 deletions(-)
 create mode 100644 present/present_execute.c

diff --git a/present/Makefile.am b/present/Makefile.am
index 3d3d38d..55ad295 100644
--- a/present/Makefile.am
+++ b/present/Makefile.am
@@ -7,6 +7,7 @@ libpresent_la_SOURCES = \
present.h \
present.c \
present_event.c \
+   present_execute.c \
present_fake.c \
present_fence.c \
present_notify.c \
diff --git a/present/meson.build b/present/meson.build
index 801e810..5e1dd3c 100644
--- a/present/meson.build
+++ b/present/meson.build
@@ -1,6 +1,7 @@
 srcs_present = [
 'present.c',
 'present_event.c',
+'present_execute.c',
 'present_fake.c',
 'present_fence.c',
 'present_notify.c',
diff --git a/present/present_execute.c b/present/present_execute.c
new file mode 100644
index 000..e45e547
--- /dev/null
+++ b/present/present_execute.c
@@ -0,0 +1,116 @@
+/*
+ * Copyright © 2013 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include 
+#endif
+
+#include "present_priv.h"
+
+/*
+ * Called when the wait fence is triggered; just gets the current msc/ust and
+ * calls the proper execute again. That will re-check the fence and pend the
+ * request again if it's still not actually ready
+ */
+static void
+present_wait_fence_triggered(void *param)
+{
+present_vblank_ptr  vblank = param;
+ScreenPtr   screen = vblank->screen;
+present_screen_priv_ptr screen_priv = present_screen_priv(screen);
+
+screen_priv->re_execute(vblank);
+}
+
+Bool
+present_execute_wait(present_vblank_ptr vblank, uint64_t crtc_msc)
+{
+WindowPtr   window = vblank->window;
+ScreenPtr   screen = window->drawable.pScreen;
+present_screen_priv_ptr screen_priv = present_screen_priv(screen);
+
+if (vblank->requeue) {
+vblank->requeue = FALSE;
+if (msc_is_after(vblank->target_msc, crtc_msc) &&
+Success == screen_priv->queue_vblank(screen,
+ vblank->crtc,
+ vblank->event_id,
+ vblank->target_msc))
+return TRUE;
+}
+
+if (vblank->wait_fence) {
+if (!present_fence_check_triggered(vblank->wait_fence)) {
+present_fence_set_callback(vblank->wait_fence, 
present_wait_fence_triggered, vblank);
+return TRUE;
+}
+}
+return FALSE;
+}
+
+void
+present_execute_copy(present_vblank_ptr vblank, uint64_t crtc_msc)
+{
+WindowPtr   window = vblank->window;
+ScreenPtr   screen = window->drawable.pScreen;
+present_screen_priv_ptr screen_priv = present_screen_priv(screen);
+
+/* If present_flip failed, we may have to requeue for the target MSC */
+if (vblank->target_msc == crtc_msc + 1 &&
+Success == screen_priv->queue_vblank(screen,
+ vblank->crtc,
+ vblank->event_id,
+ vblank->target_msc)) {
+vblank->queued = TRUE;
+return;
+}
+
+present_copy_region(&windo

[PATCH 15/19] present: In window flip mode report damage on flip to driver

2018-01-29 Thread Roman Gilg
Calculate damage before trying to flip and report it to the driver.
This allows supporting drivers to optimize their rendering.

Signed-off-by: Roman Gilg 
---
 present/present.h  |  3 ++-
 present/present_wnmd.c | 24 +---
 2 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/present/present.h b/present/present.h
index 7929cf9..b9e7839 100644
--- a/present/present.h
+++ b/present/present.h
@@ -96,7 +96,8 @@ typedef Bool (*present_wnmd_flip_ptr) (WindowPtr window,
uint64_t event_id,
uint64_t target_msc,
PixmapPtr pixmap,
-   Bool sync_flip);
+   Bool sync_flip,
+   RegionPtr damage);
 
 /* "unflip" back to the regular screen scanout buffer
  *
diff --git a/present/present_wnmd.c b/present/present_wnmd.c
index c428232..77f4f19 100644
--- a/present/present_wnmd.c
+++ b/present/present_wnmd.c
@@ -351,7 +351,8 @@ present_wnmd_flip(WindowPtr window,
   uint64_t event_id,
   uint64_t target_msc,
   PixmapPtr pixmap,
-  Bool sync_flip)
+  Bool sync_flip,
+  RegionPtr damage)
 {
 ScreenPtr   screen = crtc->pScreen;
 present_screen_priv_ptr screen_priv = present_screen_priv(screen);
@@ -361,7 +362,8 @@ present_wnmd_flip(WindowPtr window,
 event_id,
 target_msc,
 pixmap,
-sync_flip);
+sync_flip,
+damage);
 }
 
 static void
@@ -422,12 +424,19 @@ present_wnmd_execute(present_vblank_ptr vblank, uint64_t 
ust, uint64_t crtc_msc)
  */
 xorg_list_add(&vblank->event_queue, &window_priv->flip_queue);
 
+/* Set update region as damaged */
+if (vblank->update) {
+damage = vblank->update;
+RegionIntersect(damage, damage, &window->clipList);
+} else
+damage = &window->clipList;
+
 /* Try to flip - the vblank is now pending
  */
 window_priv->flip_pending = vblank;
 // ask the driver
 if (present_wnmd_flip(vblank->window, vblank->crtc, 
vblank->event_id,
- vblank->target_msc, vblank->pixmap, 
vblank->sync_flip)) {
+ vblank->target_msc, vblank->pixmap, 
vblank->sync_flip, damage)) {
 
 /* Fix window pixmap: Copy pixmap content to window drawable */
 present_copy_region(&window->drawable,
@@ -436,14 +445,7 @@ present_wnmd_execute(present_vblank_ptr vblank, uint64_t 
ust, uint64_t crtc_msc)
 vblank->x_off,
 vblank->y_off);
 
-/* Report update region as damaged
- */
-if (vblank->update) {
-damage = vblank->update;
-RegionIntersect(damage, damage, &window->clipList);
-} else
-damage = &window->clipList;
-
+/* Report damage */
 DamageDamageRegion(&vblank->window->drawable, damage);
 return;
 }
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH 18/19] xwayland: Add arguments to glamor_pixmap_get_wl_buffer

2018-01-29 Thread Roman Gilg
Add arguments to allow the caller more information and control
over the creation of a wl_buffer with GBM, in particular let
the caller determine the size of the buffer.

Signed-off-by: Roman Gilg 
---
 hw/xwayland/xwayland-glamor.c | 22 ++
 hw/xwayland/xwayland.c|  5 -
 hw/xwayland/xwayland.h|  5 -
 3 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index 8ffb40d..cfc6dc3 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -153,14 +153,28 @@ xwl_glamor_create_pixmap_for_bo(ScreenPtr screen, struct 
gbm_bo *bo, int depth)
 }
 
 struct wl_buffer *
-xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap)
+xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap,
+unsigned short width,
+unsigned short height,
+Bool *created)
 {
 struct xwl_screen *xwl_screen = xwl_screen_get(pixmap->drawable.pScreen);
 struct xwl_pixmap *xwl_pixmap = xwl_pixmap_get(pixmap);
 int prime_fd;
 
-if (xwl_pixmap->buffer)
+if (xwl_pixmap->buffer) {
+// buffer already exists, also
+// inform caller if interested
+if(created)
+*created = FALSE;
 return xwl_pixmap->buffer;
+}
+
+// buffer does not yet exist
+// and will be created now,
+// inform caller if interested
+if(created)
+*created = TRUE;
 
 prime_fd = gbm_bo_get_fd(xwl_pixmap->bo);
 if (prime_fd == -1)
@@ -168,8 +182,8 @@ xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap)
 
 xwl_pixmap->buffer =
 wl_drm_create_prime_buffer(xwl_screen->drm, prime_fd,
-   pixmap->drawable.width,
-   pixmap->drawable.height,
+   width,
+   height,

drm_format_for_depth(pixmap->drawable.depth),
0, gbm_bo_get_stride(xwl_pixmap->bo),
0, 0,
diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c
index 19aa14a..2191956 100644
--- a/hw/xwayland/xwayland.c
+++ b/hw/xwayland/xwayland.c
@@ -642,7 +642,10 @@ xwl_window_post_damage(struct xwl_window *xwl_window)
 
 #ifdef GLAMOR_HAS_GBM
 if (xwl_screen->glamor)
-buffer = xwl_glamor_pixmap_get_wl_buffer(pixmap);
+buffer = xwl_glamor_pixmap_get_wl_buffer(pixmap,
+ pixmap->drawable.width,
+ pixmap->drawable.height,
+ NULL);
 else
 #endif
 buffer = xwl_shm_pixmap_get_wl_buffer(pixmap);
diff --git a/hw/xwayland/xwayland.h b/hw/xwayland/xwayland.h
index ffa0d72..783ab59 100644
--- a/hw/xwayland/xwayland.h
+++ b/hw/xwayland/xwayland.h
@@ -328,7 +328,10 @@ Bool xwl_glamor_init(struct xwl_screen *xwl_screen);
 
 Bool xwl_screen_init_glamor(struct xwl_screen *xwl_screen,
  uint32_t id, uint32_t version);
-struct wl_buffer *xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap);
+struct wl_buffer *xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap,
+  unsigned short width,
+  unsigned short height,
+  Bool *created);
 
 void xwl_screen_release_tablet_manager(struct xwl_screen *xwl_screen);
 
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH 16/19] present: Add cleanups for window flip mode

2018-01-29 Thread Roman Gilg
Make sure that vblanks and windows get cleaned up correctly
in window flip mode.

Signed-off-by: Roman Gilg 
---
 present/present_screen.c | 33 -
 present/present_vblank.c |  2 ++
 2 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/present/present_screen.c b/present/present_screen.c
index b0cae0f..8ad14ad 100644
--- a/present/present_screen.c
+++ b/present/present_screen.c
@@ -109,6 +109,32 @@ present_clear_window_flip(WindowPtr window)
 }
 }
 
+static void
+present_wnmd_clear_window_flip(WindowPtr window)
+{
+present_window_priv_ptr window_priv = present_window_priv(window);
+present_vblank_ptr  vblank, tmp;
+
+if (window_priv->flip_pending) {
+present_wnmd_set_abort_flip(window);
+window_priv->flip_pending->window = NULL;
+}
+
+xorg_list_for_each_entry_safe(vblank, tmp, &window_priv->idle_queue, 
event_queue) {
+present_pixmap_idle(vblank->pixmap, vblank->window, vblank->serial, 
vblank->idle_fence);
+/* The pixmap will be destroyed by freeing the window resources. */
+vblank->pixmap = NULL;
+present_vblank_destroy(vblank);
+}
+
+vblank = window_priv->flip_active;
+if (vblank) {
+present_pixmap_idle(vblank->pixmap, vblank->window, vblank->serial, 
vblank->idle_fence);
+present_vblank_destroy(vblank);
+}
+window_priv->flip_active = NULL;
+}
+
 /*
  * Hook the close window function to clean up our window private
  */
@@ -124,7 +150,12 @@ present_destroy_window(WindowPtr window)
 present_clear_window_notifies(window);
 present_free_events(window);
 present_free_window_vblank(window);
-present_clear_window_flip(window);
+
+if (screen_priv->wnmd_info)
+present_wnmd_clear_window_flip(window);
+else
+present_clear_window_flip(window);
+
 free(window_priv);
 }
 unwrap(screen_priv, screen, DestroyWindow);
diff --git a/present/present_vblank.c b/present/present_vblank.c
index dbfedb4..af6ebe5 100644
--- a/present/present_vblank.c
+++ b/present/present_vblank.c
@@ -169,6 +169,8 @@ present_vblank_destroy(present_vblank_ptr vblank)
 {
 /* Remove vblank from window and screen lists */
 xorg_list_del(&vblank->window_list);
+/* Also make sure vblank is removed from event queue (wnmd) */
+xorg_list_del(&vblank->event_queue);
 
 DebugPresent(("\td %lld %p %8lld: %08lx -> %08lx\n",
   vblank->event_id, vblank, vblank->target_msc,
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH 19/19] xwayland: Preliminary support for present's new window flip mode

2018-01-29 Thread Roman Gilg
Introduce support for present's window flip mode. The support is not yet
complete, but works reasonable well for the most important use case, what
is fullscreen applications

We take a present flip and if the xwl_window->window has the same dimensions
as the presenting window, the flip is represented by a wl_buffer and
attached to the main wl_surface of the xwl_window.

After commit we are listening for the sync callback in order to tell present,
that the pixmap flip is not longer pending, for the frame callback in order
to update the msc counter and for the buffer release callback in order to tell
present that the pixmap is idle again.

In case the compositor is not sending any more frame callbacks, we use a slow
timer to continue the msc counter.

The following functionality is missing from this implementation:
* per window flips for child windows with smaller size than the xwl_window,
* queuing events to MSC times,
* reporting UST values to present.

To make use of this functionality Xwayland must run rootless and with
Glamor/GBM.

Signed-off-by: Roman Gilg 
---
 hw/xwayland/Makefile.am|   1 +
 hw/xwayland/meson.build|   1 +
 hw/xwayland/xwayland-present.c | 423 +
 hw/xwayland/xwayland.c |  20 ++
 hw/xwayland/xwayland.h |  31 +++
 5 files changed, 476 insertions(+)
 create mode 100644 hw/xwayland/xwayland-present.c

diff --git a/hw/xwayland/Makefile.am b/hw/xwayland/Makefile.am
index 7204591..9a2369b 100644
--- a/hw/xwayland/Makefile.am
+++ b/hw/xwayland/Makefile.am
@@ -11,6 +11,7 @@ Xwayland_CFLAGS = \
 
 Xwayland_SOURCES = \
xwayland.c  \
+   xwayland-present.c  \
xwayland-input.c\
xwayland-cursor.c   \
xwayland-shm.c  \
diff --git a/hw/xwayland/meson.build b/hw/xwayland/meson.build
index 24203c6..d58c5a1 100644
--- a/hw/xwayland/meson.build
+++ b/hw/xwayland/meson.build
@@ -1,5 +1,6 @@
 srcs = [
 'xwayland.c',
+'xwayland-present.c',
 'xwayland-input.c',
 'xwayland-cursor.c',
 'xwayland-shm.c',
diff --git a/hw/xwayland/xwayland-present.c b/hw/xwayland/xwayland-present.c
new file mode 100644
index 000..d08c39e
--- /dev/null
+++ b/hw/xwayland/xwayland-present.c
@@ -0,0 +1,423 @@
+/*
+ * Copyright © 2018 Roman Gilg
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of the
+ * copyright holders not be used in advertising or publicity
+ * pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no
+ * representations about the suitability of this software for any
+ * purpose.  It is provided "as is" without express or implied
+ * warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+#include "xwayland.h"
+
+#include 
+
+#define FRAME_TIMER_IVAL 67 // ~15fps
+
+static struct xorg_list xwl_present_windows;
+
+void
+xwl_present_cleanup(WindowPtr window)
+{
+struct xwl_window   *xwl_window = xwl_window_of_top(window);
+struct xwl_present_event*event, *tmp;
+
+if (!xwl_window)
+return;
+
+if (!xwl_window->present_window)
+return;
+
+if (xwl_window->present_window != window && xwl_window->window != window)
+/* Unrealizing a non-presenting sibling */
+return;
+
+/*
+ * At this point we're either:
+ * - Unflipping.
+ * - Unrealizing the presenting window 'xwl_window->present_window'
+ *   or its ancestor 'xwl_window->window'.
+ * And therefore need to cleanup.
+ */
+
+if (xwl_window->present_frame_callback) {
+wl_callback_destroy(xwl_window->present_frame_callback);
+xwl_window->present_frame_callback = NULL;
+}
+
+/* Reset base data */
+xorg_list_del(&xwl_window->present_link);
+
+xwl_window->present_surface = NULL;
+xwl_window->present_window = NULL;
+
+TimerFree(xwl_window->present_frame_timer);
+xwl_window

[RFC][PATCH xserver] Multi-buffered flips on subsurfaces seg fault in Mesa

2018-01-29 Thread Roman Gilg
The above patch series only allows flips on a child window with the same
dimensions as its parent xwl_window. For flips on child windows (for example
the video view port of a video player in windowed mode, see here:
http://www.subdiff.de/assets/images/2017-07-28-a-new-beginning.jpg) I wanted
to use Wayland subsurfaces as in the attached patch.

The flipping itself works well on Weston and on KWin. But when shutting down
KWin in the end I get always a segmentation fault in Mesa when cleaning up EGL
via eglTerminate(EGLDisplay) through libepoxy.

I pinpointed the seg fault to be a missing destroyImage function pointer here:
https://cgit.freedesktop.org/mesa/mesa/tree/src/egl/drivers/dri2/egl_dri2.c#n2685

But I don't see currently what component is making the problems here or if the
problem lies in my code.

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver] xwayland: Flips on subsurfaces

2018-01-29 Thread Roman Gilg
Do flips for child windows via subsurfaces if the Wayland server
supports them.

Signed-off-by: Roman Gilg 
---
 hw/xwayland/xwayland-present.c | 57 +-
 hw/xwayland/xwayland.c |  6 -
 hw/xwayland/xwayland.h |  2 ++
 present/present_wnmd.c | 23 -
 4 files changed, 52 insertions(+), 36 deletions(-)

diff --git a/hw/xwayland/xwayland-present.c b/hw/xwayland/xwayland-present.c
index d08c39e..f68bf92 100644
--- a/hw/xwayland/xwayland-present.c
+++ b/hw/xwayland/xwayland-present.c
@@ -55,15 +55,22 @@ xwl_present_cleanup(WindowPtr window)
  * And therefore need to cleanup.
  */
 
+/* Clear frame callback */
 if (xwl_window->present_frame_callback) {
 wl_callback_destroy(xwl_window->present_frame_callback);
 xwl_window->present_frame_callback = NULL;
 }
 
+/* Clear surfaces */
+if (xwl_window->present_subsurface) {
+wl_subsurface_destroy(xwl_window->present_subsurface);
+wl_surface_destroy(xwl_window->present_surface);
+xwl_window->present_subsurface = NULL;
+}
+xwl_window->present_surface = NULL;
+
 /* Reset base data */
 xorg_list_del(&xwl_window->present_link);
-
-xwl_window->present_surface = NULL;
 xwl_window->present_window = NULL;
 
 TimerFree(xwl_window->present_frame_timer);
@@ -299,29 +306,31 @@ xwl_present_check_flip(RRCrtcPtr crtc,
 return FALSE;
 
 /*
- * We currently only allow flips of windows, that have the same
- * dimensions as their xwl_window parent window. For the case of
- * different sizes subsurfaces are presumably the way forward.
+ * Allow different sizes for the presenting window and its associated
+ * xwl_window only if the Wayland server supports subsurfaces.
  */
-if (!RegionEqual(&xwl_window->window->winSize, &present_window->winSize))
+if (!RegionEqual(&xwl_window->window->winSize, &present_window->winSize) &&
+!xwl_window->xwl_screen->subcompositor)
 return FALSE;
 
 return TRUE;
 }
 
-static void
+static Bool
 xwl_present_reset_present_window(struct xwl_window *xwl_window, WindowPtr 
present_window)
 {
 /* Do not reset if it is the same present_window. But this also means, that
  * we always switch to another child window, if it wants to present.
  */
 if (xwl_window->present_window == present_window)
-return;
+return FALSE;
 
 if (xwl_window->present_window)
 xwl_present_cleanup(xwl_window->present_window);
 xwl_window->present_window = present_window;
 xorg_list_add(&xwl_window->present_link, &xwl_present_windows);
+
+return TRUE;
 }
 
 static Bool
@@ -334,18 +343,37 @@ xwl_present_flip(WindowPtr present_window,
  RegionPtr damage)
 {
 struct xwl_window   *xwl_window = 
xwl_window_of_top(present_window);
-BoxPtr  present_box, damage_box;
+BoxPtr  win_box, present_box, damage_box;
+struct xwl_screen   *xwl_screen = xwl_window->xwl_screen;
 Boolbuffer_created;
 struct wl_buffer*buffer;
 struct xwl_present_event*event;
+struct wl_region*input_region;
 
+win_box = RegionExtents(&xwl_window->window->winSize);
 present_box = RegionExtents(&present_window->winSize);
 damage_box = RegionExtents(damage);
 
 /* Potentially reset the presenting window */
-xwl_present_reset_present_window(xwl_window, present_window);
-/* We can flip directly to the main surface (full screen window without 
clips) */
-xwl_window->present_surface = xwl_window->surface;
+if ( xwl_present_reset_present_window(xwl_window, present_window) ) {
+
+if (RegionEqual(&xwl_window->window->winSize, 
&present_window->winSize)) {
+/* We can flip directly to the main surface (full screen window 
without clips) */
+xwl_window->present_surface = xwl_window->surface;
+} else {
+xwl_window->present_surface =  
wl_compositor_create_surface(xwl_screen->compositor);
+wl_surface_set_user_data(xwl_window->present_surface, xwl_window);
+
+xwl_window->present_subsurface =
+wl_subcompositor_get_subsurface(xwl_screen->subcompositor, 
xwl_window->present_surface, xwl_window->surface);
+wl_subsurface_set_sync(xwl_window->present_subsurface);
+
+input_region = wl_compositor_create_region(xwl_screen->compositor);
+wl_surface_set_input_region(xwl_window->present_surface, 
input_region);
+wl_region_destroy(input_region);
+}
+
+}
 
 event = malloc(sizeof *event);
 if (!event) {
@@ -353,6 +38

Re: [RFC][PATCH xserver] Multi-buffered flips on subsurfaces seg fault in Mesa

2018-01-29 Thread Roman Gilg
Sorry, somewhat part of my message got removed. It should begin with:

"This is a RFC on a follow-up patch to my recently posted patch series on
the
xorg-devel mailing list to enable per window flips of Present Pixmaps to
Wayland surfaces:
https://lists.freedesktop.org/archives/xorg-devel/2018-January/055674.html

The above patch series only allows flips..."

and so on.

On Mon, Jan 29, 2018 at 5:54 PM, Roman Gilg  wrote:

> The above patch series only allows flips on a child window with the same
> dimensions as its parent xwl_window. For flips on child windows (for
> example
> the video view port of a video player in windowed mode, see here:
> http://www.subdiff.de/assets/images/2017-07-28-a-new-beginning.jpg) I
> wanted
> to use Wayland subsurfaces as in the attached patch.
>
> The flipping itself works well on Weston and on KWin. But when shutting
> down
> KWin in the end I get always a segmentation fault in Mesa when cleaning up
> EGL
> via eglTerminate(EGLDisplay) through libepoxy.
>
> I pinpointed the seg fault to be a missing destroyImage function pointer
> here:
> https://cgit.freedesktop.org/mesa/mesa/tree/src/egl/
> drivers/dri2/egl_dri2.c#n2685
>
> But I don't see currently what component is making the problems here or if
> the
> problem lies in my code.
>
>
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[RFC][PATCH xserver] xwayland: Queue Present events

2018-01-29 Thread Roman Gilg
This is a RFC on a follow-up patch to my recently posted patch series on the
xorg-devel mailing list to enable per window flips of Present Pixmaps to
Wayland surfaces:
https://lists.freedesktop.org/archives/xorg-devel/2018-January/055674.html

With the attached patch queuing events should be possible. This works with the
changed timer interval reasonable well, but I don't fully understand the logic
of queuing, that's why I decided on excluding the patch from the above patch
series.

The problem with the old timer interval was, that this was too slow. For
example VLC would send new Pixmaps too slow and the video would stutter. So
changing it to a larger value makes sense.

But the question is if this needs to take into account the refresh rate of the
display as well. I would then go over to analyzing the current position of the
window and the refresh rate of the xwl_output the window covers the most (this
is similar to how the xfree86 modesetting driver does it).

Anyways I don't fully understand the logic behind this queuing mechanism. The
client would need to know the refresh rate it can accept to predict the
upcomping MSC counter its next presentation is supposed to be depicted on.

I don't see such logic in the Present extension. Or is the client supposed to
calculate the refresh rate from the returned UST values?

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver] xwayland: Queue Present events

2018-01-29 Thread Roman Gilg
Add functionality for queuing events as requested by Present.

Signed-off-by: Roman Gilg 
---
 hw/xwayland/xwayland-present.c | 73 +-
 1 file changed, 51 insertions(+), 22 deletions(-)

diff --git a/hw/xwayland/xwayland-present.c b/hw/xwayland/xwayland-present.c
index d08c39e..f8ac5a6 100644
--- a/hw/xwayland/xwayland-present.c
+++ b/hw/xwayland/xwayland-present.c
@@ -27,7 +27,7 @@
 
 #include 
 
-#define FRAME_TIMER_IVAL 67 // ~15fps
+#define FRAME_TIMER_IVAL 33 // ~30fps
 
 static struct xorg_list xwl_present_windows;
 
@@ -227,6 +227,21 @@ xwl_present_get_ust_msc(WindowPtr present_window, uint64_t 
*ust, uint64_t *msc)
 return Success;
 }
 
+static void
+xwl_present_reset_present_window(struct xwl_window *xwl_window, WindowPtr 
present_window)
+{
+/* Do not reset if it is the same present_window. But this also means, that
+ * we always switch to another child window, if it wants to present.
+ */
+if (xwl_window->present_window == present_window)
+return;
+
+if (xwl_window->present_window)
+xwl_present_cleanup(xwl_window->present_window);
+xwl_window->present_window = present_window;
+xorg_list_add(&xwl_window->present_link, &xwl_present_windows);
+}
+
 /*
  * Queue an event to report back to the Present extension when the specified
  * MSC has past
@@ -237,12 +252,38 @@ xwl_present_queue_vblank(WindowPtr present_window,
  uint64_t event_id,
  uint64_t msc)
 {
-/*
- * Queuing events is not yet implemented.
- *
- */
-return BadRequest;
-/* */
+struct xwl_window *xwl_window = xwl_window_of_top(present_window);
+struct xwl_present_event *event;
+
+if (!xwl_window)
+return BadAlloc;
+
+if (xwl_window->present_crtc_fake != crtc)
+return BadRequest;
+
+event = malloc(sizeof *event);
+if (!event)
+return BadAlloc;
+
+xwl_present_reset_present_window(xwl_window, present_window);
+
+event->event_id = event_id;
+event->xwl_window = xwl_window;
+event->buffer = NULL;
+event->target_msc = msc;
+event->pending = FALSE;
+event->abort = FALSE;
+
+xorg_list_add(&event->list, &xwl_window->present_event_list);
+
+if (!xwl_window->present_frame_callback && 
!xwl_window->present_frame_timer_firing)
+xwl_window->present_frame_timer = 
TimerSet(xwl_window->present_frame_timer,
+   0,
+   FRAME_TIMER_IVAL,
+   
&present_frame_timer_callback,
+   xwl_window);
+
+return Success;
 }
 
 /*
@@ -255,6 +296,9 @@ xwl_present_abort_vblank(WindowPtr present_window, 
RRCrtcPtr crtc, uint64_t even
 struct xwl_window *xwl_window = xwl_window_of_top(present_window);
 struct xwl_present_event *event, *tmp;
 
+if (!xwl_window || !crtc || xwl_window->present_crtc_fake != crtc)
+return;
+
 xorg_list_for_each_entry_safe(event, tmp, &xwl_window->present_event_list, 
list) {
 if (event->event_id == event_id) {
 xorg_list_del(&event->list);
@@ -309,21 +353,6 @@ xwl_present_check_flip(RRCrtcPtr crtc,
 return TRUE;
 }
 
-static void
-xwl_present_reset_present_window(struct xwl_window *xwl_window, WindowPtr 
present_window)
-{
-/* Do not reset if it is the same present_window. But this also means, that
- * we always switch to another child window, if it wants to present.
- */
-if (xwl_window->present_window == present_window)
-return;
-
-if (xwl_window->present_window)
-xwl_present_cleanup(xwl_window->present_window);
-xwl_window->present_window = present_window;
-xorg_list_add(&xwl_window->present_link, &xwl_present_windows);
-}
-
 static Bool
 xwl_present_flip(WindowPtr present_window,
  RRCrtcPtr crtc,
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH 13/19] present: Add driver facing window flip mode hooks

2018-01-29 Thread Roman Gilg
The idea with this whole "flip mode API" was to separate the window
flip mode from the screen flip mode as much as possible and touch the
old code only as little as possible, such that the probability for
regressions decreases and the possibility for adding other modes or
just partial functionality for one of the modes in the future without
large rewrites maximizes. Regarding future additions I was thinking of

a) crtc flips as a possible third mode (or some other mode currently
not on our radar),
b) non-copy flips in window flip mode.

Also I assume a driver is normally either only interested in window or
screen flips. So let's assume a driver wants to do window flips: it
can decide upon this by setting the respective present_wnmd_info
struct and call its init function independently of any version shift
in the screen flip struct. This clear separation is a good thing in my
opinion.

I understand your point and there are for sure some good reasons to do
it this way (although I would argue that there are also good reasons
to do it like I did now and I hope the ones I mentioned are already
quite convincing). But anyways I have designed the code structure now
with this "flip mode API" including separate driver hooks and I
neither have the time nor the mental fortitude to rewrite it again in
order to merge the two API modes, which would basically completely
remove the separation I came up with.

On Mon, Jan 29, 2018 at 7:08 PM, Adam Jackson  wrote:
> On Mon, 2018-01-29 at 14:34 +0100, Roman Gilg wrote:
>
>> @@ -100,6 +128,21 @@ typedef struct present_screen_info {
>>
>>  } present_screen_info_rec, *present_screen_info_ptr;
>>
>> +typedef struct present_wnmd_info {
>> +uint32_tversion;
>> +
>> +present_get_crtc_ptrget_crtc;
>> +present_wnmd_get_ust_msc_ptrget_ust_msc;
>> +present_wnmd_queue_vblank_ptr   queue_vblank;
>> +present_wnmd_abort_vblank_ptr   abort_vblank;
>> +present_flush_ptr   flush;
>> +uint32_tcapabilities;
>> +present_check_flip_ptr  check_flip;
>> +present_wnmd_flip_ptr   flip;
>> +present_wnmd_unflip_ptr unflip;
>> +
>> +} present_wnmd_info_rec, *present_wnmd_info_ptr;
>
> I'm not a huge fan of this. present_screen_info is versioned for
> exactly this reason, if we want to add new functionality we bump the
> 'version' field and add new function pointers to the end of the vtable.
>
> The mode-dependent bit of present_destroy_window would admittedly be a
> bit awkward to add to this table, since it's the driver that would fill
> it in. It might be nice to refactor that path so even the screen-mode
> code tracked flips per-window (and just only ever _did_ any on the root
> window). Which, tbh, might not be a bad idea in general: add a
> check_flip_window to present_screen_info, and for the "screen mode"
> code just fail if the window isn't the root.
>
> - ajax
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH 14/19] present: Add window flip mode

2018-02-02 Thread Roman Gilg
It's because of what you made me aware of in the previous patch set:
the window original pixmap needs to have the updated content from the
flip Pixmap, otherwise for example screenshot applications won't work
anymore. I tested it with xwd.

I also tried to not copy, but set the window pixmap to the flip
pixmap. The problem I encountered here, is that the window original
pixmap can be controlled by the client. And when unflipping and
restoring the original pixmap, this already might have been deleted by
the client.

There might be ways to circumvent this problem, I have a few ideas,
but I decided to first go for a simple implementation by just copying
the pixmap content in order to decrease the overall complexity of the
patch set.

On Thu, Feb 1, 2018 at 4:33 PM, Michel Dänzer  wrote:
> On 2018-01-29 02:34 PM, Roman Gilg wrote:
>> In contrast to screen flip mode this mode currently:
>> * supports flips per windows (these windows need to have the same size
>>   as their parent windows with the same pixmap),
>> * always copies back to the original pixmap instead of pure flips, while
>>   giving the driver the flip pixmap provided by the application,
>
> What are the reasons for always copying back to the original pixmap? I
> don't think that should be necessary.
>
>
> --
> Earthling Michel Dänzer   |   http://www.amd.com
> Libre software enthusiast | Mesa and X developer
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH 14/19] present: Add window flip mode

2018-02-06 Thread Roman Gilg
On Fri, Feb 2, 2018 at 5:11 PM, Michel Dänzer  wrote:
> Taking a step back, do we even need to keep around the original pixmap
> and unflip to it at all? I had a chat on IRC about this with Keith a
> while ago, see the attached log excerpt.
>
> Keith's main concern is that the presenting client could be able to
> read/write the window pixmap's contents behind the X server's back. I
> understand this concern at least somewhat in the case of per-screen
> flips, because the screen pixmap can be used for completely different
> windows after flipping.
>
> But this seems irrelevant for per-window flips. In this case, the window
> pixmap isn't used for anything else after flipping, so having direct
> access to the pixmap doesn't allow the client to do anything it couldn't
> do anyway using the X11 protocol. (There might be exceptions to this if
> the window wasn't created by the presenting client, and the Security
> extension comes into play. But that would be a rather exotic scenario,
> so I don't think we need to consider it here.)

An unflip might happen at any time when the window is reconfigured and
the check_flip_window function returns false. Then we need again a
pixmap for the window to paint to.

> Unfortunately, I've come to realize that this doesn't work correctly in
> all cases. Consider this scenario:
>
> A client does one or more presentations to a window, which can be
> executed as a flip. At some point it stops doing presentations, and
> instead uses other X11 requests to update the window contents.
>
> With the implementation in this patch, the latter updates will only
> affect the original window pixmap, not the flip pixmap, so they won't be
> visible to the Wayland compositor and its output (until an unflip to the
> original window pixmap is triggered for some reason).

This is indeed a problematic corner case. But do such clients really
exist? A client using one of its child windows to flip pixmaps on,
most likely with DRI, and then at some point deciding to paint to the
current window pixmap of the same child window directly instead seems
kind of odd.
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver] Correct xorg_list_is_empty return value description The helper xorg_list_is_empty returns True when the list is empty and not when it contains one or more elements.

2018-02-09 Thread Roman Gilg
Signed-off-by: Roman Gilg 
---
 include/list.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/list.h b/include/list.h
index 3f0574d..f81d97f 100644
--- a/include/list.h
+++ b/include/list.h
@@ -211,7 +211,8 @@ xorg_list_del(struct xorg_list *entry)
  * Example:
  * xorg_list_is_empty(&bar->list_of_foos);
  *
- * @return True if the list contains one or more elements or False otherwise.
+ * @return True if the list is empty or False if the list contains one or more
+ * elements.
  */
 static inline int
 xorg_list_is_empty(struct xorg_list *head)
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH] Correct xorg_list_is_empty return value description

2018-02-09 Thread Roman Gilg
The helper xorg_list_is_empty returns True when the list is empty and not when
it contains one or more elements.

Signed-off-by: Roman Gilg 
---
 include/list.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/list.h b/include/list.h
index 3f0574d..f81d97f 100644
--- a/include/list.h
+++ b/include/list.h
@@ -211,7 +211,8 @@ xorg_list_del(struct xorg_list *entry)
  * Example:
  * xorg_list_is_empty(&bar->list_of_foos);
  *
- * @return True if the list contains one or more elements or False otherwise.
+ * @return True if the list is empty or False if the list contains one or more
+ * elements.
  */
 static inline int
 xorg_list_is_empty(struct xorg_list *head)
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Re: xserver 1.20 RC1 tomorrow

2018-02-27 Thread Roman Gilg
On Tue, Feb 27, 2018 at 10:59 PM, Adam Jackson  wrote:
> 4) https://patchwork.freedesktop.org/series/37274/
> Per-window flips for Xwayland. No xfree86 changes.

Michel gave me feedback on my patches in the last weeks and I did
changes to some parts because of that. I planned on posting a new
patch series with these changes replacing the current one. I can do
this today.
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver v2 02/22] present: Preliminary internal flip mode API

2018-02-28 Thread Roman Gilg
Add some basic function hooks to our future present-internal flip mode API,
that will allow us to share functionality in between modes and move more code
in separate files.

Signed-off-by: Roman Gilg 
---
 present/present_priv.h   | 26 +++---
 present/present_scmd.c   | 20 ++--
 present/present_screen.c |  4 +++-
 3 files changed, 44 insertions(+), 6 deletions(-)

diff --git a/present/present_priv.h b/present/present_priv.h
index 5abec06..738c8aa 100644
--- a/present/present_priv.h
+++ b/present/present_priv.h
@@ -83,6 +83,20 @@ struct present_vblank {
 Boolabort_flip; /* aborting this flip */
 };
 
+/*
+ * Mode hooks
+ */
+typedef Bool (*present_priv_check_flip_ptr)(RRCrtcPtr crtc,
+WindowPtr window,
+PixmapPtr pixmap,
+Bool sync_flip,
+RegionPtr valid,
+int16_t x_off,
+int16_t y_off);
+typedef void (*present_priv_check_flip_window_ptr)(WindowPtr window);
+
+typedef void (*present_priv_create_event_id_ptr)(present_vblank_ptr vblank);
+
 typedef struct present_screen_priv {
 CloseScreenProcPtr  CloseScreen;
 ConfigNotifyProcPtr ConfigNotify;
@@ -103,6 +117,12 @@ typedef struct present_screen_priv {
 Boolflip_sync;
 
 present_screen_info_ptr info;
+
+/* Mode hooks */
+present_priv_check_flip_ptr check_flip;
+present_priv_check_flip_window_ptr  check_flip_window;
+
+present_priv_create_event_id_ptrcreate_event_id;
 } present_screen_priv_rec, *present_screen_priv_ptr;
 
 #define wrap(priv,real,mem,func) {\
@@ -316,9 +336,6 @@ present_restore_screen_pixmap(ScreenPtr screen);
 void
 present_set_abort_flip(ScreenPtr screen);
 
-void
-present_check_flip_window(WindowPtr window);
-
 RRCrtcPtr
 present_get_crtc(WindowPtr window);
 
@@ -328,6 +345,9 @@ present_query_capabilities(RRCrtcPtr crtc);
 Bool
 present_init(void);
 
+void
+present_scmd_init_mode_hooks(present_screen_priv_ptr screen_priv);
+
 /*
  * present_screen.c
  */
diff --git a/present/present_scmd.c b/present/present_scmd.c
index 8b83876..f40e5ab 100644
--- a/present/present_scmd.c
+++ b/present/present_scmd.c
@@ -68,6 +68,12 @@ msc_is_equal_or_after(uint64_t test, uint64_t reference)
 return (int64_t)(test - reference) >= 0;
 }
 
+static void
+present_scmd_create_event_id(present_vblank_ptr vblank)
+{
+vblank->event_id = ++present_event_id;
+}
+
 static inline PixmapPtr
 present_flip_pending_pixmap(ScreenPtr screen)
 {
@@ -475,7 +481,7 @@ present_event_notify(uint64_t event_id, uint64_t ust, 
uint64_t msc)
  * 'window' is being reconfigured. Check to see if it is involved
  * in flipping and clean up as necessary
  */
-void
+static void
 present_check_flip_window (WindowPtr window)
 {
 ScreenPtr   screen = window->drawable.pScreen;
@@ -804,7 +810,8 @@ present_pixmap(WindowPtr window,
 vblank->screen = screen;
 vblank->window = window;
 vblank->pixmap = pixmap;
-vblank->event_id = ++present_event_id;
+present_scmd_create_event_id(vblank);
+
 if (pixmap) {
 vblank->kind = PresentCompleteKindPixmap;
 pixmap->refcnt++;
@@ -982,6 +989,15 @@ present_vblank_destroy(present_vblank_ptr vblank)
 free(vblank);
 }
 
+void
+present_scmd_init_mode_hooks(present_screen_priv_ptr screen_priv)
+{
+screen_priv->check_flip =   &present_check_flip;
+screen_priv->check_flip_window  =   &present_check_flip_window;
+
+screen_priv->create_event_id=   &present_scmd_create_event_id;
+}
+
 Bool
 present_init(void)
 {
diff --git a/present/present_screen.c b/present/present_screen.c
index 9d03c8a..454cc53 100644
--- a/present/present_screen.c
+++ b/present/present_screen.c
@@ -161,7 +161,7 @@ present_clip_notify(WindowPtr window, int dx, int dy)
 ScreenPtr screen = window->drawable.pScreen;
 present_screen_priv_ptr screen_priv = present_screen_priv(screen);
 
-present_check_flip_window(window);
+screen_priv->check_flip_window(window);
 unwrap(screen_priv, screen, ClipNotify)
 if (screen->ClipNotify)
 screen->ClipNotify (window, dx, dy);
@@ -194,6 +194,8 @@ present_screen_init(ScreenPtr screen, 
present_screen_info_ptr info)
 
 dixSetPrivate(&screen->devPrivates, &present_screen_private_key, 
screen_priv);
 
+present_scmd_init_mode_hooks(screen_priv);
+
 present_fake_screen_init(screen);
 }
 
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver v2 00/22] Per window flips in Present with support for them in Xwayland

2018-02-28 Thread Roman Gilg
This revision provides changes requested by Michel Dänzer. In particular
flips without copies in window flip mode are now possible and clients can
queue flips on Xwayland.


___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver v2 01/22] present: Move screen flip functionality in separate file

2018-02-28 Thread Roman Gilg
As a preperation for future flip mode alternatives move most of the
functionality from 'present.c' into a separate file.

Leave some functions needed by future other flip modes in 'present.c'.

Signed-off-by: Roman Gilg 
---
 present/Makefile.am|   1 +
 present/meson.build|   1 +
 present/present.c  | 969 +--
 present/present_priv.h | 116 +++---
 present/present_scmd.c | 992 +
 5 files changed, 1067 insertions(+), 1012 deletions(-)
 create mode 100644 present/present_scmd.c

diff --git a/present/Makefile.am b/present/Makefile.am
index 7fea669..3b458fd 100644
--- a/present/Makefile.am
+++ b/present/Makefile.am
@@ -12,6 +12,7 @@ libpresent_la_SOURCES = \
present_notify.c \
present_priv.h \
present_request.c \
+   present_scmd.c \
present_screen.c
 
 sdk_HEADERS = present.h presentext.h
diff --git a/present/meson.build b/present/meson.build
index a4296ca..bbe0de5 100644
--- a/present/meson.build
+++ b/present/meson.build
@@ -5,6 +5,7 @@ srcs_present = [
 'present_fence.c',
 'present_notify.c',
 'present_request.c',
+'present_scmd.c',
 'present_screen.c',
 ]
 
diff --git a/present/present.c b/present/present.c
index 176e89c..ec29533 100644
--- a/present/present.c
+++ b/present/present.c
@@ -26,51 +26,11 @@
 
 #include "present_priv.h"
 #include 
-#include 
-#include 
-#ifdef MONOTONIC_CLOCK
-#include 
-#endif
-
-static uint64_t present_event_id;
-static struct xorg_list present_exec_queue;
-static struct xorg_list present_flip_queue;
-
-#if 0
-#define DebugPresent(x) ErrorF x
-#else
-#define DebugPresent(x)
-#endif
-
-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
- * FALSE if the first MSC value is before the second one
- */
-static Bool
-msc_is_equal_or_after(uint64_t test, uint64_t reference)
-{
-return (int64_t)(test - reference) >= 0;
-}
 
 /*
  * Copies the update region from a pixmap to the target drawable
  */
-static void
+void
 present_copy_region(DrawablePtr drawable,
 PixmapPtr pixmap,
 RegionPtr update,
@@ -103,120 +63,7 @@ present_copy_region(DrawablePtr drawable,
 FreeScratchGC(gc);
 }
 
-static inline PixmapPtr
-present_flip_pending_pixmap(ScreenPtr screen)
-{
-present_screen_priv_ptr screen_priv = present_screen_priv(screen);
-
-if (!screen_priv)
-return NULL;
-
-if (!screen_priv->flip_pending)
-return NULL;
-
-return screen_priv->flip_pending->pixmap;
-}
-
-static Bool
-present_check_flip(RRCrtcPtrcrtc,
-   WindowPtrwindow,
-   PixmapPtrpixmap,
-   Bool sync_flip,
-   RegionPtrvalid,
-   int16_t  x_off,
-   int16_t  y_off)
-{
-ScreenPtr   screen = window->drawable.pScreen;
-PixmapPtr   window_pixmap;
-WindowPtr   root = screen->root;
-present_screen_priv_ptr screen_priv = present_screen_priv(screen);
-
-if (!screen_priv)
-return FALSE;
-
-if (!screen_priv->info)
-return FALSE;
-
-if (!crtc)
-return FALSE;
-
-/* Check to see if the driver supports flips at all */
-if (!screen_priv->info->flip)
-return FALSE;
-
-/* Make sure the window hasn't been redirected with Composite */
-window_pixmap = screen->GetWindowPixmap(window);
-if (window_pixmap != screen->GetScreenPixmap(screen) &&
-window_pixmap != screen_priv->flip_pixmap &&
-window_pixmap != present_flip_pending_pixmap(screen))
-return FALSE;
-
-/* Check for full-screen window */
-if (!RegionEqual(&window->clipList, &root->winSize)) {
-return FALSE;
-}
-
-/* Source pixmap must align with window exactly */
-if (x_off || y_off) {
-return FALSE;
-}
-
-/* Make sure the area marked as valid fills the screen */
-if (valid && !RegionEqual(valid, &root->winSize)) {
-return FALSE;
-}
-
-/* Does the window match the pixmap exactly? */
-if (window->drawable.x != 0 || window->drawable.y != 0 ||
-#ifdef COMPOSITE
-window->drawable.x != pixmap->screen_x || window->drawable.y != 
pixmap->screen_y ||
-#endif
-window->drawable.width != pixmap->drawable.width ||
-win

[PATCH xserver v2 05/22] present: Refactor execute in separate file

2018-02-28 Thread Roman Gilg
To be shared by multiple flip modes, refactor execute functionality,
such that logical chunks can go in new separate file.

Signed-off-by: Roman Gilg 
---
 present/Makefile.am   |   1 +
 present/meson.build   |   1 +
 present/present_execute.c | 116 ++
 present/present_priv.h|  12 +
 present/present_scmd.c|  66 +++---
 5 files changed, 136 insertions(+), 60 deletions(-)
 create mode 100644 present/present_execute.c

diff --git a/present/Makefile.am b/present/Makefile.am
index 3d3d38d..55ad295 100644
--- a/present/Makefile.am
+++ b/present/Makefile.am
@@ -7,6 +7,7 @@ libpresent_la_SOURCES = \
present.h \
present.c \
present_event.c \
+   present_execute.c \
present_fake.c \
present_fence.c \
present_notify.c \
diff --git a/present/meson.build b/present/meson.build
index 801e810..5e1dd3c 100644
--- a/present/meson.build
+++ b/present/meson.build
@@ -1,6 +1,7 @@
 srcs_present = [
 'present.c',
 'present_event.c',
+'present_execute.c',
 'present_fake.c',
 'present_fence.c',
 'present_notify.c',
diff --git a/present/present_execute.c b/present/present_execute.c
new file mode 100644
index 000..e45e547
--- /dev/null
+++ b/present/present_execute.c
@@ -0,0 +1,116 @@
+/*
+ * Copyright © 2013 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include 
+#endif
+
+#include "present_priv.h"
+
+/*
+ * Called when the wait fence is triggered; just gets the current msc/ust and
+ * calls the proper execute again. That will re-check the fence and pend the
+ * request again if it's still not actually ready
+ */
+static void
+present_wait_fence_triggered(void *param)
+{
+present_vblank_ptr  vblank = param;
+ScreenPtr   screen = vblank->screen;
+present_screen_priv_ptr screen_priv = present_screen_priv(screen);
+
+screen_priv->re_execute(vblank);
+}
+
+Bool
+present_execute_wait(present_vblank_ptr vblank, uint64_t crtc_msc)
+{
+WindowPtr   window = vblank->window;
+ScreenPtr   screen = window->drawable.pScreen;
+present_screen_priv_ptr screen_priv = present_screen_priv(screen);
+
+if (vblank->requeue) {
+vblank->requeue = FALSE;
+if (msc_is_after(vblank->target_msc, crtc_msc) &&
+Success == screen_priv->queue_vblank(screen,
+ vblank->crtc,
+ vblank->event_id,
+ vblank->target_msc))
+return TRUE;
+}
+
+if (vblank->wait_fence) {
+if (!present_fence_check_triggered(vblank->wait_fence)) {
+present_fence_set_callback(vblank->wait_fence, 
present_wait_fence_triggered, vblank);
+return TRUE;
+}
+}
+return FALSE;
+}
+
+void
+present_execute_copy(present_vblank_ptr vblank, uint64_t crtc_msc)
+{
+WindowPtr   window = vblank->window;
+ScreenPtr   screen = window->drawable.pScreen;
+present_screen_priv_ptr screen_priv = present_screen_priv(screen);
+
+/* If present_flip failed, we may have to requeue for the target MSC */
+if (vblank->target_msc == crtc_msc + 1 &&
+Success == screen_priv->queue_vblank(screen,
+ vblank->crtc,
+ vblank->event_id,
+ vblank->target_msc)) {
+vblank->queued = TRUE;
+return;
+}
+
+present_copy_region(&windo

[PATCH xserver v2 09/22] present: Refactor present_screen_init

2018-02-28 Thread Roman Gilg
To initialize easily different flip modes, refactor
'present_screen_init'.

Signed-off-by: Roman Gilg 
---
 present/present_screen.c | 46 +-
 1 file changed, 33 insertions(+), 13 deletions(-)

diff --git a/present/present_screen.c b/present/present_screen.c
index 98f701a..868eaf8 100644
--- a/present/present_screen.c
+++ b/present/present_screen.c
@@ -170,32 +170,52 @@ present_clip_notify(WindowPtr window, int dx, int dy)
 wrap(screen_priv, screen, ClipNotify, present_clip_notify);
 }
 
+static Bool
+present_screen_register_priv_keys(void)
+{
+if (!dixRegisterPrivateKey(&present_screen_private_key, PRIVATE_SCREEN, 0))
+return FALSE;
+
+if (!dixRegisterPrivateKey(&present_window_private_key, PRIVATE_WINDOW, 0))
+return FALSE;
+
+return TRUE;
+}
+
+static present_screen_priv_ptr
+present_screen_priv_init(ScreenPtr screen)
+{
+present_screen_priv_ptr screen_priv;
+
+screen_priv = calloc(1, sizeof (present_screen_priv_rec));
+if (!screen_priv)
+return NULL;
+
+wrap(screen_priv, screen, CloseScreen, present_close_screen);
+wrap(screen_priv, screen, DestroyWindow, present_destroy_window);
+wrap(screen_priv, screen, ConfigNotify, present_config_notify);
+wrap(screen_priv, screen, ClipNotify, present_clip_notify);
+
+dixSetPrivate(&screen->devPrivates, &present_screen_private_key, 
screen_priv);
+
+return screen_priv;
+}
+
 /*
  * Initialize a screen for use with present
  */
 int
 present_screen_init(ScreenPtr screen, present_screen_info_ptr info)
 {
-if (!dixRegisterPrivateKey(&present_screen_private_key, PRIVATE_SCREEN, 0))
-return FALSE;
-
-if (!dixRegisterPrivateKey(&present_window_private_key, PRIVATE_WINDOW, 0))
+if (!present_screen_register_priv_keys())
 return FALSE;
 
 if (!present_screen_priv(screen)) {
-present_screen_priv_ptr screen_priv = calloc(1, sizeof 
(present_screen_priv_rec));
+present_screen_priv_ptr screen_priv = present_screen_priv_init(screen);
 if (!screen_priv)
 return FALSE;
 
-wrap(screen_priv, screen, CloseScreen, present_close_screen);
-wrap(screen_priv, screen, DestroyWindow, present_destroy_window);
-wrap(screen_priv, screen, ConfigNotify, present_config_notify);
-wrap(screen_priv, screen, ClipNotify, present_clip_notify);
-
 screen_priv->info = info;
-
-dixSetPrivate(&screen->devPrivates, &present_screen_private_key, 
screen_priv);
-
 present_scmd_init_mode_hooks(screen_priv);
 
 present_fake_screen_init(screen);
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver v2 04/22] present: Add flip mode API hooks for several functions

2018-02-28 Thread Roman Gilg
Add 'queue_vblank', 'flush' and 're_execute' hooks, that
are supposed to be shared with other flip modes.

Signed-off-by: Roman Gilg 
---
 present/present_priv.h | 12 
 present/present_scmd.c |  3 +++
 2 files changed, 15 insertions(+)

diff --git a/present/present_priv.h b/present/present_priv.h
index 077a823..017e204 100644
--- a/present/present_priv.h
+++ b/present/present_priv.h
@@ -97,6 +97,13 @@ typedef void (*present_priv_check_flip_window_ptr)(WindowPtr 
window);
 
 typedef void (*present_priv_create_event_id_ptr)(present_vblank_ptr vblank);
 
+typedef int (*present_priv_queue_vblank_ptr)(ScreenPtr screen,
+ RRCrtcPtr crtc,
+ uint64_t event_id,
+ uint64_t msc);
+typedef void (*present_priv_flush_ptr)(WindowPtr window);
+typedef void (*present_priv_re_execute_ptr)(present_vblank_ptr vblank);
+
 typedef struct present_screen_priv {
 CloseScreenProcPtr  CloseScreen;
 ConfigNotifyProcPtr ConfigNotify;
@@ -123,6 +130,11 @@ typedef struct present_screen_priv {
 present_priv_check_flip_window_ptr  check_flip_window;
 
 present_priv_create_event_id_ptrcreate_event_id;
+
+present_priv_queue_vblank_ptr   queue_vblank;
+present_priv_flush_ptr  flush;
+present_priv_re_execute_ptr re_execute;
+
 } present_screen_priv_rec, *present_screen_priv_ptr;
 
 #define wrap(priv,real,mem,func) {\
diff --git a/present/present_scmd.c b/present/present_scmd.c
index 86b2508..6f5e733 100644
--- a/present/present_scmd.c
+++ b/present/present_scmd.c
@@ -877,6 +877,9 @@ present_scmd_init_mode_hooks(present_screen_priv_ptr 
screen_priv)
 screen_priv->check_flip_window  =   &present_check_flip_window;
 
 screen_priv->create_event_id=   &present_scmd_create_event_id;
+screen_priv->queue_vblank   =   &present_queue_vblank;
+screen_priv->flush  =   &present_flush;
+screen_priv->re_execute =   &present_re_execute;
 }
 
 Bool
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver v2 07/22] present: Move timings adjustment in common part of flip mode API

2018-02-28 Thread Roman Gilg
To reduce future code duplication refactor timings adjustment out
as a separate function.

Signed-off-by: Roman Gilg 
---
 present/present.c  | 38 ++
 present/present_priv.h |  7 +++
 present/present_scmd.c | 34 +-
 3 files changed, 50 insertions(+), 29 deletions(-)

diff --git a/present/present.c b/present/present.c
index ddd9c1c..2c8adb8 100644
--- a/present/present.c
+++ b/present/present.c
@@ -28,6 +28,17 @@
 #include 
 
 /*
+ * Returns:
+ * TRUE if the first MSC value is equal to or after the second one
+ * FALSE if the first MSC value is before the second one
+ */
+static Bool
+msc_is_equal_or_after(uint64_t test, uint64_t reference)
+{
+return (int64_t)(test - reference) >= 0;
+}
+
+/*
  * Copies the update region from a pixmap to the target drawable
  */
 void
@@ -109,6 +120,33 @@ present_set_tree_pixmap(WindowPtr window,
 TraverseTree(window, present_set_tree_pixmap_visit, &visit);
 }
 
+void
+present_adjust_timings(uint32_t options,
+   uint64_t *crtc_msc,
+   uint64_t *target_msc,
+   uint64_t divisor,
+   uint64_t remainder)
+{
+/* Adjust target_msc to match modulus
+ */
+if (msc_is_equal_or_after(*crtc_msc, *target_msc)) {
+if (divisor != 0) {
+*target_msc = *crtc_msc - (*crtc_msc % divisor) + remainder;
+if (options & PresentOptionAsync) {
+if (msc_is_after(*crtc_msc, *target_msc))
+*target_msc += divisor;
+} else {
+if (msc_is_equal_or_after(*crtc_msc, *target_msc))
+*target_msc += divisor;
+}
+} else {
+*target_msc = *crtc_msc;
+if (!(options & PresentOptionAsync))
+(*target_msc)++;
+}
+}
+}
+
 int
 present_pixmap(WindowPtr window,
PixmapPtr pixmap,
diff --git a/present/present_priv.h b/present/present_priv.h
index 44122d5..26d6b67 100644
--- a/present/present_priv.h
+++ b/present/present_priv.h
@@ -234,6 +234,13 @@ present_set_tree_pixmap(WindowPtr window,
 PixmapPtr expected,
 PixmapPtr pixmap);
 
+void
+present_adjust_timings(uint32_t options,
+   uint64_t *crtc_msc,
+   uint64_t *target_msc,
+   uint64_t divisor,
+   uint64_t remainder);
+
 int
 present_pixmap(WindowPtr window,
PixmapPtr pixmap,
diff --git a/present/present_scmd.c b/present/present_scmd.c
index fa886f8..7ea7552 100644
--- a/present/present_scmd.c
+++ b/present/present_scmd.c
@@ -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 equal to or after the second one
- * FALSE if the first MSC value is before the second one
- */
-static Bool
-msc_is_equal_or_after(uint64_t test, uint64_t reference)
-{
-return (int64_t)(test - reference) >= 0;
-}
-
 static void
 present_scmd_create_event_id(present_vblank_ptr vblank)
 {
@@ -665,24 +654,11 @@ present_scmd_pixmap(WindowPtr window,
 window_priv->msc = crtc_msc;
 }
 
-/* Adjust target_msc to match modulus
- */
-if (msc_is_equal_or_after(crtc_msc, target_msc)) {
-if (divisor != 0) {
-target_msc = crtc_msc - (crtc_msc % divisor) + remainder;
-if (options & PresentOptionAsync) {
-if (msc_is_after(crtc_msc, target_msc))
-target_msc += divisor;
-} else {
-if (msc_is_equal_or_after(crtc_msc, target_msc))
-target_msc += divisor;
-}
-} else {
-target_msc = crtc_msc;
-if (!(options & PresentOptionAsync))
-target_msc++;
-}
-}
+present_adjust_timings(options,
+   &crtc_msc,
+   &target_msc,
+   divisor,
+   remainder);
 
 /*
  * Look for a matching presentation already on the list and
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver v2 03/22] present: Move vblank functionality in seperate file

2018-02-28 Thread Roman Gilg
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 
---
 present/Makefile.am  |   3 +-
 present/meson.build  |   1 +
 present/present_priv.h   |  44 ++-
 present/present_scmd.c   | 153 
 present/present_vblank.c | 197 +++
 5 files changed, 258 insertions(+), 140 deletions(-)
 create mode 100644 present/present_vblank.c

diff --git a/present/Makefile.am b/present/Makefile.am
index 3b458fd..3d3d38d 100644
--- a/present/Makefile.am
+++ b/present/Makefile.am
@@ -13,6 +13,7 @@ libpresent_la_SOURCES = \
present_priv.h \
present_request.c \
present_scmd.c \
-   present_screen.c
+   present_screen.c \
+   present_vblank.c
 
 sdk_HEADERS = present.h presentext.h
diff --git a/present/meson.build b/present/meson.build
index bbe0de5..801e810 100644
--- a/present/meson.build
+++ b/present/meson.build
@@ -7,6 +7,7 @@ srcs_present = [
 'present_request.c',
 'present_scmd.c',
 'present_screen.c',
+'present_vblank.c',
 ]
 
 libxserver_present = static_library('libxserver_present',
diff --git a/present/present_priv.h b/present/present_priv.h
index 738c8aa..077a823 100644
--- a/present/present_priv.h
+++ b/present/present_priv.h
@@ -176,6 +176,17 @@ present_window_priv_ptr
 present_get_window_priv(WindowPtr window, Bool create);
 
 /*
+ * 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 inline Bool
+msc_is_after(uint64_t test, uint64_t reference)
+{
+return (int64_t)(test - reference) > 0;
+}
+
+/*
  * present.c
  */
 void
@@ -325,9 +336,6 @@ void
 present_abort_vblank(ScreenPtr screen, RRCrtcPtr crtc, uint64_t event_id, 
uint64_t msc);
 
 void
-present_vblank_destroy(present_vblank_ptr vblank);
-
-void
 present_flip_destroy(ScreenPtr screen);
 
 void
@@ -352,4 +360,34 @@ present_scmd_init_mode_hooks(present_screen_priv_ptr 
screen_priv);
  * present_screen.c
  */
 
+/*
+ * present_vblank.c
+ */
+void
+present_vblank_notify(present_vblank_ptr vblank, CARD8 kind, CARD8 mode, 
uint64_t ust, uint64_t crtc_msc);
+
+present_vblank_ptr
+present_vblank_create(WindowPtr window,
+  PixmapPtr pixmap,
+  CARD32 serial,
+  RegionPtr valid,
+  RegionPtr update,
+  int16_t x_off,
+  int16_t y_off,
+  RRCrtcPtr target_crtc,
+  SyncFence *wait_fence,
+  SyncFence *idle_fence,
+  uint32_t options,
+  const uint32_t *capabilities,
+  present_notify_ptr notifies,
+  int num_notifies,
+  uint64_t *target_msc,
+  uint64_t crtc_msc);
+
+void
+present_vblank_scrap(present_vblank_ptr vblank);
+
+void
+present_vblank_destroy(present_vblank_ptr vblank);
+
 #endif /*  _PRESENT_PRIV_H_ */
diff --git a/present/present_scmd.c b/present/present_scmd.c
index f40e5ab..86b2508 100644
--- a/present/present_scmd.c
+++ b/present/present_scmd.c
@@ -48,17 +48,6 @@ 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
  * FALSE if the first MSC value is before the second one
  */
@@ -171,22 +160,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)
 {
@@ -800,79 +773,26 @@ present_pixmap(WindowPtr window,
 }
 }
 
-vblank = calloc (1, sizeof (present_vblank_rec));
+vblank = present_vblank_create(window,
+   pixmap,
+   serial,
+   val

[PATCH xserver v2 08/22] present: Add more hooks to internal flip mode API

2018-02-28 Thread Roman Gilg
Add hooks to query caps, get crtcs, abort vblanks and destroy
a flip.

Signed-off-by: Roman Gilg 
---
 present/present.c| 28 
 present/present_priv.h   | 33 +
 present/present_scmd.c   | 38 ++
 present/present_screen.c |  6 --
 4 files changed, 71 insertions(+), 34 deletions(-)

diff --git a/present/present.c b/present/present.c
index 2c8adb8..28cac55 100644
--- a/present/present.c
+++ b/present/present.c
@@ -38,6 +38,34 @@ msc_is_equal_or_after(uint64_t test, uint64_t reference)
 return (int64_t)(test - reference) >= 0;
 }
 
+uint32_t
+present_query_capabilities(RRCrtcPtr crtc)
+{
+present_screen_priv_ptr screen_priv;
+
+if (!crtc)
+return 0;
+
+screen_priv = present_screen_priv(crtc->pScreen);
+
+if (!screen_priv)
+return 0;
+
+return screen_priv->query_capabilities(screen_priv);
+}
+
+RRCrtcPtr
+present_get_crtc(WindowPtr window)
+{
+ScreenPtr   screen = window->drawable.pScreen;
+present_screen_priv_ptr screen_priv = present_screen_priv(screen);
+
+if (!screen_priv)
+return NULL;
+
+return screen_priv->get_crtc(screen_priv, window);
+}
+
 /*
  * Copies the update region from a pixmap to the target drawable
  */
diff --git a/present/present_priv.h b/present/present_priv.h
index 26d6b67..84da04a 100644
--- a/present/present_priv.h
+++ b/present/present_priv.h
@@ -83,9 +83,15 @@ struct present_vblank {
 Boolabort_flip; /* aborting this flip */
 };
 
+typedef struct present_screen_priv present_screen_priv_rec, 
*present_screen_priv_ptr;
+
 /*
  * Mode hooks
  */
+typedef uint32_t 
(*present_priv_query_capabilities_ptr)(present_screen_priv_ptr screen_priv);
+typedef RRCrtcPtr (*present_priv_get_crtc_ptr)(present_screen_priv_ptr 
screen_priv,
+   WindowPtr window);
+
 typedef Bool (*present_priv_check_flip_ptr)(RRCrtcPtr crtc,
 WindowPtr window,
 PixmapPtr pixmap,
@@ -121,7 +127,13 @@ typedef int (*present_priv_queue_vblank_ptr)(ScreenPtr 
screen,
 typedef void (*present_priv_flush_ptr)(WindowPtr window);
 typedef void (*present_priv_re_execute_ptr)(present_vblank_ptr vblank);
 
-typedef struct present_screen_priv {
+typedef void (*present_priv_abort_vblank_ptr)(ScreenPtr screen,
+  RRCrtcPtr crtc,
+  uint64_t event_id,
+  uint64_t msc);
+typedef void (*present_priv_flip_destroy_ptr)(ScreenPtr screen);
+
+struct present_screen_priv {
 CloseScreenProcPtr  CloseScreen;
 ConfigNotifyProcPtr ConfigNotify;
 DestroyWindowProcPtrDestroyWindow;
@@ -143,6 +155,9 @@ typedef struct present_screen_priv {
 present_screen_info_ptr info;
 
 /* Mode hooks */
+present_priv_query_capabilities_ptr query_capabilities;
+present_priv_get_crtc_ptr   get_crtc;
+
 present_priv_check_flip_ptr check_flip;
 present_priv_check_flip_window_ptr  check_flip_window;
 
@@ -153,7 +168,9 @@ typedef struct present_screen_priv {
 present_priv_flush_ptr  flush;
 present_priv_re_execute_ptr re_execute;
 
-} present_screen_priv_rec, *present_screen_priv_ptr;
+present_priv_abort_vblank_ptr   abort_vblank;
+present_priv_flip_destroy_ptr   flip_destroy;
+};
 
 #define wrap(priv,real,mem,func) {\
 priv->mem = real->mem; \
@@ -219,6 +236,12 @@ msc_is_after(uint64_t test, uint64_t reference)
 /*
  * present.c
  */
+uint32_t
+present_query_capabilities(RRCrtcPtr crtc);
+
+RRCrtcPtr
+present_get_crtc(WindowPtr window);
+
 void
 present_copy_region(DrawablePtr drawable,
 PixmapPtr pixmap,
@@ -393,12 +416,6 @@ present_restore_screen_pixmap(ScreenPtr screen);
 void
 present_set_abort_flip(ScreenPtr screen);
 
-RRCrtcPtr
-present_get_crtc(WindowPtr window);
-
-uint32_t
-present_query_capabilities(RRCrtcPtr crtc);
-
 Bool
 present_init(void);
 
diff --git a/present/present_scmd.c b/present/present_scmd.c
index 7ea7552..282c894 100644
--- a/present/present_scmd.c
+++ b/present/present_scmd.c
@@ -149,34 +149,18 @@ present_flip(RRCrtcPtr crtc,
 return (*screen_priv->info->flip) (crtc, event_id, target_msc, pixmap, 
sync_flip);
 }
 
-RRCrtcPtr
-present_get_crtc(WindowPtr window)
+static RRCrtcPtr
+present_scmd_get_crtc(present_screen_priv_ptr screen_priv, WindowPtr window)
 {
-ScreenPtr   screen = window->drawable.pScreen;
-present_screen_priv_ptr screen_priv = present_screen_priv(screen);
-
-if (!screen_priv)
-return NULL;
-
 if (!screen_priv->info)
 return NULL;
 
 return (*screen_priv->info->get_crtc)(window);
 }
 
-uint32_t
-present_query_capabi

[PATCH xserver v2 06/22] present: Add flip mode API hook for present_pixmap

2018-02-28 Thread Roman Gilg
Make present_pixmap a common function callable by any
flip mode.

Signed-off-by: Roman Gilg 
---
 present/present.c  | 57 ++
 present/present_priv.h | 68 +++---
 present/present_scmd.c | 54 ++-
 3 files changed, 119 insertions(+), 60 deletions(-)

diff --git a/present/present.c b/present/present.c
index ec29533..ddd9c1c 100644
--- a/present/present.c
+++ b/present/present.c
@@ -108,3 +108,60 @@ present_set_tree_pixmap(WindowPtr window,
 return;
 TraverseTree(window, present_set_tree_pixmap_visit, &visit);
 }
+
+int
+present_pixmap(WindowPtr window,
+   PixmapPtr pixmap,
+   CARD32 serial,
+   RegionPtr valid,
+   RegionPtr update,
+   int16_t x_off,
+   int16_t y_off,
+   RRCrtcPtr target_crtc,
+   SyncFence *wait_fence,
+   SyncFence *idle_fence,
+   uint32_t options,
+   uint64_t window_msc,
+   uint64_t divisor,
+   uint64_t remainder,
+   present_notify_ptr notifies,
+   int num_notifies)
+{
+ScreenPtr   screen = window->drawable.pScreen;
+present_screen_priv_ptr screen_priv = present_screen_priv(screen);
+
+return screen_priv->present_pixmap(window,
+   pixmap,
+   serial,
+   valid,
+   update,
+   x_off,
+   y_off,
+   target_crtc,
+   wait_fence,
+   idle_fence,
+   options,
+   window_msc,
+   divisor,
+   remainder,
+   notifies,
+   num_notifies);
+}
+
+int
+present_notify_msc(WindowPtr window,
+   CARD32 serial,
+   uint64_t target_msc,
+   uint64_t divisor,
+   uint64_t remainder)
+{
+return present_pixmap(window,
+  NULL,
+  serial,
+  NULL, NULL,
+  0, 0,
+  NULL,
+  NULL, NULL,
+  divisor == 0 ? PresentOptionAsync : 0,
+  target_msc, divisor, remainder, NULL, 0);
+}
diff --git a/present/present_priv.h b/present/present_priv.h
index a8e07c6..44122d5 100644
--- a/present/present_priv.h
+++ b/present/present_priv.h
@@ -95,6 +95,23 @@ typedef Bool (*present_priv_check_flip_ptr)(RRCrtcPtr crtc,
 int16_t y_off);
 typedef void (*present_priv_check_flip_window_ptr)(WindowPtr window);
 
+typedef int (*present_priv_pixmap_ptr)(WindowPtr window,
+   PixmapPtr pixmap,
+   CARD32 serial,
+   RegionPtr valid,
+   RegionPtr update,
+   int16_t x_off,
+   int16_t y_off,
+   RRCrtcPtr target_crtc,
+   SyncFence *wait_fence,
+   SyncFence *idle_fence,
+   uint32_t options,
+   uint64_t window_msc,
+   uint64_t divisor,
+   uint64_t remainder,
+   present_notify_ptr notifies,
+   int num_notifies);
+
 typedef void (*present_priv_create_event_id_ptr)(present_vblank_ptr vblank);
 
 typedef int (*present_priv_queue_vblank_ptr)(ScreenPtr screen,
@@ -129,6 +146,7 @@ typedef struct present_screen_priv {
 present_priv_check_flip_ptr check_flip;
 present_priv_check_flip_window_ptr  check_flip_window;
 
+present_priv_pixmap_ptr present_pixmap;
 present_priv_create_event_id_ptrcreate_event_id;
 
 present_priv_queue_vblank_ptr   queue_vblank;
@@ -216,6 +234,31 @@ present_set_tree_pixmap(WindowPtr window,
 PixmapPtr expected,
 PixmapPtr pixmap);
 
+int
+present_pixmap(WindowPtr window,
+   PixmapPtr pixmap,
+   CARD32 serial,
+   RegionPtr valid,
+   RegionPtr update,
+   int16_t x_off,
+   int16_t y_off,
+   RRCrtcPtr t

[PATCH xserver v2 12/22] present: Adapt flip mode API hooks for window flip mode

2018-02-28 Thread Roman Gilg
Flipping pixmaps per window needs additional arguments in the
flip mode API. Add these as preperation for window flip mode.

Signed-off-by: Roman Gilg 
---
 present/present_execute.c |  2 ++
 present/present_priv.h| 10 +++---
 present/present_scmd.c|  8 +---
 present/present_screen.c  |  2 +-
 present/present_vblank.c  |  2 +-
 5 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/present/present_execute.c b/present/present_execute.c
index e45e547..e0c755a 100644
--- a/present/present_execute.c
+++ b/present/present_execute.c
@@ -52,6 +52,7 @@ present_execute_wait(present_vblank_ptr vblank, uint64_t 
crtc_msc)
 vblank->requeue = FALSE;
 if (msc_is_after(vblank->target_msc, crtc_msc) &&
 Success == screen_priv->queue_vblank(screen,
+ window,
  vblank->crtc,
  vblank->event_id,
  vblank->target_msc))
@@ -77,6 +78,7 @@ present_execute_copy(present_vblank_ptr vblank, uint64_t 
crtc_msc)
 /* If present_flip failed, we may have to requeue for the target MSC */
 if (vblank->target_msc == crtc_msc + 1 &&
 Success == screen_priv->queue_vblank(screen,
+ window,
  vblank->crtc,
  vblank->event_id,
  vblank->target_msc)) {
diff --git a/present/present_priv.h b/present/present_priv.h
index 4685040..2900e9a 100644
--- a/present/present_priv.h
+++ b/present/present_priv.h
@@ -85,6 +85,7 @@ struct present_vblank {
 };
 
 typedef struct present_screen_priv present_screen_priv_rec, 
*present_screen_priv_ptr;
+typedef struct present_window_priv present_window_priv_rec, 
*present_window_priv_ptr;
 
 /*
  * Mode hooks
@@ -119,9 +120,11 @@ typedef int (*present_priv_pixmap_ptr)(WindowPtr window,
present_notify_ptr notifies,
int num_notifies);
 
-typedef void (*present_priv_create_event_id_ptr)(present_vblank_ptr vblank);
+typedef void (*present_priv_create_event_id_ptr)(present_window_priv_ptr 
window_priv,
+ present_vblank_ptr vblank);
 
 typedef int (*present_priv_queue_vblank_ptr)(ScreenPtr screen,
+ WindowPtr window,
  RRCrtcPtr crtc,
  uint64_t event_id,
  uint64_t msc);
@@ -129,6 +132,7 @@ typedef void (*present_priv_flush_ptr)(WindowPtr window);
 typedef void (*present_priv_re_execute_ptr)(present_vblank_ptr vblank);
 
 typedef void (*present_priv_abort_vblank_ptr)(ScreenPtr screen,
+  WindowPtr window,
   RRCrtcPtr crtc,
   uint64_t event_id,
   uint64_t msc);
@@ -201,7 +205,7 @@ typedef struct present_event {
 int mask;
 } present_event_rec;
 
-typedef struct present_window_priv {
+struct present_window_priv {
 WindowPtr  window;
 present_event_ptr  events;
 RRCrtcPtr  crtc;/* Last reported CRTC from get_ust_msc 
*/
@@ -218,7 +222,7 @@ typedef struct present_window_priv {
 
 present_vblank_ptr flip_pending;
 present_vblank_ptr flip_active;
-} present_window_priv_rec, *present_window_priv_ptr;
+};
 
 #define PresentCrtcNeverSet ((RRCrtcPtr) 1)
 
diff --git a/present/present_scmd.c b/present/present_scmd.c
index 282c894..935525f 100644
--- a/present/present_scmd.c
+++ b/present/present_scmd.c
@@ -47,7 +47,8 @@ static void
 present_execute(present_vblank_ptr vblank, uint64_t ust, uint64_t crtc_msc);
 
 static void
-present_scmd_create_event_id(present_vblank_ptr vblank)
+present_scmd_create_event_id(present_window_priv_ptr window_priv,
+ present_vblank_ptr vblank)
 {
 vblank->event_id = ++present_event_id;
 }
@@ -195,6 +196,7 @@ present_flush(WindowPtr window)
 
 static int
 present_queue_vblank(ScreenPtr screen,
+ WindowPtr window,
  RRCrtcPtr crtc,
  uint64_t event_id,
  uint64_t msc)
@@ -702,7 +704,7 @@ present_scmd_pixmap(WindowPtr window,
 xorg_list_append(&vblank->event_queue, &present_exec_queue);
 vblank->queued = TRUE;
 if (msc_is_after(target_msc, crtc_msc)) {
-ret = present_queue_vblank(screen, target_crtc, vblank->event_id, 
target_msc);
+ret = present_queue_vblank(screen, window, target_crtc, 
vblank->event_id, target_msc);

[PATCH xserver v2 13/22] present: Add driver facing window flip mode hooks

2018-02-28 Thread Roman Gilg
To enable special functionality of window flips introduce for window flips
a separate set of driver facing function hooks.

Signed-off-by: Roman Gilg 
---
 present/present.h  | 43 +++
 present/present_priv.h |  1 +
 2 files changed, 44 insertions(+)

diff --git a/present/present.h b/present/present.h
index aab2e16..b87d5bd 100644
--- a/present/present.h
+++ b/present/present.h
@@ -36,6 +36,7 @@ typedef RRCrtcPtr (*present_get_crtc_ptr) (WindowPtr window);
 /* Return the current ust/msc for 'crtc'
  */
 typedef int (*present_get_ust_msc_ptr) (RRCrtcPtr crtc, uint64_t *ust, 
uint64_t *msc);
+typedef int (*present_wnmd_get_ust_msc_ptr) (WindowPtr window, uint64_t *ust, 
uint64_t *msc);
 
 /* Queue callback on 'crtc' for time 'msc'. Call present_event_notify with 
'event_id'
  * at or after 'msc'. Return false if it didn't happen (which might occur if 
'crtc'
@@ -44,12 +45,20 @@ typedef int (*present_get_ust_msc_ptr) (RRCrtcPtr crtc, 
uint64_t *ust, uint64_t
 typedef Bool (*present_queue_vblank_ptr) (RRCrtcPtr crtc,
   uint64_t event_id,
   uint64_t msc);
+typedef Bool (*present_wnmd_queue_vblank_ptr) (WindowPtr window,
+   RRCrtcPtr crtc,
+   uint64_t event_id,
+   uint64_t msc);
 
 /* Abort pending vblank. The extension is no longer interested in
  * 'event_id' which was to be notified at 'msc'. If possible, the
  * driver is free to de-queue the notification.
  */
 typedef void (*present_abort_vblank_ptr) (RRCrtcPtr crtc, uint64_t event_id, 
uint64_t msc);
+typedef void (*present_wnmd_abort_vblank_ptr) (WindowPtr window,
+   RRCrtcPtr crtc,
+   uint64_t event_id,
+   uint64_t msc);
 
 /* Flush pending drawing on 'window' to the hardware.
  */
@@ -75,6 +84,19 @@ typedef Bool (*present_flip_ptr) (RRCrtcPtr crtc,
   uint64_t target_msc,
   PixmapPtr pixmap,
   Bool sync_flip);
+/* Flip pixmap for window, return false if it didn't happen.
+ *
+ * Like present_flip_ptr, additionaly with:
+ *
+ * 'window' used for synchronization.
+ *
+ */
+typedef Bool (*present_wnmd_flip_ptr) (WindowPtr window,
+   RRCrtcPtr crtc,
+   uint64_t event_id,
+   uint64_t target_msc,
+   PixmapPtr pixmap,
+   Bool sync_flip);
 
 /* "unflip" back to the regular screen scanout buffer
  *
@@ -83,6 +105,12 @@ typedef Bool (*present_flip_ptr) (RRCrtcPtr crtc,
 typedef void (*present_unflip_ptr) (ScreenPtr screen,
 uint64_t event_id);
 
+/* Doing flips has been discontinued.
+ *
+ * Inform driver for potential cleanup on its side.
+ */
+typedef void (*present_wnmd_flips_stop_ptr) (WindowPtr window);
+
 #define PRESENT_SCREEN_INFO_VERSION0
 
 typedef struct present_screen_info {
@@ -100,6 +128,21 @@ typedef struct present_screen_info {
 
 } present_screen_info_rec, *present_screen_info_ptr;
 
+typedef struct present_wnmd_info {
+uint32_tversion;
+
+present_get_crtc_ptrget_crtc;
+present_wnmd_get_ust_msc_ptrget_ust_msc;
+present_wnmd_queue_vblank_ptr   queue_vblank;
+present_wnmd_abort_vblank_ptr   abort_vblank;
+present_flush_ptr   flush;
+uint32_tcapabilities;
+present_check_flip_ptr  check_flip;
+present_wnmd_flip_ptr   flip;
+present_wnmd_flips_stop_ptr flips_stop;
+
+} present_wnmd_info_rec, *present_wnmd_info_ptr;
+
 /*
  * Called when 'event_id' occurs. 'ust' and 'msc' indicate when the
  * event actually happened
diff --git a/present/present_priv.h b/present/present_priv.h
index 2900e9a..a732126 100644
--- a/present/present_priv.h
+++ b/present/present_priv.h
@@ -158,6 +158,7 @@ struct present_screen_priv {
 Boolflip_sync;
 
 present_screen_info_ptr info;
+present_wnmd_info_ptr   wnmd_info;
 
 /* Mode hooks */
 present_priv_query_capabilities_ptr query_capabilities;
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver v2 11/22] present: Add flip_idler vblank property

2018-02-28 Thread Roman Gilg
Introduce vblank property for flip modes, that demand explicite
allowance by the driver for vblanks to become idle.

Signed-off-by: Roman Gilg 
---
 present/present_priv.h   | 1 +
 present/present_vblank.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/present/present_priv.h b/present/present_priv.h
index a3e59ac..4685040 100644
--- a/present/present_priv.h
+++ b/present/present_priv.h
@@ -79,6 +79,7 @@ struct present_vblank {
 Boolrequeue;/* on queue, but target_msc has 
changed */
 Boolflip;   /* planning on using flip */
 Boolflip_ready; /* wants to flip, but waiting for 
previous flip or unflip */
+Boolflip_idler; /* driver explicitly permitted idling 
*/
 Boolsync_flip;  /* do flip synchronous to vblank */
 Boolabort_flip; /* aborting this flip */
 };
diff --git a/present/present_vblank.c b/present/present_vblank.c
index 0f1c3e6..00bb65c 100644
--- a/present/present_vblank.c
+++ b/present/present_vblank.c
@@ -104,6 +104,7 @@ present_vblank_create(WindowPtr window,
 vblank->msc_offset = window_priv->msc_offset;
 vblank->notifies = notifies;
 vblank->num_notifies = num_notifies;
+vblank->flip_idler = FALSE;
 
 if (pixmap != NULL &&
 !(options & PresentOptionCopy) &&
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver v2 15/22] present: In window flip mode report damage on flip to driver

2018-02-28 Thread Roman Gilg
Calculate damage before trying to flip and report it to the driver.
This allows drivers to optimize their rendering.

Signed-off-by: Roman Gilg 
---
 present/present.h  |  3 ++-
 present/present_wnmd.c | 24 +---
 2 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/present/present.h b/present/present.h
index 553fd49..8b2e03f 100644
--- a/present/present.h
+++ b/present/present.h
@@ -96,7 +96,8 @@ typedef Bool (*present_wnmd_flip_ptr) (WindowPtr window,
uint64_t event_id,
uint64_t target_msc,
PixmapPtr pixmap,
-   Bool sync_flip);
+   Bool sync_flip,
+   RegionPtr damage);
 
 /* "unflip" back to the regular screen scanout buffer
  *
diff --git a/present/present_wnmd.c b/present/present_wnmd.c
index 14ab721..da503af 100644
--- a/present/present_wnmd.c
+++ b/present/present_wnmd.c
@@ -341,7 +341,8 @@ present_wnmd_flip(WindowPtr window,
   uint64_t event_id,
   uint64_t target_msc,
   PixmapPtr pixmap,
-  Bool sync_flip)
+  Bool sync_flip,
+  RegionPtr damage)
 {
 ScreenPtr   screen = crtc->pScreen;
 present_screen_priv_ptr screen_priv = present_screen_priv(screen);
@@ -351,7 +352,8 @@ present_wnmd_flip(WindowPtr window,
 event_id,
 target_msc,
 pixmap,
-sync_flip);
+sync_flip,
+damage);
 }
 
 static void
@@ -412,12 +414,19 @@ present_wnmd_execute(present_vblank_ptr vblank, uint64_t 
ust, uint64_t crtc_msc)
  */
 xorg_list_add(&vblank->event_queue, &window_priv->flip_queue);
 
+/* Set update region as damaged */
+if (vblank->update) {
+damage = vblank->update;
+RegionIntersect(damage, damage, &window->clipList);
+} else
+damage = &window->clipList;
+
 /* Try to flip - the vblank is now pending
  */
 window_priv->flip_pending = vblank;
 // ask the driver
 if (present_wnmd_flip(vblank->window, vblank->crtc, 
vblank->event_id,
- vblank->target_msc, vblank->pixmap, 
vblank->sync_flip)) {
+ vblank->target_msc, vblank->pixmap, 
vblank->sync_flip, damage)) {
 ScreenPtr screen = window->drawable.pScreen;
 WindowPtr toplvl_window = 
present_wnmd_toplvl_pixmap_window(vblank->window);
 PixmapPtr old_pixmap = screen->GetWindowPixmap(window);
@@ -427,14 +436,7 @@ present_wnmd_execute(present_vblank_ptr vblank, uint64_t 
ust, uint64_t crtc_msc)
 vblank->pixmap->refcnt++;
 dixDestroyPixmap(old_pixmap, old_pixmap->drawable.id);
 
-/* Report update region as damaged
- */
-if (vblank->update) {
-damage = vblank->update;
-RegionIntersect(damage, damage, &window->clipList);
-} else
-damage = &window->clipList;
-
+/* Report damage */
 DamageDamageRegion(&vblank->window->drawable, damage);
 return;
 }
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver v2 10/22] present: Add present_window_priv properties for window flip mode

2018-02-28 Thread Roman Gilg
For window flip mode data about flips needs to be stored per window.
Add properties to 'present_window_priv' and initialize them on creation.

Signed-off-by: Roman Gilg 
---
 present/present_priv.h   | 10 ++
 present/present_screen.c |  6 ++
 2 files changed, 16 insertions(+)

diff --git a/present/present_priv.h b/present/present_priv.h
index 84da04a..a3e59ac 100644
--- a/present/present_priv.h
+++ b/present/present_priv.h
@@ -201,12 +201,22 @@ typedef struct present_event {
 } present_event_rec;
 
 typedef struct present_window_priv {
+WindowPtr  window;
 present_event_ptr  events;
 RRCrtcPtr  crtc;/* Last reported CRTC from get_ust_msc 
*/
 uint64_t   msc_offset;
 uint64_t   msc; /* Last reported MSC from the current 
crtc */
 struct xorg_list   vblank;
 struct xorg_list   notifies;
+
+/* Used for window flips */
+uint64_t   event_id;
+struct xorg_list   exec_queue;
+struct xorg_list   flip_queue;
+struct xorg_list   idle_queue;
+
+present_vblank_ptr flip_pending;
+present_vblank_ptr flip_active;
 } present_window_priv_rec, *present_window_priv_ptr;
 
 #define PresentCrtcNeverSet ((RRCrtcPtr) 1)
diff --git a/present/present_screen.c b/present/present_screen.c
index 868eaf8..d6c9a5e 100644
--- a/present/present_screen.c
+++ b/present/present_screen.c
@@ -45,6 +45,12 @@ present_get_window_priv(WindowPtr window, Bool create)
 return NULL;
 xorg_list_init(&window_priv->vblank);
 xorg_list_init(&window_priv->notifies);
+
+xorg_list_init(&window_priv->exec_queue);
+xorg_list_init(&window_priv->flip_queue);
+xorg_list_init(&window_priv->idle_queue);
+
+window_priv->window = window;
 window_priv->crtc = PresentCrtcNeverSet;
 dixSetPrivate(&window->devPrivates, &present_window_private_key, 
window_priv);
 return window_priv;
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver v2 17/22] present: Add exported init function of window flip mode

2018-02-28 Thread Roman Gilg
Allow drivers now to initialize window flip mode.

Signed-off-by: Roman Gilg 
---
 present/present.h|  2 ++
 present/present_screen.c | 23 ++-
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/present/present.h b/present/present.h
index 8b2e03f..123791d 100644
--- a/present/present.h
+++ b/present/present.h
@@ -164,6 +164,8 @@ present_event_abandon(RRCrtcPtr crtc);
 
 extern _X_EXPORT Bool
 present_screen_init(ScreenPtr screen, present_screen_info_ptr info);
+extern _X_EXPORT Bool
+present_wnmd_screen_init(ScreenPtr screen, present_wnmd_info_ptr info);
 
 typedef void (*present_complete_notify_proc)(WindowPtr window,
  CARD8 kind,
diff --git a/present/present_screen.c b/present/present_screen.c
index 8ad14ad..c7e37c5 100644
--- a/present/present_screen.c
+++ b/present/present_screen.c
@@ -239,7 +239,28 @@ present_screen_priv_init(ScreenPtr screen)
 }
 
 /*
- * Initialize a screen for use with present
+ * Initialize a screen for use with present in window flip mode (wnmd)
+ */
+int
+present_wnmd_screen_init(ScreenPtr screen, present_wnmd_info_ptr info)
+{
+if (!present_screen_register_priv_keys())
+return FALSE;
+
+if (!present_screen_priv(screen)) {
+present_screen_priv_ptr screen_priv = present_screen_priv_init(screen);
+if (!screen_priv)
+return FALSE;
+
+screen_priv->wnmd_info = info;
+present_wnmd_init_mode_hooks(screen_priv);
+}
+
+return TRUE;
+}
+
+/*
+ * Initialize a screen for use with present in default screen flip mode (scmd)
  */
 int
 present_screen_init(ScreenPtr screen, present_screen_info_ptr info)
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver v2 16/22] present: Add cleanups for window flip mode

2018-02-28 Thread Roman Gilg
Make sure that vblanks and windows get cleaned up correctly
in window flip mode.

Signed-off-by: Roman Gilg 
---
 present/present_screen.c | 33 -
 present/present_vblank.c |  2 ++
 2 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/present/present_screen.c b/present/present_screen.c
index b0cae0f..8ad14ad 100644
--- a/present/present_screen.c
+++ b/present/present_screen.c
@@ -109,6 +109,32 @@ present_clear_window_flip(WindowPtr window)
 }
 }
 
+static void
+present_wnmd_clear_window_flip(WindowPtr window)
+{
+present_window_priv_ptr window_priv = present_window_priv(window);
+present_vblank_ptr  vblank, tmp;
+
+if (window_priv->flip_pending) {
+present_wnmd_set_abort_flip(window);
+window_priv->flip_pending->window = NULL;
+}
+
+xorg_list_for_each_entry_safe(vblank, tmp, &window_priv->idle_queue, 
event_queue) {
+present_pixmap_idle(vblank->pixmap, vblank->window, vblank->serial, 
vblank->idle_fence);
+/* The pixmap will be destroyed by freeing the window resources. */
+vblank->pixmap = NULL;
+present_vblank_destroy(vblank);
+}
+
+vblank = window_priv->flip_active;
+if (vblank) {
+present_pixmap_idle(vblank->pixmap, vblank->window, vblank->serial, 
vblank->idle_fence);
+present_vblank_destroy(vblank);
+}
+window_priv->flip_active = NULL;
+}
+
 /*
  * Hook the close window function to clean up our window private
  */
@@ -124,7 +150,12 @@ present_destroy_window(WindowPtr window)
 present_clear_window_notifies(window);
 present_free_events(window);
 present_free_window_vblank(window);
-present_clear_window_flip(window);
+
+if (screen_priv->wnmd_info)
+present_wnmd_clear_window_flip(window);
+else
+present_clear_window_flip(window);
+
 free(window_priv);
 }
 unwrap(screen_priv, screen, DestroyWindow);
diff --git a/present/present_vblank.c b/present/present_vblank.c
index dbfedb4..af6ebe5 100644
--- a/present/present_vblank.c
+++ b/present/present_vblank.c
@@ -169,6 +169,8 @@ present_vblank_destroy(present_vblank_ptr vblank)
 {
 /* Remove vblank from window and screen lists */
 xorg_list_del(&vblank->window_list);
+/* Also make sure vblank is removed from event queue (wnmd) */
+xorg_list_del(&vblank->event_queue);
 
 DebugPresent(("\td %lld %p %8lld: %08lx -> %08lx\n",
   vblank->event_id, vblank, vblank->target_msc,
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver v2 14/22] present: Add window flip mode

2018-02-28 Thread Roman Gilg
In contrast to screen flip mode this mode:
* supports flips per windows (these windows currently need to have the same
  size as their parent windows with the same pixmap),
* sends pixmap idle signals to the client only after the driver has given
  an additional event notify.

This patch only introduces the new mode as a stub. It additionally needs a
driver hook, such that it can get initialized and appropriate cleanup
functions.

Signed-off-by: Roman Gilg 
---
 present/Makefile.am|   3 +-
 present/meson.build|   1 +
 present/present.h  |   6 +
 present/present_priv.h |   9 +
 present/present_wnmd.c | 663 +
 5 files changed, 681 insertions(+), 1 deletion(-)
 create mode 100644 present/present_wnmd.c

diff --git a/present/Makefile.am b/present/Makefile.am
index 55ad295..542f4ca 100644
--- a/present/Makefile.am
+++ b/present/Makefile.am
@@ -15,6 +15,7 @@ libpresent_la_SOURCES = \
present_request.c \
present_scmd.c \
present_screen.c \
-   present_vblank.c
+   present_vblank.c \
+   present_wnmd.c
 
 sdk_HEADERS = present.h presentext.h
diff --git a/present/meson.build b/present/meson.build
index 5e1dd3c..ad4fcff 100644
--- a/present/meson.build
+++ b/present/meson.build
@@ -9,6 +9,7 @@ srcs_present = [
 'present_scmd.c',
 'present_screen.c',
 'present_vblank.c',
+'present_wnmd.c',
 ]
 
 libxserver_present = static_library('libxserver_present',
diff --git a/present/present.h b/present/present.h
index b87d5bd..553fd49 100644
--- a/present/present.h
+++ b/present/present.h
@@ -149,6 +149,12 @@ typedef struct present_wnmd_info {
  */
 extern _X_EXPORT void
 present_event_notify(uint64_t event_id, uint64_t ust, uint64_t msc);
+/*
+ * Called when 'event_id' occurs for 'window'.
+ * 'ust' and 'msc' indicate when the event actually happened
+ */
+extern _X_EXPORT void
+present_wnmd_event_notify(WindowPtr window, uint64_t event_id, uint64_t ust, 
uint64_t msc);
 
 /* 'crtc' has been turned off, so any pending events will never occur.
  */
diff --git a/present/present_priv.h b/present/present_priv.h
index a732126..900acc2 100644
--- a/present/present_priv.h
+++ b/present/present_priv.h
@@ -472,4 +472,13 @@ present_vblank_scrap(present_vblank_ptr vblank);
 void
 present_vblank_destroy(present_vblank_ptr vblank);
 
+/*
+ * present_wnmd.c
+ */
+void
+present_wnmd_set_abort_flip(WindowPtr window);
+
+void
+present_wnmd_init_mode_hooks(present_screen_priv_ptr screen_priv);
+
 #endif /*  _PRESENT_PRIV_H_ */
diff --git a/present/present_wnmd.c b/present/present_wnmd.c
new file mode 100644
index 000..14ab721
--- /dev/null
+++ b/present/present_wnmd.c
@@ -0,0 +1,663 @@
+/*
+ * Copyright © 2018 Roman Gilg
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include 
+#endif
+
+#include "present_priv.h"
+
+/*
+ * Window flip mode
+ *
+ * Provides per-window flips. Flips can be processed on windows that
+ * have the same size as their parents, which they share their pixmap with.
+ *
+ * A flip still requires a copy currently, since the original pixmap needs
+ * to be updated with the new pixmap content. Just a flip of all windows
+ * to the new pixmap is diffcult, because the original pixmap might not be
+ * controlled by the Xserver.
+ *
+ */
+
+static void
+present_wnmd_execute(present_vblank_ptr vblank, uint64_t ust, uint64_t 
crtc_msc);
+
+static void
+present_wnmd_create_event_id(present_window_priv_ptr window_priv, 
present_vblank_ptr vblank)
+{
+vblank->event_id = ++window_priv->event_id;
+}
+
+static uint32_t
+present_wnmd_query_capabilities(present_screen_priv_ptr screen_priv)
+{
+return screen_priv->wnmd_info->capabilities;
+}
+
+st

[PATCH xserver v2 20/22] xwayland: Add fallback timer for msc counting

2018-02-28 Thread Roman Gilg
When the compositor is not sending frame callbacks while we still wait
on buffer release events fake a continuous msc counter with a timer.

Having this timer is a prerequisite for queuing events.

Signed-off-by: Roman Gilg 
---
 hw/xwayland/xwayland-present.c | 70 ++
 hw/xwayland/xwayland.h |  3 ++
 2 files changed, 73 insertions(+)

diff --git a/hw/xwayland/xwayland-present.c b/hw/xwayland/xwayland-present.c
index 2798c2a..3088f03 100644
--- a/hw/xwayland/xwayland-present.c
+++ b/hw/xwayland/xwayland-present.c
@@ -27,6 +27,34 @@
 
 #include 
 
+#define TIMER_LEN_FLIP1000  // 1fps
+
+static void
+xwl_present_free_timer(struct xwl_window *xwl_window)
+{
+TimerFree(xwl_window->present_timer);
+xwl_window->present_timer = NULL;
+}
+
+static CARD32
+xwl_present_timer_callback(OsTimerPtr timer,
+   CARD32 time,
+   void *arg);
+
+static void
+xwl_present_reset_timer(struct xwl_window *xwl_window)
+{
+if ( !xorg_list_is_empty(&xwl_window->present_release_queue) ) {
+xwl_window->present_timer = TimerSet(xwl_window->present_timer,
+ 0,
+ TIMER_LEN_FLIP,
+ &xwl_present_timer_callback,
+ xwl_window);
+} else {
+xwl_present_free_timer(xwl_window);
+}
+}
+
 void
 xwl_present_cleanup(WindowPtr window)
 {
@@ -51,6 +79,10 @@ xwl_present_cleanup(WindowPtr window)
 event->abort = TRUE;
 }
 }
+
+/* Clear timer */
+if ( xorg_list_is_empty(&xwl_window->present_release_queue) )
+xwl_present_free_timer(xwl_window);
 }
 
 static void
@@ -90,6 +122,27 @@ static const struct wl_buffer_listener 
xwl_present_release_listener = {
 xwl_present_buffer_release
 };
 
+CARD32
+xwl_present_timer_callback(OsTimerPtr timer,
+   CARD32 time,
+   void *arg)
+{
+struct xwl_window *xwl_window = arg;
+
+xwl_window->present_timer_firing = TRUE;
+xwl_window->present_msc++;
+xwl_window->present_ust = GetTimeInMicros();
+
+if ( !xorg_list_is_empty(&xwl_window->present_release_queue) ) {
+/* Still events, restart timer */
+return TIMER_LEN_FLIP;
+} else {
+/* No more events, do not restart timer and delete it instead */
+xwl_present_free_timer(xwl_window);
+return 0;
+}
+}
+
 static void
 xwl_present_frame_callback(void *data,
struct wl_callback *callback,
@@ -100,8 +153,18 @@ xwl_present_frame_callback(void *data,
 wl_callback_destroy(xwl_window->present_frame_callback);
 xwl_window->present_frame_callback = NULL;
 
+if (xwl_window->present_timer_firing) {
+/* If the timer is firing, this frame callback is too late */
+return;
+}
+
 xwl_window->present_msc++;
 xwl_window->present_ust = GetTimeInMicros();
+
+/* we do not need the timer anymore for this frame,
+ * reset it for potentially the next one
+ */
+xwl_present_reset_timer(xwl_window);
 }
 
 static const struct wl_callback_listener xwl_present_frame_listener = {
@@ -307,6 +370,13 @@ xwl_present_flip(WindowPtr present_window,
 /* We can flip directly to the main surface (full screen window without 
clips) */
 wl_surface_attach(xwl_window->surface, buffer, 0, 0);
 
+if (!xwl_window->present_timer ||
+xwl_window->present_timer_firing) {
+/* Realign timer */
+xwl_window->present_timer_firing = FALSE;
+xwl_present_reset_timer(xwl_window);
+}
+
 if (!xwl_window->present_frame_callback) {
 xwl_window->present_frame_callback = 
wl_surface_frame(xwl_window->surface);
 wl_callback_add_listener(xwl_window->present_frame_callback,
diff --git a/hw/xwayland/xwayland.h b/hw/xwayland/xwayland.h
index a41c8ca..a64498a 100644
--- a/hw/xwayland/xwayland.h
+++ b/hw/xwayland/xwayland.h
@@ -124,6 +124,9 @@ struct xwl_window {
 uint64_t present_msc;
 uint64_t present_ust;
 
+OsTimerPtr present_timer;
+Bool present_timer_firing;
+
 struct wl_callback *present_frame_callback;
 struct wl_callback *present_sync_callback;
 struct xorg_list present_release_queue;
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver v2 19/22] xwayland: Preliminary support for Present's new window flip mode

2018-02-28 Thread Roman Gilg
Introduce support for Present's window flip mode. The support is not yet
complete, but works reasonable well for the most important use case, that
is fullscreen applications.

We take a Present flip and if the xwl_window->window has the same dimensions
as the presenting window, the flip is represented by a wl_buffer and attached
to the main wl_surface of the xwl_window.

After commit we are listening for the sync callback in order to tell Present,
that the pixmap flip is not longer pending, for the frame callback in order
to update the msc counter and for the buffer release callback in order to tell
Present that the pixmap is idle again.

The following functionality is missing from this patch:
* (slowed down) flips in case the compositor is not sending frame callbacks,
* queuing events to MSC times,
* per window flips for child windows with smaller size than the xwl_window.

To make use of this functionality Xwayland must run rootless and with
Glamor/GBM.

Signed-off-by: Roman Gilg 
---
 hw/xwayland/Makefile.am|   1 +
 hw/xwayland/meson.build|   1 +
 hw/xwayland/xwayland-present.c | 365 +
 hw/xwayland/xwayland.c |  21 +++
 hw/xwayland/xwayland.h |  30 
 5 files changed, 418 insertions(+)
 create mode 100644 hw/xwayland/xwayland-present.c

diff --git a/hw/xwayland/Makefile.am b/hw/xwayland/Makefile.am
index 173686e..28ee5a5 100644
--- a/hw/xwayland/Makefile.am
+++ b/hw/xwayland/Makefile.am
@@ -11,6 +11,7 @@ Xwayland_CFLAGS = \
 
 Xwayland_SOURCES = \
xwayland.c  \
+   xwayland-present.c  \
xwayland-input.c\
xwayland-cursor.c   \
xwayland-shm.c  \
diff --git a/hw/xwayland/meson.build b/hw/xwayland/meson.build
index f6f7500..77da405 100644
--- a/hw/xwayland/meson.build
+++ b/hw/xwayland/meson.build
@@ -1,5 +1,6 @@
 srcs = [
 'xwayland.c',
+'xwayland-present.c',
 'xwayland-input.c',
 'xwayland-cursor.c',
 'xwayland-shm.c',
diff --git a/hw/xwayland/xwayland-present.c b/hw/xwayland/xwayland-present.c
new file mode 100644
index 000..2798c2a
--- /dev/null
+++ b/hw/xwayland/xwayland-present.c
@@ -0,0 +1,365 @@
+/*
+ * Copyright © 2018 Roman Gilg
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of the
+ * copyright holders not be used in advertising or publicity
+ * pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no
+ * representations about the suitability of this software for any
+ * purpose.  It is provided "as is" without express or implied
+ * warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+#include "xwayland.h"
+
+#include 
+
+void
+xwl_present_cleanup(WindowPtr window)
+{
+struct xwl_window   *xwl_window = xwl_window_of_top(window);
+struct xwl_present_event*event, *tmp;
+
+if (!xwl_window)
+return;
+
+if (xwl_window->present_window == window) {
+if (xwl_window->present_frame_callback) {
+wl_callback_destroy(xwl_window->present_frame_callback);
+xwl_window->present_frame_callback = NULL;
+}
+xwl_window->present_window = NULL;
+}
+
+/* Clear remaining buffer releases and inform Present about free 
ressources */
+xorg_list_for_each_entry_safe(event, tmp, 
&xwl_window->present_release_queue, list) {
+if (event->present_window == window) {
+xorg_list_del(&event->list);
+event->abort = TRUE;
+}
+}
+}
+
+static void
+xwl_present_free_event(struct xwl_present_event *event)
+{
+xorg_list_del(&event->list);
+free(event);
+}
+
+static void
+xwl_present_buffer_release(void *data, struct wl_buffer *buffer)
+{
+struct xwl_present_event *event = data;
+
+if (!event)
+return;
+wl_buffer_set_user_data(buffer, NULL);
+
+event->buffer_released = TRUE;
+
+if (event->abort) {
+if (!event->pending)
+  

[PATCH xserver v2 21/22] xwayland: Implement queuing present vblanks

2018-02-28 Thread Roman Gilg
Queue present events to msc values. Fake msc events with a refresh rate of
about 60fps when flips are not possible. When flips are executed rely on
frame callbacks with a slow updating timer as fallback.

This is important for applications, that want to limit their framerate.

Signed-off-by: Roman Gilg 
---
 hw/xwayland/xwayland-present.c | 103 +
 hw/xwayland/xwayland.c |   1 +
 hw/xwayland/xwayland.h |   2 +
 3 files changed, 97 insertions(+), 9 deletions(-)

diff --git a/hw/xwayland/xwayland-present.c b/hw/xwayland/xwayland-present.c
index 3088f03..27bc569 100644
--- a/hw/xwayland/xwayland-present.c
+++ b/hw/xwayland/xwayland-present.c
@@ -27,6 +27,13 @@
 
 #include 
 
+/*
+ * When not flipping let Present copy with 60fps.
+ * When flipping wait on frame_callback, otherwise
+ * the surface is not visible, in this case update
+ * with long interval.
+ */
+#define TIMER_LEN_COPY  17  // ~60fps
 #define TIMER_LEN_FLIP1000  // 1fps
 
 static void
@@ -41,13 +48,23 @@ xwl_present_timer_callback(OsTimerPtr timer,
CARD32 time,
void *arg);
 
+static inline Bool
+xwl_present_has_events(struct xwl_window *xwl_window)
+{
+return !xorg_list_is_empty(&xwl_window->present_event_list) ||
+   !xorg_list_is_empty(&xwl_window->present_release_queue);
+}
+
 static void
 xwl_present_reset_timer(struct xwl_window *xwl_window)
 {
-if ( !xorg_list_is_empty(&xwl_window->present_release_queue) ) {
+if (xwl_present_has_events(xwl_window)) {
+uint32_t timer_len = xwl_window->present_window ? TIMER_LEN_FLIP :
+  TIMER_LEN_COPY;
+
 xwl_window->present_timer = TimerSet(xwl_window->present_timer,
  0,
- TIMER_LEN_FLIP,
+ timer_len,
  &xwl_present_timer_callback,
  xwl_window);
 } else {
@@ -72,6 +89,14 @@ xwl_present_cleanup(WindowPtr window)
 xwl_window->present_window = NULL;
 }
 
+/* Clear remaining events */
+xorg_list_for_each_entry_safe(event, tmp, &xwl_window->present_event_list, 
list) {
+if (event->present_window == window) {
+xorg_list_del(&event->list);
+free(event);
+}
+}
+
 /* Clear remaining buffer releases and inform Present about free 
ressources */
 xorg_list_for_each_entry_safe(event, tmp, 
&xwl_window->present_release_queue, list) {
 if (event->present_window == window) {
@@ -81,7 +106,7 @@ xwl_present_cleanup(WindowPtr window)
 }
 
 /* Clear timer */
-if ( xorg_list_is_empty(&xwl_window->present_release_queue) )
+if (!xwl_present_has_events(xwl_window))
 xwl_present_free_timer(xwl_window);
 }
 
@@ -122,6 +147,25 @@ static const struct wl_buffer_listener 
xwl_present_release_listener = {
 xwl_present_buffer_release
 };
 
+static void
+xwl_present_events_notify(struct xwl_window *xwl_window)
+{
+uint64_tmsc = xwl_window->present_msc;
+struct xwl_present_event*event, *tmp;
+
+xorg_list_for_each_entry_safe(event, tmp,
+  &xwl_window->present_event_list,
+  list) {
+if (event->target_msc <= msc) {
+present_wnmd_event_notify(event->present_window,
+  event->event_id,
+  xwl_window->present_ust,
+  msc);
+xwl_present_free_event(event);
+}
+}
+}
+
 CARD32
 xwl_present_timer_callback(OsTimerPtr timer,
CARD32 time,
@@ -133,9 +177,12 @@ xwl_present_timer_callback(OsTimerPtr timer,
 xwl_window->present_msc++;
 xwl_window->present_ust = GetTimeInMicros();
 
-if ( !xorg_list_is_empty(&xwl_window->present_release_queue) ) {
+xwl_present_events_notify(xwl_window);
+
+if (xwl_present_has_events(xwl_window)) {
 /* Still events, restart timer */
-return TIMER_LEN_FLIP;
+return xwl_window->present_window ? TIMER_LEN_FLIP :
+TIMER_LEN_COPY;
 } else {
 /* No more events, do not restart timer and delete it instead */
 xwl_present_free_timer(xwl_window);
@@ -161,6 +208,8 @@ xwl_present_frame_callback(void *data,
 xwl_window->present_msc++;
 xwl_window->present_ust = GetTimeInMicros();
 
+xwl_present_events_notify(xwl_window);
+
 /* we do not need the timer anymore for this frame,
  * reset it for potentially the next one
  */
@@ -248,9 +297,34 @@ xwl_present_queue_vblank(WindowPtr p

[PATCH xserver v2 22/22] xwayland: Guard against very late vblanks

2018-02-28 Thread Roman Gilg
Do not allow queuing events too far into the the future. The result can be a
presentation freeze until the msc time is reached.

At the moment clients might do this per accident, because the fake vblank code
in Present and the xfree86 driver tolerate high 64bit msc values without
freeze due to an erroneous 64 to 32bit conversion.

The sample client, that triggers this behavior, is the Steam client.

Signed-off-by: Roman Gilg 
---
 hw/xwayland/xwayland-present.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/hw/xwayland/xwayland-present.c b/hw/xwayland/xwayland-present.c
index 27bc569..c0bc1f0 100644
--- a/hw/xwayland/xwayland-present.c
+++ b/hw/xwayland/xwayland-present.c
@@ -303,6 +303,11 @@ xwl_present_queue_vblank(WindowPtr present_window,
 if (!xwl_window)
 return BadMatch;
 
+if (msc > xwl_window->present_msc + 100) {
+ErrorF("Client queued frame too far in the future: %lu -> %lu\n", 
xwl_window->present_msc, msc);
+return BadRequest;
+}
+
 if (xwl_window->present_crtc_fake != crtc)
 return BadRequest;
 
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver v2 18/22] xwayland: Add arguments to glamor_pixmap_get_wl_buffer

2018-02-28 Thread Roman Gilg
Add arguments to give the caller more information and control
over the creation of a wl_buffer with GBM, in particular let
the caller determine the size of the buffer.

Signed-off-by: Roman Gilg 
---
 hw/xwayland/xwayland-glamor.c | 19 +++
 hw/xwayland/xwayland.c|  5 -
 hw/xwayland/xwayland.h|  5 -
 3 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index 8ffb40d..ee7e11c 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -153,14 +153,25 @@ xwl_glamor_create_pixmap_for_bo(ScreenPtr screen, struct 
gbm_bo *bo, int depth)
 }
 
 struct wl_buffer *
-xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap)
+xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap,
+unsigned short width,
+unsigned short height,
+Bool *created)
 {
 struct xwl_screen *xwl_screen = xwl_screen_get(pixmap->drawable.pScreen);
 struct xwl_pixmap *xwl_pixmap = xwl_pixmap_get(pixmap);
 int prime_fd;
 
-if (xwl_pixmap->buffer)
+if (xwl_pixmap->buffer) {
+/* Buffer already exists. Return it and inform caller if interested. */
+if (created)
+*created = FALSE;
 return xwl_pixmap->buffer;
+}
+
+/* Buffer does not exist yet. Create now and inform caller if interested. 
*/
+if (created)
+*created = TRUE;
 
 prime_fd = gbm_bo_get_fd(xwl_pixmap->bo);
 if (prime_fd == -1)
@@ -168,8 +179,8 @@ xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap)
 
 xwl_pixmap->buffer =
 wl_drm_create_prime_buffer(xwl_screen->drm, prime_fd,
-   pixmap->drawable.width,
-   pixmap->drawable.height,
+   width,
+   height,

drm_format_for_depth(pixmap->drawable.depth),
0, gbm_bo_get_stride(xwl_pixmap->bo),
0, 0,
diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c
index 73bc47a..8cb 100644
--- a/hw/xwayland/xwayland.c
+++ b/hw/xwayland/xwayland.c
@@ -649,7 +649,10 @@ xwl_window_post_damage(struct xwl_window *xwl_window)
 
 #ifdef GLAMOR_HAS_GBM
 if (xwl_screen->glamor)
-buffer = xwl_glamor_pixmap_get_wl_buffer(pixmap);
+buffer = xwl_glamor_pixmap_get_wl_buffer(pixmap,
+ pixmap->drawable.width,
+ pixmap->drawable.height,
+ NULL);
 else
 #endif
 buffer = xwl_shm_pixmap_get_wl_buffer(pixmap);
diff --git a/hw/xwayland/xwayland.h b/hw/xwayland/xwayland.h
index ffa0d72..783ab59 100644
--- a/hw/xwayland/xwayland.h
+++ b/hw/xwayland/xwayland.h
@@ -328,7 +328,10 @@ Bool xwl_glamor_init(struct xwl_screen *xwl_screen);
 
 Bool xwl_screen_init_glamor(struct xwl_screen *xwl_screen,
  uint32_t id, uint32_t version);
-struct wl_buffer *xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap);
+struct wl_buffer *xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap,
+  unsigned short width,
+  unsigned short height,
+  Bool *created);
 
 void xwl_screen_release_tablet_manager(struct xwl_screen *xwl_screen);
 
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH xserver v2 22/22] xwayland: Guard against very late vblanks

2018-02-28 Thread Roman Gilg
On Wed, Feb 28, 2018 at 6:43 PM, Michel Dänzer  wrote:
> I'm unable to reproduce the issue you described with Steam (without this
> patch series applied). I'd really like to know where the bogus target
> MSC values you're seeing are coming from. What are the values of the
> window_msc parameter and window_priv->msc_offset in
> present_window_to_crtc_msc?

You don't have to go that far. I did read out on current master high
target msc values directly for stuff->target_msc in
proc_present_pixmap. But this happened only on like two or three
occasions directly at the startup of the Steam client while hundreds
of other present_pixmap requests before and after had normal
stuff->target_msc values.

So just put a line

ErrorF("XXX %lu\n", stuff->target_msc);

in proc_present_pixmap and if you look carefully through the debug
output there should be one or two very high numbers in comparison to
all the other values.
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver v3 00/22] Per window flips in Present with support for them in Xwayland

2018-03-13 Thread Roman Gilg
This revision rebases the patch set on current master and does changes
requested by Michel Dänzer.

Please note that while compilation works fine for me, I can't test the runtime
any longer because the latest changes to xserver master require a newer mesa
build, and although I tried extensively I can't get the latest mesa code
to work on my system.

Also note, that I'm not able to spend more time on this patch set besides minor
changes. So this is the last revision I'm sending in.

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver v3 01/24] present: Move screen flip functionality in separate file

2018-03-13 Thread Roman Gilg
As a preperation for future flip mode alternatives move most of the
functionality from 'present.c' into a separate file.

Leave some functions needed by future other flip modes in 'present.c'.

Signed-off-by: Roman Gilg 
---
 present/Makefile.am|1 +
 present/meson.build|1 +
 present/present.c  | 1025 +-
 present/present_priv.h |  116 +++---
 present/present_scmd.c | 1048 
 5 files changed, 1123 insertions(+), 1068 deletions(-)
 create mode 100644 present/present_scmd.c

diff --git a/present/Makefile.am b/present/Makefile.am
index 7fea669..3b458fd 100644
--- a/present/Makefile.am
+++ b/present/Makefile.am
@@ -12,6 +12,7 @@ libpresent_la_SOURCES = \
present_notify.c \
present_priv.h \
present_request.c \
+   present_scmd.c \
present_screen.c
 
 sdk_HEADERS = present.h presentext.h
diff --git a/present/meson.build b/present/meson.build
index cf72530..859a991 100644
--- a/present/meson.build
+++ b/present/meson.build
@@ -5,6 +5,7 @@ srcs_present = [
 'present_fence.c',
 'present_notify.c',
 'present_request.c',
+'present_scmd.c',
 'present_screen.c',
 ]
 
diff --git a/present/present.c b/present/present.c
index 080cafc..ec29533 100644
--- a/present/present.c
+++ b/present/present.c
@@ -26,51 +26,11 @@
 
 #include "present_priv.h"
 #include 
-#include 
-#include 
-#ifdef MONOTONIC_CLOCK
-#include 
-#endif
-
-static uint64_t present_event_id;
-static struct xorg_list present_exec_queue;
-static struct xorg_list present_flip_queue;
-
-#if 0
-#define DebugPresent(x) ErrorF x
-#else
-#define DebugPresent(x)
-#endif
-
-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
- * FALSE if the first MSC value is before the second one
- */
-static Bool
-msc_is_equal_or_after(uint64_t test, uint64_t reference)
-{
-return (int64_t)(test - reference) >= 0;
-}
 
 /*
  * Copies the update region from a pixmap to the target drawable
  */
-static void
+void
 present_copy_region(DrawablePtr drawable,
 PixmapPtr pixmap,
 RegionPtr update,
@@ -103,129 +63,7 @@ present_copy_region(DrawablePtr drawable,
 FreeScratchGC(gc);
 }
 
-static inline PixmapPtr
-present_flip_pending_pixmap(ScreenPtr screen)
-{
-present_screen_priv_ptr screen_priv = present_screen_priv(screen);
-
-if (!screen_priv)
-return NULL;
-
-if (!screen_priv->flip_pending)
-return NULL;
-
-return screen_priv->flip_pending->pixmap;
-}
-
-static Bool
-present_check_flip(RRCrtcPtrcrtc,
-   WindowPtrwindow,
-   PixmapPtrpixmap,
-   Bool sync_flip,
-   RegionPtrvalid,
-   int16_t  x_off,
-   int16_t  y_off,
-   PresentFlipReason   *reason)
-{
-ScreenPtr   screen = window->drawable.pScreen;
-PixmapPtr   window_pixmap;
-WindowPtr   root = screen->root;
-present_screen_priv_ptr screen_priv = present_screen_priv(screen);
-
-if (reason)
-*reason = PRESENT_FLIP_REASON_UNKNOWN;
-
-if (!screen_priv)
-return FALSE;
-
-if (!screen_priv->info)
-return FALSE;
-
-if (!crtc)
-return FALSE;
-
-/* Check to see if the driver supports flips at all */
-if (!screen_priv->info->flip)
-return FALSE;
-
-/* Make sure the window hasn't been redirected with Composite */
-window_pixmap = screen->GetWindowPixmap(window);
-if (window_pixmap != screen->GetScreenPixmap(screen) &&
-window_pixmap != screen_priv->flip_pixmap &&
-window_pixmap != present_flip_pending_pixmap(screen))
-return FALSE;
-
-/* Check for full-screen window */
-if (!RegionEqual(&window->clipList, &root->winSize)) {
-return FALSE;
-}
-
-/* Source pixmap must align with window exactly */
-if (x_off || y_off) {
-return FALSE;
-}
-
-/* Make sure the area marked as valid fills the screen */
-if (valid && !RegionEqual(valid, &root->winSize)) {
-return FALSE;
-}
-
-/* Does the window match the pixmap exactly? */
-if (window->drawable.x != 0 || window->drawable.y != 0 ||
-#ifdef COMPOSITE
-window->

[PATCH xserver v3 02/24] present: Preliminary internal flip mode API

2018-03-13 Thread Roman Gilg
Add some basic function hooks to our future present-internal flip mode API,
that will allow us to share functionality in between modes and move more code
in separate files.

Signed-off-by: Roman Gilg 
---
 present/present_priv.h   | 27 ---
 present/present_scmd.c   | 20 ++--
 present/present_screen.c |  4 +++-
 3 files changed, 45 insertions(+), 6 deletions(-)

diff --git a/present/present_priv.h b/present/present_priv.h
index 66539e1..8908061 100644
--- a/present/present_priv.h
+++ b/present/present_priv.h
@@ -85,6 +85,21 @@ struct present_vblank {
 Boolhas_suboptimal; /* whether client can support 
SuboptimalCopy mode */
 };
 
+/*
+ * Mode hooks
+ */
+typedef Bool (*present_priv_check_flip_ptr)(RRCrtcPtr crtc,
+WindowPtr window,
+PixmapPtr pixmap,
+Bool sync_flip,
+RegionPtr valid,
+int16_t x_off,
+int16_t y_off,
+PresentFlipReason *reason);
+typedef void (*present_priv_check_flip_window_ptr)(WindowPtr window);
+
+typedef void (*present_priv_create_event_id_ptr)(present_vblank_ptr vblank);
+
 typedef struct present_screen_priv {
 CloseScreenProcPtr  CloseScreen;
 ConfigNotifyProcPtr ConfigNotify;
@@ -105,6 +120,12 @@ typedef struct present_screen_priv {
 Boolflip_sync;
 
 present_screen_info_ptr info;
+
+/* Mode hooks */
+present_priv_check_flip_ptr check_flip;
+present_priv_check_flip_window_ptr  check_flip_window;
+
+present_priv_create_event_id_ptrcreate_event_id;
 } present_screen_priv_rec, *present_screen_priv_ptr;
 
 #define wrap(priv,real,mem,func) {\
@@ -318,9 +339,6 @@ present_restore_screen_pixmap(ScreenPtr screen);
 void
 present_set_abort_flip(ScreenPtr screen);
 
-void
-present_check_flip_window(WindowPtr window);
-
 RRCrtcPtr
 present_get_crtc(WindowPtr window);
 
@@ -330,6 +348,9 @@ present_query_capabilities(RRCrtcPtr crtc);
 Bool
 present_init(void);
 
+void
+present_scmd_init_mode_hooks(present_screen_priv_ptr screen_priv);
+
 /*
  * present_screen.c
  */
diff --git a/present/present_scmd.c b/present/present_scmd.c
index bd92b27..17a1758 100644
--- a/present/present_scmd.c
+++ b/present/present_scmd.c
@@ -68,6 +68,12 @@ msc_is_equal_or_after(uint64_t test, uint64_t reference)
 return (int64_t)(test - reference) >= 0;
 }
 
+static void
+present_scmd_create_event_id(present_vblank_ptr vblank)
+{
+vblank->event_id = ++present_event_id;
+}
+
 static inline PixmapPtr
 present_flip_pending_pixmap(ScreenPtr screen)
 {
@@ -484,7 +490,7 @@ present_event_notify(uint64_t event_id, uint64_t ust, 
uint64_t msc)
  * 'window' is being reconfigured. Check to see if it is involved
  * in flipping and clean up as necessary
  */
-void
+static void
 present_check_flip_window (WindowPtr window)
 {
 ScreenPtr   screen = window->drawable.pScreen;
@@ -858,7 +864,8 @@ present_pixmap(WindowPtr window,
 vblank->screen = screen;
 vblank->window = window;
 vblank->pixmap = pixmap;
-vblank->event_id = ++present_event_id;
+present_scmd_create_event_id(vblank);
+
 if (pixmap) {
 vblank->kind = PresentCompleteKindPixmap;
 pixmap->refcnt++;
@@ -1038,6 +1045,15 @@ present_vblank_destroy(present_vblank_ptr vblank)
 free(vblank);
 }
 
+void
+present_scmd_init_mode_hooks(present_screen_priv_ptr screen_priv)
+{
+screen_priv->check_flip =   &present_check_flip;
+screen_priv->check_flip_window  =   &present_check_flip_window;
+
+screen_priv->create_event_id=   &present_scmd_create_event_id;
+}
+
 Bool
 present_init(void)
 {
diff --git a/present/present_screen.c b/present/present_screen.c
index 9d03c8a..454cc53 100644
--- a/present/present_screen.c
+++ b/present/present_screen.c
@@ -161,7 +161,7 @@ present_clip_notify(WindowPtr window, int dx, int dy)
 ScreenPtr screen = window->drawable.pScreen;
 present_screen_priv_ptr screen_priv = present_screen_priv(screen);
 
-present_check_flip_window(window);
+screen_priv->check_flip_window(window);
 unwrap(screen_priv, screen, ClipNotify)
 if (screen->ClipNotify)
 screen->ClipNotify (window, dx, dy);
@@ -194,6 +194,8 @@ present_screen_init(ScreenPtr screen, 
present_screen_info_ptr info)
 
 dixSetPrivate(&screen->devPrivates, &present_screen_private_key, 
screen_priv);
 
+present_scmd_init_mode_hooks(screen_priv);
+
 present_fake_screen_init(screen);
 }
 
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver v3 06/24] present: Add flip mode API hook for present_pixmap

2018-03-13 Thread Roman Gilg
Make present_pixmap a common function callable by any
flip mode.

Signed-off-by: Roman Gilg 
---
 present/present.c  | 57 ++
 present/present_priv.h | 68 +++---
 present/present_scmd.c | 54 ++-
 3 files changed, 119 insertions(+), 60 deletions(-)

diff --git a/present/present.c b/present/present.c
index ec29533..ddd9c1c 100644
--- a/present/present.c
+++ b/present/present.c
@@ -108,3 +108,60 @@ present_set_tree_pixmap(WindowPtr window,
 return;
 TraverseTree(window, present_set_tree_pixmap_visit, &visit);
 }
+
+int
+present_pixmap(WindowPtr window,
+   PixmapPtr pixmap,
+   CARD32 serial,
+   RegionPtr valid,
+   RegionPtr update,
+   int16_t x_off,
+   int16_t y_off,
+   RRCrtcPtr target_crtc,
+   SyncFence *wait_fence,
+   SyncFence *idle_fence,
+   uint32_t options,
+   uint64_t window_msc,
+   uint64_t divisor,
+   uint64_t remainder,
+   present_notify_ptr notifies,
+   int num_notifies)
+{
+ScreenPtr   screen = window->drawable.pScreen;
+present_screen_priv_ptr screen_priv = present_screen_priv(screen);
+
+return screen_priv->present_pixmap(window,
+   pixmap,
+   serial,
+   valid,
+   update,
+   x_off,
+   y_off,
+   target_crtc,
+   wait_fence,
+   idle_fence,
+   options,
+   window_msc,
+   divisor,
+   remainder,
+   notifies,
+   num_notifies);
+}
+
+int
+present_notify_msc(WindowPtr window,
+   CARD32 serial,
+   uint64_t target_msc,
+   uint64_t divisor,
+   uint64_t remainder)
+{
+return present_pixmap(window,
+  NULL,
+  serial,
+  NULL, NULL,
+  0, 0,
+  NULL,
+  NULL, NULL,
+  divisor == 0 ? PresentOptionAsync : 0,
+  target_msc, divisor, remainder, NULL, 0);
+}
diff --git a/present/present_priv.h b/present/present_priv.h
index 05c793d..27b8048 100644
--- a/present/present_priv.h
+++ b/present/present_priv.h
@@ -98,6 +98,23 @@ typedef Bool (*present_priv_check_flip_ptr)(RRCrtcPtr crtc,
 PresentFlipReason *reason);
 typedef void (*present_priv_check_flip_window_ptr)(WindowPtr window);
 
+typedef int (*present_priv_pixmap_ptr)(WindowPtr window,
+   PixmapPtr pixmap,
+   CARD32 serial,
+   RegionPtr valid,
+   RegionPtr update,
+   int16_t x_off,
+   int16_t y_off,
+   RRCrtcPtr target_crtc,
+   SyncFence *wait_fence,
+   SyncFence *idle_fence,
+   uint32_t options,
+   uint64_t window_msc,
+   uint64_t divisor,
+   uint64_t remainder,
+   present_notify_ptr notifies,
+   int num_notifies);
+
 typedef void (*present_priv_create_event_id_ptr)(present_vblank_ptr vblank);
 
 typedef int (*present_priv_queue_vblank_ptr)(ScreenPtr screen,
@@ -132,6 +149,7 @@ typedef struct present_screen_priv {
 present_priv_check_flip_ptr check_flip;
 present_priv_check_flip_window_ptr  check_flip_window;
 
+present_priv_pixmap_ptr present_pixmap;
 present_priv_create_event_id_ptrcreate_event_id;
 
 present_priv_queue_vblank_ptr   queue_vblank;
@@ -219,6 +237,31 @@ present_set_tree_pixmap(WindowPtr window,
 PixmapPtr expected,
 PixmapPtr pixmap);
 
+int
+present_pixmap(WindowPtr window,
+   PixmapPtr pixmap,
+   CARD32 serial,
+   RegionPtr valid,
+   RegionPtr update,
+   int16_t x_off,
+   int16_t y_off,
+   RRCrtcPtr t

[PATCH xserver v3 04/24] present: Add flip mode API hooks for several functions

2018-03-13 Thread Roman Gilg
Add 'queue_vblank', 'flush' and 're_execute' hooks, that
are supposed to be shared with other flip modes.

Signed-off-by: Roman Gilg 
---
 present/present_priv.h | 12 
 present/present_scmd.c |  3 +++
 2 files changed, 15 insertions(+)

diff --git a/present/present_priv.h b/present/present_priv.h
index dc6654e..971bce5 100644
--- a/present/present_priv.h
+++ b/present/present_priv.h
@@ -100,6 +100,13 @@ typedef void 
(*present_priv_check_flip_window_ptr)(WindowPtr window);
 
 typedef void (*present_priv_create_event_id_ptr)(present_vblank_ptr vblank);
 
+typedef int (*present_priv_queue_vblank_ptr)(ScreenPtr screen,
+ RRCrtcPtr crtc,
+ uint64_t event_id,
+ uint64_t msc);
+typedef void (*present_priv_flush_ptr)(WindowPtr window);
+typedef void (*present_priv_re_execute_ptr)(present_vblank_ptr vblank);
+
 typedef struct present_screen_priv {
 CloseScreenProcPtr  CloseScreen;
 ConfigNotifyProcPtr ConfigNotify;
@@ -126,6 +133,11 @@ typedef struct present_screen_priv {
 present_priv_check_flip_window_ptr  check_flip_window;
 
 present_priv_create_event_id_ptrcreate_event_id;
+
+present_priv_queue_vblank_ptr   queue_vblank;
+present_priv_flush_ptr  flush;
+present_priv_re_execute_ptr re_execute;
+
 } present_screen_priv_rec, *present_screen_priv_ptr;
 
 #define wrap(priv,real,mem,func) {\
diff --git a/present/present_scmd.c b/present/present_scmd.c
index 1e11d35..0376b4e 100644
--- a/present/present_scmd.c
+++ b/present/present_scmd.c
@@ -930,6 +930,9 @@ present_scmd_init_mode_hooks(present_screen_priv_ptr 
screen_priv)
 screen_priv->check_flip_window  =   &present_check_flip_window;
 
 screen_priv->create_event_id=   &present_scmd_create_event_id;
+screen_priv->queue_vblank   =   &present_queue_vblank;
+screen_priv->flush  =   &present_flush;
+screen_priv->re_execute =   &present_re_execute;
 }
 
 Bool
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver v3 03/24] present: Move vblank functionality in seperate file

2018-03-13 Thread Roman Gilg
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 
---
 present/Makefile.am  |   3 +-
 present/meson.build  |   1 +
 present/present_priv.h   |  44 ++-
 present/present_scmd.c   | 156 
 present/present_vblank.c | 200 +++
 5 files changed, 261 insertions(+), 143 deletions(-)
 create mode 100644 present/present_vblank.c

diff --git a/present/Makefile.am b/present/Makefile.am
index 3b458fd..3d3d38d 100644
--- a/present/Makefile.am
+++ b/present/Makefile.am
@@ -13,6 +13,7 @@ libpresent_la_SOURCES = \
present_priv.h \
present_request.c \
present_scmd.c \
-   present_screen.c
+   present_screen.c \
+   present_vblank.c
 
 sdk_HEADERS = present.h presentext.h
diff --git a/present/meson.build b/present/meson.build
index 859a991..d22cd09 100644
--- a/present/meson.build
+++ b/present/meson.build
@@ -7,6 +7,7 @@ srcs_present = [
 'present_request.c',
 'present_scmd.c',
 'present_screen.c',
+'present_vblank.c',
 ]
 
 libxserver_present = static_library('libxserver_present',
diff --git a/present/present_priv.h b/present/present_priv.h
index 8908061..dc6654e 100644
--- a/present/present_priv.h
+++ b/present/present_priv.h
@@ -179,6 +179,17 @@ present_window_priv_ptr
 present_get_window_priv(WindowPtr window, Bool create);
 
 /*
+ * 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 inline Bool
+msc_is_after(uint64_t test, uint64_t reference)
+{
+return (int64_t)(test - reference) > 0;
+}
+
+/*
  * present.c
  */
 void
@@ -328,9 +339,6 @@ void
 present_abort_vblank(ScreenPtr screen, RRCrtcPtr crtc, uint64_t event_id, 
uint64_t msc);
 
 void
-present_vblank_destroy(present_vblank_ptr vblank);
-
-void
 present_flip_destroy(ScreenPtr screen);
 
 void
@@ -355,4 +363,34 @@ present_scmd_init_mode_hooks(present_screen_priv_ptr 
screen_priv);
  * present_screen.c
  */
 
+/*
+ * present_vblank.c
+ */
+void
+present_vblank_notify(present_vblank_ptr vblank, CARD8 kind, CARD8 mode, 
uint64_t ust, uint64_t crtc_msc);
+
+present_vblank_ptr
+present_vblank_create(WindowPtr window,
+  PixmapPtr pixmap,
+  CARD32 serial,
+  RegionPtr valid,
+  RegionPtr update,
+  int16_t x_off,
+  int16_t y_off,
+  RRCrtcPtr target_crtc,
+  SyncFence *wait_fence,
+  SyncFence *idle_fence,
+  uint32_t options,
+  const uint32_t *capabilities,
+  present_notify_ptr notifies,
+  int num_notifies,
+  uint64_t *target_msc,
+  uint64_t crtc_msc);
+
+void
+present_vblank_scrap(present_vblank_ptr vblank);
+
+void
+present_vblank_destroy(present_vblank_ptr vblank);
+
 #endif /*  _PRESENT_PRIV_H_ */
diff --git a/present/present_scmd.c b/present/present_scmd.c
index 17a1758..1e11d35 100644
--- a/present/present_scmd.c
+++ b/present/present_scmd.c
@@ -48,17 +48,6 @@ 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
  * FALSE if the first MSC value is before 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);
-PresentFlipRea

[PATCH xserver v3 05/24] present: Refactor execute in separate file

2018-03-13 Thread Roman Gilg
To be shared by multiple flip modes, refactor execute functionality,
such that logical chunks can go in new separate file.

Signed-off-by: Roman Gilg 
---
 present/Makefile.am   |   1 +
 present/meson.build   |   1 +
 present/present_execute.c | 120 ++
 present/present_priv.h|  12 +
 present/present_scmd.c|  70 +++
 5 files changed, 140 insertions(+), 64 deletions(-)
 create mode 100644 present/present_execute.c

diff --git a/present/Makefile.am b/present/Makefile.am
index 3d3d38d..55ad295 100644
--- a/present/Makefile.am
+++ b/present/Makefile.am
@@ -7,6 +7,7 @@ libpresent_la_SOURCES = \
present.h \
present.c \
present_event.c \
+   present_execute.c \
present_fake.c \
present_fence.c \
present_notify.c \
diff --git a/present/meson.build b/present/meson.build
index d22cd09..84bea9b 100644
--- a/present/meson.build
+++ b/present/meson.build
@@ -1,6 +1,7 @@
 srcs_present = [
 'present.c',
 'present_event.c',
+'present_execute.c',
 'present_fake.c',
 'present_fence.c',
 'present_notify.c',
diff --git a/present/present_execute.c b/present/present_execute.c
new file mode 100644
index 000..c9b5678
--- /dev/null
+++ b/present/present_execute.c
@@ -0,0 +1,120 @@
+/*
+ * Copyright © 2013 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include 
+#endif
+
+#include "present_priv.h"
+
+/*
+ * Called when the wait fence is triggered; just gets the current msc/ust and
+ * calls the proper execute again. That will re-check the fence and pend the
+ * request again if it's still not actually ready
+ */
+static void
+present_wait_fence_triggered(void *param)
+{
+present_vblank_ptr  vblank = param;
+ScreenPtr   screen = vblank->screen;
+present_screen_priv_ptr screen_priv = present_screen_priv(screen);
+
+screen_priv->re_execute(vblank);
+}
+
+Bool
+present_execute_wait(present_vblank_ptr vblank, uint64_t crtc_msc)
+{
+WindowPtr   window = vblank->window;
+ScreenPtr   screen = window->drawable.pScreen;
+present_screen_priv_ptr screen_priv = present_screen_priv(screen);
+
+if (vblank->requeue) {
+vblank->requeue = FALSE;
+if (msc_is_after(vblank->target_msc, crtc_msc) &&
+Success == screen_priv->queue_vblank(screen,
+ vblank->crtc,
+ vblank->event_id,
+ vblank->target_msc))
+return TRUE;
+}
+
+if (vblank->wait_fence) {
+if (!present_fence_check_triggered(vblank->wait_fence)) {
+present_fence_set_callback(vblank->wait_fence, 
present_wait_fence_triggered, vblank);
+return TRUE;
+}
+}
+return FALSE;
+}
+
+void
+present_execute_copy(present_vblank_ptr vblank, uint64_t crtc_msc)
+{
+WindowPtr   window = vblank->window;
+ScreenPtr   screen = window->drawable.pScreen;
+present_screen_priv_ptr screen_priv = present_screen_priv(screen);
+
+/* If present_flip failed, we may have to requeue for the target MSC */
+if (vblank->target_msc == crtc_msc + 1 &&
+Success == screen_priv->queue_vblank(screen,
+ vblank->crtc,
+ vblank->event_id,
+ vblank->target_msc)) {
+vblank->queued = TRUE;
+return;
+}
+
+present_copy_region(&windo

[PATCH xserver v3 08/24] present: Move timings adjustment in common part of flip mode API

2018-03-13 Thread Roman Gilg
To reduce future code duplication refactor timings adjustment out
as a separate function.

Signed-off-by: Roman Gilg 
---
 present/present.c  | 38 ++
 present/present_priv.h |  7 +++
 present/present_scmd.c | 34 +-
 3 files changed, 50 insertions(+), 29 deletions(-)

diff --git a/present/present.c b/present/present.c
index da45491..8ba8647 100644
--- a/present/present.c
+++ b/present/present.c
@@ -28,6 +28,17 @@
 #include 
 
 /*
+ * Returns:
+ * TRUE if the first MSC value is equal to or after the second one
+ * FALSE if the first MSC value is before the second one
+ */
+static Bool
+msc_is_equal_or_after(uint64_t test, uint64_t reference)
+{
+return (int64_t)(test - reference) >= 0;
+}
+
+/*
  * Copies the update region from a pixmap to the target drawable
  */
 void
@@ -118,6 +129,33 @@ present_can_window_flip(WindowPtr window)
 return screen_priv->can_window_flip(window);
 }
 
+void
+present_adjust_timings(uint32_t options,
+   uint64_t *crtc_msc,
+   uint64_t *target_msc,
+   uint64_t divisor,
+   uint64_t remainder)
+{
+/* Adjust target_msc to match modulus
+ */
+if (msc_is_equal_or_after(*crtc_msc, *target_msc)) {
+if (divisor != 0) {
+*target_msc = *crtc_msc - (*crtc_msc % divisor) + remainder;
+if (options & PresentOptionAsync) {
+if (msc_is_after(*crtc_msc, *target_msc))
+*target_msc += divisor;
+} else {
+if (msc_is_equal_or_after(*crtc_msc, *target_msc))
+*target_msc += divisor;
+}
+} else {
+*target_msc = *crtc_msc;
+if (!(options & PresentOptionAsync))
+(*target_msc)++;
+}
+}
+}
+
 int
 present_pixmap(WindowPtr window,
PixmapPtr pixmap,
diff --git a/present/present_priv.h b/present/present_priv.h
index aee3e57..261f0e4 100644
--- a/present/present_priv.h
+++ b/present/present_priv.h
@@ -239,6 +239,13 @@ present_set_tree_pixmap(WindowPtr window,
 PixmapPtr expected,
 PixmapPtr pixmap);
 
+void
+present_adjust_timings(uint32_t options,
+   uint64_t *crtc_msc,
+   uint64_t *target_msc,
+   uint64_t divisor,
+   uint64_t remainder);
+
 int
 present_pixmap(WindowPtr window,
PixmapPtr pixmap,
diff --git a/present/present_scmd.c b/present/present_scmd.c
index 7fd27ac..71c8fb9 100644
--- a/present/present_scmd.c
+++ b/present/present_scmd.c
@@ -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 equal to or after the second one
- * FALSE if the first MSC value is before the second one
- */
-static Bool
-msc_is_equal_or_after(uint64_t test, uint64_t reference)
-{
-return (int64_t)(test - reference) >= 0;
-}
-
 static void
 present_scmd_create_event_id(present_vblank_ptr vblank)
 {
@@ -714,24 +703,11 @@ present_scmd_pixmap(WindowPtr window,
 window_priv->msc = crtc_msc;
 }
 
-/* Adjust target_msc to match modulus
- */
-if (msc_is_equal_or_after(crtc_msc, target_msc)) {
-if (divisor != 0) {
-target_msc = crtc_msc - (crtc_msc % divisor) + remainder;
-if (options & PresentOptionAsync) {
-if (msc_is_after(crtc_msc, target_msc))
-target_msc += divisor;
-} else {
-if (msc_is_equal_or_after(crtc_msc, target_msc))
-target_msc += divisor;
-}
-} else {
-target_msc = crtc_msc;
-if (!(options & PresentOptionAsync))
-target_msc++;
-}
-}
+present_adjust_timings(options,
+   &crtc_msc,
+   &target_msc,
+   divisor,
+   remainder);
 
 /*
  * Look for a matching presentation already on the list and
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver v3 07/24] present: Add flip mode API hook for present_can_window_flip

2018-03-13 Thread Roman Gilg
Flip modes can now have different implementations of
present_can_window_flip.

Signed-off-by: Roman Gilg 
---
 present/present.c  | 9 +
 present/present_priv.h | 2 ++
 present/present_scmd.c | 5 +++--
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/present/present.c b/present/present.c
index ddd9c1c..da45491 100644
--- a/present/present.c
+++ b/present/present.c
@@ -109,6 +109,15 @@ present_set_tree_pixmap(WindowPtr window,
 TraverseTree(window, present_set_tree_pixmap_visit, &visit);
 }
 
+Bool
+present_can_window_flip(WindowPtr window)
+{
+ScreenPtr   screen = window->drawable.pScreen;
+present_screen_priv_ptr screen_priv = present_screen_priv(screen);
+
+return screen_priv->can_window_flip(window);
+}
+
 int
 present_pixmap(WindowPtr window,
PixmapPtr pixmap,
diff --git a/present/present_priv.h b/present/present_priv.h
index 27b8048..aee3e57 100644
--- a/present/present_priv.h
+++ b/present/present_priv.h
@@ -97,6 +97,7 @@ typedef Bool (*present_priv_check_flip_ptr)(RRCrtcPtr crtc,
 int16_t y_off,
 PresentFlipReason *reason);
 typedef void (*present_priv_check_flip_window_ptr)(WindowPtr window);
+typedef Bool (*present_priv_can_window_flip_ptr)(WindowPtr window);
 
 typedef int (*present_priv_pixmap_ptr)(WindowPtr window,
PixmapPtr pixmap,
@@ -148,6 +149,7 @@ typedef struct present_screen_priv {
 /* Mode hooks */
 present_priv_check_flip_ptr check_flip;
 present_priv_check_flip_window_ptr  check_flip_window;
+present_priv_can_window_flip_ptrcan_window_flip;
 
 present_priv_pixmap_ptr present_pixmap;
 present_priv_create_event_id_ptrcreate_event_id;
diff --git a/present/present_scmd.c b/present/present_scmd.c
index 8ba4b2e..7fd27ac 100644
--- a/present/present_scmd.c
+++ b/present/present_scmd.c
@@ -512,8 +512,8 @@ present_check_flip_window (WindowPtr window)
 }
 }
 
-Bool
-present_can_window_flip(WindowPtr window)
+static Bool
+present_scmd_can_window_flip(WindowPtr window)
 {
 ScreenPtr   screen = window->drawable.pScreen;
 PixmapPtr   window_pixmap;
@@ -852,6 +852,7 @@ present_scmd_init_mode_hooks(present_screen_priv_ptr 
screen_priv)
 {
 screen_priv->check_flip =   &present_check_flip;
 screen_priv->check_flip_window  =   &present_check_flip_window;
+screen_priv->can_window_flip=   &present_scmd_can_window_flip;
 
 screen_priv->present_pixmap =   &present_scmd_pixmap;
 screen_priv->create_event_id=   &present_scmd_create_event_id;
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver v3 10/24] present: Refactor present_screen_init

2018-03-13 Thread Roman Gilg
To initialize easily different flip modes, refactor
'present_screen_init'.

Signed-off-by: Roman Gilg 
---
 present/present_screen.c | 46 +-
 1 file changed, 33 insertions(+), 13 deletions(-)

diff --git a/present/present_screen.c b/present/present_screen.c
index 98f701a..868eaf8 100644
--- a/present/present_screen.c
+++ b/present/present_screen.c
@@ -170,32 +170,52 @@ present_clip_notify(WindowPtr window, int dx, int dy)
 wrap(screen_priv, screen, ClipNotify, present_clip_notify);
 }
 
+static Bool
+present_screen_register_priv_keys(void)
+{
+if (!dixRegisterPrivateKey(&present_screen_private_key, PRIVATE_SCREEN, 0))
+return FALSE;
+
+if (!dixRegisterPrivateKey(&present_window_private_key, PRIVATE_WINDOW, 0))
+return FALSE;
+
+return TRUE;
+}
+
+static present_screen_priv_ptr
+present_screen_priv_init(ScreenPtr screen)
+{
+present_screen_priv_ptr screen_priv;
+
+screen_priv = calloc(1, sizeof (present_screen_priv_rec));
+if (!screen_priv)
+return NULL;
+
+wrap(screen_priv, screen, CloseScreen, present_close_screen);
+wrap(screen_priv, screen, DestroyWindow, present_destroy_window);
+wrap(screen_priv, screen, ConfigNotify, present_config_notify);
+wrap(screen_priv, screen, ClipNotify, present_clip_notify);
+
+dixSetPrivate(&screen->devPrivates, &present_screen_private_key, 
screen_priv);
+
+return screen_priv;
+}
+
 /*
  * Initialize a screen for use with present
  */
 int
 present_screen_init(ScreenPtr screen, present_screen_info_ptr info)
 {
-if (!dixRegisterPrivateKey(&present_screen_private_key, PRIVATE_SCREEN, 0))
-return FALSE;
-
-if (!dixRegisterPrivateKey(&present_window_private_key, PRIVATE_WINDOW, 0))
+if (!present_screen_register_priv_keys())
 return FALSE;
 
 if (!present_screen_priv(screen)) {
-present_screen_priv_ptr screen_priv = calloc(1, sizeof 
(present_screen_priv_rec));
+present_screen_priv_ptr screen_priv = present_screen_priv_init(screen);
 if (!screen_priv)
 return FALSE;
 
-wrap(screen_priv, screen, CloseScreen, present_close_screen);
-wrap(screen_priv, screen, DestroyWindow, present_destroy_window);
-wrap(screen_priv, screen, ConfigNotify, present_config_notify);
-wrap(screen_priv, screen, ClipNotify, present_clip_notify);
-
 screen_priv->info = info;
-
-dixSetPrivate(&screen->devPrivates, &present_screen_private_key, 
screen_priv);
-
 present_scmd_init_mode_hooks(screen_priv);
 
 present_fake_screen_init(screen);
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver v3 12/24] present: Add flip_idler vblank property

2018-03-13 Thread Roman Gilg
Introduce vblank property for flip modes, that demand explicite
allowance by the driver for vblanks to become idle.

Signed-off-by: Roman Gilg 
---
 present/present_priv.h   | 1 +
 present/present_vblank.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/present/present_priv.h b/present/present_priv.h
index 3fba10d..5e1bc3c 100644
--- a/present/present_priv.h
+++ b/present/present_priv.h
@@ -79,6 +79,7 @@ struct present_vblank {
 Boolrequeue;/* on queue, but target_msc has 
changed */
 Boolflip;   /* planning on using flip */
 Boolflip_ready; /* wants to flip, but waiting for 
previous flip or unflip */
+Boolflip_idler; /* driver explicitly permitted idling 
*/
 Boolsync_flip;  /* do flip synchronous to vblank */
 Boolabort_flip; /* aborting this flip */
 PresentFlipReason   reason; /* reason for which flip is not 
possible */
diff --git a/present/present_vblank.c b/present/present_vblank.c
index 6265dff..fac639b 100644
--- a/present/present_vblank.c
+++ b/present/present_vblank.c
@@ -106,6 +106,7 @@ present_vblank_create(WindowPtr window,
 vblank->notifies = notifies;
 vblank->num_notifies = num_notifies;
 vblank->has_suboptimal = (options & PresentOptionSuboptimal);
+vblank->flip_idler = FALSE;
 
 if (pixmap != NULL &&
 !(options & PresentOptionCopy) &&
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver v3 11/24] present: Add present_window_priv properties for window flip mode

2018-03-13 Thread Roman Gilg
For window flip mode data about flips needs to be stored per window.
Add properties to 'present_window_priv' and initialize them on creation.

Signed-off-by: Roman Gilg 
---
 present/present_priv.h   | 10 ++
 present/present_screen.c |  6 ++
 2 files changed, 16 insertions(+)

diff --git a/present/present_priv.h b/present/present_priv.h
index ba607e2..3fba10d 100644
--- a/present/present_priv.h
+++ b/present/present_priv.h
@@ -206,12 +206,22 @@ typedef struct present_event {
 } present_event_rec;
 
 typedef struct present_window_priv {
+WindowPtr  window;
 present_event_ptr  events;
 RRCrtcPtr  crtc;/* Last reported CRTC from get_ust_msc 
*/
 uint64_t   msc_offset;
 uint64_t   msc; /* Last reported MSC from the current 
crtc */
 struct xorg_list   vblank;
 struct xorg_list   notifies;
+
+/* Used for window flips */
+uint64_t   event_id;
+struct xorg_list   exec_queue;
+struct xorg_list   flip_queue;
+struct xorg_list   idle_queue;
+
+present_vblank_ptr flip_pending;
+present_vblank_ptr flip_active;
 } present_window_priv_rec, *present_window_priv_ptr;
 
 #define PresentCrtcNeverSet ((RRCrtcPtr) 1)
diff --git a/present/present_screen.c b/present/present_screen.c
index 868eaf8..d6c9a5e 100644
--- a/present/present_screen.c
+++ b/present/present_screen.c
@@ -45,6 +45,12 @@ present_get_window_priv(WindowPtr window, Bool create)
 return NULL;
 xorg_list_init(&window_priv->vblank);
 xorg_list_init(&window_priv->notifies);
+
+xorg_list_init(&window_priv->exec_queue);
+xorg_list_init(&window_priv->flip_queue);
+xorg_list_init(&window_priv->idle_queue);
+
+window_priv->window = window;
 window_priv->crtc = PresentCrtcNeverSet;
 dixSetPrivate(&window->devPrivates, &present_window_private_key, 
window_priv);
 return window_priv;
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver v3 09/24] present: Add more hooks to internal flip mode API

2018-03-13 Thread Roman Gilg
Add hooks to query caps, get crtcs, abort vblanks and destroy
a flip.

Signed-off-by: Roman Gilg 
---
 present/present.c| 28 
 present/present_priv.h   | 33 +
 present/present_scmd.c   | 38 ++
 present/present_screen.c |  6 --
 4 files changed, 71 insertions(+), 34 deletions(-)

diff --git a/present/present.c b/present/present.c
index 8ba8647..37cbf07 100644
--- a/present/present.c
+++ b/present/present.c
@@ -38,6 +38,34 @@ msc_is_equal_or_after(uint64_t test, uint64_t reference)
 return (int64_t)(test - reference) >= 0;
 }
 
+uint32_t
+present_query_capabilities(RRCrtcPtr crtc)
+{
+present_screen_priv_ptr screen_priv;
+
+if (!crtc)
+return 0;
+
+screen_priv = present_screen_priv(crtc->pScreen);
+
+if (!screen_priv)
+return 0;
+
+return screen_priv->query_capabilities(screen_priv);
+}
+
+RRCrtcPtr
+present_get_crtc(WindowPtr window)
+{
+ScreenPtr   screen = window->drawable.pScreen;
+present_screen_priv_ptr screen_priv = present_screen_priv(screen);
+
+if (!screen_priv)
+return NULL;
+
+return screen_priv->get_crtc(screen_priv, window);
+}
+
 /*
  * Copies the update region from a pixmap to the target drawable
  */
diff --git a/present/present_priv.h b/present/present_priv.h
index 261f0e4..ba607e2 100644
--- a/present/present_priv.h
+++ b/present/present_priv.h
@@ -85,9 +85,15 @@ struct present_vblank {
 Boolhas_suboptimal; /* whether client can support 
SuboptimalCopy mode */
 };
 
+typedef struct present_screen_priv present_screen_priv_rec, 
*present_screen_priv_ptr;
+
 /*
  * Mode hooks
  */
+typedef uint32_t 
(*present_priv_query_capabilities_ptr)(present_screen_priv_ptr screen_priv);
+typedef RRCrtcPtr (*present_priv_get_crtc_ptr)(present_screen_priv_ptr 
screen_priv,
+   WindowPtr window);
+
 typedef Bool (*present_priv_check_flip_ptr)(RRCrtcPtr crtc,
 WindowPtr window,
 PixmapPtr pixmap,
@@ -125,7 +131,13 @@ typedef int (*present_priv_queue_vblank_ptr)(ScreenPtr 
screen,
 typedef void (*present_priv_flush_ptr)(WindowPtr window);
 typedef void (*present_priv_re_execute_ptr)(present_vblank_ptr vblank);
 
-typedef struct present_screen_priv {
+typedef void (*present_priv_abort_vblank_ptr)(ScreenPtr screen,
+  RRCrtcPtr crtc,
+  uint64_t event_id,
+  uint64_t msc);
+typedef void (*present_priv_flip_destroy_ptr)(ScreenPtr screen);
+
+struct present_screen_priv {
 CloseScreenProcPtr  CloseScreen;
 ConfigNotifyProcPtr ConfigNotify;
 DestroyWindowProcPtrDestroyWindow;
@@ -147,6 +159,9 @@ typedef struct present_screen_priv {
 present_screen_info_ptr info;
 
 /* Mode hooks */
+present_priv_query_capabilities_ptr query_capabilities;
+present_priv_get_crtc_ptr   get_crtc;
+
 present_priv_check_flip_ptr check_flip;
 present_priv_check_flip_window_ptr  check_flip_window;
 present_priv_can_window_flip_ptrcan_window_flip;
@@ -158,7 +173,9 @@ typedef struct present_screen_priv {
 present_priv_flush_ptr  flush;
 present_priv_re_execute_ptr re_execute;
 
-} present_screen_priv_rec, *present_screen_priv_ptr;
+present_priv_abort_vblank_ptr   abort_vblank;
+present_priv_flip_destroy_ptr   flip_destroy;
+};
 
 #define wrap(priv,real,mem,func) {\
 priv->mem = real->mem; \
@@ -224,6 +241,12 @@ msc_is_after(uint64_t test, uint64_t reference)
 /*
  * present.c
  */
+uint32_t
+present_query_capabilities(RRCrtcPtr crtc);
+
+RRCrtcPtr
+present_get_crtc(WindowPtr window);
+
 void
 present_copy_region(DrawablePtr drawable,
 PixmapPtr pixmap,
@@ -398,12 +421,6 @@ present_restore_screen_pixmap(ScreenPtr screen);
 void
 present_set_abort_flip(ScreenPtr screen);
 
-RRCrtcPtr
-present_get_crtc(WindowPtr window);
-
-uint32_t
-present_query_capabilities(RRCrtcPtr crtc);
-
 Bool
 present_init(void);
 
diff --git a/present/present_scmd.c b/present/present_scmd.c
index 71c8fb9..18ce619 100644
--- a/present/present_scmd.c
+++ b/present/present_scmd.c
@@ -158,34 +158,18 @@ present_flip(RRCrtcPtr crtc,
 return (*screen_priv->info->flip) (crtc, event_id, target_msc, pixmap, 
sync_flip);
 }
 
-RRCrtcPtr
-present_get_crtc(WindowPtr window)
+static RRCrtcPtr
+present_scmd_get_crtc(present_screen_priv_ptr screen_priv, WindowPtr window)
 {
-ScreenPtr   screen = window->drawable.pScreen;
-present_screen_priv_ptr screen_priv = present_screen_priv(screen);
-
-if (!screen_priv)
-return NULL;
-
 if (!screen_priv->info)
 return NULL;
 
 ret

[PATCH xserver v3 13/24] present: Adapt flip mode API hooks for window flip mode

2018-03-13 Thread Roman Gilg
Flipping pixmaps per window needs additional arguments in the
flip mode API. Add these as preperation for window flip mode.

Signed-off-by: Roman Gilg 
---
 present/present_execute.c |  2 ++
 present/present_priv.h| 10 +++---
 present/present_scmd.c|  8 +---
 present/present_screen.c  |  2 +-
 present/present_vblank.c  |  2 +-
 5 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/present/present_execute.c b/present/present_execute.c
index c9b5678..8d1ef4a 100644
--- a/present/present_execute.c
+++ b/present/present_execute.c
@@ -52,6 +52,7 @@ present_execute_wait(present_vblank_ptr vblank, uint64_t 
crtc_msc)
 vblank->requeue = FALSE;
 if (msc_is_after(vblank->target_msc, crtc_msc) &&
 Success == screen_priv->queue_vblank(screen,
+ window,
  vblank->crtc,
  vblank->event_id,
  vblank->target_msc))
@@ -77,6 +78,7 @@ present_execute_copy(present_vblank_ptr vblank, uint64_t 
crtc_msc)
 /* If present_flip failed, we may have to requeue for the target MSC */
 if (vblank->target_msc == crtc_msc + 1 &&
 Success == screen_priv->queue_vblank(screen,
+ window,
  vblank->crtc,
  vblank->event_id,
  vblank->target_msc)) {
diff --git a/present/present_priv.h b/present/present_priv.h
index 5e1bc3c..f697471 100644
--- a/present/present_priv.h
+++ b/present/present_priv.h
@@ -87,6 +87,7 @@ struct present_vblank {
 };
 
 typedef struct present_screen_priv present_screen_priv_rec, 
*present_screen_priv_ptr;
+typedef struct present_window_priv present_window_priv_rec, 
*present_window_priv_ptr;
 
 /*
  * Mode hooks
@@ -123,9 +124,11 @@ typedef int (*present_priv_pixmap_ptr)(WindowPtr window,
present_notify_ptr notifies,
int num_notifies);
 
-typedef void (*present_priv_create_event_id_ptr)(present_vblank_ptr vblank);
+typedef void (*present_priv_create_event_id_ptr)(present_window_priv_ptr 
window_priv,
+ present_vblank_ptr vblank);
 
 typedef int (*present_priv_queue_vblank_ptr)(ScreenPtr screen,
+ WindowPtr window,
  RRCrtcPtr crtc,
  uint64_t event_id,
  uint64_t msc);
@@ -133,6 +136,7 @@ typedef void (*present_priv_flush_ptr)(WindowPtr window);
 typedef void (*present_priv_re_execute_ptr)(present_vblank_ptr vblank);
 
 typedef void (*present_priv_abort_vblank_ptr)(ScreenPtr screen,
+  WindowPtr window,
   RRCrtcPtr crtc,
   uint64_t event_id,
   uint64_t msc);
@@ -206,7 +210,7 @@ typedef struct present_event {
 int mask;
 } present_event_rec;
 
-typedef struct present_window_priv {
+struct present_window_priv {
 WindowPtr  window;
 present_event_ptr  events;
 RRCrtcPtr  crtc;/* Last reported CRTC from get_ust_msc 
*/
@@ -223,7 +227,7 @@ typedef struct present_window_priv {
 
 present_vblank_ptr flip_pending;
 present_vblank_ptr flip_active;
-} present_window_priv_rec, *present_window_priv_ptr;
+};
 
 #define PresentCrtcNeverSet ((RRCrtcPtr) 1)
 
diff --git a/present/present_scmd.c b/present/present_scmd.c
index 18ce619..0803a0c 100644
--- a/present/present_scmd.c
+++ b/present/present_scmd.c
@@ -47,7 +47,8 @@ static void
 present_execute(present_vblank_ptr vblank, uint64_t ust, uint64_t crtc_msc);
 
 static void
-present_scmd_create_event_id(present_vblank_ptr vblank)
+present_scmd_create_event_id(present_window_priv_ptr window_priv,
+ present_vblank_ptr vblank)
 {
 vblank->event_id = ++present_event_id;
 }
@@ -204,6 +205,7 @@ present_flush(WindowPtr window)
 
 static int
 present_queue_vblank(ScreenPtr screen,
+ WindowPtr window,
  RRCrtcPtr crtc,
  uint64_t event_id,
  uint64_t msc)
@@ -751,7 +753,7 @@ present_scmd_pixmap(WindowPtr window,
 xorg_list_append(&vblank->event_queue, &present_exec_queue);
 vblank->queued = TRUE;
 if (msc_is_after(target_msc, crtc_msc)) {
-ret = present_queue_vblank(screen, target_crtc, vblank->event_id, 
target_msc);
+ret = present_queue_vblank(screen, window, target_crtc, 
vblank->event_id, target_msc);

[PATCH xserver v3 15/24] present: Add window flip mode

2018-03-13 Thread Roman Gilg
In contrast to screen flip mode this mode:
* supports flips per windows (these windows currently need to have the same
  size as their parent windows with the same pixmap),
* sends pixmap idle signals to the client only after the driver has given
  an additional event notify.

This patch only introduces the new mode as a stub. It additionally needs a
driver hook, such that it can get initialized and appropriate cleanup
functions.

Signed-off-by: Roman Gilg 
---
 present/Makefile.am|   3 +-
 present/meson.build|   1 +
 present/present.h  |   6 +
 present/present_priv.h |   9 +
 present/present_wnmd.c | 701 +
 5 files changed, 719 insertions(+), 1 deletion(-)
 create mode 100644 present/present_wnmd.c

diff --git a/present/Makefile.am b/present/Makefile.am
index 55ad295..542f4ca 100644
--- a/present/Makefile.am
+++ b/present/Makefile.am
@@ -15,6 +15,7 @@ libpresent_la_SOURCES = \
present_request.c \
present_scmd.c \
present_screen.c \
-   present_vblank.c
+   present_vblank.c \
+   present_wnmd.c
 
 sdk_HEADERS = present.h presentext.h
diff --git a/present/meson.build b/present/meson.build
index 84bea9b..1bd3d38 100644
--- a/present/meson.build
+++ b/present/meson.build
@@ -9,6 +9,7 @@ srcs_present = [
 'present_scmd.c',
 'present_screen.c',
 'present_vblank.c',
+'present_wnmd.c',
 ]
 
 libxserver_present = static_library('libxserver_present',
diff --git a/present/present.h b/present/present.h
index 8224322..0ea0a0e 100644
--- a/present/present.h
+++ b/present/present.h
@@ -159,6 +159,12 @@ typedef struct present_wnmd_info {
  */
 extern _X_EXPORT void
 present_event_notify(uint64_t event_id, uint64_t ust, uint64_t msc);
+/*
+ * Called when 'event_id' occurs for 'window'.
+ * 'ust' and 'msc' indicate when the event actually happened
+ */
+extern _X_EXPORT void
+present_wnmd_event_notify(WindowPtr window, uint64_t event_id, uint64_t ust, 
uint64_t msc);
 
 /* 'crtc' has been turned off, so any pending events will never occur.
  */
diff --git a/present/present_priv.h b/present/present_priv.h
index 375a100..f624567 100644
--- a/present/present_priv.h
+++ b/present/present_priv.h
@@ -477,4 +477,13 @@ present_vblank_scrap(present_vblank_ptr vblank);
 void
 present_vblank_destroy(present_vblank_ptr vblank);
 
+/*
+ * present_wnmd.c
+ */
+void
+present_wnmd_set_abort_flip(WindowPtr window);
+
+void
+present_wnmd_init_mode_hooks(present_screen_priv_ptr screen_priv);
+
 #endif /*  _PRESENT_PRIV_H_ */
diff --git a/present/present_wnmd.c b/present/present_wnmd.c
new file mode 100644
index 000..c1f879c
--- /dev/null
+++ b/present/present_wnmd.c
@@ -0,0 +1,701 @@
+/*
+ * Copyright © 2018 Roman Gilg
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include 
+#endif
+
+#include "present_priv.h"
+
+/*
+ * Window flip mode
+ *
+ * Provides per-window flips. Flips can be processed on windows that
+ * have the same size as their parents, which they share their pixmap with.
+ *
+ * A flip still requires a copy currently, since the original pixmap needs
+ * to be updated with the new pixmap content. Just a flip of all windows
+ * to the new pixmap is diffcult, because the original pixmap might not be
+ * controlled by the Xserver.
+ *
+ */
+
+static void
+present_wnmd_execute(present_vblank_ptr vblank, uint64_t ust, uint64_t 
crtc_msc);
+
+static void
+present_wnmd_create_event_id(present_window_priv_ptr window_priv, 
present_vblank_ptr vblank)
+{
+vblank->event_id = ++window_priv->event_id;
+}
+
+static uint32_t
+present_wnmd_query_capabilities(present_screen_priv_ptr screen_priv)
+{
+return screen_priv->wnmd_info->capabilities;
+}
+
+st

[PATCH xserver v3 16/24] present: In window flip mode report damage on flip to driver

2018-03-13 Thread Roman Gilg
Calculate damage before trying to flip and report it to the driver.
This allows drivers to optimize their rendering.

Signed-off-by: Roman Gilg 
---
 present/present.h  |  3 ++-
 present/present_wnmd.c | 24 +---
 2 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/present/present.h b/present/present.h
index 0ea0a0e..affb75f 100644
--- a/present/present.h
+++ b/present/present.h
@@ -105,7 +105,8 @@ typedef Bool (*present_wnmd_flip_ptr) (WindowPtr window,
uint64_t event_id,
uint64_t target_msc,
PixmapPtr pixmap,
-   Bool sync_flip);
+   Bool sync_flip,
+   RegionPtr damage);
 
 /* "unflip" back to the regular screen scanout buffer
  *
diff --git a/present/present_wnmd.c b/present/present_wnmd.c
index c1f879c..72bda2f 100644
--- a/present/present_wnmd.c
+++ b/present/present_wnmd.c
@@ -350,7 +350,8 @@ present_wnmd_flip(WindowPtr window,
   uint64_t event_id,
   uint64_t target_msc,
   PixmapPtr pixmap,
-  Bool sync_flip)
+  Bool sync_flip,
+  RegionPtr damage)
 {
 ScreenPtr   screen = crtc->pScreen;
 present_screen_priv_ptr screen_priv = present_screen_priv(screen);
@@ -360,7 +361,8 @@ present_wnmd_flip(WindowPtr window,
 event_id,
 target_msc,
 pixmap,
-sync_flip);
+sync_flip,
+damage);
 }
 
 static void
@@ -449,12 +451,19 @@ present_wnmd_execute(present_vblank_ptr vblank, uint64_t 
ust, uint64_t crtc_msc)
  */
 xorg_list_add(&vblank->event_queue, &window_priv->flip_queue);
 
+/* Set update region as damaged */
+if (vblank->update) {
+damage = vblank->update;
+RegionIntersect(damage, damage, &window->clipList);
+} else
+damage = &window->clipList;
+
 /* Try to flip - the vblank is now pending
  */
 window_priv->flip_pending = vblank;
 // ask the driver
 if (present_wnmd_flip(vblank->window, vblank->crtc, 
vblank->event_id,
- vblank->target_msc, vblank->pixmap, 
vblank->sync_flip)) {
+ vblank->target_msc, vblank->pixmap, 
vblank->sync_flip, damage)) {
 ScreenPtr screen = window->drawable.pScreen;
 WindowPtr toplvl_window = 
present_wnmd_toplvl_pixmap_window(vblank->window);
 PixmapPtr old_pixmap = screen->GetWindowPixmap(window);
@@ -464,14 +473,7 @@ present_wnmd_execute(present_vblank_ptr vblank, uint64_t 
ust, uint64_t crtc_msc)
 vblank->pixmap->refcnt++;
 dixDestroyPixmap(old_pixmap, old_pixmap->drawable.id);
 
-/* Report update region as damaged
- */
-if (vblank->update) {
-damage = vblank->update;
-RegionIntersect(damage, damage, &window->clipList);
-} else
-damage = &window->clipList;
-
+/* Report damage */
 DamageDamageRegion(&vblank->window->drawable, damage);
 return;
 }
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver v3 18/24] present: Add exported init function of window flip mode

2018-03-13 Thread Roman Gilg
Allow drivers now to initialize window flip mode.

Signed-off-by: Roman Gilg 
---
 present/present.h|  2 ++
 present/present_screen.c | 23 ++-
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/present/present.h b/present/present.h
index affb75f..3d0b972 100644
--- a/present/present.h
+++ b/present/present.h
@@ -174,6 +174,8 @@ present_event_abandon(RRCrtcPtr crtc);
 
 extern _X_EXPORT Bool
 present_screen_init(ScreenPtr screen, present_screen_info_ptr info);
+extern _X_EXPORT Bool
+present_wnmd_screen_init(ScreenPtr screen, present_wnmd_info_ptr info);
 
 typedef void (*present_complete_notify_proc)(WindowPtr window,
  CARD8 kind,
diff --git a/present/present_screen.c b/present/present_screen.c
index 8ad14ad..c7e37c5 100644
--- a/present/present_screen.c
+++ b/present/present_screen.c
@@ -239,7 +239,28 @@ present_screen_priv_init(ScreenPtr screen)
 }
 
 /*
- * Initialize a screen for use with present
+ * Initialize a screen for use with present in window flip mode (wnmd)
+ */
+int
+present_wnmd_screen_init(ScreenPtr screen, present_wnmd_info_ptr info)
+{
+if (!present_screen_register_priv_keys())
+return FALSE;
+
+if (!present_screen_priv(screen)) {
+present_screen_priv_ptr screen_priv = present_screen_priv_init(screen);
+if (!screen_priv)
+return FALSE;
+
+screen_priv->wnmd_info = info;
+present_wnmd_init_mode_hooks(screen_priv);
+}
+
+return TRUE;
+}
+
+/*
+ * Initialize a screen for use with present in default screen flip mode (scmd)
  */
 int
 present_screen_init(ScreenPtr screen, present_screen_info_ptr info)
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver v3 17/24] present: Add cleanups for window flip mode

2018-03-13 Thread Roman Gilg
Make sure that vblanks and windows get cleaned up correctly
in window flip mode.

Signed-off-by: Roman Gilg 
---
 present/present_screen.c | 33 -
 present/present_vblank.c |  2 ++
 2 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/present/present_screen.c b/present/present_screen.c
index b0cae0f..8ad14ad 100644
--- a/present/present_screen.c
+++ b/present/present_screen.c
@@ -109,6 +109,32 @@ present_clear_window_flip(WindowPtr window)
 }
 }
 
+static void
+present_wnmd_clear_window_flip(WindowPtr window)
+{
+present_window_priv_ptr window_priv = present_window_priv(window);
+present_vblank_ptr  vblank, tmp;
+
+if (window_priv->flip_pending) {
+present_wnmd_set_abort_flip(window);
+window_priv->flip_pending->window = NULL;
+}
+
+xorg_list_for_each_entry_safe(vblank, tmp, &window_priv->idle_queue, 
event_queue) {
+present_pixmap_idle(vblank->pixmap, vblank->window, vblank->serial, 
vblank->idle_fence);
+/* The pixmap will be destroyed by freeing the window resources. */
+vblank->pixmap = NULL;
+present_vblank_destroy(vblank);
+}
+
+vblank = window_priv->flip_active;
+if (vblank) {
+present_pixmap_idle(vblank->pixmap, vblank->window, vblank->serial, 
vblank->idle_fence);
+present_vblank_destroy(vblank);
+}
+window_priv->flip_active = NULL;
+}
+
 /*
  * Hook the close window function to clean up our window private
  */
@@ -124,7 +150,12 @@ present_destroy_window(WindowPtr window)
 present_clear_window_notifies(window);
 present_free_events(window);
 present_free_window_vblank(window);
-present_clear_window_flip(window);
+
+if (screen_priv->wnmd_info)
+present_wnmd_clear_window_flip(window);
+else
+present_clear_window_flip(window);
+
 free(window_priv);
 }
 unwrap(screen_priv, screen, DestroyWindow);
diff --git a/present/present_vblank.c b/present/present_vblank.c
index 7662c4d..f93a1af 100644
--- a/present/present_vblank.c
+++ b/present/present_vblank.c
@@ -172,6 +172,8 @@ present_vblank_destroy(present_vblank_ptr vblank)
 {
 /* Remove vblank from window and screen lists */
 xorg_list_del(&vblank->window_list);
+/* Also make sure vblank is removed from event queue (wnmd) */
+xorg_list_del(&vblank->event_queue);
 
 DebugPresent(("\td %lld %p %8lld: %08lx -> %08lx\n",
   vblank->event_id, vblank, vblank->target_msc,
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver v3 14/24] present: Add driver facing window flip mode hooks

2018-03-13 Thread Roman Gilg
To enable special functionality of window flips introduce for window flips
a separate set of driver facing function hooks.

Signed-off-by: Roman Gilg 
---
 present/present.h  | 43 +++
 present/present_priv.h |  1 +
 2 files changed, 44 insertions(+)

diff --git a/present/present.h b/present/present.h
index ade838b..8224322 100644
--- a/present/present.h
+++ b/present/present.h
@@ -41,6 +41,7 @@ typedef RRCrtcPtr (*present_get_crtc_ptr) (WindowPtr window);
 /* Return the current ust/msc for 'crtc'
  */
 typedef int (*present_get_ust_msc_ptr) (RRCrtcPtr crtc, uint64_t *ust, 
uint64_t *msc);
+typedef int (*present_wnmd_get_ust_msc_ptr) (WindowPtr window, uint64_t *ust, 
uint64_t *msc);
 
 /* Queue callback on 'crtc' for time 'msc'. Call present_event_notify with 
'event_id'
  * at or after 'msc'. Return false if it didn't happen (which might occur if 
'crtc'
@@ -49,12 +50,20 @@ typedef int (*present_get_ust_msc_ptr) (RRCrtcPtr crtc, 
uint64_t *ust, uint64_t
 typedef Bool (*present_queue_vblank_ptr) (RRCrtcPtr crtc,
   uint64_t event_id,
   uint64_t msc);
+typedef Bool (*present_wnmd_queue_vblank_ptr) (WindowPtr window,
+   RRCrtcPtr crtc,
+   uint64_t event_id,
+   uint64_t msc);
 
 /* Abort pending vblank. The extension is no longer interested in
  * 'event_id' which was to be notified at 'msc'. If possible, the
  * driver is free to de-queue the notification.
  */
 typedef void (*present_abort_vblank_ptr) (RRCrtcPtr crtc, uint64_t event_id, 
uint64_t msc);
+typedef void (*present_wnmd_abort_vblank_ptr) (WindowPtr window,
+   RRCrtcPtr crtc,
+   uint64_t event_id,
+   uint64_t msc);
 
 /* Flush pending drawing on 'window' to the hardware.
  */
@@ -84,6 +93,19 @@ typedef Bool (*present_flip_ptr) (RRCrtcPtr crtc,
   uint64_t target_msc,
   PixmapPtr pixmap,
   Bool sync_flip);
+/* Flip pixmap for window, return false if it didn't happen.
+ *
+ * Like present_flip_ptr, additionaly with:
+ *
+ * 'window' used for synchronization.
+ *
+ */
+typedef Bool (*present_wnmd_flip_ptr) (WindowPtr window,
+   RRCrtcPtr crtc,
+   uint64_t event_id,
+   uint64_t target_msc,
+   PixmapPtr pixmap,
+   Bool sync_flip);
 
 /* "unflip" back to the regular screen scanout buffer
  *
@@ -92,6 +114,12 @@ typedef Bool (*present_flip_ptr) (RRCrtcPtr crtc,
 typedef void (*present_unflip_ptr) (ScreenPtr screen,
 uint64_t event_id);
 
+/* Doing flips has been discontinued.
+ *
+ * Inform driver for potential cleanup on its side.
+ */
+typedef void (*present_wnmd_flips_stop_ptr) (WindowPtr window);
+
 #define PRESENT_SCREEN_INFO_VERSION1
 
 typedef struct present_screen_info {
@@ -110,6 +138,21 @@ typedef struct present_screen_info {
 
 } present_screen_info_rec, *present_screen_info_ptr;
 
+typedef struct present_wnmd_info {
+uint32_tversion;
+
+present_get_crtc_ptrget_crtc;
+present_wnmd_get_ust_msc_ptrget_ust_msc;
+present_wnmd_queue_vblank_ptr   queue_vblank;
+present_wnmd_abort_vblank_ptr   abort_vblank;
+present_flush_ptr   flush;
+uint32_tcapabilities;
+present_check_flip2_ptr check_flip2;
+present_wnmd_flip_ptr   flip;
+present_wnmd_flips_stop_ptr flips_stop;
+
+} present_wnmd_info_rec, *present_wnmd_info_ptr;
+
 /*
  * Called when 'event_id' occurs. 'ust' and 'msc' indicate when the
  * event actually happened
diff --git a/present/present_priv.h b/present/present_priv.h
index f697471..375a100 100644
--- a/present/present_priv.h
+++ b/present/present_priv.h
@@ -162,6 +162,7 @@ struct present_screen_priv {
 Boolflip_sync;
 
 present_screen_info_ptr info;
+present_wnmd_info_ptr   wnmd_info;
 
 /* Mode hooks */
 present_priv_query_capabilities_ptr query_capabilities;
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver v3 19/24] xwayland: Add arguments to glamor_pixmap_get_wl_buffer

2018-03-13 Thread Roman Gilg
Add arguments to give the caller more information and control
over the creation of a wl_buffer with GBM, in particular let
the caller determine the size of the buffer.

Signed-off-by: Roman Gilg 
---
 hw/xwayland/xwayland-glamor.c | 23 +--
 hw/xwayland/xwayland.c|  5 -
 hw/xwayland/xwayland.h|  5 -
 3 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index 4de3beb..7e98156 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -158,7 +158,10 @@ xwl_glamor_create_pixmap_for_bo(ScreenPtr screen, struct 
gbm_bo *bo, int depth)
 }
 
 struct wl_buffer *
-xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap)
+xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap,
+unsigned short width,
+unsigned short height,
+Bool *created)
 {
 struct xwl_screen *xwl_screen = xwl_screen_get(pixmap->drawable.pScreen);
 struct xwl_pixmap *xwl_pixmap = xwl_pixmap_get(pixmap);
@@ -169,8 +172,16 @@ xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap)
 uint64_t modifier;
 int i;
 
-if (xwl_pixmap->buffer)
+if (xwl_pixmap->buffer) {
+/* Buffer already exists. Return it and inform caller if interested. */
+if (created)
+*created = FALSE;
 return xwl_pixmap->buffer;
+}
+
+/* Buffer does not exist yet. Create now and inform caller if interested. 
*/
+if (created)
+*created = TRUE;
 
 if (!xwl_pixmap->bo)
return NULL;
@@ -205,16 +216,16 @@ xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap)
 
 xwl_pixmap->buffer =
zwp_linux_buffer_params_v1_create_immed(params,
-   pixmap->drawable.width,
-   pixmap->drawable.height,
+   width,
+   height,

wl_drm_format_for_depth(pixmap->drawable.depth),
0);
 zwp_linux_buffer_params_v1_destroy(params);
 } else if (num_planes == 1) {
 xwl_pixmap->buffer =
 wl_drm_create_prime_buffer(xwl_screen->drm, prime_fd,
-   pixmap->drawable.width,
-   pixmap->drawable.height,
+   width,
+   height,

wl_drm_format_for_depth(pixmap->drawable.depth),
0, gbm_bo_get_stride(xwl_pixmap->bo),
0, 0,
diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c
index d6a2887..f3fd497 100644
--- a/hw/xwayland/xwayland.c
+++ b/hw/xwayland/xwayland.c
@@ -649,7 +649,10 @@ xwl_window_post_damage(struct xwl_window *xwl_window)
 
 #ifdef GLAMOR_HAS_GBM
 if (xwl_screen->glamor)
-buffer = xwl_glamor_pixmap_get_wl_buffer(pixmap);
+buffer = xwl_glamor_pixmap_get_wl_buffer(pixmap,
+ pixmap->drawable.width,
+ pixmap->drawable.height,
+ NULL);
 else
 #endif
 buffer = xwl_shm_pixmap_get_wl_buffer(pixmap);
diff --git a/hw/xwayland/xwayland.h b/hw/xwayland/xwayland.h
index 36ebeaa..49fb5ba 100644
--- a/hw/xwayland/xwayland.h
+++ b/hw/xwayland/xwayland.h
@@ -341,7 +341,10 @@ Bool xwl_screen_set_drm_interface(struct xwl_screen 
*xwl_screen,
   uint32_t id, uint32_t version);
 Bool xwl_screen_set_dmabuf_interface(struct xwl_screen *xwl_screen,
  uint32_t id, uint32_t version);
-struct wl_buffer *xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap);
+struct wl_buffer *xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap,
+  unsigned short width,
+  unsigned short height,
+  Bool *created);
 
 void xwl_screen_release_tablet_manager(struct xwl_screen *xwl_screen);
 
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver v3 20/24] xwayland: Preliminary support for Present's new window flip mode

2018-03-13 Thread Roman Gilg
Introduce support for Present's window flip mode. The support is not yet
complete, but works reasonable well for the most important use case, that
is fullscreen applications.

We take a Present flip and if the xwl_window->window has the same dimensions
as the presenting window, the flip is represented by a wl_buffer and attached
to the main wl_surface of the xwl_window.

After commit we are listening for the sync callback in order to tell Present,
that the pixmap flip is not longer pending, for the frame callback in order
to update the msc counter and for the buffer release callback in order to tell
Present that the pixmap is idle again.

The following functionality is missing from this patch:
* (slowed down) flips in case the compositor is not sending frame callbacks,
* queuing events to MSC times,
* per window flips for child windows with smaller size than the xwl_window.

To make use of this functionality Xwayland must run rootless and with
Glamor/GBM.

Signed-off-by: Roman Gilg 
---
 hw/xwayland/Makefile.am|   1 +
 hw/xwayland/meson.build|   1 +
 hw/xwayland/xwayland-present.c | 366 +
 hw/xwayland/xwayland.h |  30 
 4 files changed, 398 insertions(+)
 create mode 100644 hw/xwayland/xwayland-present.c

diff --git a/hw/xwayland/Makefile.am b/hw/xwayland/Makefile.am
index f44a7de..3378a66 100644
--- a/hw/xwayland/Makefile.am
+++ b/hw/xwayland/Makefile.am
@@ -11,6 +11,7 @@ Xwayland_CFLAGS = \
 
 Xwayland_SOURCES = \
xwayland.c  \
+   xwayland-present.c  \
xwayland-input.c\
xwayland-cursor.c   \
xwayland-shm.c  \
diff --git a/hw/xwayland/meson.build b/hw/xwayland/meson.build
index 7e24c5d..17f52b4 100644
--- a/hw/xwayland/meson.build
+++ b/hw/xwayland/meson.build
@@ -1,5 +1,6 @@
 srcs = [
 'xwayland.c',
+'xwayland-present.c',
 'xwayland-input.c',
 'xwayland-cursor.c',
 'xwayland-shm.c',
diff --git a/hw/xwayland/xwayland-present.c b/hw/xwayland/xwayland-present.c
new file mode 100644
index 000..f41e864
--- /dev/null
+++ b/hw/xwayland/xwayland-present.c
@@ -0,0 +1,366 @@
+/*
+ * Copyright © 2018 Roman Gilg
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of the
+ * copyright holders not be used in advertising or publicity
+ * pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no
+ * representations about the suitability of this software for any
+ * purpose.  It is provided "as is" without express or implied
+ * warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+#include "xwayland.h"
+
+#include 
+
+void
+xwl_present_cleanup(WindowPtr window)
+{
+struct xwl_window   *xwl_window = xwl_window_of_top(window);
+struct xwl_present_event*event, *tmp;
+
+if (!xwl_window)
+return;
+
+if (xwl_window->present_window == window) {
+if (xwl_window->present_frame_callback) {
+wl_callback_destroy(xwl_window->present_frame_callback);
+xwl_window->present_frame_callback = NULL;
+}
+xwl_window->present_window = NULL;
+}
+
+/* Clear remaining buffer releases and inform Present about free 
ressources */
+xorg_list_for_each_entry_safe(event, tmp, 
&xwl_window->present_release_queue, list) {
+if (event->present_window == window) {
+xorg_list_del(&event->list);
+event->abort = TRUE;
+}
+}
+}
+
+static void
+xwl_present_free_event(struct xwl_present_event *event)
+{
+xorg_list_del(&event->list);
+free(event);
+}
+
+static void
+xwl_present_buffer_release(void *data, struct wl_buffer *buffer)
+{
+struct xwl_present_event *event = data;
+
+if (!event)
+return;
+wl_buffer_set_user_data(buffer, NULL);
+
+event->buffer_released = TRUE;
+
+if (event->abort) {
+if (!event->pending)
+xwl_present_

[PATCH xserver v3 21/24] xwayland: Add fallback timer for msc counting

2018-03-13 Thread Roman Gilg
When the compositor is not sending frame callbacks while we still wait
on buffer release events fake a continuous msc counter with a timer.

Having this timer is a prerequisite for queuing events.

Signed-off-by: Roman Gilg 
---
 hw/xwayland/xwayland-present.c | 70 ++
 hw/xwayland/xwayland.h |  3 ++
 2 files changed, 73 insertions(+)

diff --git a/hw/xwayland/xwayland-present.c b/hw/xwayland/xwayland-present.c
index f41e864..a8cc024 100644
--- a/hw/xwayland/xwayland-present.c
+++ b/hw/xwayland/xwayland-present.c
@@ -27,6 +27,34 @@
 
 #include 
 
+#define TIMER_LEN_FLIP1000  // 1fps
+
+static void
+xwl_present_free_timer(struct xwl_window *xwl_window)
+{
+TimerFree(xwl_window->present_timer);
+xwl_window->present_timer = NULL;
+}
+
+static CARD32
+xwl_present_timer_callback(OsTimerPtr timer,
+   CARD32 time,
+   void *arg);
+
+static void
+xwl_present_reset_timer(struct xwl_window *xwl_window)
+{
+if ( !xorg_list_is_empty(&xwl_window->present_release_queue) ) {
+xwl_window->present_timer = TimerSet(xwl_window->present_timer,
+ 0,
+ TIMER_LEN_FLIP,
+ &xwl_present_timer_callback,
+ xwl_window);
+} else {
+xwl_present_free_timer(xwl_window);
+}
+}
+
 void
 xwl_present_cleanup(WindowPtr window)
 {
@@ -51,6 +79,10 @@ xwl_present_cleanup(WindowPtr window)
 event->abort = TRUE;
 }
 }
+
+/* Clear timer */
+if ( xorg_list_is_empty(&xwl_window->present_release_queue) )
+xwl_present_free_timer(xwl_window);
 }
 
 static void
@@ -90,6 +122,27 @@ static const struct wl_buffer_listener 
xwl_present_release_listener = {
 xwl_present_buffer_release
 };
 
+CARD32
+xwl_present_timer_callback(OsTimerPtr timer,
+   CARD32 time,
+   void *arg)
+{
+struct xwl_window *xwl_window = arg;
+
+xwl_window->present_timer_firing = TRUE;
+xwl_window->present_msc++;
+xwl_window->present_ust = GetTimeInMicros();
+
+if ( !xorg_list_is_empty(&xwl_window->present_release_queue) ) {
+/* Still events, restart timer */
+return TIMER_LEN_FLIP;
+} else {
+/* No more events, do not restart timer and delete it instead */
+xwl_present_free_timer(xwl_window);
+return 0;
+}
+}
+
 static void
 xwl_present_frame_callback(void *data,
struct wl_callback *callback,
@@ -100,8 +153,18 @@ xwl_present_frame_callback(void *data,
 wl_callback_destroy(xwl_window->present_frame_callback);
 xwl_window->present_frame_callback = NULL;
 
+if (xwl_window->present_timer_firing) {
+/* If the timer is firing, this frame callback is too late */
+return;
+}
+
 xwl_window->present_msc++;
 xwl_window->present_ust = GetTimeInMicros();
+
+/* we do not need the timer anymore for this frame,
+ * reset it for potentially the next one
+ */
+xwl_present_reset_timer(xwl_window);
 }
 
 static const struct wl_callback_listener xwl_present_frame_listener = {
@@ -308,6 +371,13 @@ xwl_present_flip(WindowPtr present_window,
 /* We can flip directly to the main surface (full screen window without 
clips) */
 wl_surface_attach(xwl_window->surface, buffer, 0, 0);
 
+if (!xwl_window->present_timer ||
+xwl_window->present_timer_firing) {
+/* Realign timer */
+xwl_window->present_timer_firing = FALSE;
+xwl_present_reset_timer(xwl_window);
+}
+
 if (!xwl_window->present_frame_callback) {
 xwl_window->present_frame_callback = 
wl_surface_frame(xwl_window->surface);
 wl_callback_add_listener(xwl_window->present_frame_callback,
diff --git a/hw/xwayland/xwayland.h b/hw/xwayland/xwayland.h
index dd7d1c6..e6cec18 100644
--- a/hw/xwayland/xwayland.h
+++ b/hw/xwayland/xwayland.h
@@ -135,6 +135,9 @@ struct xwl_window {
 uint64_t present_msc;
 uint64_t present_ust;
 
+OsTimerPtr present_timer;
+Bool present_timer_firing;
+
 struct wl_callback *present_frame_callback;
 struct wl_callback *present_sync_callback;
 struct xorg_list present_release_queue;
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver v3 23/24] xwayland: Cut off upper 32bit of queued vblank delay

2018-03-13 Thread Roman Gilg
This ensures the same behavior as in Present's fake counter and xfree86.

At the moment clients might do put vblanks too far into the future, because
the fake vblank code in Present and the xfree86 driver tolerate cut off upper
32bit due to an 64 to 32bit conversion. Do this therefore here as well to not
suddenly regress on Xwayland only.

The sample client, that triggers this behavior, is the Steam client.

Signed-off-by: Roman Gilg 
---
 hw/xwayland/xwayland-present.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/hw/xwayland/xwayland-present.c b/hw/xwayland/xwayland-present.c
index f403ff7..300d96f 100644
--- a/hw/xwayland/xwayland-present.c
+++ b/hw/xwayland/xwayland-present.c
@@ -299,6 +299,7 @@ xwl_present_queue_vblank(WindowPtr present_window,
 {
 struct xwl_window *xwl_window = xwl_window_of_top(present_window);
 struct xwl_present_event *event;
+INT32 delay;
 
 if (!xwl_window)
 return BadMatch;
@@ -317,7 +318,10 @@ xwl_present_queue_vblank(WindowPtr present_window,
 event->event_id = event_id;
 event->present_window = present_window;
 event->xwl_window = xwl_window;
-event->target_msc = msc;
+
+/* Cut off upper 32bit, copies present_fake_queue_vblank. */
+delay = (int64_t) (msc - xwl_window->present_msc);
+event->target_msc = xwl_window->present_msc + delay;
 
 xorg_list_append(&event->list, &xwl_window->present_event_list);
 
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver v3 22/24] xwayland: Implement queuing present vblanks

2018-03-13 Thread Roman Gilg
Queue present events to msc values. Fake msc events with a refresh rate of
about 60fps when flips are not possible. When flips are executed rely on
frame callbacks with a slow updating timer as fallback.

This is important for applications, that want to limit their framerate.

Signed-off-by: Roman Gilg 
---
 hw/xwayland/xwayland-present.c | 103 +
 hw/xwayland/xwayland.h |   2 +
 2 files changed, 96 insertions(+), 9 deletions(-)

diff --git a/hw/xwayland/xwayland-present.c b/hw/xwayland/xwayland-present.c
index a8cc024..f403ff7 100644
--- a/hw/xwayland/xwayland-present.c
+++ b/hw/xwayland/xwayland-present.c
@@ -27,6 +27,13 @@
 
 #include 
 
+/*
+ * When not flipping let Present copy with 60fps.
+ * When flipping wait on frame_callback, otherwise
+ * the surface is not visible, in this case update
+ * with long interval.
+ */
+#define TIMER_LEN_COPY  17  // ~60fps
 #define TIMER_LEN_FLIP1000  // 1fps
 
 static void
@@ -41,13 +48,23 @@ xwl_present_timer_callback(OsTimerPtr timer,
CARD32 time,
void *arg);
 
+static inline Bool
+xwl_present_has_events(struct xwl_window *xwl_window)
+{
+return !xorg_list_is_empty(&xwl_window->present_event_list) ||
+   !xorg_list_is_empty(&xwl_window->present_release_queue);
+}
+
 static void
 xwl_present_reset_timer(struct xwl_window *xwl_window)
 {
-if ( !xorg_list_is_empty(&xwl_window->present_release_queue) ) {
+if (xwl_present_has_events(xwl_window)) {
+uint32_t timer_len = xwl_window->present_window ? TIMER_LEN_FLIP :
+  TIMER_LEN_COPY;
+
 xwl_window->present_timer = TimerSet(xwl_window->present_timer,
  0,
- TIMER_LEN_FLIP,
+ timer_len,
  &xwl_present_timer_callback,
  xwl_window);
 } else {
@@ -72,6 +89,14 @@ xwl_present_cleanup(WindowPtr window)
 xwl_window->present_window = NULL;
 }
 
+/* Clear remaining events */
+xorg_list_for_each_entry_safe(event, tmp, &xwl_window->present_event_list, 
list) {
+if (event->present_window == window) {
+xorg_list_del(&event->list);
+free(event);
+}
+}
+
 /* Clear remaining buffer releases and inform Present about free 
ressources */
 xorg_list_for_each_entry_safe(event, tmp, 
&xwl_window->present_release_queue, list) {
 if (event->present_window == window) {
@@ -81,7 +106,7 @@ xwl_present_cleanup(WindowPtr window)
 }
 
 /* Clear timer */
-if ( xorg_list_is_empty(&xwl_window->present_release_queue) )
+if (!xwl_present_has_events(xwl_window))
 xwl_present_free_timer(xwl_window);
 }
 
@@ -122,6 +147,25 @@ static const struct wl_buffer_listener 
xwl_present_release_listener = {
 xwl_present_buffer_release
 };
 
+static void
+xwl_present_events_notify(struct xwl_window *xwl_window)
+{
+uint64_tmsc = xwl_window->present_msc;
+struct xwl_present_event*event, *tmp;
+
+xorg_list_for_each_entry_safe(event, tmp,
+  &xwl_window->present_event_list,
+  list) {
+if (event->target_msc <= msc) {
+present_wnmd_event_notify(event->present_window,
+  event->event_id,
+  xwl_window->present_ust,
+  msc);
+xwl_present_free_event(event);
+}
+}
+}
+
 CARD32
 xwl_present_timer_callback(OsTimerPtr timer,
CARD32 time,
@@ -133,9 +177,12 @@ xwl_present_timer_callback(OsTimerPtr timer,
 xwl_window->present_msc++;
 xwl_window->present_ust = GetTimeInMicros();
 
-if ( !xorg_list_is_empty(&xwl_window->present_release_queue) ) {
+xwl_present_events_notify(xwl_window);
+
+if (xwl_present_has_events(xwl_window)) {
 /* Still events, restart timer */
-return TIMER_LEN_FLIP;
+return xwl_window->present_window ? TIMER_LEN_FLIP :
+TIMER_LEN_COPY;
 } else {
 /* No more events, do not restart timer and delete it instead */
 xwl_present_free_timer(xwl_window);
@@ -161,6 +208,8 @@ xwl_present_frame_callback(void *data,
 xwl_window->present_msc++;
 xwl_window->present_ust = GetTimeInMicros();
 
+xwl_present_events_notify(xwl_window);
+
 /* we do not need the timer anymore for this frame,
  * reset it for potentially the next one
  */
@@ -248,9 +297,34 @@ xwl_present_queue_vblank(WindowPtr present_window,
  

[PATCH xserver v3 24/24] xwayland: Activate Present flips in rootless mode with Glamor

2018-03-13 Thread Roman Gilg
Link the newly introduced support for Present flips. For now flips can only
be used in rootless mode together with Glamor.

Signed-off-by: Roman Gilg 
---
 hw/xwayland/xwayland.c | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c
index f3fd497..e65d8b7 100644
--- a/hw/xwayland/xwayland.c
+++ b/hw/xwayland/xwayland.c
@@ -522,6 +522,15 @@ xwl_realize_window(WindowPtr window)
 wl_region_destroy(region);
 }
 
+if (xwl_screen->present) {
+xwl_window->present_crtc_fake = RRCrtcCreate(xwl_screen->screen, 
xwl_window);
+xwl_window->present_msc = 1;
+xwl_window->present_ust = GetTimeInMicros();
+
+xorg_list_init(&xwl_window->present_event_list);
+xorg_list_init(&xwl_window->present_release_queue);
+}
+
 wl_display_flush(xwl_screen->display);
 
 send_surface_id_event(xwl_window);
@@ -587,6 +596,10 @@ xwl_unrealize_window(WindowPtr window)
 
 compUnredirectWindow(serverClient, window, CompositeRedirectManual);
 
+if (xwl_screen->present)
+/* Always cleanup Present (Present might have been active on child 
window) */
+xwl_present_cleanup(window);
+
 screen->UnrealizeWindow = xwl_screen->UnrealizeWindow;
 ret = (*screen->UnrealizeWindow) (window);
 xwl_screen->UnrealizeWindow = screen->UnrealizeWindow;
@@ -605,6 +618,9 @@ xwl_unrealize_window(WindowPtr window)
 if (xwl_window->frame_callback)
 wl_callback_destroy(xwl_window->frame_callback);
 
+if (xwl_window->present_crtc_fake)
+RRCrtcDestroy(xwl_window->present_crtc_fake);
+
 free(xwl_window);
 dixSetPrivate(&window->devPrivates, &xwl_window_private_key, NULL);
 
@@ -690,6 +706,9 @@ xwl_screen_post_damage(struct xwl_screen *xwl_screen)
 
 xorg_list_for_each_entry_safe(xwl_window, next_xwl_window,
   &xwl_screen->damage_window_list, 
link_damage) {
+/* Present on the main surface. So don't commit here as well. */
+if (xwl_window->present_window)
+continue;
 /* If we're waiting on a frame callback from the server,
  * don't attach a new buffer. */
 if (xwl_window->frame_callback)
@@ -1033,6 +1052,9 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
 }
 #endif
 
+if (xwl_screen->glamor && xwl_screen->rootless)
+xwl_screen->present = xwl_present_init(pScreen);
+
 if (!xwl_screen->glamor) {
 xwl_screen->CreateScreenResources = pScreen->CreateScreenResources;
 pScreen->CreateScreenResources = xwl_shm_create_screen_resources;
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Re: Bug 105851 Xserver 1.20 RC2+ issues with Kwin + Present 1.2

2018-04-09 Thread Roman Gilg
On Sat, Apr 7, 2018 at 9:56 AM, Mike Lothian  wrote:
> Switching to glx from egl gets things started for me

Do you mean switching from egl to glx as in switching the compositing
backend? And it did not work with egl backend but with glx?

The egl backend on X in KWin isn't supported well at the moment and
switching between them shouldn't be possible anymore from the control
module in system settings.

Can you post a backtrace from the dying process? Is it KWin or
Plasmashell? The one of Plasmashell in the Gentoo bug report is with
an AMD card.

Cheers
Roman
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH xserver] xwayland: Fix build without glamor

2018-04-16 Thread Roman Gilg
Thank you Olivier. Sorry for that.

An alternative solution would be to only ifdef out the
xwl_glamor_pixmap_get_wl_buffer call in xwl_present_flip and otherwise
return FALSE. But we then would needlessly still build the Present
support when compiling without glamor.

Reviewed-by: Roman Gilg 

On Mon, Apr 16, 2018 at 9:39 AM, Olivier Fourdan  wrote:
> Present support in Xwayland relies on glamor, make sure Xwayland can
> be built without glamor by moving references to Present code inside
> the conditional GLAMOR_HAS_GBM.
>
> Reported-by: Matt Turner 
> Signed-off-by: Olivier Fourdan 
> ---
>  hw/xwayland/Makefile.am |  4 ++--
>  hw/xwayland/meson.build |  3 +--
>  hw/xwayland/xwayland.c  | 10 +-
>  hw/xwayland/xwayland.h  |  7 ++-
>  4 files changed, 18 insertions(+), 6 deletions(-)
>
> diff --git a/hw/xwayland/Makefile.am b/hw/xwayland/Makefile.am
> index 0291afee7..80d3a1f19 100644
> --- a/hw/xwayland/Makefile.am
> +++ b/hw/xwayland/Makefile.am
> @@ -11,7 +11,6 @@ Xwayland_CFLAGS = \
>
>  Xwayland_SOURCES = \
> xwayland.c  \
> -   xwayland-present.c  \
> xwayland-input.c\
> xwayland-cursor.c   \
> xwayland-shm.c  \
> @@ -35,7 +34,8 @@ Xwayland_built_sources =
>
>  if GLAMOR_EGL
>  Xwayland_SOURCES +=\
> -   xwayland-glamor.c
> +   xwayland-glamor.c   \
> +   xwayland-present.c
>  if XV
>  Xwayland_SOURCES +=\
> xwayland-glamor-xv.c
> diff --git a/hw/xwayland/meson.build b/hw/xwayland/meson.build
> index 69a5c819a..8d178825e 100644
> --- a/hw/xwayland/meson.build
> +++ b/hw/xwayland/meson.build
> @@ -1,6 +1,5 @@
>  srcs = [
>  'xwayland.c',
> -'xwayland-present.c',
>  'xwayland-input.c',
>  'xwayland-cursor.c',
>  'xwayland-shm.c',
> @@ -53,7 +52,7 @@ srcs += code.process(dmabuf_xml)
>
>  xwayland_glamor = []
>  if gbm_dep.found()
> -srcs += 'xwayland-glamor.c'
> +srcs += [ 'xwayland-glamor.c', 'xwayland-present.c' ]
>  if build_xv
>  srcs += 'xwayland-glamor-xv.c'
>  endif
> diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c
> index dd074c341..44bbc3b18 100644
> --- a/hw/xwayland/xwayland.c
> +++ b/hw/xwayland/xwayland.c
> @@ -525,6 +525,7 @@ xwl_realize_window(WindowPtr window)
>  wl_region_destroy(region);
>  }
>
> +#ifdef GLAMOR_HAS_GBM
>  if (xwl_screen->present) {
>  xwl_window->present_crtc_fake = RRCrtcCreate(xwl_screen->screen, 
> xwl_window);
>  xwl_window->present_msc = 1;
> @@ -533,6 +534,7 @@ xwl_realize_window(WindowPtr window)
>  xorg_list_init(&xwl_window->present_event_list);
>  xorg_list_init(&xwl_window->present_release_queue);
>  }
> +#endif
>
>  wl_display_flush(xwl_screen->display);
>
> @@ -599,9 +601,11 @@ xwl_unrealize_window(WindowPtr window)
>
>  compUnredirectWindow(serverClient, window, CompositeRedirectManual);
>
> +#ifdef GLAMOR_HAS_GBM
>  if (xwl_screen->present)
>  /* Always cleanup Present (Present might have been active on child 
> window) */
>  xwl_present_cleanup(window);
> +#endif
>
>  screen->UnrealizeWindow = xwl_screen->UnrealizeWindow;
>  ret = (*screen->UnrealizeWindow) (window);
> @@ -621,8 +625,10 @@ xwl_unrealize_window(WindowPtr window)
>  if (xwl_window->frame_callback)
>  wl_callback_destroy(xwl_window->frame_callback);
>
> +#ifdef GLAMOR_HAS_GBM
>  if (xwl_window->present_crtc_fake)
>  RRCrtcDestroy(xwl_window->present_crtc_fake);
> +#endif
>
>  free(xwl_window);
>  dixSetPrivate(&window->devPrivates, &xwl_window_private_key, NULL);
> @@ -709,9 +715,11 @@ xwl_screen_post_damage(struct xwl_screen *xwl_screen)
>
>  xorg_list_for_each_entry_safe(xwl_window, next_xwl_window,
>&xwl_screen->damage_window_list, 
> link_damage) {
> +#ifdef GLAMOR_HAS_GBM
>  /* Present on the main surface. So don't commit here as well. */
>  if (xwl_window->present_window)
>  continue;
> +#endif
>  /* If we're waiting on a frame callback from the server,
>   * don't attach a new buffer. */
>  if (xwl_window->frame_callback)
> @@ -1053,10 +1061,10 @@ xwl_screen_init(ScreenPtr pScreen, int argc, 

Re: Quick heads-up, Xwayland present code causing memory corruption and crashes

2018-04-18 Thread Roman Gilg
On Wed, Apr 18, 2018 at 11:25 AM, Olivier Fourdan  wrote:
> This is a quick heads up, I was experiencing random crashes in Xwayland
> (very annoying in gnome-shell and it takes gnome-shell and the entire
> session with it). while running skype with current Xwayladn from 1.20 rc4.

Sorry for the annoyances. But I'm of course very glad you found them
before release. Thanks!

> This is due to commit 82df2ce3:
>
> Author: Roman Gilg 
> Date:   Tue Aug 22 15:38:26 2017 +0200
>
> xwayland: Avoid repeatedly looping through window ancestor chain
>
> Calling xwl_window_from_window means looping through the window ancestor
> chain whenever it is called on a child window or on an automatically
> redirected window.
>
> Since these properties and the potential ancestor's xwl_window are
> constant
> between window realization and unrealization, we can omit the looping by
> always putting the respective xwl_window in the Window's private field
> on
> its realization. If the Window doesn't feature an xwl_window on its own,
>     it's the xwl_window of its first ancestor with one.
>
> Signed-off-by: Roman Gilg 
> Reviewed-by: Pekka Paalanen 
>
> I think the assumption there is invalid in the case of a UnrealizeTree().

In UnrealizeTree() it seems indeed the tree is unrealized top to
bottom. What's the reason for doing it this way? Naively I would think
that unrealizing a window tree should run in opposed direction to
realizing one.

> Reverting that patch (and adjusting xwayland-present.c accordingly) solves
> the “invalid read” problem (as we don;t point to freed memoery anymore), but
> unfortunately that breaks xwayland-present logic that now leaves pending
> buffers and events after the unrealize()...

Reverting the patch and always calling xwl_window_from_window in the
present code (of course this means that we loop quite often in the
xwayland-present code) should work, since xwl_present_cleanup is
called in xwl_unrealize_window also already for the top parent window.

To fix the logic in xwl_present_cleanup we would need comparison
between event->present_window and xwl_window->present_window. And
destroy the xwl_window->present_frame_callback also if cleanup is
called on the top parent window.

So should we do this or try to always unrealize bottom-to-top in
UnrealizeTree()?
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH xserver v2] xwayland: avoid using freed xwl_window on unrealize

2018-04-18 Thread Roman Gilg
On Wed, Apr 18, 2018 at 4:02 PM, Olivier Fourdan  wrote:
> diff --git a/hw/xwayland/xwayland-present.c b/hw/xwayland/xwayland-present.c
> index f403ff701..e835a1399 100644
> --- a/hw/xwayland/xwayland-present.c
> +++ b/hw/xwayland/xwayland-present.c
> @@ -73,13 +73,9 @@ xwl_present_reset_timer(struct xwl_window *xwl_window)
>  }
>
>  void
> -xwl_present_cleanup(WindowPtr window)
> +xwl_present_cleanup(struct xwl_window *xwl_window, WindowPtr window)
>  {
> -struct xwl_window   *xwl_window = xwl_window_of_top(window);
> -struct xwl_present_event*event, *tmp;
> -
> -if (!xwl_window)
> -return;
> +struct xwl_present_event *event, *tmp;
>
>  if (xwl_window->present_window == window) {

I believe this check should be ORed with xwl_window->window == window.
Otherwise in case the top parent window is unrealized first,
xwl_window->present_window != window holds here and afterwards
xwl_present_cleanup won't be called again since the xwl_window is
already gone. I.e. an existing frame callback wouldn't be destroyed in
this case.

>  if (xwl_window->present_frame_callback) {
> @@ -91,18 +87,14 @@ xwl_present_cleanup(WindowPtr window)
>
>  /* Clear remaining events */
>  xorg_list_for_each_entry_safe(event, tmp, 
> &xwl_window->present_event_list, list) {
> -if (event->present_window == window) {
> -xorg_list_del(&event->list);
> -free(event);
> -}
> +xorg_list_del(&event->list);
> +free(event);
>  }
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH xserver] xwayland: Clean up all frame callbacks

2018-04-19 Thread Roman Gilg
Reviewed-by: Roman Gilg 

On Thu, Apr 19, 2018 at 9:13 AM, Olivier Fourdan  wrote:
> Regardless of the order we un-realize windows.
>
> Suggested-by: Roman Gilg 
> Signed-off-by: Olivier Fourdan 
> ---
>  hw/xwayland/xwayland-present.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/xwayland/xwayland-present.c b/hw/xwayland/xwayland-present.c
> index e835a1399..c41a8a2d1 100644
> --- a/hw/xwayland/xwayland-present.c
> +++ b/hw/xwayland/xwayland-present.c
> @@ -77,7 +77,7 @@ xwl_present_cleanup(struct xwl_window *xwl_window, 
> WindowPtr window)
>  {
>  struct xwl_present_event *event, *tmp;
>
> -if (xwl_window->present_window == window) {
> +if (xwl_window->present_window == window || xwl_window->window == 
> window) {
>  if (xwl_window->present_frame_callback) {
>  wl_callback_destroy(xwl_window->present_frame_callback);
>  xwl_window->present_frame_callback = NULL;
> --
> 2.17.0
>
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver] present: fix msc offset calculation in window mode

2018-04-20 Thread Roman Gilg
Instead of getting the current msc value from the window, which might be
different to old one directly take the last saved msc value saved in
the window_priv struct.

Signed-off-by: Roman Gilg 
---
 present/present_wnmd.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/present/present_wnmd.c b/present/present_wnmd.c
index 72bda2f..80ffb01 100644
--- a/present/present_wnmd.c
+++ b/present/present_wnmd.c
@@ -518,8 +518,6 @@ present_wnmd_window_to_crtc_msc(WindowPtr window, RRCrtcPtr 
crtc, uint64_t windo
 present_window_priv_ptr window_priv = present_get_window_priv(window, 
TRUE);
 
 if (crtc != window_priv->crtc) {
-uint64_t old_ust, old_msc;
-
 if (window_priv->crtc == PresentCrtcNeverSet) {
 window_priv->msc_offset = 0;
 } else {
@@ -527,10 +525,7 @@ present_wnmd_window_to_crtc_msc(WindowPtr window, 
RRCrtcPtr crtc, uint64_t windo
  * we'll just use whatever previous MSC we'd seen from this CRTC
  */
 
-if (present_wnmd_get_ust_msc(window->drawable.pScreen, window, 
&old_ust, &old_msc) != Success)
-old_msc = window_priv->msc;
-
-window_priv->msc_offset += new_msc - old_msc;
+window_priv->msc_offset += new_msc - window_priv->msc;
 }
 window_priv->crtc = crtc;
 }
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver] xwayland: restrict present cleanup to presenting and top parent window

2018-04-20 Thread Roman Gilg
Clean up only if the request points to the presenting window or its top
parent window.

Since in this case all events are removed unconditionally, always stop
the timer.

Signed-off-by: Roman Gilg 
---
 hw/xwayland/xwayland-present.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/hw/xwayland/xwayland-present.c b/hw/xwayland/xwayland-present.c
index c41a8a2..5112950 100644
--- a/hw/xwayland/xwayland-present.c
+++ b/hw/xwayland/xwayland-present.c
@@ -77,13 +77,14 @@ xwl_present_cleanup(struct xwl_window *xwl_window, 
WindowPtr window)
 {
 struct xwl_present_event *event, *tmp;
 
-if (xwl_window->present_window == window || xwl_window->window == window) {
-if (xwl_window->present_frame_callback) {
-wl_callback_destroy(xwl_window->present_frame_callback);
-xwl_window->present_frame_callback = NULL;
-}
-xwl_window->present_window = NULL;
+if (xwl_window->present_window != window && xwl_window->window != window)
+return;
+
+if (xwl_window->present_frame_callback) {
+wl_callback_destroy(xwl_window->present_frame_callback);
+xwl_window->present_frame_callback = NULL;
 }
+xwl_window->present_window = NULL;
 
 /* Clear remaining events */
 xorg_list_for_each_entry_safe(event, tmp, &xwl_window->present_event_list, 
list) {
@@ -98,8 +99,7 @@ xwl_present_cleanup(struct xwl_window *xwl_window, WindowPtr 
window)
 }
 
 /* Clear timer */
-if (!xwl_present_has_events(xwl_window))
-xwl_present_free_timer(xwl_window);
+xwl_present_free_timer(xwl_window);
 }
 
 static void
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH xserver] present: fix msc offset calculation in window mode

2018-04-21 Thread Roman Gilg
On Fri, Apr 20, 2018 at 6:23 PM, Olivier Fourdan  wrote:
> Unfortunately, contrary to my initial tests, the black window still occurs
> randomly even with that patch applied.
That's unfortunate. How severe is it? Is it just for a short period or
longer? I believe you said on IRC that it once stayed black and never
resumed but you weren't sure if just the client froze.

One idea I have regarding the issue is, that I believe on Unrealize
the remaining queued events are not sent back to Present, but simply
discarded on xwl_present_cleanup. I think these events should still be
delivered to Present instead.

But maybe the best way forward instead would be to do what Michel
proposed: add a persistent private struct to Xwayland and not reuse
the xwl_window one, which gets destroyed on every Unrealize. This way
the window's Xwayland Present msc counter could keep running while the
window is unrealized and we could more reliable process events still
waiting for their target msc.

The problem is that I'm on a Plasma dev sprint by today till next
weekend and won't be able to work on the issue in this time. After
that I would try to setup my build enviornment for the Xserver again
and find a solution to the problem. If this is not possible in regards
to the planned Xserver release, we need to find another solution.
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH xserver] present: fix msc offset calculation in window mode

2018-04-21 Thread Roman Gilg
You are right that this would prevent possible future backends
supporting window mode and with real crtcs to return consistent msc
values. But this wouldn't work anyway currently since
present_wnmd_get_ust_msc_ptr does not provide the crtc it expects to
the backend, but only the window.

I think now that this should change instead of the patch I sent in
here (add the crtc argument back to the call). This way Xwayland could
check the expected crtc and if it is not the fake one currently in its
xwl_window struct it would just return an error (and then
present_wnmd_window_to_crtc_msc would use the window_priv->msc value
instead).

On Fri, Apr 20, 2018 at 6:11 PM, Michel Dänzer  wrote:
> On 2018-04-20 05:10 PM, Roman Gilg wrote:
>> Instead of getting the current msc value from the window, which might be
>> different to old one directly take the last saved msc value saved in
>> the window_priv struct.
>>
>> Signed-off-by: Roman Gilg 
>> ---
>>  present/present_wnmd.c | 7 +--
>>  1 file changed, 1 insertion(+), 6 deletions(-)
>>
>> diff --git a/present/present_wnmd.c b/present/present_wnmd.c
>> index 72bda2f..80ffb01 100644
>> --- a/present/present_wnmd.c
>> +++ b/present/present_wnmd.c
>> @@ -518,8 +518,6 @@ present_wnmd_window_to_crtc_msc(WindowPtr window, 
>> RRCrtcPtr crtc, uint64_t windo
>>  present_window_priv_ptr window_priv = present_get_window_priv(window, 
>> TRUE);
>>
>>  if (crtc != window_priv->crtc) {
>> -uint64_t old_ust, old_msc;
>> -
>>  if (window_priv->crtc == PresentCrtcNeverSet) {
>>  window_priv->msc_offset = 0;
>>  } else {
>> @@ -527,10 +525,7 @@ present_wnmd_window_to_crtc_msc(WindowPtr window, 
>> RRCrtcPtr crtc, uint64_t windo
>>   * we'll just use whatever previous MSC we'd seen from this CRTC
>>   */
>>
>> -if (present_wnmd_get_ust_msc(window->drawable.pScreen, window, 
>> &old_ust, &old_msc) != Success)
>> -old_msc = window_priv->msc;
>> -
>> -window_priv->msc_offset += new_msc - old_msc;
>> +window_priv->msc_offset += new_msc - window_priv->msc;
>
> This is working around an issue in xwl_present_get_ust_msc (it doesn't
> return consistent MSC values for a window which has been unmapped and
> mapped again). This change might do the wrong thing with another backend
> which has real CRTCs and returns consistent MSC values for them.
>
> That said, maybe this is the best that can be done to address the
> immediate issue, but it might be good to at least add a comment saying
> this is a kludge which should be revisited after 1.20.
>
>
> --
> Earthling Michel Dänzer   |   http://www.amd.com
> Libre software enthusiast | Mesa and X developer
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver] modesetting: set gbm as dependency in meson build

2018-05-02 Thread Roman Gilg
Modifiers support needs gbm as a dependency. Without setting the dependency
included headers are not found reliably and the build might fail if the
headers are not placed in the default system include paths.

Signed-off-by: Roman Gilg 
---
 hw/xfree86/drivers/modesetting/meson.build | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/xfree86/drivers/modesetting/meson.build 
b/hw/xfree86/drivers/modesetting/meson.build
index 37fd893..5e13f1a 100644
--- a/hw/xfree86/drivers/modesetting/meson.build
+++ b/hw/xfree86/drivers/modesetting/meson.build
@@ -19,6 +19,7 @@ shared_module(
 common_dep,
 udev_dep,
 libdrm_dep,
+gbm_dep,
 ],
 
 install: true,
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver] present: in get_ust_msc hook of wnmd provide CRTC as argument

2018-05-02 Thread Roman Gilg
For backwards compatibility a driver supporting window flip mode still must
calculate msc values per CRTC.

It is important that the driver returns the msc for the CRTC that Present
requests the msc for or return an error if this is not possible.

This way Present can calculate the offset correctly in
present_wnmd_window_to_crtc_msc.

Signed-off-by: Roman Gilg 
---
 hw/xwayland/xwayland-present.c | 10 +-
 present/present.h  |  2 +-
 present/present_wnmd.c | 14 +-
 3 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/hw/xwayland/xwayland-present.c b/hw/xwayland/xwayland-present.c
index 66bfaae..adc3a68 100644
--- a/hw/xwayland/xwayland-present.c
+++ b/hw/xwayland/xwayland-present.c
@@ -258,11 +258,19 @@ xwl_present_get_crtc(WindowPtr present_window)
 }
 
 static int
-xwl_present_get_ust_msc(WindowPtr present_window, uint64_t *ust, uint64_t *msc)
+xwl_present_get_ust_msc(WindowPtr present_window, RRCrtcPtr crtc, uint64_t 
*ust, uint64_t *msc)
 {
 struct xwl_window *xwl_window = xwl_window_from_window(present_window);
 if (!xwl_window)
 return BadAlloc;
+
+if (xwl_window->present_crtc_fake != crtc) {
+/* the crtc changed between the last call and this one,
+ * falls back to using the saved window msc in Present
+ */
+return BadMatch;
+}
+
 *ust = xwl_window->present_ust;
 *msc = xwl_window->present_msc;
 
diff --git a/present/present.h b/present/present.h
index 3d0b972..0a3682c 100644
--- a/present/present.h
+++ b/present/present.h
@@ -41,7 +41,7 @@ typedef RRCrtcPtr (*present_get_crtc_ptr) (WindowPtr window);
 /* Return the current ust/msc for 'crtc'
  */
 typedef int (*present_get_ust_msc_ptr) (RRCrtcPtr crtc, uint64_t *ust, 
uint64_t *msc);
-typedef int (*present_wnmd_get_ust_msc_ptr) (WindowPtr window, uint64_t *ust, 
uint64_t *msc);
+typedef int (*present_wnmd_get_ust_msc_ptr) (WindowPtr window, RRCrtcPtr crtc, 
uint64_t *ust, uint64_t *msc);
 
 /* Queue callback on 'crtc' for time 'msc'. Call present_event_notify with 
'event_id'
  * at or after 'msc'. Return false if it didn't happen (which might occur if 
'crtc'
diff --git a/present/present_wnmd.c b/present/present_wnmd.c
index 80ffb01..c95bc92 100644
--- a/present/present_wnmd.c
+++ b/present/present_wnmd.c
@@ -61,10 +61,10 @@ present_wnmd_get_crtc(present_screen_priv_ptr screen_priv, 
WindowPtr window)
 }
 
 static int
-present_wnmd_get_ust_msc(ScreenPtr screen, WindowPtr window, uint64_t *ust, 
uint64_t *msc)
+present_wnmd_get_ust_msc(ScreenPtr screen, WindowPtr window, RRCrtcPtr crtc, 
uint64_t *ust, uint64_t *msc)
 {
 present_screen_priv_ptr screen_priv = present_screen_priv(screen);
-return (*screen_priv->wnmd_info->get_ust_msc)(window, ust, msc);
+return (*screen_priv->wnmd_info->get_ust_msc)(window, crtc, ust, msc);
 }
 
 /*
@@ -76,7 +76,7 @@ present_wnmd_re_execute(present_vblank_ptr vblank)
 {
 uint64_t ust = 0, crtc_msc = 0;
 
-(void) present_wnmd_get_ust_msc(vblank->screen, vblank->window, &ust, 
&crtc_msc);
+(void) present_wnmd_get_ust_msc(vblank->screen, vblank->window, 
vblank->crtc, &ust, &crtc_msc);
 present_wnmd_execute(vblank, ust, crtc_msc);
 }
 
@@ -518,6 +518,7 @@ present_wnmd_window_to_crtc_msc(WindowPtr window, RRCrtcPtr 
crtc, uint64_t windo
 present_window_priv_ptr window_priv = present_get_window_priv(window, 
TRUE);
 
 if (crtc != window_priv->crtc) {
+uint64_t old_ust, old_msc;
 if (window_priv->crtc == PresentCrtcNeverSet) {
 window_priv->msc_offset = 0;
 } else {
@@ -525,7 +526,10 @@ present_wnmd_window_to_crtc_msc(WindowPtr window, 
RRCrtcPtr crtc, uint64_t windo
  * we'll just use whatever previous MSC we'd seen from this CRTC
  */
 
-window_priv->msc_offset += new_msc - window_priv->msc;
+if (present_wnmd_get_ust_msc(window->drawable.pScreen, window, 
window_priv->crtc, &old_ust, &old_msc) != Success)
+old_msc = window_priv->msc;
+
+window_priv->msc_offset += new_msc - old_msc;
 }
 window_priv->crtc = crtc;
 }
@@ -565,7 +569,7 @@ present_wnmd_pixmap(WindowPtr window,
 
 target_crtc = present_wnmd_get_crtc(screen_priv, window);
 
-ret = present_wnmd_get_ust_msc(screen, window, &ust, &crtc_msc);
+ret = present_wnmd_get_ust_msc(screen, window, target_crtc, &ust, 
&crtc_msc);
 
 target_msc = present_wnmd_window_to_crtc_msc(window, target_crtc, 
window_msc, crtc_msc);
 
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[RFC xserver] xwayland: persistent window struct on present

2018-05-03 Thread Roman Gilg
Instead of reusing xwl_window introduce a persistent window struct for every
window, that asks for Present flips.

This struct saves all relevant data and is only freed on window destroy.

Signed-off-by: Roman Gilg 
---
 hw/xwayland/xwayland-present.c | 277 -
 hw/xwayland/xwayland.c |  50 
 hw/xwayland/xwayland.h |  37 +++---
 3 files changed, 212 insertions(+), 152 deletions(-)

diff --git a/hw/xwayland/xwayland-present.c b/hw/xwayland/xwayland-present.c
index 66bfaae..ae9f47e 100644
--- a/hw/xwayland/xwayland-present.c
+++ b/hw/xwayland/xwayland-present.c
@@ -36,11 +36,49 @@
 #define TIMER_LEN_COPY  17  // ~60fps
 #define TIMER_LEN_FLIP1000  // 1fps
 
+static DevPrivateKeyRec xwl_present_window_private_key;
+
+static struct xwl_present_window *
+xwl_present_window_priv(WindowPtr window)
+{
+return dixGetPrivate(&window->devPrivates,
+ &xwl_present_window_private_key);
+}
+
+static struct xwl_present_window *
+xwl_present_window_get_priv(WindowPtr window)
+{
+struct xwl_present_window *xwl_present_window = 
xwl_present_window_priv(window);
+
+if (xwl_present_window == NULL) {
+ScreenPtr screen = window->drawable.pScreen;
+
+xwl_present_window = calloc (1, sizeof (struct xwl_present_window));
+if (!xwl_present_window)
+return NULL;
+
+xwl_present_window->crtc_fake = RRCrtcCreate(screen,
+ xwl_present_window);
+xwl_present_window->window = window;
+xwl_present_window->msc = 1;
+xwl_present_window->ust = GetTimeInMicros();
+
+xorg_list_init(&xwl_present_window->event_list);
+xorg_list_init(&xwl_present_window->release_queue);
+
+dixSetPrivate(&window->devPrivates,
+  &xwl_present_window_private_key,
+  xwl_present_window);
+}
+
+return xwl_present_window;
+}
+
 static void
-xwl_present_free_timer(struct xwl_window *xwl_window)
+xwl_present_free_timer(struct xwl_present_window *xwl_present_window)
 {
-TimerFree(xwl_window->present_timer);
-xwl_window->present_timer = NULL;
+TimerFree(xwl_present_window->frame_timer);
+xwl_present_window->frame_timer = NULL;
 }
 
 static CARD32
@@ -49,57 +87,73 @@ xwl_present_timer_callback(OsTimerPtr timer,
void *arg);
 
 static inline Bool
-xwl_present_has_events(struct xwl_window *xwl_window)
+xwl_present_has_events(struct xwl_present_window *xwl_present_window)
 {
-return !xorg_list_is_empty(&xwl_window->present_event_list) ||
-   !xorg_list_is_empty(&xwl_window->present_release_queue);
+return !xorg_list_is_empty(&xwl_present_window->event_list) ||
+   !xorg_list_is_empty(&xwl_present_window->release_queue);
+}
+
+static inline Bool
+xwl_present_is_flipping(WindowPtr window, struct xwl_window *xwl_window)
+{
+return xwl_window && xwl_window->present_window == window;
 }
 
 static void
-xwl_present_reset_timer(struct xwl_window *xwl_window)
+xwl_present_reset_timer(struct xwl_present_window *xwl_present_window)
 {
-if (xwl_present_has_events(xwl_window)) {
-uint32_t timer_len = xwl_window->present_window ? TIMER_LEN_FLIP :
-  TIMER_LEN_COPY;
-
-xwl_window->present_timer = TimerSet(xwl_window->present_timer,
- 0,
- timer_len,
- &xwl_present_timer_callback,
- xwl_window);
+if (xwl_present_has_events(xwl_present_window)) {
+WindowPtr present_window = xwl_present_window->window;
+Bool is_flipping = xwl_present_is_flipping(present_window,
+   
xwl_window_from_window(present_window));
+
+xwl_present_window->frame_timer = 
TimerSet(xwl_present_window->frame_timer,
+   0,
+   is_flipping ? 
TIMER_LEN_FLIP :
+ 
TIMER_LEN_COPY,
+   &xwl_present_timer_callback,
+   xwl_present_window);
 } else {
-xwl_present_free_timer(xwl_window);
+xwl_present_free_timer(xwl_present_window);
 }
 }
 
 void
-xwl_present_cleanup(struct xwl_window *xwl_window, WindowPtr window)
+xwl_present_cleanup(WindowPtr window)
 {
+struct xwl_window *xwl_window = xwl_window_from_window(window);
+struct xwl_present_window *xwl_present_window = 
xwl_present_window_priv(window);
 struct xwl_present_event *event, *tmp

Re: [RFC xserver] xwayland: persistent window struct on present

2018-05-04 Thread Roman Gilg
Thanks for the testing Olivier. That's great news because the code
change was written rather hastily and I hadn't tested it extensively
yet. I just wanted to get some early feedback on the overall design.

But using separate persistent window structs is just more robust than
using xwl_window, which always get discarded on unmap. So that the
change directly worked for you without regressions is probably a
consequence of that.

On Fri, May 4, 2018 at 10:05 AM, Olivier Fourdan  wrote:
> Hi Roman,
>
> On Fri, May 4, 2018 at 3:07 AM, Roman Gilg  wrote:
>>
>> Instead of reusing xwl_window introduce a persistent window struct for
>> every
>> window, that asks for Present flips.
>>
>> This struct saves all relevant data and is only freed on window destroy.
>>
>> Signed-off-by: Roman Gilg 
>> ---
>>  hw/xwayland/xwayland-present.c | 277
>> -
>>  hw/xwayland/xwayland.c |  50 
>>  hw/xwayland/xwayland.h |  37 +++---
>>  3 files changed, 212 insertions(+), 152 deletions(-)
>>
>> diff --git a/hw/xwayland/xwayland-present.c
>> b/hw/xwayland/xwayland-present.c
>> index 66bfaae..ae9f47e 100644
>> --- a/hw/xwayland/xwayland-present.c
>> +++ b/hw/xwayland/xwayland-present.c
>> @@ -36,11 +36,49 @@
>>  #define TIMER_LEN_COPY  17  // ~60fps
>>  #define TIMER_LEN_FLIP1000  // 1fps
>>
>> +static DevPrivateKeyRec xwl_present_window_private_key;
>> +
>> +static struct xwl_present_window *
>> +xwl_present_window_priv(WindowPtr window)
>> +{
>> +return dixGetPrivate(&window->devPrivates,
>> + &xwl_present_window_private_key);
>> +}
>> +
>> +static struct xwl_present_window *
>> +xwl_present_window_get_priv(WindowPtr window)
>> +{
>> +struct xwl_present_window *xwl_present_window =
>> xwl_present_window_priv(window);
>> +
>> +if (xwl_present_window == NULL) {
>> +ScreenPtr screen = window->drawable.pScreen;
>> +
>> +xwl_present_window = calloc (1, sizeof (struct
>> xwl_present_window));
>> +if (!xwl_present_window)
>> +return NULL;
>> +
>> +xwl_present_window->crtc_fake = RRCrtcCreate(screen,
>> + xwl_present_window);
>> +xwl_present_window->window = window;
>> +xwl_present_window->msc = 1;
>> +xwl_present_window->ust = GetTimeInMicros();
>> +
>> +xorg_list_init(&xwl_present_window->event_list);
>> +xorg_list_init(&xwl_present_window->release_queue);
>> +
>> +dixSetPrivate(&window->devPrivates,
>> +  &xwl_present_window_private_key,
>> +  xwl_present_window);
>> +}
>> +
>> +return xwl_present_window;
>> +}
>> +
>>  static void
>> -xwl_present_free_timer(struct xwl_window *xwl_window)
>> +xwl_present_free_timer(struct xwl_present_window *xwl_present_window)
>>  {
>> -TimerFree(xwl_window->present_timer);
>> -xwl_window->present_timer = NULL;
>> +TimerFree(xwl_present_window->frame_timer);
>> +xwl_present_window->frame_timer = NULL;
>>  }
>>
>>  static CARD32
>> @@ -49,57 +87,73 @@ xwl_present_timer_callback(OsTimerPtr timer,
>> void *arg);
>>
>>  static inline Bool
>> -xwl_present_has_events(struct xwl_window *xwl_window)
>> +xwl_present_has_events(struct xwl_present_window *xwl_present_window)
>>  {
>> -return !xorg_list_is_empty(&xwl_window->present_event_list) ||
>> -   !xorg_list_is_empty(&xwl_window->present_release_queue);
>> +return !xorg_list_is_empty(&xwl_present_window->event_list) ||
>> +   !xorg_list_is_empty(&xwl_present_window->release_queue);
>> +}
>> +
>> +static inline Bool
>> +xwl_present_is_flipping(WindowPtr window, struct xwl_window *xwl_window)
>> +{
>> +return xwl_window && xwl_window->present_window == window;
>>  }
>>
>>  static void
>> -xwl_present_reset_timer(struct xwl_window *xwl_window)
>> +xwl_present_reset_timer(struct xwl_present_window *xwl_present_window)
>>  {
>> -if (xwl_present_has_events(xwl_window)) {
>> -uint32_t timer_len = xwl_window->present_window ? TIMER_LEN_FLIP
>> :
>> -  TIMER_LEN_

Re: [Mesa-dev] [PATCH 1/2] loader_dri3: Wait for pending swaps to complete before drawable_fini.

2018-05-05 Thread Roman Gilg
Without this patch plasmashell on Xserver/Mesa master freezes on me
when opening the launcher menu (Kickoff). With the patch haven't
experienced freezes yet.

Haven't tested the Steam client yet. Might be a different problem though.

Tested-by: Roman Gilg 

On Fri, May 4, 2018 at 3:45 PM, Mario Kleiner
 wrote:
> Before destroying the loader_dri3_drawable, make sure all pending
> swaps for it have completed. This guides against the following scenario,
> which happens, e.g., with KDE Plasma-5's plasmashell (which uses
> QT-5's QtGui/QtQuick for rendering), when it repaints multiple
> UI elements, each represented by its own Window/GLXDrawable, using
> one common GLXContext for all GLXDrawable's:
>
> 1. glXMakeCurrent(dpy, drawable1, context);
> 2. glXXX render to drawable1
> 3. glXSwapBuffers(dpy, drawable1); #1
> 4. glXMakeCurrent(dpy, drawable2, context);
> 5. glXXX render to drawable2
> 6. glXSwapBuffers(dpy, drawable2);
> // While the swap #1 is still pending for drawable1:
> 7. glXMakeCurrent(dpy, drawable1, context);
> 8. glXXX render to drawable1
> 9. glXSwapBuffers(dpy, drawable1);
>
> Binding a different drawable2 to the same context via glXMakeCurrent
> will cause its previous drawable1 to be released (cfe. dri3_bind_context
> -> driReleaseDrawables), which in turn calls loader_dri3_drawable_fini().
> This unselects for Present notify event delivery on the associated
> X-Window and loses all dri3 related state. If drawable1 is selected for
> the context again [7], a new incarnation of loader_dri3_drawable is
> created in dri3_bind_context->driFetchDrawable->dri3_create_drawable->
> loader_dri3_drawable_init(), which again selects for Present notify
> event delivery for the underlying X-Window, but the new incarnation lost
> all state wrt. to previous rendering and swaps. The server now delivers
> PresentPixmapIdle and PresentPixmapComplete events from the completed
> previous swapbuffers call #1 [3] to the new loader_dri3_drawable, which
> doesn't expect those. One problem is that the new incarnation has a
> draw->send_sbc == 0, but now receives PresentPixmapComplete events with
> sbc's > 0, therefore updating draw->recv_sbc to > 0 in
> dri3_handle_present_event(). The draw->recv_sbc > draw_send_sbc is
> misinterpreted as sbc wraparound, triggers recv_sbc wraparound handling
> and ends up with a very large draw->recv_sbc. During the next swapbuffers
> call [9], the totally wrong recv_sbc is used for calculating the target_msc
> for the PresentPixmap request, leading to a target_msc billions of vblanks
> in the future, leading to a swap that never completes and thereby frozen UI
> and hang of the client.
>
> Make sure that a loader_dri3_drawable can only be destroyed after all
> its pending swaps have completed, to prevent misdelivery of PresentNotify
> events to the right X-Window, but the wrong incarnation of the associated
> loader_dri3_drawable.
>
> Signed-off-by: Mario Kleiner 
> Cc: xorg-devel@lists.x.org
> Cc: dan...@fooishbar.org
> Cc: eero.t.tammi...@intel.com
> Cc: m...@fireburn.co.uk
> ---
>  src/loader/loader_dri3_helper.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/src/loader/loader_dri3_helper.c b/src/loader/loader_dri3_helper.c
> index 6bb11c4..7bd79af 100644
> --- a/src/loader/loader_dri3_helper.c
> +++ b/src/loader/loader_dri3_helper.c
> @@ -234,6 +234,9 @@ loader_dri3_drawable_fini(struct loader_dri3_drawable 
> *draw)
>  {
> int i;
>
> +   if (draw->special_event)
> +  loader_dri3_swapbuffer_barrier(draw);
> +
> draw->ext->core->destroyDrawable(draw->dri_drawable);
>
> for (i = 0; i < ARRAY_SIZE(draw->buffers); i++) {
> --
> 2.7.4
>
> ___
> mesa-dev mailing list
> mesa-...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Re: [Mesa-dev] [PATCH 1/2] loader_dri3: Wait for pending swaps to complete before drawable_fini.

2018-05-05 Thread Roman Gilg
On Sat, May 5, 2018 at 8:50 PM, Mario Kleiner
 wrote:
> Thanks. Can you see if you get any freezes in kwin_x11 by "violent
> alt-tabbing" with patch 1? I've seen two such freezes within 8 hours
> of normal use yesterday, each occuring when i alt-tabbed (normally)
> and the switcher side panel moved out from the left. Desktop was
> mostly blocked then, i assume it was kwin_x11 that got stuck. When
> VT-switching to the console and attaching gdb to kwin_x11 the
> backtrace showed it blocked in the loader_dri3_swapbuffer_barrier()
> from patch 1. I don't know if that was the cause of the freeze, or if
> something unrelated was going wrong and kwin just happens to block
> there when one VT switches away from the X-Server while kwin does its
> thing. Freezes happened both with compositing enabled and disabled.

Yes, I can confirm it happened to me as well now with patch 1.
Happened when holding Alt + Tab, but I had to try a few times. I
logged in directly with sddm and got the following backtrace without
VT switch by ssh session. So should be a clean one:

#0  0x7f4517e1074d in poll () at ../sysdeps/unix/syscall-template.S:84
#1  0x7f4516d32172 in poll (__timeout=-1, __nfds=1,
__fds=0x7ffed4e8ead0) at /usr/include/x86_64-linux-gnu/bits/poll2.h:46
#2  _xcb_conn_wait (c=c@entry=0xcc4be0, cond=cond@entry=0x19ef968,
vector=vector@entry=0x0, count=count@entry=0x0) at
/home/roman/dev/gfx/xcb/src/libxcb/src/xcb_conn.c:479
#3  0x7f4516d33e69 in xcb_wait_for_special_event (c=0xcc4be0,
se=0x19ef940) at /home/roman/dev/gfx/xcb/src/libxcb/src/xcb_in.c:795
#4  0x7f450d764d36 in dri3_wait_for_event_locked (draw=0x1a28288)
at ../../src/mesa/src/loader/loader_dri3_helper.c:457
#5  0x7f450d765568 in loader_dri3_wait_for_sbc
(draw=draw@entry=0x1a28288, target_sbc=47, target_sbc@entry=0,
ust=ust@entry=0x7ffed4e8eca0, msc=msc@entry=0x7ffed4e8eca8,
sbc=sbc@entry=0x7ffed4e8ecb0) at
../../src/mesa/src/loader/loader_dri3_helper.c:534
#6  0x7f450d76560b in loader_dri3_swapbuffer_barrier
(draw=0x1a28288) at
../../src/mesa/src/loader/loader_dri3_helper.c:1930
#7  loader_dri3_drawable_fini (draw=0x1a28288) at
../../src/mesa/src/loader/loader_dri3_helper.c:238
#8  0x7f450d75aaad in dri3_destroy_drawable (base=0x1a28250) at
../../src/mesa/src/glx/dri3_glx.c:349
#9  0x7f450d7537d2 in driReleaseDrawables (gc=gc@entry=0x1542920)
at ../../src/mesa/src/glx/dri_common.c:481
#10 0x7f450d75af0c in dri3_bind_context (context=0x1542920,
old=, draw=41946959, read=41946959) at
../../src/mesa/src/glx/dri3_glx.c:198
#11 0x7f450d746537 in MakeContextCurrent (dpy=0xcc3850,
draw=41946959, read=41946959, gc_user=0x1542920) at
../../src/mesa/src/glx/glxcurrent.c:213
#12 0x7f44fd3056fd in ?? () from
/usr/lib/x86_64-linux-gnu/qt5/plugins/xcbglintegrations/libqxcb-glx-integration.so
#13 0x7f45157d5229 in QOpenGLContext::makeCurrent(QSurface*) ()
from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#14 0x7f451024ea5e in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Quick.so.5
#15 0x7f451024faa5 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Quick.so.5
#16 0x7f45157a5625 in QWindow::event(QEvent*) () from
/usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#17 0x7f45102c78c5 in QQuickWindow::event(QEvent*) () from
/usr/lib/x86_64-linux-gnu/libQt5Quick.so.5
#18 0x7f44d974565b in PlasmaQuick::Dialog::event(QEvent*) () from
/usr/lib/x86_64-linux-gnu/libKF5PlasmaQuick.so.5
#19 0x7f4515f40acc in QApplicationPrivate::notify_helper(QObject*,
QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#20 0x7f4515f48417 in QApplication::notify(QObject*, QEvent*) ()
from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#21 0x7f45152003c8 in QCoreApplication::notifyInternal2(QObject*,
QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#22 0x7f451579a28d in
QGuiApplicationPrivate::processExposeEvent(QWindowSystemInterfacePrivate::ExposeEvent*)
() from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#23 0x7f451579aebd in
QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*)
() from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#24 0x7f45157748fb in
QWindowSystemInterface::sendWindowSystemEvents(QFlags)
() from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#25 0x7f44fec534b6 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5
#26 0x7f45151fe64a in
QEventLoop::exec(QFlags) () from
/usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#27 0x7f4515207854 in QCoreApplication::exec() () from
/usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#28 0x7f45180e81f9 in kdemain () from
/usr/lib/x86_64-linux-gnu/libkdeinit5_kwin_x11.so
#29 0x7f4517d35830 in __libc_start_main (main=0x4006b0, argc=1,
argv=0x7ffed4e8f868, init=, fini=,
rtld_fini=, stack_end=0x7ffed4e8f858) at
../csu/libc-start.c:291
#30 0x004006e9 in _start ()

> So far, only using patch 2/2, i haven't seen any new freezes, but
> looking at the debug output i get a lot of these when alt-tabbing:
>
> INIT: wxh 

Re: [PATCH xserver 1/4] xwayland: Don't create a "fake" crtc for Present

2018-05-08 Thread Roman Gilg
Thanks for looking into this. You are right that the fake CRTCs are
not needed. The reason I introduced them in the past was that with a
change (reset) of the msc counter the client might want to see a
different CRTC as well. But with the persistent window structs the
CRTC stays the same all the time and the msc counter is monotonically
counting for a window so there should be no need to have different
CRTCs for different msc counters.

Tested the patch in a Plasma session with VLC and Skype.

Tested-by: Roman Gilg 
Reviewed-by: Roman Gilg 

On Mon, May 7, 2018 at 11:21 PM, Adam Jackson  wrote:
> We probably don't want a fake crtc to be visible to clients, and we
> definitely don't want to generate events every time we create such a
> fake (which would happen as a side effect from RRCrtcCreate hitting
> RRTellChanged). As it happens we're not actually using that crtc for
> anything because xwayland doesn't store any state on the crtc object,
> so it suffices to use the real crtc for the screen.
>
> Signed-off-by: Adam Jackson 
> ---
>  hw/xwayland/xwayland-present.c | 21 -
>  hw/xwayland/xwayland.h |  1 -
>  2 files changed, 4 insertions(+), 18 deletions(-)
>
> diff --git a/hw/xwayland/xwayland-present.c b/hw/xwayland/xwayland-present.c
> index ae9f47ebae..b5ae80dcf0 100644
> --- a/hw/xwayland/xwayland-present.c
> +++ b/hw/xwayland/xwayland-present.c
> @@ -51,14 +51,10 @@ xwl_present_window_get_priv(WindowPtr window)
>  struct xwl_present_window *xwl_present_window = 
> xwl_present_window_priv(window);
>
>  if (xwl_present_window == NULL) {
> -ScreenPtr screen = window->drawable.pScreen;
> -
>  xwl_present_window = calloc (1, sizeof (struct xwl_present_window));
>  if (!xwl_present_window)
>  return NULL;
>
> -xwl_present_window->crtc_fake = RRCrtcCreate(screen,
> - xwl_present_window);
>  xwl_present_window->window = window;
>  xwl_present_window->msc = 1;
>  xwl_present_window->ust = GetTimeInMicros();
> @@ -131,8 +127,6 @@ xwl_present_cleanup(WindowPtr window)
>  if (xwl_window && xwl_window->present_window == window)
>  xwl_window->present_window = NULL;
>
> -RRCrtcDestroy(xwl_present_window->crtc_fake);
> -
>  if (xwl_present_window->frame_callback) {
>  wl_callback_destroy(xwl_present_window->frame_callback);
>  xwl_present_window->frame_callback = NULL;
> @@ -306,10 +300,13 @@ static RRCrtcPtr
>  xwl_present_get_crtc(WindowPtr present_window)
>  {
>  struct xwl_present_window *xwl_present_window = 
> xwl_present_window_get_priv(present_window);
> +rrScrPrivPtr rr_private;
> +
>  if (xwl_present_window == NULL)
>  return NULL;
>
> -return xwl_present_window->crtc_fake;
> +rr_private = rrGetScrPriv(present_window->drawable.pScreen);
> +return rr_private->crtcs[0];
>  }
>
>  static int
> @@ -342,9 +339,6 @@ xwl_present_queue_vblank(WindowPtr present_window,
>  if (!xwl_window)
>  return BadMatch;
>
> -if (xwl_present_window->crtc_fake != crtc)
> -return BadRequest;
> -
>  if (xwl_window->present_window &&
>  xwl_window->present_window != present_window)
>  return BadMatch;
> @@ -454,13 +448,6 @@ xwl_present_flip(WindowPtr present_window,
>  if (!xwl_window)
>  return FALSE;
>
> -/*
> - * Make sure the client doesn't try to flip to another crtc
> - * than the one created for 'xwl_window'.
> - */
> -if (xwl_present_window->crtc_fake != crtc)
> -return FALSE;
> -
>  present_box = RegionExtents(&present_window->winSize);
>  damage_box = RegionExtents(damage);
>
> diff --git a/hw/xwayland/xwayland.h b/hw/xwayland/xwayland.h
> index ce290d4909..25112e2cb8 100644
> --- a/hw/xwayland/xwayland.h
> +++ b/hw/xwayland/xwayland.h
> @@ -182,7 +182,6 @@ struct xwl_present_window {
>  WindowPtr window;
>  struct xorg_list link;
>
> -RRCrtcPtr crtc_fake;
>  uint64_t msc;
>  uint64_t ust;
>
> --
> 2.17.0
>
> ___
> xorg-devel@lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: https://lists.x.org/mailman/listinfo/xorg-devel
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

  1   2   >