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

Wait for pageflips to support non-blocking backend-wide commits #8401

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 59 additions & 2 deletions sway/desktop/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ static int output_repaint_timer_handler(void *data) {
}

if (!wlr_output_commit_state(output->wlr_output, &pending)) {
sway_log(SWAY_ERROR, "Page-flip failed on output %s", output->wlr_output->name);
// sway_log(SWAY_ERROR, "Page-flip failed on output %s", output->wlr_output->name);
}
wlr_output_state_finish(&pending);
return 0;
Expand Down Expand Up @@ -391,12 +391,69 @@ void update_output_manager_config(struct sway_server *server) {
ipc_event_output();
}

// Placeholder while all render tasks clear up
static void handle_frame_nop(struct wl_listener *listener, void *user_data) {}

static void handle_frame_clear(struct wl_listener *listener, void *user_data) {
struct sway_output *output = wl_container_of(listener, output, frame);
output->frame.notify = handle_frame_nop;

sway_log(SWAY_DEBUG, "Render task for %s cleared", output->wlr_output->name);

wl_list_for_each(output, &root->all_outputs, link) {
if (output == root->fallback_output) {
continue;
}
if (output->frame.notify != handle_frame_nop) {
return;
}
}

// All done!
sway_log(SWAY_DEBUG, "All render tasks cleared, modestting");
wl_list_for_each(output, &root->all_outputs, link) {
if (output == root->fallback_output) {
continue;
}
output->frame.notify = handle_frame;
}
apply_stored_output_configs();
}

static int timer_modeset_handle(void *data) {
struct sway_server *server = data;
wl_event_source_remove(server->delayed_modeset);
server->delayed_modeset = NULL;

apply_stored_output_configs();
bool wait = false;
struct sway_output *output;
wl_list_for_each(output, &root->all_outputs, link) {
if (output == root->fallback_output) {
continue;
}
if (output->wlr_output->frame_pending) {
output->frame.notify = handle_frame_clear;
wait = true;
sway_log(SWAY_DEBUG, "Awaiting render task on %s", output->wlr_output->name);
} else {
output->frame.notify = handle_frame_nop;
}
}

if (!wait) {
// Nothing to wait for, go ahead
sway_log(SWAY_DEBUG, "No render tasks to wait for, modesetting");
wl_list_for_each(output, &root->all_outputs, link) {
if (output == root->fallback_output) {
continue;
}
output->frame.notify = handle_frame;
}
apply_stored_output_configs();
return 0;
}


return 0;
}

Expand Down