aboutsummaryrefslogtreecommitdiff
path: root/backend/drm
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2020-12-14 19:50:13 +0100
committerSimon Ser <contact@emersion.fr>2020-12-22 15:53:10 +0100
commit83925f04c36c7c189341800d3303b8262a0de9bc (patch)
treedf8404b6852a2a4c53f2218b4b8456c939138125 /backend/drm
parent55b02f753f6bdc004ac2f7af27f89d82946b8701 (diff)
backend/drm: don't save texture in gbm_bo user data
The GBM BO is destroyed when released anyways.
Diffstat (limited to 'backend/drm')
-rw-r--r--backend/drm/renderer.c44
1 files changed, 14 insertions, 30 deletions
diff --git a/backend/drm/renderer.c b/backend/drm/renderer.c
index 61b838bc..a3b2e812 100644
--- a/backend/drm/renderer.c
+++ b/backend/drm/renderer.c
@@ -169,33 +169,6 @@ bool export_drm_bo(struct gbm_bo *bo, struct wlr_dmabuf_attributes *attribs) {
return true;
}
-static void free_tex(struct gbm_bo *bo, void *data) {
- struct wlr_texture *tex = data;
- wlr_texture_destroy(tex);
-}
-
-static struct wlr_texture *get_tex_for_bo(struct wlr_drm_renderer *renderer,
- struct gbm_bo *bo) {
- struct wlr_texture *tex = gbm_bo_get_user_data(bo);
- if (tex) {
- return tex;
- }
-
- struct wlr_dmabuf_attributes attribs;
- if (!export_drm_bo(bo, &attribs)) {
- return NULL;
- }
-
- tex = wlr_texture_from_dmabuf(renderer->wlr_rend, &attribs);
- if (tex) {
- gbm_bo_set_user_data(bo, tex, free_tex);
- }
-
- wlr_dmabuf_attributes_finish(&attribs);
-
- return tex;
-}
-
void drm_plane_finish_surface(struct wlr_drm_plane *plane) {
if (!plane) {
return;
@@ -434,19 +407,26 @@ struct gbm_bo *drm_fb_acquire(struct wlr_drm_fb *fb, struct wlr_drm_backend *drm
/* Perform copy across GPUs */
- struct wlr_texture *tex = get_tex_for_bo(mgpu->renderer, fb->bo);
- if (!tex) {
+ struct wlr_renderer *renderer = mgpu->renderer->wlr_rend;
+
+ struct wlr_dmabuf_attributes attribs = {0};
+ if (!wlr_buffer_get_dmabuf(fb->wlr_buf, &attribs)) {
+ return NULL;
+ }
+
+ struct wlr_texture *tex = wlr_texture_from_dmabuf(renderer, &attribs);
+ if (tex == NULL) {
return NULL;
}
if (!drm_surface_make_current(mgpu, NULL)) {
+ wlr_texture_destroy(tex);
return NULL;
}
float mat[9];
wlr_matrix_projection(mat, 1, 1, WL_OUTPUT_TRANSFORM_NORMAL);
- struct wlr_renderer *renderer = mgpu->renderer->wlr_rend;
wlr_renderer_begin(renderer, mgpu->width, mgpu->height);
wlr_renderer_clear(renderer, (float[]){ 0.0, 0.0, 0.0, 0.0 });
wlr_render_texture_with_matrix(renderer, tex, mat, 1.0f);
@@ -457,8 +437,12 @@ struct gbm_bo *drm_fb_acquire(struct wlr_drm_fb *fb, struct wlr_drm_backend *drm
.wlr_buf = fb->mgpu_wlr_buf,
};
if (!drm_fb_lock_surface(&mgpu_fb, mgpu)) {
+ wlr_texture_destroy(tex);
return false;
}
+
+ wlr_texture_destroy(tex);
+
fb->mgpu_bo = mgpu_fb.bo;
fb->mgpu_wlr_buf = mgpu_fb.wlr_buf;
fb->mgpu_surf = mgpu;