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