enum mesa_debug_type type;
GLuint id;
enum mesa_debug_severity severity;
+ /* length as given by the user - if message was explicitly null terminated,
+ * length can be negative */
GLsizei length;
GLcharARB *message;
};
struct gl_debug_group *Groups[MAX_DEBUG_GROUP_STACK_DEPTH];
struct gl_debug_message GroupMessages[MAX_DEBUG_GROUP_STACK_DEPTH];
- GLint GroupStackDepth;
+ GLint CurrentGroup; // GroupStackDepth - 1
struct gl_debug_log Log;
};
enum mesa_debug_severity severity,
GLsizei len, const char *buf)
{
+ GLsizei length = len;
+
assert(!msg->message && !msg->length);
- msg->message = malloc(len+1);
+ if (length < 0)
+ length = strlen(buf);
+
+ msg->message = malloc(length+1);
if (msg->message) {
- (void) strncpy(msg->message, buf, (size_t)len);
- msg->message[len] = '\0';
+ (void) strncpy(msg->message, buf, (size_t)length);
+ msg->message[length] = '\0';
- msg->length = len+1;
+ msg->length = len;
msg->source = source;
msg->type = type;
msg->id = id;
/* malloc failed! */
msg->message = out_of_memory;
- msg->length = strlen(out_of_memory)+1;
+ msg->length = -1;
msg->source = MESA_DEBUG_SOURCE_OTHER;
msg->type = MESA_DEBUG_TYPE_ERROR;
msg->id = oom_msg_id;
make_empty_list(&ns->Elements);
/* Enable all the messages with severity HIGH or MEDIUM by default */
- ns->DefaultState = (1 << MESA_DEBUG_SEVERITY_HIGH) |
- (1 << MESA_DEBUG_SEVERITY_MEDIUM);
+ ns->DefaultState = (1 << MESA_DEBUG_SEVERITY_MEDIUM ) |
+ (1 << MESA_DEBUG_SEVERITY_HIGH) |
+ (1 << MESA_DEBUG_SEVERITY_NOTIFICATION);
}
static void
static bool
debug_is_group_read_only(const struct gl_debug_state *debug)
{
- const GLint gstack = debug->GroupStackDepth;
+ const GLint gstack = debug->CurrentGroup;
return (gstack > 0 && debug->Groups[gstack] == debug->Groups[gstack - 1]);
}
static bool
debug_make_group_writable(struct gl_debug_state *debug)
{
- const GLint gstack = debug->GroupStackDepth;
+ const GLint gstack = debug->CurrentGroup;
const struct gl_debug_group *src = debug->Groups[gstack];
struct gl_debug_group *dst;
int s, t;
static void
debug_clear_group(struct gl_debug_state *debug)
{
- const GLint gstack = debug->GroupStackDepth;
+ const GLint gstack = debug->CurrentGroup;
if (!debug_is_group_read_only(debug)) {
struct gl_debug_group *grp = debug->Groups[gstack];
static void
debug_destroy(struct gl_debug_state *debug)
{
- while (debug->GroupStackDepth > 0) {
+ while (debug->CurrentGroup > 0) {
debug_clear_group(debug);
- debug->GroupStackDepth--;
+ debug->CurrentGroup--;
}
debug_clear_group(debug);
enum mesa_debug_type type,
GLuint id, GLboolean enabled)
{
- const GLint gstack = debug->GroupStackDepth;
+ const GLint gstack = debug->CurrentGroup;
struct gl_debug_namespace *ns;
debug_make_group_writable(debug);
enum mesa_debug_severity severity,
GLboolean enabled)
{
- const GLint gstack = debug->GroupStackDepth;
+ const GLint gstack = debug->CurrentGroup;
int s, t, smax, tmax;
if (source == MESA_DEBUG_SOURCE_COUNT) {
GLuint id,
enum mesa_debug_severity severity)
{
- const GLint gstack = debug->GroupStackDepth;
+ const GLint gstack = debug->CurrentGroup;
struct gl_debug_group *grp = debug->Groups[gstack];
struct gl_debug_namespace *nspace = &grp->Namespaces[source][type];
GLint nextEmpty;
struct gl_debug_message *emptySlot;
- assert(len >= 0 && len < MAX_DEBUG_MESSAGE_LENGTH);
+ assert(len < MAX_DEBUG_MESSAGE_LENGTH);
if (log->NumMessages == MAX_DEBUG_LOGGED_MESSAGES)
return;
static struct gl_debug_message *
debug_get_group_message(struct gl_debug_state *debug)
{
- return &debug->GroupMessages[debug->GroupStackDepth];
+ return &debug->GroupMessages[debug->CurrentGroup];
}
static void
debug_push_group(struct gl_debug_state *debug)
{
- const GLint gstack = debug->GroupStackDepth;
+ const GLint gstack = debug->CurrentGroup;
/* just point to the previous stack */
debug->Groups[gstack + 1] = debug->Groups[gstack];
- debug->GroupStackDepth++;
+ debug->CurrentGroup++;
}
static void
debug_pop_group(struct gl_debug_state *debug)
{
debug_clear_group(debug);
- debug->GroupStackDepth--;
+ debug->CurrentGroup--;
}
debug->Log.Messages[debug->Log.NextMessage].length : 0;
break;
case GL_DEBUG_GROUP_STACK_DEPTH:
- val = debug->GroupStackDepth;
+ val = debug->CurrentGroup + 1;
break;
default:
assert(!"unknown debug output param");
case GL_DEBUG_TYPE_PORTABILITY_ARB:
case GL_DEBUG_TYPE_OTHER_ARB:
case GL_DEBUG_TYPE_MARKER:
- break;
case GL_DEBUG_TYPE_PUSH_GROUP:
case GL_DEBUG_TYPE_POP_GROUP:
+ break;
case GL_DONT_CARE:
if (caller == CONTROL)
break;
static GLboolean
-validate_length(struct gl_context *ctx, const char *callerstr, GLsizei length)
+validate_length(struct gl_context *ctx, const char *callerstr, GLsizei length,
+ const GLchar *buf)
{
+
+ if (length < 0) {
+ GLsizei len = strlen(buf);
+
+ if (len >= MAX_DEBUG_MESSAGE_LENGTH) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "%s(null terminated string length=%d, is not less than "
+ "GL_MAX_DEBUG_MESSAGE_LENGTH=%d)", callerstr, len,
+ MAX_DEBUG_MESSAGE_LENGTH);
+ return GL_FALSE;
+ }
+ }
+
if (length >= MAX_DEBUG_MESSAGE_LENGTH) {
_mesa_error(ctx, GL_INVALID_VALUE,
"%s(length=%d, which is not less than "
GLenum severity, GLint length,
const GLchar *buf)
{
- const char *callerstr = "glDebugMessageInsert";
-
GET_CURRENT_CONTEXT(ctx);
+ const char *callerstr;
+
+ if (_mesa_is_desktop_gl(ctx))
+ callerstr = "glDebugMessageInsert";
+ else
+ callerstr = "glDebugMessageInsertKHR";
if (!validate_params(ctx, INSERT, callerstr, source, type, severity))
return; /* GL_INVALID_ENUM */
- if (length < 0)
- length = strlen(buf);
- if (!validate_length(ctx, callerstr, length))
+ if (!validate_length(ctx, callerstr, length, buf))
return; /* GL_INVALID_VALUE */
log_msg(ctx, gl_enum_to_debug_source(source),
{
GET_CURRENT_CONTEXT(ctx);
struct gl_debug_state *debug;
+ const char *callerstr;
GLuint ret;
+ if (_mesa_is_desktop_gl(ctx))
+ callerstr = "glGetDebugMessageLog";
+ else
+ callerstr = "glGetDebugMessageLogKHR";
+
if (!messageLog)
logSize = 0;
if (logSize < 0) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glGetDebugMessageLog(logSize=%d : logSize must not be"
- " negative)", logSize);
+ "%s(logSize=%d : logSize must not be negative)",
+ callerstr, logSize);
return 0;
}
for (ret = 0; ret < count; ret++) {
const struct gl_debug_message *msg = debug_fetch_message(debug);
+ GLsizei len;
if (!msg)
break;
- if (logSize < msg->length && messageLog != NULL)
+ len = msg->length;
+ if (len < 0)
+ len = strlen(msg->message);
+
+ if (logSize < len+1 && messageLog != NULL)
break;
if (messageLog) {
- assert(msg->message[msg->length-1] == '\0');
- (void) strncpy(messageLog, msg->message, (size_t)msg->length);
+ assert(msg->message[len] == '\0');
+ (void) strncpy(messageLog, msg->message, (size_t)len+1);
- messageLog += msg->length;
- logSize -= msg->length;
+ messageLog += len+1;
+ logSize -= len+1;
}
if (lengths)
- *lengths++ = msg->length;
+ *lengths++ = len+1;
if (severities)
*severities++ = debug_severity_enums[msg->severity];
if (sources)
enum mesa_debug_source source = gl_enum_to_debug_source(gl_source);
enum mesa_debug_type type = gl_enum_to_debug_type(gl_type);
enum mesa_debug_severity severity = gl_enum_to_debug_severity(gl_severity);
- const char *callerstr = "glDebugMessageControl";
+ const char *callerstr;
struct gl_debug_state *debug;
+ if (_mesa_is_desktop_gl(ctx))
+ callerstr = "glDebugMessageControl";
+ else
+ callerstr = "glDebugMessageControlKHR";
+
if (count < 0) {
_mesa_error(ctx, GL_INVALID_VALUE,
"%s(count=%d : count must not be negative)", callerstr,
const GLchar *message)
{
GET_CURRENT_CONTEXT(ctx);
- const char *callerstr = "glPushDebugGroup";
+ const char *callerstr;
struct gl_debug_state *debug;
struct gl_debug_message *emptySlot;
+ if (_mesa_is_desktop_gl(ctx))
+ callerstr = "glPushDebugGroup";
+ else
+ callerstr = "glPushDebugGroupKHR";
+
switch(source) {
case GL_DEBUG_SOURCE_APPLICATION:
case GL_DEBUG_SOURCE_THIRD_PARTY:
return;
}
- if (length < 0)
- length = strlen(message);
- if (!validate_length(ctx, callerstr, length))
+ if (!validate_length(ctx, callerstr, length, message))
return; /* GL_INVALID_VALUE */
debug = _mesa_lock_debug_state(ctx);
if (!debug)
return;
- if (debug->GroupStackDepth >= MAX_DEBUG_GROUP_STACK_DEPTH-1) {
+ if (debug->CurrentGroup >= MAX_DEBUG_GROUP_STACK_DEPTH-1) {
_mesa_unlock_debug_state(ctx);
_mesa_error(ctx, GL_STACK_OVERFLOW, "%s", callerstr);
return;
_mesa_PopDebugGroup(void)
{
GET_CURRENT_CONTEXT(ctx);
- const char *callerstr = "glPopDebugGroup";
+ const char *callerstr;
struct gl_debug_state *debug;
struct gl_debug_message *gdmessage, msg;
+ if (_mesa_is_desktop_gl(ctx))
+ callerstr = "glPopDebugGroup";
+ else
+ callerstr = "glPopDebugGroupKHR";
+
debug = _mesa_lock_debug_state(ctx);
if (!debug)
return;
- if (debug->GroupStackDepth <= 0) {
+ if (debug->CurrentGroup <= 0) {
_mesa_unlock_debug_state(ctx);
_mesa_error(ctx, GL_STACK_UNDERFLOW, "%s", callerstr);
return;
mtx_destroy(&ctx->DebugMutex);
}
+void GLAPIENTRY
+_mesa_StringMarkerGREMEDY(GLsizei len, const GLvoid *string)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ if (ctx->Extensions.GREMEDY_string_marker) {
+ /* if length not specified, string will be null terminated: */
+ if (len <= 0)
+ len = strlen(string);
+ ctx->Driver.EmitStringMarker(ctx, string, len);
+ } else {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "StringMarkerGREMEDY");
+ }
+}
/**********************************************************************/
/** \name Diagnostics */
if (ctx->ErrorDebugCount) {
_mesa_snprintf(s, MAX_DEBUG_MESSAGE_LENGTH, "%d similar %s errors",
ctx->ErrorDebugCount,
- _mesa_lookup_enum_by_nr(ctx->ErrorValue));
+ _mesa_enum_to_string(ctx->ErrorValue));
output_if_debug("Mesa", s, GL_TRUE);
}
+void
+_mesa_gl_vdebug(struct gl_context *ctx,
+ GLuint *id,
+ enum mesa_debug_source source,
+ enum mesa_debug_type type,
+ enum mesa_debug_severity severity,
+ const char *fmtString,
+ va_list args)
+{
+ char s[MAX_DEBUG_MESSAGE_LENGTH];
+ int len;
+
+ debug_get_id(id);
+
+ len = _mesa_vsnprintf(s, MAX_DEBUG_MESSAGE_LENGTH, fmtString, args);
+
+ log_msg(ctx, source, type, *id, severity, len, s);
+}
+
+
void
_mesa_gl_debug(struct gl_context *ctx,
GLuint *id,
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);
+ _mesa_gl_vdebug(ctx, id, source, type, severity, fmtString, args);
va_end(args);
-
- log_msg(ctx, source, type, *id, severity, len, s);
}
}
len = _mesa_snprintf(s2, MAX_DEBUG_MESSAGE_LENGTH, "%s in %s",
- _mesa_lookup_enum_by_nr(error), s);
+ _mesa_enum_to_string(error), s);
if (len >= MAX_DEBUG_MESSAGE_LENGTH) {
/* Same as above. */
assert(0);
* \param ctx GL context.
* \param type The namespace to which this message belongs.
* \param id The message ID within the given namespace.
- * \param msg The message to output. Need not be null-terminated.
- * \param len The length of 'msg'. If negative, 'msg' must be null-terminated.
+ * \param msg The message to output. Must be null-terminated.
*/
void
-_mesa_shader_debug( struct gl_context *ctx, GLenum type, GLuint *id,
- const char *msg, int len )
+_mesa_shader_debug(struct gl_context *ctx, GLenum type, GLuint *id,
+ const char *msg)
{
enum mesa_debug_source source = MESA_DEBUG_SOURCE_SHADER_COMPILER;
enum mesa_debug_severity severity = MESA_DEBUG_SEVERITY_HIGH;
+ int len;
debug_get_id(id);
- if (len < 0)
- len = strlen(msg);
+ len = strlen(msg);
/* Truncate the message if necessary. */
if (len >= MAX_DEBUG_MESSAGE_LENGTH)