mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-02 11:55:59 +01:00
Copy cursor surface to secondary gpu if necessary
This commit is contained in:
parent
72c76b128e
commit
bc048b22fb
2 changed files with 24 additions and 7 deletions
|
@ -636,14 +636,26 @@ static bool drm_connector_set_cursor(struct wlr_output *output,
|
||||||
ret = drmGetCap(drm->fd, DRM_CAP_CURSOR_HEIGHT, &h);
|
ret = drmGetCap(drm->fd, DRM_CAP_CURSOR_HEIGHT, &h);
|
||||||
h = ret ? 64 : h;
|
h = ret ? 64 : h;
|
||||||
|
|
||||||
struct wlr_drm_renderer *renderer =
|
|
||||||
drm->parent ? &drm->parent->renderer : &drm->renderer;
|
|
||||||
|
|
||||||
if (!init_drm_surface(&plane->surf, renderer, w, h,
|
if (!drm->parent) {
|
||||||
renderer->gbm_format, GBM_BO_USE_LINEAR | GBM_BO_USE_SCANOUT)) {
|
if (!init_drm_surface(&plane->surf, &drm->renderer, w, h,
|
||||||
|
drm->renderer.gbm_format, GBM_BO_USE_LINEAR | GBM_BO_USE_SCANOUT)) {
|
||||||
wlr_log(WLR_ERROR, "Cannot allocate cursor resources");
|
wlr_log(WLR_ERROR, "Cannot allocate cursor resources");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (!init_drm_surface(&plane->surf, &drm->parent->renderer, w, h,
|
||||||
|
drm->parent->renderer.gbm_format, 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)) {
|
||||||
|
wlr_log(WLR_ERROR, "Cannot allocate cursor resources");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_matrix_projection(plane->matrix, plane->surf.width,
|
wlr_matrix_projection(plane->matrix, plane->surf.width,
|
||||||
|
@ -712,6 +724,11 @@ static bool drm_connector_set_cursor(struct wlr_output *output,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct gbm_bo *bo = plane->cursor_enabled ? plane->surf.back : NULL;
|
struct gbm_bo *bo = plane->cursor_enabled ? plane->surf.back : NULL;
|
||||||
|
|
||||||
|
if (drm->parent) {
|
||||||
|
bo = copy_drm_surface_mgpu(&plane->mgpu_surf, plane->surf.back);
|
||||||
|
}
|
||||||
|
|
||||||
bool ok = drm->iface->crtc_set_cursor(drm, crtc, bo);
|
bool ok = drm->iface->crtc_set_cursor(drm, crtc, bo);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
wlr_output_update_needs_swap(output);
|
wlr_output_update_needs_swap(output);
|
||||||
|
|
|
@ -230,7 +230,7 @@ struct gbm_bo *copy_drm_surface_mgpu(struct wlr_drm_surface *dest,
|
||||||
|
|
||||||
struct wlr_renderer *renderer = dest->renderer->wlr_rend;
|
struct wlr_renderer *renderer = dest->renderer->wlr_rend;
|
||||||
wlr_renderer_begin(renderer, dest->width, dest->height);
|
wlr_renderer_begin(renderer, dest->width, dest->height);
|
||||||
wlr_renderer_clear(renderer, (float[]){ 0.0, 0.0, 0.0, 1.0 });
|
wlr_renderer_clear(renderer, (float[]){ 0.0, 0.0, 0.0, 0.0 });
|
||||||
wlr_render_texture_with_matrix(renderer, tex, mat, 1.0f);
|
wlr_render_texture_with_matrix(renderer, tex, mat, 1.0f);
|
||||||
wlr_renderer_end(renderer);
|
wlr_renderer_end(renderer);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue