aboutsummaryrefslogtreecommitdiff
path: root/backend/drm
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2022-06-01 21:31:54 +0200
committerIsaac Freund <mail@isaacfreund.com>2022-06-02 11:46:31 +0000
commit6936e163b514fd4f43a9319f53090527fc411156 (patch)
tree0acdb396728dcb736790dc4f6b66528c2fa5f3b0 /backend/drm
parentacc6d94db048118e7e910d7812431dfb27b2d769 (diff)
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.
Diffstat (limited to 'backend/drm')
-rw-r--r--backend/drm/drm.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/backend/drm/drm.c b/backend/drm/drm.c
index 2caa0ef0..97e473b6 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -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);