Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1901 | serge | 1 | /* |
2 | * Mesa 3-D graphics library |
||
3 | * Version: 7.7 |
||
4 | * |
||
5 | * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. |
||
6 | * Copyright (c) 2008-2009 VMware, Inc. |
||
7 | * |
||
8 | * Permission is hereby granted, free of charge, to any person obtaining a |
||
9 | * copy of this software and associated documentation files (the "Software"), |
||
10 | * to deal in the Software without restriction, including without limitation |
||
11 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||
12 | * and/or sell copies of the Software, and to permit persons to whom the |
||
13 | * Software is furnished to do so, subject to the following conditions: |
||
14 | * |
||
15 | * The above copyright notice and this permission notice shall be included |
||
16 | * in all copies or substantial portions 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 MERCHANTABILITY, |
||
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||
21 | * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
||
22 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
||
23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||
24 | */ |
||
25 | |||
26 | |||
27 | #include "imports.h" |
||
28 | #include "formats.h" |
||
29 | #include "mfeatures.h" |
||
30 | |||
31 | |||
32 | /** |
||
33 | * Information about texture formats. |
||
34 | */ |
||
35 | struct gl_format_info |
||
36 | { |
||
37 | gl_format Name; |
||
38 | |||
39 | /** text name for debugging */ |
||
40 | const char *StrName; |
||
41 | |||
42 | /** |
||
43 | * Base format is one of GL_RGB, GL_RGBA, GL_ALPHA, GL_LUMINANCE, |
||
44 | * GL_LUMINANCE_ALPHA, GL_INTENSITY, GL_YCBCR_MESA, GL_COLOR_INDEX, |
||
45 | * GL_DEPTH_COMPONENT, GL_STENCIL_INDEX, GL_DEPTH_STENCIL. |
||
46 | */ |
||
47 | GLenum BaseFormat; |
||
48 | |||
49 | /** |
||
50 | * Logical data type: one of GL_UNSIGNED_NORMALIZED, GL_SIGNED_NORMALED, |
||
51 | * GL_UNSIGNED_INT, GL_INT, GL_FLOAT. |
||
52 | */ |
||
53 | GLenum DataType; |
||
54 | |||
55 | GLubyte RedBits; |
||
56 | GLubyte GreenBits; |
||
57 | GLubyte BlueBits; |
||
58 | GLubyte AlphaBits; |
||
59 | GLubyte LuminanceBits; |
||
60 | GLubyte IntensityBits; |
||
61 | GLubyte IndexBits; |
||
62 | GLubyte DepthBits; |
||
63 | GLubyte StencilBits; |
||
64 | |||
65 | /** |
||
66 | * To describe compressed formats. If not compressed, Width=Height=1. |
||
67 | */ |
||
68 | GLubyte BlockWidth, BlockHeight; |
||
69 | GLubyte BytesPerBlock; |
||
70 | }; |
||
71 | |||
72 | |||
73 | /** |
||
74 | * Info about each format. |
||
75 | * These must be in the same order as the MESA_FORMAT_* enums so that |
||
76 | * we can do lookups without searching. |
||
77 | */ |
||
78 | static struct gl_format_info format_info[MESA_FORMAT_COUNT] = |
||
79 | { |
||
80 | { |
||
81 | MESA_FORMAT_NONE, /* Name */ |
||
82 | "MESA_FORMAT_NONE", /* StrName */ |
||
83 | GL_NONE, /* BaseFormat */ |
||
84 | GL_NONE, /* DataType */ |
||
85 | 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ |
||
86 | 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ |
||
87 | 0, 0, 0 /* BlockWidth/Height,Bytes */ |
||
88 | }, |
||
89 | { |
||
90 | MESA_FORMAT_RGBA8888, /* Name */ |
||
91 | "MESA_FORMAT_RGBA8888", /* StrName */ |
||
92 | GL_RGBA, /* BaseFormat */ |
||
93 | GL_UNSIGNED_NORMALIZED, /* DataType */ |
||
94 | 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */ |
||
95 | 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ |
||
96 | 1, 1, 4 /* BlockWidth/Height,Bytes */ |
||
97 | }, |
||
98 | { |
||
99 | MESA_FORMAT_RGBA8888_REV, /* Name */ |
||
100 | "MESA_FORMAT_RGBA8888_REV", /* StrName */ |
||
101 | GL_RGBA, /* BaseFormat */ |
||
102 | GL_UNSIGNED_NORMALIZED, /* DataType */ |
||
103 | 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */ |
||
104 | 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ |
||
105 | 1, 1, 4 /* BlockWidth/Height,Bytes */ |
||
106 | }, |
||
107 | { |
||
108 | MESA_FORMAT_ARGB8888, /* Name */ |
||
109 | "MESA_FORMAT_ARGB8888", /* StrName */ |
||
110 | GL_RGBA, /* BaseFormat */ |
||
111 | GL_UNSIGNED_NORMALIZED, /* DataType */ |
||
112 | 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */ |
||
113 | 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ |
||
114 | 1, 1, 4 /* BlockWidth/Height,Bytes */ |
||
115 | }, |
||
116 | { |
||
117 | MESA_FORMAT_ARGB8888_REV, /* Name */ |
||
118 | "MESA_FORMAT_ARGB8888_REV", /* StrName */ |
||
119 | GL_RGBA, /* BaseFormat */ |
||
120 | GL_UNSIGNED_NORMALIZED, /* DataType */ |
||
121 | 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */ |
||
122 | 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ |
||
123 | 1, 1, 4 /* BlockWidth/Height,Bytes */ |
||
124 | }, |
||
125 | { |
||
126 | MESA_FORMAT_XRGB8888, /* Name */ |
||
127 | "MESA_FORMAT_XRGB8888", /* StrName */ |
||
128 | GL_RGB, /* BaseFormat */ |
||
129 | GL_UNSIGNED_NORMALIZED, /* DataType */ |
||
130 | 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */ |
||
131 | 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ |
||
132 | 1, 1, 4 /* BlockWidth/Height,Bytes */ |
||
133 | }, |
||
134 | { |
||
135 | MESA_FORMAT_XRGB8888_REV, /* Name */ |
||
136 | "MESA_FORMAT_XRGB8888_REV", /* StrName */ |
||
137 | GL_RGB, /* BaseFormat */ |
||
138 | GL_UNSIGNED_NORMALIZED, /* DataType */ |
||
139 | 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */ |
||
140 | 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ |
||
141 | 1, 1, 4 /* BlockWidth/Height,Bytes */ |
||
142 | }, |
||
143 | { |
||
144 | MESA_FORMAT_RGB888, /* Name */ |
||
145 | "MESA_FORMAT_RGB888", /* StrName */ |
||
146 | GL_RGB, /* BaseFormat */ |
||
147 | GL_UNSIGNED_NORMALIZED, /* DataType */ |
||
148 | 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */ |
||
149 | 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ |
||
150 | 1, 1, 3 /* BlockWidth/Height,Bytes */ |
||
151 | }, |
||
152 | { |
||
153 | MESA_FORMAT_BGR888, /* Name */ |
||
154 | "MESA_FORMAT_BGR888", /* StrName */ |
||
155 | GL_RGB, /* BaseFormat */ |
||
156 | GL_UNSIGNED_NORMALIZED, /* DataType */ |
||
157 | 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */ |
||
158 | 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ |
||
159 | 1, 1, 3 /* BlockWidth/Height,Bytes */ |
||
160 | }, |
||
161 | { |
||
162 | MESA_FORMAT_RGB565, /* Name */ |
||
163 | "MESA_FORMAT_RGB565", /* StrName */ |
||
164 | GL_RGB, /* BaseFormat */ |
||
165 | GL_UNSIGNED_NORMALIZED, /* DataType */ |
||
166 | 5, 6, 5, 0, /* Red/Green/Blue/AlphaBits */ |
||
167 | 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ |
||
168 | 1, 1, 2 /* BlockWidth/Height,Bytes */ |
||
169 | }, |
||
170 | { |
||
171 | MESA_FORMAT_RGB565_REV, /* Name */ |
||
172 | "MESA_FORMAT_RGB565_REV", /* StrName */ |
||
173 | GL_RGB, /* BaseFormat */ |
||
174 | GL_UNSIGNED_NORMALIZED, /* DataType */ |
||
175 | 5, 6, 5, 0, /* Red/Green/Blue/AlphaBits */ |
||
176 | 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ |
||
177 | 1, 1, 2 /* BlockWidth/Height,Bytes */ |
||
178 | }, |
||
179 | { |
||
180 | MESA_FORMAT_ARGB4444, /* Name */ |
||
181 | "MESA_FORMAT_ARGB4444", /* StrName */ |
||
182 | GL_RGBA, /* BaseFormat */ |
||
183 | GL_UNSIGNED_NORMALIZED, /* DataType */ |
||
184 | 4, 4, 4, 4, /* Red/Green/Blue/AlphaBits */ |
||
185 | 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ |
||
186 | 1, 1, 2 /* BlockWidth/Height,Bytes */ |
||
187 | }, |
||
188 | { |
||
189 | MESA_FORMAT_ARGB4444_REV, /* Name */ |
||
190 | "MESA_FORMAT_ARGB4444_REV", /* StrName */ |
||
191 | GL_RGBA, /* BaseFormat */ |
||
192 | GL_UNSIGNED_NORMALIZED, /* DataType */ |
||
193 | 4, 4, 4, 4, /* Red/Green/Blue/AlphaBits */ |
||
194 | 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ |
||
195 | 1, 1, 2 /* BlockWidth/Height,Bytes */ |
||
196 | }, |
||
197 | { |
||
198 | MESA_FORMAT_RGBA5551, /* Name */ |
||
199 | "MESA_FORMAT_RGBA5551", /* StrName */ |
||
200 | GL_RGBA, /* BaseFormat */ |
||
201 | GL_UNSIGNED_NORMALIZED, /* DataType */ |
||
202 | 5, 5, 5, 1, /* Red/Green/Blue/AlphaBits */ |
||
203 | 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ |
||
204 | 1, 1, 2 /* BlockWidth/Height,Bytes */ |
||
205 | }, |
||
206 | { |
||
207 | MESA_FORMAT_ARGB1555, /* Name */ |
||
208 | "MESA_FORMAT_ARGB1555", /* StrName */ |
||
209 | GL_RGBA, /* BaseFormat */ |
||
210 | GL_UNSIGNED_NORMALIZED, /* DataType */ |
||
211 | 5, 5, 5, 1, /* Red/Green/Blue/AlphaBits */ |
||
212 | 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ |
||
213 | 1, 1, 2 /* BlockWidth/Height,Bytes */ |
||
214 | }, |
||
215 | { |
||
216 | MESA_FORMAT_ARGB1555_REV, /* Name */ |
||
217 | "MESA_FORMAT_ARGB1555_REV", /* StrName */ |
||
218 | GL_RGBA, /* BaseFormat */ |
||
219 | GL_UNSIGNED_NORMALIZED, /* DataType */ |
||
220 | 5, 5, 5, 1, /* Red/Green/Blue/AlphaBits */ |
||
221 | 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ |
||
222 | 1, 1, 2 /* BlockWidth/Height,Bytes */ |
||
223 | }, |
||
224 | { |
||
225 | MESA_FORMAT_AL88, /* Name */ |
||
226 | "MESA_FORMAT_AL88", /* StrName */ |
||
227 | GL_LUMINANCE_ALPHA, /* BaseFormat */ |
||
228 | GL_UNSIGNED_NORMALIZED, /* DataType */ |
||
229 | 0, 0, 0, 8, /* Red/Green/Blue/AlphaBits */ |
||
230 | 8, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ |
||
231 | 1, 1, 2 /* BlockWidth/Height,Bytes */ |
||
232 | }, |
||
233 | { |
||
234 | MESA_FORMAT_AL88_REV, /* Name */ |
||
235 | "MESA_FORMAT_AL88_REV", /* StrName */ |
||
236 | GL_LUMINANCE_ALPHA, /* BaseFormat */ |
||
237 | GL_UNSIGNED_NORMALIZED, /* DataType */ |
||
238 | 0, 0, 0, 8, /* Red/Green/Blue/AlphaBits */ |
||
239 | 8, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ |
||
240 | 1, 1, 2 /* BlockWidth/Height,Bytes */ |
||
241 | }, |
||
242 | { |
||
243 | MESA_FORMAT_AL1616, /* Name */ |
||
244 | "MESA_FORMAT_AL1616", /* StrName */ |
||
245 | GL_LUMINANCE_ALPHA, /* BaseFormat */ |
||
246 | GL_UNSIGNED_NORMALIZED, /* DataType */ |
||
247 | 0, 0, 0, 16, /* Red/Green/Blue/AlphaBits */ |
||
248 | 16, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ |
||
249 | 1, 1, 4 /* BlockWidth/Height,Bytes */ |
||
250 | }, |
||
251 | { |
||
252 | MESA_FORMAT_AL1616_REV, /* Name */ |
||
253 | "MESA_FORMAT_AL1616_REV", /* StrName */ |
||
254 | GL_LUMINANCE_ALPHA, /* BaseFormat */ |
||
255 | GL_UNSIGNED_NORMALIZED, /* DataType */ |
||
256 | 0, 0, 0, 16, /* Red/Green/Blue/AlphaBits */ |
||
257 | 16, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ |
||
258 | 1, 1, 4 /* BlockWidth/Height,Bytes */ |
||
259 | }, |
||
260 | { |
||
261 | MESA_FORMAT_RGB332, /* Name */ |
||
262 | "MESA_FORMAT_RGB332", /* StrName */ |
||
263 | GL_RGB, /* BaseFormat */ |
||
264 | GL_UNSIGNED_NORMALIZED, /* DataType */ |
||
265 | 3, 3, 2, 0, /* Red/Green/Blue/AlphaBits */ |
||
266 | 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ |
||
267 | 1, 1, 1 /* BlockWidth/Height,Bytes */ |
||
268 | }, |
||
269 | { |
||
270 | MESA_FORMAT_A8, /* Name */ |
||
271 | "MESA_FORMAT_A8", /* StrName */ |
||
272 | GL_ALPHA, /* BaseFormat */ |
||
273 | GL_UNSIGNED_NORMALIZED, /* DataType */ |
||
274 | 0, 0, 0, 8, /* Red/Green/Blue/AlphaBits */ |
||
275 | 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ |
||
276 | 1, 1, 1 /* BlockWidth/Height,Bytes */ |
||
277 | }, |
||
278 | { |
||
279 | MESA_FORMAT_L8, /* Name */ |
||
280 | "MESA_FORMAT_L8", /* StrName */ |
||
281 | GL_LUMINANCE, /* BaseFormat */ |
||
282 | GL_UNSIGNED_NORMALIZED, /* DataType */ |
||
283 | 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ |
||
284 | 8, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ |
||
285 | 1, 1, 1 /* BlockWidth/Height,Bytes */ |
||
286 | }, |
||
287 | { |
||
288 | MESA_FORMAT_I8, /* Name */ |
||
289 | "MESA_FORMAT_I8", /* StrName */ |
||
290 | GL_INTENSITY, /* BaseFormat */ |
||
291 | GL_UNSIGNED_NORMALIZED, /* DataType */ |
||
292 | 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ |
||
293 | 0, 8, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ |
||
294 | 1, 1, 1 /* BlockWidth/Height,Bytes */ |
||
295 | }, |
||
296 | { |
||
297 | MESA_FORMAT_CI8, /* Name */ |
||
298 | "MESA_FORMAT_CI8", /* StrName */ |
||
299 | GL_COLOR_INDEX, /* BaseFormat */ |
||
300 | GL_UNSIGNED_INT, /* DataType */ |
||
301 | 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ |
||
302 | 0, 0, 8, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ |
||
303 | 1, 1, 1 /* BlockWidth/Height,Bytes */ |
||
304 | }, |
||
305 | { |
||
306 | MESA_FORMAT_YCBCR, /* Name */ |
||
307 | "MESA_FORMAT_YCBCR", /* StrName */ |
||
308 | GL_YCBCR_MESA, /* BaseFormat */ |
||
309 | GL_UNSIGNED_NORMALIZED, /* DataType */ |
||
310 | 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ |
||
311 | 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ |
||
312 | 1, 1, 2 /* BlockWidth/Height,Bytes */ |
||
313 | }, |
||
314 | { |
||
315 | MESA_FORMAT_YCBCR_REV, /* Name */ |
||
316 | "MESA_FORMAT_YCBCR_REV", /* StrName */ |
||
317 | GL_YCBCR_MESA, /* BaseFormat */ |
||
318 | GL_UNSIGNED_NORMALIZED, /* DataType */ |
||
319 | 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ |
||
320 | 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ |
||
321 | 1, 1, 2 /* BlockWidth/Height,Bytes */ |
||
322 | }, |
||
323 | { |
||
324 | MESA_FORMAT_R8, |
||
325 | "MESA_FORMAT_R8", |
||
326 | GL_RED, |
||
327 | GL_UNSIGNED_NORMALIZED, |
||
328 | 8, 0, 0, 0, |
||
329 | 0, 0, 0, 0, 0, |
||
330 | 1, 1, 1 |
||
331 | }, |
||
332 | { |
||
333 | MESA_FORMAT_RG88, |
||
334 | "MESA_FORMAT_RG88", |
||
335 | GL_RG, |
||
336 | GL_UNSIGNED_NORMALIZED, |
||
337 | 8, 8, 0, 0, |
||
338 | 0, 0, 0, 0, 0, |
||
339 | 1, 1, 2 |
||
340 | }, |
||
341 | { |
||
342 | MESA_FORMAT_RG88_REV, |
||
343 | "MESA_FORMAT_RG88_REV", |
||
344 | GL_RG, |
||
345 | GL_UNSIGNED_NORMALIZED, |
||
346 | 8, 8, 0, 0, |
||
347 | 0, 0, 0, 0, 0, |
||
348 | 1, 1, 2 |
||
349 | }, |
||
350 | { |
||
351 | MESA_FORMAT_R16, |
||
352 | "MESA_FORMAT_R16", |
||
353 | GL_RED, |
||
354 | GL_UNSIGNED_NORMALIZED, |
||
355 | 16, 0, 0, 0, |
||
356 | 0, 0, 0, 0, 0, |
||
357 | 1, 1, 2 |
||
358 | }, |
||
359 | { |
||
360 | MESA_FORMAT_RG1616, |
||
361 | "MESA_FORMAT_RG1616", |
||
362 | GL_RG, |
||
363 | GL_UNSIGNED_NORMALIZED, |
||
364 | 16, 16, 0, 0, |
||
365 | 0, 0, 0, 0, 0, |
||
366 | 1, 1, 4 |
||
367 | }, |
||
368 | { |
||
369 | MESA_FORMAT_RG1616_REV, |
||
370 | "MESA_FORMAT_RG1616_REV", |
||
371 | GL_RG, |
||
372 | GL_UNSIGNED_NORMALIZED, |
||
373 | 16, 16, 0, 0, |
||
374 | 0, 0, 0, 0, 0, |
||
375 | 1, 1, 4 |
||
376 | }, |
||
377 | { |
||
378 | MESA_FORMAT_Z24_S8, /* Name */ |
||
379 | "MESA_FORMAT_Z24_S8", /* StrName */ |
||
380 | GL_DEPTH_STENCIL, /* BaseFormat */ |
||
381 | GL_UNSIGNED_INT, /* DataType */ |
||
382 | 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ |
||
383 | 0, 0, 0, 24, 8, /* Lum/Int/Index/Depth/StencilBits */ |
||
384 | 1, 1, 4 /* BlockWidth/Height,Bytes */ |
||
385 | }, |
||
386 | { |
||
387 | MESA_FORMAT_S8_Z24, /* Name */ |
||
388 | "MESA_FORMAT_S8_Z24", /* StrName */ |
||
389 | GL_DEPTH_STENCIL, /* BaseFormat */ |
||
390 | GL_UNSIGNED_INT, /* DataType */ |
||
391 | 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ |
||
392 | 0, 0, 0, 24, 8, /* Lum/Int/Index/Depth/StencilBits */ |
||
393 | 1, 1, 4 /* BlockWidth/Height,Bytes */ |
||
394 | }, |
||
395 | { |
||
396 | MESA_FORMAT_Z16, /* Name */ |
||
397 | "MESA_FORMAT_Z16", /* StrName */ |
||
398 | GL_DEPTH_COMPONENT, /* BaseFormat */ |
||
399 | GL_UNSIGNED_INT, /* DataType */ |
||
400 | 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ |
||
401 | 0, 0, 0, 16, 0, /* Lum/Int/Index/Depth/StencilBits */ |
||
402 | 1, 1, 2 /* BlockWidth/Height,Bytes */ |
||
403 | }, |
||
404 | { |
||
405 | MESA_FORMAT_X8_Z24, /* Name */ |
||
406 | "MESA_FORMAT_X8_Z24", /* StrName */ |
||
407 | GL_DEPTH_COMPONENT, /* BaseFormat */ |
||
408 | GL_UNSIGNED_INT, /* DataType */ |
||
409 | 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ |
||
410 | 0, 0, 0, 24, 0, /* Lum/Int/Index/Depth/StencilBits */ |
||
411 | 1, 1, 4 /* BlockWidth/Height,Bytes */ |
||
412 | }, |
||
413 | { |
||
414 | MESA_FORMAT_Z24_X8, /* Name */ |
||
415 | "MESA_FORMAT_Z24_X8", /* StrName */ |
||
416 | GL_DEPTH_COMPONENT, /* BaseFormat */ |
||
417 | GL_UNSIGNED_INT, /* DataType */ |
||
418 | 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ |
||
419 | 0, 0, 0, 24, 0, /* Lum/Int/Index/Depth/StencilBits */ |
||
420 | 1, 1, 4 /* BlockWidth/Height,Bytes */ |
||
421 | }, |
||
422 | { |
||
423 | MESA_FORMAT_Z32, /* Name */ |
||
424 | "MESA_FORMAT_Z32", /* StrName */ |
||
425 | GL_DEPTH_COMPONENT, /* BaseFormat */ |
||
426 | GL_UNSIGNED_INT, /* DataType */ |
||
427 | 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ |
||
428 | 0, 0, 0, 32, 0, /* Lum/Int/Index/Depth/StencilBits */ |
||
429 | 1, 1, 4 /* BlockWidth/Height,Bytes */ |
||
430 | }, |
||
431 | { |
||
432 | MESA_FORMAT_S8, /* Name */ |
||
433 | "MESA_FORMAT_S8", /* StrName */ |
||
434 | GL_STENCIL_INDEX, /* BaseFormat */ |
||
435 | GL_UNSIGNED_INT, /* DataType */ |
||
436 | 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ |
||
437 | 0, 0, 0, 0, 8, /* Lum/Int/Index/Depth/StencilBits */ |
||
438 | 1, 1, 1 /* BlockWidth/Height,Bytes */ |
||
439 | }, |
||
440 | { |
||
441 | MESA_FORMAT_SRGB8, |
||
442 | "MESA_FORMAT_SRGB8", |
||
443 | GL_RGB, |
||
444 | GL_UNSIGNED_NORMALIZED, |
||
445 | 8, 8, 8, 0, |
||
446 | 0, 0, 0, 0, 0, |
||
447 | 1, 1, 3 |
||
448 | }, |
||
449 | { |
||
450 | MESA_FORMAT_SRGBA8, |
||
451 | "MESA_FORMAT_SRGBA8", |
||
452 | GL_RGBA, |
||
453 | GL_UNSIGNED_NORMALIZED, |
||
454 | 8, 8, 8, 8, |
||
455 | 0, 0, 0, 0, 0, |
||
456 | 1, 1, 4 |
||
457 | }, |
||
458 | { |
||
459 | MESA_FORMAT_SARGB8, |
||
460 | "MESA_FORMAT_SARGB8", |
||
461 | GL_RGBA, |
||
462 | GL_UNSIGNED_NORMALIZED, |
||
463 | 8, 8, 8, 8, |
||
464 | 0, 0, 0, 0, 0, |
||
465 | 1, 1, 4 |
||
466 | }, |
||
467 | { |
||
468 | MESA_FORMAT_SL8, |
||
469 | "MESA_FORMAT_SL8", |
||
470 | GL_LUMINANCE, |
||
471 | GL_UNSIGNED_NORMALIZED, |
||
472 | 0, 0, 0, 0, |
||
473 | 8, 0, 0, 0, 0, |
||
474 | 1, 1, 1 |
||
475 | }, |
||
476 | { |
||
477 | MESA_FORMAT_SLA8, |
||
478 | "MESA_FORMAT_SLA8", |
||
479 | GL_LUMINANCE_ALPHA, |
||
480 | GL_UNSIGNED_NORMALIZED, |
||
481 | 0, 0, 0, 8, |
||
482 | 8, 0, 0, 0, 0, |
||
483 | 1, 1, 2 |
||
484 | }, |
||
485 | { |
||
486 | MESA_FORMAT_SRGB_DXT1, /* Name */ |
||
487 | "MESA_FORMAT_SRGB_DXT1", /* StrName */ |
||
488 | GL_RGB, /* BaseFormat */ |
||
489 | GL_UNSIGNED_NORMALIZED, /* DataType */ |
||
490 | 4, 4, 4, 0, /* approx Red/Green/Blue/AlphaBits */ |
||
491 | 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ |
||
492 | 4, 4, 8 /* 8 bytes per 4x4 block */ |
||
493 | }, |
||
494 | { |
||
495 | MESA_FORMAT_SRGBA_DXT1, |
||
496 | "MESA_FORMAT_SRGBA_DXT1", |
||
497 | GL_RGBA, |
||
498 | GL_UNSIGNED_NORMALIZED, |
||
499 | 4, 4, 4, 4, |
||
500 | 0, 0, 0, 0, 0, |
||
501 | 4, 4, 8 /* 8 bytes per 4x4 block */ |
||
502 | }, |
||
503 | { |
||
504 | MESA_FORMAT_SRGBA_DXT3, |
||
505 | "MESA_FORMAT_SRGBA_DXT3", |
||
506 | GL_RGBA, |
||
507 | GL_UNSIGNED_NORMALIZED, |
||
508 | 4, 4, 4, 4, |
||
509 | 0, 0, 0, 0, 0, |
||
510 | 4, 4, 16 /* 16 bytes per 4x4 block */ |
||
511 | }, |
||
512 | { |
||
513 | MESA_FORMAT_SRGBA_DXT5, |
||
514 | "MESA_FORMAT_SRGBA_DXT5", |
||
515 | GL_RGBA, |
||
516 | GL_UNSIGNED_NORMALIZED, |
||
517 | 4, 4, 4, 4, |
||
518 | 0, 0, 0, 0, 0, |
||
519 | 4, 4, 16 /* 16 bytes per 4x4 block */ |
||
520 | }, |
||
521 | |||
522 | { |
||
523 | MESA_FORMAT_RGB_FXT1, |
||
524 | "MESA_FORMAT_RGB_FXT1", |
||
525 | GL_RGB, |
||
526 | GL_UNSIGNED_NORMALIZED, |
||
527 | 4, 4, 4, 0, /* approx Red/Green/BlueBits */ |
||
528 | 0, 0, 0, 0, 0, |
||
529 | 8, 4, 16 /* 16 bytes per 8x4 block */ |
||
530 | }, |
||
531 | { |
||
532 | MESA_FORMAT_RGBA_FXT1, |
||
533 | "MESA_FORMAT_RGBA_FXT1", |
||
534 | GL_RGBA, |
||
535 | GL_UNSIGNED_NORMALIZED, |
||
536 | 4, 4, 4, 1, /* approx Red/Green/Blue/AlphaBits */ |
||
537 | 0, 0, 0, 0, 0, |
||
538 | 8, 4, 16 /* 16 bytes per 8x4 block */ |
||
539 | }, |
||
540 | |||
541 | { |
||
542 | MESA_FORMAT_RGB_DXT1, /* Name */ |
||
543 | "MESA_FORMAT_RGB_DXT1", /* StrName */ |
||
544 | GL_RGB, /* BaseFormat */ |
||
545 | GL_UNSIGNED_NORMALIZED, /* DataType */ |
||
546 | 4, 4, 4, 0, /* approx Red/Green/Blue/AlphaBits */ |
||
547 | 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ |
||
548 | 4, 4, 8 /* 8 bytes per 4x4 block */ |
||
549 | }, |
||
550 | { |
||
551 | MESA_FORMAT_RGBA_DXT1, |
||
552 | "MESA_FORMAT_RGBA_DXT1", |
||
553 | GL_RGBA, |
||
554 | GL_UNSIGNED_NORMALIZED, |
||
555 | 4, 4, 4, 4, |
||
556 | 0, 0, 0, 0, 0, |
||
557 | 4, 4, 8 /* 8 bytes per 4x4 block */ |
||
558 | }, |
||
559 | { |
||
560 | MESA_FORMAT_RGBA_DXT3, |
||
561 | "MESA_FORMAT_RGBA_DXT3", |
||
562 | GL_RGBA, |
||
563 | GL_UNSIGNED_NORMALIZED, |
||
564 | 4, 4, 4, 4, |
||
565 | 0, 0, 0, 0, 0, |
||
566 | 4, 4, 16 /* 16 bytes per 4x4 block */ |
||
567 | }, |
||
568 | { |
||
569 | MESA_FORMAT_RGBA_DXT5, |
||
570 | "MESA_FORMAT_RGBA_DXT5", |
||
571 | GL_RGBA, |
||
572 | GL_UNSIGNED_NORMALIZED, |
||
573 | 4, 4, 4, 4, |
||
574 | 0, 0, 0, 0, 0, |
||
575 | 4, 4, 16 /* 16 bytes per 4x4 block */ |
||
576 | }, |
||
577 | { |
||
578 | MESA_FORMAT_RGBA_FLOAT32, |
||
579 | "MESA_FORMAT_RGBA_FLOAT32", |
||
580 | GL_RGBA, |
||
581 | GL_FLOAT, |
||
582 | 32, 32, 32, 32, |
||
583 | 0, 0, 0, 0, 0, |
||
584 | 1, 1, 16 |
||
585 | }, |
||
586 | { |
||
587 | MESA_FORMAT_RGBA_FLOAT16, |
||
588 | "MESA_FORMAT_RGBA_FLOAT16", |
||
589 | GL_RGBA, |
||
590 | GL_FLOAT, |
||
591 | 16, 16, 16, 16, |
||
592 | 0, 0, 0, 0, 0, |
||
593 | 1, 1, 8 |
||
594 | }, |
||
595 | { |
||
596 | MESA_FORMAT_RGB_FLOAT32, |
||
597 | "MESA_FORMAT_RGB_FLOAT32", |
||
598 | GL_RGB, |
||
599 | GL_FLOAT, |
||
600 | 32, 32, 32, 0, |
||
601 | 0, 0, 0, 0, 0, |
||
602 | 1, 1, 12 |
||
603 | }, |
||
604 | { |
||
605 | MESA_FORMAT_RGB_FLOAT16, |
||
606 | "MESA_FORMAT_RGB_FLOAT16", |
||
607 | GL_RGB, |
||
608 | GL_FLOAT, |
||
609 | 16, 16, 16, 0, |
||
610 | 0, 0, 0, 0, 0, |
||
611 | 1, 1, 6 |
||
612 | }, |
||
613 | { |
||
614 | MESA_FORMAT_ALPHA_FLOAT32, |
||
615 | "MESA_FORMAT_ALPHA_FLOAT32", |
||
616 | GL_ALPHA, |
||
617 | GL_FLOAT, |
||
618 | 0, 0, 0, 32, |
||
619 | 0, 0, 0, 0, 0, |
||
620 | 1, 1, 4 |
||
621 | }, |
||
622 | { |
||
623 | MESA_FORMAT_ALPHA_FLOAT16, |
||
624 | "MESA_FORMAT_ALPHA_FLOAT16", |
||
625 | GL_ALPHA, |
||
626 | GL_FLOAT, |
||
627 | 0, 0, 0, 16, |
||
628 | 0, 0, 0, 0, 0, |
||
629 | 1, 1, 2 |
||
630 | }, |
||
631 | { |
||
632 | MESA_FORMAT_LUMINANCE_FLOAT32, |
||
633 | "MESA_FORMAT_LUMINANCE_FLOAT32", |
||
634 | GL_ALPHA, |
||
635 | GL_FLOAT, |
||
636 | 0, 0, 0, 0, |
||
637 | 32, 0, 0, 0, 0, |
||
638 | 1, 1, 4 |
||
639 | }, |
||
640 | { |
||
641 | MESA_FORMAT_LUMINANCE_FLOAT16, |
||
642 | "MESA_FORMAT_LUMINANCE_FLOAT16", |
||
643 | GL_ALPHA, |
||
644 | GL_FLOAT, |
||
645 | 0, 0, 0, 0, |
||
646 | 16, 0, 0, 0, 0, |
||
647 | 1, 1, 2 |
||
648 | }, |
||
649 | { |
||
650 | MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32, |
||
651 | "MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32", |
||
652 | GL_LUMINANCE_ALPHA, |
||
653 | GL_FLOAT, |
||
654 | 0, 0, 0, 32, |
||
655 | 32, 0, 0, 0, 0, |
||
656 | 1, 1, 8 |
||
657 | }, |
||
658 | { |
||
659 | MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16, |
||
660 | "MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16", |
||
661 | GL_LUMINANCE_ALPHA, |
||
662 | GL_FLOAT, |
||
663 | 0, 0, 0, 16, |
||
664 | 16, 0, 0, 0, 0, |
||
665 | 1, 1, 4 |
||
666 | }, |
||
667 | { |
||
668 | MESA_FORMAT_INTENSITY_FLOAT32, |
||
669 | "MESA_FORMAT_INTENSITY_FLOAT32", |
||
670 | GL_INTENSITY, |
||
671 | GL_FLOAT, |
||
672 | 0, 0, 0, 0, |
||
673 | 0, 32, 0, 0, 0, |
||
674 | 1, 1, 4 |
||
675 | }, |
||
676 | { |
||
677 | MESA_FORMAT_INTENSITY_FLOAT16, |
||
678 | "MESA_FORMAT_INTENSITY_FLOAT16", |
||
679 | GL_INTENSITY, |
||
680 | GL_FLOAT, |
||
681 | 0, 0, 0, 0, |
||
682 | 0, 16, 0, 0, 0, |
||
683 | 1, 1, 2 |
||
684 | }, |
||
685 | |||
686 | /* unnormalized signed int formats */ |
||
687 | { |
||
688 | MESA_FORMAT_RGBA_INT8, |
||
689 | "MESA_FORMAT_RGBA_INT8", |
||
690 | GL_RGBA, |
||
691 | GL_INT, |
||
692 | 8, 8, 8, 8, |
||
693 | 0, 0, 0, 0, 0, |
||
694 | 1, 1, 4 |
||
695 | }, |
||
696 | { |
||
697 | MESA_FORMAT_RGBA_INT16, |
||
698 | "MESA_FORMAT_RGBA_INT16", |
||
699 | GL_RGBA, |
||
700 | GL_INT, |
||
701 | 16, 16, 16, 16, |
||
702 | 0, 0, 0, 0, 0, |
||
703 | 1, 1, 8 |
||
704 | }, |
||
705 | { |
||
706 | MESA_FORMAT_RGBA_INT32, |
||
707 | "MESA_FORMAT_RGBA_INT32", |
||
708 | GL_RGBA, |
||
709 | GL_INT, |
||
710 | 32, 32, 32, 32, |
||
711 | 0, 0, 0, 0, 0, |
||
712 | 1, 1, 16 |
||
713 | }, |
||
714 | |||
715 | /* unnormalized unsigned int formats */ |
||
716 | { |
||
717 | MESA_FORMAT_RGBA_UINT8, |
||
718 | "MESA_FORMAT_RGBA_UINT8", |
||
719 | GL_RGBA, |
||
720 | GL_UNSIGNED_INT, |
||
721 | 8, 8, 8, 8, |
||
722 | 0, 0, 0, 0, 0, |
||
723 | 1, 1, 4 |
||
724 | }, |
||
725 | { |
||
726 | MESA_FORMAT_RGBA_UINT16, |
||
727 | "MESA_FORMAT_RGBA_UINT16", |
||
728 | GL_RGBA, |
||
729 | GL_UNSIGNED_INT, |
||
730 | 16, 16, 16, 16, |
||
731 | 0, 0, 0, 0, 0, |
||
732 | 1, 1, 8 |
||
733 | }, |
||
734 | { |
||
735 | MESA_FORMAT_RGBA_UINT32, |
||
736 | "MESA_FORMAT_RGBA_UINT32", |
||
737 | GL_RGBA, |
||
738 | GL_UNSIGNED_INT, |
||
739 | 32, 32, 32, 32, |
||
740 | 0, 0, 0, 0, 0, |
||
741 | 1, 1, 16 |
||
742 | }, |
||
743 | |||
744 | |||
745 | { |
||
746 | MESA_FORMAT_DUDV8, |
||
747 | "MESA_FORMAT_DUDV8", |
||
748 | GL_DUDV_ATI, |
||
749 | GL_SIGNED_NORMALIZED, |
||
750 | 0, 0, 0, 0, |
||
751 | 0, 0, 0, 0, 0, |
||
752 | 1, 1, 2 |
||
753 | }, |
||
754 | |||
755 | /* Signed 8 bits / channel */ |
||
756 | { |
||
757 | MESA_FORMAT_SIGNED_R8, /* Name */ |
||
758 | "MESA_FORMAT_SIGNED_R8", /* StrName */ |
||
759 | GL_RED, /* BaseFormat */ |
||
760 | GL_SIGNED_NORMALIZED, /* DataType */ |
||
761 | 8, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ |
||
762 | 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ |
||
763 | 1, 1, 1 /* BlockWidth/Height,Bytes */ |
||
764 | }, |
||
765 | { |
||
766 | MESA_FORMAT_SIGNED_RG88, |
||
767 | "MESA_FORMAT_SIGNED_RG88", |
||
768 | GL_RG, |
||
769 | GL_SIGNED_NORMALIZED, |
||
770 | 8, 8, 0, 0, |
||
771 | 0, 0, 0, 0, 0, |
||
772 | 1, 1, 2 |
||
773 | }, |
||
774 | { |
||
775 | MESA_FORMAT_SIGNED_RGBX8888, |
||
776 | "MESA_FORMAT_SIGNED_RGBX8888", |
||
777 | GL_RGB, |
||
778 | GL_SIGNED_NORMALIZED, |
||
779 | 8, 8, 8, 0, |
||
780 | 0, 0, 0, 0, 0, |
||
781 | 1, 1, 4 /* 4 bpp, but no alpha */ |
||
782 | }, |
||
783 | { |
||
784 | MESA_FORMAT_SIGNED_RGBA8888, |
||
785 | "MESA_FORMAT_SIGNED_RGBA8888", |
||
786 | GL_RGBA, |
||
787 | GL_SIGNED_NORMALIZED, |
||
788 | 8, 8, 8, 8, |
||
789 | 0, 0, 0, 0, 0, |
||
790 | 1, 1, 4 |
||
791 | }, |
||
792 | { |
||
793 | MESA_FORMAT_SIGNED_RGBA8888_REV, |
||
794 | "MESA_FORMAT_SIGNED_RGBA8888_REV", |
||
795 | GL_RGBA, |
||
796 | GL_SIGNED_NORMALIZED, |
||
797 | 8, 8, 8, 8, |
||
798 | 0, 0, 0, 0, 0, |
||
799 | 1, 1, 4 |
||
800 | }, |
||
801 | |||
802 | /* Signed 16 bits / channel */ |
||
803 | { |
||
804 | MESA_FORMAT_SIGNED_R_16, |
||
805 | "MESA_FORMAT_SIGNED_R_16", |
||
806 | GL_RED, |
||
807 | GL_SIGNED_NORMALIZED, |
||
808 | 16, 0, 0, 0, |
||
809 | 0, 0, 0, 0, 0, |
||
810 | 1, 1, 2 |
||
811 | }, |
||
812 | { |
||
813 | MESA_FORMAT_SIGNED_RG_16, |
||
814 | "MESA_FORMAT_SIGNED_RG_16", |
||
815 | GL_RG, |
||
816 | GL_SIGNED_NORMALIZED, |
||
817 | 16, 16, 0, 0, |
||
818 | 0, 0, 0, 0, 0, |
||
819 | 1, 1, 4 |
||
820 | }, |
||
821 | { |
||
822 | MESA_FORMAT_SIGNED_RGB_16, |
||
823 | "MESA_FORMAT_SIGNED_RGB_16", |
||
824 | GL_RGB, |
||
825 | GL_SIGNED_NORMALIZED, |
||
826 | 16, 16, 16, 0, |
||
827 | 0, 0, 0, 0, 0, |
||
828 | 1, 1, 6 |
||
829 | }, |
||
830 | { |
||
831 | MESA_FORMAT_SIGNED_RGBA_16, |
||
832 | "MESA_FORMAT_SIGNED_RGBA_16", |
||
833 | GL_RGBA, |
||
834 | GL_SIGNED_NORMALIZED, |
||
835 | 16, 16, 16, 16, |
||
836 | 0, 0, 0, 0, 0, |
||
837 | 1, 1, 8 |
||
838 | }, |
||
839 | { |
||
840 | MESA_FORMAT_RGBA_16, |
||
841 | "MESA_FORMAT_RGBA_16", |
||
842 | GL_RGBA, |
||
843 | GL_UNSIGNED_NORMALIZED, |
||
844 | 16, 16, 16, 16, |
||
845 | 0, 0, 0, 0, 0, |
||
846 | 1, 1, 8 |
||
847 | } |
||
848 | }; |
||
849 | |||
850 | |||
851 | |||
852 | static const struct gl_format_info * |
||
853 | _mesa_get_format_info(gl_format format) |
||
854 | { |
||
855 | const struct gl_format_info *info = &format_info[format]; |
||
856 | assert(info->Name == format); |
||
857 | return info; |
||
858 | } |
||
859 | |||
860 | |||
861 | /** Return string name of format (for debugging) */ |
||
862 | const char * |
||
863 | _mesa_get_format_name(gl_format format) |
||
864 | { |
||
865 | const struct gl_format_info *info = _mesa_get_format_info(format); |
||
866 | ASSERT(info->BytesPerBlock); |
||
867 | return info->StrName; |
||
868 | } |
||
869 | |||
870 | |||
871 | |||
872 | /** |
||
873 | * Return bytes needed to store a block of pixels in the given format. |
||
874 | * Normally, a block is 1x1 (a single pixel). But for compressed formats |
||
875 | * a block may be 4x4 or 8x4, etc. |
||
876 | */ |
||
877 | GLuint |
||
878 | _mesa_get_format_bytes(gl_format format) |
||
879 | { |
||
880 | const struct gl_format_info *info = _mesa_get_format_info(format); |
||
881 | ASSERT(info->BytesPerBlock); |
||
882 | return info->BytesPerBlock; |
||
883 | } |
||
884 | |||
885 | |||
886 | /** |
||
887 | * Return bits per component for the given format. |
||
888 | * \param format one of MESA_FORMAT_x |
||
889 | * \param pname the component, such as GL_RED_BITS, GL_TEXTURE_BLUE_BITS, etc. |
||
890 | */ |
||
891 | GLint |
||
892 | _mesa_get_format_bits(gl_format format, GLenum pname) |
||
893 | { |
||
894 | const struct gl_format_info *info = _mesa_get_format_info(format); |
||
895 | |||
896 | switch (pname) { |
||
897 | case GL_RED_BITS: |
||
898 | case GL_TEXTURE_RED_SIZE: |
||
899 | case GL_RENDERBUFFER_RED_SIZE_EXT: |
||
900 | case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE: |
||
901 | return info->RedBits; |
||
902 | case GL_GREEN_BITS: |
||
903 | case GL_TEXTURE_GREEN_SIZE: |
||
904 | case GL_RENDERBUFFER_GREEN_SIZE_EXT: |
||
905 | case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: |
||
906 | return info->GreenBits; |
||
907 | case GL_BLUE_BITS: |
||
908 | case GL_TEXTURE_BLUE_SIZE: |
||
909 | case GL_RENDERBUFFER_BLUE_SIZE_EXT: |
||
910 | case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: |
||
911 | return info->BlueBits; |
||
912 | case GL_ALPHA_BITS: |
||
913 | case GL_TEXTURE_ALPHA_SIZE: |
||
914 | case GL_RENDERBUFFER_ALPHA_SIZE_EXT: |
||
915 | case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: |
||
916 | return info->AlphaBits; |
||
917 | case GL_TEXTURE_INTENSITY_SIZE: |
||
918 | return info->IntensityBits; |
||
919 | case GL_TEXTURE_LUMINANCE_SIZE: |
||
920 | return info->LuminanceBits; |
||
921 | case GL_INDEX_BITS: |
||
922 | case GL_TEXTURE_INDEX_SIZE_EXT: |
||
923 | return info->IndexBits; |
||
924 | case GL_DEPTH_BITS: |
||
925 | case GL_TEXTURE_DEPTH_SIZE_ARB: |
||
926 | case GL_RENDERBUFFER_DEPTH_SIZE_EXT: |
||
927 | case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: |
||
928 | return info->DepthBits; |
||
929 | case GL_STENCIL_BITS: |
||
930 | case GL_TEXTURE_STENCIL_SIZE_EXT: |
||
931 | case GL_RENDERBUFFER_STENCIL_SIZE_EXT: |
||
932 | case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: |
||
933 | return info->StencilBits; |
||
934 | default: |
||
935 | _mesa_problem(NULL, "bad pname in _mesa_get_format_bits()"); |
||
936 | return 0; |
||
937 | } |
||
938 | } |
||
939 | |||
940 | |||
941 | /** |
||
942 | * Return the data type (or more specifically, the data representation) |
||
943 | * for the given format. |
||
944 | * The return value will be one of: |
||
945 | * GL_UNSIGNED_NORMALIZED = unsigned int representing [0,1] |
||
946 | * GL_SIGNED_NORMALIZED = signed int representing [-1, 1] |
||
947 | * GL_UNSIGNED_INT = an ordinary unsigned integer |
||
948 | * GL_INT = an ordinary signed integer |
||
949 | * GL_FLOAT = an ordinary float |
||
950 | */ |
||
951 | GLenum |
||
952 | _mesa_get_format_datatype(gl_format format) |
||
953 | { |
||
954 | const struct gl_format_info *info = _mesa_get_format_info(format); |
||
955 | return info->DataType; |
||
956 | } |
||
957 | |||
958 | |||
959 | /** |
||
960 | * Return the basic format for the given type. The result will be |
||
961 | * one of GL_RGB, GL_RGBA, GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA, |
||
962 | * GL_INTENSITY, GL_YCBCR_MESA, GL_COLOR_INDEX, GL_DEPTH_COMPONENT, |
||
963 | * GL_STENCIL_INDEX, GL_DEPTH_STENCIL. |
||
964 | */ |
||
965 | GLenum |
||
966 | _mesa_get_format_base_format(gl_format format) |
||
967 | { |
||
968 | const struct gl_format_info *info = _mesa_get_format_info(format); |
||
969 | return info->BaseFormat; |
||
970 | } |
||
971 | |||
972 | |||
973 | /** |
||
974 | * Return the block size (in pixels) for the given format. Normally |
||
975 | * the block size is 1x1. But compressed formats will have block sizes |
||
976 | * of 4x4 or 8x4 pixels, etc. |
||
977 | * \param bw returns block width in pixels |
||
978 | * \param bh returns block height in pixels |
||
979 | */ |
||
980 | void |
||
981 | _mesa_get_format_block_size(gl_format format, GLuint *bw, GLuint *bh) |
||
982 | { |
||
983 | const struct gl_format_info *info = _mesa_get_format_info(format); |
||
984 | *bw = info->BlockWidth; |
||
985 | *bh = info->BlockHeight; |
||
986 | } |
||
987 | |||
988 | |||
989 | /** Is the given format a compressed format? */ |
||
990 | GLboolean |
||
991 | _mesa_is_format_compressed(gl_format format) |
||
992 | { |
||
993 | const struct gl_format_info *info = _mesa_get_format_info(format); |
||
994 | return info->BlockWidth > 1 || info->BlockHeight > 1; |
||
995 | } |
||
996 | |||
997 | |||
998 | /** |
||
999 | * Determine if the given format represents a packed depth/stencil buffer. |
||
1000 | */ |
||
1001 | GLboolean |
||
1002 | _mesa_is_format_packed_depth_stencil(gl_format format) |
||
1003 | { |
||
1004 | const struct gl_format_info *info = _mesa_get_format_info(format); |
||
1005 | |||
1006 | return info->BaseFormat == GL_DEPTH_STENCIL; |
||
1007 | } |
||
1008 | |||
1009 | |||
1010 | /** |
||
1011 | * Is the given format a signed/unsigned integer color format? |
||
1012 | */ |
||
1013 | GLboolean |
||
1014 | _mesa_is_format_integer_color(gl_format format) |
||
1015 | { |
||
1016 | const struct gl_format_info *info = _mesa_get_format_info(format); |
||
1017 | return (info->DataType == GL_INT || info->DataType == GL_UNSIGNED_INT) && |
||
1018 | info->BaseFormat != GL_DEPTH_COMPONENT && |
||
1019 | info->BaseFormat != GL_DEPTH_STENCIL && |
||
1020 | info->BaseFormat != GL_STENCIL_INDEX; |
||
1021 | } |
||
1022 | |||
1023 | |||
1024 | /** |
||
1025 | * Return color encoding for given format. |
||
1026 | * \return GL_LINEAR or GL_SRGB |
||
1027 | */ |
||
1028 | GLenum |
||
1029 | _mesa_get_format_color_encoding(gl_format format) |
||
1030 | { |
||
1031 | /* XXX this info should be encoded in gl_format_info */ |
||
1032 | switch (format) { |
||
1033 | case MESA_FORMAT_SRGB8: |
||
1034 | case MESA_FORMAT_SRGBA8: |
||
1035 | case MESA_FORMAT_SARGB8: |
||
1036 | case MESA_FORMAT_SL8: |
||
1037 | case MESA_FORMAT_SLA8: |
||
1038 | case MESA_FORMAT_SRGB_DXT1: |
||
1039 | case MESA_FORMAT_SRGBA_DXT1: |
||
1040 | case MESA_FORMAT_SRGBA_DXT3: |
||
1041 | case MESA_FORMAT_SRGBA_DXT5: |
||
1042 | return GL_SRGB; |
||
1043 | default: |
||
1044 | return GL_LINEAR; |
||
1045 | } |
||
1046 | } |
||
1047 | |||
1048 | |||
1049 | /** |
||
1050 | * Return number of bytes needed to store an image of the given size |
||
1051 | * in the given format. |
||
1052 | */ |
||
1053 | GLuint |
||
1054 | _mesa_format_image_size(gl_format format, GLsizei width, |
||
1055 | GLsizei height, GLsizei depth) |
||
1056 | { |
||
1057 | const struct gl_format_info *info = _mesa_get_format_info(format); |
||
1058 | /* Strictly speaking, a conditional isn't needed here */ |
||
1059 | if (info->BlockWidth > 1 || info->BlockHeight > 1) { |
||
1060 | /* compressed format (2D only for now) */ |
||
1061 | const GLuint bw = info->BlockWidth, bh = info->BlockHeight; |
||
1062 | const GLuint wblocks = (width + bw - 1) / bw; |
||
1063 | const GLuint hblocks = (height + bh - 1) / bh; |
||
1064 | const GLuint sz = wblocks * hblocks * info->BytesPerBlock; |
||
1065 | assert(depth == 1); |
||
1066 | return sz; |
||
1067 | } |
||
1068 | else { |
||
1069 | /* non-compressed */ |
||
1070 | const GLuint sz = width * height * depth * info->BytesPerBlock; |
||
1071 | return sz; |
||
1072 | } |
||
1073 | } |
||
1074 | |||
1075 | |||
1076 | /** |
||
1077 | * Same as _mesa_format_image_size() but returns a 64-bit value to |
||
1078 | * accomodate very large textures. |
||
1079 | */ |
||
1080 | uint64_t |
||
1081 | _mesa_format_image_size64(gl_format format, GLsizei width, |
||
1082 | GLsizei height, GLsizei depth) |
||
1083 | { |
||
1084 | const struct gl_format_info *info = _mesa_get_format_info(format); |
||
1085 | /* Strictly speaking, a conditional isn't needed here */ |
||
1086 | if (info->BlockWidth > 1 || info->BlockHeight > 1) { |
||
1087 | /* compressed format (2D only for now) */ |
||
1088 | const uint64_t bw = info->BlockWidth, bh = info->BlockHeight; |
||
1089 | const uint64_t wblocks = (width + bw - 1) / bw; |
||
1090 | const uint64_t hblocks = (height + bh - 1) / bh; |
||
1091 | const uint64_t sz = wblocks * hblocks * info->BytesPerBlock; |
||
1092 | assert(depth == 1); |
||
1093 | return sz; |
||
1094 | } |
||
1095 | else { |
||
1096 | /* non-compressed */ |
||
1097 | const uint64_t sz = ((uint64_t) width * |
||
1098 | (uint64_t) height * |
||
1099 | (uint64_t) depth * |
||
1100 | info->BytesPerBlock); |
||
1101 | return sz; |
||
1102 | } |
||
1103 | } |
||
1104 | |||
1105 | |||
1106 | |||
1107 | GLint |
||
1108 | _mesa_format_row_stride(gl_format format, GLsizei width) |
||
1109 | { |
||
1110 | const struct gl_format_info *info = _mesa_get_format_info(format); |
||
1111 | /* Strictly speaking, a conditional isn't needed here */ |
||
1112 | if (info->BlockWidth > 1 || info->BlockHeight > 1) { |
||
1113 | /* compressed format */ |
||
1114 | const GLuint bw = info->BlockWidth; |
||
1115 | const GLuint wblocks = (width + bw - 1) / bw; |
||
1116 | const GLint stride = wblocks * info->BytesPerBlock; |
||
1117 | return stride; |
||
1118 | } |
||
1119 | else { |
||
1120 | const GLint stride = width * info->BytesPerBlock; |
||
1121 | return stride; |
||
1122 | } |
||
1123 | } |
||
1124 | |||
1125 | |||
1126 | |||
1127 | /** |
||
1128 | * Do sanity checking of the format info table. |
||
1129 | */ |
||
1130 | void |
||
1131 | _mesa_test_formats(void) |
||
1132 | { |
||
1133 | GLuint i; |
||
1134 | |||
1135 | assert(Elements(format_info) == MESA_FORMAT_COUNT); |
||
1136 | |||
1137 | for (i = 0; i < MESA_FORMAT_COUNT; i++) { |
||
1138 | const struct gl_format_info *info = _mesa_get_format_info(i); |
||
1139 | assert(info); |
||
1140 | |||
1141 | assert(info->Name == i); |
||
1142 | |||
1143 | if (info->Name == MESA_FORMAT_NONE) |
||
1144 | continue; |
||
1145 | |||
1146 | if (info->BlockWidth == 1 && info->BlockHeight == 1) { |
||
1147 | if (info->RedBits > 0) { |
||
1148 | GLuint t = info->RedBits + info->GreenBits |
||
1149 | + info->BlueBits + info->AlphaBits; |
||
1150 | assert(t / 8 <= info->BytesPerBlock); |
||
1151 | (void) t; |
||
1152 | } |
||
1153 | } |
||
1154 | |||
1155 | assert(info->DataType == GL_UNSIGNED_NORMALIZED || |
||
1156 | info->DataType == GL_SIGNED_NORMALIZED || |
||
1157 | info->DataType == GL_UNSIGNED_INT || |
||
1158 | info->DataType == GL_INT || |
||
1159 | info->DataType == GL_FLOAT); |
||
1160 | |||
1161 | if (info->BaseFormat == GL_RGB) { |
||
1162 | assert(info->RedBits > 0); |
||
1163 | assert(info->GreenBits > 0); |
||
1164 | assert(info->BlueBits > 0); |
||
1165 | assert(info->AlphaBits == 0); |
||
1166 | assert(info->LuminanceBits == 0); |
||
1167 | assert(info->IntensityBits == 0); |
||
1168 | } |
||
1169 | else if (info->BaseFormat == GL_RGBA) { |
||
1170 | assert(info->RedBits > 0); |
||
1171 | assert(info->GreenBits > 0); |
||
1172 | assert(info->BlueBits > 0); |
||
1173 | assert(info->AlphaBits > 0); |
||
1174 | assert(info->LuminanceBits == 0); |
||
1175 | assert(info->IntensityBits == 0); |
||
1176 | } |
||
1177 | else if (info->BaseFormat == GL_RG) { |
||
1178 | assert(info->RedBits > 0); |
||
1179 | assert(info->GreenBits > 0); |
||
1180 | assert(info->BlueBits == 0); |
||
1181 | assert(info->AlphaBits == 0); |
||
1182 | assert(info->LuminanceBits == 0); |
||
1183 | assert(info->IntensityBits == 0); |
||
1184 | } |
||
1185 | else if (info->BaseFormat == GL_RED) { |
||
1186 | assert(info->RedBits > 0); |
||
1187 | assert(info->GreenBits == 0); |
||
1188 | assert(info->BlueBits == 0); |
||
1189 | assert(info->AlphaBits == 0); |
||
1190 | assert(info->LuminanceBits == 0); |
||
1191 | assert(info->IntensityBits == 0); |
||
1192 | } |
||
1193 | else if (info->BaseFormat == GL_LUMINANCE) { |
||
1194 | assert(info->RedBits == 0); |
||
1195 | assert(info->GreenBits == 0); |
||
1196 | assert(info->BlueBits == 0); |
||
1197 | assert(info->AlphaBits == 0); |
||
1198 | assert(info->LuminanceBits > 0); |
||
1199 | assert(info->IntensityBits == 0); |
||
1200 | } |
||
1201 | else if (info->BaseFormat == GL_INTENSITY) { |
||
1202 | assert(info->RedBits == 0); |
||
1203 | assert(info->GreenBits == 0); |
||
1204 | assert(info->BlueBits == 0); |
||
1205 | assert(info->AlphaBits == 0); |
||
1206 | assert(info->LuminanceBits == 0); |
||
1207 | assert(info->IntensityBits > 0); |
||
1208 | } |
||
1209 | |||
1210 | } |
||
1211 | } |
||
1212 | |||
1213 | |||
1214 | |||
1215 | /** |
||
1216 | * Return datatype and number of components per texel for the given gl_format. |
||
1217 | * Only used for mipmap generation code. |
||
1218 | */ |
||
1219 | void |
||
1220 | _mesa_format_to_type_and_comps(gl_format format, |
||
1221 | GLenum *datatype, GLuint *comps) |
||
1222 | { |
||
1223 | switch (format) { |
||
1224 | case MESA_FORMAT_RGBA8888: |
||
1225 | case MESA_FORMAT_RGBA8888_REV: |
||
1226 | case MESA_FORMAT_ARGB8888: |
||
1227 | case MESA_FORMAT_ARGB8888_REV: |
||
1228 | case MESA_FORMAT_XRGB8888: |
||
1229 | case MESA_FORMAT_XRGB8888_REV: |
||
1230 | *datatype = GL_UNSIGNED_BYTE; |
||
1231 | *comps = 4; |
||
1232 | return; |
||
1233 | case MESA_FORMAT_RGB888: |
||
1234 | case MESA_FORMAT_BGR888: |
||
1235 | *datatype = GL_UNSIGNED_BYTE; |
||
1236 | *comps = 3; |
||
1237 | return; |
||
1238 | case MESA_FORMAT_RGB565: |
||
1239 | case MESA_FORMAT_RGB565_REV: |
||
1240 | *datatype = GL_UNSIGNED_SHORT_5_6_5; |
||
1241 | *comps = 3; |
||
1242 | return; |
||
1243 | |||
1244 | case MESA_FORMAT_ARGB4444: |
||
1245 | case MESA_FORMAT_ARGB4444_REV: |
||
1246 | *datatype = GL_UNSIGNED_SHORT_4_4_4_4; |
||
1247 | *comps = 4; |
||
1248 | return; |
||
1249 | |||
1250 | case MESA_FORMAT_ARGB1555: |
||
1251 | case MESA_FORMAT_ARGB1555_REV: |
||
1252 | *datatype = GL_UNSIGNED_SHORT_1_5_5_5_REV; |
||
1253 | *comps = 4; |
||
1254 | return; |
||
1255 | |||
1256 | case MESA_FORMAT_RGBA5551: |
||
1257 | *datatype = GL_UNSIGNED_SHORT_5_5_5_1; |
||
1258 | *comps = 4; |
||
1259 | return; |
||
1260 | |||
1261 | case MESA_FORMAT_AL88: |
||
1262 | case MESA_FORMAT_AL88_REV: |
||
1263 | case MESA_FORMAT_RG88: |
||
1264 | case MESA_FORMAT_RG88_REV: |
||
1265 | *datatype = GL_UNSIGNED_BYTE; |
||
1266 | *comps = 2; |
||
1267 | return; |
||
1268 | |||
1269 | case MESA_FORMAT_AL1616: |
||
1270 | case MESA_FORMAT_AL1616_REV: |
||
1271 | case MESA_FORMAT_RG1616: |
||
1272 | case MESA_FORMAT_RG1616_REV: |
||
1273 | *datatype = GL_UNSIGNED_SHORT; |
||
1274 | *comps = 2; |
||
1275 | return; |
||
1276 | |||
1277 | case MESA_FORMAT_R16: |
||
1278 | *datatype = GL_UNSIGNED_SHORT; |
||
1279 | *comps = 1; |
||
1280 | return; |
||
1281 | |||
1282 | case MESA_FORMAT_RGB332: |
||
1283 | *datatype = GL_UNSIGNED_BYTE_3_3_2; |
||
1284 | *comps = 3; |
||
1285 | return; |
||
1286 | |||
1287 | case MESA_FORMAT_A8: |
||
1288 | case MESA_FORMAT_L8: |
||
1289 | case MESA_FORMAT_I8: |
||
1290 | case MESA_FORMAT_CI8: |
||
1291 | case MESA_FORMAT_R8: |
||
1292 | case MESA_FORMAT_S8: |
||
1293 | *datatype = GL_UNSIGNED_BYTE; |
||
1294 | *comps = 1; |
||
1295 | return; |
||
1296 | |||
1297 | case MESA_FORMAT_YCBCR: |
||
1298 | case MESA_FORMAT_YCBCR_REV: |
||
1299 | *datatype = GL_UNSIGNED_SHORT; |
||
1300 | *comps = 2; |
||
1301 | return; |
||
1302 | |||
1303 | case MESA_FORMAT_Z24_S8: |
||
1304 | *datatype = GL_UNSIGNED_INT; |
||
1305 | *comps = 1; /* XXX OK? */ |
||
1306 | return; |
||
1307 | |||
1308 | case MESA_FORMAT_S8_Z24: |
||
1309 | *datatype = GL_UNSIGNED_INT; |
||
1310 | *comps = 1; /* XXX OK? */ |
||
1311 | return; |
||
1312 | |||
1313 | case MESA_FORMAT_Z16: |
||
1314 | *datatype = GL_UNSIGNED_SHORT; |
||
1315 | *comps = 1; |
||
1316 | return; |
||
1317 | |||
1318 | case MESA_FORMAT_X8_Z24: |
||
1319 | *datatype = GL_UNSIGNED_INT; |
||
1320 | *comps = 1; |
||
1321 | return; |
||
1322 | |||
1323 | case MESA_FORMAT_Z24_X8: |
||
1324 | *datatype = GL_UNSIGNED_INT; |
||
1325 | *comps = 1; |
||
1326 | return; |
||
1327 | |||
1328 | case MESA_FORMAT_Z32: |
||
1329 | *datatype = GL_UNSIGNED_INT; |
||
1330 | *comps = 1; |
||
1331 | return; |
||
1332 | |||
1333 | case MESA_FORMAT_DUDV8: |
||
1334 | *datatype = GL_BYTE; |
||
1335 | *comps = 2; |
||
1336 | return; |
||
1337 | |||
1338 | case MESA_FORMAT_SIGNED_R8: |
||
1339 | *datatype = GL_BYTE; |
||
1340 | *comps = 1; |
||
1341 | return; |
||
1342 | case MESA_FORMAT_SIGNED_RG88: |
||
1343 | *datatype = GL_BYTE; |
||
1344 | *comps = 2; |
||
1345 | return; |
||
1346 | case MESA_FORMAT_SIGNED_RGBA8888: |
||
1347 | case MESA_FORMAT_SIGNED_RGBA8888_REV: |
||
1348 | case MESA_FORMAT_SIGNED_RGBX8888: |
||
1349 | *datatype = GL_BYTE; |
||
1350 | *comps = 4; |
||
1351 | return; |
||
1352 | |||
1353 | case MESA_FORMAT_RGBA_16: |
||
1354 | *datatype = GL_UNSIGNED_SHORT; |
||
1355 | *comps = 4; |
||
1356 | return; |
||
1357 | |||
1358 | case MESA_FORMAT_SIGNED_R_16: |
||
1359 | *datatype = GL_SHORT; |
||
1360 | *comps = 1; |
||
1361 | return; |
||
1362 | case MESA_FORMAT_SIGNED_RG_16: |
||
1363 | *datatype = GL_SHORT; |
||
1364 | *comps = 2; |
||
1365 | return; |
||
1366 | case MESA_FORMAT_SIGNED_RGB_16: |
||
1367 | *datatype = GL_SHORT; |
||
1368 | *comps = 3; |
||
1369 | return; |
||
1370 | case MESA_FORMAT_SIGNED_RGBA_16: |
||
1371 | *datatype = GL_SHORT; |
||
1372 | *comps = 4; |
||
1373 | return; |
||
1374 | |||
1375 | #if FEATURE_EXT_texture_sRGB |
||
1376 | case MESA_FORMAT_SRGB8: |
||
1377 | *datatype = GL_UNSIGNED_BYTE; |
||
1378 | *comps = 3; |
||
1379 | return; |
||
1380 | case MESA_FORMAT_SRGBA8: |
||
1381 | case MESA_FORMAT_SARGB8: |
||
1382 | *datatype = GL_UNSIGNED_BYTE; |
||
1383 | *comps = 4; |
||
1384 | return; |
||
1385 | case MESA_FORMAT_SL8: |
||
1386 | *datatype = GL_UNSIGNED_BYTE; |
||
1387 | *comps = 1; |
||
1388 | return; |
||
1389 | case MESA_FORMAT_SLA8: |
||
1390 | *datatype = GL_UNSIGNED_BYTE; |
||
1391 | *comps = 2; |
||
1392 | return; |
||
1393 | #endif |
||
1394 | |||
1395 | #if FEATURE_texture_fxt1 |
||
1396 | case MESA_FORMAT_RGB_FXT1: |
||
1397 | case MESA_FORMAT_RGBA_FXT1: |
||
1398 | #endif |
||
1399 | #if FEATURE_texture_s3tc |
||
1400 | case MESA_FORMAT_RGB_DXT1: |
||
1401 | case MESA_FORMAT_RGBA_DXT1: |
||
1402 | case MESA_FORMAT_RGBA_DXT3: |
||
1403 | case MESA_FORMAT_RGBA_DXT5: |
||
1404 | #if FEATURE_EXT_texture_sRGB |
||
1405 | case MESA_FORMAT_SRGB_DXT1: |
||
1406 | case MESA_FORMAT_SRGBA_DXT1: |
||
1407 | case MESA_FORMAT_SRGBA_DXT3: |
||
1408 | case MESA_FORMAT_SRGBA_DXT5: |
||
1409 | #endif |
||
1410 | #endif |
||
1411 | /* XXX generate error instead? */ |
||
1412 | *datatype = GL_UNSIGNED_BYTE; |
||
1413 | *comps = 0; |
||
1414 | return; |
||
1415 | |||
1416 | case MESA_FORMAT_RGBA_FLOAT32: |
||
1417 | *datatype = GL_FLOAT; |
||
1418 | *comps = 4; |
||
1419 | return; |
||
1420 | case MESA_FORMAT_RGBA_FLOAT16: |
||
1421 | *datatype = GL_HALF_FLOAT_ARB; |
||
1422 | *comps = 4; |
||
1423 | return; |
||
1424 | case MESA_FORMAT_RGB_FLOAT32: |
||
1425 | *datatype = GL_FLOAT; |
||
1426 | *comps = 3; |
||
1427 | return; |
||
1428 | case MESA_FORMAT_RGB_FLOAT16: |
||
1429 | *datatype = GL_HALF_FLOAT_ARB; |
||
1430 | *comps = 3; |
||
1431 | return; |
||
1432 | case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32: |
||
1433 | *datatype = GL_FLOAT; |
||
1434 | *comps = 2; |
||
1435 | return; |
||
1436 | case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16: |
||
1437 | *datatype = GL_HALF_FLOAT_ARB; |
||
1438 | *comps = 2; |
||
1439 | return; |
||
1440 | case MESA_FORMAT_ALPHA_FLOAT32: |
||
1441 | case MESA_FORMAT_LUMINANCE_FLOAT32: |
||
1442 | case MESA_FORMAT_INTENSITY_FLOAT32: |
||
1443 | *datatype = GL_FLOAT; |
||
1444 | *comps = 1; |
||
1445 | return; |
||
1446 | case MESA_FORMAT_ALPHA_FLOAT16: |
||
1447 | case MESA_FORMAT_LUMINANCE_FLOAT16: |
||
1448 | case MESA_FORMAT_INTENSITY_FLOAT16: |
||
1449 | *datatype = GL_HALF_FLOAT_ARB; |
||
1450 | *comps = 1; |
||
1451 | return; |
||
1452 | |||
1453 | case MESA_FORMAT_RGBA_INT8: |
||
1454 | *datatype = GL_BYTE; |
||
1455 | *comps = 4; |
||
1456 | return; |
||
1457 | case MESA_FORMAT_RGBA_INT16: |
||
1458 | *datatype = GL_SHORT; |
||
1459 | *comps = 4; |
||
1460 | return; |
||
1461 | case MESA_FORMAT_RGBA_INT32: |
||
1462 | *datatype = GL_INT; |
||
1463 | *comps = 4; |
||
1464 | return; |
||
1465 | |||
1466 | /** |
||
1467 | * \name Non-normalized unsigned integer formats. |
||
1468 | */ |
||
1469 | case MESA_FORMAT_RGBA_UINT8: |
||
1470 | *datatype = GL_UNSIGNED_BYTE; |
||
1471 | *comps = 4; |
||
1472 | return; |
||
1473 | case MESA_FORMAT_RGBA_UINT16: |
||
1474 | *datatype = GL_UNSIGNED_SHORT; |
||
1475 | *comps = 4; |
||
1476 | return; |
||
1477 | case MESA_FORMAT_RGBA_UINT32: |
||
1478 | *datatype = GL_UNSIGNED_INT; |
||
1479 | *comps = 4; |
||
1480 | return; |
||
1481 | |||
1482 | case MESA_FORMAT_NONE: |
||
1483 | case MESA_FORMAT_COUNT: |
||
1484 | /* For debug builds, warn if any formats are not handled */ |
||
1485 | #ifndef DEBUG |
||
1486 | default: |
||
1487 | #endif |
||
1488 | _mesa_problem(NULL, "bad format %s in _mesa_format_to_type_and_comps", |
||
1489 | _mesa_get_format_name(format)); |
||
1490 | *datatype = 0; |
||
1491 | *comps = 1; |
||
1492 | } |
||
1493 | }=>> |