summaryrefslogtreecommitdiff
path: root/src/gallium/winsys
diff options
context:
space:
mode:
authorAsahi Lina <lina@asahilina.net>2022-12-21 00:37:31 +0900
committerAsahi Lina <lina@asahilina.net>2022-12-25 19:23:27 +0900
commitad4d7ca8332488be8a75aff001f00306a9f6402e (patch)
treea2863b64e2b2ad816bf7a8ee293db2d41e0b5599 /src/gallium/winsys
parent3e568cc6fe4a71a897ec5516d12df6578b11a7e7 (diff)
kmsro: Fix renderonly_scanout BO aliasing
BOs can only have one handle. If renderonly_create_gpu_import_for_resource ends up importing a BO that was already mapped for scanout, it will get the same handle. This leaves us with two renderonly_scanout objects for one handle, and the first one to be destroyed will free it. Import the BO map tracking logic from asahi, to avoid aliasing renderonly_scanout objects. Each actual BO now is only represented by a single object instance, which is reference counted. Fixes KWin full-screen PipeWire capture breaking scanout entirely. Reviewed-by: Lucas Stach <l.stach@pengutronix.de> Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com> Signed-off-by: Asahi Lina <lina@asahilina.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20397>
Diffstat (limited to 'src/gallium/winsys')
-rw-r--r--src/gallium/winsys/kmsro/drm/kmsro_drm_winsys.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/gallium/winsys/kmsro/drm/kmsro_drm_winsys.c b/src/gallium/winsys/kmsro/drm/kmsro_drm_winsys.c
index 3c8a3c4519f..dd26120dcaa 100644
--- a/src/gallium/winsys/kmsro/drm/kmsro_drm_winsys.c
+++ b/src/gallium/winsys/kmsro/drm/kmsro_drm_winsys.c
@@ -44,6 +44,8 @@ static void kmsro_ro_destroy(struct renderonly *ro)
if (ro->gpu_fd >= 0)
close(ro->gpu_fd);
+ util_sparse_array_finish(&ro->bo_map);
+
FREE(ro);
}
@@ -59,6 +61,8 @@ struct pipe_screen *kmsro_drm_screen_create(int fd,
ro->kms_fd = fd;
ro->gpu_fd = -1;
ro->destroy = kmsro_ro_destroy;
+ util_sparse_array_init(&ro->bo_map, sizeof(struct renderonly_scanout), 64);
+ simple_mtx_init(&ro->bo_map_lock, mtx_plain);
#if defined(GALLIUM_VC4)
ro->gpu_fd = drmOpenWithType("vc4", NULL, DRM_NODE_RENDER);