cogl: Move graphics reset status into the driver vtable

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1194
This commit is contained in:
Adam Jackson 2020-01-28 15:16:25 -05:00
parent 0b6f5c6f55
commit ca79073014
7 changed files with 53 additions and 38 deletions

View File

@ -56,24 +56,6 @@
#define GL_POINT_SPRITE 0x8861
#endif
/* This is a relatively new extension */
#ifndef GL_PURGED_CONTEXT_RESET_NV
#define GL_PURGED_CONTEXT_RESET_NV 0x92BB
#endif
/* These aren't defined in the GLES2 headers */
#ifndef GL_GUILTY_CONTEXT_RESET_ARB
#define GL_GUILTY_CONTEXT_RESET_ARB 0x8253
#endif
#ifndef GL_INNOCENT_CONTEXT_RESET_ARB
#define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254
#endif
#ifndef GL_UNKNOWN_CONTEXT_RESET_ARB
#define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255
#endif
static void _cogl_context_free (CoglContext *context);
COGL_OBJECT_DEFINE (Context, context);
@ -479,26 +461,7 @@ cogl_get_clock_time (CoglContext *context)
CoglGraphicsResetStatus
cogl_get_graphics_reset_status (CoglContext *context)
{
if (!context->glGetGraphicsResetStatus)
return COGL_GRAPHICS_RESET_STATUS_NO_ERROR;
switch (context->glGetGraphicsResetStatus ())
{
case GL_GUILTY_CONTEXT_RESET_ARB:
return COGL_GRAPHICS_RESET_STATUS_GUILTY_CONTEXT_RESET;
case GL_INNOCENT_CONTEXT_RESET_ARB:
return COGL_GRAPHICS_RESET_STATUS_INNOCENT_CONTEXT_RESET;
case GL_UNKNOWN_CONTEXT_RESET_ARB:
return COGL_GRAPHICS_RESET_STATUS_UNKNOWN_CONTEXT_RESET;
case GL_PURGED_CONTEXT_RESET_NV:
return COGL_GRAPHICS_RESET_STATUS_PURGED_CONTEXT_RESET;
default:
return COGL_GRAPHICS_RESET_STATUS_NO_ERROR;
}
return context->driver_vtable->get_graphics_reset_status (context);
}
gboolean

View File

@ -50,6 +50,9 @@ struct _CoglDriverVtable
gboolean
(* is_hardware_accelerated) (CoglContext *context);
CoglGraphicsResetStatus
(* get_graphics_reset_status) (CoglContext *context);
/* TODO: factor this out since this is OpenGL specific and
* so can be ignored by non-OpenGL drivers. */
gboolean

View File

@ -131,4 +131,7 @@ _cogl_gl_util_parse_gl_version (const char *version_string,
int *major_out,
int *minor_out);
CoglGraphicsResetStatus
_cogl_gl_get_graphics_reset_status (CoglContext *context);
#endif /* _COGL_UTIL_GL_PRIVATE_H_ */

View File

@ -37,6 +37,24 @@
#include "driver/gl/cogl-pipeline-opengl-private.h"
#include "driver/gl/cogl-util-gl-private.h"
/* This is a relatively new extension */
#ifndef GL_PURGED_CONTEXT_RESET_NV
#define GL_PURGED_CONTEXT_RESET_NV 0x92BB
#endif
/* These aren't defined in the GLES2 headers */
#ifndef GL_GUILTY_CONTEXT_RESET_ARB
#define GL_GUILTY_CONTEXT_RESET_ARB 0x8253
#endif
#ifndef GL_INNOCENT_CONTEXT_RESET_ARB
#define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254
#endif
#ifndef GL_UNKNOWN_CONTEXT_RESET_ARB
#define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255
#endif
#ifdef COGL_GL_DEBUG
/* GL error to string conversion */
static const struct {
@ -309,3 +327,28 @@ _cogl_driver_gl_is_hardware_accelerated (CoglContext *ctx)
return !software;
}
CoglGraphicsResetStatus
_cogl_gl_get_graphics_reset_status (CoglContext *context)
{
if (!context->glGetGraphicsResetStatus)
return COGL_GRAPHICS_RESET_STATUS_NO_ERROR;
switch (context->glGetGraphicsResetStatus ())
{
case GL_GUILTY_CONTEXT_RESET_ARB:
return COGL_GRAPHICS_RESET_STATUS_GUILTY_CONTEXT_RESET;
case GL_INNOCENT_CONTEXT_RESET_ARB:
return COGL_GRAPHICS_RESET_STATUS_INNOCENT_CONTEXT_RESET;
case GL_UNKNOWN_CONTEXT_RESET_ARB:
return COGL_GRAPHICS_RESET_STATUS_UNKNOWN_CONTEXT_RESET;
case GL_PURGED_CONTEXT_RESET_NV:
return COGL_GRAPHICS_RESET_STATUS_PURGED_CONTEXT_RESET;
default:
return COGL_GRAPHICS_RESET_STATUS_NO_ERROR;
}
}

View File

@ -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_gl_get_graphics_reset_status,
_cogl_driver_pixel_format_from_gl_internal,
_cogl_driver_pixel_format_to_gl,
_cogl_driver_update_features,

View File

@ -396,6 +396,7 @@ _cogl_driver_gles =
_cogl_driver_gl_context_init,
_cogl_driver_gl_context_deinit,
_cogl_driver_gl_is_hardware_accelerated,
_cogl_gl_get_graphics_reset_status,
_cogl_driver_pixel_format_from_gl_internal,
_cogl_driver_pixel_format_to_gl,
_cogl_driver_update_features,

View File

@ -73,6 +73,7 @@ _cogl_driver_nop =
_cogl_driver_nop_context_init,
_cogl_driver_nop_context_deinit,
_cogl_driver_nop_is_hardware_accelerated,
NULL, /* get_graphics_reset_status */
NULL, /* pixel_format_from_gl_internal */
NULL, /* pixel_format_to_gl */
_cogl_driver_update_features,