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> (cherry picked from commitcf5508bdeb
)
This commit is contained in:
parent
4b622fbda8
commit
0fab816982
1 changed files with 6 additions and 8 deletions
|
@ -2044,8 +2044,8 @@ get_supported_egl_modifiers (CoglOnscreen *onscreen,
|
||||||
MetaRenderDevice *render_device;
|
MetaRenderDevice *render_device;
|
||||||
EGLDisplay egl_display;
|
EGLDisplay egl_display;
|
||||||
EGLint num_modifiers;
|
EGLint num_modifiers;
|
||||||
GArray *modifiers;
|
g_autofree EGLuint64KHR *modifiers = NULL;
|
||||||
GError *error = NULL;
|
g_autoptr (GError) error = NULL;
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
|
|
||||||
gpu = meta_crtc_get_gpu (META_CRTC (crtc_kms));
|
gpu = meta_crtc_get_gpu (META_CRTC (crtc_kms));
|
||||||
|
@ -2065,22 +2065,20 @@ get_supported_egl_modifiers (CoglOnscreen *onscreen,
|
||||||
if (!ret || num_modifiers == 0)
|
if (!ret || num_modifiers == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
modifiers = g_array_sized_new (FALSE, FALSE, sizeof (uint64_t),
|
modifiers = g_new (typeof (*modifiers), num_modifiers);
|
||||||
num_modifiers);
|
|
||||||
ret = meta_egl_query_dma_buf_modifiers (egl, egl_display,
|
ret = meta_egl_query_dma_buf_modifiers (egl, egl_display,
|
||||||
format, num_modifiers,
|
format, num_modifiers,
|
||||||
(EGLuint64KHR *) modifiers->data, NULL,
|
modifiers, NULL,
|
||||||
&num_modifiers, &error);
|
&num_modifiers, &error);
|
||||||
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
g_warning ("Failed to query DMABUF modifiers: %s", error->message);
|
g_warning ("Failed to query DMABUF modifiers: %s", error->message);
|
||||||
g_error_free (error);
|
|
||||||
g_array_free (modifiers, TRUE);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return modifiers;
|
return g_array_new_take (g_steal_pointer (&modifiers), num_modifiers, FALSE,
|
||||||
|
sizeof (*modifiers));
|
||||||
}
|
}
|
||||||
|
|
||||||
static GArray *
|
static GArray *
|
||||||
|
|
Loading…
Reference in a new issue