diff options
-rw-r--r-- | backend/drm/drm.c | 10 | ||||
-rw-r--r-- | backend/drm/renderer.c | 23 | ||||
-rw-r--r-- | include/backend/drm/renderer.h | 2 |
3 files changed, 24 insertions, 11 deletions
diff --git a/backend/drm/drm.c b/backend/drm/drm.c index ca23a1b6..15311a18 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -680,22 +680,24 @@ static bool drm_connector_set_cursor(struct wlr_output *output, ret = drmGetCap(drm->fd, DRM_CAP_CURSOR_HEIGHT, &h); h = ret ? 64 : h; - if (!drm->parent) { if (!init_drm_surface(&plane->surf, &drm->renderer, w, h, - drm->renderer.gbm_format, GBM_BO_USE_LINEAR | GBM_BO_USE_SCANOUT)) { + drm->renderer.gbm_format, NULL, + GBM_BO_USE_LINEAR | GBM_BO_USE_SCANOUT)) { wlr_log(WLR_ERROR, "Cannot allocate cursor resources"); return false; } } else { if (!init_drm_surface(&plane->surf, &drm->parent->renderer, w, h, - drm->parent->renderer.gbm_format, GBM_BO_USE_LINEAR)) { + drm->parent->renderer.gbm_format, NULL, + GBM_BO_USE_LINEAR)) { wlr_log(WLR_ERROR, "Cannot allocate cursor resources"); return false; } if (!init_drm_surface(&plane->mgpu_surf, &drm->renderer, w, h, - drm->renderer.gbm_format, GBM_BO_USE_LINEAR | GBM_BO_USE_SCANOUT)) { + drm->renderer.gbm_format, NULL, + GBM_BO_USE_LINEAR | GBM_BO_USE_SCANOUT)) { wlr_log(WLR_ERROR, "Cannot allocate cursor resources"); return false; } diff --git a/backend/drm/renderer.c b/backend/drm/renderer.c index d8b30974..f25ce247 100644 --- a/backend/drm/renderer.c +++ b/backend/drm/renderer.c @@ -62,7 +62,7 @@ void finish_drm_renderer(struct wlr_drm_renderer *renderer) { bool init_drm_surface(struct wlr_drm_surface *surf, struct wlr_drm_renderer *renderer, uint32_t width, uint32_t height, - uint32_t format, uint32_t flags) { + uint32_t format, struct wlr_drm_format_set *set, uint32_t flags) { if (surf->width == width && surf->height == height) { return true; } @@ -84,8 +84,19 @@ bool init_drm_surface(struct wlr_drm_surface *surf, } wlr_egl_destroy_surface(&surf->renderer->egl, surf->egl); - surf->gbm = gbm_surface_create(renderer->gbm, width, height, - format, GBM_BO_USE_RENDERING | flags); + if (!(flags & GBM_BO_USE_LINEAR) && set != NULL) { + const struct wlr_drm_format *drm_format = + wlr_drm_format_set_get(set, format); + if (drm_format != NULL) { + surf->gbm = gbm_surface_create_with_modifiers(renderer->gbm, + width, height, format, drm_format->modifiers, drm_format->len); + } + } + + if (surf->gbm == NULL) { + surf->gbm = gbm_surface_create(renderer->gbm, width, height, + format, GBM_BO_USE_RENDERING | flags); + } if (!surf->gbm) { wlr_log_errno(WLR_ERROR, "Failed to create GBM surface"); goto error_zero; @@ -279,16 +290,16 @@ bool init_drm_plane_surfaces(struct wlr_drm_plane *plane, uint32_t format) { if (!drm->parent) { return init_drm_surface(&plane->surf, &drm->renderer, width, height, - format, GBM_BO_USE_SCANOUT); + format, &plane->formats, GBM_BO_USE_SCANOUT); } if (!init_drm_surface(&plane->surf, &drm->parent->renderer, - width, height, format, GBM_BO_USE_LINEAR)) { + width, height, format, NULL, GBM_BO_USE_LINEAR)) { return false; } if (!init_drm_surface(&plane->mgpu_surf, &drm->renderer, - width, height, format, GBM_BO_USE_SCANOUT)) { + width, height, format, &plane->formats, GBM_BO_USE_SCANOUT)) { finish_drm_surface(&plane->surf); return false; } diff --git a/include/backend/drm/renderer.h b/include/backend/drm/renderer.h index 93b8da7c..1b1f1243 100644 --- a/include/backend/drm/renderer.h +++ b/include/backend/drm/renderer.h @@ -40,7 +40,7 @@ void finish_drm_renderer(struct wlr_drm_renderer *renderer); bool init_drm_surface(struct wlr_drm_surface *surf, struct wlr_drm_renderer *renderer, uint32_t width, uint32_t height, - uint32_t format, uint32_t flags); + uint32_t format, struct wlr_drm_format_set *set, uint32_t flags); bool init_drm_plane_surfaces(struct wlr_drm_plane *plane, struct wlr_drm_backend *drm, int32_t width, uint32_t height, |