backend/drm: short-circuit no-op commits

Some output commits (changing e.g. the output scale or transform)
don't require any change in the KMS state. Instead of going through
a KMS commit, return early. Blocking KMS commits can be expensive.
Simon Ser 3 years ago committed by Isaac Freund
parent acc6d94db0
commit 6936e163b5

@ -31,13 +31,16 @@
#include "render/wlr_renderer.h" #include "render/wlr_renderer.h"
#include "util/signal.h" #include "util/signal.h"
static const uint32_t SUPPORTED_OUTPUT_STATE = // Output state which needs a KMS commit to be applied
WLR_OUTPUT_STATE_BACKEND_OPTIONAL | static const uint32_t COMMIT_OUTPUT_STATE =
WLR_OUTPUT_STATE_BUFFER | WLR_OUTPUT_STATE_BUFFER |
WLR_OUTPUT_STATE_MODE | WLR_OUTPUT_STATE_MODE |
WLR_OUTPUT_STATE_ENABLED | WLR_OUTPUT_STATE_ENABLED |
WLR_OUTPUT_STATE_GAMMA_LUT; WLR_OUTPUT_STATE_GAMMA_LUT;
static const uint32_t SUPPORTED_OUTPUT_STATE =
WLR_OUTPUT_STATE_BACKEND_OPTIONAL | COMMIT_OUTPUT_STATE;
bool check_drm_features(struct wlr_drm_backend *drm) { bool check_drm_features(struct wlr_drm_backend *drm) {
if (drmGetCap(drm->fd, DRM_CAP_CURSOR_WIDTH, &drm->cursor_width)) { if (drmGetCap(drm->fd, DRM_CAP_CURSOR_WIDTH, &drm->cursor_width)) {
drm->cursor_width = 64; drm->cursor_width = 64;
@ -474,6 +477,11 @@ static bool drm_connector_test(struct wlr_output *output,
return false; return false;
} }
if ((state->committed & ~COMMIT_OUTPUT_STATE) == 0) {
// This commit doesn't change the KMS state
return true;
}
if ((state->committed & WLR_OUTPUT_STATE_ENABLED) && state->enabled) { if ((state->committed & WLR_OUTPUT_STATE_ENABLED) && state->enabled) {
if (output->current_mode == NULL && if (output->current_mode == NULL &&
!(state->committed & WLR_OUTPUT_STATE_MODE)) { !(state->committed & WLR_OUTPUT_STATE_MODE)) {
@ -560,6 +568,11 @@ bool drm_connector_commit_state(struct wlr_drm_connector *conn,
return false; return false;
} }
if ((base->committed & ~COMMIT_OUTPUT_STATE) == 0) {
// This commit doesn't change the KMS state
return true;
}
struct wlr_drm_connector_state pending = {0}; struct wlr_drm_connector_state pending = {0};
drm_connector_state_init(&pending, conn, base); drm_connector_state_init(&pending, conn, base);

Loading…
Cancel
Save