Merge branch '7.8'
[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_buffer;
41 struct pipe_resource;
42 struct pipe_surface;
43 struct pipe_transfer;
44 struct pipe_box;
45
46 /*
47 * Call before use.
48 */
49 void trace_dump_init(void);
50
51 /*
52 * Low level dumping controls.
53 *
54 * Opening the trace file and checking if that is opened.
55 */
56 boolean trace_dump_trace_begin(void);
57 boolean trace_dump_trace_enabled(void);
58 void trace_dump_trace_end(void);
59
60 /*
61 * Lock and unlock the call mutex.
62 *
63 * It used by the none locked version of dumping control
64 * and begin/end call dump functions.
65 *
66 * Begin takes the lock while end unlocks it. Use the _locked
67 * version to avoid locking/unlocking it.
68 */
69 void trace_dump_call_lock(void);
70 void trace_dump_call_unlock(void);
71
72 /*
73 * High level dumping control.
74 */
75 void trace_dumping_start_locked(void);
76 void trace_dumping_stop_locked(void);
77 boolean trace_dumping_enabled_locked(void);
78 void trace_dumping_start(void);
79 void trace_dumping_stop(void);
80 boolean trace_dumping_enabled(void);
81
82 void trace_dump_call_begin_locked(const char *klass, const char *method);
83 void trace_dump_call_end_locked(void);
84 void trace_dump_call_begin(const char *klass, const char *method);
85 void trace_dump_call_end(void);
86
87 void trace_dump_arg_begin(const char *name);
88 void trace_dump_arg_end(void);
89 void trace_dump_ret_begin(void);
90 void trace_dump_ret_end(void);
91 void trace_dump_bool(int value);
92 void trace_dump_int(long long int value);
93 void trace_dump_uint(long long unsigned value);
94 void trace_dump_float(double value);
95 void trace_dump_bytes(const void *data, size_t size);
96 void trace_dump_box_bytes(const void *data,
97 enum pipe_format format,
98 const struct pipe_box *box,
99 unsigned stride,
100 unsigned slice_stride);
101 void trace_dump_string(const char *str);
102 void trace_dump_enum(const char *value);
103 void trace_dump_array_begin(void);
104 void trace_dump_array_end(void);
105 void trace_dump_elem_begin(void);
106 void trace_dump_elem_end(void);
107 void trace_dump_struct_begin(const char *name);
108 void trace_dump_struct_end(void);
109 void trace_dump_member_begin(const char *name);
110 void trace_dump_member_end(void);
111 void trace_dump_null(void);
112 void trace_dump_ptr(const void *value);
113 /* will turn a wrapped object into the real one and dump ptr */
114 void trace_dump_resource_ptr(struct pipe_resource *_texture);
115 void trace_dump_surface_ptr(struct pipe_surface *_surface);
116 void trace_dump_transfer_ptr(struct pipe_transfer *_transfer);
117
118 /*
119 * Code saving macros.
120 */
121
122 #define trace_dump_arg(_type, _arg) \
123 do { \
124 trace_dump_arg_begin(#_arg); \
125 trace_dump_##_type(_arg); \
126 trace_dump_arg_end(); \
127 } while(0)
128
129 #define trace_dump_arg_struct(_type, _arg) \
130 do { \
131 trace_dump_arg_begin(#_arg); \
132 trace_dump_##_type(&_arg); \
133 trace_dump_arg_end(); \
134 } while(0)
135
136 #define trace_dump_ret(_type, _arg) \
137 do { \
138 trace_dump_ret_begin(); \
139 trace_dump_##_type(_arg); \
140 trace_dump_ret_end(); \
141 } while(0)
142
143 #define trace_dump_array(_type, _obj, _size) \
144 do { \
145 size_t idx; \
146 trace_dump_array_begin(); \
147 for(idx = 0; idx < (_size); ++idx) { \
148 trace_dump_elem_begin(); \
149 trace_dump_##_type((_obj)[idx]); \
150 trace_dump_elem_end(); \
151 } \
152 trace_dump_array_end(); \
153 } while(0)
154
155 #define trace_dump_struct_array(_type, _obj, _size) \
156 do { \
157 size_t idx; \
158 trace_dump_array_begin(); \
159 for(idx = 0; idx < (_size); ++idx) { \
160 trace_dump_elem_begin(); \
161 trace_dump_##_type(&(_obj)[idx]); \
162 trace_dump_elem_end(); \
163 } \
164 trace_dump_array_end(); \
165 } while(0)
166
167 #define trace_dump_member(_type, _obj, _member) \
168 do { \
169 trace_dump_member_begin(#_member); \
170 trace_dump_##_type((_obj)->_member); \
171 trace_dump_member_end(); \
172 } while(0)
173
174 #define trace_dump_arg_array(_type, _arg, _size) \
175 do { \
176 trace_dump_arg_begin(#_arg); \
177 trace_dump_array(_type, _arg, _size); \
178 trace_dump_arg_end(); \
179 } while(0)
180
181 #define trace_dump_member_array(_type, _obj, _member) \
182 do { \
183 trace_dump_member_begin(#_member); \
184 trace_dump_array(_type, (_obj)->_member, sizeof((_obj)->_member)/sizeof((_obj)->_member[0])); \
185 trace_dump_member_end(); \
186 } while(0)
187
188
189 #endif /* TR_DUMP_H */