kms/device: Add flag to disable sending DRM modifiers to clients

So far the new flag can only be set via the new environment variable
MUTTER_DEBUG_SEND_KMS_MODIFIERS, and doesn't have any effect yet.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2637>
This commit is contained in:
Michel Dänzer 2022-09-20 18:54:32 +02:00 committed by Marge Bot
parent 6601c3b02a
commit 00ffe0b454
3 changed files with 35 additions and 9 deletions

View File

@ -64,6 +64,7 @@ typedef enum _MetaKmsDeviceFlag
META_KMS_DEVICE_FLAG_NO_MODE_SETTING = 1 << 4, META_KMS_DEVICE_FLAG_NO_MODE_SETTING = 1 << 4,
META_KMS_DEVICE_FLAG_HAS_ADDFB2 = 1 << 5, META_KMS_DEVICE_FLAG_HAS_ADDFB2 = 1 << 5,
META_KMS_DEVICE_FLAG_FORCE_LEGACY = 1 << 6, META_KMS_DEVICE_FLAG_FORCE_LEGACY = 1 << 6,
META_KMS_DEVICE_FLAG_DISABLE_CLIENT_MODIFIERS = 1 << 7,
} MetaKmsDeviceFlag; } MetaKmsDeviceFlag;
typedef enum _MetaKmsResourceChanges typedef enum _MetaKmsResourceChanges

View File

@ -87,6 +87,7 @@ struct _MetaRendererNative
MetaGles3 *gles3; MetaGles3 *gles3;
gboolean use_modifiers; gboolean use_modifiers;
gboolean send_modifiers;
GHashTable *gpu_datas; GHashTable *gpu_datas;
@ -247,6 +248,12 @@ meta_renderer_native_get_egl (MetaRendererNative *renderer_native)
return meta_backend_get_egl (meta_renderer_get_backend (renderer)); return meta_backend_get_egl (meta_renderer_get_backend (renderer));
} }
gboolean
meta_renderer_native_send_modifiers (MetaRendererNative *renderer_native)
{
return renderer_native->send_modifiers;
}
gboolean gboolean
meta_renderer_native_use_modifiers (MetaRendererNative *renderer_native) meta_renderer_native_use_modifiers (MetaRendererNative *renderer_native)
{ {
@ -2033,7 +2040,9 @@ meta_renderer_native_initable_init (GInitable *initable,
gpus = meta_backend_get_gpus (backend); gpus = meta_backend_get_gpus (backend);
if (gpus) if (gpus)
{ {
const char *use_kms_modifiers_debug_env; MetaKmsDevice *kms_device;
MetaKmsDeviceFlag flags;
const char *kms_modifiers_debug_env;
for (l = gpus; l; l = l->next) for (l = gpus; l; l = l->next)
{ {
@ -2049,19 +2058,17 @@ meta_renderer_native_initable_init (GInitable *initable,
if (!renderer_native->primary_gpu_kms) if (!renderer_native->primary_gpu_kms)
return FALSE; return FALSE;
use_kms_modifiers_debug_env = g_getenv ("MUTTER_DEBUG_USE_KMS_MODIFIERS"); kms_device = meta_gpu_kms_get_kms_device (renderer_native->primary_gpu_kms);
if (use_kms_modifiers_debug_env) flags = meta_kms_device_get_flags (kms_device);
kms_modifiers_debug_env = g_getenv ("MUTTER_DEBUG_USE_KMS_MODIFIERS");
if (kms_modifiers_debug_env)
{ {
renderer_native->use_modifiers = renderer_native->use_modifiers =
g_strcmp0 (use_kms_modifiers_debug_env, "1") == 0; g_strcmp0 (kms_modifiers_debug_env, "1") == 0;
} }
else else
{ {
MetaKmsDevice *kms_device =
meta_gpu_kms_get_kms_device (renderer_native->primary_gpu_kms);
MetaKmsDeviceFlag flags;
flags = meta_kms_device_get_flags (kms_device);
renderer_native->use_modifiers = renderer_native->use_modifiers =
!(flags & META_KMS_DEVICE_FLAG_DISABLE_MODIFIERS) && !(flags & META_KMS_DEVICE_FLAG_DISABLE_MODIFIERS) &&
flags & META_KMS_DEVICE_FLAG_HAS_ADDFB2; flags & META_KMS_DEVICE_FLAG_HAS_ADDFB2;
@ -2069,6 +2076,22 @@ meta_renderer_native_initable_init (GInitable *initable,
meta_topic (META_DEBUG_KMS, "Usage of KMS modifiers is %s", meta_topic (META_DEBUG_KMS, "Usage of KMS modifiers is %s",
renderer_native->use_modifiers ? "enabled" : "disabled"); renderer_native->use_modifiers ? "enabled" : "disabled");
kms_modifiers_debug_env = g_getenv ("MUTTER_DEBUG_SEND_KMS_MODIFIERS");
if (kms_modifiers_debug_env)
{
renderer_native->send_modifiers =
g_strcmp0 (kms_modifiers_debug_env, "1") == 0;
}
else
{
renderer_native->send_modifiers =
!(flags & META_KMS_DEVICE_FLAG_DISABLE_CLIENT_MODIFIERS) &&
flags & META_KMS_DEVICE_FLAG_HAS_ADDFB2;
}
meta_topic (META_DEBUG_KMS, "Sending KMS modifiers to clients is %s",
renderer_native->send_modifiers ? "enabled" : "disabled");
} }
else else
{ {

View File

@ -66,6 +66,8 @@ void meta_renderer_native_finish_frame (MetaRendererNative *renderer_native,
void meta_renderer_native_reset_modes (MetaRendererNative *renderer_native); void meta_renderer_native_reset_modes (MetaRendererNative *renderer_native);
gboolean meta_renderer_native_send_modifiers (MetaRendererNative *renderer_native);
gboolean meta_renderer_native_use_modifiers (MetaRendererNative *renderer_native); gboolean meta_renderer_native_use_modifiers (MetaRendererNative *renderer_native);
MetaRendererNativeMode meta_renderer_native_get_mode (MetaRendererNative *renderer_native); MetaRendererNativeMode meta_renderer_native_get_mode (MetaRendererNative *renderer_native);