• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**************************************************************************
2  *
3  * Copyright 2009 VMware, Inc.
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 VMWARE 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 #include "util/u_memory.h"
30 #include "util/u_debug.h"
31 #include "util/u_dump.h"
32 
33 
34 #if 0
35 static const char *
36 util_dump_strip_prefix(const char *name,
37                         const char *prefix)
38 {
39    const char *stripped;
40    assert(name);
41    assert(prefix);
42    stripped = name;
43    while(*prefix) {
44       if(*stripped != *prefix)
45 	 return name;
46 
47       ++stripped;
48       ++prefix;
49    }
50    return stripped;
51 }
52 #endif
53 
54 static const char *
util_dump_enum_continuous(unsigned value,unsigned num_names,const char ** names)55 util_dump_enum_continuous(unsigned value,
56                            unsigned num_names,
57                            const char **names)
58 {
59    if (value >= num_names)
60       return UTIL_DUMP_INVALID_NAME;
61    return names[value];
62 }
63 
64 
65 #define DEFINE_UTIL_DUMP_CONTINUOUS(_name) \
66    const char * \
67    util_dump_##_name(unsigned value, boolean shortened) \
68    { \
69       if(shortened) \
70          return util_dump_enum_continuous(value, Elements(util_dump_##_name##_short_names), util_dump_##_name##_short_names); \
71       else \
72          return util_dump_enum_continuous(value, Elements(util_dump_##_name##_names), util_dump_##_name##_names); \
73    }
74 
75 
76 static const char *
77 util_dump_blend_factor_names[] = {
78    UTIL_DUMP_INVALID_NAME, /* 0x0 */
79    "PIPE_BLENDFACTOR_ONE",
80    "PIPE_BLENDFACTOR_SRC_COLOR",
81    "PIPE_BLENDFACTOR_SRC_ALPHA",
82    "PIPE_BLENDFACTOR_DST_ALPHA",
83    "PIPE_BLENDFACTOR_DST_COLOR",
84    "PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE",
85    "PIPE_BLENDFACTOR_CONST_COLOR",
86    "PIPE_BLENDFACTOR_CONST_ALPHA",
87    "PIPE_BLENDFACTOR_SRC1_COLOR",
88    "PIPE_BLENDFACTOR_SRC1_ALPHA",
89    UTIL_DUMP_INVALID_NAME, /* 0x0b */
90    UTIL_DUMP_INVALID_NAME, /* 0x0c */
91    UTIL_DUMP_INVALID_NAME, /* 0x0d */
92    UTIL_DUMP_INVALID_NAME, /* 0x0e */
93    UTIL_DUMP_INVALID_NAME, /* 0x0f */
94    UTIL_DUMP_INVALID_NAME, /* 0x10 */
95    "PIPE_BLENDFACTOR_ZERO",
96    "PIPE_BLENDFACTOR_INV_SRC_COLOR",
97    "PIPE_BLENDFACTOR_INV_SRC_ALPHA",
98    "PIPE_BLENDFACTOR_INV_DST_ALPHA",
99    "PIPE_BLENDFACTOR_INV_DST_COLOR",
100    UTIL_DUMP_INVALID_NAME, /* 0x16 */
101    "PIPE_BLENDFACTOR_INV_CONST_COLOR",
102    "PIPE_BLENDFACTOR_INV_CONST_ALPHA",
103    "PIPE_BLENDFACTOR_INV_SRC1_COLOR",
104    "PIPE_BLENDFACTOR_INV_SRC1_ALPHA"
105 };
106 
107 static const char *
108 util_dump_blend_factor_short_names[] = {
109    UTIL_DUMP_INVALID_NAME, /* 0x0 */
110    "one",
111    "src_color",
112    "src_alpha",
113    "dst_alpha",
114    "dst_color",
115    "src_alpha_saturate",
116    "const_color",
117    "const_alpha",
118    "src1_color",
119    "src1_alpha",
120    UTIL_DUMP_INVALID_NAME, /* 0x0b */
121    UTIL_DUMP_INVALID_NAME, /* 0x0c */
122    UTIL_DUMP_INVALID_NAME, /* 0x0d */
123    UTIL_DUMP_INVALID_NAME, /* 0x0e */
124    UTIL_DUMP_INVALID_NAME, /* 0x0f */
125    UTIL_DUMP_INVALID_NAME, /* 0x10 */
126    "zero",
127    "inv_src_color",
128    "inv_src_alpha",
129    "inv_dst_alpha",
130    "inv_dst_color",
131    UTIL_DUMP_INVALID_NAME, /* 0x16 */
132    "inv_const_color",
133    "inv_const_alpha",
134    "inv_src1_color",
135    "inv_src1_alpha"
136 };
137 
138 DEFINE_UTIL_DUMP_CONTINUOUS(blend_factor)
139 
140 
141 static const char *
142 util_dump_blend_func_names[] = {
143    "PIPE_BLEND_ADD",
144    "PIPE_BLEND_SUBTRACT",
145    "PIPE_BLEND_REVERSE_SUBTRACT",
146    "PIPE_BLEND_MIN",
147    "PIPE_BLEND_MAX"
148 };
149 
150 static const char *
151 util_dump_blend_func_short_names[] = {
152    "add",
153    "sub",
154    "rev_sub",
155    "min",
156    "max"
157 };
158 
159 DEFINE_UTIL_DUMP_CONTINUOUS(blend_func)
160 
161 
162 static const char *
163 util_dump_logicop_names[] = {
164    "PIPE_LOGICOP_CLEAR",
165    "PIPE_LOGICOP_NOR",
166    "PIPE_LOGICOP_AND_INVERTED",
167    "PIPE_LOGICOP_COPY_INVERTED",
168    "PIPE_LOGICOP_AND_REVERSE",
169    "PIPE_LOGICOP_INVERT",
170    "PIPE_LOGICOP_XOR",
171    "PIPE_LOGICOP_NAND",
172    "PIPE_LOGICOP_AND",
173    "PIPE_LOGICOP_EQUIV",
174    "PIPE_LOGICOP_NOOP",
175    "PIPE_LOGICOP_OR_INVERTED",
176    "PIPE_LOGICOP_COPY",
177    "PIPE_LOGICOP_OR_REVERSE",
178    "PIPE_LOGICOP_OR",
179    "PIPE_LOGICOP_SET"
180 };
181 
182 static const char *
183 util_dump_logicop_short_names[] = {
184    "clear",
185    "nor",
186    "and_inverted",
187    "copy_inverted",
188    "and_reverse",
189    "invert",
190    "xor",
191    "nand",
192    "and",
193    "equiv",
194    "noop",
195    "or_inverted",
196    "copy",
197    "or_reverse",
198    "or",
199    "set"
200 };
201 
202 DEFINE_UTIL_DUMP_CONTINUOUS(logicop)
203 
204 
205 static const char *
206 util_dump_func_names[] = {
207    "PIPE_FUNC_NEVER",
208    "PIPE_FUNC_LESS",
209    "PIPE_FUNC_EQUAL",
210    "PIPE_FUNC_LEQUAL",
211    "PIPE_FUNC_GREATER",
212    "PIPE_FUNC_NOTEQUAL",
213    "PIPE_FUNC_GEQUAL",
214    "PIPE_FUNC_ALWAYS"
215 };
216 
217 static const char *
218 util_dump_func_short_names[] = {
219    "never",
220    "less",
221    "equal",
222    "less_equal",
223    "greater",
224    "not_equal",
225    "greater_equal",
226    "always"
227 };
228 
229 DEFINE_UTIL_DUMP_CONTINUOUS(func)
230 
231 
232 static const char *
233 util_dump_stencil_op_names[] = {
234    "PIPE_STENCIL_OP_KEEP",
235    "PIPE_STENCIL_OP_ZERO",
236    "PIPE_STENCIL_OP_REPLACE",
237    "PIPE_STENCIL_OP_INCR",
238    "PIPE_STENCIL_OP_DECR",
239    "PIPE_STENCIL_OP_INCR_WRAP",
240    "PIPE_STENCIL_OP_DECR_WRAP",
241    "PIPE_STENCIL_OP_INVERT"
242 };
243 
244 static const char *
245 util_dump_stencil_op_short_names[] = {
246    "keep",
247    "zero",
248    "replace",
249    "incr",
250    "decr",
251    "incr_wrap",
252    "decr_wrap",
253    "invert"
254 };
255 
256 DEFINE_UTIL_DUMP_CONTINUOUS(stencil_op)
257 
258 
259 static const char *
260 util_dump_tex_target_names[] = {
261    "PIPE_BUFFER",
262    "PIPE_TEXTURE_1D",
263    "PIPE_TEXTURE_2D",
264    "PIPE_TEXTURE_3D",
265    "PIPE_TEXTURE_CUBE"
266 };
267 
268 static const char *
269 util_dump_tex_target_short_names[] = {
270    "buffer",
271    "1d",
272    "2d",
273    "3d",
274    "cube"
275 };
276 
277 DEFINE_UTIL_DUMP_CONTINUOUS(tex_target)
278 
279 
280 static const char *
281 util_dump_tex_wrap_names[] = {
282    "PIPE_TEX_WRAP_REPEAT",
283    "PIPE_TEX_WRAP_CLAMP",
284    "PIPE_TEX_WRAP_CLAMP_TO_EDGE",
285    "PIPE_TEX_WRAP_CLAMP_TO_BORDER",
286    "PIPE_TEX_WRAP_MIRROR_REPEAT",
287    "PIPE_TEX_WRAP_MIRROR_CLAMP",
288    "PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE",
289    "PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER"
290 };
291 
292 static const char *
293 util_dump_tex_wrap_short_names[] = {
294    "repeat",
295    "clamp",
296    "clamp_to_edge",
297    "clamp_to_border",
298    "mirror_repeat",
299    "mirror_clamp",
300    "mirror_clamp_to_edge",
301    "mirror_clamp_to_border"
302 };
303 
304 DEFINE_UTIL_DUMP_CONTINUOUS(tex_wrap)
305 
306 
307 static const char *
308 util_dump_tex_mipfilter_names[] = {
309    "PIPE_TEX_MIPFILTER_NEAREST",
310    "PIPE_TEX_MIPFILTER_LINEAR",
311    "PIPE_TEX_MIPFILTER_NONE"
312 };
313 
314 static const char *
315 util_dump_tex_mipfilter_short_names[] = {
316    "nearest",
317    "linear",
318    "none"
319 };
320 
321 DEFINE_UTIL_DUMP_CONTINUOUS(tex_mipfilter)
322 
323 
324 static const char *
325 util_dump_tex_filter_names[] = {
326    "PIPE_TEX_FILTER_NEAREST",
327    "PIPE_TEX_FILTER_LINEAR"
328 };
329 
330 static const char *
331 util_dump_tex_filter_short_names[] = {
332    "nearest",
333    "linear"
334 };
335 
336 DEFINE_UTIL_DUMP_CONTINUOUS(tex_filter)
337