[Mesa-dev] [PATCH 13/15] mesa: Remap debug type and severity

Ian Romanick idr at freedesktop.org
Wed Sep 4 13:54:15 PDT 2013


On 08/26/2013 03:43 AM, Timothy Arceri wrote:
> Remap any type or severity exclusive to KHR_debug to
> something suitable for ARB_debug_output

There is no need for any of this remapping.  The only way the new enums
can be passed back to the application is if the application specifically
requests them by using functionality added by this extension.

This whole patch should be removed.

> Signed-off-by: Timothy Arceri <t_arceri at yahoo.com.au>
> ---
>  src/mesa/main/errors.c |   65 ++++++++++++++++++++++++++++++++++++++++++------
>  src/mesa/main/mtypes.h |    1 +
>  2 files changed, 58 insertions(+), 8 deletions(-)
> 
> diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c
> index 6e877e3..83033dc 100644
> --- a/src/mesa/main/errors.c
> +++ b/src/mesa/main/errors.c
> @@ -39,6 +39,9 @@
>  #include "hash_table.h"
>  #include "glapi/glthread.h"
>  
> +#define MESSAGE_LOG 1
> +#define MESSAGE_LOG_ARB 2
> +
>  _glthread_DECLARE_STATIC_MUTEX(DynamicIDMutex);
>  static GLuint NextDynamicID = 1;
>  
> @@ -304,6 +307,38 @@ store_message_details(struct gl_debug_msg *emptySlot,
>     }
>  }
>  
> + /**
> + * Remap any type exclusive to KHR_debug to something suitable
> + * for ARB_debug_output
> + */
> +inline static int
> +remap_type(GLenum type) {
> +
> +   switch(type) {
> +   case GL_DEBUG_TYPE_MARKER:
> +   case GL_DEBUG_TYPE_PUSH_GROUP:
> +   case GL_DEBUG_TYPE_POP_GROUP:
> +      type = GL_DEBUG_TYPE_OTHER;
> +   default:
> +      ;
> +   }
> +
> +  return type;
> +}
> +
> +/**
> + * Remap severity exclusive to KHR_debug to something suitable
> + * for ARB_debug_output
> + */
> +inline static int
> +remap_severity(GLenum severity) {
> +
> +   if (GL_DEBUG_SEVERITY_NOTIFICATION == severity)
> +      severity = GL_DEBUG_SEVERITY_LOW;
> +
> +   return severity;
> +}
> +
>  /**
>   * 'buf' is not necessarily a null-terminated string. When logging, copy
>   * 'len' characters from it, store them in a new, null-terminated string,
> @@ -324,10 +359,17 @@ _mesa_log_msg(struct gl_context *ctx, enum mesa_debug_source source,
>        return;
>  
>     if (ctx->Debug.Callback) {
> +       GLenum gl_type = debug_type_enums[type];
> +       GLenum gl_severity = debug_severity_enums[severity];
> +
> +       if (ctx->Debug.ARBCallback) {
> +          gl_severity = remap_severity(gl_severity);
> +          gl_type = remap_type(gl_type);
> +      }
>        ctx->Debug.Callback(debug_source_enums[source],
> -                          debug_type_enums[type],
> +                          gl_type,
>                            id,
> -                          debug_severity_enums[severity],
> +                          gl_severity,
>                            len, buf, ctx->Debug.CallbackData);
>        return;
>     }
> @@ -359,7 +401,8 @@ _mesa_log_msg(struct gl_context *ctx, enum mesa_debug_source source,
>   */
>  static GLsizei
>  _mesa_get_msg(struct gl_context *ctx, GLenum *source, GLenum *type,
> -              GLuint *id, GLenum *severity, GLsizei bufSize, char *buf)
> +              GLuint *id, GLenum *severity, GLsizei bufSize, char *buf,
> +              unsigned caller)
>  {
>     struct gl_debug_msg *msg;
>     GLsizei length;
> @@ -375,12 +418,18 @@ _mesa_get_msg(struct gl_context *ctx, GLenum *source, GLenum *type,
>     if (bufSize < length && buf != NULL)
>        return 0;
>  
> -   if (severity)
> +   if (severity) {
>        *severity = debug_severity_enums[msg->severity];
> +      if (caller == MESSAGE_LOG_ARB)
> +         *severity = remap_severity(*severity);
> +   }
>     if (source)
>        *source = debug_source_enums[msg->source];
> -   if (type)
> +   if (type) {
>        *type = debug_type_enums[msg->type];
> +      if (caller == MESSAGE_LOG_ARB)
> +         *type = remap_type(*type);
> +   }
>     if (id)
>        *id = msg->id;
>  
> @@ -648,8 +697,6 @@ get_message_log(GLuint count, GLsizei logSize, GLenum* sources,
>                  GLsizei* lengths, GLchar* messageLog,
>                  unsigned caller, const char *callerstr)
>  {
> -#define MESSAGE_LOG 1
> -#define MESSAGE_LOG_ARB 2
>     GET_CURRENT_CONTEXT(ctx);
>     GLuint ret;
>  
> @@ -665,7 +712,7 @@ get_message_log(GLuint count, GLsizei logSize, GLenum* sources,
>  
>     for (ret = 0; ret < count; ret++) {
>        GLsizei written = _mesa_get_msg(ctx, sources, types, ids, severities,
> -                                      logSize, messageLog);
> +                                      logSize, messageLog, caller);
>        if (!written)
>           break;
>  
> @@ -766,6 +813,7 @@ _mesa_DebugMessageCallback(GLDEBUGPROC callback, const void *userParam)
>     GET_CURRENT_CONTEXT(ctx);
>     ctx->Debug.Callback = callback;
>     ctx->Debug.CallbackData = userParam;
> +   ctx->Debug.ARBCallback = GL_FALSE;
>  }
>  
>  void GLAPIENTRY
> @@ -925,6 +973,7 @@ _mesa_DebugMessageCallbackARB(GLDEBUGPROCARB callback, const void *userParam)
>     GET_CURRENT_CONTEXT(ctx);
>     ctx->Debug.Callback = callback;
>     ctx->Debug.CallbackData = userParam;
> +   ctx->Debug.ARBCallback = GL_TRUE;
>  }
>  
>  void
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index b15394f..ee30cba 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -3392,6 +3392,7 @@ struct gl_debug_state
>     const void *CallbackData;
>     GLboolean SyncOutput;
>     GLboolean DebugOutput;
> +   GLboolean ARBCallback; /* Used to track if current callback is of type ARB_debug_output or KHR_debug */
>     GLboolean Defaults[MAX_DEBUG_GROUP_STACK_DEPTH][MESA_DEBUG_SEVERITY_COUNT][MESA_DEBUG_SOURCE_COUNT][MESA_DEBUG_TYPE_COUNT];
>     struct gl_debug_namespace Namespaces[MAX_DEBUG_GROUP_STACK_DEPTH][MESA_DEBUG_SOURCE_COUNT][MESA_DEBUG_TYPE_COUNT];
>     struct gl_debug_msg Log[MAX_DEBUG_LOGGED_MESSAGES];
> 



More information about the mesa-dev mailing list