aboutsummaryrefslogtreecommitdiff
path: root/backend/drm/drm.c
AgeCommit message (Collapse)Author
2020-06-19output: rename impl->rollback to rollback_renderSimon Ser
The output backend API is now mostly state-less thanks to the atomic hooks (commit and test). There is one exception though: attach_render. This function makes the rendering context current. However sometimes the compositor might decide not to render after attach_render (e.g. when there's nothing new to render to the back buffer). Thus wlr_output_rollback has been introduced to revert the pending state. Because the output backend API is mostly state-less, the only thing wlr_output_impl.rollback needs to do is revert the current rendering context. Rename the function to rollback_render to make this clear. Add a check in the common wlr_output code to only call rollback_render when attach_buffer has been previously called. On the long term, we'll be able to remove attach_render and rollback_render together.
2020-06-08backend/drm: fix stack overflow in dealloc_crtcSimon Ser
Call drm_crtc_commit directly instead of calling drm_connector_set_mode. This restores the previous behaviour where conn_enable was called [1]. [1]: https://github.com/swaywm/wlroots/blob/0c7c562482575cacaecadcd7913ef25aeb21711f/backend/drm/drm.c#L1093 Closes: https://github.com/swaywm/wlroots/issues/2253
2020-06-03backend/drm: fix black screens when enabling outputSimon Ser
This patch fixes this failure: 01:57:16.642 [ERROR] [backend/drm/drm.c:360] Failed to page-flip output 'eDP-1': a page-flip is already pending 01:57:16.684 [ERROR] [backend/drm/drm.c:360] Failed to page-flip output 'eDP-1': a page-flip is already pending 01:57:16.684 [ERROR] [backend/drm/drm.c:732] Failed to initialize renderer on connector 'eDP-1': initial page-flip failed 01:57:16.684 [ERROR] [backend/drm/drm.c:805] Failed to initialize renderer for plane 01:57:16.684 [sway/config/output.c:423] Failed to commit output eDP-1 References: https://github.com/swaywm/sway/issues/5101
2020-06-01backend/drm: always perform a CRTC commit in drm_connector_commitSimon Ser
When the mode, status or buffer hasn't changed, drm_connector_commit was a no-op. Because of this individual changes to the gamma LUT or adaptive sync status were ignored (if committed without a buffer). Instead, perform a commit to apply the changes.
2020-06-01backend/drm: drop extra wlr_output_update_enabled callSimon Ser
drm_connector_set_mode already takes care of keeping this up-to-date.
2020-06-01backend/drm: commit/rollback FBs in drm_crtc_commitSimon Ser
We need to perform the FB bookkeeping on all commits, not just on page-flips.
2020-06-01backend/drm: make adaptive_sync atomicSimon Ser
Stop using drmModeObjectSetProperty, set the property in the crtc_commit function instead.
2020-06-01backend/drm: rollback pending CRTC state on test commitSimon Ser
A test commit doesn't apply the pending state. The CRTC state will be populated again if the compositor decides to perform a regular commit afterwards.
2020-05-27backend/drm: fix missing crtc->cursor NULL checkSimon Ser
Fixes: cdb6fdbc6cb7 ("backend/drm: remove missing cursor plane workaround")
2020-05-27backend/drm: don't set cursor if off-screenSimon Ser
Closes: https://github.com/swaywm/wlroots/issues/2216
2020-05-26backend/drm: introduce pending and current CRTC stateSimon Ser
Previously, we only had the pending state (crtc->pending, crtc->mode and crtc->active). This causes issues when a commit fails: the pending state is left as-is, and the next commit may read stale data from it. This will also cause issues when implementing test-only commits: we need to rollback the pending CRTC state after a test-only commit. Introduce separate pending and current CRTC states. Properly update the current state after a commit.
2020-05-26backend/drm: nuke retry_pageflipSimon Ser
retry_pageflip is now dead code, since drm_connector_start_renderer isn't called anymore. It was previously called when enabling an output. The name "retry_pageflip" was a little confusing because the function retried a modeset and the timer wasn't set up while performing a simple page-flip. Let's just remove this altogether for now. We can discuss whether it's worth it to bring it back. Should we only do it on failed page-flips? Should we only do it on EBUSY?
2020-05-26backend/drm: make drm_connector_set_mode take a wlr_drm_connectorSimon Ser
Since this is an internal DRM backend function, there's no reason we need to take a generic wlr_output.
2020-05-26backend/drm: remove enable_drm_connectorSimon Ser
Merge enable_drm_connector into drm_connector_set_mode. This allows us to de-duplicate logic since enabling an output performs a modeset.
2020-05-26backend/drm: remove drm_connector_set_custom_modeSimon Ser
Replace it with a function that returns the pending mode.
2020-05-26backend/drm: refuse to enable an output without a modeSimon Ser
2020-05-20render/egl: unset current context after swapping buffersSimon Ser
After swapping buffers, it doesn't make sense to perform more rendering operations. Unset the context to reflect this. This commit makes it so the context is always only current between wlr_egl_make_current and wlr_egl_swap_buffers. This is an alternative to [1]. [1]: https://github.com/swaywm/wlroots/pull/2212
2020-05-19backend/drm: add missing wlr_egl_unset_currentSimon Ser
2020-05-19render/egl: introduce wlr_egl_unset_currentSimon Ser
This function can be called after wlr_egl_make_current to cleanup the EGL context. This avoids having lingering EGL contexts that make things work by chance. Closes: https://github.com/swaywm/wlroots/issues/2197
2020-05-14output: make wlr_output_set_gamma atomicSimon Ser
wlr_output_set_gamma is now double-buffered and applies the gamma LUT on the next output commit.
2020-05-14backend/drm: fix segfault in drm_crtc_page_flipSimon Ser
When no cursor plane is available, drm_crtc_page_flip would segfault.
2020-05-12backend/drm: disable cursor in dealloc_crtcSimon Ser
dealloc_crtc was destroying GBM surfaces, but the cursor_enabled flag was left as-is. When re-enabling the output, atomic_crtc_pageflip would try enabling the cursor plane, but would fail because no framebuffer is available. Closes: https://github.com/swaywm/wlroots/issues/2150
2020-05-12backend/drm: fix combined modeset+enable commitsSimon Ser
When an output is enabled and modeset at the same time, drm_connector_commit would first try to modeset then try to commit. This won't work because both will trigger a page-flip. KMS will reject that. Change the logic to only enable an output if no modeset has been requested. The logic in wlr_output already checks that the user isn't doing a modeset and disabling the output at the same time.
2020-05-12backend/drm: remove missing cursor plane workaroundSimon Ser
We have a workaround for legacy drivers that support drmModeSetCursor without exposing a cursor plane. It doesn't work anymore now that we've moved to a more atomic interface. Let's just remove this workaround and fallback to software cursors. Closes: https://github.com/swaywm/wlroots/issues/2166
2020-05-11backend/drm: fix missing cursor on external monitors with multi-GPU setup ↵JonnyMako
and nouveau We need to make the multi-GPU surface current before the glFinish call. Closes: https://github.com/swaywm/sway/issues/5319
2020-05-10backend/drm: simplify atomic commit logicSimon Ser
We don't need a per-CRTC atomic request anymore. Let's make the request per-commit so that it's easier to debug. This is also groundwork for supporting wlr_output_test properly.
2020-05-10backend/drm: GAMMA_LUT_SIZE isn't atomicSimon Ser
GAMMA_LUT_SIZE isn't an atomic property. It can be used with the legacy interface too. So we can unify both codepaths and remove wlr_drm_interface.crtc_get_gamma_size. It's no guaranteed to exist though, so we still need to keep the fallback.
2020-05-09backend/drm: remove crtc_set_cursor from interfaceSimon Ser
2020-05-09backend/drm: remove conn_enable from interfaceSimon Ser
Use crtc_commit instead.
2020-05-09backend/drm: rename crtc_pageflip to crtc_commitSimon Ser
Also add a flags argument. The commit function will also be used for disabling the CRTC.
2020-05-09backend/drm: apply gamma LUT on page-flipSimon Ser
2020-05-09backend/drm: remove mode argument to crtc_pageflipSimon Ser
Add a new wlr_drm_crtc.pending bitfield which keeps track of pending output changes. More fields will be added in the future (e.g. active, gamma).
2020-05-09backend/drm: remove wlr_drm_interface.crtc_move_cursorSimon Ser
Instead, make the legacy backend call drmModeMoveCursor on page-flip.
2020-05-01backend/drm: make page-flip error scarierSimon Ser
The logs don't currently display the importance of a line. It's easy to read "skipping page-flip" as a debug message instead of an error message. Change the error message to make it more explicit. References: https://github.com/swaywm/wlroots/pull/2147
2020-05-01Fix error when reconnecting external displayWill Daly
Reconnecting an external display fails on initial page-flip. This occurs when the pageflip_pending flag has been set on the connector at the time the monitor is removed. Once the connector's CRTC has been deallocated, page_flip_handler cannot find the connector by its crtc_id, so pageflip_pending will remain set. This causes initialization to fail when the monitor is reconnected with the error messages: Skipping pageflip on output 'X' Failed to initialize renderer on connector 'X': initial page-flip failed To fix this problem, clear the pageflip_pending flag when cleaning up the connector.
2020-04-28backend/drm: don't allow legacy to use direct scanoutScott Anderson
2020-04-28backend/drm: move atomic cursor code into pageflip codeScott Anderson
It makes sense to construct as much atomic state as possible in the same place, so it doesn't get lost if we "reset" it.
2020-04-28backend/drm: introduce wlr_drm_fbScott Anderson
This is a type which manages gbm_surfaces and imported dmabufs in the same place, and makes the lifetime management between the two shared. It should lead to easier to understand code, and fewer special cases. This also contains a fair bit of refactoring to start using this new type. Co-authored-by: Simon Ser <contact@emersion.fr>
2020-04-10output: check for buffer size compatibility in common codeSimon Ser
Instead of checking for buffer size compatibility in each backend, centralize the check in wlr_output itself.
2020-04-10output: fix blurred hw cursors with fractional scalingSimon Ser
The scaling factor was being implicitly cast to an int. Closes: https://github.com/swaywm/sway/issues/4927
2020-04-08Add wlr_output_impl.rollbackSimon Ser
Most of the pending output state is not forwarded to the backend prior to an output commit. For instance, wlr_output_set_mode just stashes the mode without calling any wlr_output_impl function. wlr_output_impl.commit is responsible for applying the pending mode. However, there are exceptions to this rule. The first one is wlr_output_attach_render. It won't go away before renderer v6 is complete, because it needs to set the current EGL surface. The second one is wlr_output_attach_buffer. wlr_output_impl.attach_buffer is removed in [1]. When wlr_output_rollback is called, all pending state is supposed to be cleared. This works for all the state except the two exceptions mentionned above. To fix this, introduce wlr_output_impl.rollback. Right now, the backend resets the current EGL surface. This prevents GL commands from affecting the output after wlr_output_rollback. This patch is required for FBO-based outputs to work properly. The compositor might be using FBOs for its own purposes [2], having leftover FBO state can have bad consequences. [1]: https://github.com/swaywm/wlroots/pull/2097 [2]: https://github.com/swaywm/wlroots/pull/2063#issuecomment-597614312
2020-04-08backend: reset EGL surface after buffer swapSimon Ser
This prevents GL commands to affect a previously current EGL surface after a buffer swap.
2020-04-08output: check buffer in wlr_output_testSimon Ser
Check that buffer can be scanned out in wlr_output_test instead of wlr_output_attach_buffer. This allows the backend to have access to the whole pending state when performing the check. This brings the wlr_output API more in line with the KMS API. This removes the need for wlr_output_attach_buffer to return a value, and for wlr_output_impl.attach_buffer.
2020-04-08output: introduce wlr_output_testSimon Ser
2020-04-02buffer: add a release eventSimon Ser
Consumers call wlr_buffer_lock. Once all consumers are done with the buffer, only the producer should have a reference to the buffer. In this case, we can release the buffer (and let the producer re-use it).
2020-03-15Fix uint32 overflow in fill_empty_gamma_table on Icelake platformFilip Sandborg
Closes: https://github.com/swaywm/sway/issues/4826
2020-03-06backend/drm: add support for adaptive_sync_enabledSimon Ser
The vrr_capable and VRR_ENABLED properties are used.
2020-03-04output: remove wlr_output_impl.schedule_frameSimon Ser
This function allowed backends to provide a custom function for frame scheduling. Before resuming the rendering loop, the DRM and Wayland backends would wait for vsync. There isn't a clear benefit of doing this. The only upside is that we get more stable timings: the delay between two repaints doesn't change too much and is close to a mutliple of the refresh rate. However this introduces latency, especially when a client misses a frame. For instance a fullscreen game missing vblank will need to wait more than a whole frame before being able to display new content. This worst case scenario happens as follows: - Client is still rendering its frame and cannot submit it in time - Deadline is reached - Compositor decides to stop the rendering loop since nothing changed on screen - Client finally manages to render its frame, submits it - Compositor calls wlr_output_schedule_frame - DRM backend waits for next vblank - The wlr_output frame event is fired, compositor draws new content on screen - On the second next vblank, the new content reaches the screen With this patch, the wlr_output frame event is fired immediately when the client submits its late frame. This change also makes it easier to support variable refresh rate, since VRR is all about being able to present too-late frames earlier. References: https://github.com/swaywm/wlroots/issues/1925
2020-01-24backend/drm: remove overzealous finish_drm_surfaceRouven Czerwinski
The previous PR was overzealous in adding a finish_drm_surface call which was also done by the caller. Remove the call and also move the comment to the correct code location.
2020-01-24backend/drm: add env variable to disable modifiersRouven Czerwinski
In some cases modesets fail if the planes are initialized with modifiers. Since in this case possibly all planes need to reinitialized, which is not possible in the current wlroots design, add an environment variable for affected users.