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.
This commit is contained in:
Simon Ser 2022-06-01 21:31:54 +02:00 committed by Isaac Freund
parent acc6d94db0
commit 6936e163b5
1 changed files with 15 additions and 2 deletions

View File

@ -31,13 +31,16 @@
#include "render/wlr_renderer.h"
#include "util/signal.h"
static const uint32_t SUPPORTED_OUTPUT_STATE =
WLR_OUTPUT_STATE_BACKEND_OPTIONAL |
// Output state which needs a KMS commit to be applied
static const uint32_t COMMIT_OUTPUT_STATE =
WLR_OUTPUT_STATE_BUFFER |
WLR_OUTPUT_STATE_MODE |
WLR_OUTPUT_STATE_ENABLED |
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) {
if (drmGetCap(drm->fd, DRM_CAP_CURSOR_WIDTH, &drm->cursor_width)) {
drm->cursor_width = 64;
@ -474,6 +477,11 @@ static bool drm_connector_test(struct wlr_output *output,
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 (output->current_mode == NULL &&
!(state->committed & WLR_OUTPUT_STATE_MODE)) {
@ -560,6 +568,11 @@ bool drm_connector_commit_state(struct wlr_drm_connector *conn,
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};
drm_connector_state_init(&pending, conn, base);