mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 11:08:03 +02:00
mesa: refactor _mesa_PopDebugGroup and _mesa_free_errors_data
Replace free_errors_data by debug_clear_group. Add debug_pop_group and debug_destroy for use in _mesa_PopDebugGroup and _mesa_free_errors_data respectively. No funcitonal change. Signed-off-by: Chia-I Wu <olv@lunarg.com> Reviewed-by: Brian Paul <brianp@vmware.com>
This commit is contained in:
parent
f1d00dce43
commit
04a8baad37
1 changed files with 63 additions and 62 deletions
|
|
@ -259,7 +259,57 @@ debug_create(void)
|
||||||
return debug;
|
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.
|
* Sets the state of the given message source/type/ID tuple.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
|
|
@ -533,6 +583,15 @@ out:
|
||||||
debug->GroupStackDepth++;
|
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
|
* Return debug state for the context. The debug state will be allocated
|
||||||
|
|
@ -835,47 +894,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
|
void GLAPIENTRY
|
||||||
_mesa_DebugMessageInsert(GLenum source, GLenum type, GLuint id,
|
_mesa_DebugMessageInsert(GLenum source, GLenum type, GLuint id,
|
||||||
GLenum severity, GLint length,
|
GLenum severity, GLint length,
|
||||||
|
|
@ -1039,7 +1057,6 @@ _mesa_PopDebugGroup(void)
|
||||||
struct gl_debug_state *debug = _mesa_get_debug_state(ctx);
|
struct gl_debug_state *debug = _mesa_get_debug_state(ctx);
|
||||||
const char *callerstr = "glPopDebugGroup";
|
const char *callerstr = "glPopDebugGroup";
|
||||||
struct gl_debug_msg *gdmessage;
|
struct gl_debug_msg *gdmessage;
|
||||||
GLint prevStackDepth;
|
|
||||||
|
|
||||||
if (!debug)
|
if (!debug)
|
||||||
return;
|
return;
|
||||||
|
|
@ -1049,8 +1066,7 @@ _mesa_PopDebugGroup(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
prevStackDepth = debug->GroupStackDepth;
|
debug_pop_group(debug);
|
||||||
debug->GroupStackDepth--;
|
|
||||||
|
|
||||||
gdmessage = debug_get_group_message(debug);
|
gdmessage = debug_get_group_message(debug);
|
||||||
/* using log_msg() directly here as verification of parameters
|
/* using log_msg() directly here as verification of parameters
|
||||||
|
|
@ -1062,13 +1078,7 @@ _mesa_PopDebugGroup(void)
|
||||||
gl_enum_to_debug_severity(GL_DEBUG_SEVERITY_NOTIFICATION),
|
gl_enum_to_debug_severity(GL_DEBUG_SEVERITY_NOTIFICATION),
|
||||||
gdmessage->length, gdmessage->message);
|
gdmessage->length, gdmessage->message);
|
||||||
|
|
||||||
if (gdmessage->message != (char*)out_of_memory)
|
debug_message_clear(gdmessage);
|
||||||
free(gdmessage->message);
|
|
||||||
gdmessage->message = NULL;
|
|
||||||
gdmessage->length = 0;
|
|
||||||
|
|
||||||
/* free popped debug group data */
|
|
||||||
free_errors_data(ctx, prevStackDepth);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1079,20 +1089,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
|
void
|
||||||
_mesa_free_errors_data(struct gl_context *ctx)
|
_mesa_free_errors_data(struct gl_context *ctx)
|
||||||
{
|
{
|
||||||
if (ctx->Debug) {
|
if (ctx->Debug) {
|
||||||
GLint i;
|
debug_destroy(ctx->Debug);
|
||||||
|
|
||||||
for (i = 0; i <= ctx->Debug->GroupStackDepth; i++) {
|
|
||||||
free_errors_data(ctx, i);
|
|
||||||
}
|
|
||||||
free(ctx->Debug);
|
|
||||||
/* set to NULL just in case it is used before context is completely gone. */
|
/* set to NULL just in case it is used before context is completely gone. */
|
||||||
ctx->Debug = NULL;
|
ctx->Debug = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue