[Mesa-dev] [PATCH 2/4] mesa: make ARB_debug_output functions an alias of KHR_debug
Emil Velikov
emil.l.velikov at gmail.com
Mon Mar 3 08:28:29 PST 2014
On 03/03/14 08:33, Timothy Arceri wrote:
> The spec doesn't mention how ARB_debug_output and KHR_debug should
> interact but testing with Nvidia and AMD shows this is how they both
> treat these functions
>
Hi Timothy,
AFAICS this patch will break make check, only to be fixed with the
following patch. Would it be possible merge the aliasing with the next
patch ?
Thanks
-Emil
> Signed-off-by: Timothy Arceri <t_arceri at yahoo.com.au>
> ---
> src/mapi/glapi/gen/ARB_debug_output.xml | 8 +-
> src/mesa/main/errors.c | 293 ++++++++------------------------
> src/mesa/main/errors.h | 15 --
> src/mesa/main/mtypes.h | 1 -
> 4 files changed, 78 insertions(+), 239 deletions(-)
>
> diff --git a/src/mapi/glapi/gen/ARB_debug_output.xml b/src/mapi/glapi/gen/ARB_debug_output.xml
> index 11f268d..0468d57 100644
> --- a/src/mapi/glapi/gen/ARB_debug_output.xml
> +++ b/src/mapi/glapi/gen/ARB_debug_output.xml
> @@ -52,7 +52,7 @@
> <enum name="DEBUG_SEVERITY_LOW_ARB" value="0x9148"/>
>
>
> - <function name="DebugMessageControlARB" offset="assign">
> + <function name="DebugMessageControlARB" alias="DebugMessageControl">
> <param name="source" type="GLenum"/>
> <param name="type" type="GLenum"/>
> <param name="severity" type="GLenum"/>
> @@ -61,7 +61,7 @@
> <param name="enabled" type="GLboolean"/>
> </function>
>
> - <function name="DebugMessageInsertARB" offset="assign">
> + <function name="DebugMessageInsertARB" alias="DebugMessageInsert">
> <param name="source" type="GLenum"/>
> <param name="type" type="GLenum"/>
> <param name="id" type="GLuint"/>
> @@ -70,12 +70,12 @@
> <param name="buf" type="const GLcharARB *"/>
> </function>
>
> - <function name="DebugMessageCallbackARB" offset="assign">
> + <function name="DebugMessageCallbackARB" alias="DebugMessageCallback">
> <param name="callback" type="GLDEBUGPROCARB"/>
> <param name="userParam" type="const GLvoid *"/>
> </function>
>
> - <function name="GetDebugMessageLogARB" offset="assign">
> + <function name="GetDebugMessageLogARB" alias="GetDebugMessageLog">
> <return type="GLuint"/>
> <param name="count" type="GLuint"/>
> <param name="bufsize" type="GLsizei"/>
> diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c
> index 5f4eac6..003d0d4 100644
> --- a/src/mesa/main/errors.c
> +++ b/src/mesa/main/errors.c
> @@ -39,9 +39,6 @@
> #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;
>
> @@ -374,40 +371,6 @@ 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,
> * and remember the number of bytes used by that string, *including*
> @@ -434,10 +397,6 @@ log_msg(struct gl_context *ctx, enum mesa_debug_source source,
> GLenum gl_type = debug_type_enums[type];
> GLenum gl_severity = debug_severity_enums[severity];
>
> - if (debug->ARBCallback) {
> - gl_severity = remap_severity(gl_severity);
> - gl_type = remap_type(gl_type);
> - }
> debug->Callback(debug_source_enums[source], gl_type, id, gl_severity,
> len, buf, debug->CallbackData);
> return;
> @@ -471,8 +430,7 @@ log_msg(struct gl_context *ctx, enum mesa_debug_source source,
> */
> static GLsizei
> get_msg(struct gl_context *ctx, GLenum *source, GLenum *type,
> - GLuint *id, GLenum *severity, GLsizei bufSize, char *buf,
> - unsigned caller)
> + GLuint *id, GLenum *severity, GLsizei bufSize, char *buf)
> {
> struct gl_debug_state *debug = _mesa_get_debug_state(ctx);
> struct gl_debug_msg *msg;
> @@ -491,8 +449,6 @@ get_msg(struct gl_context *ctx, GLenum *source, GLenum *type,
>
> if (severity) {
> *severity = debug_severity_enums[msg->severity];
> - if (caller == MESSAGE_LOG_ARB)
> - *severity = remap_severity(*severity);
> }
>
> if (source) {
> @@ -501,8 +457,6 @@ get_msg(struct gl_context *ctx, GLenum *source, GLenum *type,
>
> if (type) {
> *type = debug_type_enums[msg->type];
> - if (caller == MESSAGE_LOG_ARB)
> - *type = remap_type(*type);
> }
>
> if (id) {
> @@ -530,12 +484,9 @@ get_msg(struct gl_context *ctx, GLenum *source, GLenum *type,
>
> /**
> * Verify that source, type, and severity are valid enums.
> - * glDebugMessageInsertARB only accepts two values for 'source',
> - * and glDebugMessageControlARB will additionally accept GL_DONT_CARE
> - * in any parameter, so handle those cases specially.
> *
> - * There is also special cases for handling values available in
> - * GL_KHR_debug that are not avaliable in GL_ARB_debug_output
> + * The 'caller' param is used for handling values available
> + * only in glDebugMessageInsert or glDebugMessageControl
> */
> static GLboolean
> validate_params(struct gl_context *ctx, unsigned caller,
> @@ -544,8 +495,6 @@ validate_params(struct gl_context *ctx, unsigned caller,
> {
> #define INSERT 1
> #define CONTROL 2
> -#define INSERT_ARB 3
> -#define CONTROL_ARB 4
> switch(source) {
> case GL_DEBUG_SOURCE_APPLICATION_ARB:
> case GL_DEBUG_SOURCE_THIRD_PARTY_ARB:
> @@ -554,10 +503,10 @@ validate_params(struct gl_context *ctx, unsigned caller,
> case GL_DEBUG_SOURCE_SHADER_COMPILER_ARB:
> case GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB:
> case GL_DEBUG_SOURCE_OTHER_ARB:
> - if (caller != INSERT || caller == INSERT_ARB)
> + if (caller != INSERT)
> break;
> case GL_DONT_CARE:
> - if (caller == CONTROL || caller == CONTROL_ARB)
> + if (caller == CONTROL)
> break;
> default:
> goto error;
> @@ -570,13 +519,10 @@ validate_params(struct gl_context *ctx, unsigned caller,
> case GL_DEBUG_TYPE_PERFORMANCE_ARB:
> case GL_DEBUG_TYPE_PORTABILITY_ARB:
> case GL_DEBUG_TYPE_OTHER_ARB:
> - break;
> case GL_DEBUG_TYPE_MARKER:
> - /* this value is only valid for GL_KHR_debug functions */
> - if (caller == CONTROL || caller == INSERT)
> - break;
> + break;
> case GL_DONT_CARE:
> - if (caller == CONTROL || caller == CONTROL_ARB)
> + if (caller == CONTROL)
> break;
> default:
> goto error;
> @@ -586,13 +532,10 @@ validate_params(struct gl_context *ctx, unsigned caller,
> case GL_DEBUG_SEVERITY_HIGH_ARB:
> case GL_DEBUG_SEVERITY_MEDIUM_ARB:
> case GL_DEBUG_SEVERITY_LOW_ARB:
> - break;
> case GL_DEBUG_SEVERITY_NOTIFICATION:
> - /* this value is only valid for GL_KHR_debug functions */
> - if (caller == CONTROL || caller == INSERT)
> - break;
> + break;
> case GL_DONT_CARE:
> - if (caller == CONTROL || caller == CONTROL_ARB)
> + if (caller == CONTROL)
> break;
> default:
> goto error;
> @@ -707,44 +650,6 @@ control_app_messages(struct gl_context *ctx, GLenum esource, GLenum etype,
>
>
> /**
> - * This is a generic message control function for use by both
> - * glDebugMessageControlARB and glDebugMessageControl.
> - */
> -static void
> -message_control(GLenum gl_source, GLenum gl_type,
> - GLenum gl_severity,
> - GLsizei count, const GLuint *ids,
> - GLboolean enabled,
> - unsigned caller, const char *callerstr)
> -{
> - GET_CURRENT_CONTEXT(ctx);
> -
> - if (count < 0) {
> - _mesa_error(ctx, GL_INVALID_VALUE,
> - "%s(count=%d : count must not be negative)", callerstr,
> - count);
> - return;
> - }
> -
> - if (!validate_params(ctx, caller, callerstr, gl_source, gl_type,
> - gl_severity))
> - return; /* GL_INVALID_ENUM */
> -
> - if (count && (gl_severity != GL_DONT_CARE || gl_type == GL_DONT_CARE
> - || gl_source == GL_DONT_CARE)) {
> - _mesa_error(ctx, GL_INVALID_OPERATION,
> - "%s(When passing an array of ids, severity must be"
> - " GL_DONT_CARE, and source and type must not be GL_DONT_CARE.",
> - callerstr);
> - return;
> - }
> -
> - control_app_messages(ctx, gl_source, gl_type, gl_severity,
> - count, ids, enabled);
> -}
> -
> -
> -/**
> * This is a generic message insert function.
> * Validation of source, type and severity parameters should be done
> * before calling this funtion.
> @@ -774,58 +679,6 @@ message_insert(GLenum source, GLenum type, GLuint id,
> }
>
>
> -/**
> - * This is a generic message insert function for use by both
> - * glGetDebugMessageLogARB and glGetDebugMessageLog.
> - */
> -static GLuint
> -get_message_log(GLuint count, GLsizei logSize, GLenum *sources,
> - GLenum *types, GLenum *ids, GLenum *severities,
> - GLsizei *lengths, GLchar *messageLog,
> - unsigned caller, const char *callerstr)
> -{
> - GET_CURRENT_CONTEXT(ctx);
> - GLuint ret;
> -
> - if (!messageLog)
> - logSize = 0;
> -
> - if (logSize < 0) {
> - _mesa_error(ctx, GL_INVALID_VALUE,
> - "%s(logSize=%d : logSize must not be negative)", callerstr,
> - logSize);
> - return 0;
> - }
> -
> - for (ret = 0; ret < count; ret++) {
> - GLsizei written = get_msg(ctx, sources, types, ids, severities,
> - logSize, messageLog, caller);
> - if (!written)
> - break;
> -
> - if (messageLog) {
> - messageLog += written;
> - logSize -= written;
> - }
> - if (lengths) {
> - *lengths = written;
> - lengths++;
> - }
> -
> - if (severities)
> - severities++;
> - if (sources)
> - sources++;
> - if (types)
> - types++;
> - if (ids)
> - ids++;
> - }
> -
> - return ret;
> -}
> -
> -
> static void
> do_nothing(GLuint key, void *data, void *userData)
> {
> @@ -888,22 +741,79 @@ _mesa_GetDebugMessageLog(GLuint count, GLsizei logSize, GLenum *sources,
> GLenum *types, GLenum *ids, GLenum *severities,
> GLsizei *lengths, GLchar *messageLog)
> {
> - const char *callerstr = "glGetDebugMessageLog";
> + GET_CURRENT_CONTEXT(ctx);
> + GLuint ret;
> +
> + if (!messageLog)
> + logSize = 0;
> +
> + if (logSize < 0) {
> + _mesa_error(ctx, GL_INVALID_VALUE,
> + "glGetDebugMessageLog(logSize=%d : logSize must not be"
> + " negative)", logSize);
> + return 0;
> + }
> +
> + for (ret = 0; ret < count; ret++) {
> + GLsizei written = get_msg(ctx, sources, types, ids, severities,
> + logSize, messageLog);
> + if (!written)
> + break;
> +
> + if (messageLog) {
> + messageLog += written;
> + logSize -= written;
> + }
> + if (lengths) {
> + *lengths = written;
> + lengths++;
> + }
> +
> + if (severities)
> + severities++;
> + if (sources)
> + sources++;
> + if (types)
> + types++;
> + if (ids)
> + ids++;
> + }
>
> - return get_message_log(count, logSize, sources, types, ids, severities,
> - lengths, messageLog, MESSAGE_LOG, callerstr);
> + return ret;
> }
>
>
> void GLAPIENTRY
> -_mesa_DebugMessageControl(GLenum source, GLenum type, GLenum severity,
> - GLsizei count, const GLuint *ids,
> - GLboolean enabled)
> +_mesa_DebugMessageControl(GLenum gl_source, GLenum gl_type,
> + GLenum gl_severity, GLsizei count,
> + const GLuint *ids, GLboolean enabled)
> {
> const char *callerstr = "glDebugMessageControl";
>
> - message_control(source, type, severity, count, ids,
> - enabled, CONTROL, callerstr);
> + GET_CURRENT_CONTEXT(ctx);
> +
> + if (count < 0) {
> + _mesa_error(ctx, GL_INVALID_VALUE,
> + "%s(count=%d : count must not be negative)", callerstr,
> + count);
> + return;
> + }
> +
> + if (!validate_params(ctx, CONTROL, callerstr, gl_source, gl_type,
> + gl_severity))
> + return; /* GL_INVALID_ENUM */
> +
> + if (count && (gl_severity != GL_DONT_CARE || gl_type == GL_DONT_CARE
> + || gl_source == GL_DONT_CARE)) {
> + _mesa_error(ctx, GL_INVALID_OPERATION,
> + "%s(When passing an array of ids, severity must be"
> + " GL_DONT_CARE, and source and type must not be GL_DONT_CARE.",
> + callerstr);
> + return;
> + }
> +
> + control_app_messages(ctx, gl_source, gl_type, gl_severity,
> + count, ids, enabled);
> }
>
>
> @@ -915,7 +825,6 @@ _mesa_DebugMessageCallback(GLDEBUGPROC callback, const void *userParam)
> if (debug) {
> debug->Callback = callback;
> debug->CallbackData = userParam;
> - debug->ARBCallback = GL_FALSE;
> }
> }
>
> @@ -1042,60 +951,6 @@ _mesa_PopDebugGroup(void)
> }
>
>
> -void GLAPIENTRY
> -_mesa_DebugMessageInsertARB(GLenum source, GLenum type, GLuint id,
> - GLenum severity, GLint length,
> - const GLcharARB *buf)
> -{
> - const char *callerstr = "glDebugMessageInsertARB";
> -
> - GET_CURRENT_CONTEXT(ctx);
> -
> - if (!validate_params(ctx, INSERT_ARB, callerstr, source, type, severity))
> - return; /* GL_INVALID_ENUM */
> -
> - message_insert(source, type, id, severity, length, buf, callerstr);
> -}
> -
> -
> -GLuint GLAPIENTRY
> -_mesa_GetDebugMessageLogARB(GLuint count, GLsizei logSize, GLenum *sources,
> - GLenum *types, GLenum *ids, GLenum *severities,
> - GLsizei *lengths, GLcharARB *messageLog)
> -{
> - const char *callerstr = "glGetDebugMessageLogARB";
> -
> - return get_message_log(count, logSize, sources, types, ids, severities,
> - lengths, messageLog, MESSAGE_LOG_ARB, callerstr);
> -}
> -
> -
> -void GLAPIENTRY
> -_mesa_DebugMessageControlARB(GLenum gl_source, GLenum gl_type,
> - GLenum gl_severity,
> - GLsizei count, const GLuint *ids,
> - GLboolean enabled)
> -{
> - const char *callerstr = "glDebugMessageControlARB";
> -
> - message_control(gl_source, gl_type, gl_severity, count, ids,
> - enabled, CONTROL_ARB, callerstr);
> -}
> -
> -
> -void GLAPIENTRY
> -_mesa_DebugMessageCallbackARB(GLDEBUGPROCARB callback, const void *userParam)
> -{
> - GET_CURRENT_CONTEXT(ctx);
> - struct gl_debug_state *debug = _mesa_get_debug_state(ctx);
> - if (debug) {
> - debug->Callback = callback;
> - debug->CallbackData = userParam;
> - debug->ARBCallback = GL_TRUE;
> - }
> -}
> -
> -
> void
> _mesa_init_errors(struct gl_context *ctx)
> {
> diff --git a/src/mesa/main/errors.h b/src/mesa/main/errors.h
> index cd414e6..e0706e5 100644
> --- a/src/mesa/main/errors.h
> +++ b/src/mesa/main/errors.h
> @@ -91,21 +91,6 @@ _mesa_shader_debug(struct gl_context *ctx, GLenum type, GLuint *id,
> const char *msg, int len);
>
> void GLAPIENTRY
> -_mesa_DebugMessageInsertARB(GLenum source, GLenum type, GLuint id,
> - GLenum severity, GLint length,
> - const GLcharARB* buf);
> -GLuint GLAPIENTRY
> -_mesa_GetDebugMessageLogARB(GLuint count, GLsizei logSize, GLenum* sources,
> - GLenum* types, GLenum* ids, GLenum* severities,
> - GLsizei* lengths, GLcharARB* messageLog);
> -void GLAPIENTRY
> -_mesa_DebugMessageControlARB(GLenum source, GLenum type, GLenum severity,
> - GLsizei count, const GLuint *ids,
> - GLboolean enabled);
> -void GLAPIENTRY
> -_mesa_DebugMessageCallbackARB(GLDEBUGPROCARB callback,
> - const void *userParam);
> -void GLAPIENTRY
> _mesa_DebugMessageInsert(GLenum source, GLenum type, GLuint id,
> GLenum severity, GLint length,
> const GLchar* buf);
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index 7246b1e..8a4d125 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -3843,7 +3843,6 @@ 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