Commit Graph

227 Commits

Author SHA1 Message Date
emersion 68362b37a8
backend/drm: fix frame scheduling on secondary GPUs
There was a missing copy_drm_surface_mgpu call in drm_connector_schedule_frame
so we asked for a pageflip with an unknown BO, resulting in ENOENT.

Additionally, this commit makes schedule_frame return a bool indicating
failures. This allows schedule_frame_handle_idle_timer to only set
frame_pending to true if a frame has been successfully scheduled. Thus, if a
pageflip fails, rendering won't be blocked forever anymore.

In case a pageflip is already pending, true is returned because a frame has
already been scheduled and will be sent sometime soon.
2018-10-29 20:38:57 +01:00
sghctoma fa587b8ea9 Increase _POSIX_C_SOURCE to 200112L
CLOCK_MONOTONIC appeared in IEEE Std. 1003.1-200x, it was not part of
POSIX.1b (the 1993 version), and FreeBSD treats it accordingly.
2018-10-17 08:33:19 +02:00
emersion b66041a9e5 backend/drm: don't reset conn->pageflip_pending in drm_connector_cleanup
If a pageflip is pending before cleanup, it's still pending after. This
is used line 1177: drm_connector_cleanup is called and
conn->pageflip_pending is checked afterwards.

Fixes #1297
2018-10-09 14:54:33 +02:00
Drew DeVault 8488ed2997
Merge pull request #1298 from emersion/output-dangling-idle-frame
output: remove idle_frame event source when destroying output
2018-10-09 13:41:04 +02:00
Rouven Czerwinski 77478ac302 backend/drm: set drmEventContext version to 2
As per [1] set drmEventContext version to 2, since wlroots does not use the
page_flip_handler2.

[1]: https://s-opensource.org/2017/04/12/libdrm-event-handling-youre-probably-wrong/
2018-10-09 12:34:01 +02:00
emersion 46b1ba386f output: remove idle_frame event source when destroying output
This prevents the idle event to be activated on a destroyed
output.

This also makes the backend responsible for free-ing modes, as it
is the one allocating them and adding them to the list. Note that
the DRM backend (the only one using modes) already frees them.
2018-10-09 10:55:03 +02:00
Scott Anderson 885586a831
Merge pull request #1280 from emersion/drm-link-status
backend/drm: add support for the link-status property
2018-10-08 21:01:30 +02:00
emersion 37de179013 backend/drm: fix zero-length VLAs 2018-10-07 13:04:52 +02:00
emersion 776008da69 backend/drm: properly handle GPUs without CRTCs 2018-10-07 12:59:00 +02:00
emersion ba91422747 output: don't trigger a frame immediately in schedule_frame
This desynchronizes our rendering loop with the vblank cycle.

In case a compositor doesn't swap buffers but schedules a frame,
emitting a frame event immediately enters a busy-loop.

Instead, ask the backend to send a frame when appropriate. On
Wayland we can just register a frame callback on our surface. On
DRM we can do a no-op pageflip.

Fixes #617
Fixes swaywm/sway#2748
2018-10-05 16:18:37 +02:00
emersion eac7c2ad2f output: add presentation refresh prediction 2018-10-04 22:00:24 +02:00
emersion 54e1287f30 backend: add get_present_clock 2018-10-04 21:58:17 +02:00
emersion 78389fe722 output: add present event 2018-10-04 21:56:38 +02:00
emersion f5a147b739 backend/drm: add support for the link-status property 2018-10-04 21:54:27 +02:00
emersion e88db9a3fb backend/drm: reset gamma table on VT switch 2018-10-03 10:53:35 +02:00
emersion 2beb68007e output: make gamma size a size_t and gamma table const 2018-10-03 10:36:33 +02:00
emersion 79dd9ba151 backend/drm: don't free connector immediately
When a pageflip is pending, we'll get a DRM event for the connector
in the future. We don't want to free the connector immediately
otherwise we'll use-after-free in the pageflip handler.

This commit adds a new state, "DISAPPEARED". This asks the pageflip
handler to destroy the output after it's done pageflipping.
2018-09-28 10:00:40 +02:00
emersion 139a905924 backend/drm: add assertions 2018-09-18 11:06:01 +02:00
emersion f8a50e4fe7 backend/drm: steal CRTCs from disabled outputs
This commit allows outputs that need a CRTC to steal it from
user-disabled outputs. Note that in the case there are enough
CRTCs, disabled outputs don't loose it (so there's no modeset
and plane initialization needed after DPMS). CRTC allocation
still prefers to keep the old configuration, even if that means
allocating an extra CRTC to a disabled output.

CRTC reallocation now happen when enabling/disabling an output as
well as when trying to modeset. When enabling an output without a
CRTC, we realloc to try to steal a CRTC from a disabled output
(that doesn't really need the CRTC). When disabling an output, we
try to give our CRTC to an output that needs one. Modesetting is
similar to enabling.

A new DRM connector field has been added: `desired_enabled`.
Outputs without CRTCs get automatically disabled. This field keeps
track of the state desired by the user, allowing to automatically
re-enable outputs when a CRTC becomes free.

This required some changes to the allocation algorithm. Previously,
the algorithm tried to keep the previous configuration even if a
new configuration with a better score was possible (it only changed
configuration when the old one didn't work anymore). This is now
changed and the old configuration (still preferred) is only
retained without considering new possibilities when it's perfect
(all outputs have CRTCs).

User-disabled outputs now have `possible_crtcs` set to 0, meaning
they can only retain a previous CRTC (not acquire a new one). The
allocation algorithm has been updated to do not bump the score
when assigning a CRTC to a disabled output.
2018-09-15 08:37:33 +02:00
emersion cb293f09e7 output: make wlr_output_enable return a bool 2018-09-14 18:18:07 +02:00
emersion 1fcecd68df backend/drm: de-allocate unused CRTCs
They can be re-used by another output after a subsequent hotplug.
2018-09-10 18:46:30 +02:00
emersion 8a6bdc193d backend/drm: damage outputs when switching CRTCs 2018-09-04 23:10:37 +02:00
emersion 017cfb0b86 backend/drm: log when de-allocating CRTC 2018-09-04 19:44:44 +02:00
emersion b877daded1 backend/drm: better hotplug handling
This commit handles better situations in which the number of
connected outputs is greater than the number of available CRTCs.
It'll enable as many outputs as possible, and transfer CRTCs to
outputs that need one on unplug.

This changes CRTC and plane reallocation to happen after scanning
DRM connectors instead of on modeset.

This cleanups CRTCs and planes on unplug to allow them to be
re-used for other outputs.

On modeset, if an output doesn't have a CRTC, the desired mode is
saved and used later when the output gains a CRTC.

Future work includes giving priority to enabled outputs over
disabled ones for CRTC allocation. This requires the compositor to
know about all outputs (even outputs without CRTCs) to properly
modeset outputs enabled in the compositor config file and disable
outputs disabled in the config file.
2018-09-04 15:09:07 +02:00
emersion 95d05acda5 backend/drm: fix invalid VLA size in scan_drm_connectors
I failed to see this issue with Valgrind because of the +1.
2018-09-02 10:11:23 +02:00
emersion ef88df2142 backend/drm: emit new_output after scanning connectors
This prevents receiving modesetting requests from the compositor
while we don't have the whole picture (ie. while we haven't yet
scanned all connectors).

This also makes connectors without CRTCs disabled (they can't be
enabled yet even if some CRTCs are free'd -- this is future work).
2018-09-02 01:03:20 +02:00
emersion e84f01168d backend/drm: allow disabling outputs in NEEDS_MODESET state
This correctly frees CRTCs when disabling outputs without setting
a mode.
2018-09-01 23:43:16 +02:00
Scott Anderson 2d8f53affd Check for DRM prime
This will indicate the user properly when multi-GPU is not supported by
their GPU driver.
2018-08-05 18:25:25 +12:00
Scott Anderson 4bee710c30 Fix hardware cursor on secondary GPU
Create rendering resources on parent GPU, so that we can sample the
passed in texture properly. The cursor buffer needs to remain on the
same GPU.
2018-08-04 15:08:28 +12:00
emersion 364afced3e backend/drm: remove unnecessary casts 2018-08-02 23:33:59 +01:00
emersion 2ebecb6727 backend/drm: allow to pass empty gamma ramp to reset it 2018-08-02 23:33:59 +01:00
emersion a149c2370a Implement wlr-gamma-control-unstable-v1 2018-08-02 23:33:04 +01:00
emersion 7cbef15206
util: add wlr_ prefix to log symbols 2018-07-09 22:49:54 +01:00
Drew DeVault be54278207
Merge pull request #1095 from agx/output-add-mode
Allow to add additional modes to outputs
2018-07-07 08:58:17 -07:00
Guido Günther 8d72090afe drm: Allow to add additional modes
This allows to add additional modes to the list of available video modes
using VESA Coordinated Video Timing information.

Closes #1080
2018-07-07 14:51:39 +02:00
emersion 2b9cbaddf3
screencopy: add support for frame flags 2018-06-30 22:18:03 +01:00
Dominique Martinet f0d455f088 drm backend: overflow fixes
These operations are done in 32-bit arithmetics before being casted to 64-bit,
thus can overflow before the cast.
Casting early fixes the issue.

Found through static analysis
2018-06-30 11:21:22 +09:00
emersion 21928cbe61
Merge branch 'master' into screencontent 2018-05-31 12:33:27 +01:00
emersion bd430b8620
backend/drm: support multi-planar DMA-BUFs when exporting 2018-05-29 18:47:17 +01:00
emersion 9e26808c28
output, backend/drm: add wlr_output_export_dmabuf 2018-05-29 18:45:45 +01:00
emersion 79683ee497
backend/drm: better connector cleanup, add more logs 2018-05-27 13:21:41 +01:00
Markus Ongyerth 6a46fcc6f2 recalculate cursor projection matrix on set_cursor
Updates the projection matrix for the cursor plane in the DRM backend,
when the cursor is set, so new cursor are uploaded with the correct
transformation.
2018-05-16 15:44:41 +02:00
emersion 13098a18ea
Fix hardware cursors scale & transform 2018-05-09 19:58:18 +01:00
emersion caf9f9022c
Merge pull request #936 from emersion/full-hardware-cursors
output: always use hardware cursors if available
2018-05-04 19:00:45 +01:00
Guido Günther 1637053ef8 drm: only disable atomic modesetting when WLR_DRM_NO_ATOMIC == 1
Don't allow any value of the env var to disable atomic mode setting.
2018-05-03 15:37:37 +02:00
emersion 225d182765
output: always use hardware cursors if available
This changes the `wlr_output_impl.set_cursor` function to take a
`wlr_texture` instead of a byte buffer. This simplifies the
DRM and Wayland backends since they were creating textures from
the byte buffer anyway.

With this commit, performance should be improved when moving the
cursor since outputs don't need to be re-rendered anymore.
2018-05-01 21:38:04 +01:00
emersion 71ca45e2c0
Make sure we don't use others' prefixes 2018-04-25 23:24:58 +01:00
emersion b0d99f5c67
Remove wlr_ prefix from local symbols 2018-04-25 23:00:46 +01:00
emersion 94fa6c88f4
output: don't emit the mode event if it hasn't changed
This also fixes #535.
2018-04-18 00:15:25 +01:00
emersion a2391a6047
Fix cursor transform on DRM backend 2018-03-31 20:55:31 -04:00