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

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