diff --git a/cogl/cogl/cogl-context.c b/cogl/cogl/cogl-context.c index a7eed29ab..4b1af6106 100644 --- a/cogl/cogl/cogl-context.c +++ b/cogl/cogl/cogl-context.c @@ -76,6 +76,11 @@ #define GL_NUM_EXTENSIONS 0x821D #endif +/* This is a relatively new extension */ +#ifndef GL_PURGED_CONTEXT_RESET_NV +#define GL_PURGED_CONTEXT_RESET_NV 0x92BB +#endif + static void _cogl_context_free (CoglContext *context); COGL_OBJECT_DEFINE (Context, context); @@ -784,3 +789,28 @@ cogl_get_clock_time (CoglContext *context) else return 0; } + +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; + } +} diff --git a/cogl/cogl/cogl-context.h b/cogl/cogl/cogl-context.h index 529481765..b0fdc279c 100644 --- a/cogl/cogl/cogl-context.h +++ b/cogl/cogl/cogl-context.h @@ -373,6 +373,48 @@ cogl_foreach_feature (CoglContext *context, int64_t cogl_get_clock_time (CoglContext *context); +/** + * CoglGraphicsResetStatus: + * @COGL_GRAPHICS_RESET_STATUS_NO_ERROR: + * @COGL_GRAPHICS_RESET_STATUS_GUILTY_CONTEXT_RESET: + * @COGL_GRAPHICS_RESET_STATUS_INNOCENT_CONTEXT_RESET: + * @COGL_GRAPHICS_RESET_STATUS_UNKNOWN_CONTEXT_RESET: + * @COGL_GRAPHICS_RESET_STATUS_PURGED_CONTEXT_RESET: + * + * All the error values that might be returned by + * cogl_get_graphics_reset_status(). Each value's meaning corresponds + * to the similarly named value defined in the ARB_robustness and + * NV_robustness_video_memory_purge extensions. + */ +typedef enum _CoglGraphicsResetStatus +{ + COGL_GRAPHICS_RESET_STATUS_NO_ERROR, + COGL_GRAPHICS_RESET_STATUS_GUILTY_CONTEXT_RESET, + COGL_GRAPHICS_RESET_STATUS_INNOCENT_CONTEXT_RESET, + COGL_GRAPHICS_RESET_STATUS_UNKNOWN_CONTEXT_RESET, + COGL_GRAPHICS_RESET_STATUS_PURGED_CONTEXT_RESET, +} CoglGraphicsResetStatus; + +/** + * cogl_get_graphics_reset_status: + * @context: a #CoglContext pointer + * + * Returns the graphics reset status as reported by + * GetGraphicsResetStatusARB defined in the ARB_robustness extension. + * + * Note that Cogl doesn't normally enable the ARB_robustness + * extension in which case this will only ever return + * #COGL_GRAPHICS_RESET_STATUS_NO_ERROR. + * + * Applications must explicitly use a backend specific method to + * request that errors get reported such as X11's + * cogl_xlib_renderer_request_reset_on_video_memory_purge(). + * + * Return value: a #CoglGraphicsResetStatus + */ +CoglGraphicsResetStatus +cogl_get_graphics_reset_status (CoglContext *context); + #endif /* COGL_ENABLE_EXPERIMENTAL_API */ COGL_END_DECLS diff --git a/cogl/cogl/cogl.symbols b/cogl/cogl/cogl.symbols index cdac57210..c1cd50e07 100644 --- a/cogl/cogl/cogl.symbols +++ b/cogl/cogl/cogl.symbols @@ -330,6 +330,7 @@ cogl_get_clock_time cogl_get_depth_test_enabled cogl_get_draw_framebuffer cogl_get_features +cogl_get_graphics_reset_status cogl_get_modelview_matrix cogl_get_option_group cogl_get_proc_address