mesa: Replace MESA_VERSION with PACKAGE_VERSION.
[mesa.git] / src / mesa / main / errors.c
index 3c720bc55007b8001934322d280c78e2ce5f4684..1c1d85d414d41257338fd0b3e42e5fb8f7c52b7f 100644 (file)
@@ -310,12 +310,15 @@ _mesa_log_msg(struct gl_context *ctx, enum mesa_debug_source source,
       emptySlot->id = id;
       emptySlot->severity = severity;
    } else {
+      static GLuint oom_msg_id = 0;
+      debug_get_id(&oom_msg_id);
+
       /* malloc failed! */
       emptySlot->message = out_of_memory;
       emptySlot->length = strlen(out_of_memory)+1;
       emptySlot->source = MESA_DEBUG_SOURCE_OTHER;
       emptySlot->type = MESA_DEBUG_TYPE_ERROR;
-      emptySlot->id = OTHER_ERROR_OUT_OF_MEMORY;
+      emptySlot->id = oom_msg_id;
       emptySlot->severity = MESA_DEBUG_SEVERITY_HIGH;
    }
 
@@ -648,8 +651,8 @@ _mesa_DebugMessageControlARB(GLenum gl_source, GLenum gl_type,
       return;
    }
 
-   source = gl_enum_to_debug_severity(gl_source);
-   type = gl_enum_to_debug_severity(gl_type);
+   source = gl_enum_to_debug_source(gl_source);
+   type = gl_enum_to_debug_type(gl_type);
    severity = gl_enum_to_debug_severity(gl_severity);
 
    control_app_messages(ctx, source, type, severity, count, ids, enabled);
@@ -845,7 +848,7 @@ _mesa_problem( const struct gl_context *ctx, const char *fmtString, ... )
       _mesa_vsnprintf( str, MAX_DEBUG_MESSAGE_LENGTH, fmtString, args );
       va_end( args );
       fprintf(stderr, "Mesa %s implementation error: %s\n",
-              MESA_VERSION_STRING, str);
+              PACKAGE_VERSION, str);
       fprintf(stderr, "Please report at bugs.freedesktop.org\n");
    }
 }
@@ -924,12 +927,18 @@ void
 _mesa_error( struct gl_context *ctx, GLenum error, const char *fmtString, ... )
 {
    GLboolean do_output, do_log;
+   /* Ideally this would be set up by the caller, so that we had proper IDs
+    * per different message.
+    */
+   static GLuint error_msg_id = 0;
+
+   debug_get_id(&error_msg_id);
 
    do_output = should_output(ctx, error, fmtString);
    do_log = should_log(ctx,
                        MESA_DEBUG_SOURCE_API,
                        MESA_DEBUG_TYPE_ERROR,
-                       API_ERROR_UNKNOWN,
+                       error_msg_id,
                        MESA_DEBUG_SEVERITY_HIGH);
 
    if (do_output || do_log) {
@@ -966,7 +975,7 @@ _mesa_error( struct gl_context *ctx, GLenum error, const char *fmtString, ... )
          _mesa_log_msg(ctx,
                        MESA_DEBUG_SOURCE_API,
                        MESA_DEBUG_TYPE_ERROR,
-                       API_ERROR_UNKNOWN,
+                       error_msg_id,
                        MESA_DEBUG_SEVERITY_HIGH, len, s2);
       }
    }
@@ -1009,12 +1018,14 @@ _mesa_debug( const struct gl_context *ctx, const char *fmtString, ... )
  * \param len The length of 'msg'. If negative, 'msg' must be null-terminated.
  */
 void
-_mesa_shader_debug( struct gl_context *ctx, GLenum type, GLuint id,
+_mesa_shader_debug( struct gl_context *ctx, GLenum type, GLuint *id,
                     const char *msg, int len )
 {
    enum mesa_debug_source source = MESA_DEBUG_SOURCE_SHADER_COMPILER;
    enum mesa_debug_severity severity = MESA_DEBUG_SEVERITY_HIGH;
 
+   debug_get_id(id);
+
    if (len < 0)
       len = strlen(msg);
 
@@ -1022,7 +1033,7 @@ _mesa_shader_debug( struct gl_context *ctx, GLenum type, GLuint id,
    if (len >= MAX_DEBUG_MESSAGE_LENGTH)
       len = MAX_DEBUG_MESSAGE_LENGTH - 1;
 
-   _mesa_log_msg(ctx, source, type, id, severity, len, msg);
+   _mesa_log_msg(ctx, source, type, *id, severity, len, msg);
 }
 
 /*@}*/