From 135e60ff8210d7194a67fda1125a74ee102eb2e8 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Tue, 28 Jun 2022 19:57:49 +0200 Subject: backend/x11: report adaptive sync as enabled All we can do to influence adaptive sync on the X11 backend is set the _VARIABLE_REFRESH window property like mesa automatically does. We don't have any control beyond that, so we set the state to enabled on creating the output and never allow changing it (just like the Wayland backend). --- backend/x11/output.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/backend/x11/output.c b/backend/x11/output.c index 0e124f9a..f109757d 100644 --- a/backend/x11/output.c +++ b/backend/x11/output.c @@ -113,6 +113,17 @@ static bool output_test(struct wlr_output *wlr_output, return false; } + // All we can do to influence adaptive sync on the X11 backend is set the + // _VARIABLE_REFRESH window property like mesa automatically does. We don't + // have any control beyond that, so we set the state to enabled on creating + // the output and never allow changing it (just like the Wayland backend). + assert(wlr_output->adaptive_sync_status == WLR_OUTPUT_ADAPTIVE_SYNC_ENABLED); + if (state->committed & WLR_OUTPUT_STATE_ADAPTIVE_SYNC_ENABLED) { + if (!state->adaptive_sync_enabled) { + return false; + } + } + if (state->committed & WLR_OUTPUT_STATE_MODE) { assert(state->mode_type == WLR_OUTPUT_STATE_MODE_CUSTOM); } @@ -335,21 +346,6 @@ static bool output_commit(struct wlr_output *wlr_output, } } - if (state->committed & WLR_OUTPUT_STATE_ADAPTIVE_SYNC_ENABLED && - x11->atoms.variable_refresh != XCB_ATOM_NONE) { - if (state->adaptive_sync_enabled) { - uint32_t enabled = 1; - xcb_change_property(x11->xcb, XCB_PROP_MODE_REPLACE, output->win, - x11->atoms.variable_refresh, XCB_ATOM_CARDINAL, 32, 1, - &enabled); - wlr_output->adaptive_sync_status = WLR_OUTPUT_ADAPTIVE_SYNC_UNKNOWN; - } else { - xcb_delete_property(x11->xcb, output->win, - x11->atoms.variable_refresh); - wlr_output->adaptive_sync_status = WLR_OUTPUT_ADAPTIVE_SYNC_DISABLED; - } - } - if (state->committed & WLR_OUTPUT_STATE_BUFFER) { if (!output_commit_buffer(output, state)) { return false; @@ -574,6 +570,12 @@ struct wlr_output *wlr_x11_output_create(struct wlr_backend *backend) { x11->atoms.wm_protocols, XCB_ATOM_ATOM, 32, 1, &x11->atoms.wm_delete_window); + uint32_t enabled = 1; + xcb_change_property(x11->xcb, XCB_PROP_MODE_REPLACE, output->win, + x11->atoms.variable_refresh, XCB_ATOM_CARDINAL, 32, 1, + &enabled); + wlr_output->adaptive_sync_status = WLR_OUTPUT_ADAPTIVE_SYNC_ENABLED; + wlr_x11_output_set_title(wlr_output, NULL); xcb_map_window(x11->xcb, output->win); -- cgit v1.2.3