From 63fabecee2fd43f49488f5834d8715121366b434 Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Thu, 7 Nov 2024 14:45:23 +0100 Subject: [PATCH] backend/wayland: Account for shm buffer offset If we are trying directly scan-out a shm buffer, we create a temporary buffer pool to instantiate a wl_buffer from, created in accordance to our buffers size. If the buffer has an offset, it will end up out of bounds of the created pool. Extend the temporary pool by the buffer offset to compensate. Matching the original pool size does matter unless we want to optimize away the temporary pool to reduce mappings in the parent compositor. --- backend/wayland/output.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/wayland/output.c b/backend/wayland/output.c index 5b8dfb0f2..d09b74352 100644 --- a/backend/wayland/output.c +++ b/backend/wayland/output.c @@ -197,7 +197,7 @@ static struct wl_buffer *import_shm(struct wlr_wl_backend *wl, struct wlr_shm_attributes *shm) { enum wl_shm_format wl_shm_format = convert_drm_format_to_wl_shm(shm->format); uint32_t size = shm->stride * shm->height; - struct wl_shm_pool *pool = wl_shm_create_pool(wl->shm, shm->fd, size); + struct wl_shm_pool *pool = wl_shm_create_pool(wl->shm, shm->fd, shm->offset + size); if (pool == NULL) { return NULL; }