gallium: remove some debug assertions in vertex format validation
[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(enum pipe_format format, struct pipe_format_info *pinfo)
103 {
104 if (pf_layout(format) == PIPE_FORMAT_LAYOUT_RGBAZS) {
105 pipe_format_rgbazs_t info;
106
107 info = format;
108
109 #if 0
110 {
111 char fmtname[256];
112
113 pf_sprint_name( fmtname, format );
114 printf(
115 "%s\n",
116 fmtname );
117 }
118 #endif
119
120 /* Data type */
121 if (format == PIPE_FORMAT_A1R5G5B5_UNORM || format == PIPE_FORMAT_R5G6B5_UNORM) {
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(enum pipe_format format)
224 {
225 struct pipe_format_info info;
226 if (!st_get_format_info( format, &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(enum pipe_format format)
239 {
240 struct pipe_format_info info;
241 if (!st_get_format_info( format, &info )) {
242 assert( 0 );
243 return 0;
244 }
245 return info.datatype;
246 }
247
248
249 enum pipe_format
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_A8R8G8B8_UNORM;
257 case MESA_FORMAT_ARGB1555:
258 return PIPE_FORMAT_A1R5G5B5_UNORM;
259 case MESA_FORMAT_ARGB4444:
260 return PIPE_FORMAT_A4R4G4B4_UNORM;
261 case MESA_FORMAT_RGB565:
262 return PIPE_FORMAT_R5G6B5_UNORM;
263 case MESA_FORMAT_AL88:
264 return PIPE_FORMAT_U_A8_L8;
265 case MESA_FORMAT_A8:
266 return PIPE_FORMAT_U_A8;
267 case MESA_FORMAT_L8:
268 return PIPE_FORMAT_U_L8;
269 case MESA_FORMAT_I8:
270 return PIPE_FORMAT_U_I8;
271 case MESA_FORMAT_Z16:
272 return PIPE_FORMAT_Z16_UNORM;
273 default:
274 assert(0);
275 return 0;
276 }
277 }
278
279 /**
280 * Find an RGBA format supported by the context/winsys.
281 */
282 static GLuint
283 default_rgba_format(struct pipe_context *pipe, uint type)
284 {
285 static const enum pipe_format colorFormats[] = {
286 PIPE_FORMAT_A8R8G8B8_UNORM,
287 PIPE_FORMAT_B8G8R8A8_UNORM,
288 PIPE_FORMAT_R8G8B8A8_UNORM,
289 PIPE_FORMAT_R5G6B5_UNORM
290 };
291 uint i;
292 for (i = 0; i < Elements(colorFormats); i++) {
293 if (pipe->is_format_supported( pipe, colorFormats[i], type )) {
294 return colorFormats[i];
295 }
296 }
297 return PIPE_FORMAT_NONE;
298 }
299
300
301 /**
302 * Search list of formats for first RGBA format with >8 bits/channel.
303 */
304 static GLuint
305 default_deep_rgba_format(struct pipe_context *pipe, uint type)
306 {
307 if (pipe->is_format_supported(pipe, PIPE_FORMAT_R16G16B16A16_SNORM, type)) {
308 return PIPE_FORMAT_R16G16B16A16_SNORM;
309 }
310 return PIPE_FORMAT_NONE;
311 }
312
313
314 /**
315 * Find an Z format supported by the context/winsys.
316 */
317 static GLuint
318 default_depth_format(struct pipe_context *pipe, uint type)
319 {
320 static const enum pipe_format zFormats[] = {
321 PIPE_FORMAT_Z16_UNORM,
322 PIPE_FORMAT_Z32_UNORM,
323 PIPE_FORMAT_S8Z24_UNORM,
324 PIPE_FORMAT_Z24S8_UNORM
325 };
326 uint i;
327 for (i = 0; i < Elements(zFormats); i++) {
328 if (pipe->is_format_supported( pipe, zFormats[i], type )) {
329 return zFormats[i];
330 }
331 }
332 return PIPE_FORMAT_NONE;
333 }
334
335
336 /**
337 * Choose the PIPE_FORMAT_ to use for user-created renderbuffers.
338 *
339 * \return PIPE_FORMAT_NONE if error/problem.
340 */
341 enum pipe_format
342 st_choose_renderbuffer_format(struct pipe_context *pipe, GLint internalFormat)
343 {
344 uint surfType = PIPE_SURFACE;
345
346 switch (internalFormat) {
347 case 4:
348 case GL_RGBA:
349 case GL_COMPRESSED_RGBA:
350 case 3:
351 case GL_RGB:
352 case GL_COMPRESSED_RGB:
353 case GL_RGBA8:
354 case GL_RGB10_A2:
355 case GL_RGBA12:
356 return default_rgba_format( pipe, surfType );
357 case GL_RGBA16:
358 return default_deep_rgba_format( pipe, surfType );
359
360 case GL_RGBA4:
361 case GL_RGBA2:
362 if (pipe->is_format_supported( pipe, PIPE_FORMAT_A4R4G4B4_UNORM, surfType ))
363 return PIPE_FORMAT_A4R4G4B4_UNORM;
364 return default_rgba_format( pipe, surfType );
365
366 case GL_RGB5_A1:
367 if (pipe->is_format_supported( pipe, PIPE_FORMAT_A1R5G5B5_UNORM, surfType ))
368 return PIPE_FORMAT_A1R5G5B5_UNORM;
369 return default_rgba_format( pipe, surfType );
370
371 case GL_RGB8:
372 case GL_RGB10:
373 case GL_RGB12:
374 case GL_RGB16:
375 return default_rgba_format( pipe, surfType );
376
377 case GL_RGB5:
378 case GL_RGB4:
379 case GL_R3_G3_B2:
380 if (pipe->is_format_supported( pipe, PIPE_FORMAT_A1R5G5B5_UNORM, surfType ))
381 return PIPE_FORMAT_A1R5G5B5_UNORM;
382 if (pipe->is_format_supported( pipe, PIPE_FORMAT_R5G6B5_UNORM, surfType ))
383 return PIPE_FORMAT_R5G6B5_UNORM;
384 return default_rgba_format( pipe, surfType );
385
386 case GL_ALPHA:
387 case GL_ALPHA4:
388 case GL_ALPHA8:
389 case GL_ALPHA12:
390 case GL_ALPHA16:
391 case GL_COMPRESSED_ALPHA:
392 if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A8, surfType ))
393 return PIPE_FORMAT_U_A8;
394 return default_rgba_format( pipe, surfType );
395
396 case 1:
397 case GL_LUMINANCE:
398 case GL_LUMINANCE4:
399 case GL_LUMINANCE8:
400 case GL_LUMINANCE12:
401 case GL_LUMINANCE16:
402 case GL_COMPRESSED_LUMINANCE:
403 if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_L8, surfType ))
404 return PIPE_FORMAT_U_A8;
405 return default_rgba_format( pipe, surfType );
406
407 case 2:
408 case GL_LUMINANCE_ALPHA:
409 case GL_LUMINANCE4_ALPHA4:
410 case GL_LUMINANCE6_ALPHA2:
411 case GL_LUMINANCE8_ALPHA8:
412 case GL_LUMINANCE12_ALPHA4:
413 case GL_LUMINANCE12_ALPHA12:
414 case GL_LUMINANCE16_ALPHA16:
415 case GL_COMPRESSED_LUMINANCE_ALPHA:
416 if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A8_L8, surfType ))
417 return PIPE_FORMAT_U_A8_L8;
418 return default_rgba_format( pipe, surfType );
419
420 case GL_INTENSITY:
421 case GL_INTENSITY4:
422 case GL_INTENSITY8:
423 case GL_INTENSITY12:
424 case GL_INTENSITY16:
425 case GL_COMPRESSED_INTENSITY:
426 if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_I8, surfType ))
427 return PIPE_FORMAT_U_I8;
428 return default_rgba_format( pipe, surfType );
429
430 #if 0
431 /* not supported for renderbuffers */
432 case GL_YCBCR_MESA:
433 return PIPE_FORMAT_NONE;
434 case GL_COMPRESSED_RGB_FXT1_3DFX:
435 return &_mesa_texformat_rgb_fxt1;
436 case GL_COMPRESSED_RGBA_FXT1_3DFX:
437 return &_mesa_texformat_rgba_fxt1;
438
439 case GL_RGB_S3TC:
440 case GL_RGB4_S3TC:
441 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
442 return &_mesa_texformat_rgb_dxt1;
443
444 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
445 return &_mesa_texformat_rgba_dxt1;
446
447 case GL_RGBA_S3TC:
448 case GL_RGBA4_S3TC:
449 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
450 return &_mesa_texformat_rgba_dxt3;
451
452 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
453 return &_mesa_texformat_rgba_dxt5;
454 #endif
455
456 case GL_DEPTH_COMPONENT16:
457 if (pipe->is_format_supported( pipe, PIPE_FORMAT_Z16_UNORM, surfType ))
458 return PIPE_FORMAT_Z16_UNORM;
459 /* fall-through */
460 case GL_DEPTH_COMPONENT24:
461 if (pipe->is_format_supported( pipe, PIPE_FORMAT_S8Z24_UNORM, surfType ))
462 return PIPE_FORMAT_S8Z24_UNORM;
463 if (pipe->is_format_supported( pipe, PIPE_FORMAT_Z24S8_UNORM, surfType ))
464 return PIPE_FORMAT_Z24S8_UNORM;
465 /* fall-through */
466 case GL_DEPTH_COMPONENT32:
467 if (pipe->is_format_supported( pipe, PIPE_FORMAT_Z32_UNORM, surfType ))
468 return PIPE_FORMAT_Z32_UNORM;
469 /* fall-through */
470 case GL_DEPTH_COMPONENT:
471 return default_depth_format( pipe, surfType );
472
473 case GL_STENCIL_INDEX:
474 case GL_STENCIL_INDEX1_EXT:
475 case GL_STENCIL_INDEX4_EXT:
476 case GL_STENCIL_INDEX8_EXT:
477 case GL_STENCIL_INDEX16_EXT:
478 if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_S8, surfType ))
479 return PIPE_FORMAT_U_S8;
480 if (pipe->is_format_supported( pipe, PIPE_FORMAT_S8Z24_UNORM, surfType ))
481 return PIPE_FORMAT_S8Z24_UNORM;
482 if (pipe->is_format_supported( pipe, PIPE_FORMAT_Z24S8_UNORM, surfType ))
483 return PIPE_FORMAT_Z24S8_UNORM;
484 return PIPE_FORMAT_NONE;
485
486 case GL_DEPTH_STENCIL_EXT:
487 case GL_DEPTH24_STENCIL8_EXT:
488 if (pipe->is_format_supported( pipe, PIPE_FORMAT_S8Z24_UNORM, surfType ))
489 return PIPE_FORMAT_S8Z24_UNORM;
490 if (pipe->is_format_supported( pipe, PIPE_FORMAT_Z24S8_UNORM, surfType ))
491 return PIPE_FORMAT_Z24S8_UNORM;
492 return PIPE_FORMAT_NONE;
493
494 default:
495 return PIPE_FORMAT_NONE;
496 }
497 }
498
499
500
501 /* It works out that this function is fine for all the supported
502 * hardware. However, there is still a need to map the formats onto
503 * hardware descriptors.
504 */
505 /* Note that the i915 can actually support many more formats than
506 * these if we take the step of simply swizzling the colors
507 * immediately after sampling...
508 */
509 const struct gl_texture_format *
510 st_ChooseTextureFormat(GLcontext * ctx, GLint internalFormat,
511 GLenum format, GLenum type)
512 {
513 #if 0
514 struct intel_context *intel = intel_context(ctx);
515 const GLboolean do32bpt = (intel->intelScreen->front.cpp == 4);
516 #else
517 const GLboolean do32bpt = 1;
518 #endif
519
520 (void) ctx;
521
522 switch (internalFormat) {
523 case 4:
524 case GL_RGBA:
525 case GL_COMPRESSED_RGBA:
526 if (format == GL_BGRA) {
527 if (type == GL_UNSIGNED_BYTE || type == GL_UNSIGNED_INT_8_8_8_8_REV) {
528 return &_mesa_texformat_argb8888;
529 }
530 else if (type == GL_UNSIGNED_SHORT_4_4_4_4_REV) {
531 return &_mesa_texformat_argb4444;
532 }
533 else if (type == GL_UNSIGNED_SHORT_1_5_5_5_REV) {
534 return &_mesa_texformat_argb1555;
535 }
536 }
537 return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
538
539 case 3:
540 case GL_RGB:
541 case GL_COMPRESSED_RGB:
542 if (format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5) {
543 return &_mesa_texformat_rgb565;
544 }
545 return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565;
546
547 case GL_RGBA8:
548 case GL_RGB10_A2:
549 case GL_RGBA12:
550 case GL_RGBA16:
551 return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
552
553 case GL_RGBA4:
554 case GL_RGBA2:
555 return &_mesa_texformat_argb4444;
556
557 case GL_RGB5_A1:
558 return &_mesa_texformat_argb1555;
559
560 case GL_RGB8:
561 case GL_RGB10:
562 case GL_RGB12:
563 case GL_RGB16:
564 return &_mesa_texformat_argb8888;
565
566 case GL_RGB5:
567 case GL_RGB4:
568 case GL_R3_G3_B2:
569 return &_mesa_texformat_rgb565;
570
571 case GL_ALPHA:
572 case GL_ALPHA4:
573 case GL_ALPHA8:
574 case GL_ALPHA12:
575 case GL_ALPHA16:
576 case GL_COMPRESSED_ALPHA:
577 return &_mesa_texformat_a8;
578
579 case 1:
580 case GL_LUMINANCE:
581 case GL_LUMINANCE4:
582 case GL_LUMINANCE8:
583 case GL_LUMINANCE12:
584 case GL_LUMINANCE16:
585 case GL_COMPRESSED_LUMINANCE:
586 return &_mesa_texformat_l8;
587
588 case 2:
589 case GL_LUMINANCE_ALPHA:
590 case GL_LUMINANCE4_ALPHA4:
591 case GL_LUMINANCE6_ALPHA2:
592 case GL_LUMINANCE8_ALPHA8:
593 case GL_LUMINANCE12_ALPHA4:
594 case GL_LUMINANCE12_ALPHA12:
595 case GL_LUMINANCE16_ALPHA16:
596 case GL_COMPRESSED_LUMINANCE_ALPHA:
597 return &_mesa_texformat_al88;
598
599 case GL_INTENSITY:
600 case GL_INTENSITY4:
601 case GL_INTENSITY8:
602 case GL_INTENSITY12:
603 case GL_INTENSITY16:
604 case GL_COMPRESSED_INTENSITY:
605 return &_mesa_texformat_i8;
606
607 case GL_YCBCR_MESA:
608 if (type == GL_UNSIGNED_SHORT_8_8_MESA || type == GL_UNSIGNED_BYTE)
609 return &_mesa_texformat_ycbcr;
610 else
611 return &_mesa_texformat_ycbcr_rev;
612
613 case GL_COMPRESSED_RGB_FXT1_3DFX:
614 return &_mesa_texformat_rgb_fxt1;
615 case GL_COMPRESSED_RGBA_FXT1_3DFX:
616 return &_mesa_texformat_rgba_fxt1;
617
618 case GL_RGB_S3TC:
619 case GL_RGB4_S3TC:
620 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
621 return &_mesa_texformat_rgb_dxt1;
622
623 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
624 return &_mesa_texformat_rgba_dxt1;
625
626 case GL_RGBA_S3TC:
627 case GL_RGBA4_S3TC:
628 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
629 return &_mesa_texformat_rgba_dxt3;
630
631 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
632 return &_mesa_texformat_rgba_dxt5;
633
634 case GL_DEPTH_COMPONENT:
635 case GL_DEPTH_COMPONENT16:
636 case GL_DEPTH_COMPONENT24:
637 case GL_DEPTH_COMPONENT32:
638 return &_mesa_texformat_z16;
639
640 case GL_DEPTH_STENCIL_EXT:
641 case GL_DEPTH24_STENCIL8_EXT:
642 return &_mesa_texformat_z24_s8;
643
644 default:
645 fprintf(stderr, "unexpected texture format %s in %s\n",
646 _mesa_lookup_enum_by_nr(internalFormat), __FUNCTION__);
647 return NULL;
648 }
649
650 return NULL; /* never get here */
651 }