1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * Mesa 3-D graphics library
3bf215546Sopenharmony_ci *
4bf215546Sopenharmony_ci * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
5bf215546Sopenharmony_ci *
6bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
7bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
8bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation
9bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
11bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
12bf215546Sopenharmony_ci *
13bf215546Sopenharmony_ci * The above copyright notice and this permission notice shall be included
14bf215546Sopenharmony_ci * in all copies or substantial portions of the Software.
15bf215546Sopenharmony_ci *
16bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17bf215546Sopenharmony_ci * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20bf215546Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21bf215546Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22bf215546Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE.
23bf215546Sopenharmony_ci */
24bf215546Sopenharmony_ci
25bf215546Sopenharmony_ci
26bf215546Sopenharmony_ci/**
27bf215546Sopenharmony_ci * \file errors.h
28bf215546Sopenharmony_ci * Mesa debugging and error handling functions.
29bf215546Sopenharmony_ci *
30bf215546Sopenharmony_ci * This file provides functions to record errors, warnings, and miscellaneous
31bf215546Sopenharmony_ci * debug information.
32bf215546Sopenharmony_ci */
33bf215546Sopenharmony_ci
34bf215546Sopenharmony_ci
35bf215546Sopenharmony_ci#ifndef ERRORS_H
36bf215546Sopenharmony_ci#define ERRORS_H
37bf215546Sopenharmony_ci
38bf215546Sopenharmony_ci
39bf215546Sopenharmony_ci#include <stdio.h>
40bf215546Sopenharmony_ci#include <stdarg.h>
41bf215546Sopenharmony_ci#include "glheader.h"
42bf215546Sopenharmony_ci#include "menums.h"
43bf215546Sopenharmony_ci
44bf215546Sopenharmony_ci
45bf215546Sopenharmony_ci#ifdef __cplusplus
46bf215546Sopenharmony_ciextern "C" {
47bf215546Sopenharmony_ci#endif
48bf215546Sopenharmony_ci
49bf215546Sopenharmony_cistruct gl_context;
50bf215546Sopenharmony_ci
51bf215546Sopenharmony_ciextern void
52bf215546Sopenharmony_ci_mesa_warning( struct gl_context *gc, const char *fmtString, ... ) PRINTFLIKE(2, 3);
53bf215546Sopenharmony_ci
54bf215546Sopenharmony_ciextern void
55bf215546Sopenharmony_ci_mesa_problem( const struct gl_context *ctx, const char *fmtString, ... ) PRINTFLIKE(2, 3);
56bf215546Sopenharmony_ci
57bf215546Sopenharmony_ciextern void
58bf215546Sopenharmony_ci_mesa_error( struct gl_context *ctx, GLenum error, const char *fmtString, ... ) PRINTFLIKE(3, 4);
59bf215546Sopenharmony_ci
60bf215546Sopenharmony_ciextern void
61bf215546Sopenharmony_ci_mesa_error_no_memory(const char *caller);
62bf215546Sopenharmony_ci
63bf215546Sopenharmony_ciextern void
64bf215546Sopenharmony_ci_mesa_debug( const struct gl_context *ctx, const char *fmtString, ... ) PRINTFLIKE(2, 3);
65bf215546Sopenharmony_ci
66bf215546Sopenharmony_ciextern void
67bf215546Sopenharmony_ci_mesa_log(const char *fmtString, ...) PRINTFLIKE(1, 2);
68bf215546Sopenharmony_ci
69bf215546Sopenharmony_ciextern void
70bf215546Sopenharmony_ci_mesa_log_direct(const char *string);
71bf215546Sopenharmony_ci
72bf215546Sopenharmony_ci
73bf215546Sopenharmony_ciextern FILE *
74bf215546Sopenharmony_ci_mesa_get_log_file(void);
75bf215546Sopenharmony_ci
76bf215546Sopenharmony_civoid
77bf215546Sopenharmony_ci_mesa_shader_debug(struct gl_context *ctx, GLenum type, GLuint *id,
78bf215546Sopenharmony_ci                   const char *msg);
79bf215546Sopenharmony_ci
80bf215546Sopenharmony_ciextern void
81bf215546Sopenharmony_ci_mesa_gl_vdebugf(struct gl_context *ctx,
82bf215546Sopenharmony_ci                 GLuint *id,
83bf215546Sopenharmony_ci                 enum mesa_debug_source source,
84bf215546Sopenharmony_ci                 enum mesa_debug_type type,
85bf215546Sopenharmony_ci                 enum mesa_debug_severity severity,
86bf215546Sopenharmony_ci                 const char *fmtString,
87bf215546Sopenharmony_ci                 va_list args);
88bf215546Sopenharmony_ci
89bf215546Sopenharmony_ciextern void
90bf215546Sopenharmony_ci_mesa_gl_debugf(struct gl_context *ctx,
91bf215546Sopenharmony_ci                GLuint *id,
92bf215546Sopenharmony_ci                enum mesa_debug_source source,
93bf215546Sopenharmony_ci                enum mesa_debug_type type,
94bf215546Sopenharmony_ci                enum mesa_debug_severity severity,
95bf215546Sopenharmony_ci                const char *fmtString, ...) PRINTFLIKE(6, 7);
96bf215546Sopenharmony_ci
97bf215546Sopenharmony_ciextern size_t
98bf215546Sopenharmony_ci_mesa_gl_debug(struct gl_context *ctx,
99bf215546Sopenharmony_ci               GLuint *id,
100bf215546Sopenharmony_ci               enum mesa_debug_source source,
101bf215546Sopenharmony_ci               enum mesa_debug_type type,
102bf215546Sopenharmony_ci               enum mesa_debug_severity severity,
103bf215546Sopenharmony_ci               const char *msg);
104bf215546Sopenharmony_ci
105bf215546Sopenharmony_ci#define _mesa_perf_debug(ctx, sev, ...) do {                              \
106bf215546Sopenharmony_ci   static GLuint msg_id = 0;                                              \
107bf215546Sopenharmony_ci   if (unlikely(ctx->Const.ContextFlags & GL_CONTEXT_FLAG_DEBUG_BIT)) {   \
108bf215546Sopenharmony_ci      _mesa_gl_debugf(ctx, &msg_id,                                       \
109bf215546Sopenharmony_ci                      MESA_DEBUG_SOURCE_API,                              \
110bf215546Sopenharmony_ci                      MESA_DEBUG_TYPE_PERFORMANCE,                        \
111bf215546Sopenharmony_ci                      sev,                                                \
112bf215546Sopenharmony_ci                      __VA_ARGS__);                                       \
113bf215546Sopenharmony_ci   }                                                                      \
114bf215546Sopenharmony_ci} while (0)
115bf215546Sopenharmony_ci
116bf215546Sopenharmony_ci#ifdef __cplusplus
117bf215546Sopenharmony_ci}
118bf215546Sopenharmony_ci#endif
119bf215546Sopenharmony_ci
120bf215546Sopenharmony_ci
121bf215546Sopenharmony_ci#endif /* ERRORS_H */
122