2 * Copyright © 2020 Google, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 #ifndef FREEDRENO_LOG_H_
25 #define FREEDRENO_LOG_H_
27 #include "freedreno_util.h"
32 void fd_log_process(struct fd_context
*ctx
, bool wait
);
33 void fd_log_flush(struct fd_batch
*batch
);
34 void _fd_log(struct fd_batch
*batch
, const char *fmt
, ...)
35 _util_printf_format(2, 3);
37 /* macro wrapper so that arguments are not evaluated when logging is not
40 #define fd_log(__batch, __fmt, ...) \
42 if (unlikely(fd_mesa_debug & FD_DBG_LOG)) { \
43 _fd_log(__batch, __fmt, ##__VA_ARGS__); \
45 DBG(__fmt, ##__VA_ARGS__); \
49 /* A variant of fd_log() which provides a FILE* stream to write the
50 * log msg into, mostly to make u_dump_state stuff useful
52 #define fd_log_stream(__batch, __stream, __exp) \
54 if (unlikely(fd_mesa_debug & FD_DBG_LOG)) { \
56 FILE *__stream = fmemopen(buf, sizeof(buf), "w"); \
59 _fd_log(__batch, "%s", buf); \
63 void fd_log_eof(struct fd_context
*ctx
);
65 #endif /* FREEDRENO_LOG_H_ */