diff --git a/backend/drm/drm.c b/backend/drm/drm.c index a99ce50b2..0b336cc3d 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -1718,14 +1718,12 @@ static void handle_page_flip(int fd, unsigned seq, /* The DRM backend guarantees that the presentation event will be for * the last submitted frame. */ .output = &conn->output, - .commit_seq = conn->output.commit_seq, .presented = drm->session->active, .when = &present_time, .seq = seq, .refresh = mhz_to_nsec(conn->output.refresh), .flags = present_flags, }; - wlr_output_send_present(&conn->output, &present_event); wl_signal_emit_mutable(&conn->commit.events.present, &present_event); if (drm->session->active) { diff --git a/backend/wayland/output.c b/backend/wayland/output.c index dd7261a0f..d5e244630 100644 --- a/backend/wayland/output.c +++ b/backend/wayland/output.c @@ -103,7 +103,6 @@ static void presentation_feedback_handle_presented(void *data, .tv_nsec = tv_nsec, }; struct wlr_output_event_present event = { - .commit_seq = feedback->commit_seq, .presented = true, .output = &feedback->output->wlr_output, .when = &t, @@ -111,7 +110,6 @@ static void presentation_feedback_handle_presented(void *data, .refresh = refresh_ns, .flags = flags, }; - wlr_output_send_present(&feedback->output->wlr_output, &event); wl_signal_emit_mutable(&feedback->commit.events.present, &event); presentation_feedback_destroy(feedback); @@ -122,11 +120,9 @@ static void presentation_feedback_handle_discarded(void *data, struct wlr_wl_presentation_feedback *feedback = data; struct wlr_output_event_present event = { - .commit_seq = feedback->commit_seq, .presented = false, .output = &feedback->output->wlr_output, }; - wlr_output_send_present(&feedback->output->wlr_output, &event); wl_signal_emit_mutable(&feedback->commit.events.present, &event); presentation_feedback_destroy(feedback); @@ -588,7 +584,6 @@ static struct wlr_output_commit *output_commit(struct wlr_output *wlr_output, } feedback->output = output; feedback->feedback = wp_feedback; - feedback->commit_seq = output->wlr_output.commit_seq + 1; wl_list_insert(&output->presentation_feedbacks, &feedback->link); wp_presentation_feedback_add_listener(wp_feedback, diff --git a/backend/x11/output.c b/backend/x11/output.c index 5c8b0697d..64be76c49 100644 --- a/backend/x11/output.c +++ b/backend/x11/output.c @@ -383,7 +383,7 @@ static struct wlr_output_commit *output_commit(struct wlr_output *wlr_output, } } - uint32_t serial = output->wlr_output.commit_seq; + uint32_t serial = output->serial++; wlr_output_commit_init(&commit->commit, wlr_output); wl_list_insert(&output->commits, &commit->link); @@ -754,13 +754,11 @@ void handle_x11_present_event(struct wlr_x11_backend *x11, bool presented = complete_notify->mode != XCB_PRESENT_COMPLETE_MODE_SKIP; struct wlr_output_event_present present_event = { .output = &output->wlr_output, - .commit_seq = complete_notify->serial, .presented = presented, .when = &t, .seq = complete_notify->msc, .flags = flags, }; - wlr_output_send_present(&output->wlr_output, &present_event); wl_signal_emit_mutable(&commit->commit.events.present, &present_event); wl_list_remove(&commit->link); diff --git a/include/backend/wayland.h b/include/backend/wayland.h index 17211a92c..ee1c2f716 100644 --- a/include/backend/wayland.h +++ b/include/backend/wayland.h @@ -67,7 +67,6 @@ struct wlr_wl_presentation_feedback { struct wlr_wl_output *output; struct wl_list link; // wlr_wl_output.presentation_feedbacks struct wp_presentation_feedback *feedback; - uint32_t commit_seq; }; struct wlr_wl_output_layer { diff --git a/include/backend/x11.h b/include/backend/x11.h index 218faf7b3..acc51731c 100644 --- a/include/backend/x11.h +++ b/include/backend/x11.h @@ -37,6 +37,7 @@ struct wlr_x11_output { struct wlr_output wlr_output; struct wlr_x11_backend *x11; struct wl_list link; // wlr_x11_backend.outputs + uint32_t serial; xcb_window_t win; xcb_present_event_t present_event_id; diff --git a/include/wlr/interfaces/wlr_output.h b/include/wlr/interfaces/wlr_output.h index 616f81398..cf0c829f2 100644 --- a/include/wlr/interfaces/wlr_output.h +++ b/include/wlr/interfaces/wlr_output.h @@ -115,13 +115,6 @@ void wlr_output_update_needs_frame(struct wlr_output *output); * See wlr_output.events.frame. */ void wlr_output_send_frame(struct wlr_output *output); -/** - * Send a present event. - * - * See wlr_output.events.present. - */ -void wlr_output_send_present(struct wlr_output *output, - struct wlr_output_event_present *event); /** * Request the compositor to apply new state. */ diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h index 8793fe8b1..b0d5e27e0 100644 --- a/include/wlr/types/wlr_output.h +++ b/include/wlr/types/wlr_output.h @@ -160,9 +160,6 @@ struct wlr_output { struct wlr_output_state pending; - // Commit sequence number. Incremented on each commit, may overflow. - uint32_t commit_seq; - struct { // Request to render a frame struct wl_signal frame; @@ -176,9 +173,6 @@ struct wlr_output { struct wl_signal precommit; // struct wlr_output_event_precommit // Emitted right after commit struct wl_signal commit; // struct wlr_output_event_commit - // Emitted right after a commit has been presented to the user for - // enabled outputs - struct wl_signal present; // struct wlr_output_event_present // Emitted after a client bound the wl_output global struct wl_signal bind; // struct wlr_output_event_bind struct wl_signal description; @@ -209,6 +203,11 @@ struct wlr_output { struct wlr_addon_set addons; void *data; + + // private state + + // used for when to create a new back buffer + bool not_committed; }; struct wlr_output_event_damage { @@ -246,9 +245,6 @@ enum wlr_output_present_flag { struct wlr_output_event_present { struct wlr_output *output; - // Frame submission for which this presentation event is for (see - // wlr_output.commit_seq). - uint32_t commit_seq; // Whether the frame was presented at all. bool presented; // Time when the content update turned into light the first time. diff --git a/types/output/output.c b/types/output/output.c index a370f32d1..174e81595 100644 --- a/types/output/output.c +++ b/types/output/output.c @@ -411,7 +411,6 @@ void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend, .render_format = DRM_FORMAT_XRGB8888, .transform = WL_OUTPUT_TRANSFORM_NORMAL, .scale = 1, - .commit_seq = 0, }; wl_list_init(&output->modes); @@ -423,7 +422,6 @@ void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend, wl_signal_init(&output->events.needs_frame); wl_signal_init(&output->events.precommit); wl_signal_init(&output->events.commit); - wl_signal_init(&output->events.present); wl_signal_init(&output->events.bind); wl_signal_init(&output->events.description); wl_signal_init(&output->events.request_state); @@ -440,6 +438,8 @@ void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend, output->display_destroy.notify = handle_display_destroy; wl_display_add_destroy_listener(display, &output->display_destroy); + output->not_committed = true; + if (state) { output_apply_state(output, state); } @@ -829,8 +829,6 @@ bool wlr_output_commit_state(struct wlr_output *output, return false; } - output->commit_seq++; - if (output_pending_enabled(output, state)) { output->frame_pending = true; output->needs_frame = false; @@ -851,6 +849,8 @@ bool wlr_output_commit_state(struct wlr_output *output, wlr_buffer_unlock(pending.buffer); } + output->not_committed = false; + return true; } @@ -915,26 +915,6 @@ void wlr_output_schedule_frame(struct wlr_output *output) { wl_event_loop_add_idle(ev, schedule_frame_handle_idle_timer, output); } -void wlr_output_send_present(struct wlr_output *output, - struct wlr_output_event_present *event) { - assert(event); - event->output = output; - - struct timespec now; - if (event->presented && event->when == NULL) { - clockid_t clock = wlr_backend_get_presentation_clock(output->backend); - errno = 0; - if (clock_gettime(clock, &now) != 0) { - wlr_log_errno(WLR_ERROR, "failed to send output present event: " - "failed to read clock"); - return; - } - event->when = &now; - } - - wl_signal_emit_mutable(&output->events.present, event); -} - struct deferred_present_event { struct wlr_output_commit *commit; struct wl_event_source *idle_source; diff --git a/types/output/render.c b/types/output/render.c index a185d8446..a16f4405a 100644 --- a/types/output/render.c +++ b/types/output/render.c @@ -155,7 +155,7 @@ bool output_ensure_buffer(struct wlr_output *output, if (state->committed & WLR_OUTPUT_STATE_RENDER_FORMAT) { needs_new_buffer = true; } - if (state->allow_artifacts && output->commit_seq == 0 && enabled) { + if (state->allow_artifacts && output->not_committed && enabled) { // On first commit, require a new buffer if the compositor called a // mode-setting function, even if the mode won't change. This makes it // so the swapchain is created now.