--- src/mesa/main/context.c | 1 + src/mesa/main/enable.c | 5 +++++ src/mesa/main/errors.c | 10 ++++++++++ src/mesa/main/extensions.c | 1 + src/mesa/main/get.c | 7 +++++++ src/mesa/main/getstring.c | 6 ++++++ src/mesa/main/imports.h | 3 +++ src/mesa/main/mtypes.h | 31 +++++++++++++++++++++++++++++++ 8 files changed, 64 insertions(+), 0 deletions(-)
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index ea13bdd..0173535 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -763,6 +763,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 2ec19c8..c2286a0 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -344,6 +344,9 @@ 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; @@ -1097,6 +1100,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 009681a..e112915 100644 --- a/src/mesa/main/errors.c +++ b/src/mesa/main/errors.c @@ -38,6 +38,16 @@ #define MAXSTRING 4000 /* for _mesa_vsnprintf() */ +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.NextMsg = &ctx->Debug.Log[0]; + ctx->Debug.NumMessages = 0; +} + /**********************************************************************/ /** \name Diagnostics */ /*@{*/ diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index e0562cc..c034370 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -81,6 +81,7 @@ { "GL_ARB_blend_func_extended", o(ARB_blend_func_extended), GL, 2009 }, { "GL_ARB_color_buffer_float", o(ARB_color_buffer_float), GL, 2004 }, { "GL_ARB_copy_buffer", o(ARB_copy_buffer), GL, 2008 }, + { "GL_ARB_debug_output", o(ARB_debug_output), GL, 2009 }, { "GL_ARB_depth_buffer_float", o(ARB_depth_buffer_float), GL, 2008 }, { "GL_ARB_depth_clamp", o(ARB_depth_clamp), GL, 2003 }, { "GL_ARB_depth_texture", o(ARB_depth_texture), GL, 2001 }, diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index e933bbe..527480b 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -1284,6 +1284,13 @@ /* 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(_MESA_MAX_DEBUG_LOGGED_MESSAGES), NO_EXTRA }, + { GL_MAX_DEBUG_MESSAGE_LENGTH_ARB, CONST(_MESA_MAX_DEBUG_MESSAGE_LENGTH), NO_EXTRA }, + #endif /* FEATURE_GL */ }; diff --git a/src/mesa/main/getstring.c b/src/mesa/main/getstring.c index c381fb2..019d931 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->PointSize.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/imports.h b/src/mesa/main/imports.h index 604fbcb..cc5f154 100644 --- a/src/mesa/main/imports.h +++ b/src/mesa/main/imports.h @@ -610,6 +610,9 @@ extern void _mesa_debug( const struct gl_context *ctx, const char *fmtString, ... ) PRINTFLIKE(2, 3); +extern void +_mesa_init_errors( struct gl_context *ctx ); + #if defined(_MSC_VER) && !defined(snprintf) #define snprintf _snprintf diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index fba65e8..06083c5 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2765,6 +2765,7 @@ struct gl_extensions GLboolean ARB_blend_func_extended; GLboolean ARB_color_buffer_float; GLboolean ARB_copy_buffer; + GLboolean ARB_debug_output; GLboolean ARB_depth_buffer_float; GLboolean ARB_depth_clamp; GLboolean ARB_depth_texture; @@ -3152,6 +3153,33 @@ 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; +}; +#define _MESA_MAX_DEBUG_LOGGED_MESSAGES 1 +#define _MESA_MAX_DEBUG_MESSAGE_LENGTH 4096 + +/* GL_ARB_debug_output */ +struct gl_debug_state +{ + GLDEBUGPROCARB Callback; + GLvoid *CallbackData; + GLboolean SyncOutput; + struct gl_debug_msg Log[_MESA_MAX_DEBUG_LOGGED_MESSAGES]; + struct gl_debug_msg *NextMsg; + GLint NextMsgLength; /* redundant, but here for the sake of get.c */ + GLint NumMessages; +}; /** * Enum for the OpenGL APIs we know about and may support. @@ -3317,6 +3345,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.0.4
From 1b832c3ee31610666d36544a449d06321b70cd42 Mon Sep 17 00:00:00 2001 From: nobled <nob...@dreamwidth.org> Date: Sun, 1 May 2011 15:46:45 +0000 Subject: [PATCH 5/5] mesa: add infrastructure for GL_ARB_debug_output --- src/mesa/main/context.c | 1 + src/mesa/main/enable.c | 5 +++++ src/mesa/main/errors.c | 10 ++++++++++ src/mesa/main/extensions.c | 1 + src/mesa/main/get.c | 7 +++++++ src/mesa/main/getstring.c | 6 ++++++ src/mesa/main/imports.h | 3 +++ src/mesa/main/mtypes.h | 31 +++++++++++++++++++++++++++++++ 8 files changed, 64 insertions(+), 0 deletions(-) diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index ea13bdd..0173535 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -763,6 +763,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 2ec19c8..c2286a0 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -344,6 +344,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; @@ -1097,6 +1100,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 009681a..e112915 100644 --- a/src/mesa/main/errors.c +++ b/src/mesa/main/errors.c @@ -38,6 +38,16 @@ #define MAXSTRING 4000 /* for _mesa_vsnprintf() */ +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.NextMsg = &ctx->Debug.Log[0]; + ctx->Debug.NumMessages = 0; +} + /**********************************************************************/ /** \name Diagnostics */ /*@{*/ diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index e0562cc..c034370 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -81,6 +81,7 @@ static const struct extension extension_table[] = { { "GL_ARB_blend_func_extended", o(ARB_blend_func_extended), GL, 2009 }, { "GL_ARB_color_buffer_float", o(ARB_color_buffer_float), GL, 2004 }, { "GL_ARB_copy_buffer", o(ARB_copy_buffer), GL, 2008 }, + { "GL_ARB_debug_output", o(ARB_debug_output), GL, 2009 }, { "GL_ARB_depth_buffer_float", o(ARB_depth_buffer_float), GL, 2008 }, { "GL_ARB_depth_clamp", o(ARB_depth_clamp), GL, 2003 }, { "GL_ARB_depth_texture", o(ARB_depth_texture), GL, 2001 }, diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index e933bbe..527480b 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -1284,6 +1284,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(_MESA_MAX_DEBUG_LOGGED_MESSAGES), NO_EXTRA }, + { GL_MAX_DEBUG_MESSAGE_LENGTH_ARB, CONST(_MESA_MAX_DEBUG_MESSAGE_LENGTH), NO_EXTRA }, + #endif /* FEATURE_GL */ }; diff --git a/src/mesa/main/getstring.c b/src/mesa/main/getstring.c index c381fb2..019d931 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->PointSize.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/imports.h b/src/mesa/main/imports.h index 604fbcb..cc5f154 100644 --- a/src/mesa/main/imports.h +++ b/src/mesa/main/imports.h @@ -610,6 +610,9 @@ _mesa_error( struct gl_context *ctx, GLenum error, const char *fmtString, ... ) extern void _mesa_debug( const struct gl_context *ctx, const char *fmtString, ... ) PRINTFLIKE(2, 3); +extern void +_mesa_init_errors( struct gl_context *ctx ); + #if defined(_MSC_VER) && !defined(snprintf) #define snprintf _snprintf diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index fba65e8..06083c5 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2765,6 +2765,7 @@ struct gl_extensions GLboolean ARB_blend_func_extended; GLboolean ARB_color_buffer_float; GLboolean ARB_copy_buffer; + GLboolean ARB_debug_output; GLboolean ARB_depth_buffer_float; GLboolean ARB_depth_clamp; GLboolean ARB_depth_texture; @@ -3152,6 +3153,33 @@ 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; +}; +#define _MESA_MAX_DEBUG_LOGGED_MESSAGES 1 +#define _MESA_MAX_DEBUG_MESSAGE_LENGTH 4096 + +/* GL_ARB_debug_output */ +struct gl_debug_state +{ + GLDEBUGPROCARB Callback; + GLvoid *CallbackData; + GLboolean SyncOutput; + struct gl_debug_msg Log[_MESA_MAX_DEBUG_LOGGED_MESSAGES]; + struct gl_debug_msg *NextMsg; + GLint NextMsgLength; /* redundant, but here for the sake of get.c */ + GLint NumMessages; +}; /** * Enum for the OpenGL APIs we know about and may support. @@ -3317,6 +3345,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.0.4
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev