backend/drm: add support for wlr_swapchain buffer age

This commit is contained in:
Simon Ser 2020-07-27 18:37:40 +02:00
parent c11c6c4568
commit 68a8d99055
2 changed files with 13 additions and 7 deletions

View file

@ -27,6 +27,7 @@
#include "backend/drm/drm.h" #include "backend/drm/drm.h"
#include "backend/drm/iface.h" #include "backend/drm/iface.h"
#include "backend/drm/util.h" #include "backend/drm/util.h"
#include "render/swapchain.h"
#include "util/signal.h" #include "util/signal.h"
bool check_drm_features(struct wlr_drm_backend *drm) { bool check_drm_features(struct wlr_drm_backend *drm) {
@ -331,6 +332,15 @@ static bool drm_connector_attach_render(struct wlr_output *output,
return drm_surface_make_current(&conn->crtc->primary->surf, buffer_age); return drm_surface_make_current(&conn->crtc->primary->surf, buffer_age);
} }
static void drm_plane_set_committed(struct wlr_drm_plane *plane) {
drm_fb_move(&plane->queued_fb, &plane->pending_fb);
struct wlr_buffer *queued = plane->queued_fb.wlr_buf;
if (queued != NULL) {
wlr_swapchain_set_buffer_submitted(plane->surf.swapchain, queued);
}
}
static bool drm_crtc_commit(struct wlr_drm_connector *conn, uint32_t flags) { static bool drm_crtc_commit(struct wlr_drm_connector *conn, uint32_t flags) {
struct wlr_drm_backend *drm = struct wlr_drm_backend *drm =
get_drm_backend_from_backend(conn->output.backend); get_drm_backend_from_backend(conn->output.backend);
@ -338,9 +348,9 @@ static bool drm_crtc_commit(struct wlr_drm_connector *conn, uint32_t flags) {
bool ok = drm->iface->crtc_commit(drm, conn, flags); bool ok = drm->iface->crtc_commit(drm, conn, flags);
if (ok && !(flags & DRM_MODE_ATOMIC_TEST_ONLY)) { if (ok && !(flags & DRM_MODE_ATOMIC_TEST_ONLY)) {
memcpy(&crtc->current, &crtc->pending, sizeof(struct wlr_drm_crtc_state)); memcpy(&crtc->current, &crtc->pending, sizeof(struct wlr_drm_crtc_state));
drm_fb_move(&crtc->primary->queued_fb, &crtc->primary->pending_fb); drm_plane_set_committed(crtc->primary);
if (crtc->cursor != NULL) { if (crtc->cursor != NULL) {
drm_fb_move(&crtc->cursor->queued_fb, &crtc->cursor->pending_fb); drm_plane_set_committed(crtc->cursor);
} }
} else { } else {
memcpy(&crtc->pending, &crtc->current, sizeof(struct wlr_drm_crtc_state)); memcpy(&crtc->pending, &crtc->current, sizeof(struct wlr_drm_crtc_state));

View file

@ -137,7 +137,7 @@ static void finish_drm_surface(struct wlr_drm_surface *surf) {
bool drm_surface_make_current(struct wlr_drm_surface *surf, bool drm_surface_make_current(struct wlr_drm_surface *surf,
int *buffer_age) { int *buffer_age) {
wlr_buffer_unlock(surf->back_buffer); wlr_buffer_unlock(surf->back_buffer);
surf->back_buffer = wlr_swapchain_acquire(surf->swapchain); surf->back_buffer = wlr_swapchain_acquire(surf->swapchain, buffer_age);
if (surf->back_buffer == NULL) { if (surf->back_buffer == NULL) {
wlr_log(WLR_ERROR, "Failed to acquire swapchain buffer"); wlr_log(WLR_ERROR, "Failed to acquire swapchain buffer");
return false; return false;
@ -151,10 +151,6 @@ bool drm_surface_make_current(struct wlr_drm_surface *surf,
return false; return false;
} }
// TODO: damage tracking
if (buffer_age != NULL) {
*buffer_age = -1;
}
return true; return true;
} }