mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-12-23 02:19:49 +01:00
backend/drm: use modifiers for our GBM buffers
This commit is contained in:
parent
11bf87d678
commit
2bdd1d0896
3 changed files with 24 additions and 11 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue