Commit Graph

98 Commits

Author SHA1 Message Date
Adam Jackson
b9f415cbad present: Fix swapping of PresentCompleteNotify events
The code would fall through to the PresentIdleNotify case, and nothing
good would come of it.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2018-05-08 12:15:29 -04:00
Roman Gilg
22285a6f1c present: fix msc offset calculation in window mode
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 <subdiff@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-05-02 14:55:48 -04:00
Thierry Reding
88c7b8bf4b meson: Distribute more SDK headers
Install missing headers to the SDK directory to allow external modules
to properly build against the SDK. After this commit, the list of files
installed in the SDK include directory is the same as the list of files
installed by the autotools-based build.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
2018-04-02 13:42:08 -04:00
Roman Gilg
902429f077 present: Add exported init function of window flip mode
Allow drivers now to initialize window flip mode.

Signed-off-by: Roman Gilg <subdiff@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-03-28 14:36:44 -04:00
Roman Gilg
a337949f99 present: Add cleanups for window flip mode
Make sure that vblanks and windows get cleaned up correctly
in window flip mode.

Signed-off-by: Roman Gilg <subdiff@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-03-28 14:36:42 -04:00
Roman Gilg
66a5c0bccb present: In window flip mode report damage on flip to driver
Calculate damage before trying to flip and report it to the driver.
This allows drivers to optimize their rendering.

Signed-off-by: Roman Gilg <subdiff@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-03-28 14:36:39 -04:00
Roman Gilg
029608dd80 present: Add window flip mode
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 <subdiff@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-03-28 14:36:36 -04:00
Roman Gilg
8d370fcdca present: Add driver facing window flip mode hooks
To enable special functionality of window flips introduce for window flips
a separate set of driver facing function hooks.

Signed-off-by: Roman Gilg <subdiff@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-03-28 14:36:34 -04:00
Roman Gilg
7b071b4e44 present: Adapt flip mode API hooks for window flip mode
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 <subdiff@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-03-28 14:36:33 -04:00
Roman Gilg
92b91b8cf3 present: Add flip_idler vblank property
Introduce vblank property for flip modes, that demand explicite
allowance by the driver for vblanks to become idle.

Signed-off-by: Roman Gilg <subdiff@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-03-28 14:36:31 -04:00
Roman Gilg
84e47f3fe6 present: Add present_window_priv properties for window flip mode
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 <subdiff@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-03-28 14:36:30 -04:00
Roman Gilg
3aaaac0be5 present: Refactor present_screen_init
To initialize easily different flip modes, refactor
'present_screen_init'.

Signed-off-by: Roman Gilg <subdiff@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-03-28 14:36:28 -04:00
Roman Gilg
6d813bbd5e present: Add more hooks to internal flip mode API
Add hooks to query caps, get crtcs, abort vblanks and destroy
a flip.

Signed-off-by: Roman Gilg <subdiff@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-03-28 14:36:27 -04:00
Roman Gilg
6a338b5959 present: Move timings adjustment in common part of flip mode API
To reduce future code duplication refactor timings adjustment out
as a separate function.

Signed-off-by: Roman Gilg <subdiff@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-03-28 14:36:25 -04:00
Roman Gilg
84112a1d0b present: Add flip mode API hook for present_can_window_flip
Flip modes can now have different implementations of
present_can_window_flip.

Signed-off-by: Roman Gilg <subdiff@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-03-28 14:36:24 -04:00
Roman Gilg
1db7cf0429 present: Add flip mode API hook for present_pixmap
Make present_pixmap a common function callable by any
flip mode.

Signed-off-by: Roman Gilg <subdiff@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-03-28 14:36:22 -04:00
Roman Gilg
679ffbf5f3 present: Refactor execute in separate file
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 <subdiff@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-03-28 14:36:20 -04:00
Roman Gilg
1e7d8902bf present: Add flip mode API hooks for several functions
Add 'queue_vblank', 'flush' and 're_execute' hooks, that
are supposed to be shared with other flip modes.

Signed-off-by: Roman Gilg <subdiff@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-03-28 14:36:18 -04:00
Roman Gilg
5365ece70a present: Move vblank functionality in seperate file
With the new internal flip mode API move vblank creation
and so on into a seperate file, such that it can be shared
between flip modes.

Signed-off-by: Roman Gilg <subdiff@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-03-28 14:36:16 -04:00
Roman Gilg
c5c50c6db1 present: Preliminary internal flip mode API
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 <subdiff@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-03-28 14:36:14 -04:00
Roman Gilg
dda7efec36 present: Move screen flip functionality in separate file
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 <subdiff@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-03-28 14:36:12 -04:00
Emil Velikov
6a5d51e082 present: cap the version returned to the client
As per the protocol, the server should not return version greater than
the one supported by the client.

Add a spec quote and tweak the numbers accordingly.

Fixes: 5c5c1b7798 ("present: Add Present extension")
Cc: Thierry Reding <treding@nvidia.com>
Cc: Daniel Stone <daniels@collabora.com>
Cc: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2018-03-19 15:46:41 -04:00
Louis-Francis Ratté-Boulianne
cef12efc15 glamor: Implement GetSupportedModifiers
Implement function added in DRI3 v1.1.

A newest version of libepoxy (>= 1.4.4) is required as earlier
versions use a problematic version of Khronos
EXT_image_dma_buf_import_modifiers spec.

v4: Only send scanout-supported modifiers if flipping is possible
v5: Fix memory corruption in XWayland (uninitialized pointer)

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-03-05 13:27:55 -05:00
Louis-Francis Ratté-Boulianne
e2ef3b44fa present: Send PresentCompleteModeSuboptimalCopy appropriately
Add 'check_flip2' hook for driver to let know the core
about why flipping is not possible ('reason').
If it is because of unsupported buffer format/modifier,
a PresentCompleteNotify event is sent to the client with
the PresentCompleteModeSuboptimalCopy mode.

v2: Check for PresentOptionSuboptimal and check driver version
    before using 'check_flip2'.

v3: Only require one of 'check_flip' or 'check_flip2' to be
    implemented by the driver.
    Refactor reasons list to enum

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-03-05 13:27:32 -05:00
Michel Dänzer
76732f498f Revert "present: Only send PresentCompleteNotify events to the presenting client"
This reverts commit 5c00e69363.

It broke the Gallium nine state tracker, which makes PresentPixmap
requests on one display connection and processes the corresponding
events on another one.

The issue that motivated this change is prevented on the client side by
https://cgit.freedesktop.org/mesa/mesa/commit/?id=7b0e8264dd21ae05521d08d41fecd84139401fef

Bugzilla: https://bugs.freedesktop.org/104678
2018-01-24 11:40:50 +01:00
Michel Dänzer
559954aaa8 present: Only send PresentCompleteNotify events to the presenting client
We were sending the events to all clients listening for them on the
window. But clients can get confused by events from another client, and
I can't imagine any case where receiving events from other clients would
be required.

v2:
* Also restrict events sent to additional windows to the presenting
  client
* Don't shorten line lengths

Reviewed-by: Keith Packard <keithp@keithp.com>
2017-11-23 10:28:06 +01:00
Louis-Francis Ratté-Boulianne
c2f2b25ab5 present: Check the whole exec queue on event
Later events are sometimes added in front of the queue (e.g.
if page flipping fails) so we need to check the whole queue
on event.

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2017-10-04 15:22:04 -04:00
Eric Anholt
e0f872207a sync: Convert from "CARD64" to int64_t.
The extension was using the name CARD64 to represent 64-bit values,
with a #define from CARD64 to XSyncValue, a struct with a pair of
32-bit values representing a signed 64-bit value.  This interfered
with protocol headers using CARD64 to try to actually store a
uint64_t.  Now that stdint.h exists, let's just use that here,
instead.

v2: Fix alarm delta changes.
v3: Do the potentially overflowing math as uint and convert to int
    afterward, out of C spec paranoia.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2017-09-20 13:19:27 -04:00
Eric Anholt
1549e30372 Add a Meson build system alongside autotools.
This is a work in progress that builds Xvfb, Xephyr, Xwayland, Xnest,
and Xdmx so far.  The outline of Xquartz/Xwin support is in tree, but
hasn't been built yet.  The unit tests are also not done.

The intent is to build this as a complete replacement for the
autotools system, then eventually replace autotools.  meson is faster
to generate the build, faster to run the bulid, shorter to write the
build files in, and less error-prone than autotools.

v2: Fix indentation nits, move version declaration to project(), use
    existing meson_options for version-config.h's vendor name/web.

Signed-off-by: Eric Anholt <eric@anholt.net>
Acked-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-04-26 15:25:27 -07:00
Adam Jackson
dc7ceda90f dispatch: Mark swapped dispatch as _X_COLD
This touches everything that ends up in the Xorg binary; the big missing
part is GLX since that's all generated code. Cuts about 14k from the
binary on amd64.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2017-03-01 10:16:20 -05:00
Michel Dänzer
542d9f6807 present: Allow flipping with PRIME slave outputs
Works fine now.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
2017-02-08 12:08:56 -05:00
Qiang Yu
bb9128fdc8 present: disable page flip only when a slave crtc is active
This prevents the tearing of moving window in a composite WM
desktop when output slave is attached but none of its crtc is
really active.

Signed-off-by: Qiang Yu <Qiang.Yu@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2017-02-01 17:29:34 +09:00
Michel Dänzer
e473b2bc01 present: Only call present_flip_notify if vblank->queued == FALSE
We are no longer using the present_flip_queue list only for presents
which have already been submitted to the driver for page flipping, but
also for those which we are queueing up to be flipped later, marked
with vblank->queued == TRUE. We were incorrectly calling
present_flip_notify for such entries, failing the assertion in
present_flip_notify (or presumably resulting in other undesirable
behaviour with assertions disabled).

Reproduction recipe: Run the JavaFX test case referenced by
https://bugs.freedesktop.org/show_bug.cgi?id=98831#c6 and alt-tab out
of it while it's fullscreen. May take a few attempts to hit the
assertion failure.

Fixes: bab0f450a7 ("present: Fix presentation of flips out of order")
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98854
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-01-10 12:38:50 +09:00
Olivier Fourdan
de5291c04b present: Free the fake_present OsTimerPtr
Plug a leak in present_fake_queue_vblank() where the OsTimer would not
be freed.

 492,608 (482,816 direct, 9,792 indirect) bytes in 15,088 blocks
are definitely lost in loss record 3,954 of 3,954
    at 0x4C2ABDE: malloc (in vgpreload_memcheck-amd64-linux.so)
    by 0x586B19: TimerSet (WaitFor.c:433)
    by 0x4F1AA9: present_fake_queue_vblank (present_fake.c:108)
    by 0x4F15E0: present_pixmap (present.c:954)
    by 0x4F23B4: proc_present_pixmap (present_request.c:138)
    by 0x552BCE: Dispatch (dispatch.c:430)
    by 0x556C22: dix_main (main.c:300)
    by 0x6F0D290: (below main) (in /usr/lib/libc-2.24.so)

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97065
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2016-08-15 15:16:48 -04:00
Michel Dänzer
d21b53673b present: Call set_abort_flip / restore_screen_pixmap in clear_window_flip
We were asserting that these were called before from other places, but
that isn't always the case, e.g. during server shutdown.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=96951
Reported-and-Tested-by: Tod Jackson <tod.jackson@gmail.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
2016-08-15 15:14:53 -04:00
Michel Dänzer
9f04fa3bab present: Make present_restore_screen_pixmap handle screen->root == NULL
Easier than dealing with it in all paths that can end up here during
server shutdown.

Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-08-15 15:14:43 -04:00
Michel Dänzer
c833c0866f present: Handle event mask updates as specified v2
From the Present extension specification:

 An event context is associated with a specific window; using
 an existing event context with a different window generates
 a Match error.

 If eventContext specifies an existing event context, then if
 eventMask is empty, PresentSelectInput deletes the specified
 context, otherwise the specified event context is changed to
 select a different set of events.

 If eventContext is an unused XID, then if eventMask is empty
 no operation is performed. Otherwise, a new event context is
 created selecting the specified events.

Without this change, there's no way for a client to explicitly change
or destroy an existing event mask entry. Trying to do so as specified
above would just result in a protocol error.

v2: (Keith Packard)
* Use dixLookupResourceByType instead of walking window_priv->events
* Return BadMatch if the existing event context is associated with a
  different window or client
* Call LEGAL_NEW_RESOURCE again when creating a new event context
* Drop invalid "leak fix"

Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2016-07-30 15:43:54 -07:00
Michel Dänzer
0924ac014d present: Only call restore_screen_pixmap once from set_abort_flip
present_restore_screen_pixmap's work doesn't need to be done several
times for the same pending flip.

Fixes a crash if the X server quits while a flip is pending, in which
case present_set_abort_flip may be called several times, including when
screen->root is already cleared to NULL.

Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-07-28 10:12:44 +09:00
Hans de Goede
5c7af02b10 xrandrprovider: Do not use separate lists for unbound / source / offload slaves
A single provider can be both a offload and source slave at the same time,
the use of seperate lists breaks in this case e.g. :

xrandr --listproviders
Providers: number : 2
Provider 0: id: 0x7b cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 3 outputs: 2 associated providers: 0 name:modesetting
Provider 1: id: 0x46 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 2 outputs: 5 associated providers: 0 name:modesetting

xrandr --setprovideroutputsource 1 0x7b
xrandr --listproviders
Providers: number : 2
Provider 0: id: 0x7b cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 3 outputs: 2 associated providers: 1 name:modesetting
Provider 1: id: 0x46 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 2 outputs: 5 associated providers: 1 name:modesetting

xrandr --setprovideroffloadsink 1 0x7b
xrandr --listproviders
Providers: number : 3
Provider 0: id: 0x7b cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 3 outputs: 2 associated providers: 2 name:modesetting
Provider 1: id: 0x46 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 2 outputs: 5 associated providers: 2 name:modesetting
Provider 2: id: 0x46 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 2 outputs: 5 associated providers: 2 name:modesetting

Not good. The problem is that the provider with id 0x46 now is on both
the output_slave_list and the offload_slave_list of the master screen.

This commit fixes this by unifying all 3 lists into a single slaves list.

Note that this does change the struct _Screen definition, so this is an ABI
break. I do not expect any of the drivers to actually use the removed / changed
fields so a recompile should suffice.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2016-06-17 11:35:58 +02:00
Chris Wilson
bab0f450a7 present: Fix presentation of flips out of order
The flip queue currently only holds events submitted to the driver for
flipping, awaiting the completion notifier. It is short. We therefore
can speed up interrupt processing by keeping the small number of events
ready to be flipped on the end of the flip queue. By appending the
events to the flip_queue in the order that they become ready, we also
resolve one issue causing Present to display frames out of order.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-and-tested-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2016-06-17 11:21:30 +02:00
Chris Wilson
fbe660b765 present: Improve scaling of vblank handler
With large numbers of queued vblank, the list iteration on every
interupt dominates processing time. If we reorder the list to be in
ascending event order, then not only is also likely to be in order for
notification queries (i.e. the notification will be near the start of
the list), we can also stop iterating when past the target event_id.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-and-tested-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2016-06-17 11:21:30 +02:00
Michel Dänzer
3b385105b2 present: Only requeue for next MSC after flip failure
This code was added to deal with the driver present hook failing, in
which case we need to wait for the next MSC before executing the
presentation.

However, it could also take effect in cases where the driver incorrectly
thinks the current MSC matches the target one (e.g. due to the kernel
interface only supporting 32-bit MSC values), in which case it could
result in the presentation getting requeued over and over.

To prevent such issues, check specifically for the target MSC
immediately following the current MSC.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94596
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
2016-03-24 15:47:33 -04:00
Dave Airlie
47bc7fcaa5 present: fail flipping if we have any slave outputs
Due to the way present currently works, we don't ever check with the
secondary adapters if we can flip at all.

We shouldn't flip if the secondary adapters are attached to the pixmap
currently, however using the current check_flip callback isn't possible
as it passes the Window to the driver (something we shouldn't be doing),
so the slave driver can never get it's own screen ptr back.

For now to fix the problem just block flips if we have any slaves
configured. We can fix the ABI up later, but this fix can be backported
to stable.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
2016-03-11 11:38:37 -05:00
Michel Dänzer
1bee4e254c present: Call present_restore_screen_pixmap from present_set_abort_flip
After present_set_abort_flip, the screen pixmap will be used for all
screen drawing, so we need to restore the current flip pixmap contents
to the screen pixmap here as well.

Improves flashing / stutter e.g. when something like a popup menu appears
on top of a flipping fullscreen window or when switching out of
fullscreen.

Note that this means present_set_abort_flip now relies on screen->root
being non-NULL, but that's already the case in other present code.

Reviewed-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-03-01 11:59:51 +09:00
Michel Dänzer
4611e902c2 present: Factor code for restoring screen pixmap out of present_unflip (v2)
The following fix will use the refactored function.

The logic in the refactored function is slightly simplified, exploiting
the fact that this function is only ever called with a valid flip
pixmap.

v2: Assert that flip_pixmap is non-NULL instead of testing and bailing
    on NULL, preserve test for flip_window being non-NULL before calling
    present_set_tree_pixmap for it (Keith Packard)

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> (v1)
Reviewed-by: Keith Packard <keithp@keithp.com>
2016-03-01 11:59:51 +09:00
Michel Dänzer
72328e5eb9 present: Only update screen pixmap from flip pixmap once per unflip
present_unflip may be called several times from present_check_flip_window
during the same unflip. We can only copy to the screen pixmap the first
time, otherwise we may scribble over other windows. The flip pixmap
contents don't get updated after the first time anyway.

Fixes at least the following problems, which were introduced by commit
806470b9 ("present: Copy unflip contents back to the Screen Pixmap"):

On xfwm4 without compositing, run glxgears and put its window into
fullscreen mode to start flipping. While in fullscreen, open the xfwm4
window menu by pressing Alt-Space. The window menu was invisible most
of the time because it was getting scribbled over by a repeated unflip
copy.

When switching a flipping window out of fullscreen, a repeated unflip
copy could leave artifacts of the flip pixmap on the desktop.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94325

Reviewed-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-03-01 11:59:51 +09:00
Michel Dänzer
b4ac7b142f present: Only requeue if target MSC is not reached after an unflip
While present_pixmap decrements target_msc by 1 for present_queue_vblank,
it leaves the original vblank->target_msc intact. So incrementing the
latter for requeueing resulted in the requeued presentation being
executed too late.

Also, no need to requeue if the target MSC is already reached.

This further reduces stutter when a popup menu appears on top of a
flipping fullscreen window.

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
2016-02-25 10:18:04 -05:00
Michel Dänzer
e7a35b9e16 present: Requeue if flip driver hook fails and target MSC not reached
For flipping, we wait for the MSC before the target MSC and then call
the driver flip hook. If the latter fails, we have to wait for the
target MSC before falling back to a copy, or else it's executed too
early.

Fixes glxgears running at unbounded framerate (not synchronized to the
refresh rate) in fullscreen if the driver flip hook fails.

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
2016-02-25 10:18:00 -05:00
Michel Dänzer
1a9f8c4623 present: Move msc_is_(equal_or_)after to the top of present.c
To make them usable from any other function in the file. No functional
change.

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
2016-02-25 10:17:47 -05:00
Michel Dänzer
25eca80265 present: Handle wraparound when comparing MSC values
When a window moves from one CRTC to another, present_window_to_crtc_msc
updates window_priv->msc_offset according to the delta between the
current MSC values of the old and new CRTC:

            window_priv->msc_offset += new_msc - old_msc;

window_priv->msc_offset is initially 0, so if new_msc < old_msc,
window_priv->msc_offset wraps around and becomes a large number. If the
window_msc parameter passed in is small (in particular if it's 0, such as
is the case when the client just wants to know the current window MSC
value), the returned CRTC MSC value may still be a large number. In that
case, the existing MSC comparisons in pixmap_present weren't working as
intended, resulting in scheduling a wait far into the future when the
target MSC had actually already passed. This would result in the client
(e.g. the Chromium browser) hanging when moving its window between CRTCs.

In order to fix this, introduce msc_is_(equal_or_)after helper functions
which take the wraparound into account for comparing two MSC values.

Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Martin Peres <martin.peres@linux.intel.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2016-01-19 18:03:26 -08:00