trace: adapt to clear interface changes
[mesa.git] / src / gallium / drivers / trace / tr_dump.h
1 /**************************************************************************
2 *
3 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 /**
29 * @file
30 * Trace data dumping primitives.
31 */
32
33 #ifndef TR_DUMP_H
34 #define TR_DUMP_H
35
36
37 #include "pipe/p_compiler.h"
38 #include "pipe/p_format.h"
39
40 struct pipe_resource;
41 struct pipe_surface;
42 struct pipe_transfer;
43 struct pipe_box;
44
45 /*
46 * Call before use.
47 */
48 void trace_dump_init(void);
49
50 /*
51 * Low level dumping controls.
52 *
53 * Opening the trace file and checking if that is opened.
54 */
55 boolean trace_dump_trace_begin(void);
56 boolean trace_dump_trace_enabled(void);
57 void trace_dump_trace_end(void);
58
59 /*
60 * Lock and unlock the call mutex.
61 *
62 * It used by the none locked version of dumping control
63 * and begin/end call dump functions.
64 *
65 * Begin takes the lock while end unlocks it. Use the _locked
66 * version to avoid locking/unlocking it.
67 */
68 void trace_dump_call_lock(void);
69 void trace_dump_call_unlock(void);
70
71 /*
72 * High level dumping control.
73 */
74 void trace_dumping_start_locked(void);
75 void trace_dumping_stop_locked(void);
76 boolean trace_dumping_enabled_locked(void);
77 void trace_dumping_start(void);
78 void trace_dumping_stop(void);
79 boolean trace_dumping_enabled(void);
80
81 void trace_dump_call_begin_locked(const char *klass, const char *method);
82 void trace_dump_call_end_locked(void);
83 void trace_dump_call_begin(const char *klass, const char *method);
84 void trace_dump_call_end(void);
85
86 void trace_dump_arg_begin(const char *name);
87 void trace_dump_arg_end(void);
88 void trace_dump_ret_begin(void);
89 void trace_dump_ret_end(void);
90 void trace_dump_bool(int value);
91 void trace_dump_int(long long int value);
92 void trace_dump_uint(long long unsigned value);
93 void trace_dump_float(double value);
94 void trace_dump_bytes(const void *data, size_t size);
95 void trace_dump_box_bytes(const void *data,
96 enum pipe_format format,
97 const struct pipe_box *box,
98 unsigned stride,
99 unsigned slice_stride);
100 void trace_dump_string(const char *str);
101 void trace_dump_enum(const char *value);
102 void trace_dump_array_begin(void);
103 void trace_dump_array_end(void);
104 void trace_dump_elem_begin(void);
105 void trace_dump_elem_end(void);
106 void trace_dump_struct_begin(const char *name);
107 void trace_dump_struct_end(void);
108 void trace_dump_member_begin(const char *name);
109 void trace_dump_member_end(void);
110 void trace_dump_null(void);
111 void trace_dump_ptr(const void *value);
112 /* will turn a wrapped object into the real one and dump ptr */
113 void trace_dump_resource_ptr(struct pipe_resource *_texture);
114 void trace_dump_surface_ptr(struct pipe_surface *_surface);
115 void trace_dump_transfer_ptr(struct pipe_transfer *_transfer);
116
117 /*
118 * Code saving macros.
119 */
120
121 #define trace_dump_arg(_type, _arg) \
122 do { \
123 trace_dump_arg_begin(#_arg); \
124 trace_dump_##_type(_arg); \
125 trace_dump_arg_end(); \
126 } while(0)
127
128 #define trace_dump_arg_struct(_type, _arg) \
129 do { \
130 trace_dump_arg_begin(#_arg); \
131 trace_dump_##_type(&_arg); \
132 trace_dump_arg_end(); \
133 } while(0)
134
135 #define trace_dump_ret(_type, _arg) \
136 do { \
137 trace_dump_ret_begin(); \
138 trace_dump_##_type(_arg); \
139 trace_dump_ret_end(); \
140 } while(0)
141
142 #define trace_dump_array(_type, _obj, _size) \
143 do { \
144 size_t idx; \
145 trace_dump_array_begin(); \
146 for(idx = 0; idx < (_size); ++idx) { \
147 trace_dump_elem_begin(); \
148 trace_dump_##_type((_obj)[idx]); \
149 trace_dump_elem_end(); \
150 } \
151 trace_dump_array_end(); \
152 } while(0)
153
154 #define trace_dump_struct_array(_type, _obj, _size) \
155 do { \
156 size_t idx; \
157 trace_dump_array_begin(); \
158 for(idx = 0; idx < (_size); ++idx) { \
159 trace_dump_elem_begin(); \
160 trace_dump_##_type(&(_obj)[idx]); \
161 trace_dump_elem_end(); \
162 } \
163 trace_dump_array_end(); \
164 } while(0)
165
166 #define trace_dump_member(_type, _obj, _member) \
167 do { \
168 trace_dump_member_begin(#_member); \
169 trace_dump_##_type((_obj)->_member); \
170 trace_dump_member_end(); \
171 } while(0)
172
173 #define trace_dump_arg_array(_type, _arg, _size) \
174 do { \
175 trace_dump_arg_begin(#_arg); \
176 trace_dump_array(_type, _arg, _size); \
177 trace_dump_arg_end(); \
178 } while(0)
179
180 #define trace_dump_member_array(_type, _obj, _member) \
181 do { \
182 trace_dump_member_begin(#_member); \
183 trace_dump_array(_type, (_obj)->_member, sizeof((_obj)->_member)/sizeof((_obj)->_member[0])); \
184 trace_dump_member_end(); \
185 } while(0)
186
187
188 #endif /* TR_DUMP_H */