mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 08:00:42 -05:00
backends/native: Move primary_gpu into MetaRendererNative
Make the choosing and identity of the primary GPU an internal detail to the native renderer. MonitorManagerKms did not need it for anything. The primary GPU logic remains unchanged. This allows follow-up patches to change how the renderer chooses the primary GPU. It will be easier for the renderer to use private information for choosing. https://gitlab.gnome.org/GNOME/mutter/merge_requests/271
This commit is contained in:
parent
1def099047
commit
9182c8b801
@ -84,8 +84,6 @@ struct _MetaMonitorManagerKms
|
|||||||
{
|
{
|
||||||
MetaMonitorManager parent_instance;
|
MetaMonitorManager parent_instance;
|
||||||
|
|
||||||
MetaGpuKms *primary_gpu;
|
|
||||||
|
|
||||||
GUdevClient *udev;
|
GUdevClient *udev;
|
||||||
guint uevent_handler_id;
|
guint uevent_handler_id;
|
||||||
};
|
};
|
||||||
@ -580,12 +578,6 @@ meta_monitor_manager_kms_get_default_layout_mode (MetaMonitorManager *manager)
|
|||||||
return META_LOGICAL_MONITOR_LAYOUT_MODE_PHYSICAL;
|
return META_LOGICAL_MONITOR_LAYOUT_MODE_PHYSICAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
MetaGpuKms *
|
|
||||||
meta_monitor_manager_kms_get_primary_gpu (MetaMonitorManagerKms *manager_kms)
|
|
||||||
{
|
|
||||||
return manager_kms->primary_gpu;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
init_gpus (MetaMonitorManagerKms *manager_kms,
|
init_gpus (MetaMonitorManagerKms *manager_kms,
|
||||||
GError **error)
|
GError **error)
|
||||||
@ -692,37 +684,6 @@ init_gpus (MetaMonitorManagerKms *manager_kms,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static MetaGpuKms *
|
|
||||||
choose_primary_gpu (MetaMonitorManagerKms *manager_kms)
|
|
||||||
{
|
|
||||||
MetaMonitorManager *manager = META_MONITOR_MANAGER (manager_kms);
|
|
||||||
GList *gpus = meta_monitor_manager_get_gpus (manager);
|
|
||||||
GList *l;
|
|
||||||
|
|
||||||
g_return_val_if_fail (gpus, NULL);
|
|
||||||
|
|
||||||
/* Prefer a platform device */
|
|
||||||
for (l = gpus; l; l = l->next)
|
|
||||||
{
|
|
||||||
MetaGpuKms *gpu_kms = META_GPU_KMS (l->data);
|
|
||||||
|
|
||||||
if (meta_gpu_kms_is_platform_device (gpu_kms))
|
|
||||||
return gpu_kms;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Otherwise a device we booted with */
|
|
||||||
for (l = gpus; l; l = l->next)
|
|
||||||
{
|
|
||||||
MetaGpuKms *gpu_kms = META_GPU_KMS (l->data);
|
|
||||||
|
|
||||||
if (meta_gpu_kms_is_boot_vga (gpu_kms))
|
|
||||||
return gpu_kms;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Lastly, just pick the first device */
|
|
||||||
return META_GPU_KMS (gpus->data);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
meta_monitor_manager_kms_initable_init (GInitable *initable,
|
meta_monitor_manager_kms_initable_init (GInitable *initable,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
@ -743,8 +704,6 @@ meta_monitor_manager_kms_initable_init (GInitable *initable,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
manager_kms->primary_gpu = choose_primary_gpu (manager_kms);
|
|
||||||
|
|
||||||
can_have_outputs = FALSE;
|
can_have_outputs = FALSE;
|
||||||
for (l = meta_monitor_manager_get_gpus (manager); l; l = l->next)
|
for (l = meta_monitor_manager_get_gpus (manager); l; l = l->next)
|
||||||
{
|
{
|
||||||
|
@ -35,8 +35,6 @@ G_DECLARE_FINAL_TYPE (MetaMonitorManagerKms, meta_monitor_manager_kms,
|
|||||||
META, MONITOR_MANAGER_KMS,
|
META, MONITOR_MANAGER_KMS,
|
||||||
MetaMonitorManager)
|
MetaMonitorManager)
|
||||||
|
|
||||||
MetaGpuKms * meta_monitor_manager_kms_get_primary_gpu (MetaMonitorManagerKms *manager_kms);
|
|
||||||
|
|
||||||
void meta_monitor_manager_kms_pause (MetaMonitorManagerKms *manager_kms);
|
void meta_monitor_manager_kms_pause (MetaMonitorManagerKms *manager_kms);
|
||||||
|
|
||||||
void meta_monitor_manager_kms_resume (MetaMonitorManagerKms *manager_kms);
|
void meta_monitor_manager_kms_resume (MetaMonitorManagerKms *manager_kms);
|
||||||
|
@ -195,6 +195,7 @@ struct _MetaRendererNative
|
|||||||
MetaRenderer parent;
|
MetaRenderer parent;
|
||||||
|
|
||||||
MetaMonitorManagerKms *monitor_manager_kms;
|
MetaMonitorManagerKms *monitor_manager_kms;
|
||||||
|
MetaGpuKms *primary_gpu_kms;
|
||||||
MetaGles3 *gles3;
|
MetaGles3 *gles3;
|
||||||
|
|
||||||
gboolean use_modifiers;
|
gboolean use_modifiers;
|
||||||
@ -2857,12 +2858,8 @@ static CoglRenderer *
|
|||||||
meta_renderer_native_create_cogl_renderer (MetaRenderer *renderer)
|
meta_renderer_native_create_cogl_renderer (MetaRenderer *renderer)
|
||||||
{
|
{
|
||||||
MetaRendererNative *renderer_native = META_RENDERER_NATIVE (renderer);
|
MetaRendererNative *renderer_native = META_RENDERER_NATIVE (renderer);
|
||||||
MetaMonitorManagerKms *monitor_manager_kms =
|
|
||||||
renderer_native->monitor_manager_kms;
|
|
||||||
MetaGpuKms *primary_gpu =
|
|
||||||
meta_monitor_manager_kms_get_primary_gpu (monitor_manager_kms);
|
|
||||||
|
|
||||||
return create_cogl_renderer_for_gpu (primary_gpu);
|
return create_cogl_renderer_for_gpu (renderer_native->primary_gpu_kms);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -2965,14 +2962,11 @@ meta_renderer_native_create_view (MetaRenderer *renderer,
|
|||||||
MetaLogicalMonitor *logical_monitor)
|
MetaLogicalMonitor *logical_monitor)
|
||||||
{
|
{
|
||||||
MetaRendererNative *renderer_native = META_RENDERER_NATIVE (renderer);
|
MetaRendererNative *renderer_native = META_RENDERER_NATIVE (renderer);
|
||||||
MetaMonitorManagerKms *monitor_manager_kms =
|
|
||||||
renderer_native->monitor_manager_kms;
|
|
||||||
MetaMonitorManager *monitor_manager =
|
MetaMonitorManager *monitor_manager =
|
||||||
META_MONITOR_MANAGER (monitor_manager_kms);
|
META_MONITOR_MANAGER (renderer_native->monitor_manager_kms);
|
||||||
CoglContext *cogl_context =
|
CoglContext *cogl_context =
|
||||||
cogl_context_from_renderer_native (renderer_native);
|
cogl_context_from_renderer_native (renderer_native);
|
||||||
CoglDisplay *cogl_display = cogl_context_get_display (cogl_context);
|
CoglDisplay *cogl_display = cogl_context_get_display (cogl_context);
|
||||||
MetaGpuKms *primary_gpu;
|
|
||||||
CoglDisplayEGL *cogl_display_egl;
|
CoglDisplayEGL *cogl_display_egl;
|
||||||
CoglOnscreenEGL *onscreen_egl;
|
CoglOnscreenEGL *onscreen_egl;
|
||||||
MetaMonitorTransform view_transform;
|
MetaMonitorTransform view_transform;
|
||||||
@ -2993,9 +2987,8 @@ meta_renderer_native_create_view (MetaRenderer *renderer,
|
|||||||
width = roundf (logical_monitor->rect.width * scale);
|
width = roundf (logical_monitor->rect.width * scale);
|
||||||
height = roundf (logical_monitor->rect.height * scale);
|
height = roundf (logical_monitor->rect.height * scale);
|
||||||
|
|
||||||
primary_gpu = meta_monitor_manager_kms_get_primary_gpu (monitor_manager_kms);
|
|
||||||
onscreen = meta_renderer_native_create_onscreen (renderer_native,
|
onscreen = meta_renderer_native_create_onscreen (renderer_native,
|
||||||
primary_gpu,
|
renderer_native->primary_gpu_kms,
|
||||||
logical_monitor,
|
logical_monitor,
|
||||||
cogl_context,
|
cogl_context,
|
||||||
view_transform,
|
view_transform,
|
||||||
@ -3006,7 +2999,8 @@ meta_renderer_native_create_view (MetaRenderer *renderer,
|
|||||||
g_error ("Failed to allocate onscreen framebuffer: %s", error->message);
|
g_error ("Failed to allocate onscreen framebuffer: %s", error->message);
|
||||||
|
|
||||||
if (view_transform != META_MONITOR_TRANSFORM_NORMAL ||
|
if (view_transform != META_MONITOR_TRANSFORM_NORMAL ||
|
||||||
should_force_shadow_fb (renderer_native, primary_gpu))
|
should_force_shadow_fb (renderer_native,
|
||||||
|
renderer_native->primary_gpu_kms))
|
||||||
{
|
{
|
||||||
offscreen = meta_renderer_native_create_offscreen (renderer_native,
|
offscreen = meta_renderer_native_create_offscreen (renderer_native,
|
||||||
cogl_context,
|
cogl_context,
|
||||||
@ -3283,13 +3277,11 @@ create_renderer_gpu_data_gbm (MetaRendererNative *renderer_native,
|
|||||||
MetaGpuKms *gpu_kms,
|
MetaGpuKms *gpu_kms,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
MetaMonitorManagerKms *monitor_manager_kms;
|
|
||||||
MetaEgl *egl = meta_renderer_native_get_egl (renderer_native);
|
MetaEgl *egl = meta_renderer_native_get_egl (renderer_native);
|
||||||
struct gbm_device *gbm_device;
|
struct gbm_device *gbm_device;
|
||||||
EGLDisplay egl_display;
|
EGLDisplay egl_display;
|
||||||
int kms_fd;
|
int kms_fd;
|
||||||
MetaRendererNativeGpuData *renderer_gpu_data;
|
MetaRendererNativeGpuData *renderer_gpu_data;
|
||||||
MetaGpuKms *primary_gpu;
|
|
||||||
|
|
||||||
if (!meta_egl_has_extensions (egl, EGL_NO_DISPLAY, NULL,
|
if (!meta_egl_has_extensions (egl, EGL_NO_DISPLAY, NULL,
|
||||||
"EGL_MESA_platform_gbm",
|
"EGL_MESA_platform_gbm",
|
||||||
@ -3333,9 +3325,7 @@ create_renderer_gpu_data_gbm (MetaRendererNative *renderer_native,
|
|||||||
renderer_gpu_data->mode = META_RENDERER_NATIVE_MODE_GBM;
|
renderer_gpu_data->mode = META_RENDERER_NATIVE_MODE_GBM;
|
||||||
renderer_gpu_data->egl_display = egl_display;
|
renderer_gpu_data->egl_display = egl_display;
|
||||||
|
|
||||||
monitor_manager_kms = renderer_native->monitor_manager_kms;
|
if (gpu_kms != renderer_native->primary_gpu_kms)
|
||||||
primary_gpu = meta_monitor_manager_kms_get_primary_gpu (monitor_manager_kms);
|
|
||||||
if (gpu_kms != primary_gpu)
|
|
||||||
init_secondary_gpu_data (renderer_gpu_data);
|
init_secondary_gpu_data (renderer_gpu_data);
|
||||||
|
|
||||||
return renderer_gpu_data;
|
return renderer_gpu_data;
|
||||||
@ -3462,17 +3452,13 @@ create_renderer_gpu_data_egl_device (MetaRendererNative *renderer_native,
|
|||||||
MetaGpuKms *gpu_kms,
|
MetaGpuKms *gpu_kms,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
MetaMonitorManagerKms *monitor_manager_kms =
|
|
||||||
renderer_native->monitor_manager_kms;
|
|
||||||
MetaEgl *egl = meta_renderer_native_get_egl (renderer_native);
|
MetaEgl *egl = meta_renderer_native_get_egl (renderer_native);
|
||||||
MetaGpuKms *primary_gpu;
|
|
||||||
char **missing_extensions;
|
char **missing_extensions;
|
||||||
EGLDeviceEXT egl_device;
|
EGLDeviceEXT egl_device;
|
||||||
EGLDisplay egl_display;
|
EGLDisplay egl_display;
|
||||||
MetaRendererNativeGpuData *renderer_gpu_data;
|
MetaRendererNativeGpuData *renderer_gpu_data;
|
||||||
|
|
||||||
primary_gpu = meta_monitor_manager_kms_get_primary_gpu (monitor_manager_kms);
|
if (gpu_kms != renderer_native->primary_gpu)
|
||||||
if (gpu_kms != primary_gpu)
|
|
||||||
{
|
{
|
||||||
g_set_error (error, G_IO_ERROR,
|
g_set_error (error, G_IO_ERROR,
|
||||||
G_IO_ERROR_FAILED,
|
G_IO_ERROR_FAILED,
|
||||||
@ -3624,6 +3610,34 @@ on_gpu_added (MetaMonitorManager *monitor_manager,
|
|||||||
_cogl_winsys_egl_ensure_current (cogl_display);
|
_cogl_winsys_egl_ensure_current (cogl_display);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static MetaGpuKms *
|
||||||
|
choose_primary_gpu (MetaMonitorManager *manager)
|
||||||
|
{
|
||||||
|
GList *gpus = meta_monitor_manager_get_gpus (manager);
|
||||||
|
GList *l;
|
||||||
|
|
||||||
|
/* Prefer a platform device */
|
||||||
|
for (l = gpus; l; l = l->next)
|
||||||
|
{
|
||||||
|
MetaGpuKms *gpu_kms = META_GPU_KMS (l->data);
|
||||||
|
|
||||||
|
if (meta_gpu_kms_is_platform_device (gpu_kms))
|
||||||
|
return gpu_kms;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Otherwise a device we booted with */
|
||||||
|
for (l = gpus; l; l = l->next)
|
||||||
|
{
|
||||||
|
MetaGpuKms *gpu_kms = META_GPU_KMS (l->data);
|
||||||
|
|
||||||
|
if (meta_gpu_kms_is_boot_vga (gpu_kms))
|
||||||
|
return gpu_kms;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Lastly, just pick the first device */
|
||||||
|
return META_GPU_KMS (gpus->data);
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
meta_renderer_native_initable_init (GInitable *initable,
|
meta_renderer_native_initable_init (GInitable *initable,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
@ -3637,6 +3651,8 @@ meta_renderer_native_initable_init (GInitable *initable,
|
|||||||
GList *gpus;
|
GList *gpus;
|
||||||
GList *l;
|
GList *l;
|
||||||
|
|
||||||
|
renderer_native->primary_gpu_kms = choose_primary_gpu (monitor_manager);
|
||||||
|
|
||||||
gpus = meta_monitor_manager_get_gpus (monitor_manager);
|
gpus = meta_monitor_manager_get_gpus (monitor_manager);
|
||||||
for (l = gpus; l; l = l->next)
|
for (l = gpus; l; l = l->next)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user