kathenas / rpms / mutter

Forked from rpms/mutter 5 years ago
Clone

Blame SOURCES/0001-renderer-Add-API-to-check-whether-renderer-is-hardwa.patch

99364f
From d107b52939ca0acb1f8dacf1275278edba64eebe Mon Sep 17 00:00:00 2001
99364f
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
99364f
Date: Tue, 1 Oct 2019 11:53:57 +0200
99364f
Subject: [PATCH] renderer: Add API to check whether renderer is hardware
99364f
 accelerated
99364f
99364f
Also expose an introspected variant via the MetaBackend.
99364f
99364f
https://gitlab.gnome.org/GNOME/mutter/merge_requests/838
99364f
---
99364f
 src/backends/meta-backend.c  | 15 +++++++++++++++
99364f
 src/backends/meta-renderer.c | 27 +++++++++++++++++++++++++++
99364f
 src/backends/meta-renderer.h |  2 ++
99364f
 src/meta/meta-backend.h      |  3 +++
99364f
 4 files changed, 47 insertions(+)
99364f
99364f
diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c
99364f
index 72cfbdaf3..e61181f9a 100644
99364f
--- a/src/backends/meta-backend.c
99364f
+++ b/src/backends/meta-backend.c
99364f
@@ -985,6 +985,21 @@ meta_backend_get_remote_access_controller (MetaBackend *backend)
99364f
 #endif
99364f
 }
99364f
 
99364f
+/**
99364f
+ * meta_backend_is_rendering_hardware_accelerated:
99364f
+ * @backend: A #MetaBackend
99364f
+ *
99364f
+ * Returns: %TRUE if the rendering is hardware accelerated, otherwise
99364f
+ * %FALSE.
99364f
+ */
99364f
+gboolean
99364f
+meta_backend_is_rendering_hardware_accelerated (MetaBackend *backend)
99364f
+{
99364f
+  MetaRenderer *renderer = meta_backend_get_renderer (backend);
99364f
+
99364f
+  return meta_renderer_is_hardware_accelerated (renderer);
99364f
+}
99364f
+
99364f
 /**
99364f
  * meta_backend_grab_device: (skip)
99364f
  */
99364f
diff --git a/src/backends/meta-renderer.c b/src/backends/meta-renderer.c
99364f
index 87ba9f9f0..470220fc8 100644
99364f
--- a/src/backends/meta-renderer.c
99364f
+++ b/src/backends/meta-renderer.c
99364f
@@ -166,6 +166,33 @@ meta_renderer_get_view_from_logical_monitor (MetaRenderer       *renderer,
99364f
   return NULL;
99364f
 }
99364f
 
99364f
+gboolean
99364f
+meta_renderer_is_hardware_accelerated (MetaRenderer *renderer)
99364f
+{
99364f
+  MetaRendererPrivate *priv = meta_renderer_get_instance_private (renderer);
99364f
+  MetaBackend *backend = meta_get_backend ();
99364f
+  ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
99364f
+  CoglContext *cogl_context =
99364f
+    clutter_backend_get_cogl_context (clutter_backend);
99364f
+  CoglGpuInfo *info = &cogl_context->gpu;
99364f
+
99364f
+  switch (info->architecture)
99364f
+    {
99364f
+    case COGL_GPU_INFO_ARCHITECTURE_UNKNOWN:
99364f
+    case COGL_GPU_INFO_ARCHITECTURE_SANDYBRIDGE:
99364f
+    case COGL_GPU_INFO_ARCHITECTURE_SGX:
99364f
+    case COGL_GPU_INFO_ARCHITECTURE_MALI:
99364f
+      return TRUE;
99364f
+    case COGL_GPU_INFO_ARCHITECTURE_LLVMPIPE:
99364f
+    case COGL_GPU_INFO_ARCHITECTURE_SOFTPIPE:
99364f
+    case COGL_GPU_INFO_ARCHITECTURE_SWRAST:
99364f
+      return FALSE;
99364f
+    }
99364f
+
99364f
+  g_assert_not_reached ();
99364f
+  return FALSE;
99364f
+}
99364f
+
99364f
 static void
99364f
 meta_renderer_finalize (GObject *object)
99364f
 {
99364f
diff --git a/src/backends/meta-renderer.h b/src/backends/meta-renderer.h
99364f
index 478baee91..97bf36860 100644
99364f
--- a/src/backends/meta-renderer.h
99364f
+++ b/src/backends/meta-renderer.h
99364f
@@ -59,4 +59,6 @@ GList * meta_renderer_get_views (MetaRenderer *renderer);
99364f
 MetaRendererView * meta_renderer_get_view_from_logical_monitor (MetaRenderer       *renderer,
99364f
                                                                 MetaLogicalMonitor *logical_monitor);
99364f
 
99364f
+gboolean meta_renderer_is_hardware_accelerated (MetaRenderer *renderer);
99364f
+
99364f
 #endif /* META_RENDERER_H */
99364f
diff --git a/src/meta/meta-backend.h b/src/meta/meta-backend.h
99364f
index aaa6aae97..8edc0bf2c 100644
99364f
--- a/src/meta/meta-backend.h
99364f
+++ b/src/meta/meta-backend.h
99364f
@@ -64,6 +64,9 @@ MetaSettings *meta_backend_get_settings (MetaBackend *backend);
99364f
 META_EXPORT
99364f
 MetaRemoteAccessController * meta_backend_get_remote_access_controller (MetaBackend *backend);
99364f
 
99364f
+META_EXPORT
99364f
+gboolean meta_backend_is_rendering_hardware_accelerated (MetaBackend *backend);
99364f
+
99364f
 META_EXPORT
99364f
 void meta_clutter_init (void);
99364f
 
99364f
-- 
99364f
2.26.2
99364f