util/u_dump: Update texture target strings.
[mesa.git] / src / gallium / auxiliary / util / u_dump_defines.c
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 *
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 "PIPE_TEXTURE_RECT",
267 "PIPE_TEXTURE_1D_ARRAY",
268 "PIPE_TEXTURE_2D_ARRAY",
269 "PIPE_TEXTURE_CUBE_ARRAY",
270 };
271
272 static const char *
273 util_dump_tex_target_short_names[] = {
274 "buffer",
275 "1d",
276 "2d",
277 "3d",
278 "cube",
279 "rect",
280 "1d_array",
281 "2d_array",
282 "cube_array",
283 };
284
285 DEFINE_UTIL_DUMP_CONTINUOUS(tex_target)
286
287
288 static const char *
289 util_dump_tex_wrap_names[] = {
290 "PIPE_TEX_WRAP_REPEAT",
291 "PIPE_TEX_WRAP_CLAMP",
292 "PIPE_TEX_WRAP_CLAMP_TO_EDGE",
293 "PIPE_TEX_WRAP_CLAMP_TO_BORDER",
294 "PIPE_TEX_WRAP_MIRROR_REPEAT",
295 "PIPE_TEX_WRAP_MIRROR_CLAMP",
296 "PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE",
297 "PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER"
298 };
299
300 static const char *
301 util_dump_tex_wrap_short_names[] = {
302 "repeat",
303 "clamp",
304 "clamp_to_edge",
305 "clamp_to_border",
306 "mirror_repeat",
307 "mirror_clamp",
308 "mirror_clamp_to_edge",
309 "mirror_clamp_to_border"
310 };
311
312 DEFINE_UTIL_DUMP_CONTINUOUS(tex_wrap)
313
314
315 static const char *
316 util_dump_tex_mipfilter_names[] = {
317 "PIPE_TEX_MIPFILTER_NEAREST",
318 "PIPE_TEX_MIPFILTER_LINEAR",
319 "PIPE_TEX_MIPFILTER_NONE"
320 };
321
322 static const char *
323 util_dump_tex_mipfilter_short_names[] = {
324 "nearest",
325 "linear",
326 "none"
327 };
328
329 DEFINE_UTIL_DUMP_CONTINUOUS(tex_mipfilter)
330
331
332 static const char *
333 util_dump_tex_filter_names[] = {
334 "PIPE_TEX_FILTER_NEAREST",
335 "PIPE_TEX_FILTER_LINEAR"
336 };
337
338 static const char *
339 util_dump_tex_filter_short_names[] = {
340 "nearest",
341 "linear"
342 };
343
344 DEFINE_UTIL_DUMP_CONTINUOUS(tex_filter)