mirror of
https://github.com/brl/mutter.git
synced 2024-12-22 11:02:05 +00:00
cogl: Introduce and use cogl_context_is_hardware_accelerated
We delegate the answer through CoglDriverVtable::is_hardware_accelerated since this is properly a property of the renderer, and not something the cogl core should know about. The answer given for the nop driver is admittedly arbitrary, yes it's infinitely fast but no there's not any "hardware" making it so. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1194
This commit is contained in:
parent
e216d9c6ad
commit
d133f94f8f
@ -593,3 +593,9 @@ cogl_get_graphics_reset_status (CoglContext *context)
|
||||
return COGL_GRAPHICS_RESET_STATUS_NO_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
cogl_context_is_hardware_accelerated (CoglContext *context)
|
||||
{
|
||||
return context->driver_vtable->is_hardware_accelerated (context);
|
||||
}
|
||||
|
@ -357,6 +357,16 @@ typedef enum _CoglGraphicsResetStatus
|
||||
COGL_EXPORT CoglGraphicsResetStatus
|
||||
cogl_get_graphics_reset_status (CoglContext *context);
|
||||
|
||||
/**
|
||||
* cogl_context_is_hardware_accelerated:
|
||||
* @context: a #CoglContext pointer
|
||||
*
|
||||
* Returns: %TRUE if the @context is hardware accelerated, or %FALSE if
|
||||
* not.
|
||||
*/
|
||||
COGL_EXPORT gboolean
|
||||
cogl_context_is_hardware_accelerated (CoglContext *context);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __COGL_CONTEXT_H__ */
|
||||
|
@ -46,6 +46,9 @@ struct _CoglDriverVtable
|
||||
void
|
||||
(* context_deinit) (CoglContext *context);
|
||||
|
||||
gboolean
|
||||
(* is_hardware_accelerated) (CoglContext *context);
|
||||
|
||||
/* TODO: factor this out since this is OpenGL specific and
|
||||
* so can be ignored by non-OpenGL drivers. */
|
||||
gboolean
|
||||
|
@ -91,6 +91,9 @@ _cogl_gl_util_clear_gl_errors (CoglContext *ctx);
|
||||
gboolean
|
||||
_cogl_gl_util_catch_out_of_memory (CoglContext *ctx, GError **error);
|
||||
|
||||
gboolean
|
||||
_cogl_driver_gl_is_hardware_accelerated (CoglContext *context);
|
||||
|
||||
/* Parses a GL version number stored in a string. @version_string must
|
||||
* point to the beginning of the version number (ie, it can't point to
|
||||
* the "OpenGL ES" part on GLES). The version number can be followed
|
||||
|
@ -179,3 +179,28 @@ _cogl_gl_util_parse_gl_version (const char *version_string,
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* This should arguably use something like GLX_MESA_query_renderer, but
|
||||
* a) that's GLX-only, and you could add it to EGL too but
|
||||
* b) that'd make this a winsys query when really it's not a property of
|
||||
* the winsys but the renderer, and
|
||||
* c) only Mesa really supports it anyway, and
|
||||
* d) Mesa is the only software renderer of interest.
|
||||
*
|
||||
* So instead just check a list of known software renderer strings.
|
||||
*/
|
||||
gboolean
|
||||
_cogl_driver_gl_is_hardware_accelerated (CoglContext *ctx)
|
||||
{
|
||||
const char *renderer = (const char *) ctx->glGetString (GL_RENDERER);
|
||||
gboolean software;
|
||||
|
||||
software = strstr (renderer, "llvmpipe") != NULL ||
|
||||
strstr (renderer, "softpipe") != NULL ||
|
||||
strstr (renderer, "software rasterizer") != NULL ||
|
||||
strstr (renderer, "Software Rasterizer") != NULL ||
|
||||
strstr (renderer, "SWR");
|
||||
|
||||
return !software;
|
||||
}
|
||||
|
@ -532,6 +532,7 @@ _cogl_driver_gl =
|
||||
{
|
||||
_cogl_driver_gl_real_context_init,
|
||||
_cogl_driver_gl_context_deinit,
|
||||
_cogl_driver_gl_is_hardware_accelerated,
|
||||
_cogl_driver_pixel_format_from_gl_internal,
|
||||
_cogl_driver_pixel_format_to_gl,
|
||||
_cogl_driver_update_features,
|
||||
|
@ -396,6 +396,7 @@ _cogl_driver_gles =
|
||||
{
|
||||
_cogl_driver_gl_context_init,
|
||||
_cogl_driver_gl_context_deinit,
|
||||
_cogl_driver_gl_is_hardware_accelerated,
|
||||
_cogl_driver_pixel_format_from_gl_internal,
|
||||
_cogl_driver_pixel_format_to_gl,
|
||||
_cogl_driver_update_features,
|
||||
|
@ -63,11 +63,18 @@ _cogl_driver_nop_context_deinit (CoglContext *context)
|
||||
{
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_cogl_driver_nop_is_hardware_accelerated (CoglContext *context)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
const CoglDriverVtable
|
||||
_cogl_driver_nop =
|
||||
{
|
||||
_cogl_driver_nop_context_init,
|
||||
_cogl_driver_nop_context_deinit,
|
||||
_cogl_driver_nop_is_hardware_accelerated,
|
||||
NULL, /* pixel_format_from_gl_internal */
|
||||
NULL, /* pixel_format_to_gl */
|
||||
_cogl_driver_update_features,
|
||||
|
@ -194,23 +194,8 @@ meta_renderer_is_hardware_accelerated (MetaRenderer *renderer)
|
||||
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
|
||||
CoglContext *cogl_context =
|
||||
clutter_backend_get_cogl_context (clutter_backend);
|
||||
CoglGpuInfo *info = &cogl_context->gpu;
|
||||
|
||||
switch (info->architecture)
|
||||
{
|
||||
case COGL_GPU_INFO_ARCHITECTURE_UNKNOWN:
|
||||
case COGL_GPU_INFO_ARCHITECTURE_SANDYBRIDGE:
|
||||
case COGL_GPU_INFO_ARCHITECTURE_SGX:
|
||||
case COGL_GPU_INFO_ARCHITECTURE_MALI:
|
||||
return TRUE;
|
||||
case COGL_GPU_INFO_ARCHITECTURE_LLVMPIPE:
|
||||
case COGL_GPU_INFO_ARCHITECTURE_SOFTPIPE:
|
||||
case COGL_GPU_INFO_ARCHITECTURE_SWRAST:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_assert_not_reached ();
|
||||
return FALSE;
|
||||
return cogl_context_is_hardware_accelerated (cogl_context);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user