[Mesa-dev] [PATCH 12/21] mesa: refactor _mesa_PopDebugGroup and _mesa_free_errors_data
Timothy Arceri
t_arceri at yahoo.com.au
Tue Apr 22 04:31:00 PDT 2014
On Tue, 2014-04-22 at 16:58 +0800, Chia-I Wu wrote:
> Move group clearing to debug_clear_group. Add debug_pop_group and
> debug_destroy for use in _mesa_PopDebugGroup and _mesa_free_errors_data
> respectively.
debug_destroy is not very specific debug_destroy_groups maybe?
>
> Signed-off-by: Chia-I Wu <olv at lunarg.com>
> ---
> src/mesa/main/errors.c | 127 +++++++++++++++++++++++++------------------------
> 1 file changed, 64 insertions(+), 63 deletions(-)
>
> diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c
> index 9873dfc..139e31d 100644
> --- a/src/mesa/main/errors.c
> +++ b/src/mesa/main/errors.c
> @@ -217,7 +217,57 @@ debug_create(void)
> return debug;
> }
>
> -/*
> +static void
> +debug_clear_group_cb(GLuint key, void *data, void *userData)
> +{
> +}
> +
> +/**
> + * Free debug state for the given stack depth.
> + */
> +static void
> +debug_clear_group(struct gl_debug_state *debug, GLint gstack)
> +{
> + enum mesa_debug_type t;
> + enum mesa_debug_source s;
> + enum mesa_debug_severity sev;
> +
> + /* Tear down state for filtering debug messages. */
> + for (s = 0; s < MESA_DEBUG_SOURCE_COUNT; s++) {
> + for (t = 0; t < MESA_DEBUG_TYPE_COUNT; t++) {
> + struct gl_debug_namespace *nspace = &debug->Namespaces[gstack][s][t];
> +
> + _mesa_HashDeleteAll(nspace->IDs, debug_clear_group_cb, NULL);
> + _mesa_DeleteHashTable(nspace->IDs);
> + for (sev = 0; sev < MESA_DEBUG_SEVERITY_COUNT; sev++) {
> + struct simple_node *node, *tmp;
> + struct gl_debug_severity *entry;
> +
> + foreach_s(node, tmp, &nspace->Severity[sev]) {
> + entry = (struct gl_debug_severity *)node;
> + free(entry);
> + }
> + }
> + }
> + }
> +}
> +
> +/**
> + * Loop through debug group stack tearing down states for
> + * filtering debug messages. Then free debug output state.
> + */
> +static void
> +debug_destroy(struct gl_debug_state *debug)
> +{
> + GLint i;
> +
> + for (i = 0; i <= debug->GroupStackDepth; i++)
> + debug_clear_group(debug, i);
> +
> + free(debug);
> +}
> +
> +/**
> * Sets the state of the given message source/type/ID tuple.
> */
> static void
> @@ -538,6 +588,15 @@ out:
> debug->GroupStackDepth++;
> }
>
> +static void
> +debug_pop_group(struct gl_debug_state *debug)
> +{
> + const GLint gstack = debug->GroupStackDepth;
> +
> + debug->GroupStackDepth--;
> + debug_clear_group(debug, gstack);
> +}
> +
>
> /**
> * Return debug state for the context. The debug state will be allocated
> @@ -840,47 +899,6 @@ message_insert(GLenum source, GLenum type, GLuint id,
> }
>
>
> -static void
> -do_nothing(GLuint key, void *data, void *userData)
> -{
> -}
> -
> -
> -/**
> - * Free context state pertaining to error/debug state for the given stack
> - * depth.
> - */
> -static void
> -free_errors_data(struct gl_context *ctx, GLint gstack)
> -{
> - struct gl_debug_state *debug = ctx->Debug;
> - enum mesa_debug_type t;
> - enum mesa_debug_source s;
> - enum mesa_debug_severity sev;
> -
> - assert(debug);
> -
> - /* Tear down state for filtering debug messages. */
> - for (s = 0; s < MESA_DEBUG_SOURCE_COUNT; s++) {
> - for (t = 0; t < MESA_DEBUG_TYPE_COUNT; t++) {
> - _mesa_HashDeleteAll(debug->Namespaces[gstack][s][t].IDs,
> - do_nothing, NULL);
> - _mesa_DeleteHashTable(debug->Namespaces[gstack][s][t].IDs);
> - for (sev = 0; sev < MESA_DEBUG_SEVERITY_COUNT; sev++) {
> - struct simple_node *node, *tmp;
> - struct gl_debug_severity *entry;
> -
> - foreach_s(node, tmp,
> - &debug->Namespaces[gstack][s][t].Severity[sev]) {
> - entry = (struct gl_debug_severity *)node;
> - free(entry);
> - }
> - }
> - }
> - }
> -}
> -
> -
> void GLAPIENTRY
> _mesa_DebugMessageInsert(GLenum source, GLenum type, GLuint id,
> GLenum severity, GLint length,
> @@ -1044,7 +1062,6 @@ _mesa_PopDebugGroup(void)
> struct gl_debug_state *debug = _mesa_get_debug_state(ctx);
> const char *callerstr = "glPopDebugGroup";
> struct gl_debug_msg *gdmessage;
> - GLint prevStackDepth;
>
> if (!debug)
> return;
> @@ -1054,10 +1071,9 @@ _mesa_PopDebugGroup(void)
> return;
> }
>
> - prevStackDepth = debug->GroupStackDepth;
> - debug->GroupStackDepth--;
> + debug_pop_group(debug);
>
> - gdmessage = &debug->DebugGroupMsgs[prevStackDepth];
> + gdmessage = debug_get_group_message(debug);
> /* using log_msg() directly here as verification of parameters
> * already done in push
> */
> @@ -1067,13 +1083,7 @@ _mesa_PopDebugGroup(void)
> gl_enum_to_debug_severity(GL_DEBUG_SEVERITY_NOTIFICATION),
> gdmessage->length, gdmessage->message);
>
> - if (gdmessage->message != (char*)out_of_memory)
> - free(gdmessage->message);
> - gdmessage->message = NULL;
> - gdmessage->length = 0;
> -
> - /* free popped debug group data */
> - free_errors_data(ctx, prevStackDepth);
> + debug_clear_message(debug, gdmessage);
> }
>
>
> @@ -1084,20 +1094,11 @@ _mesa_init_errors(struct gl_context *ctx)
> }
>
>
> -/**
> - * Loop through debug group stack tearing down states for
> - * filtering debug messages. Then free debug output state.
> - */
> void
> _mesa_free_errors_data(struct gl_context *ctx)
> {
> if (ctx->Debug) {
> - GLint i;
> -
> - for (i = 0; i <= ctx->Debug->GroupStackDepth; i++) {
> - free_errors_data(ctx, i);
> - }
> - free(ctx->Debug);
> + debug_destroy(ctx->Debug);
> /* set to NULL just in case it is used before context is completely gone. */
> ctx->Debug = NULL;
> }
More information about the mesa-dev
mailing list