gallium: Update calls to the simple shader functions
[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 "pipe/p_screen.h"
44 #include "st_context.h"
45 #include "st_format.h"
46
47 static GLuint
48 format_bits(
49 pipe_format_rgbazs_t info,
50 GLuint comp )
51 {
52 GLuint size;
53
54 if (pf_swizzle_x(info) == comp) {
55 size = pf_size_x(info);
56 }
57 else if (pf_swizzle_y(info) == comp) {
58 size = pf_size_y(info);
59 }
60 else if (pf_swizzle_z(info) == comp) {
61 size = pf_size_z(info);
62 }
63 else if (pf_swizzle_w(info) == comp) {
64 size = pf_size_w(info);
65 }
66 else {
67 size = 0;
68 }
69 return size << (pf_exp8(info) * 3);
70 }
71
72 static GLuint
73 format_max_bits(
74 pipe_format_rgbazs_t info )
75 {
76 GLuint size = format_bits( info, PIPE_FORMAT_COMP_R );
77
78 size = MAX2( size, format_bits( info, PIPE_FORMAT_COMP_G ) );
79 size = MAX2( size, format_bits( info, PIPE_FORMAT_COMP_B ) );
80 size = MAX2( size, format_bits( info, PIPE_FORMAT_COMP_A ) );
81 size = MAX2( size, format_bits( info, PIPE_FORMAT_COMP_Z ) );
82 size = MAX2( size, format_bits( info, PIPE_FORMAT_COMP_S ) );
83 return size;
84 }
85
86 static GLuint
87 format_size(
88 pipe_format_rgbazs_t info )
89 {
90 return
91 format_bits( info, PIPE_FORMAT_COMP_R ) +
92 format_bits( info, PIPE_FORMAT_COMP_G ) +
93 format_bits( info, PIPE_FORMAT_COMP_B ) +
94 format_bits( info, PIPE_FORMAT_COMP_A ) +
95 format_bits( info, PIPE_FORMAT_COMP_Z ) +
96 format_bits( info, PIPE_FORMAT_COMP_S );
97 }
98
99 /*
100 * XXX temporary here
101 */
102 GLboolean
103 st_get_format_info(enum pipe_format format, struct pipe_format_info *pinfo)
104 {
105 if (pf_layout(format) == PIPE_FORMAT_LAYOUT_RGBAZS) {
106 pipe_format_rgbazs_t info;
107
108 info = format;
109
110 #if 0
111 {
112 char fmtname[256];
113
114 pf_sprint_name( fmtname, format );
115 printf(
116 "%s\n",
117 fmtname );
118 }
119 #endif
120
121 /* Data type */
122 if (format == PIPE_FORMAT_A1R5G5B5_UNORM || format == PIPE_FORMAT_R5G6B5_UNORM) {
123 pinfo->datatype = GL_UNSIGNED_SHORT;
124 }
125 else {
126 GLuint size;
127
128 size = format_max_bits( info );
129 if (size == 8) {
130 if (pf_type(info) == PIPE_FORMAT_TYPE_UNORM)
131 pinfo->datatype = GL_UNSIGNED_BYTE;
132 else
133 pinfo->datatype = GL_BYTE;
134 }
135 else if (size == 16) {
136 if (pf_type(info) == PIPE_FORMAT_TYPE_UNORM)
137 pinfo->datatype = GL_UNSIGNED_SHORT;
138 else
139 pinfo->datatype = GL_SHORT;
140 }
141 else {
142 assert( size <= 32 );
143 if (pf_type(info) == PIPE_FORMAT_TYPE_UNORM)
144 pinfo->datatype = GL_UNSIGNED_INT;
145 else
146 pinfo->datatype = GL_INT;
147 }
148 }
149
150 /* Component bits */
151 pinfo->red_bits = format_bits( info, PIPE_FORMAT_COMP_R );
152 pinfo->green_bits = format_bits( info, PIPE_FORMAT_COMP_G );
153 pinfo->blue_bits = format_bits( info, PIPE_FORMAT_COMP_B );
154 pinfo->alpha_bits = format_bits( info, PIPE_FORMAT_COMP_A );
155 pinfo->depth_bits = format_bits( info, PIPE_FORMAT_COMP_Z );
156 pinfo->stencil_bits = format_bits( info, PIPE_FORMAT_COMP_S );
157 pinfo->luminance_bits = 0;
158 pinfo->intensity_bits = 0;
159
160 /* Format size */
161 pinfo->size = format_size( info ) / 8;
162
163 /* Luminance & Intensity bits */
164 if( pf_swizzle_x(info) == PIPE_FORMAT_COMP_R &&
165 pf_swizzle_y(info) == PIPE_FORMAT_COMP_R &&
166 pf_swizzle_z(info) == PIPE_FORMAT_COMP_R ) {
167 if( pf_swizzle_w(info) == PIPE_FORMAT_COMP_R ) {
168 pinfo->intensity_bits = pinfo->red_bits;
169 }
170 else {
171 pinfo->luminance_bits = pinfo->red_bits;
172 }
173 pinfo->red_bits = 0;
174 }
175
176 /* Base format */
177 if (pinfo->depth_bits) {
178 if (pinfo->stencil_bits) {
179 pinfo->base_format = GL_DEPTH_STENCIL_EXT;
180 }
181 else {
182 pinfo->base_format = GL_DEPTH_COMPONENT;
183 }
184 }
185 else if (pinfo->stencil_bits) {
186 pinfo->base_format = GL_STENCIL_INDEX;
187 }
188 else {
189 pinfo->base_format = GL_RGBA;
190 }
191 }
192 else {
193 pipe_format_ycbcr_t info;
194
195 assert( pf_layout(format) == PIPE_FORMAT_LAYOUT_YCBCR );
196
197 info = format;
198
199 /* TODO */
200 assert( 0 );
201 }
202
203 #if 0
204 printf(
205 "ST_FORMAT: R(%u), G(%u), B(%u), A(%u), Z(%u), S(%u)\n",
206 pinfo->red_bits,
207 pinfo->green_bits,
208 pinfo->blue_bits,
209 pinfo->alpha_bits,
210 pinfo->depth_bits,
211 pinfo->stencil_bits );
212 #endif
213
214 pinfo->format = format;
215
216 return GL_TRUE;
217 }
218
219
220 /**
221 * Return bytes per pixel for the given format.
222 */
223 GLuint
224 st_sizeof_format(enum pipe_format format)
225 {
226 struct pipe_format_info info;
227 if (!st_get_format_info( format, &info )) {
228 assert( 0 );
229 return 0;
230 }
231 return info.size;
232 }
233
234
235 /**
236 * Return bytes per pixel for the given format.
237 */
238 GLenum
239 st_format_datatype(enum pipe_format format)
240 {
241 struct pipe_format_info info;
242 if (!st_get_format_info( format, &info )) {
243 assert( 0 );
244 return 0;
245 }
246 return info.datatype;
247 }
248
249
250 enum pipe_format
251 st_mesa_format_to_pipe_format(GLuint mesaFormat)
252 {
253 switch (mesaFormat) {
254 /* fix this */
255 case MESA_FORMAT_ARGB8888_REV:
256 case MESA_FORMAT_ARGB8888:
257 return PIPE_FORMAT_A8R8G8B8_UNORM;
258 case MESA_FORMAT_ARGB1555:
259 return PIPE_FORMAT_A1R5G5B5_UNORM;
260 case MESA_FORMAT_ARGB4444:
261 return PIPE_FORMAT_A4R4G4B4_UNORM;
262 case MESA_FORMAT_RGB565:
263 return PIPE_FORMAT_R5G6B5_UNORM;
264 case MESA_FORMAT_AL88:
265 return PIPE_FORMAT_U_A8_L8;
266 case MESA_FORMAT_A8:
267 return PIPE_FORMAT_U_A8;
268 case MESA_FORMAT_L8:
269 return PIPE_FORMAT_U_L8;
270 case MESA_FORMAT_I8:
271 return PIPE_FORMAT_U_I8;
272 case MESA_FORMAT_Z16:
273 return PIPE_FORMAT_Z16_UNORM;
274 default:
275 assert(0);
276 return 0;
277 }
278 }
279
280 /**
281 * Find an RGBA format supported by the context/winsys.
282 */
283 static GLuint
284 default_rgba_format(struct pipe_context *pipe, uint type)
285 {
286 static const enum pipe_format colorFormats[] = {
287 PIPE_FORMAT_A8R8G8B8_UNORM,
288 PIPE_FORMAT_B8G8R8A8_UNORM,
289 PIPE_FORMAT_R8G8B8A8_UNORM,
290 PIPE_FORMAT_R5G6B5_UNORM
291 };
292 struct pipe_screen *screen = pipe->screen;
293 uint i;
294 for (i = 0; i < Elements(colorFormats); i++) {
295 if (screen->is_format_supported( screen, colorFormats[i], type )) {
296 return colorFormats[i];
297 }
298 }
299 return PIPE_FORMAT_NONE;
300 }
301
302
303 /**
304 * Search list of formats for first RGBA format with >8 bits/channel.
305 */
306 static GLuint
307 default_deep_rgba_format(struct pipe_context *pipe, uint type)
308 {
309 struct pipe_screen *screen = pipe->screen;
310 if (screen->is_format_supported(screen, PIPE_FORMAT_R16G16B16A16_SNORM, type)) {
311 return PIPE_FORMAT_R16G16B16A16_SNORM;
312 }
313 return PIPE_FORMAT_NONE;
314 }
315
316
317 /**
318 * Find an Z format supported by the context/winsys.
319 */
320 static GLuint
321 default_depth_format(struct pipe_context *pipe, uint type)
322 {
323 static const enum pipe_format zFormats[] = {
324 PIPE_FORMAT_Z16_UNORM,
325 PIPE_FORMAT_Z32_UNORM,
326 PIPE_FORMAT_S8Z24_UNORM,
327 PIPE_FORMAT_Z24S8_UNORM
328 };
329 struct pipe_screen *screen = pipe->screen;
330 uint i;
331 for (i = 0; i < Elements(zFormats); i++) {
332 if (screen->is_format_supported( screen, zFormats[i], type )) {
333 return zFormats[i];
334 }
335 }
336 return PIPE_FORMAT_NONE;
337 }
338
339
340 /**
341 * Choose the PIPE_FORMAT_ to use for user-created renderbuffers.
342 *
343 * \return PIPE_FORMAT_NONE if error/problem.
344 */
345 enum pipe_format
346 st_choose_renderbuffer_format(struct pipe_context *pipe, GLint internalFormat)
347 {
348 struct pipe_screen *screen = pipe->screen;
349 uint surfType = PIPE_SURFACE;
350
351 switch (internalFormat) {
352 case 4:
353 case GL_RGBA:
354 case GL_COMPRESSED_RGBA:
355 case 3:
356 case GL_RGB:
357 case GL_COMPRESSED_RGB:
358 case GL_RGBA8:
359 case GL_RGB10_A2:
360 case GL_RGBA12:
361 return default_rgba_format( pipe, surfType );
362 case GL_RGBA16:
363 return default_deep_rgba_format( pipe, surfType );
364
365 case GL_RGBA4:
366 case GL_RGBA2:
367 if (screen->is_format_supported( screen, PIPE_FORMAT_A4R4G4B4_UNORM, surfType ))
368 return PIPE_FORMAT_A4R4G4B4_UNORM;
369 return default_rgba_format( pipe, surfType );
370
371 case GL_RGB5_A1:
372 if (screen->is_format_supported( screen, PIPE_FORMAT_A1R5G5B5_UNORM, surfType ))
373 return PIPE_FORMAT_A1R5G5B5_UNORM;
374 return default_rgba_format( pipe, surfType );
375
376 case GL_RGB8:
377 case GL_RGB10:
378 case GL_RGB12:
379 case GL_RGB16:
380 return default_rgba_format( pipe, surfType );
381
382 case GL_RGB5:
383 case GL_RGB4:
384 case GL_R3_G3_B2:
385 if (screen->is_format_supported( screen, PIPE_FORMAT_A1R5G5B5_UNORM, surfType ))
386 return PIPE_FORMAT_A1R5G5B5_UNORM;
387 if (screen->is_format_supported( screen, PIPE_FORMAT_R5G6B5_UNORM, surfType ))
388 return PIPE_FORMAT_R5G6B5_UNORM;
389 return default_rgba_format( pipe, surfType );
390
391 case GL_ALPHA:
392 case GL_ALPHA4:
393 case GL_ALPHA8:
394 case GL_ALPHA12:
395 case GL_ALPHA16:
396 case GL_COMPRESSED_ALPHA:
397 if (screen->is_format_supported( screen, PIPE_FORMAT_U_A8, surfType ))
398 return PIPE_FORMAT_U_A8;
399 return default_rgba_format( pipe, surfType );
400
401 case 1:
402 case GL_LUMINANCE:
403 case GL_LUMINANCE4:
404 case GL_LUMINANCE8:
405 case GL_LUMINANCE12:
406 case GL_LUMINANCE16:
407 case GL_COMPRESSED_LUMINANCE:
408 if (screen->is_format_supported( screen, PIPE_FORMAT_U_L8, surfType ))
409 return PIPE_FORMAT_U_A8;
410 return default_rgba_format( pipe, surfType );
411
412 case 2:
413 case GL_LUMINANCE_ALPHA:
414 case GL_LUMINANCE4_ALPHA4:
415 case GL_LUMINANCE6_ALPHA2:
416 case GL_LUMINANCE8_ALPHA8:
417 case GL_LUMINANCE12_ALPHA4:
418 case GL_LUMINANCE12_ALPHA12:
419 case GL_LUMINANCE16_ALPHA16:
420 case GL_COMPRESSED_LUMINANCE_ALPHA:
421 if (screen->is_format_supported( screen, PIPE_FORMAT_U_A8_L8, surfType ))
422 return PIPE_FORMAT_U_A8_L8;
423 return default_rgba_format( pipe, surfType );
424
425 case GL_INTENSITY:
426 case GL_INTENSITY4:
427 case GL_INTENSITY8:
428 case GL_INTENSITY12:
429 case GL_INTENSITY16:
430 case GL_COMPRESSED_INTENSITY:
431 if (screen->is_format_supported( screen, PIPE_FORMAT_U_I8, surfType ))
432 return PIPE_FORMAT_U_I8;
433 return default_rgba_format( pipe, surfType );
434
435 #if 0
436 /* not supported for renderbuffers */
437 case GL_YCBCR_MESA:
438 return PIPE_FORMAT_NONE;
439 case GL_COMPRESSED_RGB_FXT1_3DFX:
440 return &_mesa_texformat_rgb_fxt1;
441 case GL_COMPRESSED_RGBA_FXT1_3DFX:
442 return &_mesa_texformat_rgba_fxt1;
443
444 case GL_RGB_S3TC:
445 case GL_RGB4_S3TC:
446 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
447 return &_mesa_texformat_rgb_dxt1;
448
449 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
450 return &_mesa_texformat_rgba_dxt1;
451
452 case GL_RGBA_S3TC:
453 case GL_RGBA4_S3TC:
454 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
455 return &_mesa_texformat_rgba_dxt3;
456
457 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
458 return &_mesa_texformat_rgba_dxt5;
459 #endif
460
461 case GL_DEPTH_COMPONENT16:
462 if (screen->is_format_supported( screen, PIPE_FORMAT_Z16_UNORM, surfType ))
463 return PIPE_FORMAT_Z16_UNORM;
464 /* fall-through */
465 case GL_DEPTH_COMPONENT24:
466 if (screen->is_format_supported( screen, PIPE_FORMAT_S8Z24_UNORM, surfType ))
467 return PIPE_FORMAT_S8Z24_UNORM;
468 if (screen->is_format_supported( screen, PIPE_FORMAT_Z24S8_UNORM, surfType ))
469 return PIPE_FORMAT_Z24S8_UNORM;
470 /* fall-through */
471 case GL_DEPTH_COMPONENT32:
472 if (screen->is_format_supported( screen, PIPE_FORMAT_Z32_UNORM, surfType ))
473 return PIPE_FORMAT_Z32_UNORM;
474 /* fall-through */
475 case GL_DEPTH_COMPONENT:
476 return default_depth_format( pipe, surfType );
477
478 case GL_STENCIL_INDEX:
479 case GL_STENCIL_INDEX1_EXT:
480 case GL_STENCIL_INDEX4_EXT:
481 case GL_STENCIL_INDEX8_EXT:
482 case GL_STENCIL_INDEX16_EXT:
483 if (screen->is_format_supported( screen, PIPE_FORMAT_U_S8, surfType ))
484 return PIPE_FORMAT_U_S8;
485 if (screen->is_format_supported( screen, PIPE_FORMAT_S8Z24_UNORM, surfType ))
486 return PIPE_FORMAT_S8Z24_UNORM;
487 if (screen->is_format_supported( screen, PIPE_FORMAT_Z24S8_UNORM, surfType ))
488 return PIPE_FORMAT_Z24S8_UNORM;
489 return PIPE_FORMAT_NONE;
490
491 case GL_DEPTH_STENCIL_EXT:
492 case GL_DEPTH24_STENCIL8_EXT:
493 if (screen->is_format_supported( screen, PIPE_FORMAT_S8Z24_UNORM, surfType ))
494 return PIPE_FORMAT_S8Z24_UNORM;
495 if (screen->is_format_supported( screen, PIPE_FORMAT_Z24S8_UNORM, surfType ))
496 return PIPE_FORMAT_Z24S8_UNORM;
497 return PIPE_FORMAT_NONE;
498
499 default:
500 return PIPE_FORMAT_NONE;
501 }
502 }
503
504
505
506 /* It works out that this function is fine for all the supported
507 * hardware. However, there is still a need to map the formats onto
508 * hardware descriptors.
509 */
510 /* Note that the i915 can actually support many more formats than
511 * these if we take the step of simply swizzling the colors
512 * immediately after sampling...
513 */
514 const struct gl_texture_format *
515 st_ChooseTextureFormat(GLcontext * ctx, GLint internalFormat,
516 GLenum format, GLenum type)
517 {
518 #if 0
519 struct intel_context *intel = intel_context(ctx);
520 const GLboolean do32bpt = (intel->intelScreen->front.cpp == 4);
521 #else
522 const GLboolean do32bpt = 1;
523 #endif
524
525 (void) ctx;
526
527 switch (internalFormat) {
528 case 4:
529 case GL_RGBA:
530 case GL_COMPRESSED_RGBA:
531 if (format == GL_BGRA) {
532 if (type == GL_UNSIGNED_BYTE || type == GL_UNSIGNED_INT_8_8_8_8_REV) {
533 return &_mesa_texformat_argb8888;
534 }
535 else if (type == GL_UNSIGNED_SHORT_4_4_4_4_REV) {
536 return &_mesa_texformat_argb4444;
537 }
538 else if (type == GL_UNSIGNED_SHORT_1_5_5_5_REV) {
539 return &_mesa_texformat_argb1555;
540 }
541 }
542 return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
543
544 case 3:
545 case GL_RGB:
546 case GL_COMPRESSED_RGB:
547 if (format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5) {
548 return &_mesa_texformat_rgb565;
549 }
550 return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565;
551
552 case GL_RGBA8:
553 case GL_RGB10_A2:
554 case GL_RGBA12:
555 case GL_RGBA16:
556 return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
557
558 case GL_RGBA4:
559 case GL_RGBA2:
560 return &_mesa_texformat_argb4444;
561
562 case GL_RGB5_A1:
563 return &_mesa_texformat_argb1555;
564
565 case GL_RGB8:
566 case GL_RGB10:
567 case GL_RGB12:
568 case GL_RGB16:
569 return &_mesa_texformat_argb8888;
570
571 case GL_RGB5:
572 case GL_RGB4:
573 case GL_R3_G3_B2:
574 return &_mesa_texformat_rgb565;
575
576 case GL_ALPHA:
577 case GL_ALPHA4:
578 case GL_ALPHA8:
579 case GL_ALPHA12:
580 case GL_ALPHA16:
581 case GL_COMPRESSED_ALPHA:
582 return &_mesa_texformat_a8;
583
584 case 1:
585 case GL_LUMINANCE:
586 case GL_LUMINANCE4:
587 case GL_LUMINANCE8:
588 case GL_LUMINANCE12:
589 case GL_LUMINANCE16:
590 case GL_COMPRESSED_LUMINANCE:
591 return &_mesa_texformat_l8;
592
593 case 2:
594 case GL_LUMINANCE_ALPHA:
595 case GL_LUMINANCE4_ALPHA4:
596 case GL_LUMINANCE6_ALPHA2:
597 case GL_LUMINANCE8_ALPHA8:
598 case GL_LUMINANCE12_ALPHA4:
599 case GL_LUMINANCE12_ALPHA12:
600 case GL_LUMINANCE16_ALPHA16:
601 case GL_COMPRESSED_LUMINANCE_ALPHA:
602 return &_mesa_texformat_al88;
603
604 case GL_INTENSITY:
605 case GL_INTENSITY4:
606 case GL_INTENSITY8:
607 case GL_INTENSITY12:
608 case GL_INTENSITY16:
609 case GL_COMPRESSED_INTENSITY:
610 return &_mesa_texformat_i8;
611
612 case GL_YCBCR_MESA:
613 if (type == GL_UNSIGNED_SHORT_8_8_MESA || type == GL_UNSIGNED_BYTE)
614 return &_mesa_texformat_ycbcr;
615 else
616 return &_mesa_texformat_ycbcr_rev;
617
618 case GL_COMPRESSED_RGB_FXT1_3DFX:
619 return &_mesa_texformat_rgb_fxt1;
620 case GL_COMPRESSED_RGBA_FXT1_3DFX:
621 return &_mesa_texformat_rgba_fxt1;
622
623 case GL_RGB_S3TC:
624 case GL_RGB4_S3TC:
625 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
626 return &_mesa_texformat_rgb_dxt1;
627
628 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
629 return &_mesa_texformat_rgba_dxt1;
630
631 case GL_RGBA_S3TC:
632 case GL_RGBA4_S3TC:
633 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
634 return &_mesa_texformat_rgba_dxt3;
635
636 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
637 return &_mesa_texformat_rgba_dxt5;
638
639 case GL_DEPTH_COMPONENT:
640 case GL_DEPTH_COMPONENT16:
641 case GL_DEPTH_COMPONENT24:
642 case GL_DEPTH_COMPONENT32:
643 return &_mesa_texformat_z16;
644
645 case GL_DEPTH_STENCIL_EXT:
646 case GL_DEPTH24_STENCIL8_EXT:
647 return &_mesa_texformat_z24_s8;
648
649 default:
650 fprintf(stderr, "unexpected texture format %s in %s\n",
651 _mesa_lookup_enum_by_nr(internalFormat), __FUNCTION__);
652 return NULL;
653 }
654
655 return NULL; /* never get here */
656 }