util: Add support for other DXTn RGBA formats.
[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_func_names[] = {
164 "PIPE_FUNC_NEVER",
165 "PIPE_FUNC_LESS",
166 "PIPE_FUNC_EQUAL",
167 "PIPE_FUNC_LEQUAL",
168 "PIPE_FUNC_GREATER",
169 "PIPE_FUNC_NOTEQUAL",
170 "PIPE_FUNC_GEQUAL",
171 "PIPE_FUNC_ALWAYS"
172 };
173
174 static const char *
175 util_dump_func_short_names[] = {
176 "never",
177 "less",
178 "equal",
179 "less_equal",
180 "greater",
181 "not_equal",
182 "greater_equal",
183 "always"
184 };
185
186 DEFINE_UTIL_DUMP_CONTINUOUS(func)
187
188
189 static const char *
190 util_dump_tex_target_names[] = {
191 "PIPE_TEXTURE_1D",
192 "PIPE_TEXTURE_2D",
193 "PIPE_TEXTURE_3D",
194 "PIPE_TEXTURE_CUBE"
195 };
196
197 static const char *
198 util_dump_tex_target_short_names[] = {
199 "1d",
200 "2d",
201 "3d",
202 "cube"
203 };
204
205 DEFINE_UTIL_DUMP_CONTINUOUS(tex_target)
206
207
208 static const char *
209 util_dump_tex_wrap_names[] = {
210 "PIPE_TEX_WRAP_REPEAT",
211 "PIPE_TEX_WRAP_CLAMP",
212 "PIPE_TEX_WRAP_CLAMP_TO_EDGE",
213 "PIPE_TEX_WRAP_CLAMP_TO_BORDER",
214 "PIPE_TEX_WRAP_MIRROR_REPEAT",
215 "PIPE_TEX_WRAP_MIRROR_CLAMP",
216 "PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE",
217 "PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER"
218 };
219
220 static const char *
221 util_dump_tex_wrap_short_names[] = {
222 "repeat",
223 "clamp",
224 "clamp_to_edge",
225 "clamp_to_border",
226 "mirror_repeat",
227 "mirror_clamp",
228 "mirror_clamp_to_edge",
229 "mirror_clamp_to_border"
230 };
231
232 DEFINE_UTIL_DUMP_CONTINUOUS(tex_wrap)
233
234
235 static const char *
236 util_dump_tex_mipfilter_names[] = {
237 "PIPE_TEX_MIPFILTER_NEAREST",
238 "PIPE_TEX_MIPFILTER_LINEAR",
239 "PIPE_TEX_MIPFILTER_NONE"
240 };
241
242 static const char *
243 util_dump_tex_mipfilter_short_names[] = {
244 "nearest",
245 "linear",
246 "none"
247 };
248
249 DEFINE_UTIL_DUMP_CONTINUOUS(tex_mipfilter)
250
251
252 static const char *
253 util_dump_tex_filter_names[] = {
254 "PIPE_TEX_FILTER_NEAREST",
255 "PIPE_TEX_FILTER_LINEAR"
256 };
257
258 static const char *
259 util_dump_tex_filter_short_names[] = {
260 "nearest",
261 "linear"
262 };
263
264 DEFINE_UTIL_DUMP_CONTINUOUS(tex_filter)