GL_DEBUG_SEVERITY_NOTIFICATION,
};
+
static enum mesa_debug_source
gl_enum_to_debug_source(GLenum e)
{
}
}
+
/*
* We store a bitfield in the hash table, with five possible values total.
*
ENABLED = ENABLED_BIT | FOUND_BIT
};
+
/**
* Returns the state of the given message source/type/ID tuple.
*/
{
GLint gstack = ctx->Debug.GroupStackDepth;
struct gl_debug_namespace *nspace =
- &ctx->Debug.Namespaces[gstack][source][type];
+ &ctx->Debug.Namespaces[gstack][source][type];
uintptr_t state;
if (!ctx->Debug.DebugOutput)
return GL_FALSE;
/* In addition to not being able to store zero as a value, HashTable also
- can't use zero as a key. */
+ * can't use zero as a key.
+ */
if (id)
state = (uintptr_t)_mesa_HashLookup(nspace->IDs, id);
else
state = nspace->ZeroID;
/* Only do this once for each ID. This makes sure the ID exists in,
- at most, one list, and does not pointlessly appear multiple times. */
+ * at most, one list, and does not pointlessly appear multiple times.
+ */
if (!(state & KNOWN_SEVERITY)) {
struct gl_debug_severity *entry;
return !!(state & ENABLED_BIT);
}
+
/**
* Sets the state of the given message source/type/ID tuple.
*/
{
GLint gstack = ctx->Debug.GroupStackDepth;
struct gl_debug_namespace *nspace =
- &ctx->Debug.Namespaces[gstack][source][type];
+ &ctx->Debug.Namespaces[gstack][source][type];
uintptr_t state;
/* In addition to not being able to store zero as a value, HashTable also
- can't use zero as a key. */
+ * can't use zero as a key.
+ */
if (id)
state = (uintptr_t)_mesa_HashLookup(nspace->IDs, id);
else
nspace->ZeroID = state;
}
+
static void
store_message_details(struct gl_debug_msg *emptySlot,
enum mesa_debug_source source,
}
}
- /**
+
+/**
* Remap any type exclusive to KHR_debug to something suitable
* for ARB_debug_output
*/
return type;
}
+
/**
* Remap severity exclusive to KHR_debug to something suitable
* for ARB_debug_output
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,
gl_severity = remap_severity(gl_severity);
gl_type = remap_type(gl_type);
}
- ctx->Debug.Callback(debug_source_enums[source],
- gl_type,
- id,
- gl_severity,
+ ctx->Debug.Callback(debug_source_enums[source], gl_type, id, gl_severity,
len, buf, ctx->Debug.CallbackData);
return;
}
ctx->Debug.NumMessages++;
}
+
/**
* Pop the oldest debug message out of the log.
* Writes the message string, including the null terminator, into 'buf',
if (caller == MESSAGE_LOG_ARB)
*severity = remap_severity(*severity);
}
- if (source)
+
+ if (source) {
*source = debug_source_enums[msg->source];
+ }
+
if (type) {
*type = debug_type_enums[msg->type];
if (caller == MESSAGE_LOG_ARB)
*type = remap_type(*type);
}
- if (id)
+
+ if (id) {
*id = msg->id;
+ }
if (buf) {
assert(msg->message[length-1] == '\0');
return length;
}
+
/**
* Verify that source, type, and severity are valid enums.
* glDebugMessageInsertARB only accepts two values for 'source',
return GL_TRUE;
error:
- {
- _mesa_error(ctx, GL_INVALID_ENUM, "bad values passed to %s"
- "(source=0x%x, type=0x%x, severity=0x%x)", callerstr,
- source, type, severity);
- }
+ _mesa_error(ctx, GL_INVALID_ENUM, "bad values passed to %s"
+ "(source=0x%x, type=0x%x, severity=0x%x)", callerstr,
+ source, type, severity);
+
return GL_FALSE;
}
+
/**
* Set the state of all message IDs found in the given intersection of
* 'source', 'type', and 'severity'. The _COUNT enum can be used for
sevmax = severity+1;
}
- for (sev = severity; sev < sevmax; sev++)
- for (s = source; s < smax; s++)
+ for (sev = severity; sev < sevmax; sev++) {
+ for (s = source; s < smax; s++) {
for (t = type; t < tmax; t++) {
struct simple_node *node;
struct gl_debug_severity *entry;
set_message_state(ctx, s, t, entry->ID, enabled);
}
}
+ }
+ }
}
+
/**
* Debugging-message namespaces with the source APPLICATION or THIRD_PARTY
* require special handling, since the IDs in them are controlled by clients,
control_messages(ctx, source, type, severity, enabled);
}
+
/**
* This is a generic message control function for use by both
* glDebugMessageControlARB and glDebugMessageControl.
count, ids, enabled);
}
+
/**
* This is a generic message insert function.
* Validation of source, type and severity parameters should be done
*/
static void
message_insert(GLenum source, GLenum type, GLuint id,
- GLenum severity, GLint length, const GLchar* buf,
+ GLenum severity, GLint length, const GLchar *buf,
const char *callerstr)
{
GET_CURRENT_CONTEXT(ctx);
gl_enum_to_debug_severity(severity), length, buf);
}
+
/**
* 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,
+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);
return ret;
}
+
static void
do_nothing(GLuint key, void *data, void *userData)
{
}
+
static void
free_errors_data(struct gl_context *ctx, GLint gstack)
{
enum mesa_debug_severity sev;
/* Tear down state for filtering debug messages. */
- for (s = 0; s < MESA_DEBUG_SOURCE_COUNT; s++)
+ for (s = 0; s < MESA_DEBUG_SOURCE_COUNT; s++) {
for (t = 0; t < MESA_DEBUG_TYPE_COUNT; t++) {
_mesa_HashDeleteAll(ctx->Debug.Namespaces[gstack][s][t].IDs,
do_nothing, NULL);
}
}
}
+ }
}
+
void GLAPIENTRY
_mesa_DebugMessageInsert(GLenum source, GLenum type, GLuint id,
GLenum severity, GLint length,
- const GLchar* buf)
+ const GLchar *buf)
{
const char *callerstr = "glDebugMessageInsert";
if (!validate_params(ctx, INSERT, callerstr, source, type, severity))
return; /* GL_INVALID_ENUM */
- message_insert(source, type, id, severity, length, buf,
- callerstr);
+ message_insert(source, type, id, severity, length, buf, callerstr);
}
+
GLuint GLAPIENTRY
-_mesa_GetDebugMessageLog(GLuint count, GLsizei logSize, GLenum* sources,
- GLenum* types, GLenum* ids, GLenum* severities,
- GLsizei* lengths, GLchar* messageLog)
+_mesa_GetDebugMessageLog(GLuint count, GLsizei logSize, GLenum *sources,
+ GLenum *types, GLenum *ids, GLenum *severities,
+ GLsizei *lengths, GLchar *messageLog)
{
const char *callerstr = "glGetDebugMessageLog";
lengths, messageLog, MESSAGE_LOG, callerstr);
}
+
void GLAPIENTRY
_mesa_DebugMessageControl(GLenum source, GLenum type, GLenum severity,
GLsizei count, const GLuint *ids,
enabled, CONTROL, callerstr);
}
+
void GLAPIENTRY
_mesa_DebugMessageCallback(GLDEBUGPROC callback, const void *userParam)
{
ctx->Debug.ARBCallback = GL_FALSE;
}
+
void GLAPIENTRY
_mesa_PushDebugGroup(GLenum source, GLuint id, GLsizei length,
const GLchar *message)
/* inherit the control volume of the debug group previously residing on
* the top of the debug group stack
*/
- for (s = 0; s < MESA_DEBUG_SOURCE_COUNT; s++)
+ for (s = 0; s < MESA_DEBUG_SOURCE_COUNT; s++) {
for (t = 0; t < MESA_DEBUG_TYPE_COUNT; t++) {
/* copy id settings */
ctx->Debug.Namespaces[currStackDepth][s][t].IDs =
struct simple_node *node;
/* copy default settings for unknown ids */
- ctx->Debug.Defaults[currStackDepth][sev][s][t] = ctx->Debug.Defaults[prevStackDepth][sev][s][t];
+ ctx->Debug.Defaults[currStackDepth][sev][s][t] =
+ ctx->Debug.Defaults[prevStackDepth][sev][s][t];
/* copy known id severity settings */
make_empty_list(&ctx->Debug.Namespaces[currStackDepth][s][t].Severity[sev]);
}
}
}
+ }
}
+
void GLAPIENTRY
_mesa_PopDebugGroup(void)
{
free_errors_data(ctx, prevStackDepth);
}
+
void GLAPIENTRY
_mesa_DebugMessageInsertARB(GLenum source, GLenum type, GLuint id,
GLenum severity, GLint length,
- const GLcharARB* buf)
+ const GLcharARB *buf)
{
const char *callerstr = "glDebugMessageInsertARB";
if (!validate_params(ctx, INSERT_ARB, callerstr, source, type, severity))
return; /* GL_INVALID_ENUM */
- message_insert(source, type, id, severity, length, buf,
- callerstr);
+ 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)
+_mesa_GetDebugMessageLogARB(GLuint count, GLsizei logSize, GLenum *sources,
+ GLenum *types, GLenum *ids, GLenum *severities,
+ GLsizei *lengths, GLcharARB *messageLog)
{
const char *callerstr = "glGetDebugMessageLogARB";
lengths, messageLog, MESSAGE_LOG_ARB, callerstr);
}
+
void GLAPIENTRY
_mesa_DebugMessageControlARB(GLenum gl_source, GLenum gl_type,
GLenum gl_severity,
enabled, CONTROL_ARB, callerstr);
}
+
void GLAPIENTRY
_mesa_DebugMessageCallbackARB(GLDEBUGPROCARB callback, const void *userParam)
{
ctx->Debug.ARBCallback = GL_TRUE;
}
+
void
_mesa_init_errors(struct gl_context *ctx)
{
sizeof ctx->Debug.Defaults[0][MESA_DEBUG_SEVERITY_LOW]);
/* Initialize state for filtering known debug messages. */
- for (s = 0; s < MESA_DEBUG_SOURCE_COUNT; s++)
+ for (s = 0; s < MESA_DEBUG_SOURCE_COUNT; s++) {
for (t = 0; t < MESA_DEBUG_TYPE_COUNT; t++) {
ctx->Debug.Namespaces[0][s][t].IDs = _mesa_NewHashTable();
assert(ctx->Debug.Namespaces[0][s][t].IDs);
- for (sev = 0; sev < MESA_DEBUG_SEVERITY_COUNT; sev++)
+ for (sev = 0; sev < MESA_DEBUG_SEVERITY_COUNT; sev++) {
make_empty_list(&ctx->Debug.Namespaces[0][s][t].Severity[sev]);
+ }
}
+ }
}
+
/**
* Loop through debug group stack tearing down states for
* filtering debug messages.
}
}
+
/**********************************************************************/
/** \name Diagnostics */
/*@{*/
}
}
+
/**
* When a new type of error is recorded, print a message describing
* previous errors which were accumulated.
}
}
+
static GLboolean
should_output(struct gl_context *ctx, GLenum error, const char *fmtString)
{
return GL_FALSE;
}
+
void
_mesa_gl_debug(struct gl_context *ctx,
GLuint *id,
if (len >= MAX_DEBUG_MESSAGE_LENGTH) {
/* Too long error message. Whoever calls _mesa_error should use
- * shorter strings. */
+ * shorter strings.
+ */
ASSERT(0);
return;
}