#include "hash.h"
#include "mtypes.h"
#include "version.h"
+#include "hash_table.h"
+#include "glapi/glthread.h"
-
+_glthread_DECLARE_STATIC_MUTEX(DynamicIDMutex);
+static GLuint NextDynamicID = 1;
struct gl_debug_severity
{
return i;
}
+/**
+ * Handles generating a GL_ARB_debug_output message ID generated by the GL or
+ * GLSL compiler.
+ *
+ * The GL API has this "ID" mechanism, where the intention is to allow a
+ * client to filter in/out messages based on source, type, and ID. Of course,
+ * building a giant enum list of all debug output messages that Mesa might
+ * generate is ridiculous, so instead we have our caller pass us a pointer to
+ * static storage where the ID should get stored. This ID will be shared
+ * across all contexts for that message (which seems like a desirable
+ * property, even if it's not expected by the spec), but note that it won't be
+ * the same between executions if messages aren't generated in the same order.
+ */
+static void
+debug_get_id(GLuint *id)
+{
+ if (!(*id)) {
+ _glthread_LOCK_MUTEX(DynamicIDMutex);
+ if (!(*id))
+ *id = NextDynamicID++;
+ _glthread_UNLOCK_MUTEX(DynamicIDMutex);
+ }
+}
+
/*
* We store a bitfield in the hash table, with five possible values total.
*
/* Tear down state for filtering debug messages. */
for (s = 0; s < MESA_DEBUG_SOURCE_COUNT; s++)
for (t = 0; t < MESA_DEBUG_TYPE_COUNT; t++) {
- _mesa_HashDeleteAll(ClientIDs->Namespaces[s][t].IDs, do_nothing, NULL);
- _mesa_DeleteHashTable(ClientIDs->Namespaces[s][t].IDs);
+ _mesa_HashDeleteAll(ctx->Debug.Namespaces[s][t].IDs, do_nothing, NULL);
+ _mesa_DeleteHashTable(ctx->Debug.Namespaces[s][t].IDs);
for (sev = 0; sev < MESA_DEBUG_SEVERITY_COUNT; sev++) {
struct simple_node *node, *tmp;
struct gl_debug_severity *entry;
return GL_FALSE;
}
+void
+_mesa_gl_debug(struct gl_context *ctx,
+ GLuint *id,
+ enum mesa_debug_type type,
+ enum mesa_debug_severity severity,
+ const char *fmtString, ...)
+{
+ char s[MAX_DEBUG_MESSAGE_LENGTH];
+ int len;
+ va_list args;
+
+ debug_get_id(id);
+
+ va_start(args, fmtString);
+ len = _mesa_vsnprintf(s, MAX_DEBUG_MESSAGE_LENGTH, fmtString, args);
+ va_end(args);
+
+ _mesa_log_msg(ctx, MESA_DEBUG_SOURCE_API, type,
+ *id, severity, len, s);
+}
+
/**
* Record an OpenGL state error. These usually occur when the user
extern "C" {
#endif
+#include "mtypes.h"
+
struct _glapi_table;
-struct gl_context;
extern void
_mesa_init_errors( struct gl_context *ctx );
extern void
_mesa_debug( const struct gl_context *ctx, const char *fmtString, ... ) PRINTFLIKE(2, 3);
+extern void
+_mesa_gl_debug(struct gl_context *ctx,
+ GLuint *id,
+ enum mesa_debug_type type,
+ enum mesa_debug_severity severity,
+ const char *fmtString, ...) PRINTFLIKE(5, 6);
+
extern void
_mesa_shader_debug( struct gl_context *ctx, GLenum type, GLuint id, const char *msg, int len );