[Mesa-dev] [PATCH 10/11] mesa: add control for categories of application-provided messages
nobled
nobled at dreamwidth.org
Mon May 2 16:01:14 PDT 2011
This state is needed for deciding whether or not to log
application messages with IDs that haven't been specifically
passed to glDebugMessageControlARB yet.
State for each individual ID number ever passed to
glDebugMessageControlARB (per-context) still needs to be added.
---
src/mesa/main/errors.c | 127 ++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 122 insertions(+), 5 deletions(-)
diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c
index e304184..ed0e7b7 100644
--- a/src/mesa/main/errors.c
+++ b/src/mesa/main/errors.c
@@ -47,10 +47,88 @@ static char out_of_memory[] = "Debugging error:
out of memory";
#define source_is(s, kind) enum_is(s, SOURCE, kind)
#define type_is(t, kind) enum_is(t, TYPE, kind)
+enum {
+SOURCE_APPLICATION,
+SOURCE_THIRD_PARTY,
+
+SOURCE_COUNT,
+SOURCE_ANY = -1
+};
+
+enum {
+TYPE_ERROR,
+TYPE_DEPRECATED,
+TYPE_UNDEFINED,
+TYPE_PORTABILITY,
+TYPE_PERFORMANCE,
+TYPE_OTHER,
+
+TYPE_COUNT,
+TYPE_ANY = -1
+};
+
+enum {
+SEVERITY_LOW,
+SEVERITY_MEDIUM,
+SEVERITY_HIGH,
+
+SEVERITY_COUNT,
+SEVERITY_ANY = -1
+};
+
+static int
+enum_to_index(GLenum e)
+{
+ switch (e) {
+ case GL_DEBUG_SOURCE_APPLICATION_ARB:
+ return (int)SOURCE_APPLICATION;
+ 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;
+
+ default:
+ assert(0 && "unreachable");
+ return -2;
+ };
+}
+
static GLboolean
should_log(struct gl_context *ctx, GLenum source, GLenum type,
GLuint id, GLenum severity)
{
+ 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);
+
+ return ctx->Debug.ClientIDs.defaults[sev][s][t];
+ /* TODO: tracking individual client IDs. */
+ }
+
if (type_is(type, ERROR)) {
if (source_is(source, API))
return ctx->Debug.ApiErrors[id];
@@ -62,7 +140,6 @@ should_log(struct gl_context *ctx, GLenum source,
GLenum type,
return ctx->Debug.OtherErrors[id];
}
- /* TODO: tracking client messages' state. */
return (severity != GL_DEBUG_SEVERITY_LOW_ARB);
}
@@ -332,12 +409,46 @@ control_messages(GLboolean *array, GLuint size,
}
static void
-control_app_messages(struct gl_context *ctx, GLenum source, GLenum type,
- GLenum severity, GLsizei count, const GLuint *ids,
+control_app_messages(struct gl_context *ctx, GLenum esource, GLenum etype,
+ GLenum eseverity, GLsizei count, const GLuint *ids,
GLboolean enabled)
{
- assert(0 && "glDebugMessageControlARB():"
- " Controlling application IDs not implemented");
+ int source, type, severity, s, t, sev, smax, tmax, sevmax;
+
+ assert(!count && "glDebugMessageControlARB():"
+ " controlling for client-provided IDs is not implemented");
+ if (count)
+ return;
+
+ source = enum_to_index(esource);
+ type = enum_to_index(etype);
+ severity = enum_to_index(eseverity);
+
+ if (source == SOURCE_ANY) {
+ source = 0;
+ smax = SOURCE_COUNT;
+ } else {
+ smax = source+1;
+ }
+
+ if (type == TYPE_ANY) {
+ type = 0;
+ tmax = TYPE_COUNT;
+ } else {
+ tmax = type+1;
+ }
+
+ if (severity == SEVERITY_ANY) {
+ severity = 0;
+ sevmax = SEVERITY_COUNT;
+ } else {
+ sevmax = severity+1;
+ }
+
+ for (sev = severity; sev < sevmax; sev++)
+ for (s = source; s < smax; s++)
+ for (t = type; t < tmax; t++)
+ ctx->Debug.ClientIDs.defaults[sev][s][t] = enabled;
}
static void GLAPIENTRY
@@ -419,6 +530,12 @@ _mesa_init_errors(struct gl_context *ctx)
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(ctx->Debug.ClientIDs.defaults[SEVERITY_HIGH], GL_TRUE,
+ sizeof ctx->Debug.ClientIDs.defaults[SEVERITY_HIGH]);
+ memset(ctx->Debug.ClientIDs.defaults[SEVERITY_MEDIUM], GL_TRUE,
+ sizeof ctx->Debug.ClientIDs.defaults[SEVERITY_MEDIUM]);
+ memset(ctx->Debug.ClientIDs.defaults[SEVERITY_LOW], GL_FALSE,
+ sizeof ctx->Debug.ClientIDs.defaults[SEVERITY_LOW]);
}
/**********************************************************************/
--
1.7.0.4
-------------- next part --------------
From 8ed7a90fa364ade1a6c933cb68d4be0fa87c801c Mon Sep 17 00:00:00 2001
From: nobled <nobled at dreamwidth.org>
Date: Mon, 2 May 2011 20:31:00 +0000
Subject: [PATCH 10/10] mesa: add control for categories of application-provided messages
This state is needed for deciding whether or not to log
application messages with IDs that haven't been specifically
passed to glDebugMessageControlARB yet.
State for each individual ID number ever passed to
glDebugMessageControlARB (per-context) still needs to be added.
---
src/mesa/main/errors.c | 127 ++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 122 insertions(+), 5 deletions(-)
diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c
index e304184..ed0e7b7 100644
--- a/src/mesa/main/errors.c
+++ b/src/mesa/main/errors.c
@@ -47,10 +47,88 @@ static char out_of_memory[] = "Debugging error: out of memory";
#define source_is(s, kind) enum_is(s, SOURCE, kind)
#define type_is(t, kind) enum_is(t, TYPE, kind)
+enum {
+SOURCE_APPLICATION,
+SOURCE_THIRD_PARTY,
+
+SOURCE_COUNT,
+SOURCE_ANY = -1
+};
+
+enum {
+TYPE_ERROR,
+TYPE_DEPRECATED,
+TYPE_UNDEFINED,
+TYPE_PORTABILITY,
+TYPE_PERFORMANCE,
+TYPE_OTHER,
+
+TYPE_COUNT,
+TYPE_ANY = -1
+};
+
+enum {
+SEVERITY_LOW,
+SEVERITY_MEDIUM,
+SEVERITY_HIGH,
+
+SEVERITY_COUNT,
+SEVERITY_ANY = -1
+};
+
+static int
+enum_to_index(GLenum e)
+{
+ switch (e) {
+ case GL_DEBUG_SOURCE_APPLICATION_ARB:
+ return (int)SOURCE_APPLICATION;
+ 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;
+
+ default:
+ assert(0 && "unreachable");
+ return -2;
+ };
+}
+
static GLboolean
should_log(struct gl_context *ctx, GLenum source, GLenum type,
GLuint id, GLenum severity)
{
+ 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);
+
+ return ctx->Debug.ClientIDs.defaults[sev][s][t];
+ /* TODO: tracking individual client IDs. */
+ }
+
if (type_is(type, ERROR)) {
if (source_is(source, API))
return ctx->Debug.ApiErrors[id];
@@ -62,7 +140,6 @@ should_log(struct gl_context *ctx, GLenum source, GLenum type,
return ctx->Debug.OtherErrors[id];
}
- /* TODO: tracking client messages' state. */
return (severity != GL_DEBUG_SEVERITY_LOW_ARB);
}
@@ -332,12 +409,46 @@ control_messages(GLboolean *array, GLuint size,
}
static void
-control_app_messages(struct gl_context *ctx, GLenum source, GLenum type,
- GLenum severity, GLsizei count, const GLuint *ids,
+control_app_messages(struct gl_context *ctx, GLenum esource, GLenum etype,
+ GLenum eseverity, GLsizei count, const GLuint *ids,
GLboolean enabled)
{
- assert(0 && "glDebugMessageControlARB():"
- " Controlling application IDs not implemented");
+ int source, type, severity, s, t, sev, smax, tmax, sevmax;
+
+ assert(!count && "glDebugMessageControlARB():"
+ " controlling for client-provided IDs is not implemented");
+ if (count)
+ return;
+
+ source = enum_to_index(esource);
+ type = enum_to_index(etype);
+ severity = enum_to_index(eseverity);
+
+ if (source == SOURCE_ANY) {
+ source = 0;
+ smax = SOURCE_COUNT;
+ } else {
+ smax = source+1;
+ }
+
+ if (type == TYPE_ANY) {
+ type = 0;
+ tmax = TYPE_COUNT;
+ } else {
+ tmax = type+1;
+ }
+
+ if (severity == SEVERITY_ANY) {
+ severity = 0;
+ sevmax = SEVERITY_COUNT;
+ } else {
+ sevmax = severity+1;
+ }
+
+ for (sev = severity; sev < sevmax; sev++)
+ for (s = source; s < smax; s++)
+ for (t = type; t < tmax; t++)
+ ctx->Debug.ClientIDs.defaults[sev][s][t] = enabled;
}
static void GLAPIENTRY
@@ -419,6 +530,12 @@ _mesa_init_errors(struct gl_context *ctx)
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(ctx->Debug.ClientIDs.defaults[SEVERITY_HIGH], GL_TRUE,
+ sizeof ctx->Debug.ClientIDs.defaults[SEVERITY_HIGH]);
+ memset(ctx->Debug.ClientIDs.defaults[SEVERITY_MEDIUM], GL_TRUE,
+ sizeof ctx->Debug.ClientIDs.defaults[SEVERITY_MEDIUM]);
+ memset(ctx->Debug.ClientIDs.defaults[SEVERITY_LOW], GL_FALSE,
+ sizeof ctx->Debug.ClientIDs.defaults[SEVERITY_LOW]);
}
/**********************************************************************/
--
1.7.0.4
More information about the mesa-dev
mailing list