mesa: refactor debug output should_log
Move the message filtering logic to debug_is_message_enabled. No functional change. Signed-off-by: Chia-I Wu <olv@lunarg.com> Reviewed-by: Brian Paul <brianp@vmware.com>
This commit is contained in:
@@ -217,52 +217,23 @@ debug_create(void)
|
||||
return debug;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return debug state for the context. The debug state will be allocated
|
||||
* and initialized upon the first call.
|
||||
* Returns if the given message source/type/ID tuple is enabled.
|
||||
*/
|
||||
struct gl_debug_state *
|
||||
_mesa_get_debug_state(struct gl_context *ctx)
|
||||
{
|
||||
if (!ctx->Debug) {
|
||||
ctx->Debug = debug_create();
|
||||
if (!ctx->Debug) {
|
||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "allocating debug state");
|
||||
}
|
||||
}
|
||||
|
||||
return ctx->Debug;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the state of the given message source/type/ID tuple.
|
||||
*/
|
||||
static GLboolean
|
||||
should_log(struct gl_context *ctx,
|
||||
static bool
|
||||
debug_is_message_enabled(struct gl_debug_state *debug,
|
||||
enum mesa_debug_source source,
|
||||
enum mesa_debug_type type,
|
||||
GLuint id,
|
||||
enum mesa_debug_severity severity)
|
||||
{
|
||||
struct gl_debug_state *debug;
|
||||
uintptr_t state = 0;
|
||||
|
||||
if (!ctx->Debug) {
|
||||
/* no debug state set so far */
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
debug = _mesa_get_debug_state(ctx);
|
||||
if (debug) {
|
||||
const GLint gstack = debug->GroupStackDepth;
|
||||
struct gl_debug_namespace *nspace =
|
||||
&debug->Namespaces[gstack][source][type];
|
||||
uintptr_t state = 0;
|
||||
|
||||
if (!debug->DebugOutput)
|
||||
return GL_FALSE;
|
||||
return false;
|
||||
|
||||
/* In addition to not being able to store zero as a value, HashTable also
|
||||
* can't use zero as a key.
|
||||
@@ -299,9 +270,49 @@ should_log(struct gl_context *ctx,
|
||||
entry->ID = id;
|
||||
insert_at_tail(&nspace->Severity[severity], &entry->link);
|
||||
}
|
||||
}
|
||||
out:
|
||||
return !!(state & ENABLED_BIT);
|
||||
return (state & ENABLED_BIT);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return debug state for the context. The debug state will be allocated
|
||||
* and initialized upon the first call.
|
||||
*/
|
||||
struct gl_debug_state *
|
||||
_mesa_get_debug_state(struct gl_context *ctx)
|
||||
{
|
||||
if (!ctx->Debug) {
|
||||
ctx->Debug = debug_create();
|
||||
if (!ctx->Debug) {
|
||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "allocating debug state");
|
||||
}
|
||||
}
|
||||
|
||||
return ctx->Debug;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static GLboolean
|
||||
should_log(struct gl_context *ctx,
|
||||
enum mesa_debug_source source,
|
||||
enum mesa_debug_type type,
|
||||
GLuint id,
|
||||
enum mesa_debug_severity severity)
|
||||
{
|
||||
struct gl_debug_state *debug;
|
||||
|
||||
if (!ctx->Debug) {
|
||||
/* no debug state set so far */
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
debug = _mesa_get_debug_state(ctx);
|
||||
if (debug)
|
||||
return debug_is_message_enabled(debug, source, type, id, severity);
|
||||
else
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user