Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: add support for direct scan-out #1641

Draft
wants to merge 5 commits into
base: master
from

Conversation

Projects
None yet
1 participant
@emersion
Copy link
Member

commented Mar 29, 2019

This adds support for direct scan-out. This is a required feature before working on planes.

This PR tries to to as little changes as possible to make it easy to review and avoid re-writing everything. The current DRM backend and interface are not great but refactoring can happen incrementally with future PRs.

This PR is missing a lot of checks. I first wanted to make sure this actually works. I've tested with a modified version of weston-simple-dmabuf-egl. Depending on your hardware it might be easier or more difficult to test.

A new wlr_output_set_dmabuf function has been introduced. It's a bad name if we keep it that way. It does the same thing as wlr_output_swap_buffers without actually rendering. Then plan was originally to also add a wlr_output_commit/present function, but I'm not sure how to implement it for the Wayland and X11 backends.

I'm not sure wlr_dmabuf_attributes is the right data structure to use. Thoughts?

TODO:

  • We need to hold client buffers for longer than usual. When compositing, we need to hold buffers until the buffer swap (and the kernel will take care of the rest with implicit synchronization). When scanning out, we need to hold buffers as long as they're visible on screen.
  • Make software cursors force composition
  • Make screen capture force composition
  • Update wlr_output_damage
  • Test as many clients as possible

Test plan: try those fullscreen

  • weston-simple-dmabuf-drm
  • weston-simple-dmabuf-egl
  • weston-simple-egl
  • mpv
  • a glfw demo

Fixes #193

@emersion

This comment has been minimized.

Copy link
Member Author

commented Mar 31, 2019

Proposal:

// Same as wlr_output_make_current
bool wlr_output_attach_render(struct wlr_output *output);
// Instead of rendering to a buffer, use an existing DMA-BUF
bool wlr_output_attach_dmabuf(struct wlr_output *output,
	struct wlr_dmabuf_attributes *attrs);
// Submit a frame
bool wlr_output_present(struct wlr_output *output); // or commit, see #1640

@emersion emersion referenced this pull request Mar 31, 2019

Merged

Introduce wlr_format_set #1642

@emersion emersion requested a review from ascent12 Apr 8, 2019

@emersion emersion force-pushed the emersion:direct-scanout branch from 4c330a3 to 68b0a11 Apr 9, 2019

@emersion emersion force-pushed the emersion:direct-scanout branch from 68b0a11 to a8a5c7a Apr 9, 2019

@emersion emersion force-pushed the emersion:direct-scanout branch from a8a5c7a to 2bef3a3 Apr 10, 2019

emersion added some commits Apr 22, 2019

@emersion

This comment has been minimized.

Copy link
Member Author

commented Apr 22, 2019

This is now working pretty well. Apart from the API not being final yet, there is one more issue: synchronization.

When compositing, we can send wl_buffer.release as soon as we've swapped buffers, because implicit synchronization will take care of holding the buffers until we've finished drawing.

When scanning out, we need to wait for the buffer to stop being visible before sending wl_buffer.release. I've implemented this in 27ee4bd by making rootston reference the wlr_buffer when scanning out. It works, but I'm not a fan of this approach: rootston can only guess when the backend is done with the buffer. Here with the DRM backend it needs to hold the buffer for two pageflips (because we draw right after pageflips, so there is one whole pageflip during which the buffer has been drawn and submitted to DRM but it's not yet visible). For the Wayland backend it would need to wait differently (depending on the wl_buffer.release signal of the parent compositor).

To fix this, I think the most straightforward solution is to pass the wlr_buffer to the backend. Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.