More texture format updates. Drivers now need only plug an appropriate
[mesa.git] / src / mesa / main / texstore.c
1 /* $Id: texstore.c,v 1.21 2001/03/28 20:40:51 gareth Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 3.5
6 *
7 * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 */
26
27 /*
28 * Authors:
29 * Brian Paul
30 */
31
32
33 /*
34 * The functions in this file are mostly related to software texture fallbacks.
35 * This includes texture image transfer/packing and texel fetching.
36 * Hardware drivers will likely override most of this.
37 */
38
39
40
41 #include "colormac.h"
42 #include "context.h"
43 #include "convolve.h"
44 #include "image.h"
45 #include "macros.h"
46 #include "mem.h"
47 #include "texformat.h"
48 #include "teximage.h"
49 #include "texstore.h"
50
51
52 /*
53 * Given an internal texture format enum or 1, 2, 3, 4 return the
54 * corresponding _base_ internal format: GL_ALPHA, GL_LUMINANCE,
55 * GL_LUMANCE_ALPHA, GL_INTENSITY, GL_RGB, or GL_RGBA. Return the
56 * number of components for the format. Return -1 if invalid enum.
57 *
58 * GH: Do we really need this? We have the number of bytes per texel
59 * in the texture format structures, so why don't we just use that?
60 */
61 static GLint
62 components_in_intformat( GLint format )
63 {
64 switch (format) {
65 case GL_ALPHA:
66 case GL_ALPHA4:
67 case GL_ALPHA8:
68 case GL_ALPHA12:
69 case GL_ALPHA16:
70 return 1;
71 case 1:
72 case GL_LUMINANCE:
73 case GL_LUMINANCE4:
74 case GL_LUMINANCE8:
75 case GL_LUMINANCE12:
76 case GL_LUMINANCE16:
77 return 1;
78 case 2:
79 case GL_LUMINANCE_ALPHA:
80 case GL_LUMINANCE4_ALPHA4:
81 case GL_LUMINANCE6_ALPHA2:
82 case GL_LUMINANCE8_ALPHA8:
83 case GL_LUMINANCE12_ALPHA4:
84 case GL_LUMINANCE12_ALPHA12:
85 case GL_LUMINANCE16_ALPHA16:
86 return 2;
87 case GL_INTENSITY:
88 case GL_INTENSITY4:
89 case GL_INTENSITY8:
90 case GL_INTENSITY12:
91 case GL_INTENSITY16:
92 return 1;
93 case 3:
94 case GL_RGB:
95 case GL_R3_G3_B2:
96 case GL_RGB4:
97 case GL_RGB5:
98 case GL_RGB8:
99 case GL_RGB10:
100 case GL_RGB12:
101 case GL_RGB16:
102 return 3;
103 case 4:
104 case GL_RGBA:
105 case GL_RGBA2:
106 case GL_RGBA4:
107 case GL_RGB5_A1:
108 case GL_RGBA8:
109 case GL_RGB10_A2:
110 case GL_RGBA12:
111 case GL_RGBA16:
112 return 4;
113 case GL_COLOR_INDEX:
114 case GL_COLOR_INDEX1_EXT:
115 case GL_COLOR_INDEX2_EXT:
116 case GL_COLOR_INDEX4_EXT:
117 case GL_COLOR_INDEX8_EXT:
118 case GL_COLOR_INDEX12_EXT:
119 case GL_COLOR_INDEX16_EXT:
120 return 1;
121 case GL_DEPTH_COMPONENT:
122 case GL_DEPTH_COMPONENT16_SGIX:
123 case GL_DEPTH_COMPONENT24_SGIX:
124 case GL_DEPTH_COMPONENT32_SGIX:
125 return 1;
126 default:
127 return -1; /* error */
128 }
129 }
130
131
132 /*
133 * This function is used to transfer the user's image data into a texture
134 * image buffer. We handle both full texture images and subtexture images.
135 * We also take care of all image transfer operations here, including
136 * convolution, scale/bias, colortables, etc.
137 *
138 * The destination texel channel type is always GLchan.
139 *
140 * A hardware driver may use this as a helper routine to unpack and
141 * apply pixel transfer ops into a temporary image buffer. Then,
142 * convert the temporary image into the special hardware format.
143 *
144 * Input:
145 * dimensions - 1, 2, or 3
146 * texFormat - GL_LUMINANCE, GL_INTENSITY, GL_LUMINANCE_ALPHA, GL_ALPHA,
147 * GL_RGB or GL_RGBA
148 * texDestAddr - destination image address
149 * srcWidth, srcHeight, srcDepth - size (in pixels) of src and dest images
150 * dstXoffset, dstYoffset, dstZoffset - position to store the image within
151 * the destination 3D texture
152 * dstRowStride, dstImageStride - dest image strides in bytes
153 * srcFormat - source image format (GL_ALPHA, GL_RED, GL_RGB, etc)
154 * srcType - GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT_5_6_5, GL_FLOAT, etc
155 * srcPacking - describes packing of incoming image.
156 */
157 void
158 _mesa_transfer_teximage(GLcontext *ctx, GLuint dimensions,
159 GLenum texDestFormat, GLvoid *texDestAddr,
160 GLint srcWidth, GLint srcHeight, GLint srcDepth,
161 GLint dstXoffset, GLint dstYoffset, GLint dstZoffset,
162 GLint dstRowStride, GLint dstImageStride,
163 GLenum srcFormat, GLenum srcType,
164 const GLvoid *srcAddr,
165 const struct gl_pixelstore_attrib *srcPacking)
166 {
167 GLint texComponents;
168
169 ASSERT(ctx);
170 ASSERT(dimensions >= 1 && dimensions <= 3);
171 ASSERT(texDestAddr);
172 ASSERT(srcWidth >= 1);
173 ASSERT(srcHeight >= 1);
174 ASSERT(srcDepth >= 1);
175 ASSERT(dstXoffset >= 0);
176 ASSERT(dstYoffset >= 0);
177 ASSERT(dstZoffset >= 0);
178 ASSERT(dstRowStride >= 0);
179 ASSERT(dstImageStride >= 0);
180 ASSERT(srcAddr);
181 ASSERT(srcPacking);
182
183 texComponents = components_in_intformat(texDestFormat);
184
185 /* try common 2D texture cases first */
186 if (!ctx->_ImageTransferState && dimensions == 2 && srcType == CHAN_TYPE) {
187
188 if (srcFormat == texDestFormat) {
189 /* This will cover the common GL_RGB, GL_RGBA, GL_ALPHA,
190 * GL_LUMINANCE_ALPHA, etc. texture formats. Use memcpy().
191 */
192 const GLchan *src = (const GLchan *) _mesa_image_address(
193 srcPacking, srcAddr, srcWidth, srcHeight,
194 srcFormat, srcType, 0, 0, 0);
195 const GLint srcRowStride = _mesa_image_row_stride(srcPacking,
196 srcWidth, srcFormat, srcType);
197 const GLint widthInBytes = srcWidth * texComponents * sizeof(GLchan);
198 GLchan *dst = (GLchan *) texDestAddr + dstYoffset * dstRowStride
199 + dstXoffset * texComponents;
200 if (srcRowStride == widthInBytes && dstRowStride == widthInBytes) {
201 MEMCPY(dst, src, srcHeight * widthInBytes);
202 }
203 else {
204 GLint i;
205 for (i = 0; i < srcHeight; i++) {
206 MEMCPY(dst, src, widthInBytes);
207 src += srcRowStride;
208 dst += dstRowStride;
209 }
210 }
211 return; /* all done */
212 }
213 else if (srcFormat == GL_RGBA && texDestFormat == GL_RGB) {
214 /* commonly used by Quake */
215 const GLchan *src = (const GLchan *) _mesa_image_address(
216 srcPacking, srcAddr, srcWidth, srcHeight,
217 srcFormat, srcType, 0, 0, 0);
218 const GLint srcRowStride = _mesa_image_row_stride(srcPacking,
219 srcWidth, srcFormat, srcType);
220 GLchan *dst = (GLchan *) texDestAddr + dstYoffset * dstRowStride
221 + dstXoffset * texComponents;
222 GLint i, j;
223 for (i = 0; i < srcHeight; i++) {
224 const GLchan *s = src;
225 GLchan *d = dst;
226 for (j = 0; j < srcWidth; j++) {
227 *d++ = *s++; /*red*/
228 *d++ = *s++; /*green*/
229 *d++ = *s++; /*blue*/
230 s++; /*alpha*/
231 }
232 src += srcRowStride;
233 dst += dstRowStride;
234 }
235 return; /* all done */
236 }
237 }
238
239 /*
240 * General case solutions
241 */
242 if (texDestFormat == GL_COLOR_INDEX) {
243 /* color index texture */
244 const GLenum texType = CHAN_TYPE;
245 GLint img, row;
246 GLchan *dest = (GLchan *) texDestAddr + dstZoffset * dstImageStride
247 + dstYoffset * dstRowStride
248 + dstXoffset * texComponents;
249 for (img = 0; img < srcDepth; img++) {
250 GLchan *destRow = dest;
251 for (row = 0; row < srcHeight; row++) {
252 const GLvoid *src = _mesa_image_address(srcPacking,
253 srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
254 _mesa_unpack_index_span(ctx, srcWidth, texType, destRow,
255 srcType, src, srcPacking,
256 ctx->_ImageTransferState);
257 destRow += dstRowStride;
258 }
259 dest += dstImageStride;
260 }
261 }
262 else if (texDestFormat == GL_DEPTH_COMPONENT) {
263 /* Depth texture (shadow maps) */
264 GLint img, row;
265 GLubyte *dest = (GLubyte *) texDestAddr
266 + dstZoffset * dstImageStride
267 + dstYoffset * dstRowStride
268 + dstXoffset * texComponents;
269 for (img = 0; img < srcDepth; img++) {
270 GLubyte *destRow = dest;
271 for (row = 0; row < srcHeight; row++) {
272 const GLvoid *src = _mesa_image_address(srcPacking,
273 srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
274 _mesa_unpack_depth_span(ctx, srcWidth, (GLfloat *) destRow,
275 srcType, src, srcPacking);
276 destRow += dstRowStride;
277 }
278 dest += dstImageStride;
279 }
280 }
281 else {
282 /* regular, color texture */
283 if ((dimensions == 1 && ctx->Pixel.Convolution1DEnabled) ||
284 (dimensions >= 2 && ctx->Pixel.Convolution2DEnabled) ||
285 (dimensions >= 2 && ctx->Pixel.Separable2DEnabled)) {
286 /*
287 * Fill texture image with convolution
288 */
289 GLint img, row;
290 GLint convWidth = srcWidth, convHeight = srcHeight;
291 GLfloat *tmpImage, *convImage;
292 tmpImage = (GLfloat *) MALLOC(srcWidth * srcHeight * 4 * sizeof(GLfloat));
293 if (!tmpImage) {
294 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
295 return;
296 }
297 convImage = (GLfloat *) MALLOC(srcWidth * srcHeight * 4 * sizeof(GLfloat));
298 if (!convImage) {
299 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
300 FREE(tmpImage);
301 return;
302 }
303
304 for (img = 0; img < srcDepth; img++) {
305 const GLfloat *srcf;
306 GLfloat *dstf = tmpImage;
307 GLchan *dest;
308
309 /* unpack and do transfer ops up to convolution */
310 for (row = 0; row < srcHeight; row++) {
311 const GLvoid *src = _mesa_image_address(srcPacking,
312 srcAddr, srcWidth, srcHeight,
313 srcFormat, srcType, img, row, 0);
314 _mesa_unpack_float_color_span(ctx, srcWidth, GL_RGBA, dstf,
315 srcFormat, srcType, src, srcPacking,
316 ctx->_ImageTransferState & IMAGE_PRE_CONVOLUTION_BITS,
317 GL_TRUE);
318 dstf += srcWidth * 4;
319 }
320
321 /* convolve */
322 if (dimensions == 1) {
323 ASSERT(ctx->Pixel.Convolution1DEnabled);
324 _mesa_convolve_1d_image(ctx, &convWidth, tmpImage, convImage);
325 }
326 else {
327 if (ctx->Pixel.Convolution2DEnabled) {
328 _mesa_convolve_2d_image(ctx, &convWidth, &convHeight,
329 tmpImage, convImage);
330 }
331 else {
332 ASSERT(ctx->Pixel.Separable2DEnabled);
333 _mesa_convolve_sep_image(ctx, &convWidth, &convHeight,
334 tmpImage, convImage);
335 }
336 }
337
338 /* packing and transfer ops after convolution */
339 srcf = convImage;
340 dest = (GLchan *) texDestAddr + (dstZoffset + img) * dstImageStride
341 + dstYoffset * dstRowStride;
342 for (row = 0; row < convHeight; row++) {
343 _mesa_pack_float_rgba_span(ctx, convWidth,
344 (const GLfloat (*)[4]) srcf,
345 texDestFormat, CHAN_TYPE,
346 dest, &_mesa_native_packing,
347 ctx->_ImageTransferState
348 & IMAGE_POST_CONVOLUTION_BITS);
349 srcf += convWidth * 4;
350 dest += dstRowStride;
351 }
352 }
353
354 FREE(convImage);
355 FREE(tmpImage);
356 }
357 else {
358 /*
359 * no convolution
360 */
361 GLint img, row;
362 GLchan *dest = (GLchan *) texDestAddr + dstZoffset * dstImageStride
363 + dstYoffset * dstRowStride
364 + dstXoffset * texComponents;
365 for (img = 0; img < srcDepth; img++) {
366 GLchan *destRow = dest;
367 for (row = 0; row < srcHeight; row++) {
368 const GLvoid *srcRow = _mesa_image_address(srcPacking,
369 srcAddr, srcWidth, srcHeight,
370 srcFormat, srcType, img, row, 0);
371 _mesa_unpack_chan_color_span(ctx, srcWidth, texDestFormat,
372 destRow, srcFormat, srcType, srcRow,
373 srcPacking, ctx->_ImageTransferState);
374 destRow += dstRowStride;
375 }
376 dest += dstImageStride;
377 }
378 }
379 }
380 }
381
382
383
384 /*
385 * This is the software fallback for Driver.TexImage1D().
386 * The texture image type will be GLchan.
387 * The texture image format will be GL_COLOR_INDEX, GL_INTENSITY,
388 * GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_ALPHA, GL_RGB or GL_RGBA.
389 *
390 */
391 void
392 _mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level,
393 GLint internalFormat,
394 GLint width, GLint border,
395 GLenum format, GLenum type, const GLvoid *pixels,
396 const struct gl_pixelstore_attrib *packing,
397 struct gl_texture_object *texObj,
398 struct gl_texture_image *texImage)
399 {
400 GLint postConvWidth = width;
401 GLint texelBytes;
402
403 if (ctx->_ImageTransferState & IMAGE_CONVOLUTION_BIT) {
404 _mesa_adjust_image_for_convolution(ctx, 1, &postConvWidth, NULL);
405 }
406
407 /* setup the teximage struct's fields */
408 _mesa_init_tex_format( ctx, internalFormat, texImage );
409
410 texelBytes = texImage->TexFormat->TexelBytes;
411
412 /* allocate memory */
413 texImage->Data = (GLchan *) MALLOC(postConvWidth * texelBytes);
414 if (!texImage->Data)
415 return; /* out of memory */
416
417 /* unpack image, apply transfer ops and store in texImage->Data */
418 _mesa_transfer_teximage(ctx, 1, texImage->Format, texImage->Data,
419 width, 1, 1, 0, 0, 0,
420 0, /* dstRowStride */
421 0, /* dstImageStride */
422 format, type, pixels, packing);
423 }
424
425
426 /*
427 * This is the software fallback for Driver.TexImage2D().
428 * The texture image type will be GLchan.
429 * The texture image format will be GL_COLOR_INDEX, GL_INTENSITY,
430 * GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_ALPHA, GL_RGB or GL_RGBA.
431 *
432 */
433 void
434 _mesa_store_teximage2d(GLcontext *ctx, GLenum target, GLint level,
435 GLint internalFormat,
436 GLint width, GLint height, GLint border,
437 GLenum format, GLenum type, const void *pixels,
438 const struct gl_pixelstore_attrib *packing,
439 struct gl_texture_object *texObj,
440 struct gl_texture_image *texImage)
441 {
442 GLint postConvWidth = width, postConvHeight = height;
443 GLint texelBytes;
444
445 if (ctx->_ImageTransferState & IMAGE_CONVOLUTION_BIT) {
446 _mesa_adjust_image_for_convolution(ctx, 2, &postConvWidth,
447 &postConvHeight);
448 }
449
450 /* setup the teximage struct's fields */
451 _mesa_init_tex_format( ctx, internalFormat, texImage );
452
453 texelBytes = texImage->TexFormat->TexelBytes;
454
455 /* allocate memory */
456 texImage->Data = (GLchan *) MALLOC(postConvWidth * postConvHeight *
457 texelBytes);
458 if (!texImage->Data)
459 return; /* out of memory */
460
461 /* unpack image, apply transfer ops and store in texImage->Data */
462 _mesa_transfer_teximage(ctx, 2, texImage->Format, texImage->Data,
463 width, height, 1, 0, 0, 0,
464 texImage->Width * texelBytes,
465 0, /* dstImageStride */
466 format, type, pixels, packing);
467 }
468
469
470
471 /*
472 * This is the software fallback for Driver.TexImage3D().
473 * The texture image type will be GLchan.
474 * The texture image format will be GL_COLOR_INDEX, GL_INTENSITY,
475 * GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_ALPHA, GL_RGB or GL_RGBA.
476 *
477 */
478 void
479 _mesa_store_teximage3d(GLcontext *ctx, GLenum target, GLint level,
480 GLint internalFormat,
481 GLint width, GLint height, GLint depth, GLint border,
482 GLenum format, GLenum type, const void *pixels,
483 const struct gl_pixelstore_attrib *packing,
484 struct gl_texture_object *texObj,
485 struct gl_texture_image *texImage)
486 {
487 GLint texelBytes;
488
489 /* setup the teximage struct's fields */
490 _mesa_init_tex_format( ctx, internalFormat, texImage );
491
492 texelBytes = texImage->TexFormat->TexelBytes;
493
494 /* allocate memory */
495 texImage->Data = (GLchan *) MALLOC(width * height * depth * texelBytes);
496 if (!texImage->Data)
497 return; /* out of memory */
498
499 /* unpack image, apply transfer ops and store in texImage->Data */
500 _mesa_transfer_teximage(ctx, 3, texImage->Format, texImage->Data,
501 width, height, depth, 0, 0, 0,
502 texImage->Width * texelBytes,
503 texImage->Width * texImage->Height * texelBytes,
504 format, type, pixels, packing);
505 }
506
507
508
509
510 /*
511 * This is the software fallback for Driver.TexSubImage1D().
512 */
513 void
514 _mesa_store_texsubimage1d(GLcontext *ctx, GLenum target, GLint level,
515 GLint xoffset, GLint width,
516 GLenum format, GLenum type, const void *pixels,
517 const struct gl_pixelstore_attrib *packing,
518 struct gl_texture_object *texObj,
519 struct gl_texture_image *texImage)
520 {
521 _mesa_transfer_teximage(ctx, 1, texImage->Format, texImage->Data,
522 width, 1, 1, /* src size */
523 xoffset, 0, 0, /* dest offsets */
524 0, /* dstRowStride */
525 0, /* dstImageStride */
526 format, type, pixels, packing);
527 }
528
529
530 /*
531 * This is the software fallback for Driver.TexSubImage2D().
532 */
533 void
534 _mesa_store_texsubimage2d(GLcontext *ctx, GLenum target, GLint level,
535 GLint xoffset, GLint yoffset,
536 GLint width, GLint height,
537 GLenum format, GLenum type, const void *pixels,
538 const struct gl_pixelstore_attrib *packing,
539 struct gl_texture_object *texObj,
540 struct gl_texture_image *texImage)
541 {
542 _mesa_transfer_teximage(ctx, 2, texImage->Format, texImage->Data,
543 width, height, 1, /* src size */
544 xoffset, yoffset, 0, /* dest offsets */
545 texImage->Width * texImage->TexFormat->TexelBytes,
546 0, /* dstImageStride */
547 format, type, pixels, packing);
548 }
549
550
551 /*
552 * This is the software fallback for Driver.TexSubImage3D().
553 */
554 void
555 _mesa_store_texsubimage3d(GLcontext *ctx, GLenum target, GLint level,
556 GLint xoffset, GLint yoffset, GLint zoffset,
557 GLint width, GLint height, GLint depth,
558 GLenum format, GLenum type, const void *pixels,
559 const struct gl_pixelstore_attrib *packing,
560 struct gl_texture_object *texObj,
561 struct gl_texture_image *texImage)
562 {
563 const GLint texelBytes = texImage->TexFormat->TexelBytes;
564 _mesa_transfer_teximage(ctx, 3, texImage->Format, texImage->Data,
565 width, height, depth, /* src size */
566 xoffset, yoffset, xoffset, /* dest offsets */
567 texImage->Width * texelBytes,
568 texImage->Width * texImage->Height * texelBytes,
569 format, type, pixels, packing);
570 }
571
572
573
574
575 /*
576 * Fallback for Driver.CompressedTexImage1D()
577 */
578 void
579 _mesa_store_compressed_teximage1d(GLcontext *ctx, GLenum target, GLint level,
580 GLint internalFormat,
581 GLint width, GLint border,
582 GLsizei imageSize, const GLvoid *data,
583 struct gl_texture_object *texObj,
584 struct gl_texture_image *texImage)
585 {
586 /* Nothing here.
587 * The device driver has to do it all.
588 */
589 }
590
591
592
593 /*
594 * Fallback for Driver.CompressedTexImage2D()
595 */
596 void
597 _mesa_store_compressed_teximage2d(GLcontext *ctx, GLenum target, GLint level,
598 GLint internalFormat,
599 GLint width, GLint height, GLint border,
600 GLsizei imageSize, const GLvoid *data,
601 struct gl_texture_object *texObj,
602 struct gl_texture_image *texImage)
603 {
604 /* Nothing here.
605 * The device driver has to do it all.
606 */
607 }
608
609
610
611 /*
612 * Fallback for Driver.CompressedTexImage3D()
613 */
614 void
615 _mesa_store_compressed_teximage3d(GLcontext *ctx, GLenum target, GLint level,
616 GLint internalFormat,
617 GLint width, GLint height, GLint depth,
618 GLint border,
619 GLsizei imageSize, const GLvoid *data,
620 struct gl_texture_object *texObj,
621 struct gl_texture_image *texImage)
622 {
623 /* Nothing here.
624 * The device driver has to do it all.
625 */
626 }
627
628
629
630
631
632
633 /*
634 * This is the fallback for Driver.TestProxyTexImage().
635 */
636 GLboolean
637 _mesa_test_proxy_teximage(GLcontext *ctx, GLenum target, GLint level,
638 GLint internalFormat, GLenum format, GLenum type,
639 GLint width, GLint height, GLint depth, GLint border)
640 {
641 struct gl_texture_unit *texUnit;
642 struct gl_texture_object *texObj;
643 struct gl_texture_image *texImage;
644
645 (void) format;
646 (void) type;
647
648 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
649 texObj = _mesa_select_tex_object(ctx, texUnit, target);
650 texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
651
652 /* We always pass.
653 * The core Mesa code will have already tested the image size, etc.
654 * Drivers may have more stringent texture limits to enforce and will
655 * have to override this function.
656 */
657 /* setup the teximage struct's fields */
658 _mesa_init_tex_format( ctx, internalFormat, texImage );
659
660 return GL_TRUE;
661 }