SOURCE_ANY = -1
};
-enum {
- TYPE_ERROR,
- TYPE_DEPRECATED,
- TYPE_UNDEFINED,
- TYPE_PORTABILITY,
- TYPE_PERFORMANCE,
- TYPE_OTHER,
-
- TYPE_COUNT,
- TYPE_ANY = -1
+static const GLenum debug_type_enums[] = {
+ GL_DEBUG_TYPE_ERROR,
+ GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR,
+ GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR,
+ GL_DEBUG_TYPE_PORTABILITY,
+ GL_DEBUG_TYPE_PERFORMANCE,
+ GL_DEBUG_TYPE_OTHER,
};
-enum {
- SEVERITY_LOW,
- SEVERITY_MEDIUM,
- SEVERITY_HIGH,
-
- SEVERITY_COUNT,
- SEVERITY_ANY = -1
+static const GLenum debug_severity_enums[] = {
+ GL_DEBUG_SEVERITY_LOW,
+ GL_DEBUG_SEVERITY_MEDIUM,
+ GL_DEBUG_SEVERITY_HIGH,
};
+static enum mesa_debug_type
+gl_enum_to_debug_type(GLenum e)
+{
+ int i;
+
+ for (i = 0; i < Elements(debug_type_enums); i++) {
+ if (debug_type_enums[i] == e)
+ break;
+ }
+ return i;
+}
+
+static enum mesa_debug_severity
+gl_enum_to_debug_severity(GLenum e)
+{
+ int i;
+
+ for (i = 0; i < Elements(debug_severity_enums); i++) {
+ if (debug_severity_enums[i] == e)
+ break;
+ }
+ return i;
+}
+
static int
enum_to_index(GLenum e)
{
case GL_DEBUG_SOURCE_THIRD_PARTY_ARB:
return (int)SOURCE_THIRD_PARTY;
- case GL_DEBUG_TYPE_ERROR_ARB:
- return (int)TYPE_ERROR;
- case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB:
- return (int)TYPE_DEPRECATED;
- case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB:
- return (int)TYPE_UNDEFINED;
- case GL_DEBUG_TYPE_PERFORMANCE_ARB:
- return (int)TYPE_PERFORMANCE;
- case GL_DEBUG_TYPE_PORTABILITY_ARB:
- return (int)TYPE_PORTABILITY;
- case GL_DEBUG_TYPE_OTHER_ARB:
- return (int)TYPE_OTHER;
-
- case GL_DEBUG_SEVERITY_LOW_ARB:
- return (int)SEVERITY_LOW;
- case GL_DEBUG_SEVERITY_MEDIUM_ARB:
- return (int)SEVERITY_MEDIUM;
- case GL_DEBUG_SEVERITY_HIGH_ARB:
- return (int)SEVERITY_HIGH;
-
case GL_DONT_CARE:
- return (int)TYPE_ANY;
+ return (int)SOURCE_ANY;
default:
assert(0 && "unreachable");
};
}
-
/*
* We store a bitfield in the hash table, with five possible values total.
*
* not GL enums.
*/
static GLboolean
-get_message_state(struct gl_context *ctx, int source, int type,
- GLuint id, int severity)
+get_message_state(struct gl_context *ctx, int source,
+ enum mesa_debug_type type,
+ GLuint id,
+ enum mesa_debug_severity severity)
{
struct gl_client_namespace *nspace =
&ctx->Debug.ClientIDs.Namespaces[source][type];
{
if (source == GL_DEBUG_SOURCE_APPLICATION_ARB ||
source == GL_DEBUG_SOURCE_THIRD_PARTY_ARB) {
- int s, t, sev;
- s = enum_to_index(source);
- t = enum_to_index(type);
- sev = enum_to_index(severity);
+ int s = enum_to_index(source);
+ enum mesa_debug_type t = gl_enum_to_debug_type(type);
+ enum mesa_debug_severity sev = gl_enum_to_debug_severity(severity);
return get_message_state(ctx, s, t, sev, id);
}
smax = source+1;
}
- if (type == TYPE_ANY) {
+ if (type == MESA_DEBUG_TYPE_COUNT) {
type = 0;
- tmax = TYPE_COUNT;
+ tmax = MESA_DEBUG_TYPE_COUNT;
} else {
tmax = type+1;
}
- if (severity == SEVERITY_ANY) {
+ if (severity == MESA_DEBUG_SEVERITY_COUNT) {
severity = 0;
- sevmax = SEVERITY_COUNT;
+ sevmax = MESA_DEBUG_SEVERITY_COUNT;
} else {
sevmax = severity+1;
}
GLenum eseverity, GLsizei count, const GLuint *ids,
GLboolean enabled)
{
- int source, type, severity;
GLsizei i;
-
- source = enum_to_index(esource);
- type = enum_to_index(etype);
- severity = enum_to_index(eseverity);
+ int source = enum_to_index(esource);
+ enum mesa_debug_type type = gl_enum_to_debug_type(etype);
+ enum mesa_debug_severity severity = gl_enum_to_debug_severity(eseverity);
if (count)
- assert(severity == SEVERITY_ANY && type != TYPE_ANY
+ assert(severity == MESA_DEBUG_SEVERITY_COUNT
+ && type != MESA_DEBUG_TYPE_COUNT
&& source != SOURCE_ANY);
for (i = 0; i < count; i++)
memset(ctx->Debug.WinsysErrors, GL_TRUE, sizeof ctx->Debug.WinsysErrors);
memset(ctx->Debug.ShaderErrors, GL_TRUE, sizeof ctx->Debug.ShaderErrors);
memset(ctx->Debug.OtherErrors, GL_TRUE, sizeof ctx->Debug.OtherErrors);
- memset(ClientIDs->Defaults[SEVERITY_HIGH], GL_TRUE,
- sizeof ClientIDs->Defaults[SEVERITY_HIGH]);
- memset(ClientIDs->Defaults[SEVERITY_MEDIUM], GL_TRUE,
- sizeof ClientIDs->Defaults[SEVERITY_MEDIUM]);
- memset(ClientIDs->Defaults[SEVERITY_LOW], GL_FALSE,
- sizeof ClientIDs->Defaults[SEVERITY_LOW]);
+ memset(ClientIDs->Defaults[MESA_DEBUG_SEVERITY_HIGH], GL_TRUE,
+ sizeof ClientIDs->Defaults[MESA_DEBUG_SEVERITY_HIGH]);
+ memset(ClientIDs->Defaults[MESA_DEBUG_SEVERITY_MEDIUM], GL_TRUE,
+ sizeof ClientIDs->Defaults[MESA_DEBUG_SEVERITY_MEDIUM]);
+ memset(ClientIDs->Defaults[MESA_DEBUG_SEVERITY_LOW], GL_FALSE,
+ sizeof ClientIDs->Defaults[MESA_DEBUG_SEVERITY_LOW]);
/* Initialize state for filtering client-provided debug messages. */
for (s = 0; s < SOURCE_COUNT; s++)
- for (t = 0; t < TYPE_COUNT; t++) {
+ for (t = 0; t < MESA_DEBUG_TYPE_COUNT; t++) {
ClientIDs->Namespaces[s][t].IDs = _mesa_NewHashTable();
assert(ClientIDs->Namespaces[s][t].IDs);
- for (sev = 0; sev < SEVERITY_COUNT; sev++)
+ for (sev = 0; sev < MESA_DEBUG_SEVERITY_COUNT; sev++)
make_empty_list(&ClientIDs->Namespaces[s][t].Severity[sev]);
}
}
/* Tear down state for filtering client-provided debug messages. */
for (s = 0; s < SOURCE_COUNT; s++)
- for (t = 0; t < TYPE_COUNT; t++) {
+ for (t = 0; t < MESA_DEBUG_TYPE_COUNT; t++) {
_mesa_DeleteHashTable(ClientIDs->Namespaces[s][t].IDs);
- for (sev = 0; sev < SEVERITY_COUNT; sev++) {
+ for (sev = 0; sev < MESA_DEBUG_SEVERITY_COUNT; sev++) {
struct simple_node *node, *tmp;
struct gl_client_severity *entry;
} Current;
};
+/** @{
+ *
+ * These are a mapping of the GL_ARB_debug_output enums to small enums
+ * suitable for use as an array index.
+ */
+
+enum mesa_debug_type {
+ MESA_DEBUG_TYPE_ERROR,
+ MESA_DEBUG_TYPE_DEPRECATED,
+ MESA_DEBUG_TYPE_UNDEFINED,
+ MESA_DEBUG_TYPE_PORTABILITY,
+ MESA_DEBUG_TYPE_PERFORMANCE,
+ MESA_DEBUG_TYPE_OTHER,
+ MESA_DEBUG_TYPE_COUNT,
+};
+
+enum mesa_debug_severity {
+ MESA_DEBUG_SEVERITY_LOW,
+ MESA_DEBUG_SEVERITY_MEDIUM,
+ MESA_DEBUG_SEVERITY_HIGH,
+ MESA_DEBUG_SEVERITY_COUNT,
+};
+
+/** @} */
+
/**
* An error, warning, or other piece of debug information for an application
* to consume via GL_ARB_debug_output.
{
struct _mesa_HashTable *IDs;
unsigned ZeroID; /* a HashTable won't take zero, so store its state here */
- struct simple_node Severity[3]; /* lists of IDs in the hash table */
+ /** lists of IDs in the hash table at each severity */
+ struct simple_node Severity[MESA_DEBUG_SEVERITY_COUNT];
};
struct gl_client_debug
{
- GLboolean Defaults[3][2][6]; /* severity, source, type */
- struct gl_client_namespace Namespaces[2][6]; /* source, type */
+ GLboolean Defaults[MESA_DEBUG_SEVERITY_COUNT][2][MESA_DEBUG_TYPE_COUNT];
+ struct gl_client_namespace Namespaces[2][MESA_DEBUG_TYPE_COUNT];
};
struct gl_debug_state