From ca79073014d1639d334188e4a591f1984cbbd2b8 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Tue, 28 Jan 2020 15:16:25 -0500 Subject: [PATCH] cogl: Move graphics reset status into the driver vtable https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1194 --- cogl/cogl/cogl-context.c | 39 +------------------ cogl/cogl/cogl-driver.h | 3 ++ cogl/cogl/driver/gl/cogl-util-gl-private.h | 3 ++ cogl/cogl/driver/gl/cogl-util-gl.c | 43 +++++++++++++++++++++ cogl/cogl/driver/gl/gl/cogl-driver-gl.c | 1 + cogl/cogl/driver/gl/gles/cogl-driver-gles.c | 1 + cogl/cogl/driver/nop/cogl-driver-nop.c | 1 + 7 files changed, 53 insertions(+), 38 deletions(-) diff --git a/cogl/cogl/cogl-context.c b/cogl/cogl/cogl-context.c index 908738f29..e6effb008 100644 --- a/cogl/cogl/cogl-context.c +++ b/cogl/cogl/cogl-context.c @@ -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 diff --git a/cogl/cogl/cogl-driver.h b/cogl/cogl/cogl-driver.h index 04c5d2e58..d8f3cc18f 100644 --- a/cogl/cogl/cogl-driver.h +++ b/cogl/cogl/cogl-driver.h @@ -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 diff --git a/cogl/cogl/driver/gl/cogl-util-gl-private.h b/cogl/cogl/driver/gl/cogl-util-gl-private.h index b3367973f..c3f550863 100644 --- a/cogl/cogl/driver/gl/cogl-util-gl-private.h +++ b/cogl/cogl/driver/gl/cogl-util-gl-private.h @@ -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_ */ diff --git a/cogl/cogl/driver/gl/cogl-util-gl.c b/cogl/cogl/driver/gl/cogl-util-gl.c index 1e2381934..e41c17c93 100644 --- a/cogl/cogl/driver/gl/cogl-util-gl.c +++ b/cogl/cogl/driver/gl/cogl-util-gl.c @@ -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; + } +} diff --git a/cogl/cogl/driver/gl/gl/cogl-driver-gl.c b/cogl/cogl/driver/gl/gl/cogl-driver-gl.c index 950cbe662..3c2231ebc 100644 --- a/cogl/cogl/driver/gl/gl/cogl-driver-gl.c +++ b/cogl/cogl/driver/gl/gl/cogl-driver-gl.c @@ -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, diff --git a/cogl/cogl/driver/gl/gles/cogl-driver-gles.c b/cogl/cogl/driver/gl/gles/cogl-driver-gles.c index 32f8c526a..3cb11af69 100644 --- a/cogl/cogl/driver/gl/gles/cogl-driver-gles.c +++ b/cogl/cogl/driver/gl/gles/cogl-driver-gles.c @@ -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, diff --git a/cogl/cogl/driver/nop/cogl-driver-nop.c b/cogl/cogl/driver/nop/cogl-driver-nop.c index 5edd93a22..f7e6d948f 100644 --- a/cogl/cogl/driver/nop/cogl-driver-nop.c +++ b/cogl/cogl/driver/nop/cogl-driver-nop.c @@ -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,