[Mesa-dev] [PATCH 03/13] mesa: add infrastructure for GL_ARB_debug_output

Marek Olšák maraeo at gmail.com
Wed Feb 15 05:28:04 PST 2012


From: nobled <nobled at dreamwidth.org>

Marek v2: don't add the extension to extensions.c yet
---
 src/mesa/main/config.h    |    6 ++++++
 src/mesa/main/context.c   |    1 +
 src/mesa/main/enable.c    |    5 +++++
 src/mesa/main/errors.c    |   13 ++++++++++++-
 src/mesa/main/errors.h    |    3 +++
 src/mesa/main/get.c       |    7 +++++++
 src/mesa/main/getstring.c |    6 ++++++
 src/mesa/main/mtypes.h    |   29 +++++++++++++++++++++++++++++
 8 files changed, 69 insertions(+), 1 deletions(-)

diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h
index 7b7740e..74b33ed 100644
--- a/src/mesa/main/config.h
+++ b/src/mesa/main/config.h
@@ -298,6 +298,12 @@
 #define MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS         1024
 /*@}*/
 
+/** For GL_ARB_debug_output */
+/*@{*/
+#define MAX_DEBUG_LOGGED_MESSAGES   10
+#define MAX_DEBUG_MESSAGE_LENGTH    4096
+/*@}*/
+
 
 /**
  * \name Mesa-specific parameters
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 43e7438..874d33b 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -764,6 +764,7 @@ init_attrib_groups(struct gl_context *ctx)
    _mesa_init_depth( ctx );
    _mesa_init_debug( ctx );
    _mesa_init_display_list( ctx );
+   _mesa_init_errors( ctx );
    _mesa_init_eval( ctx );
    _mesa_init_fbobjects( ctx );
    _mesa_init_feedback( ctx );
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index 270b240..5a998d7 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -348,6 +348,9 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
          FLUSH_VERTICES(ctx, _NEW_DEPTH);
          ctx->Depth.Test = state;
          break;
+      case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB:
+         ctx->Debug.SyncOutput = state;
+         break;
       case GL_DITHER:
          if (ctx->Color.DitherFlag == state)
             return;
@@ -1114,6 +1117,8 @@ _mesa_IsEnabled( GLenum cap )
 	 return ctx->Light.ColorMaterialEnabled;
       case GL_CULL_FACE:
          return ctx->Polygon.CullFlag;
+      case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB:
+         return ctx->Debug.SyncOutput;
       case GL_DEPTH_TEST:
          return ctx->Depth.Test;
       case GL_DITHER:
diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c
index a571cdf..906aafc 100644
--- a/src/mesa/main/errors.c
+++ b/src/mesa/main/errors.c
@@ -36,7 +36,18 @@
 #include "version.h"
 
 
-#define MAXSTRING 4000  /* for _mesa_vsnprintf() */
+#define MAXSTRING MAX_DEBUG_MESSAGE_LENGTH
+
+void
+_mesa_init_errors(struct gl_context *ctx)
+{
+   ctx->Debug.Callback = NULL;
+   ctx->Debug.SyncOutput = GL_FALSE;
+   ctx->Debug.Log[0].length = 0;
+   ctx->Debug.NumMessages = 0;
+   ctx->Debug.NextMsg = 0;
+   ctx->Debug.NextMsgLength = 0;
+}
 
 /**********************************************************************/
 /** \name Diagnostics */
diff --git a/src/mesa/main/errors.h b/src/mesa/main/errors.h
index 78dd57a..e467f5d 100644
--- a/src/mesa/main/errors.h
+++ b/src/mesa/main/errors.h
@@ -47,6 +47,9 @@ extern "C" {
 struct gl_context;
 
 extern void
+_mesa_init_errors( struct gl_context *ctx );
+
+extern void
 _mesa_warning( struct gl_context *gc, const char *fmtString, ... ) PRINTFLIKE(2, 3);
 
 extern void
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 5ad6012..9a5ca53 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -1297,6 +1297,13 @@ static const struct value_desc values[] = {
 
    /* GL_ARB_robustness */
    { GL_RESET_NOTIFICATION_STRATEGY_ARB, CONTEXT_ENUM(Const.ResetStrategy), NO_EXTRA },
+
+   /* GL_ARB_debug_output */
+   { GL_DEBUG_LOGGED_MESSAGES_ARB, CONTEXT_INT(Debug.NumMessages), NO_EXTRA },
+   { GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB, CONTEXT_INT(Debug.NextMsgLength), NO_EXTRA },
+   { GL_MAX_DEBUG_LOGGED_MESSAGES_ARB, CONST(MAX_DEBUG_LOGGED_MESSAGES), NO_EXTRA },
+   { GL_MAX_DEBUG_MESSAGE_LENGTH_ARB, CONST(MAX_DEBUG_MESSAGE_LENGTH), NO_EXTRA },
+
 #endif /* FEATURE_GL */
 };
 
diff --git a/src/mesa/main/getstring.c b/src/mesa/main/getstring.c
index dbf6c3f..90e0280 100644
--- a/src/mesa/main/getstring.c
+++ b/src/mesa/main/getstring.c
@@ -224,6 +224,12 @@ _mesa_GetPointerv( GLenum pname, GLvoid **params )
          *params = (GLvoid *) ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_POINT_SIZE].Ptr;
          break;
 #endif
+      case GL_DEBUG_CALLBACK_FUNCTION_ARB:
+         *params = (GLvoid *) ctx->Debug.Callback;
+         break;
+      case GL_DEBUG_CALLBACK_USER_PARAM_ARB:
+         *params = ctx->Debug.CallbackData;
+         break;
       default:
          _mesa_error( ctx, GL_INVALID_ENUM, "glGetPointerv" );
          return;
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 5ef97c8..6160c04 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3194,6 +3194,32 @@ struct gl_dlist_state
    } Current;
 };
 
+/**
+ * An error, warning, or other piece of debug information for an application
+ * to consume via GL_ARB_debug_output.
+ */
+struct gl_debug_msg
+{
+   GLenum source;
+   GLenum type;
+   GLuint id;
+   GLenum severity;
+   GLsizei length;
+   GLcharARB *message;
+};
+
+/* GL_ARB_debug_output */
+struct gl_debug_state
+{
+   GLDEBUGPROCARB Callback;
+   GLvoid *CallbackData;
+   GLboolean SyncOutput;
+   struct gl_debug_msg Log[MAX_DEBUG_LOGGED_MESSAGES];
+   GLint NumMessages;
+   GLint NextMsg;
+   GLint NextMsgLength; /* redundant, but copied here from Log[NextMsg].length
+                           for the sake of the offsetof() code in get.c */
+};
 
 /**
  * Enum for the OpenGL APIs we know about and may support.
@@ -3359,6 +3385,9 @@ struct gl_context
    const char *ErrorDebugFmtString;
    GLuint ErrorDebugCount;
 
+   /* GL_ARB_debug_output */
+   struct gl_debug_state Debug;
+
    GLenum RenderMode;        /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
    GLbitfield NewState;      /**< bitwise-or of _NEW_* flags */
 
-- 
1.7.5.4



More information about the mesa-dev mailing list