initial support for PIPE_FORMAT_Z24_S8
[mesa.git] / src / mesa / state_tracker / st_format.c
1 /**************************************************************************
2 *
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28
29 /**
30 * Texture Image-related functions.
31 * \author Brian Paul
32 */
33
34 #include "main/imports.h"
35 #include "main/context.h"
36 #include "main/texstore.h"
37 #include "main/texformat.h"
38 #include "main/enums.h"
39 #include "main/macros.h"
40
41 #include "pipe/p_context.h"
42 #include "pipe/p_defines.h"
43 #include "st_context.h"
44 #include "st_format.h"
45
46 static GLuint
47 format_bits(
48 pipe_format_rgbazs_t info,
49 GLuint comp )
50 {
51 GLuint size;
52
53 if (pf_swizzle_x(info) == comp) {
54 size = pf_size_x(info);
55 }
56 else if (pf_swizzle_y(info) == comp) {
57 size = pf_size_y(info);
58 }
59 else if (pf_swizzle_z(info) == comp) {
60 size = pf_size_z(info);
61 }
62 else if (pf_swizzle_w(info) == comp) {
63 size = pf_size_w(info);
64 }
65 else {
66 size = 0;
67 }
68 return size << (pf_exp8(info) * 3);
69 }
70
71 static GLuint
72 format_max_bits(
73 pipe_format_rgbazs_t info )
74 {
75 GLuint size = format_bits( info, PIPE_FORMAT_COMP_R );
76
77 size = MAX2( size, format_bits( info, PIPE_FORMAT_COMP_G ) );
78 size = MAX2( size, format_bits( info, PIPE_FORMAT_COMP_B ) );
79 size = MAX2( size, format_bits( info, PIPE_FORMAT_COMP_A ) );
80 size = MAX2( size, format_bits( info, PIPE_FORMAT_COMP_Z ) );
81 size = MAX2( size, format_bits( info, PIPE_FORMAT_COMP_S ) );
82 return size;
83 }
84
85 static GLuint
86 format_size(
87 pipe_format_rgbazs_t info )
88 {
89 return
90 format_bits( info, PIPE_FORMAT_COMP_R ) +
91 format_bits( info, PIPE_FORMAT_COMP_G ) +
92 format_bits( info, PIPE_FORMAT_COMP_B ) +
93 format_bits( info, PIPE_FORMAT_COMP_A ) +
94 format_bits( info, PIPE_FORMAT_COMP_Z ) +
95 format_bits( info, PIPE_FORMAT_COMP_S );
96 }
97
98 /*
99 * XXX temporary here
100 */
101 GLboolean
102 st_get_format_info(
103 GLuint format,
104 struct pipe_format_info *pinfo )
105 {
106 if (pf_layout(format) == PIPE_FORMAT_LAYOUT_RGBAZS) {
107 pipe_format_rgbazs_t info;
108
109 info = format;
110
111 #if 0
112 printf(
113 "PIPE_FORMAT: X(%u), Y(%u), Z(%u), W(%u)\n",
114 info.sizeX,
115 info.sizeY,
116 info.sizeZ,
117 info.sizeW );
118 #endif
119
120 /* Data type */
121 if (format == PIPE_FORMAT_U_A1_R5_G5_B5 || format == PIPE_FORMAT_U_R5_G6_B5) {
122 pinfo->datatype = GL_UNSIGNED_SHORT;
123 }
124 else {
125 GLuint size;
126
127 size = format_max_bits( info );
128 if (size == 8) {
129 if (pf_type(info) == PIPE_FORMAT_TYPE_UNORM)
130 pinfo->datatype = GL_UNSIGNED_BYTE;
131 else
132 pinfo->datatype = GL_BYTE;
133 }
134 else if (size == 16) {
135 if (pf_type(info) == PIPE_FORMAT_TYPE_UNORM)
136 pinfo->datatype = GL_UNSIGNED_SHORT;
137 else
138 pinfo->datatype = GL_SHORT;
139 }
140 else {
141 assert( size <= 32 );
142 if (pf_type(info) == PIPE_FORMAT_TYPE_UNORM)
143 pinfo->datatype = GL_UNSIGNED_INT;
144 else
145 pinfo->datatype = GL_INT;
146 }
147 }
148
149 /* Component bits */
150 pinfo->red_bits = format_bits( info, PIPE_FORMAT_COMP_R );
151 pinfo->green_bits = format_bits( info, PIPE_FORMAT_COMP_G );
152 pinfo->blue_bits = format_bits( info, PIPE_FORMAT_COMP_B );
153 pinfo->alpha_bits = format_bits( info, PIPE_FORMAT_COMP_A );
154 pinfo->depth_bits = format_bits( info, PIPE_FORMAT_COMP_Z );
155 pinfo->stencil_bits = format_bits( info, PIPE_FORMAT_COMP_S );
156 pinfo->luminance_bits = 0;
157 pinfo->intensity_bits = 0;
158
159 /* Format size */
160 pinfo->size = format_size( info ) / 8;
161
162 /* Luminance & Intensity bits */
163 if( pf_swizzle_x(info) == PIPE_FORMAT_COMP_R &&
164 pf_swizzle_y(info) == PIPE_FORMAT_COMP_R &&
165 pf_swizzle_z(info) == PIPE_FORMAT_COMP_R ) {
166 if( pf_swizzle_w(info) == PIPE_FORMAT_COMP_R ) {
167 pinfo->intensity_bits = pinfo->red_bits;
168 }
169 else {
170 pinfo->luminance_bits = pinfo->red_bits;
171 }
172 pinfo->red_bits = 0;
173 }
174
175 /* Base format */
176 if (pinfo->depth_bits) {
177 if (pinfo->stencil_bits) {
178 pinfo->base_format = GL_DEPTH_STENCIL_EXT;
179 }
180 else {
181 pinfo->base_format = GL_DEPTH_COMPONENT;
182 }
183 }
184 else if (pinfo->stencil_bits) {
185 pinfo->base_format = GL_STENCIL_INDEX;
186 }
187 else {
188 pinfo->base_format = GL_RGBA;
189 }
190 }
191 else {
192 pipe_format_ycbcr_t info;
193
194 assert( pf_layout(format) == PIPE_FORMAT_LAYOUT_YCBCR );
195
196 info = format;
197
198 /* TODO */
199 assert( 0 );
200 }
201
202 #if 0
203 printf(
204 "ST_FORMAT: R(%u), G(%u), B(%u), A(%u), Z(%u), S(%u)\n",
205 pinfo->red_bits,
206 pinfo->green_bits,
207 pinfo->blue_bits,
208 pinfo->alpha_bits,
209 pinfo->depth_bits,
210 pinfo->stencil_bits );
211 #endif
212
213 pinfo->format = format;
214
215 return GL_TRUE;
216 }
217
218
219 /**
220 * Return bytes per pixel for the given format.
221 */
222 GLuint
223 st_sizeof_format(GLuint pipeFormat)
224 {
225 struct pipe_format_info info;
226 if (!st_get_format_info( pipeFormat, &info )) {
227 assert( 0 );
228 return 0;
229 }
230 return info.size;
231 }
232
233
234 /**
235 * Return bytes per pixel for the given format.
236 */
237 GLenum
238 st_format_datatype(GLuint pipeFormat)
239 {
240 struct pipe_format_info info;
241 if (!st_get_format_info( pipeFormat, &info )) {
242 assert( 0 );
243 return 0;
244 }
245 return info.datatype;
246 }
247
248
249 GLuint
250 st_mesa_format_to_pipe_format(GLuint mesaFormat)
251 {
252 switch (mesaFormat) {
253 /* fix this */
254 case MESA_FORMAT_ARGB8888_REV:
255 case MESA_FORMAT_ARGB8888:
256 return PIPE_FORMAT_U_A8_R8_G8_B8;
257 case MESA_FORMAT_AL88:
258 return PIPE_FORMAT_U_A8_L8;
259 case MESA_FORMAT_A8:
260 return PIPE_FORMAT_U_A8;
261 case MESA_FORMAT_L8:
262 return PIPE_FORMAT_U_L8;
263 case MESA_FORMAT_I8:
264 return PIPE_FORMAT_U_I8;
265 case MESA_FORMAT_Z16:
266 return PIPE_FORMAT_U_Z16;
267 default:
268 assert(0);
269 return 0;
270 }
271 }
272
273 /**
274 * Search list of formats for first RGBA format.
275 */
276 static GLuint
277 default_rgba_format(
278 struct pipe_context *pipe )
279 {
280 if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_R8_G8_B8_A8 )) {
281 return PIPE_FORMAT_U_R8_G8_B8_A8;
282 }
283 if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A8_R8_G8_B8 )) {
284 return PIPE_FORMAT_U_A8_R8_G8_B8;
285 }
286 if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_R5_G6_B5 )) {
287 return PIPE_FORMAT_U_R5_G6_B5;
288 }
289 return PIPE_FORMAT_NONE;
290 }
291
292
293 /**
294 * Search list of formats for first RGBA format with >8 bits/channel.
295 */
296 static GLuint
297 default_deep_rgba_format(
298 struct pipe_context *pipe )
299 {
300 if (pipe->is_format_supported( pipe, PIPE_FORMAT_S_R16_G16_B16_A16 )) {
301 return PIPE_FORMAT_S_R16_G16_B16_A16;
302 }
303 return PIPE_FORMAT_NONE;
304 }
305
306
307 /**
308 * Search list of formats for first depth/Z format.
309 */
310 static GLuint
311 default_depth_format(
312 struct pipe_context *pipe )
313 {
314 if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_Z16 )) {
315 return PIPE_FORMAT_U_Z16;
316 }
317 if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_Z32 )) {
318 return PIPE_FORMAT_U_Z32;
319 }
320 if (pipe->is_format_supported( pipe, PIPE_FORMAT_S8_Z24 )) {
321 return PIPE_FORMAT_S8_Z24;
322 }
323 if (pipe->is_format_supported( pipe, PIPE_FORMAT_Z24_S8 )) {
324 return PIPE_FORMAT_Z24_S8;
325 }
326 return PIPE_FORMAT_NONE;
327 }
328
329 /**
330 * Choose the PIPE_FORMAT_ to use for storing a texture image based
331 * on the user's internalFormat, format and type parameters.
332 * We query the pipe device for a list of formats which it supports
333 * and choose from them.
334 * If we find a device that needs a more intricate selection mechanism,
335 * this function _could_ get pushed down into the pipe device.
336 *
337 * Note: also used for glRenderbufferStorageEXT()
338 *
339 * Note: format and type may be GL_NONE (see renderbuffers)
340 *
341 * \return PIPE_FORMAT_NONE if error/problem.
342 */
343 GLuint
344 st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat,
345 GLenum format, GLenum type)
346 {
347 switch (internalFormat) {
348 case 4:
349 case GL_RGBA:
350 case GL_COMPRESSED_RGBA:
351 if (format == GL_BGRA) {
352 if (type == GL_UNSIGNED_BYTE || type == GL_UNSIGNED_INT_8_8_8_8_REV) {
353 if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A8_R8_G8_B8 ))
354 return PIPE_FORMAT_U_A8_R8_G8_B8;
355 }
356 else if (type == GL_UNSIGNED_SHORT_4_4_4_4_REV) {
357 if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A4_R4_G4_B4 ))
358 return PIPE_FORMAT_U_A4_R4_G4_B4;
359 }
360 else if (type == GL_UNSIGNED_SHORT_1_5_5_5_REV) {
361 if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A1_R5_G5_B5 ))
362 return PIPE_FORMAT_U_A1_R5_G5_B5;
363 }
364 }
365 return default_rgba_format( pipe );
366
367 case 3:
368 case GL_RGB:
369 case GL_COMPRESSED_RGB:
370 if (format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5) {
371 if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_R5_G6_B5 ))
372 return PIPE_FORMAT_U_R5_G6_B5;
373 }
374 return default_rgba_format( pipe );
375
376 case GL_RGBA8:
377 case GL_RGB10_A2:
378 case GL_RGBA12:
379 return default_rgba_format( pipe );
380 case GL_RGBA16:
381 return default_deep_rgba_format( pipe );
382
383 case GL_RGBA4:
384 case GL_RGBA2:
385 if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A4_R4_G4_B4 ))
386 return PIPE_FORMAT_U_A4_R4_G4_B4;
387 return default_rgba_format( pipe );
388
389 case GL_RGB5_A1:
390 if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A1_R5_G5_B5 ))
391 return PIPE_FORMAT_U_A1_R5_G5_B5;
392 return default_rgba_format( pipe );
393
394 case GL_RGB8:
395 case GL_RGB10:
396 case GL_RGB12:
397 case GL_RGB16:
398 return default_rgba_format( pipe );
399
400 case GL_RGB5:
401 case GL_RGB4:
402 case GL_R3_G3_B2:
403 if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A1_R5_G5_B5 ))
404 return PIPE_FORMAT_U_A1_R5_G5_B5;
405 return default_rgba_format( pipe );
406
407 case GL_ALPHA:
408 case GL_ALPHA4:
409 case GL_ALPHA8:
410 case GL_ALPHA12:
411 case GL_ALPHA16:
412 case GL_COMPRESSED_ALPHA:
413 if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A8 ))
414 return PIPE_FORMAT_U_A8;
415 return default_rgba_format( pipe );
416
417 case 1:
418 case GL_LUMINANCE:
419 case GL_LUMINANCE4:
420 case GL_LUMINANCE8:
421 case GL_LUMINANCE12:
422 case GL_LUMINANCE16:
423 case GL_COMPRESSED_LUMINANCE:
424 if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A8 ))
425 return PIPE_FORMAT_U_A8;
426 return default_rgba_format( pipe );
427
428 case 2:
429 case GL_LUMINANCE_ALPHA:
430 case GL_LUMINANCE4_ALPHA4:
431 case GL_LUMINANCE6_ALPHA2:
432 case GL_LUMINANCE8_ALPHA8:
433 case GL_LUMINANCE12_ALPHA4:
434 case GL_LUMINANCE12_ALPHA12:
435 case GL_LUMINANCE16_ALPHA16:
436 case GL_COMPRESSED_LUMINANCE_ALPHA:
437 if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A8_L8 ))
438 return PIPE_FORMAT_U_A8_L8;
439 return default_rgba_format( pipe );
440
441 case GL_INTENSITY:
442 case GL_INTENSITY4:
443 case GL_INTENSITY8:
444 case GL_INTENSITY12:
445 case GL_INTENSITY16:
446 case GL_COMPRESSED_INTENSITY:
447 if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_I8 ))
448 return PIPE_FORMAT_U_I8;
449 return default_rgba_format( pipe );
450
451 case GL_YCBCR_MESA:
452 if (type == GL_UNSIGNED_SHORT_8_8_MESA || type == GL_UNSIGNED_BYTE) {
453 if (pipe->is_format_supported( pipe, PIPE_FORMAT_YCBCR ))
454 return PIPE_FORMAT_YCBCR;
455 }
456 else {
457 if (pipe->is_format_supported( pipe, PIPE_FORMAT_YCBCR_REV ))
458 return PIPE_FORMAT_YCBCR_REV;
459 }
460 return PIPE_FORMAT_NONE;
461
462 #if 0
463 case GL_COMPRESSED_RGB_FXT1_3DFX:
464 return &_mesa_texformat_rgb_fxt1;
465 case GL_COMPRESSED_RGBA_FXT1_3DFX:
466 return &_mesa_texformat_rgba_fxt1;
467
468 case GL_RGB_S3TC:
469 case GL_RGB4_S3TC:
470 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
471 return &_mesa_texformat_rgb_dxt1;
472
473 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
474 return &_mesa_texformat_rgba_dxt1;
475
476 case GL_RGBA_S3TC:
477 case GL_RGBA4_S3TC:
478 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
479 return &_mesa_texformat_rgba_dxt3;
480
481 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
482 return &_mesa_texformat_rgba_dxt5;
483 #endif
484
485 case GL_DEPTH_COMPONENT16:
486 if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_Z16 ))
487 return PIPE_FORMAT_U_Z16;
488 /* fall-through */
489 case GL_DEPTH_COMPONENT24:
490 if (pipe->is_format_supported( pipe, PIPE_FORMAT_S8_Z24 ))
491 return PIPE_FORMAT_S8_Z24;
492 if (pipe->is_format_supported( pipe, PIPE_FORMAT_Z24_S8 ))
493 return PIPE_FORMAT_Z24_S8;
494 /* fall-through */
495 case GL_DEPTH_COMPONENT32:
496 if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_Z32 ))
497 return PIPE_FORMAT_U_Z32;
498 /* fall-through */
499 case GL_DEPTH_COMPONENT:
500 return default_depth_format( pipe );
501
502 case GL_STENCIL_INDEX:
503 case GL_STENCIL_INDEX1_EXT:
504 case GL_STENCIL_INDEX4_EXT:
505 case GL_STENCIL_INDEX8_EXT:
506 case GL_STENCIL_INDEX16_EXT:
507 if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_S8 ))
508 return PIPE_FORMAT_U_S8;
509 if (pipe->is_format_supported( pipe, PIPE_FORMAT_S8_Z24 ))
510 return PIPE_FORMAT_S8_Z24;
511 if (pipe->is_format_supported( pipe, PIPE_FORMAT_Z24_S8 ))
512 return PIPE_FORMAT_Z24_S8;
513 return PIPE_FORMAT_NONE;
514
515 case GL_DEPTH_STENCIL_EXT:
516 case GL_DEPTH24_STENCIL8_EXT:
517 if (pipe->is_format_supported( pipe, PIPE_FORMAT_S8_Z24 ))
518 return PIPE_FORMAT_S8_Z24;
519 if (pipe->is_format_supported( pipe, PIPE_FORMAT_Z24_S8 ))
520 return PIPE_FORMAT_Z24_S8;
521 return PIPE_FORMAT_NONE;
522
523 default:
524 return PIPE_FORMAT_NONE;
525 }
526 }
527
528
529
530 /* It works out that this function is fine for all the supported
531 * hardware. However, there is still a need to map the formats onto
532 * hardware descriptors.
533 */
534 /* Note that the i915 can actually support many more formats than
535 * these if we take the step of simply swizzling the colors
536 * immediately after sampling...
537 */
538 const struct gl_texture_format *
539 st_ChooseTextureFormat(GLcontext * ctx, GLint internalFormat,
540 GLenum format, GLenum type)
541 {
542 #if 0
543 struct intel_context *intel = intel_context(ctx);
544 const GLboolean do32bpt = (intel->intelScreen->front.cpp == 4);
545 #else
546 const GLboolean do32bpt = 1;
547 #endif
548
549 switch (internalFormat) {
550 case 4:
551 case GL_RGBA:
552 case GL_COMPRESSED_RGBA:
553 if (format == GL_BGRA) {
554 if (type == GL_UNSIGNED_BYTE || type == GL_UNSIGNED_INT_8_8_8_8_REV) {
555 return &_mesa_texformat_argb8888;
556 }
557 else if (type == GL_UNSIGNED_SHORT_4_4_4_4_REV) {
558 return &_mesa_texformat_argb4444;
559 }
560 else if (type == GL_UNSIGNED_SHORT_1_5_5_5_REV) {
561 return &_mesa_texformat_argb1555;
562 }
563 }
564 return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
565
566 case 3:
567 case GL_RGB:
568 case GL_COMPRESSED_RGB:
569 if (format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5) {
570 return &_mesa_texformat_rgb565;
571 }
572 return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565;
573
574 case GL_RGBA8:
575 case GL_RGB10_A2:
576 case GL_RGBA12:
577 case GL_RGBA16:
578 return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
579
580 case GL_RGBA4:
581 case GL_RGBA2:
582 return &_mesa_texformat_argb4444;
583
584 case GL_RGB5_A1:
585 return &_mesa_texformat_argb1555;
586
587 case GL_RGB8:
588 case GL_RGB10:
589 case GL_RGB12:
590 case GL_RGB16:
591 return &_mesa_texformat_argb8888;
592
593 case GL_RGB5:
594 case GL_RGB4:
595 case GL_R3_G3_B2:
596 return &_mesa_texformat_rgb565;
597
598 case GL_ALPHA:
599 case GL_ALPHA4:
600 case GL_ALPHA8:
601 case GL_ALPHA12:
602 case GL_ALPHA16:
603 case GL_COMPRESSED_ALPHA:
604 return &_mesa_texformat_a8;
605
606 case 1:
607 case GL_LUMINANCE:
608 case GL_LUMINANCE4:
609 case GL_LUMINANCE8:
610 case GL_LUMINANCE12:
611 case GL_LUMINANCE16:
612 case GL_COMPRESSED_LUMINANCE:
613 return &_mesa_texformat_l8;
614
615 case 2:
616 case GL_LUMINANCE_ALPHA:
617 case GL_LUMINANCE4_ALPHA4:
618 case GL_LUMINANCE6_ALPHA2:
619 case GL_LUMINANCE8_ALPHA8:
620 case GL_LUMINANCE12_ALPHA4:
621 case GL_LUMINANCE12_ALPHA12:
622 case GL_LUMINANCE16_ALPHA16:
623 case GL_COMPRESSED_LUMINANCE_ALPHA:
624 return &_mesa_texformat_al88;
625
626 case GL_INTENSITY:
627 case GL_INTENSITY4:
628 case GL_INTENSITY8:
629 case GL_INTENSITY12:
630 case GL_INTENSITY16:
631 case GL_COMPRESSED_INTENSITY:
632 return &_mesa_texformat_i8;
633
634 case GL_YCBCR_MESA:
635 if (type == GL_UNSIGNED_SHORT_8_8_MESA || type == GL_UNSIGNED_BYTE)
636 return &_mesa_texformat_ycbcr;
637 else
638 return &_mesa_texformat_ycbcr_rev;
639
640 case GL_COMPRESSED_RGB_FXT1_3DFX:
641 return &_mesa_texformat_rgb_fxt1;
642 case GL_COMPRESSED_RGBA_FXT1_3DFX:
643 return &_mesa_texformat_rgba_fxt1;
644
645 case GL_RGB_S3TC:
646 case GL_RGB4_S3TC:
647 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
648 return &_mesa_texformat_rgb_dxt1;
649
650 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
651 return &_mesa_texformat_rgba_dxt1;
652
653 case GL_RGBA_S3TC:
654 case GL_RGBA4_S3TC:
655 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
656 return &_mesa_texformat_rgba_dxt3;
657
658 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
659 return &_mesa_texformat_rgba_dxt5;
660
661 case GL_DEPTH_COMPONENT:
662 case GL_DEPTH_COMPONENT16:
663 case GL_DEPTH_COMPONENT24:
664 case GL_DEPTH_COMPONENT32:
665 return &_mesa_texformat_z16;
666
667 case GL_DEPTH_STENCIL_EXT:
668 case GL_DEPTH24_STENCIL8_EXT:
669 return &_mesa_texformat_z24_s8;
670
671 default:
672 fprintf(stderr, "unexpected texture format %s in %s\n",
673 _mesa_lookup_enum_by_nr(internalFormat), __FUNCTION__);
674 return NULL;
675 }
676
677 return NULL; /* never get here */
678 }