From 09c8a4c8a3826ebe01d4f3d0e52d21d79e59406b Mon Sep 17 00:00:00 2001 From: Gert-dev Date: Wed, 2 Oct 2024 21:14:45 +0200 Subject: [PATCH] drm-buffer-gbm: Avoid using fixed size for number of planes (cherry picked from commit c4c4b387536d1d2cf26ea1985a1090df43c7c59d) Part-of: Signed-off-by: Mingi Sung --- src/backends/native/meta-drm-buffer-gbm.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/backends/native/meta-drm-buffer-gbm.c b/src/backends/native/meta-drm-buffer-gbm.c index 6c2d8c93a..888b92cb8 100644 --- a/src/backends/native/meta-drm-buffer-gbm.c +++ b/src/backends/native/meta-drm-buffer-gbm.c @@ -248,10 +248,10 @@ meta_drm_buffer_gbm_create_native_blit_image (MetaEgl *egl, unsigned int width; unsigned int height; uint32_t i, n_planes; - uint32_t strides[4] = { 0 }; - uint32_t offsets[4] = { 0 }; - uint64_t modifiers[4] = { 0 }; - int fds[4] = { -1, -1, -1, -1 }; + uint32_t *strides; + uint32_t *offsets; + uint64_t *modifiers; + int *fds; uint32_t format; EGLImageKHR egl_image; gboolean use_modifiers; @@ -269,6 +269,11 @@ meta_drm_buffer_gbm_create_native_blit_image (MetaEgl *egl, format = gbm_bo_get_format (shared_bo); n_planes = gbm_bo_get_plane_count (shared_bo); + fds = g_alloca (sizeof (int) * n_planes); + strides = g_alloca (sizeof (uint32_t) * n_planes); + offsets = g_alloca (sizeof (uint32_t) * n_planes); + modifiers = g_alloca (sizeof (uint64_t) * n_planes); + for (i = 0; i < n_planes; i++) { strides[i] = gbm_bo_get_stride_for_plane (shared_bo, i);