aboutsummaryrefslogtreecommitdiff
path: root/backend/drm
AgeCommit message (Collapse)Author
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-26backend/drm: rollback atomic blobsSimon Ser
If the atomic commit fails or is test-only, rollback wlr_drm_crtc.{mode_id,gamma_lut} blob IDs to their previous value. This prevents the next commits from failing or applying test-only state.
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-19backend/drm: fix current EGL context on multi-GPUSimon Ser
get_tex_for_bo changes the current EGL context. Rendering operations must immediately follow drm_surface_make_current. Closes: https://github.com/swaywm/wlroots/issues/2209
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-14backend/drm: fix atomic commits when the GAMMA_LUT prop is missingSimon Ser
We already have the logic to fallback to the legacy interface above. We just need to avoid calling atomic_add with a zero prop ID. Closes: https://github.com/swaywm/wlroots/issues/2187
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: print error in set_plane_propsSimon Ser
This makes it easier to understand which plane failed.
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: fix crash in session_signalSimon Ser
conn->crtc is NULL in case the output is disabled. However, the DRM backend will set the GAMMA_LUT property anyway. On each commit the whole state is sent to KMS. Adding WLR_DRM_CRTC_GAMMA_LUT to the pending state would just make the backend re-create the blob containing the gamma LUT.
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-29backend/drm: strip alpha channel if necessarySimon Ser
Some primary planes don't support ARGB8888, they only support XRGB8888 (for instance on older Intel hardware). The DRM backend would fail to initialize. When that's the case, try to allocate buffers without an alpha channel.
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: don't have fallback atomic commitsScott Anderson
This is just doing atomic incorrectly.
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-09backend: set EGL_RENDERABLE_TYPE and EGL_SURFACE_TYPESimon Ser
Ensure these are set to the correct value.
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.
2020-01-17backend/drm: prevent outputs from being destroyed on commitSimon Ser
This would happen if initializing the renderer fails. Instead, we just mark the output as disabled. References: https://github.com/swaywm/sway/pull/4917
2019-12-30backend/drm: don't modeset with a NULL mode after TTY switchSimon Ser
This fixes a segfault in drm_connector_set_mode (mode = NULL). This happens because we set wlr_output.enabled to true if the connector is attached to the CRTC. When the user disables an output in the wlroots-based compositor, switches to another VT (enabling the output), then switches back, wlroots sets wlr_output.enabled to true but wlr_output.current_mode is NULL. We should consider not reading properties from KMS after a TTY switch, disabling all connectors. However this may result in flickering (outputs being disabled then re-enabled). Closes: https://github.com/swaywm/wlroots/issues/1874