Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

Support DRM connector tiling #2961

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft

Support DRM connector tiling #2961

wants to merge 5 commits into from

Conversation

coroner21
Copy link

This first part enables parsing of TILE info for the DRM backend and exposing the info into wlr_output. Addresses #1580, the remainder is still WIP:

  • Add a way to crop a buffer with wlr_output. Probably something like wlr_output_set_src_box? This should translate to the KMS SRC_* props.
  • Add wlr_output_group which forwards buffers to multiple child outputs on commit.

@emersion emersion marked this pull request as draft June 14, 2021 10:04
@emersion
Copy link
Member

To add wlr_output_set_source_box:

  • Add a source_box field to wlr_output_state, with the matching enum entry. Populate it in wlr_output_set_source_box.
  • In the DRM backend, expand set_plane_props to take a source box in addition to the existing parameters.
  • When calling set_plane_props for the primary plane, grab the source box from state if it's set there.

@coroner21
Copy link
Author

Thanks a lot Simon for the directions. Two questions came up:

  • I have the enum and field for source_box in wlr_output_state and added wlr_output_set_source_box to populate that. When would we reset the flag in the committed field tracking the state? On my display there is only the full 5k resolution which requires both connectors, the lower scaled resolutions require only one. So probably on modeset we should in general reset the flag. Or should we just ensure the field is always populated for an active output (with default (0,0,width,height) in most cases)?
  • In set_plane_props how does the width and height from GBM relate to source_box? The GBM values would correspond to the full buffer and the box cuts out parts of it, right?

Note that it seems in set_plane_props the wlr_drm_backend is not used so I could just replace that parameter with the box. I still struggle to see how the same set_plane_props function can be used for both primary and cursor planes. I might make a proposal to have a bit different code layout here instead or just duplicate this function.

@emersion
Copy link
Member

When would we reset the flag in the committed field tracking the state?

This is done automatically in wlr_output_commit.

Or should we just ensure the field is always populated for an active output (with default (0,0,width,height) in most cases)?

The pattern so far has been that the fields have undefined value if the flag isn't set.

In set_plane_props how does the width and height from GBM relate to source_box? The GBM values would correspond to the full buffer and the box cuts out parts of it, right?

Yes, that is correct. So no source box means use (0, 0, buffer_width, buffer_height).

Note that it seems in set_plane_props the wlr_drm_backend is not used

Indeed, it seems unused ATM. Feel free to submit a separate patch to remove that arg.

I still struggle to see how the same set_plane_props function can be used for both primary and cursor planes.

The current buffer is taken from the wlr_drm_plane. ATM, the SRC_* coords are set to (0, 0, buffer_width, buffer_height). The CRTC_* coords are set to (x, y, buffer_width, buffer_height) (x and y are provided as arguments to set_plane_props, they are zero for the primary plane and the cursor's position for the cursor plane).

duplicate this function.

I don't think that's necessary.

@coroner21
Copy link
Author

OK, the second step should be also completed, now the only pending task is addition of wlr_output_group to collect the tiles, setup the combined buffer and on commit set source boxes for different outputs related to the display and then call commit for the outputs.

Duplicating wlr_output I would add a wlr_output_group type. Would be great if you could provide some thoughts which parts I would need to duplicate.

Furthermore, how do we want to initialize the output group? Somewhere we need to detect the tiling display and then trigger output group initialization (probably by passing an array of wlr_output pointers and total number of tiles).

@emersion
Copy link
Member

Duplicating wlr_output

It shouldn't be necessary to duplicate wlr_output. Instead, we should be able to design wlr_output_group as a new wlr_output implementation. Maybe look into the headless backend to see how to do this?

https://github.com/swaywm/wlroots/blob/7cbcc65ad00e195a821cf955dd2302b6b0ec1bf0/backend/headless/output.c

Furthermore, how do we want to initialize the output group? Somewhere we need to detect the tiling display and then trigger output group initialization (probably by passing an array of wlr_output pointers and total number of tiles).

Yes. As a first step the compositor can manually do it. But ideally we could provide a helper to make it as easy as possible for compositors to support tiled outputs.

One annoying thing is that there's no easy way to list all outputs belonging to a backend, so we can't just have the helper walk the list. Maybe the compositor can collect all outputs with the same tile group and call a function which automatically configures and returns a new wlr_output_group? Not sure we can do much better with the current APIs.

@emersion
Copy link
Member

I've started work on wlr_output_group in #3067. It's completely untested, but maybe can help you get started? It'll only work with the DRM backend once #2903 is merged, but should already work fine with other backends. Maybe some bits need to be added for modesetting.

@emersion emersion changed the title Support DRM connector tiling [WIP] Support DRM connector tiling Jul 31, 2021
@emersion
Copy link
Member

emersion commented Nov 1, 2021

wlroots has migrated to gitlab.freedesktop.org. This pull request has been moved to:

https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/2961

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants