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

output: wlr_backend_commit and wlr_swapchain_helper #8068

Merged
merged 10 commits into from Mar 28, 2024

Conversation

kennylevinsen
Copy link
Member

Use the new wlr_backend_commit and wlr_swapchain_helper to light up outputs and apply configuration changes.

Works in local testing, but as sway's output configuration system is a bit complicated it wouldn't hurt with more testing.

sway/config/output.c Outdated Show resolved Hide resolved
@kennylevinsen kennylevinsen force-pushed the backendwide branch 2 times, most recently from 4e2585c to 3aeb4dd Compare March 19, 2024 14:18
@kennylevinsen
Copy link
Member Author

Had entirely forgotten to use the new swapchain in the wlr_scene_output_build_state call, added.

sway/config/output.c Outdated Show resolved Hide resolved
sway/config/output.c Outdated Show resolved Hide resolved
sway/desktop/output.c Outdated Show resolved Hide resolved
sway/desktop/output.c Outdated Show resolved Hide resolved
sway/desktop/output.c Outdated Show resolved Hide resolved
@kennylevinsen
Copy link
Member Author

I took the liberty of shortening some lines in the new apply_output_configs while I was addressing the comments - they had gotten a bit out of hand.

struct output_config *oc = find_output_config(output);
apply_output_config(oc, output);
free_output_config(oc);
apply_all_output_configs();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idea for future work: we could schedule a apply_all_output_configs() call with an idle event source (or a timer with a short duration), so that changes for multiple outputs are batched together (e.g. on startup, or when plugging a dock).

This would require a slightly better fallback logic though: if we can't enable all outputs we need to retry after lowering the modes and/or disabling outputs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In clay I run off an idle handler for new and destroyed outputs, and for wlr_output_power_management as those do not need any feedback. I also experimented with a timer, but it didn't seem to make much of a difference other than delaying bringup. Might be worth more experimentation.

It's a bit trickier when the trigger want feedback on success, e.g. dynamic configuration with swaymsg or wlr_output_management.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ref #8091 :)

It's a bit trickier when the trigger want feedback on success, e.g. dynamic configuration with swaymsg or wlr_output_management.

I don't think debouncing is particularly desirable in these cases.

@emersion
Copy link
Member

By the way, we have some wlr_output_test() calls in queue_output_config() to lower the mode/BPC automatically. I don't think this plays very nice with the new logic? (Not saying we should necessarily fix it right now)

@emersion
Copy link
Member

I've looked through all of the commits and they all LGTM!

@kennylevinsen
Copy link
Member Author

By the way, we have some wlr_output_test() calls in queue_output_config() to lower the mode/BPC automatically. I don't think this plays very nice with the new logic? (Not saying we should necessarily fix it right now)

Agree. In clay I retry with a new set of output states that progressively get less demanding until something sticks. While that approach isn't per-output like the old logic, I think we could have some fairly simple "graceful degradation" logic here too.

I've looked through all of the commits and they all LGTM!

Thanks for the review!

Applying an output config has two stages: Atomic application of
wlr_output_state, and applicaiton of non-atomic state like output
layout.

Split the latter out into finalize_output_config for use in a later
commit.
Introduce apply_output_configs, which applies the specified matched
output configs as a single backend commit.

Reimplement apply_output_config_to_outputs using apply_output_configs.
Apply all output configs as they are. This differs from
apply_output_config_to_outputs, which tries to apply a specific output
config.
This allows us to test and if necessary degrade the entire backend
configuration to light everything up.
apply_output_config_to_outputs uses the specified output config to check
which outputs to apply to, and to use as backup when no config is found.
If any config matches the output, the specified config will be
disregarded.

The only remaining user of apply_output_config_to_outputs is
reset_outputs, which called apply_output_config_to_outputs with either
the first stored wildcard config, or a new empty wildcard config.

Providing a stored or empty wildcard config is practically the same as
calling `apply_all_output_configs`. Replace uses of `reset_outputs` with
`apply_all_output_configs` and remove the now unused functions.
@kennylevinsen
Copy link
Member Author

re: our discussion about graceful fallback, I threw together something here: 18a1c26

It is untested, but the idea is to first degrade render formats to 8 bit, then degrade automatically selected modes, starting with the most bandwidth-intensive one.

Problems:

  • If one output supports 10-bit XRGB, while another 10-bit XBGR, then the current render format degradation will drop all the way to 8-bit as there is no per-output test.
  • The VRR issue is not yet handled. It's not a fallback in the same sense and might need a different strategy.

Copy link
Member

@emersion emersion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's merge this for now and keep improving the fallback stuff in separate PRs.

Thanks a lot!

@emersion emersion merged commit a4ef377 into swaywm:master Mar 28, 2024
3 checks passed
@kennylevinsen kennylevinsen deleted the backendwide branch March 28, 2024 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants