1af69d88dSmrg/*
2af69d88dSmrg * Mesa 3-D graphics library
3af69d88dSmrg *
4af69d88dSmrg * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
5af69d88dSmrg *
6af69d88dSmrg * Permission is hereby granted, free of charge, to any person obtaining a
7af69d88dSmrg * copy of this software and associated documentation files (the "Software"),
8af69d88dSmrg * to deal in the Software without restriction, including without limitation
9af69d88dSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10af69d88dSmrg * and/or sell copies of the Software, and to permit persons to whom the
11af69d88dSmrg * Software is furnished to do so, subject to the following conditions:
12af69d88dSmrg *
13af69d88dSmrg * The above copyright notice and this permission notice shall be included
14af69d88dSmrg * in all copies or substantial portions of the Software.
15af69d88dSmrg *
16af69d88dSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17af69d88dSmrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18af69d88dSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19af69d88dSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20af69d88dSmrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21af69d88dSmrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22af69d88dSmrg * OTHER DEALINGS IN THE SOFTWARE.
23af69d88dSmrg */
24af69d88dSmrg
25af69d88dSmrg
26af69d88dSmrg/**
27af69d88dSmrg * \file errors.h
28af69d88dSmrg * Mesa debugging and error handling functions.
29af69d88dSmrg *
30af69d88dSmrg * This file provides functions to record errors, warnings, and miscellaneous
31af69d88dSmrg * debug information.
32af69d88dSmrg */
33af69d88dSmrg
34af69d88dSmrg
35af69d88dSmrg#ifndef ERRORS_H
36af69d88dSmrg#define ERRORS_H
37af69d88dSmrg
38af69d88dSmrg
3901e04c3fSmrg#include <stdio.h>
4001e04c3fSmrg#include <stdarg.h>
41af69d88dSmrg#include "glheader.h"
4201e04c3fSmrg#include "menums.h"
43af69d88dSmrg
44af69d88dSmrg
45af69d88dSmrg#ifdef __cplusplus
46af69d88dSmrgextern "C" {
47af69d88dSmrg#endif
48af69d88dSmrg
4901e04c3fSmrgstruct gl_context;
50af69d88dSmrg
51af69d88dSmrgextern void
52af69d88dSmrg_mesa_warning( struct gl_context *gc, const char *fmtString, ... ) PRINTFLIKE(2, 3);
53af69d88dSmrg
54af69d88dSmrgextern void
55af69d88dSmrg_mesa_problem( const struct gl_context *ctx, const char *fmtString, ... ) PRINTFLIKE(2, 3);
56af69d88dSmrg
57af69d88dSmrgextern void
58af69d88dSmrg_mesa_error( struct gl_context *ctx, GLenum error, const char *fmtString, ... ) PRINTFLIKE(3, 4);
59af69d88dSmrg
60af69d88dSmrgextern void
61af69d88dSmrg_mesa_error_no_memory(const char *caller);
62af69d88dSmrg
63af69d88dSmrgextern void
64af69d88dSmrg_mesa_debug( const struct gl_context *ctx, const char *fmtString, ... ) PRINTFLIKE(2, 3);
65af69d88dSmrg
6601e04c3fSmrgextern void
6701e04c3fSmrg_mesa_log(const char *fmtString, ...) PRINTFLIKE(1, 2);
6801e04c3fSmrg
6901e04c3fSmrgextern FILE *
7001e04c3fSmrg_mesa_get_log_file(void);
7101e04c3fSmrg
7201e04c3fSmrgvoid
7301e04c3fSmrg_mesa_shader_debug(struct gl_context *ctx, GLenum type, GLuint *id,
7401e04c3fSmrg                   const char *msg);
7501e04c3fSmrg
7601e04c3fSmrgextern void
77a8bb7a65Smaya_mesa_gl_vdebugf(struct gl_context *ctx,
78a8bb7a65Smaya                 GLuint *id,
79a8bb7a65Smaya                 enum mesa_debug_source source,
80a8bb7a65Smaya                 enum mesa_debug_type type,
81a8bb7a65Smaya                 enum mesa_debug_severity severity,
82a8bb7a65Smaya                 const char *fmtString,
83a8bb7a65Smaya                 va_list args);
84a8bb7a65Smaya
85a8bb7a65Smayaextern void
86a8bb7a65Smaya_mesa_gl_debugf(struct gl_context *ctx,
8701e04c3fSmrg                GLuint *id,
8801e04c3fSmrg                enum mesa_debug_source source,
8901e04c3fSmrg                enum mesa_debug_type type,
9001e04c3fSmrg                enum mesa_debug_severity severity,
91a8bb7a65Smaya                const char *fmtString, ...) PRINTFLIKE(6, 7);
9201e04c3fSmrg
93a8bb7a65Smayaextern size_t
94af69d88dSmrg_mesa_gl_debug(struct gl_context *ctx,
95af69d88dSmrg               GLuint *id,
9601e04c3fSmrg               enum mesa_debug_source source,
97af69d88dSmrg               enum mesa_debug_type type,
98af69d88dSmrg               enum mesa_debug_severity severity,
99a8bb7a65Smaya               const char *msg);
100af69d88dSmrg
101af69d88dSmrg#define _mesa_perf_debug(ctx, sev, ...) do {                              \
102af69d88dSmrg   static GLuint msg_id = 0;                                              \
103af69d88dSmrg   if (unlikely(ctx->Const.ContextFlags & GL_CONTEXT_FLAG_DEBUG_BIT)) {   \
104a8bb7a65Smaya      _mesa_gl_debugf(ctx, &msg_id,                                       \
105a8bb7a65Smaya                      MESA_DEBUG_SOURCE_API,                              \
106a8bb7a65Smaya                      MESA_DEBUG_TYPE_PERFORMANCE,                        \
107a8bb7a65Smaya                      sev,                                                \
108a8bb7a65Smaya                      __VA_ARGS__);                                       \
109af69d88dSmrg   }                                                                      \
110af69d88dSmrg} while (0)
111af69d88dSmrg
1127ec681f3Smrgvoid GLAPIENTRY
1137ec681f3Smrg_mesa_InternalSetError(GLenum error);
114af69d88dSmrg
115af69d88dSmrg#ifdef __cplusplus
116af69d88dSmrg}
117af69d88dSmrg#endif
118af69d88dSmrg
119af69d88dSmrg
120af69d88dSmrg#endif /* ERRORS_H */
121