mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 01:20:42 -05:00
crtc/kms: Add fallback primary plane formats
This avoids having to hardcode the same fallbacks elsewhere multiple times when determining what formats might be suitable for a set of CRTCs. The formats_modifiers hash table is now guaranteed to be populated with at least something, so future code will not need to handle it being empty. The hardcoded fallback formats are a minimal set probably supported by most hardware. XRGB8888 is the format that, according to ancient lore, all DRM devices should support, especially if they don't have the capability to advertise otherwise. Mutter also hardcodes XRGB8888 as the GBM surface format, so it is already required on primary GPUs. XBGR8888 matches the most common OpenGL format, sans alpha channel since scanout hardware has not traditionally supported alpha. XBGR8888 is here also because Mutter hardcodes that format for secondary GPU outputs when using the CPU copy path. https://gitlab.gnome.org/GNOME/mutter/merge_requests/341
This commit is contained in:
parent
0789c3fb9f
commit
8a0d0ce987
@ -211,6 +211,19 @@ free_modifier_array (GArray *array)
|
||||
g_array_free (array, TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* In case the DRM driver does not expose a format list for the
|
||||
* primary plane (does not support universal planes nor
|
||||
* IN_FORMATS property), hardcode something that is probably supported.
|
||||
*/
|
||||
static const uint32_t drm_default_formats[] =
|
||||
{
|
||||
DRM_FORMAT_XRGB8888 /* The format everything should always support by convention */,
|
||||
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
||||
DRM_FORMAT_XBGR8888 /* OpenGL GL_RGBA, GL_UNSIGNED_BYTE format, hopefully supported */
|
||||
#endif
|
||||
};
|
||||
|
||||
static void
|
||||
set_formats_from_array (MetaCrtc *crtc,
|
||||
const uint32_t *formats,
|
||||
@ -407,6 +420,14 @@ init_crtc_rotations (MetaCrtc *crtc,
|
||||
crtc->all_transforms |= crtc_kms->all_hw_transforms;
|
||||
|
||||
drmModeFreePlaneResources (planes);
|
||||
|
||||
/* final formats fallback to something hardcoded */
|
||||
if (g_hash_table_size (crtc_kms->formats_modifiers) == 0)
|
||||
{
|
||||
set_formats_from_array (crtc,
|
||||
drm_default_formats,
|
||||
G_N_ELEMENTS (drm_default_formats));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user