Commit Graph

43 Commits

Author SHA1 Message Date
Michel Dänzer f6f2f203bc present: Drop flip_idler member from present_vblank_rec
It's redundant with the pixmap member of struct xwl_present_event.

Acked-by: Olivier Fourdan <ofourdan@redhat.com>
2021-07-09 16:20:56 +02:00
Michel Dänzer 61cc5d96ed present: Refactor present_vblank_init helper ouf of _vblank_create
Allows embedding into another struct.

Acked-by: Olivier Fourdan <ofourdan@redhat.com>
2021-07-09 16:15:39 +02:00
Michel Dänzer 0c0cbbc7cb present: Remove present_wnmd_info_rec
Doesn't serve any purpose anymore.

Acked-by: Olivier Fourdan <ofourdan@redhat.com>
2021-07-09 16:14:38 +02:00
Michel Dänzer b6419359b6 present: Move present_wnmd.c contents to hw/xwayland/xwayland-present.c
This will allow eliminating indirections and making the Xwayland Present
code more efficient and easier to follow.

While this technically changes the Xorg video driver ABI, I don't know
of any drivers using the dropped present_wnmd_* symbols, and I doubt a
Xorg driver could make use of them as is anyway.

(As a bonus, Xorg no longer links any Xwayland specific Present code)

v2:
* Wrap DestroyWindow before initializing Present, so that
  present_destroy_window runs before xwl_present_cleanup. Avoids crash
  due to present_destroy_window calling xwl_present_* functions when
  xwl_present_window was already freed. (Olivier Fourdan)

Acked-by: Olivier Fourdan <ofourdan@redhat.com>
2021-07-09 16:11:22 +02:00
Michel Dänzer c35a716b02 present: Fold wnmd_init_mode_hooks into wnmd_screen_init
Preparation for moving WNMD code to hw/xwayland. No functional change
intended.

Acked-by: Olivier Fourdan <ofourdan@redhat.com>
2021-07-09 16:11:11 +02:00
Michel Dänzer 10bdd87fe4 present: Move present_wnmd_screen_init to present_wnmd.c
Now all WNMD code is in present_wnmd.c.

Acked-by: Olivier Fourdan <ofourdan@redhat.com>
2021-07-09 16:11:02 +02:00
Michel Dänzer b6d54b0f5d present: Dispatch clear_window_flip via present_screen_priv hook
Eliminates special cases in present_destroy_window.

Acked-by: Olivier Fourdan <ofourdan@redhat.com>
2021-07-09 16:10:54 +02:00
Michel Dänzer 93666ebe37 present: Remove create_event_id hook
Each present_vblank_create caller generates and sets the ID afterwards.

Acked-by: Olivier Fourdan <ofourdan@redhat.com>
2021-07-09 16:10:43 +02:00
Michel Dänzer 44f705a5b6 present: Pass capabilities to present_vblank_create by value
Preparation for moving WNMD code to hw/xwayland. No functional change
intended.

Acked-by: Olivier Fourdan <ofourdan@redhat.com>
2021-07-09 16:10:06 +02:00
Michel Dänzer 62d8c1cc69 present: Include dix-config.h instead of xorg-config.h
This is DIX code.
2020-09-15 11:41:34 +02:00
Michel Dänzer b0b3159abd present: Add present_vblank::exec_msc field
For tracking the MSC when the present can be executed separately from
the target MSC.

Allows removing the requeue field instead, plus more later.

v2:
* Rename wait_msc → exec_msc (Roman Gilg)
* Use exec_msc = target_msc instead of exec_msc++, for clarity.
* Bug fix: Set exec_msc = target_msc also if present_flip returned
  false in present_execute.
v3:
* Set exec_msc = target_msc also if present_wnmd_flip returned
  false in present_wnmd_execute, for consistency.
v4:
* Specifically check for exec_msc == crtc_msc + 1 in
  present_execute_wait/copy, to avoid re-introducing
  https://bugs.freedesktop.org/show_bug.cgi?id=94596 .

Reviewed-by: Roman Gilg <subdiff@gmail.com>
Tested-by: Roman Gilg <subdiff@gmail.com>
2020-08-25 12:20:53 +02:00
Michel Dänzer 4c92dea952 present: Move flip target_msc adjustment out of present_vblank_create
Preparation for different handling between SCMD & WNMD. No functional
change intended.

Reviewed-by: Roman Gilg <subdiff@gmail.com>
Tested-by: Roman Gilg <subdiff@gmail.com>
2020-08-25 12:19:58 +02:00
Roman Gilg bf794bd7bf present: Remove superfluous set abort flip function in window mode
The function is never called from present_screen.c in contrast to the behavior
in screen mode.

In present_wnmd.c we can simply remove the function which does an unnecessary
check of the property before setting it and directly set the property at the
two locations the function was called previously.

Signed-off-by: Roman Gilg <subdiff@gmail.com>
2020-07-22 11:10:17 +02:00
Roman Gilg 4d89ba0058 present: Unfold and annotate the target-msc getter
Unfold and extensively annotate the target-msc adjustment function, to make
it easier to understand what's happening and why.

Signed-off-by: Roman Gilg <subdiff@gmail.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2020-02-18 16:30:50 +01:00
Roman Gilg 99e55f1b95 present: Adjust timings with value arguments
We can use value arguments instead of pointers when adjusting the timings
by returning the adjusted value. This improves the readability.

Signed-off-by: Roman Gilg <subdiff@gmail.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2020-02-18 16:30:32 +01:00
Lionel Landwerlin a425eee6dc present: fix compile warning with debug traces
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
2018-11-29 16:54:45 +00: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 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
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
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
Chris Wilson 180b09912c present: When cancelling a pending synchronous flip, requeue it
The vblank event request for a synchronous flip is scheduled for the
vblank before the target flip msc (so that the flip itself appears at
the right frame). If we cancel that flip and so wish to schedule a
copy instead, that copy needs to be postponed by a frame in order for it
be performed at the requested time.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2015-12-07 14:25:43 -05:00
Chris Wilson b2d55338f6 present: Requery pending flips with the right sync_flip mode
When verifying whether a pending flip is still valid, we need to pass
down the orignal sync_flip mode (e.g. if the driver only supports sync
flips, verifying a async flip will falsely fail).

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2015-12-07 14:25:42 -05:00
Adam Jackson c732bb2799 present: static cleanup
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2015-07-08 16:40:57 -04:00
Keith Packard 627bce8089 present: Make window MSC offset 0 initially
The MSC offset used by a window is adjusted as the window moves
between screens, and between shown/unshown. The value shouldn't
matter, but it's helpful for debugging to have window MSC values be
the same as the CRTC MSC at first.

This patch introduces a unique CRTC value so that Present can detect
the first time a window is a PresentPixmap destination and set the MSC
offset to zero, rather than using the fake MSC value as the previous
window MSC.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2014-07-31 00:03:53 -07:00
Keith Packard e6f5d9d7b7 present: Queue flips for later execution
When a flip (or unflip) is pending and a flip request comes in, leave
it queued until the pending flip completes and then execute it.

This fixes a bug where an application submitting back-to-back
present_pixmap requests for sequential frames would alternate between
flipping and copying as the pending flip would cause the new
present_pixmap request to not use a flip.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Tested-by: Frank Binns <frank.binns@imgtec.com>
2014-06-04 22:03:35 -07:00
Keith Packard 04e138846e present: Leave vblank on window list until flip complete
If the window is destroyed, then we've got cleanup work to do, even if
the vblank has already been executed -- we need to clear the window
pointer so that we don't try to deliver events to it.

Leaving it on the window list meant that when walking that list, we
need to know whether the vblank is waiting to be executed or waiting
for the flip to complete, so a new 'queued' flag was added to the
vblank to distinguish between the two states.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2013-12-05 09:48:36 -08:00
Keith Packard 8bdd2ccc77 present: Block for wait_fence in present_execute
Pend presentation until wait_fence is also triggered by having the
SyncFence trigger invoke present_execute once triggered.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2013-11-20 13:12:30 -08:00
Keith Packard e5a188cb91 present: Signal destroyed flip window with vblank->window == NULL
This eliminates dereferencing freed window pointers when there is a
flip for that window in progress. The flip will complete, and then
immediately get undone (as we can't stop an in-progress flip).

Remove the vblank->window_destroyed field as we can signal this with
vblank->window == NULL instead.

Change check to vblank->window == NULL in:

	present_flip_notify

Add check for vblank->window == NULL in:
	present_vblank_notify
	present_execute

present_flip_notify was also using vblank->window->drawable.pScreen,
so stop doing that and use vblank->screen instead.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2013-11-20 13:12:27 -08:00
Keith Packard 5c5c1b7798 present: Add Present extension
Provides both a software implementation using timers and driver hooks
to base everything on vblank intervals.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2013-10-31 16:59:18 -07:00