diff options
author | Chia-I Wu <[email protected]> | 2014-04-22 10:10:30 +0800 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2014-04-27 10:06:20 +0800 |
commit | 672b209225c704f31a4780e95d2487013c8a1c3a (patch) | |
tree | a008dfee2c30a15d928ee6826cbc5fba8400e881 | |
parent | 9339f8ac1bc41942c77db6fbbe0dccab42efad4c (diff) |
mesa: refactor _mesa_get_debug_state
Move gl_debug_state allocation to a new function, debug_create. No functional
change.
Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-by: Brian Paul <[email protected]>
-rw-r--r-- | src/mesa/main/errors.c | 62 |
1 files changed, 37 insertions, 25 deletions
diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c index d80fda0dbd2..66d3146c12c 100644 --- a/src/mesa/main/errors.c +++ b/src/mesa/main/errors.c @@ -181,6 +181,42 @@ enum { ENABLED = ENABLED_BIT | FOUND_BIT }; +/** + * Allocate and initialize context debug state. + */ +static struct gl_debug_state * +debug_create(void) +{ + struct gl_debug_state *debug; + int s, t, sev; + + debug = CALLOC_STRUCT(gl_debug_state); + if (!debug) + return NULL; + + /* Enable all the messages with severity HIGH or MEDIUM by default. */ + memset(debug->Defaults[0][MESA_DEBUG_SEVERITY_HIGH], GL_TRUE, + sizeof debug->Defaults[0][MESA_DEBUG_SEVERITY_HIGH]); + memset(debug->Defaults[0][MESA_DEBUG_SEVERITY_MEDIUM], GL_TRUE, + sizeof debug->Defaults[0][MESA_DEBUG_SEVERITY_MEDIUM]); + memset(debug->Defaults[0][MESA_DEBUG_SEVERITY_LOW], GL_FALSE, + sizeof debug->Defaults[0][MESA_DEBUG_SEVERITY_LOW]); + + /* Initialize state for filtering known debug messages. */ + for (s = 0; s < MESA_DEBUG_SOURCE_COUNT; s++) { + for (t = 0; t < MESA_DEBUG_TYPE_COUNT; t++) { + debug->Namespaces[0][s][t].IDs = _mesa_NewHashTable(); + assert(debug->Namespaces[0][s][t].IDs); + + for (sev = 0; sev < MESA_DEBUG_SEVERITY_COUNT; sev++) { + make_empty_list(&debug->Namespaces[0][s][t].Severity[sev]); + } + } + } + + return debug; +} + /** * Return debug state for the context. The debug state will be allocated @@ -190,34 +226,10 @@ struct gl_debug_state * _mesa_get_debug_state(struct gl_context *ctx) { if (!ctx->Debug) { - ctx->Debug = CALLOC_STRUCT(gl_debug_state); + ctx->Debug = debug_create(); if (!ctx->Debug) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "allocating debug state"); } - else { - struct gl_debug_state *debug = ctx->Debug; - int s, t, sev; - - /* Enable all the messages with severity HIGH or MEDIUM by default. */ - memset(debug->Defaults[0][MESA_DEBUG_SEVERITY_HIGH], GL_TRUE, - sizeof debug->Defaults[0][MESA_DEBUG_SEVERITY_HIGH]); - memset(debug->Defaults[0][MESA_DEBUG_SEVERITY_MEDIUM], GL_TRUE, - sizeof debug->Defaults[0][MESA_DEBUG_SEVERITY_MEDIUM]); - memset(debug->Defaults[0][MESA_DEBUG_SEVERITY_LOW], GL_FALSE, - sizeof debug->Defaults[0][MESA_DEBUG_SEVERITY_LOW]); - - /* Initialize state for filtering known debug messages. */ - for (s = 0; s < MESA_DEBUG_SOURCE_COUNT; s++) { - for (t = 0; t < MESA_DEBUG_TYPE_COUNT; t++) { - debug->Namespaces[0][s][t].IDs = _mesa_NewHashTable(); - assert(debug->Namespaces[0][s][t].IDs); - - for (sev = 0; sev < MESA_DEBUG_SEVERITY_COUNT; sev++) { - make_empty_list(&debug->Namespaces[0][s][t].Severity[sev]); - } - } - } - } } return ctx->Debug; |