1
0
Fork 0

onscreen/native: Return the correct number of EGL modifiers

g_array_sized_new() creates a new GArray with a preallocated size, but,
after creation, the array length is still zero [1].

Store the modifiers in a EGLuint64KHR array and use g_array_new_take()
to create a new GArray with the correct size.

Because no modifiers were returned, gbm_surface_create() was used
instead gbm_surface_create_with_modifiers() on multi-GPU setups.

[1] https://docs.gtk.org/glib/type_func.Array.sized_new.html

Fixes: aec85281ba ("native/renderer: Retrieve the right modifiers set for each GPU")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3998>
This commit is contained in:
José Expósito 2024-09-02 17:06:24 +02:00 committed by Marge Bot
parent 03d00902fe
commit cf5508bdeb

View file

@ -2019,8 +2019,8 @@ get_supported_egl_modifiers (CoglOnscreen *onscreen,
MetaRenderDevice *render_device;
EGLDisplay egl_display;
EGLint num_modifiers;
GArray *modifiers;
GError *error = NULL;
g_autofree EGLuint64KHR *modifiers = NULL;
g_autoptr (GError) error = NULL;
gboolean ret;
gpu = meta_crtc_get_gpu (META_CRTC (crtc_kms));
@ -2040,22 +2040,20 @@ get_supported_egl_modifiers (CoglOnscreen *onscreen,
if (!ret || num_modifiers == 0)
return NULL;
modifiers = g_array_sized_new (FALSE, FALSE, sizeof (uint64_t),
num_modifiers);
modifiers = g_new (typeof (*modifiers), num_modifiers);
ret = meta_egl_query_dma_buf_modifiers (egl, egl_display,
format, num_modifiers,
(EGLuint64KHR *) modifiers->data, NULL,
modifiers, NULL,
&num_modifiers, &error);
if (!ret)
{
g_warning ("Failed to query DMABUF modifiers: %s", error->message);
g_error_free (error);
g_array_free (modifiers, TRUE);
return NULL;
}
return modifiers;
return g_array_new_take (g_steal_pointer (&modifiers), num_modifiers, FALSE,
sizeof (*modifiers));
}
static GArray *