mesa: use _mesa_get_texel_store_func()
[mesa.git] / src / mesa / main / texformat.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 6.5.1
4 *
5 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
6 * Copyright (c) 2008 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 /**
28 * \file texformat.c
29 * Texture formats.
30 *
31 * \author Gareth Hughes
32 */
33
34
35 #include "colormac.h"
36 #include "context.h"
37 #include "texcompress.h"
38 #include "texcompress_fxt1.h"
39 #include "texcompress_s3tc.h"
40 #include "texformat.h"
41 #include "texstore.h"
42
43
44 #if FEATURE_EXT_texture_sRGB
45
46 /**
47 * Convert an 8-bit sRGB value from non-linear space to a
48 * linear RGB value in [0, 1].
49 * Implemented with a 256-entry lookup table.
50 */
51 static INLINE GLfloat
52 nonlinear_to_linear(GLubyte cs8)
53 {
54 static GLfloat table[256];
55 static GLboolean tableReady = GL_FALSE;
56 if (!tableReady) {
57 /* compute lookup table now */
58 GLuint i;
59 for (i = 0; i < 256; i++) {
60 const GLfloat cs = UBYTE_TO_FLOAT(i);
61 if (cs <= 0.04045) {
62 table[i] = cs / 12.92f;
63 }
64 else {
65 table[i] = (GLfloat) _mesa_pow((cs + 0.055) / 1.055, 2.4);
66 }
67 }
68 tableReady = GL_TRUE;
69 }
70 return table[cs8];
71 }
72
73
74 #endif /* FEATURE_EXT_texture_sRGB */
75
76
77 /* Texel fetch routines for all supported formats
78 */
79 #define DIM 1
80 #include "texformat_tmp.h"
81
82 #define DIM 2
83 #include "texformat_tmp.h"
84
85 #define DIM 3
86 #include "texformat_tmp.h"
87
88 /**
89 * Null texel fetch function.
90 *
91 * Have to have this so the FetchTexel function pointer is never NULL.
92 */
93 static void fetch_null_texel( const struct gl_texture_image *texImage,
94 GLint i, GLint j, GLint k, GLchan *texel )
95 {
96 (void) texImage; (void) i; (void) j; (void) k;
97 texel[RCOMP] = 0;
98 texel[GCOMP] = 0;
99 texel[BCOMP] = 0;
100 texel[ACOMP] = 0;
101 _mesa_warning(NULL, "fetch_null_texel() called!");
102 }
103
104 static void fetch_null_texelf( const struct gl_texture_image *texImage,
105 GLint i, GLint j, GLint k, GLfloat *texel )
106 {
107 (void) texImage; (void) i; (void) j; (void) k;
108 texel[RCOMP] = 0.0;
109 texel[GCOMP] = 0.0;
110 texel[BCOMP] = 0.0;
111 texel[ACOMP] = 0.0;
112 _mesa_warning(NULL, "fetch_null_texelf() called!");
113 }
114
115 static void store_null_texel(struct gl_texture_image *texImage,
116 GLint i, GLint j, GLint k, const void *texel)
117 {
118 (void) texImage;
119 (void) i;
120 (void) j;
121 (void) k;
122 (void) texel;
123 /* no-op */
124 }
125
126
127 /**
128 * Notes about the predefined gl_texture_formats:
129 *
130 * 1. There are 1D, 2D and 3D functions for fetching texels from texture
131 * images, returning both GLchan values and GLfloat values. (six
132 * functions in total)
133 * You don't have to provide both the GLchan and GLfloat functions;
134 * just one or the other is OK. Mesa will use an "adaptor" to convert
135 * between GLchan/GLfloat when needed.
136 * Since the adaptors have small performance penalty, we provide both
137 * GLchan and GLfloat functions for some common formats like RGB, RGBA.
138 */
139
140
141 /***************************************************************/
142 /** \name Default GLchan-based formats */
143 /*@{*/
144
145 const struct gl_texture_format _mesa_texformat_rgba = {
146 MESA_FORMAT_RGBA, /* MesaFormat */
147 GL_RGBA, /* BaseFormat */
148 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
149 CHAN_BITS, /* RedBits */
150 CHAN_BITS, /* GreenBits */
151 CHAN_BITS, /* BlueBits */
152 CHAN_BITS, /* AlphaBits */
153 0, /* LuminanceBits */
154 0, /* IntensityBits */
155 0, /* IndexBits */
156 0, /* DepthBits */
157 0, /* StencilBits */
158 4 * sizeof(GLchan), /* TexelBytes */
159 _mesa_texstore_rgba, /* StoreTexImageFunc */
160 NULL, /* FetchTexel1D */
161 NULL, /* FetchTexel2D */
162 NULL, /* FetchTexel3D */
163 NULL, /* FetchTexel1Df */
164 NULL, /* FetchTexel2Df */
165 NULL, /* FetchTexel3Df */
166 NULL /* StoreTexel */
167 };
168
169 const struct gl_texture_format _mesa_texformat_rgb = {
170 MESA_FORMAT_RGB, /* MesaFormat */
171 GL_RGB, /* BaseFormat */
172 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
173 CHAN_BITS, /* RedBits */
174 CHAN_BITS, /* GreenBits */
175 CHAN_BITS, /* BlueBits */
176 0, /* AlphaBits */
177 0, /* LuminanceBits */
178 0, /* IntensityBits */
179 0, /* IndexBits */
180 0, /* DepthBits */
181 0, /* StencilBits */
182 3 * sizeof(GLchan), /* TexelBytes */
183 _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
184 NULL, /* FetchTexel1D */
185 NULL, /* FetchTexel2D */
186 NULL, /* FetchTexel3D */
187 NULL, /* FetchTexel1Df */
188 NULL, /* FetchTexel2Df */
189 NULL, /* FetchTexel3Df */
190 NULL /* StoreTexel */
191 };
192
193 const struct gl_texture_format _mesa_texformat_alpha = {
194 MESA_FORMAT_ALPHA, /* MesaFormat */
195 GL_ALPHA, /* BaseFormat */
196 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
197 0, /* RedBits */
198 0, /* GreenBits */
199 0, /* BlueBits */
200 CHAN_BITS, /* AlphaBits */
201 0, /* LuminanceBits */
202 0, /* IntensityBits */
203 0, /* IndexBits */
204 0, /* DepthBits */
205 0, /* StencilBits */
206 sizeof(GLchan), /* TexelBytes */
207 _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
208 NULL, /* FetchTexel1D */
209 NULL, /* FetchTexel2D */
210 NULL, /* FetchTexel3D */
211 NULL, /* FetchTexel1Df */
212 NULL, /* FetchTexel2Df */
213 NULL, /* FetchTexel3Df */
214 NULL /* StoreTexel */
215 };
216
217 const struct gl_texture_format _mesa_texformat_luminance = {
218 MESA_FORMAT_LUMINANCE, /* MesaFormat */
219 GL_LUMINANCE, /* BaseFormat */
220 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
221 0, /* RedBits */
222 0, /* GreenBits */
223 0, /* BlueBits */
224 0, /* AlphaBits */
225 CHAN_BITS, /* LuminanceBits */
226 0, /* IntensityBits */
227 0, /* IndexBits */
228 0, /* DepthBits */
229 0, /* StencilBits */
230 sizeof(GLchan), /* TexelBytes */
231 _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
232 NULL, /* FetchTexel1D */
233 NULL, /* FetchTexel2D */
234 NULL, /* FetchTexel3D */
235 NULL, /* FetchTexel1Df */
236 NULL, /* FetchTexel2Df */
237 NULL, /* FetchTexel3Df */
238 NULL /* StoreTexel */
239 };
240
241 const struct gl_texture_format _mesa_texformat_luminance_alpha = {
242 MESA_FORMAT_LUMINANCE_ALPHA, /* MesaFormat */
243 GL_LUMINANCE_ALPHA, /* BaseFormat */
244 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
245 0, /* RedBits */
246 0, /* GreenBits */
247 0, /* BlueBits */
248 CHAN_BITS, /* AlphaBits */
249 CHAN_BITS, /* LuminanceBits */
250 0, /* IntensityBits */
251 0, /* IndexBits */
252 0, /* DepthBits */
253 0, /* StencilBits */
254 2 * sizeof(GLchan), /* TexelBytes */
255 _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
256 NULL, /* FetchTexel1D */
257 NULL, /* FetchTexel2D */
258 NULL, /* FetchTexel3D */
259 NULL, /* FetchTexel1Df */
260 NULL, /* FetchTexel2Df */
261 NULL, /* FetchTexel3Df */
262 NULL /* StoreTexel */
263 };
264
265 const struct gl_texture_format _mesa_texformat_intensity = {
266 MESA_FORMAT_INTENSITY, /* MesaFormat */
267 GL_INTENSITY, /* BaseFormat */
268 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
269 0, /* RedBits */
270 0, /* GreenBits */
271 0, /* BlueBits */
272 0, /* AlphaBits */
273 0, /* LuminanceBits */
274 CHAN_BITS, /* IntensityBits */
275 0, /* IndexBits */
276 0, /* DepthBits */
277 0, /* StencilBits */
278 sizeof(GLchan), /* TexelBytes */
279 _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
280 NULL, /* FetchTexel1D */
281 NULL, /* FetchTexel2D */
282 NULL, /* FetchTexel3D */
283 NULL, /* FetchTexel1Df */
284 NULL, /* FetchTexel2Df */
285 NULL, /* FetchTexel3Df */
286 NULL /* StoreTexel */
287 };
288
289
290 #if FEATURE_EXT_texture_sRGB
291
292 const struct gl_texture_format _mesa_texformat_srgb8 = {
293 MESA_FORMAT_SRGB8, /* MesaFormat */
294 GL_RGB, /* BaseFormat */
295 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
296 8, /* RedBits */
297 8, /* GreenBits */
298 8, /* BlueBits */
299 0, /* AlphaBits */
300 0, /* LuminanceBits */
301 0, /* IntensityBits */
302 0, /* IndexBits */
303 0, /* DepthBits */
304 0, /* StencilBits */
305 3, /* TexelBytes */
306 _mesa_texstore_srgb8, /* StoreTexImageFunc */
307 NULL, /* FetchTexel1D */
308 NULL, /* FetchTexel2D */
309 NULL, /* FetchTexel3D */
310 NULL, /* FetchTexel1Df */
311 NULL, /* FetchTexel2Df */
312 NULL, /* FetchTexel3Df */
313 NULL /* StoreTexel */
314 };
315
316 const struct gl_texture_format _mesa_texformat_srgba8 = {
317 MESA_FORMAT_SRGBA8, /* MesaFormat */
318 GL_RGBA, /* BaseFormat */
319 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
320 8, /* RedBits */
321 8, /* GreenBits */
322 8, /* BlueBits */
323 8, /* AlphaBits */
324 0, /* LuminanceBits */
325 0, /* IntensityBits */
326 0, /* IndexBits */
327 0, /* DepthBits */
328 0, /* StencilBits */
329 4, /* TexelBytes */
330 _mesa_texstore_srgba8, /* StoreTexImageFunc */
331 NULL, /* FetchTexel1D */
332 NULL, /* FetchTexel2D */
333 NULL, /* FetchTexel3D */
334 NULL, /* FetchTexel1Df */
335 NULL, /* FetchTexel2Df */
336 NULL, /* FetchTexel3Df */
337 NULL /* StoreTexel */
338 };
339
340 const struct gl_texture_format _mesa_texformat_sargb8 = {
341 MESA_FORMAT_SARGB8, /* MesaFormat */
342 GL_RGBA, /* BaseFormat */
343 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
344 8, /* RedBits */
345 8, /* GreenBits */
346 8, /* BlueBits */
347 8, /* AlphaBits */
348 0, /* LuminanceBits */
349 0, /* IntensityBits */
350 0, /* IndexBits */
351 0, /* DepthBits */
352 0, /* StencilBits */
353 4, /* TexelBytes */
354 _mesa_texstore_sargb8, /* StoreTexImageFunc */
355 NULL, /* FetchTexel1D */
356 NULL, /* FetchTexel2D */
357 NULL, /* FetchTexel3D */
358 NULL, /* FetchTexel1Df */
359 NULL, /* FetchTexel2Df */
360 NULL, /* FetchTexel3Df */
361 NULL /* StoreTexel */
362 };
363
364 const struct gl_texture_format _mesa_texformat_sl8 = {
365 MESA_FORMAT_SL8, /* MesaFormat */
366 GL_LUMINANCE, /* BaseFormat */
367 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
368 0, /* RedBits */
369 0, /* GreenBits */
370 0, /* BlueBits */
371 0, /* AlphaBits */
372 8, /* LuminanceBits */
373 0, /* IntensityBits */
374 0, /* IndexBits */
375 0, /* DepthBits */
376 0, /* StencilBits */
377 1, /* TexelBytes */
378 _mesa_texstore_sl8, /* StoreTexImageFunc */
379 NULL, /* FetchTexel1D */
380 NULL, /* FetchTexel2D */
381 NULL, /* FetchTexel3D */
382 NULL, /* FetchTexel1Df */
383 NULL, /* FetchTexel2Df */
384 NULL, /* FetchTexel3Df */
385 NULL /* StoreTexel */
386 };
387
388 /* Note: this format name looks like a misnomer, make it sal8? */
389 const struct gl_texture_format _mesa_texformat_sla8 = {
390 MESA_FORMAT_SLA8, /* MesaFormat */
391 GL_LUMINANCE_ALPHA, /* BaseFormat */
392 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
393 0, /* RedBits */
394 0, /* GreenBits */
395 0, /* BlueBits */
396 8, /* AlphaBits */
397 8, /* LuminanceBits */
398 0, /* IntensityBits */
399 0, /* IndexBits */
400 0, /* DepthBits */
401 0, /* StencilBits */
402 2, /* TexelBytes */
403 _mesa_texstore_sla8, /* StoreTexImageFunc */
404 NULL, /* FetchTexel1D */
405 NULL, /* FetchTexel2D */
406 NULL, /* FetchTexel3D */
407 NULL, /* FetchTexel1Df */
408 NULL, /* FetchTexel2Df */
409 NULL, /* FetchTexel3Df */
410 NULL /* StoreTexel */
411 };
412
413 #endif /* FEATURE_EXT_texture_sRGB */
414
415 const struct gl_texture_format _mesa_texformat_rgba_float32 = {
416 MESA_FORMAT_RGBA_FLOAT32, /* MesaFormat */
417 GL_RGBA, /* BaseFormat */
418 GL_FLOAT, /* DataType */
419 8 * sizeof(GLfloat), /* RedBits */
420 8 * sizeof(GLfloat), /* GreenBits */
421 8 * sizeof(GLfloat), /* BlueBits */
422 8 * sizeof(GLfloat), /* AlphaBits */
423 0, /* LuminanceBits */
424 0, /* IntensityBits */
425 0, /* IndexBits */
426 0, /* DepthBits */
427 0, /* StencilBits */
428 4 * sizeof(GLfloat), /* TexelBytes */
429 _mesa_texstore_rgba_float32, /* StoreTexImageFunc */
430 NULL, /* FetchTexel1D */
431 NULL, /* FetchTexel1D */
432 NULL, /* FetchTexel1D */
433 NULL, /* FetchTexel1Df */
434 NULL, /* FetchTexel1Df */
435 NULL, /* FetchTexel1Df */
436 NULL /* StoreTexel */
437 };
438
439 const struct gl_texture_format _mesa_texformat_rgba_float16 = {
440 MESA_FORMAT_RGBA_FLOAT16, /* MesaFormat */
441 GL_RGBA, /* BaseFormat */
442 GL_FLOAT, /* DataType */
443 8 * sizeof(GLhalfARB), /* RedBits */
444 8 * sizeof(GLhalfARB), /* GreenBits */
445 8 * sizeof(GLhalfARB), /* BlueBits */
446 8 * sizeof(GLhalfARB), /* AlphaBits */
447 0, /* LuminanceBits */
448 0, /* IntensityBits */
449 0, /* IndexBits */
450 0, /* DepthBits */
451 0, /* StencilBits */
452 4 * sizeof(GLhalfARB), /* TexelBytes */
453 _mesa_texstore_rgba_float16, /* StoreTexImageFunc */
454 NULL, /* FetchTexel1D */
455 NULL, /* FetchTexel1D */
456 NULL, /* FetchTexel1D */
457 NULL, /* FetchTexel1Df */
458 NULL, /* FetchTexel1Df */
459 NULL, /* FetchTexel1Df */
460 NULL /* StoreTexel */
461 };
462
463 const struct gl_texture_format _mesa_texformat_rgb_float32 = {
464 MESA_FORMAT_RGB_FLOAT32, /* MesaFormat */
465 GL_RGB, /* BaseFormat */
466 GL_FLOAT, /* DataType */
467 8 * sizeof(GLfloat), /* RedBits */
468 8 * sizeof(GLfloat), /* GreenBits */
469 8 * sizeof(GLfloat), /* BlueBits */
470 0, /* AlphaBits */
471 0, /* LuminanceBits */
472 0, /* IntensityBits */
473 0, /* IndexBits */
474 0, /* DepthBits */
475 0, /* StencilBits */
476 3 * sizeof(GLfloat), /* TexelBytes */
477 _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
478 NULL, /* FetchTexel1D */
479 NULL, /* FetchTexel1D */
480 NULL, /* FetchTexel1D */
481 NULL, /* FetchTexel1Df */
482 NULL, /* FetchTexel1Df */
483 NULL, /* FetchTexel1Df */
484 NULL /* StoreTexel */
485 };
486
487 const struct gl_texture_format _mesa_texformat_rgb_float16 = {
488 MESA_FORMAT_RGB_FLOAT16, /* MesaFormat */
489 GL_RGB, /* BaseFormat */
490 GL_FLOAT, /* DataType */
491 8 * sizeof(GLhalfARB), /* RedBits */
492 8 * sizeof(GLhalfARB), /* GreenBits */
493 8 * sizeof(GLhalfARB), /* BlueBits */
494 0, /* AlphaBits */
495 0, /* LuminanceBits */
496 0, /* IntensityBits */
497 0, /* IndexBits */
498 0, /* DepthBits */
499 0, /* StencilBits */
500 3 * sizeof(GLhalfARB), /* TexelBytes */
501 _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
502 NULL, /* FetchTexel1D */
503 NULL, /* FetchTexel1D */
504 NULL, /* FetchTexel1D */
505 NULL, /* FetchTexel1Df */
506 NULL, /* FetchTexel1Df */
507 NULL, /* FetchTexel1Df */
508 NULL /* StoreTexel */
509 };
510
511 const struct gl_texture_format _mesa_texformat_alpha_float32 = {
512 MESA_FORMAT_ALPHA_FLOAT32, /* MesaFormat */
513 GL_ALPHA, /* BaseFormat */
514 GL_FLOAT, /* DataType */
515 0, /* RedBits */
516 0, /* GreenBits */
517 0, /* BlueBits */
518 8 * sizeof(GLfloat), /* AlphaBits */
519 0, /* LuminanceBits */
520 0, /* IntensityBits */
521 0, /* IndexBits */
522 0, /* DepthBits */
523 0, /* StencilBits */
524 1 * sizeof(GLfloat), /* TexelBytes */
525 _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
526 NULL, /* FetchTexel1D */
527 NULL, /* FetchTexel1D */
528 NULL, /* FetchTexel1D */
529 NULL, /* FetchTexel1Df */
530 NULL, /* FetchTexel1Df */
531 NULL, /* FetchTexel1Df */
532 NULL /* StoreTexel */
533 };
534
535 const struct gl_texture_format _mesa_texformat_alpha_float16 = {
536 MESA_FORMAT_ALPHA_FLOAT16, /* MesaFormat */
537 GL_ALPHA, /* BaseFormat */
538 GL_FLOAT, /* DataType */
539 0, /* RedBits */
540 0, /* GreenBits */
541 0, /* BlueBits */
542 8 * sizeof(GLhalfARB), /* AlphaBits */
543 0, /* LuminanceBits */
544 0, /* IntensityBits */
545 0, /* IndexBits */
546 0, /* DepthBits */
547 0, /* StencilBits */
548 1 * sizeof(GLhalfARB), /* TexelBytes */
549 _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
550 NULL, /* FetchTexel1D */
551 NULL, /* FetchTexel1D */
552 NULL, /* FetchTexel1D */
553 NULL, /* FetchTexel1Df */
554 NULL, /* FetchTexel1Df */
555 NULL, /* FetchTexel1Df */
556 NULL /* StoreTexel */
557 };
558
559 const struct gl_texture_format _mesa_texformat_luminance_float32 = {
560 MESA_FORMAT_LUMINANCE_FLOAT32, /* MesaFormat */
561 GL_LUMINANCE, /* BaseFormat */
562 GL_FLOAT, /* DataType */
563 0, /* RedBits */
564 0, /* GreenBits */
565 0, /* BlueBits */
566 0, /* AlphaBits */
567 8 * sizeof(GLfloat), /* LuminanceBits */
568 0, /* IntensityBits */
569 0, /* IndexBits */
570 0, /* DepthBits */
571 0, /* StencilBits */
572 1 * sizeof(GLfloat), /* TexelBytes */
573 _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
574 NULL, /* FetchTexel1D */
575 NULL, /* FetchTexel2D */
576 NULL, /* FetchTexel3D */
577 NULL, /* FetchTexel1Df */
578 NULL, /* FetchTexel2Df */
579 NULL, /* FetchTexel3Df */
580 NULL /* StoreTexel */
581 };
582
583 const struct gl_texture_format _mesa_texformat_luminance_float16 = {
584 MESA_FORMAT_LUMINANCE_FLOAT16, /* MesaFormat */
585 GL_LUMINANCE, /* BaseFormat */
586 GL_FLOAT, /* DataType */
587 0, /* RedBits */
588 0, /* GreenBits */
589 0, /* BlueBits */
590 0, /* AlphaBits */
591 8 * sizeof(GLhalfARB), /* LuminanceBits */
592 0, /* IntensityBits */
593 0, /* IndexBits */
594 0, /* DepthBits */
595 0, /* StencilBits */
596 1 * sizeof(GLhalfARB), /* TexelBytes */
597 _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
598 NULL, /* FetchTexel1D */
599 NULL, /* FetchTexel2D */
600 NULL, /* FetchTexel3D */
601 NULL, /* FetchTexel1Df */
602 NULL, /* FetchTexel2Df */
603 NULL, /* FetchTexel3Df */
604 NULL /* StoreTexel */
605 };
606
607 const struct gl_texture_format _mesa_texformat_luminance_alpha_float32 = {
608 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32, /* MesaFormat */
609 GL_LUMINANCE_ALPHA, /* BaseFormat */
610 GL_FLOAT, /* DataType */
611 0, /* RedBits */
612 0, /* GreenBits */
613 0, /* BlueBits */
614 8 * sizeof(GLfloat), /* AlphaBits */
615 8 * sizeof(GLfloat), /* LuminanceBits */
616 0, /* IntensityBits */
617 0, /* IndexBits */
618 0, /* DepthBits */
619 0, /* StencilBits */
620 2 * sizeof(GLfloat), /* TexelBytes */
621 _mesa_texstore_rgba_float32, /* StoreTexImageFunc */
622 NULL, /* FetchTexel1D */
623 NULL, /* FetchTexel2D */
624 NULL, /* FetchTexel3D */
625 NULL, /* FetchTexel1Df */
626 NULL, /* FetchTexel2Df */
627 NULL, /* FetchTexel3Df */
628 NULL /* StoreTexel */
629 };
630
631 const struct gl_texture_format _mesa_texformat_luminance_alpha_float16 = {
632 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16, /* MesaFormat */
633 GL_LUMINANCE_ALPHA, /* BaseFormat */
634 GL_FLOAT, /* DataType */
635 0, /* RedBits */
636 0, /* GreenBits */
637 0, /* BlueBits */
638 8 * sizeof(GLhalfARB), /* AlphaBits */
639 8 * sizeof(GLhalfARB), /* LuminanceBits */
640 0, /* IntensityBits */
641 0, /* IndexBits */
642 0, /* DepthBits */
643 0, /* StencilBits */
644 2 * sizeof(GLhalfARB), /* TexelBytes */
645 _mesa_texstore_rgba_float16, /* StoreTexImageFunc */
646 NULL, /* FetchTexel1D */
647 NULL, /* FetchTexel2D */
648 NULL, /* FetchTexel3D */
649 NULL, /* FetchTexel1Df */
650 NULL, /* FetchTexel2Df */
651 NULL, /* FetchTexel3Df */
652 NULL /* StoreTexel */
653 };
654
655 const struct gl_texture_format _mesa_texformat_intensity_float32 = {
656 MESA_FORMAT_INTENSITY_FLOAT32, /* MesaFormat */
657 GL_INTENSITY, /* BaseFormat */
658 GL_FLOAT, /* DataType */
659 0, /* RedBits */
660 0, /* GreenBits */
661 0, /* BlueBits */
662 0, /* AlphaBits */
663 0, /* LuminanceBits */
664 8 * sizeof(GLfloat), /* IntensityBits */
665 0, /* IndexBits */
666 0, /* DepthBits */
667 0, /* StencilBits */
668 1 * sizeof(GLfloat), /* TexelBytes */
669 _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
670 NULL, /* FetchTexel1D */
671 NULL, /* FetchTexel2D */
672 NULL, /* FetchTexel3D */
673 NULL, /* FetchTexel1Df */
674 NULL, /* FetchTexel2Df */
675 NULL, /* FetchTexel3Df */
676 NULL /* StoreTexel */
677 };
678
679 const struct gl_texture_format _mesa_texformat_intensity_float16 = {
680 MESA_FORMAT_INTENSITY_FLOAT16, /* MesaFormat */
681 GL_INTENSITY, /* BaseFormat */
682 GL_FLOAT, /* DataType */
683 0, /* RedBits */
684 0, /* GreenBits */
685 0, /* BlueBits */
686 0, /* AlphaBits */
687 0, /* LuminanceBits */
688 8 * sizeof(GLhalfARB), /* IntensityBits */
689 0, /* IndexBits */
690 0, /* DepthBits */
691 0, /* StencilBits */
692 1 * sizeof(GLhalfARB), /* TexelBytes */
693 _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
694 NULL, /* FetchTexel1D */
695 NULL, /* FetchTexel2D */
696 NULL, /* FetchTexel3D */
697 NULL, /* FetchTexel1Df */
698 NULL, /* FetchTexel2Df */
699 NULL, /* FetchTexel3Df */
700 NULL /* StoreTexel */
701 };
702
703 const struct gl_texture_format _mesa_texformat_dudv8 = {
704 MESA_FORMAT_DUDV8, /* MesaFormat */
705 GL_DUDV_ATI, /* BaseFormat */
706 GL_SIGNED_NORMALIZED, /* DataType */
707 /* maybe should add dudvBits field, but spec seems to be
708 lacking the ability to query with GetTexLevelParameter anyway */
709 0, /* RedBits */
710 0, /* GreenBits */
711 0, /* BlueBits */
712 0, /* AlphaBits */
713 0, /* LuminanceBits */
714 0, /* IntensityBits */
715 0, /* IndexBits */
716 0, /* DepthBits */
717 0, /* StencilBits */
718 2, /* TexelBytes */
719 _mesa_texstore_dudv8, /* StoreTexImageFunc */
720 NULL, /* FetchTexel1D */
721 NULL, /* FetchTexel2D */
722 NULL, /* FetchTexel3D */
723 NULL, /* FetchTexel1Df */
724 NULL, /* FetchTexel2Df */
725 NULL, /* FetchTexel3Df */
726 NULL /* StoreTexel */
727 };
728
729 const struct gl_texture_format _mesa_texformat_signed_rgba8888 = {
730 MESA_FORMAT_SIGNED_RGBA8888, /* MesaFormat */
731 GL_RGBA, /* BaseFormat */
732 GL_SIGNED_NORMALIZED, /* DataType */
733 8, /* RedBits */
734 8, /* GreenBits */
735 8, /* BlueBits */
736 8, /* AlphaBits */
737 0, /* LuminanceBits */
738 0, /* IntensityBits */
739 0, /* IndexBits */
740 0, /* DepthBits */
741 0, /* StencilBits */
742 4, /* TexelBytes */
743 _mesa_texstore_signed_rgba8888, /* StoreTexImageFunc */
744 NULL, /* FetchTexel1D */
745 NULL, /* FetchTexel2D */
746 NULL, /* FetchTexel3D */
747 NULL, /* FetchTexel1Df */
748 NULL, /* FetchTexel2Df */
749 NULL, /* FetchTexel3Df */
750 NULL /* StoreTexel */
751 };
752
753 const struct gl_texture_format _mesa_texformat_signed_rgba8888_rev = {
754 MESA_FORMAT_SIGNED_RGBA8888_REV, /* MesaFormat */
755 GL_RGBA, /* BaseFormat */
756 GL_SIGNED_NORMALIZED, /* DataType */
757 8, /* RedBits */
758 8, /* GreenBits */
759 8, /* BlueBits */
760 8, /* AlphaBits */
761 0, /* LuminanceBits */
762 0, /* IntensityBits */
763 0, /* IndexBits */
764 0, /* DepthBits */
765 0, /* StencilBits */
766 4, /* TexelBytes */
767 _mesa_texstore_signed_rgba8888, /* StoreTexImageFunc */
768 NULL, /* FetchTexel1D */
769 NULL, /* FetchTexel2D */
770 NULL, /* FetchTexel3D */
771 NULL, /* FetchTexel1Df */
772 NULL, /* FetchTexel2Df */
773 NULL, /* FetchTexel3Df */
774 NULL /* StoreTexel */
775 };
776
777 /*@}*/
778
779
780 /***************************************************************/
781 /** \name Hardware formats */
782 /*@{*/
783
784 const struct gl_texture_format _mesa_texformat_rgba8888 = {
785 MESA_FORMAT_RGBA8888, /* MesaFormat */
786 GL_RGBA, /* BaseFormat */
787 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
788 8, /* RedBits */
789 8, /* GreenBits */
790 8, /* BlueBits */
791 8, /* AlphaBits */
792 0, /* LuminanceBits */
793 0, /* IntensityBits */
794 0, /* IndexBits */
795 0, /* DepthBits */
796 0, /* StencilBits */
797 4, /* TexelBytes */
798 _mesa_texstore_rgba8888, /* StoreTexImageFunc */
799 NULL, /* FetchTexel1D */
800 NULL, /* FetchTexel2D */
801 NULL, /* FetchTexel3D */
802 NULL, /* FetchTexel1Df */
803 NULL, /* FetchTexel2Df */
804 NULL, /* FetchTexel3Df */
805 NULL /* StoreTexel */
806 };
807
808 const struct gl_texture_format _mesa_texformat_rgba8888_rev = {
809 MESA_FORMAT_RGBA8888_REV, /* MesaFormat */
810 GL_RGBA, /* BaseFormat */
811 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
812 8, /* RedBits */
813 8, /* GreenBits */
814 8, /* BlueBits */
815 8, /* AlphaBits */
816 0, /* LuminanceBits */
817 0, /* IntensityBits */
818 0, /* IndexBits */
819 0, /* DepthBits */
820 0, /* StencilBits */
821 4, /* TexelBytes */
822 _mesa_texstore_rgba8888, /* StoreTexImageFunc */
823 NULL, /* FetchTexel1D */
824 NULL, /* FetchTexel2D */
825 NULL, /* FetchTexel3D */
826 NULL, /* FetchTexel1Df */
827 NULL, /* FetchTexel2Df */
828 NULL, /* FetchTexel3Df */
829 NULL /* StoreTexel */
830 };
831
832 const struct gl_texture_format _mesa_texformat_argb8888 = {
833 MESA_FORMAT_ARGB8888, /* MesaFormat */
834 GL_RGBA, /* BaseFormat */
835 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
836 8, /* RedBits */
837 8, /* GreenBits */
838 8, /* BlueBits */
839 8, /* AlphaBits */
840 0, /* LuminanceBits */
841 0, /* IntensityBits */
842 0, /* IndexBits */
843 0, /* DepthBits */
844 0, /* StencilBits */
845 4, /* TexelBytes */
846 _mesa_texstore_argb8888, /* StoreTexImageFunc */
847 NULL, /* FetchTexel1D */
848 NULL, /* FetchTexel2D */
849 NULL, /* FetchTexel3D */
850 NULL, /* FetchTexel1Df */
851 NULL, /* FetchTexel2Df */
852 NULL, /* FetchTexel3Df */
853 NULL /* StoreTexel */
854 };
855
856 const struct gl_texture_format _mesa_texformat_argb8888_rev = {
857 MESA_FORMAT_ARGB8888_REV, /* MesaFormat */
858 GL_RGBA, /* BaseFormat */
859 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
860 8, /* RedBits */
861 8, /* GreenBits */
862 8, /* BlueBits */
863 8, /* AlphaBits */
864 0, /* LuminanceBits */
865 0, /* IntensityBits */
866 0, /* IndexBits */
867 0, /* DepthBits */
868 0, /* StencilBits */
869 4, /* TexelBytes */
870 _mesa_texstore_argb8888, /* StoreTexImageFunc */
871 NULL, /* FetchTexel1D */
872 NULL, /* FetchTexel2D */
873 NULL, /* FetchTexel3D */
874 NULL, /* FetchTexel1Df */
875 NULL, /* FetchTexel2Df */
876 NULL, /* FetchTexel3Df */
877 NULL /* StoreTexel */
878 };
879
880 const struct gl_texture_format _mesa_texformat_rgb888 = {
881 MESA_FORMAT_RGB888, /* MesaFormat */
882 GL_RGB, /* BaseFormat */
883 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
884 8, /* RedBits */
885 8, /* GreenBits */
886 8, /* BlueBits */
887 0, /* AlphaBits */
888 0, /* LuminanceBits */
889 0, /* IntensityBits */
890 0, /* IndexBits */
891 0, /* DepthBits */
892 0, /* StencilBits */
893 3, /* TexelBytes */
894 _mesa_texstore_rgb888, /* StoreTexImageFunc */
895 NULL, /* FetchTexel1D */
896 NULL, /* FetchTexel2D */
897 NULL, /* FetchTexel3D */
898 NULL, /* FetchTexel1Df */
899 NULL, /* FetchTexel2Df */
900 NULL, /* FetchTexel3Df */
901 NULL /* StoreTexel */
902 };
903
904 const struct gl_texture_format _mesa_texformat_bgr888 = {
905 MESA_FORMAT_BGR888, /* MesaFormat */
906 GL_RGB, /* BaseFormat */
907 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
908 8, /* RedBits */
909 8, /* GreenBits */
910 8, /* BlueBits */
911 0, /* AlphaBits */
912 0, /* LuminanceBits */
913 0, /* IntensityBits */
914 0, /* IndexBits */
915 0, /* DepthBits */
916 0, /* StencilBits */
917 3, /* TexelBytes */
918 _mesa_texstore_bgr888, /* StoreTexImageFunc */
919 NULL, /* FetchTexel1D */
920 NULL, /* FetchTexel2D */
921 NULL, /* FetchTexel3D */
922 NULL, /* FetchTexel1Df */
923 NULL, /* FetchTexel2Df */
924 NULL, /* FetchTexel3Df */
925 NULL /* StoreTexel */
926 };
927
928 const struct gl_texture_format _mesa_texformat_rgb565 = {
929 MESA_FORMAT_RGB565, /* MesaFormat */
930 GL_RGB, /* BaseFormat */
931 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
932 5, /* RedBits */
933 6, /* GreenBits */
934 5, /* BlueBits */
935 0, /* AlphaBits */
936 0, /* LuminanceBits */
937 0, /* IntensityBits */
938 0, /* IndexBits */
939 0, /* DepthBits */
940 0, /* StencilBits */
941 2, /* TexelBytes */
942 _mesa_texstore_rgb565, /* StoreTexImageFunc */
943 NULL, /* FetchTexel1D */
944 NULL, /* FetchTexel2D */
945 NULL, /* FetchTexel3D */
946 NULL, /* FetchTexel1Df */
947 NULL, /* FetchTexel2Df */
948 NULL, /* FetchTexel3Df */
949 NULL /* StoreTexel */
950 };
951
952 const struct gl_texture_format _mesa_texformat_rgb565_rev = {
953 MESA_FORMAT_RGB565_REV, /* MesaFormat */
954 GL_RGB, /* BaseFormat */
955 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
956 5, /* RedBits */
957 6, /* GreenBits */
958 5, /* BlueBits */
959 0, /* AlphaBits */
960 0, /* LuminanceBits */
961 0, /* IntensityBits */
962 0, /* IndexBits */
963 0, /* DepthBits */
964 0, /* StencilBits */
965 2, /* TexelBytes */
966 _mesa_texstore_rgb565, /* StoreTexImageFunc */
967 NULL, /* FetchTexel1D */
968 NULL, /* FetchTexel2D */
969 NULL, /* FetchTexel3D */
970 NULL, /* FetchTexel1Df */
971 NULL, /* FetchTexel2Df */
972 NULL, /* FetchTexel3Df */
973 NULL /* StoreTexel */
974 };
975
976 const struct gl_texture_format _mesa_texformat_rgba4444 = {
977 MESA_FORMAT_RGBA4444, /* MesaFormat */
978 GL_RGBA, /* BaseFormat */
979 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
980 4, /* RedBits */
981 4, /* GreenBits */
982 4, /* BlueBits */
983 4, /* AlphaBits */
984 0, /* LuminanceBits */
985 0, /* IntensityBits */
986 0, /* IndexBits */
987 0, /* DepthBits */
988 0, /* StencilBits */
989 2, /* TexelBytes */
990 _mesa_texstore_rgba4444, /* StoreTexImageFunc */
991 NULL, /* FetchTexel1D */
992 NULL, /* FetchTexel2D */
993 NULL, /* FetchTexel3D */
994 NULL, /* FetchTexel1Df */
995 NULL, /* FetchTexel2Df */
996 NULL, /* FetchTexel3Df */
997 NULL /* StoreTexel */
998 };
999
1000 const struct gl_texture_format _mesa_texformat_argb4444 = {
1001 MESA_FORMAT_ARGB4444, /* MesaFormat */
1002 GL_RGBA, /* BaseFormat */
1003 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
1004 4, /* RedBits */
1005 4, /* GreenBits */
1006 4, /* BlueBits */
1007 4, /* AlphaBits */
1008 0, /* LuminanceBits */
1009 0, /* IntensityBits */
1010 0, /* IndexBits */
1011 0, /* DepthBits */
1012 0, /* StencilBits */
1013 2, /* TexelBytes */
1014 _mesa_texstore_argb4444, /* StoreTexImageFunc */
1015 NULL, /* FetchTexel1D */
1016 NULL, /* FetchTexel2D */
1017 NULL, /* FetchTexel3D */
1018 NULL, /* FetchTexel1Df */
1019 NULL, /* FetchTexel2Df */
1020 NULL, /* FetchTexel3Df */
1021 NULL /* StoreTexel */
1022 };
1023
1024 const struct gl_texture_format _mesa_texformat_argb4444_rev = {
1025 MESA_FORMAT_ARGB4444_REV, /* MesaFormat */
1026 GL_RGBA, /* BaseFormat */
1027 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
1028 4, /* RedBits */
1029 4, /* GreenBits */
1030 4, /* BlueBits */
1031 4, /* AlphaBits */
1032 0, /* LuminanceBits */
1033 0, /* IntensityBits */
1034 0, /* IndexBits */
1035 0, /* DepthBits */
1036 0, /* StencilBits */
1037 2, /* TexelBytes */
1038 _mesa_texstore_argb4444, /* StoreTexImageFunc */
1039 NULL, /* FetchTexel1D */
1040 NULL, /* FetchTexel2D */
1041 NULL, /* FetchTexel3D */
1042 NULL, /* FetchTexel1Df */
1043 NULL, /* FetchTexel2Df */
1044 NULL, /* FetchTexel3Df */
1045 NULL /* StoreTexel */
1046 };
1047
1048 const struct gl_texture_format _mesa_texformat_rgba5551 = {
1049 MESA_FORMAT_RGBA5551, /* MesaFormat */
1050 GL_RGBA, /* BaseFormat */
1051 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
1052 5, /* RedBits */
1053 5, /* GreenBits */
1054 5, /* BlueBits */
1055 1, /* AlphaBits */
1056 0, /* LuminanceBits */
1057 0, /* IntensityBits */
1058 0, /* IndexBits */
1059 0, /* DepthBits */
1060 0, /* StencilBits */
1061 2, /* TexelBytes */
1062 _mesa_texstore_rgba5551, /* StoreTexImageFunc */
1063 NULL, /* FetchTexel1D */
1064 NULL, /* FetchTexel2D */
1065 NULL, /* FetchTexel3D */
1066 NULL, /* FetchTexel1Df */
1067 NULL, /* FetchTexel2Df */
1068 NULL, /* FetchTexel3Df */
1069 NULL /* StoreTexel */
1070 };
1071
1072 const struct gl_texture_format _mesa_texformat_argb1555 = {
1073 MESA_FORMAT_ARGB1555, /* MesaFormat */
1074 GL_RGBA, /* BaseFormat */
1075 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
1076 5, /* RedBits */
1077 5, /* GreenBits */
1078 5, /* BlueBits */
1079 1, /* AlphaBits */
1080 0, /* LuminanceBits */
1081 0, /* IntensityBits */
1082 0, /* IndexBits */
1083 0, /* DepthBits */
1084 0, /* StencilBits */
1085 2, /* TexelBytes */
1086 _mesa_texstore_argb1555, /* StoreTexImageFunc */
1087 NULL, /* FetchTexel1D */
1088 NULL, /* FetchTexel2D */
1089 NULL, /* FetchTexel3D */
1090 NULL, /* FetchTexel1Df */
1091 NULL, /* FetchTexel2Df */
1092 NULL, /* FetchTexel3Df */
1093 NULL /* StoreTexel */
1094 };
1095
1096 const struct gl_texture_format _mesa_texformat_argb1555_rev = {
1097 MESA_FORMAT_ARGB1555_REV, /* MesaFormat */
1098 GL_RGBA, /* BaseFormat */
1099 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
1100 5, /* RedBits */
1101 5, /* GreenBits */
1102 5, /* BlueBits */
1103 1, /* AlphaBits */
1104 0, /* LuminanceBits */
1105 0, /* IntensityBits */
1106 0, /* IndexBits */
1107 0, /* DepthBits */
1108 0, /* StencilBits */
1109 2, /* TexelBytes */
1110 _mesa_texstore_argb1555, /* StoreTexImageFunc */
1111 NULL, /* FetchTexel1D */
1112 NULL, /* FetchTexel2D */
1113 NULL, /* FetchTexel3D */
1114 NULL, /* FetchTexel1Df */
1115 NULL, /* FetchTexel2Df */
1116 NULL, /* FetchTexel3Df */
1117 NULL /* StoreTexel */
1118 };
1119
1120 const struct gl_texture_format _mesa_texformat_al88 = {
1121 MESA_FORMAT_AL88, /* MesaFormat */
1122 GL_LUMINANCE_ALPHA, /* BaseFormat */
1123 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
1124 0, /* RedBits */
1125 0, /* GreenBits */
1126 0, /* BlueBits */
1127 8, /* AlphaBits */
1128 8, /* LuminanceBits */
1129 0, /* IntensityBits */
1130 0, /* IndexBits */
1131 0, /* DepthBits */
1132 0, /* StencilBits */
1133 2, /* TexelBytes */
1134 _mesa_texstore_al88, /* StoreTexImageFunc */
1135 NULL, /* FetchTexel1D */
1136 NULL, /* FetchTexel2D */
1137 NULL, /* FetchTexel3D */
1138 NULL, /* FetchTexel1Df */
1139 NULL, /* FetchTexel2Df */
1140 NULL, /* FetchTexel3Df */
1141 NULL /* StoreTexel */
1142 };
1143
1144 const struct gl_texture_format _mesa_texformat_al88_rev = {
1145 MESA_FORMAT_AL88_REV, /* MesaFormat */
1146 GL_LUMINANCE_ALPHA, /* BaseFormat */
1147 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
1148 0, /* RedBits */
1149 0, /* GreenBits */
1150 0, /* BlueBits */
1151 8, /* AlphaBits */
1152 8, /* LuminanceBits */
1153 0, /* IntensityBits */
1154 0, /* IndexBits */
1155 0, /* DepthBits */
1156 0, /* StencilBits */
1157 2, /* TexelBytes */
1158 _mesa_texstore_al88, /* StoreTexImageFunc */
1159 NULL, /* FetchTexel1D */
1160 NULL, /* FetchTexel2D */
1161 NULL, /* FetchTexel3D */
1162 NULL, /* FetchTexel1Df */
1163 NULL, /* FetchTexel2Df */
1164 NULL, /* FetchTexel3Df */
1165 NULL /* StoreTexel */
1166 };
1167
1168 const struct gl_texture_format _mesa_texformat_rgb332 = {
1169 MESA_FORMAT_RGB332, /* MesaFormat */
1170 GL_RGB, /* BaseFormat */
1171 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
1172 3, /* RedBits */
1173 3, /* GreenBits */
1174 2, /* BlueBits */
1175 0, /* AlphaBits */
1176 0, /* LuminanceBits */
1177 0, /* IntensityBits */
1178 0, /* IndexBits */
1179 0, /* DepthBits */
1180 0, /* StencilBits */
1181 1, /* TexelBytes */
1182 _mesa_texstore_rgb332, /* StoreTexImageFunc */
1183 NULL, /* FetchTexel1D */
1184 NULL, /* FetchTexel2D */
1185 NULL, /* FetchTexel3D */
1186 NULL, /* FetchTexel1Df */
1187 NULL, /* FetchTexel2Df */
1188 NULL, /* FetchTexel3Df */
1189 NULL /* StoreTexel */
1190 };
1191
1192 const struct gl_texture_format _mesa_texformat_a8 = {
1193 MESA_FORMAT_A8, /* MesaFormat */
1194 GL_ALPHA, /* BaseFormat */
1195 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
1196 0, /* RedBits */
1197 0, /* GreenBits */
1198 0, /* BlueBits */
1199 8, /* AlphaBits */
1200 0, /* LuminanceBits */
1201 0, /* IntensityBits */
1202 0, /* IndexBits */
1203 0, /* DepthBits */
1204 0, /* StencilBits */
1205 1, /* TexelBytes */
1206 _mesa_texstore_a8, /* StoreTexImageFunc */
1207 NULL, /* FetchTexel1D */
1208 NULL, /* FetchTexel2D */
1209 NULL, /* FetchTexel3D */
1210 NULL, /* FetchTexel1Df */
1211 NULL, /* FetchTexel2Df */
1212 NULL, /* FetchTexel3Df */
1213 NULL /* StoreTexel */
1214 };
1215
1216 const struct gl_texture_format _mesa_texformat_l8 = {
1217 MESA_FORMAT_L8, /* MesaFormat */
1218 GL_LUMINANCE, /* BaseFormat */
1219 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
1220 0, /* RedBits */
1221 0, /* GreenBits */
1222 0, /* BlueBits */
1223 0, /* AlphaBits */
1224 8, /* LuminanceBits */
1225 0, /* IntensityBits */
1226 0, /* IndexBits */
1227 0, /* DepthBits */
1228 0, /* StencilBits */
1229 1, /* TexelBytes */
1230 _mesa_texstore_a8,/*yes*/ /* StoreTexImageFunc */
1231 NULL, /* FetchTexel1D */
1232 NULL, /* FetchTexel2D */
1233 NULL, /* FetchTexel3D */
1234 NULL, /* FetchTexel1Df */
1235 NULL, /* FetchTexel2Df */
1236 NULL, /* FetchTexel3Df */
1237 NULL /* StoreTexel */
1238 };
1239
1240 const struct gl_texture_format _mesa_texformat_i8 = {
1241 MESA_FORMAT_I8, /* MesaFormat */
1242 GL_INTENSITY, /* BaseFormat */
1243 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
1244 0, /* RedBits */
1245 0, /* GreenBits */
1246 0, /* BlueBits */
1247 0, /* AlphaBits */
1248 0, /* LuminanceBits */
1249 8, /* IntensityBits */
1250 0, /* IndexBits */
1251 0, /* DepthBits */
1252 0, /* StencilBits */
1253 1, /* TexelBytes */
1254 _mesa_texstore_a8,/*yes*/ /* StoreTexImageFunc */
1255 NULL, /* FetchTexel1D */
1256 NULL, /* FetchTexel2D */
1257 NULL, /* FetchTexel3D */
1258 NULL, /* FetchTexel1Df */
1259 NULL, /* FetchTexel2Df */
1260 NULL, /* FetchTexel3Df */
1261 NULL /* StoreTexel */
1262 };
1263
1264 const struct gl_texture_format _mesa_texformat_ci8 = {
1265 MESA_FORMAT_CI8, /* MesaFormat */
1266 GL_COLOR_INDEX, /* BaseFormat */
1267 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
1268 0, /* RedBits */
1269 0, /* GreenBits */
1270 0, /* BlueBits */
1271 0, /* AlphaBits */
1272 0, /* LuminanceBits */
1273 0, /* IntensityBits */
1274 8, /* IndexBits */
1275 0, /* DepthBits */
1276 0, /* StencilBits */
1277 1, /* TexelBytes */
1278 _mesa_texstore_ci8, /* StoreTexImageFunc */
1279 NULL, /* FetchTexel1D */
1280 NULL, /* FetchTexel2D */
1281 NULL, /* FetchTexel3D */
1282 NULL, /* FetchTexel1Df */
1283 NULL, /* FetchTexel2Df */
1284 NULL, /* FetchTexel3Df */
1285 NULL /* StoreTexel */
1286 };
1287
1288 const struct gl_texture_format _mesa_texformat_ycbcr = {
1289 MESA_FORMAT_YCBCR, /* MesaFormat */
1290 GL_YCBCR_MESA, /* BaseFormat */
1291 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
1292 0, /* RedBits */
1293 0, /* GreenBits */
1294 0, /* BlueBits */
1295 0, /* AlphaBits */
1296 0, /* LuminanceBits */
1297 0, /* IntensityBits */
1298 0, /* IndexBits */
1299 0, /* DepthBits */
1300 0, /* StencilBits */
1301 2, /* TexelBytes */
1302 _mesa_texstore_ycbcr, /* StoreTexImageFunc */
1303 NULL, /* FetchTexel1D */
1304 NULL, /* FetchTexel2D */
1305 NULL, /* FetchTexel3D */
1306 NULL, /* FetchTexel1Df */
1307 NULL, /* FetchTexel2Df */
1308 NULL, /* FetchTexel3Df */
1309 NULL /* StoreTexel */
1310 };
1311
1312 const struct gl_texture_format _mesa_texformat_ycbcr_rev = {
1313 MESA_FORMAT_YCBCR_REV, /* MesaFormat */
1314 GL_YCBCR_MESA, /* BaseFormat */
1315 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
1316 0, /* RedBits */
1317 0, /* GreenBits */
1318 0, /* BlueBits */
1319 0, /* AlphaBits */
1320 0, /* LuminanceBits */
1321 0, /* IntensityBits */
1322 0, /* IndexBits */
1323 0, /* DepthBits */
1324 0, /* StencilBits */
1325 2, /* TexelBytes */
1326 _mesa_texstore_ycbcr, /* StoreTexImageFunc */
1327 NULL, /* FetchTexel1D */
1328 NULL, /* FetchTexel2D */
1329 NULL, /* FetchTexel3D */
1330 NULL, /* FetchTexel1Df */
1331 NULL, /* FetchTexel2Df */
1332 NULL, /* FetchTexel3Df */
1333 NULL /* StoreTexel */
1334 };
1335
1336 const struct gl_texture_format _mesa_texformat_z24_s8 = {
1337 MESA_FORMAT_Z24_S8, /* MesaFormat */
1338 GL_DEPTH_STENCIL_EXT, /* BaseFormat */
1339 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
1340 0, /* RedBits */
1341 0, /* GreenBits */
1342 0, /* BlueBits */
1343 0, /* AlphaBits */
1344 0, /* LuminanceBits */
1345 0, /* IntensityBits */
1346 0, /* IndexBits */
1347 24, /* DepthBits */
1348 8, /* StencilBits */
1349 4, /* TexelBytes */
1350 _mesa_texstore_z24_s8, /* StoreTexImageFunc */
1351 NULL, /* FetchTexel1D */
1352 NULL, /* FetchTexel2D */
1353 NULL, /* FetchTexel3D */
1354 NULL, /* FetchTexel1Df */
1355 NULL, /* FetchTexel2Df */
1356 NULL, /* FetchTexel3Df */
1357 NULL /* StoreTexel */
1358 };
1359
1360 const struct gl_texture_format _mesa_texformat_s8_z24 = {
1361 MESA_FORMAT_S8_Z24, /* MesaFormat */
1362 GL_DEPTH_STENCIL_EXT, /* BaseFormat */
1363 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
1364 0, /* RedBits */
1365 0, /* GreenBits */
1366 0, /* BlueBits */
1367 0, /* AlphaBits */
1368 0, /* LuminanceBits */
1369 0, /* IntensityBits */
1370 0, /* IndexBits */
1371 24, /* DepthBits */
1372 8, /* StencilBits */
1373 4, /* TexelBytes */
1374 _mesa_texstore_s8_z24, /* StoreTexImageFunc */
1375 NULL, /* FetchTexel1D */
1376 NULL, /* FetchTexel2D */
1377 NULL, /* FetchTexel3D */
1378 NULL, /* FetchTexel1Df */
1379 NULL, /* FetchTexel2Df */
1380 NULL, /* FetchTexel3Df */
1381 NULL /* StoreTexel */
1382 };
1383
1384 const struct gl_texture_format _mesa_texformat_z16 = {
1385 MESA_FORMAT_Z16, /* MesaFormat */
1386 GL_DEPTH_COMPONENT, /* BaseFormat */
1387 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
1388 0, /* RedBits */
1389 0, /* GreenBits */
1390 0, /* BlueBits */
1391 0, /* AlphaBits */
1392 0, /* LuminanceBits */
1393 0, /* IntensityBits */
1394 0, /* IndexBits */
1395 sizeof(GLushort) * 8, /* DepthBits */
1396 0, /* StencilBits */
1397 sizeof(GLushort), /* TexelBytes */
1398 _mesa_texstore_z16, /* StoreTexImageFunc */
1399 NULL, /* FetchTexel1D */
1400 NULL, /* FetchTexel1D */
1401 NULL, /* FetchTexel1D */
1402 NULL, /* FetchTexel1Df */
1403 NULL, /* FetchTexel1Df */
1404 NULL, /* FetchTexel1Df */
1405 NULL /* StoreTexel */
1406 };
1407
1408 const struct gl_texture_format _mesa_texformat_z32 = {
1409 MESA_FORMAT_Z32, /* MesaFormat */
1410 GL_DEPTH_COMPONENT, /* BaseFormat */
1411 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
1412 0, /* RedBits */
1413 0, /* GreenBits */
1414 0, /* BlueBits */
1415 0, /* AlphaBits */
1416 0, /* LuminanceBits */
1417 0, /* IntensityBits */
1418 0, /* IndexBits */
1419 sizeof(GLuint) * 8, /* DepthBits */
1420 0, /* StencilBits */
1421 sizeof(GLuint), /* TexelBytes */
1422 _mesa_texstore_z32, /* StoreTexImageFunc */
1423 NULL, /* FetchTexel1D */
1424 NULL, /* FetchTexel1D */
1425 NULL, /* FetchTexel1D */
1426 NULL, /* FetchTexel1Df */
1427 NULL, /* FetchTexel1Df */
1428 NULL, /* FetchTexel1Df */
1429 NULL /* StoreTexel */
1430 };
1431
1432 /*@}*/
1433
1434
1435 /***************************************************************/
1436 /** \name Null format (useful for proxy textures) */
1437 /*@{*/
1438
1439 const struct gl_texture_format _mesa_null_texformat = {
1440 -1, /* MesaFormat */
1441 0, /* BaseFormat */
1442 GL_NONE, /* DataType */
1443 0, /* RedBits */
1444 0, /* GreenBits */
1445 0, /* BlueBits */
1446 0, /* AlphaBits */
1447 0, /* LuminanceBits */
1448 0, /* IntensityBits */
1449 0, /* IndexBits */
1450 0, /* DepthBits */
1451 0, /* StencilBits */
1452 0, /* TexelBytes */
1453 NULL, /* StoreTexImageFunc */
1454 fetch_null_texel, /* FetchTexel1D */
1455 fetch_null_texel, /* FetchTexel1D */
1456 fetch_null_texel, /* FetchTexel1D */
1457 fetch_null_texelf, /* FetchTexel1Df */
1458 fetch_null_texelf, /* FetchTexel1Df */
1459 fetch_null_texelf, /* FetchTexel1Df */
1460 store_null_texel /* StoreTexel */
1461 };
1462
1463 /*@}*/
1464
1465
1466 /**
1467 * Choose an appropriate texture format given the format, type and
1468 * internalFormat parameters passed to glTexImage().
1469 *
1470 * \param ctx the GL context.
1471 * \param internalFormat user's prefered internal texture format.
1472 * \param format incoming image pixel format.
1473 * \param type incoming image data type.
1474 *
1475 * \return a pointer to a gl_texture_format object which describes the
1476 * choosen texture format, or NULL on failure.
1477 *
1478 * This is called via dd_function_table::ChooseTextureFormat. Hardware drivers
1479 * will typically override this function with a specialized version.
1480 */
1481 const struct gl_texture_format *
1482 _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
1483 GLenum format, GLenum type )
1484 {
1485 (void) format;
1486 (void) type;
1487
1488 switch (internalFormat) {
1489 /* RGBA formats */
1490 case 4:
1491 case GL_RGBA:
1492 case GL_RGB10_A2:
1493 case GL_RGBA12:
1494 case GL_RGBA16:
1495 return &_mesa_texformat_rgba;
1496 case GL_RGBA8:
1497 return &_mesa_texformat_rgba8888;
1498 case GL_RGB5_A1:
1499 return &_mesa_texformat_argb1555;
1500 case GL_RGBA2:
1501 return &_mesa_texformat_argb4444_rev; /* just to test another format*/
1502 case GL_RGBA4:
1503 return &_mesa_texformat_argb4444;
1504
1505 /* RGB formats */
1506 case 3:
1507 case GL_RGB:
1508 case GL_RGB10:
1509 case GL_RGB12:
1510 case GL_RGB16:
1511 return &_mesa_texformat_rgb;
1512 case GL_RGB8:
1513 return &_mesa_texformat_rgb888;
1514 case GL_R3_G3_B2:
1515 return &_mesa_texformat_rgb332;
1516 case GL_RGB4:
1517 return &_mesa_texformat_rgb565_rev; /* just to test another format */
1518 case GL_RGB5:
1519 return &_mesa_texformat_rgb565;
1520
1521 /* Alpha formats */
1522 case GL_ALPHA:
1523 case GL_ALPHA4:
1524 case GL_ALPHA12:
1525 case GL_ALPHA16:
1526 return &_mesa_texformat_alpha;
1527 case GL_ALPHA8:
1528 return &_mesa_texformat_a8;
1529
1530 /* Luminance formats */
1531 case 1:
1532 case GL_LUMINANCE:
1533 case GL_LUMINANCE4:
1534 case GL_LUMINANCE12:
1535 case GL_LUMINANCE16:
1536 return &_mesa_texformat_luminance;
1537 case GL_LUMINANCE8:
1538 return &_mesa_texformat_l8;
1539
1540 /* Luminance/Alpha formats */
1541 case 2:
1542 case GL_LUMINANCE_ALPHA:
1543 case GL_LUMINANCE4_ALPHA4:
1544 case GL_LUMINANCE6_ALPHA2:
1545 case GL_LUMINANCE12_ALPHA4:
1546 case GL_LUMINANCE12_ALPHA12:
1547 case GL_LUMINANCE16_ALPHA16:
1548 return &_mesa_texformat_luminance_alpha;
1549 case GL_LUMINANCE8_ALPHA8:
1550 return &_mesa_texformat_al88;
1551
1552 case GL_INTENSITY:
1553 case GL_INTENSITY4:
1554 case GL_INTENSITY12:
1555 case GL_INTENSITY16:
1556 return &_mesa_texformat_intensity;
1557 case GL_INTENSITY8:
1558 return &_mesa_texformat_i8;
1559
1560 case GL_COLOR_INDEX:
1561 case GL_COLOR_INDEX1_EXT:
1562 case GL_COLOR_INDEX2_EXT:
1563 case GL_COLOR_INDEX4_EXT:
1564 case GL_COLOR_INDEX12_EXT:
1565 case GL_COLOR_INDEX16_EXT:
1566 case GL_COLOR_INDEX8_EXT:
1567 return &_mesa_texformat_ci8;
1568
1569 default:
1570 ; /* fallthrough */
1571 }
1572
1573 if (ctx->Extensions.ARB_depth_texture) {
1574 switch (internalFormat) {
1575 case GL_DEPTH_COMPONENT:
1576 case GL_DEPTH_COMPONENT24:
1577 case GL_DEPTH_COMPONENT32:
1578 return &_mesa_texformat_z32;
1579 case GL_DEPTH_COMPONENT16:
1580 return &_mesa_texformat_z16;
1581 default:
1582 ; /* fallthrough */
1583 }
1584 }
1585
1586 switch (internalFormat) {
1587 case GL_COMPRESSED_ALPHA_ARB:
1588 return &_mesa_texformat_alpha;
1589 case GL_COMPRESSED_LUMINANCE_ARB:
1590 return &_mesa_texformat_luminance;
1591 case GL_COMPRESSED_LUMINANCE_ALPHA_ARB:
1592 return &_mesa_texformat_luminance_alpha;
1593 case GL_COMPRESSED_INTENSITY_ARB:
1594 return &_mesa_texformat_intensity;
1595 case GL_COMPRESSED_RGB_ARB:
1596 #if FEATURE_texture_fxt1
1597 if (ctx->Extensions.TDFX_texture_compression_FXT1)
1598 return &_mesa_texformat_rgb_fxt1;
1599 #endif
1600 #if FEATURE_texture_s3tc
1601 if (ctx->Extensions.EXT_texture_compression_s3tc ||
1602 ctx->Extensions.S3_s3tc)
1603 return &_mesa_texformat_rgb_dxt1;
1604 #endif
1605 return &_mesa_texformat_rgb;
1606 case GL_COMPRESSED_RGBA_ARB:
1607 #if FEATURE_texture_fxt1
1608 if (ctx->Extensions.TDFX_texture_compression_FXT1)
1609 return &_mesa_texformat_rgba_fxt1;
1610 #endif
1611 #if FEATURE_texture_s3tc
1612 if (ctx->Extensions.EXT_texture_compression_s3tc ||
1613 ctx->Extensions.S3_s3tc)
1614 return &_mesa_texformat_rgba_dxt3; /* Not rgba_dxt1, see spec */
1615 #endif
1616 return &_mesa_texformat_rgba;
1617 default:
1618 ; /* fallthrough */
1619 }
1620
1621 if (ctx->Extensions.MESA_ycbcr_texture) {
1622 if (internalFormat == GL_YCBCR_MESA) {
1623 if (type == GL_UNSIGNED_SHORT_8_8_MESA)
1624 return &_mesa_texformat_ycbcr;
1625 else
1626 return &_mesa_texformat_ycbcr_rev;
1627 }
1628 }
1629
1630 #if FEATURE_texture_fxt1
1631 if (ctx->Extensions.TDFX_texture_compression_FXT1) {
1632 switch (internalFormat) {
1633 case GL_COMPRESSED_RGB_FXT1_3DFX:
1634 return &_mesa_texformat_rgb_fxt1;
1635 case GL_COMPRESSED_RGBA_FXT1_3DFX:
1636 return &_mesa_texformat_rgba_fxt1;
1637 default:
1638 ; /* fallthrough */
1639 }
1640 }
1641 #endif
1642
1643 #if FEATURE_texture_s3tc
1644 if (ctx->Extensions.EXT_texture_compression_s3tc) {
1645 switch (internalFormat) {
1646 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
1647 return &_mesa_texformat_rgb_dxt1;
1648 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
1649 return &_mesa_texformat_rgba_dxt1;
1650 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
1651 return &_mesa_texformat_rgba_dxt3;
1652 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
1653 return &_mesa_texformat_rgba_dxt5;
1654 default:
1655 ; /* fallthrough */
1656 }
1657 }
1658
1659 if (ctx->Extensions.S3_s3tc) {
1660 switch (internalFormat) {
1661 case GL_RGB_S3TC:
1662 case GL_RGB4_S3TC:
1663 return &_mesa_texformat_rgb_dxt1;
1664 case GL_RGBA_S3TC:
1665 case GL_RGBA4_S3TC:
1666 return &_mesa_texformat_rgba_dxt3;
1667 default:
1668 ; /* fallthrough */
1669 }
1670 }
1671 #endif
1672
1673 if (ctx->Extensions.ARB_texture_float) {
1674 switch (internalFormat) {
1675 case GL_ALPHA16F_ARB:
1676 return &_mesa_texformat_alpha_float16;
1677 case GL_ALPHA32F_ARB:
1678 return &_mesa_texformat_alpha_float32;
1679 case GL_LUMINANCE16F_ARB:
1680 return &_mesa_texformat_luminance_float16;
1681 case GL_LUMINANCE32F_ARB:
1682 return &_mesa_texformat_luminance_float32;
1683 case GL_LUMINANCE_ALPHA16F_ARB:
1684 return &_mesa_texformat_luminance_alpha_float16;
1685 case GL_LUMINANCE_ALPHA32F_ARB:
1686 return &_mesa_texformat_luminance_alpha_float32;
1687 case GL_INTENSITY16F_ARB:
1688 return &_mesa_texformat_intensity_float16;
1689 case GL_INTENSITY32F_ARB:
1690 return &_mesa_texformat_intensity_float32;
1691 case GL_RGB16F_ARB:
1692 return &_mesa_texformat_rgb_float16;
1693 case GL_RGB32F_ARB:
1694 return &_mesa_texformat_rgb_float32;
1695 case GL_RGBA16F_ARB:
1696 return &_mesa_texformat_rgba_float16;
1697 case GL_RGBA32F_ARB:
1698 return &_mesa_texformat_rgba_float32;
1699 default:
1700 ; /* fallthrough */
1701 }
1702 }
1703
1704 if (ctx->Extensions.EXT_packed_depth_stencil) {
1705 switch (internalFormat) {
1706 case GL_DEPTH_STENCIL_EXT:
1707 case GL_DEPTH24_STENCIL8_EXT:
1708 return &_mesa_texformat_z24_s8;
1709 default:
1710 ; /* fallthrough */
1711 }
1712 }
1713
1714 if (ctx->Extensions.ATI_envmap_bumpmap) {
1715 switch (internalFormat) {
1716 case GL_DUDV_ATI:
1717 case GL_DU8DV8_ATI:
1718 return &_mesa_texformat_dudv8;
1719 default:
1720 ; /* fallthrough */
1721 }
1722 }
1723
1724 if (ctx->Extensions.MESA_texture_signed_rgba) {
1725 switch (internalFormat) {
1726 case GL_RGBA_SNORM:
1727 case GL_RGBA8_SNORM:
1728 return &_mesa_texformat_signed_rgba8888;
1729 default:
1730 ; /* fallthrough */
1731 }
1732 }
1733
1734
1735 #if FEATURE_EXT_texture_sRGB
1736 if (ctx->Extensions.EXT_texture_sRGB) {
1737 switch (internalFormat) {
1738 case GL_SRGB_EXT:
1739 case GL_SRGB8_EXT:
1740 return &_mesa_texformat_srgb8;
1741 case GL_SRGB_ALPHA_EXT:
1742 case GL_SRGB8_ALPHA8_EXT:
1743 return &_mesa_texformat_srgba8;
1744 case GL_SLUMINANCE_EXT:
1745 case GL_SLUMINANCE8_EXT:
1746 return &_mesa_texformat_sl8;
1747 case GL_SLUMINANCE_ALPHA_EXT:
1748 case GL_SLUMINANCE8_ALPHA8_EXT:
1749 return &_mesa_texformat_sla8;
1750 case GL_COMPRESSED_SLUMINANCE_EXT:
1751 return &_mesa_texformat_sl8;
1752 case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT:
1753 return &_mesa_texformat_sla8;
1754 case GL_COMPRESSED_SRGB_EXT:
1755 #if FEATURE_texture_s3tc
1756 if (ctx->Extensions.EXT_texture_compression_s3tc)
1757 return &_mesa_texformat_srgb_dxt1;
1758 #endif
1759 return &_mesa_texformat_srgb8;
1760 case GL_COMPRESSED_SRGB_ALPHA_EXT:
1761 #if FEATURE_texture_s3tc
1762 if (ctx->Extensions.EXT_texture_compression_s3tc)
1763 return &_mesa_texformat_srgba_dxt3; /* Not srgba_dxt1, see spec */
1764 #endif
1765 return &_mesa_texformat_srgba8;
1766 #if FEATURE_texture_s3tc
1767 case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
1768 if (ctx->Extensions.EXT_texture_compression_s3tc)
1769 return &_mesa_texformat_srgb_dxt1;
1770 break;
1771 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
1772 if (ctx->Extensions.EXT_texture_compression_s3tc)
1773 return &_mesa_texformat_srgba_dxt1;
1774 break;
1775 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
1776 if (ctx->Extensions.EXT_texture_compression_s3tc)
1777 return &_mesa_texformat_srgba_dxt3;
1778 break;
1779 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
1780 if (ctx->Extensions.EXT_texture_compression_s3tc)
1781 return &_mesa_texformat_srgba_dxt5;
1782 break;
1783 #endif
1784 default:
1785 ; /* fallthrough */
1786 }
1787 }
1788 #endif /* FEATURE_EXT_texture_sRGB */
1789
1790 _mesa_problem(ctx, "unexpected format in _mesa_choose_tex_format()");
1791 return NULL;
1792 }
1793
1794
1795
1796 /**
1797 * Return datatype and number of components per texel for the
1798 * given gl_texture_format.
1799 */
1800 void
1801 _mesa_format_to_type_and_comps(const struct gl_texture_format *format,
1802 GLenum *datatype, GLuint *comps)
1803 {
1804 switch (format->MesaFormat) {
1805 case MESA_FORMAT_RGBA8888:
1806 case MESA_FORMAT_RGBA8888_REV:
1807 case MESA_FORMAT_ARGB8888:
1808 case MESA_FORMAT_ARGB8888_REV:
1809 *datatype = CHAN_TYPE;
1810 *comps = 4;
1811 return;
1812 case MESA_FORMAT_RGB888:
1813 case MESA_FORMAT_BGR888:
1814 *datatype = GL_UNSIGNED_BYTE;
1815 *comps = 3;
1816 return;
1817 case MESA_FORMAT_RGB565:
1818 case MESA_FORMAT_RGB565_REV:
1819 *datatype = GL_UNSIGNED_SHORT_5_6_5;
1820 *comps = 3;
1821 return;
1822
1823 case MESA_FORMAT_ARGB4444:
1824 case MESA_FORMAT_ARGB4444_REV:
1825 *datatype = GL_UNSIGNED_SHORT_4_4_4_4;
1826 *comps = 4;
1827 return;
1828
1829 case MESA_FORMAT_ARGB1555:
1830 case MESA_FORMAT_ARGB1555_REV:
1831 *datatype = GL_UNSIGNED_SHORT_1_5_5_5_REV;
1832 *comps = 4;
1833 return;
1834
1835 case MESA_FORMAT_AL88:
1836 case MESA_FORMAT_AL88_REV:
1837 *datatype = GL_UNSIGNED_BYTE;
1838 *comps = 2;
1839 return;
1840 case MESA_FORMAT_RGB332:
1841 *datatype = GL_UNSIGNED_BYTE_3_3_2;
1842 *comps = 3;
1843 return;
1844
1845 case MESA_FORMAT_A8:
1846 case MESA_FORMAT_L8:
1847 case MESA_FORMAT_I8:
1848 case MESA_FORMAT_CI8:
1849 *datatype = GL_UNSIGNED_BYTE;
1850 *comps = 1;
1851 return;
1852
1853 case MESA_FORMAT_YCBCR:
1854 case MESA_FORMAT_YCBCR_REV:
1855 *datatype = GL_UNSIGNED_SHORT;
1856 *comps = 2;
1857 return;
1858
1859 case MESA_FORMAT_Z24_S8:
1860 *datatype = GL_UNSIGNED_INT;
1861 *comps = 1; /* XXX OK? */
1862 return;
1863
1864 case MESA_FORMAT_S8_Z24:
1865 *datatype = GL_UNSIGNED_INT;
1866 *comps = 1; /* XXX OK? */
1867 return;
1868
1869 case MESA_FORMAT_Z16:
1870 *datatype = GL_UNSIGNED_SHORT;
1871 *comps = 1;
1872 return;
1873
1874 case MESA_FORMAT_Z32:
1875 *datatype = GL_UNSIGNED_INT;
1876 *comps = 1;
1877 return;
1878
1879 case MESA_FORMAT_DUDV8:
1880 *datatype = GL_BYTE;
1881 *comps = 2;
1882 return;
1883
1884 case MESA_FORMAT_SIGNED_RGBA8888:
1885 case MESA_FORMAT_SIGNED_RGBA8888_REV:
1886 *datatype = GL_BYTE;
1887 *comps = 4;
1888 return;
1889
1890 #if FEATURE_EXT_texture_sRGB
1891 case MESA_FORMAT_SRGB8:
1892 *datatype = GL_UNSIGNED_BYTE;
1893 *comps = 3;
1894 return;
1895 case MESA_FORMAT_SRGBA8:
1896 case MESA_FORMAT_SARGB8:
1897 *datatype = GL_UNSIGNED_BYTE;
1898 *comps = 4;
1899 return;
1900 case MESA_FORMAT_SL8:
1901 *datatype = GL_UNSIGNED_BYTE;
1902 *comps = 1;
1903 return;
1904 case MESA_FORMAT_SLA8:
1905 *datatype = GL_UNSIGNED_BYTE;
1906 *comps = 2;
1907 return;
1908 #endif
1909
1910 #if FEATURE_texture_fxt1
1911 case MESA_FORMAT_RGB_FXT1:
1912 case MESA_FORMAT_RGBA_FXT1:
1913 #endif
1914 #if FEATURE_texture_s3tc
1915 case MESA_FORMAT_RGB_DXT1:
1916 case MESA_FORMAT_RGBA_DXT1:
1917 case MESA_FORMAT_RGBA_DXT3:
1918 case MESA_FORMAT_RGBA_DXT5:
1919 #if FEATURE_EXT_texture_sRGB
1920 case MESA_FORMAT_SRGB_DXT1:
1921 case MESA_FORMAT_SRGBA_DXT1:
1922 case MESA_FORMAT_SRGBA_DXT3:
1923 case MESA_FORMAT_SRGBA_DXT5:
1924 #endif
1925 /* XXX generate error instead? */
1926 *datatype = GL_UNSIGNED_BYTE;
1927 *comps = 0;
1928 return;
1929 #endif
1930
1931 case MESA_FORMAT_RGBA:
1932 *datatype = CHAN_TYPE;
1933 *comps = 4;
1934 return;
1935 case MESA_FORMAT_RGB:
1936 *datatype = CHAN_TYPE;
1937 *comps = 3;
1938 return;
1939 case MESA_FORMAT_LUMINANCE_ALPHA:
1940 *datatype = CHAN_TYPE;
1941 *comps = 2;
1942 return;
1943 case MESA_FORMAT_ALPHA:
1944 case MESA_FORMAT_LUMINANCE:
1945 case MESA_FORMAT_INTENSITY:
1946 *datatype = CHAN_TYPE;
1947 *comps = 1;
1948 return;
1949
1950 case MESA_FORMAT_RGBA_FLOAT32:
1951 *datatype = GL_FLOAT;
1952 *comps = 4;
1953 return;
1954 case MESA_FORMAT_RGBA_FLOAT16:
1955 *datatype = GL_HALF_FLOAT_ARB;
1956 *comps = 4;
1957 return;
1958 case MESA_FORMAT_RGB_FLOAT32:
1959 *datatype = GL_FLOAT;
1960 *comps = 3;
1961 return;
1962 case MESA_FORMAT_RGB_FLOAT16:
1963 *datatype = GL_HALF_FLOAT_ARB;
1964 *comps = 3;
1965 return;
1966 case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32:
1967 *datatype = GL_FLOAT;
1968 *comps = 2;
1969 return;
1970 case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16:
1971 *datatype = GL_HALF_FLOAT_ARB;
1972 *comps = 2;
1973 return;
1974 case MESA_FORMAT_ALPHA_FLOAT32:
1975 case MESA_FORMAT_LUMINANCE_FLOAT32:
1976 case MESA_FORMAT_INTENSITY_FLOAT32:
1977 *datatype = GL_FLOAT;
1978 *comps = 1;
1979 return;
1980 case MESA_FORMAT_ALPHA_FLOAT16:
1981 case MESA_FORMAT_LUMINANCE_FLOAT16:
1982 case MESA_FORMAT_INTENSITY_FLOAT16:
1983 *datatype = GL_HALF_FLOAT_ARB;
1984 *comps = 1;
1985 return;
1986
1987 default:
1988 _mesa_problem(NULL, "bad format in _mesa_format_to_type_and_comps");
1989 *datatype = 0;
1990 *comps = 1;
1991 }
1992 }
1993
1994
1995
1996 /**
1997 * Table to map MESA_FORMAT_ to texel fetch/store funcs.
1998 * XXX this is somewhat temporary.
1999 */
2000 static struct {
2001 GLuint Name;
2002 FetchTexelFuncF Fetch1D;
2003 FetchTexelFuncF Fetch2D;
2004 FetchTexelFuncF Fetch3D;
2005 StoreTexelFunc StoreTexel;
2006 }
2007 texfetch_funcs[MESA_FORMAT_COUNT] =
2008 {
2009 {
2010 MESA_FORMAT_RGBA,
2011 fetch_texel_1d_f_rgba,
2012 fetch_texel_2d_f_rgba,
2013 fetch_texel_3d_f_rgba,
2014 store_texel_rgba
2015 },
2016 {
2017 MESA_FORMAT_RGB,
2018 fetch_texel_1d_f_rgb,
2019 fetch_texel_2d_f_rgb,
2020 fetch_texel_3d_f_rgb,
2021 store_texel_rgb
2022 },
2023 {
2024 MESA_FORMAT_ALPHA,
2025 fetch_texel_1d_f_alpha,
2026 fetch_texel_2d_f_alpha,
2027 fetch_texel_3d_f_alpha,
2028 store_texel_alpha
2029 },
2030 {
2031 MESA_FORMAT_LUMINANCE,
2032 fetch_texel_1d_f_luminance,
2033 fetch_texel_2d_f_luminance,
2034 fetch_texel_3d_f_luminance,
2035 store_texel_luminance
2036 },
2037 {
2038 MESA_FORMAT_LUMINANCE_ALPHA,
2039 fetch_texel_1d_f_luminance_alpha,
2040 fetch_texel_2d_f_luminance_alpha,
2041 fetch_texel_3d_f_luminance_alpha,
2042 store_texel_luminance_alpha
2043 },
2044 {
2045 MESA_FORMAT_INTENSITY,
2046 fetch_texel_1d_f_intensity,
2047 fetch_texel_2d_f_intensity,
2048 fetch_texel_3d_f_intensity,
2049 store_texel_intensity
2050 },
2051 {
2052 MESA_FORMAT_SRGB8,
2053 fetch_texel_1d_srgb8,
2054 fetch_texel_2d_srgb8,
2055 fetch_texel_3d_srgb8,
2056 store_texel_srgb8
2057 },
2058 {
2059 MESA_FORMAT_SRGBA8,
2060 fetch_texel_1d_srgba8,
2061 fetch_texel_2d_srgba8,
2062 fetch_texel_3d_srgba8,
2063 store_texel_srgba8
2064 },
2065 {
2066 MESA_FORMAT_SARGB8,
2067 fetch_texel_1d_sargb8,
2068 fetch_texel_2d_sargb8,
2069 fetch_texel_3d_sargb8,
2070 store_texel_sargb8
2071 },
2072 {
2073 MESA_FORMAT_SL8,
2074 fetch_texel_1d_sl8,
2075 fetch_texel_2d_sl8,
2076 fetch_texel_3d_sl8,
2077 store_texel_sl8
2078 },
2079 {
2080 MESA_FORMAT_SLA8,
2081 fetch_texel_1d_sla8,
2082 fetch_texel_2d_sla8,
2083 fetch_texel_3d_sla8,
2084 store_texel_sla8
2085 },
2086 {
2087 MESA_FORMAT_RGB_FXT1,
2088 NULL,
2089 _mesa_fetch_texel_2d_f_rgb_fxt1,
2090 NULL,
2091 NULL
2092 },
2093 {
2094 MESA_FORMAT_RGBA_FXT1,
2095 NULL,
2096 _mesa_fetch_texel_2d_f_rgba_fxt1,
2097 NULL,
2098 NULL
2099 },
2100 {
2101 MESA_FORMAT_RGB_DXT1,
2102 NULL,
2103 _mesa_fetch_texel_2d_f_rgb_dxt1,
2104 NULL,
2105 NULL
2106 },
2107 {
2108 MESA_FORMAT_RGBA_DXT1,
2109 NULL,
2110 _mesa_fetch_texel_2d_f_rgba_dxt1,
2111 NULL,
2112 NULL
2113 },
2114 {
2115 MESA_FORMAT_RGBA_DXT3,
2116 NULL,
2117 _mesa_fetch_texel_2d_f_rgba_dxt3,
2118 NULL,
2119 NULL
2120 },
2121 {
2122 MESA_FORMAT_RGBA_DXT5,
2123 NULL,
2124 _mesa_fetch_texel_2d_f_rgba_dxt5,
2125 NULL,
2126 NULL
2127 },
2128 {
2129 MESA_FORMAT_SRGB_DXT1,
2130 NULL,
2131 _mesa_fetch_texel_2d_f_srgb_dxt1,
2132 NULL,
2133 NULL
2134 },
2135 {
2136 MESA_FORMAT_SRGBA_DXT1,
2137 NULL,
2138 _mesa_fetch_texel_2d_f_srgba_dxt1,
2139 NULL,
2140 NULL
2141 },
2142 {
2143 MESA_FORMAT_SRGBA_DXT3,
2144 NULL,
2145 _mesa_fetch_texel_2d_f_srgba_dxt3,
2146 NULL,
2147 NULL
2148 },
2149 {
2150 MESA_FORMAT_SRGBA_DXT5,
2151 NULL,
2152 _mesa_fetch_texel_2d_f_srgba_dxt5,
2153 NULL,
2154 NULL
2155 },
2156 {
2157 MESA_FORMAT_RGBA_FLOAT32,
2158 fetch_texel_1d_f_rgba_f32,
2159 fetch_texel_2d_f_rgba_f32,
2160 fetch_texel_3d_f_rgba_f32,
2161 store_texel_rgba_f32
2162 },
2163 {
2164 MESA_FORMAT_RGBA_FLOAT16,
2165 fetch_texel_1d_f_rgba_f16,
2166 fetch_texel_2d_f_rgba_f16,
2167 fetch_texel_3d_f_rgba_f16,
2168 store_texel_rgba_f16
2169 },
2170 {
2171 MESA_FORMAT_RGB_FLOAT32,
2172 fetch_texel_1d_f_rgb_f32,
2173 fetch_texel_2d_f_rgb_f32,
2174 fetch_texel_3d_f_rgb_f32,
2175 store_texel_rgb_f32
2176 },
2177 {
2178 MESA_FORMAT_RGB_FLOAT16,
2179 fetch_texel_1d_f_rgb_f16,
2180 fetch_texel_2d_f_rgb_f16,
2181 fetch_texel_3d_f_rgb_f16,
2182 store_texel_rgb_f16
2183 },
2184 {
2185 MESA_FORMAT_ALPHA_FLOAT32,
2186 fetch_texel_1d_f_alpha_f32,
2187 fetch_texel_2d_f_alpha_f32,
2188 fetch_texel_3d_f_alpha_f32,
2189 store_texel_alpha_f32
2190 },
2191 {
2192 MESA_FORMAT_ALPHA_FLOAT16,
2193 fetch_texel_1d_f_alpha_f16,
2194 fetch_texel_2d_f_alpha_f16,
2195 fetch_texel_3d_f_alpha_f16,
2196 store_texel_alpha_f16
2197 },
2198 {
2199 MESA_FORMAT_LUMINANCE_FLOAT32,
2200 fetch_texel_1d_f_luminance_f32,
2201 fetch_texel_2d_f_luminance_f32,
2202 fetch_texel_3d_f_luminance_f32,
2203 store_texel_luminance_f32
2204 },
2205 {
2206 MESA_FORMAT_LUMINANCE_FLOAT16,
2207 fetch_texel_1d_f_luminance_f16,
2208 fetch_texel_2d_f_luminance_f16,
2209 fetch_texel_3d_f_luminance_f16,
2210 store_texel_luminance_f16
2211 },
2212 {
2213 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32,
2214 fetch_texel_1d_f_luminance_alpha_f32,
2215 fetch_texel_2d_f_luminance_alpha_f32,
2216 fetch_texel_3d_f_luminance_alpha_f32,
2217 store_texel_luminance_alpha_f32
2218 },
2219 {
2220 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16,
2221 fetch_texel_1d_f_luminance_alpha_f16,
2222 fetch_texel_2d_f_luminance_alpha_f16,
2223 fetch_texel_3d_f_luminance_alpha_f16,
2224 store_texel_luminance_alpha_f16
2225 },
2226 {
2227 MESA_FORMAT_INTENSITY_FLOAT32,
2228 fetch_texel_1d_f_intensity_f32,
2229 fetch_texel_2d_f_intensity_f32,
2230 fetch_texel_3d_f_intensity_f32,
2231 store_texel_intensity_f32
2232 },
2233 {
2234 MESA_FORMAT_INTENSITY_FLOAT16,
2235 fetch_texel_1d_f_intensity_f16,
2236 fetch_texel_2d_f_intensity_f16,
2237 fetch_texel_3d_f_intensity_f16,
2238 store_texel_intensity_f16
2239 },
2240 {
2241 MESA_FORMAT_DUDV8,
2242 fetch_texel_1d_dudv8,
2243 fetch_texel_2d_dudv8,
2244 fetch_texel_3d_dudv8,
2245 NULL
2246 },
2247 {
2248 MESA_FORMAT_SIGNED_RGBA8888,
2249 fetch_texel_1d_signed_rgba8888,
2250 fetch_texel_2d_signed_rgba8888,
2251 fetch_texel_3d_signed_rgba8888,
2252 store_texel_signed_rgba8888
2253 },
2254 {
2255 MESA_FORMAT_SIGNED_RGBA8888_REV,
2256 fetch_texel_1d_signed_rgba8888_rev,
2257 fetch_texel_2d_signed_rgba8888_rev,
2258 fetch_texel_3d_signed_rgba8888_rev,
2259 store_texel_signed_rgba8888_rev
2260 },
2261 {
2262 MESA_FORMAT_RGBA8888,
2263 fetch_texel_1d_f_rgba8888,
2264 fetch_texel_2d_f_rgba8888,
2265 fetch_texel_3d_f_rgba8888,
2266 store_texel_rgba8888
2267 },
2268 {
2269 MESA_FORMAT_RGBA8888_REV,
2270 fetch_texel_1d_f_rgba8888_rev,
2271 fetch_texel_2d_f_rgba8888_rev,
2272 fetch_texel_3d_f_rgba8888_rev,
2273 store_texel_rgba8888_rev
2274 },
2275 {
2276 MESA_FORMAT_ARGB8888,
2277 fetch_texel_1d_f_argb8888,
2278 fetch_texel_2d_f_argb8888,
2279 fetch_texel_3d_f_argb8888,
2280 store_texel_argb8888
2281 },
2282 {
2283 MESA_FORMAT_ARGB8888_REV,
2284 fetch_texel_1d_f_argb8888_rev,
2285 fetch_texel_2d_f_argb8888_rev,
2286 fetch_texel_3d_f_argb8888_rev,
2287 store_texel_argb8888_rev
2288 },
2289 {
2290 MESA_FORMAT_RGB888,
2291 fetch_texel_1d_f_rgb888,
2292 fetch_texel_2d_f_rgb888,
2293 fetch_texel_3d_f_rgb888,
2294 store_texel_rgb888
2295 },
2296 {
2297 MESA_FORMAT_BGR888,
2298 fetch_texel_1d_f_bgr888,
2299 fetch_texel_2d_f_bgr888,
2300 fetch_texel_3d_f_bgr888,
2301 store_texel_bgr888
2302 },
2303 {
2304 MESA_FORMAT_RGB565,
2305 fetch_texel_1d_f_rgb565,
2306 fetch_texel_2d_f_rgb565,
2307 fetch_texel_3d_f_rgb565,
2308 store_texel_rgb565
2309 },
2310 {
2311 MESA_FORMAT_RGB565_REV,
2312 fetch_texel_1d_f_rgb565_rev,
2313 fetch_texel_2d_f_rgb565_rev,
2314 fetch_texel_3d_f_rgb565_rev,
2315 store_texel_rgb565_rev
2316 },
2317 {
2318 MESA_FORMAT_RGBA4444,
2319 fetch_texel_1d_f_rgba4444,
2320 fetch_texel_2d_f_rgba4444,
2321 fetch_texel_3d_f_rgba4444,
2322 store_texel_rgba4444
2323 },
2324 {
2325 MESA_FORMAT_ARGB4444,
2326 fetch_texel_1d_f_argb4444,
2327 fetch_texel_2d_f_argb4444,
2328 fetch_texel_3d_f_argb4444,
2329 store_texel_argb4444
2330 },
2331 {
2332 MESA_FORMAT_ARGB4444_REV,
2333 fetch_texel_1d_f_argb4444_rev,
2334 fetch_texel_2d_f_argb4444_rev,
2335 fetch_texel_3d_f_argb4444_rev,
2336 store_texel_argb4444_rev
2337 },
2338 {
2339 MESA_FORMAT_RGBA5551,
2340 fetch_texel_1d_f_rgba5551,
2341 fetch_texel_2d_f_rgba5551,
2342 fetch_texel_3d_f_rgba5551,
2343 store_texel_rgba5551
2344 },
2345 {
2346 MESA_FORMAT_ARGB1555,
2347 fetch_texel_1d_f_argb1555,
2348 fetch_texel_2d_f_argb1555,
2349 fetch_texel_3d_f_argb1555,
2350 store_texel_argb1555
2351 },
2352 {
2353 MESA_FORMAT_ARGB1555_REV,
2354 fetch_texel_1d_f_argb1555_rev,
2355 fetch_texel_2d_f_argb1555_rev,
2356 fetch_texel_3d_f_argb1555_rev,
2357 store_texel_argb1555_rev
2358 },
2359 {
2360 MESA_FORMAT_AL88,
2361 fetch_texel_1d_f_al88,
2362 fetch_texel_2d_f_al88,
2363 fetch_texel_3d_f_al88,
2364 store_texel_al88
2365 },
2366 {
2367 MESA_FORMAT_AL88_REV,
2368 fetch_texel_1d_f_al88_rev,
2369 fetch_texel_2d_f_al88_rev,
2370 fetch_texel_3d_f_al88_rev,
2371 store_texel_al88_rev
2372 },
2373 {
2374 MESA_FORMAT_RGB332,
2375 fetch_texel_1d_f_rgb332,
2376 fetch_texel_2d_f_rgb332,
2377 fetch_texel_3d_f_rgb332,
2378 store_texel_rgb332
2379 },
2380 {
2381 MESA_FORMAT_A8,
2382 fetch_texel_1d_f_a8,
2383 fetch_texel_2d_f_a8,
2384 fetch_texel_3d_f_a8,
2385 store_texel_a8
2386 },
2387 {
2388 MESA_FORMAT_L8,
2389 fetch_texel_1d_f_l8,
2390 fetch_texel_2d_f_l8,
2391 fetch_texel_3d_f_l8,
2392 store_texel_l8
2393 },
2394 {
2395 MESA_FORMAT_I8,
2396 fetch_texel_1d_f_i8,
2397 fetch_texel_2d_f_i8,
2398 fetch_texel_3d_f_i8,
2399 store_texel_i8
2400 },
2401 {
2402 MESA_FORMAT_CI8,
2403 fetch_texel_1d_f_ci8,
2404 fetch_texel_2d_f_ci8,
2405 fetch_texel_3d_f_ci8,
2406 store_texel_ci8
2407 },
2408 {
2409 MESA_FORMAT_YCBCR,
2410 fetch_texel_1d_f_ycbcr,
2411 fetch_texel_2d_f_ycbcr,
2412 fetch_texel_3d_f_ycbcr,
2413 store_texel_ycbcr
2414 },
2415 {
2416 MESA_FORMAT_YCBCR_REV,
2417 fetch_texel_1d_f_ycbcr_rev,
2418 fetch_texel_2d_f_ycbcr_rev,
2419 fetch_texel_3d_f_ycbcr_rev,
2420 store_texel_ycbcr_rev
2421 },
2422 {
2423 MESA_FORMAT_Z24_S8,
2424 fetch_texel_1d_f_z24_s8,
2425 fetch_texel_2d_f_z24_s8,
2426 fetch_texel_3d_f_z24_s8,
2427 store_texel_z24_s8
2428 },
2429 {
2430 MESA_FORMAT_S8_Z24,
2431 fetch_texel_1d_f_s8_z24,
2432 fetch_texel_2d_f_s8_z24,
2433 fetch_texel_3d_f_s8_z24,
2434 store_texel_s8_z24
2435 },
2436 {
2437 MESA_FORMAT_Z16,
2438 fetch_texel_1d_f_z16,
2439 fetch_texel_2d_f_z16,
2440 fetch_texel_3d_f_z16,
2441 store_texel_z16
2442 },
2443 {
2444 MESA_FORMAT_Z32,
2445 fetch_texel_1d_f_z32,
2446 fetch_texel_2d_f_z32,
2447 fetch_texel_3d_f_z32,
2448 store_texel_z32
2449 }
2450 };
2451
2452
2453 FetchTexelFuncF
2454 _mesa_get_texel_fetch_func(GLuint format, GLuint dims)
2455 {
2456 GLuint i;
2457 /* XXX replace loop with direct table lookup */
2458 for (i = 0; i < MESA_FORMAT_COUNT; i++) {
2459 if (texfetch_funcs[i].Name == format) {
2460 switch (dims) {
2461 case 1:
2462 return texfetch_funcs[i].Fetch1D;
2463 case 2:
2464 return texfetch_funcs[i].Fetch2D;
2465 case 3:
2466 return texfetch_funcs[i].Fetch3D;
2467 }
2468 }
2469 }
2470 return NULL;
2471 }
2472
2473
2474 StoreTexelFunc
2475 _mesa_get_texel_store_func(GLuint format)
2476 {
2477 GLuint i;
2478 /* XXX replace loop with direct table lookup */
2479 for (i = 0; i < MESA_FORMAT_COUNT; i++) {
2480 if (texfetch_funcs[i].Name == format) {
2481 return texfetch_funcs[i].StoreTexel;
2482 }
2483 }
2484 return NULL;
2485 }