1 /**************************************************************************
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
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.
26 **************************************************************************/
28 #include "main/mfeatures.h"
30 #include "main/convolve.h"
32 #include "main/enums.h"
33 #include "main/image.h"
34 #include "main/imports.h"
35 #include "main/macros.h"
36 #include "main/mipmap.h"
37 #include "main/pixel.h"
38 #include "main/texcompress.h"
39 #include "main/texformat.h"
40 #include "main/texgetimage.h"
41 #include "main/teximage.h"
42 #include "main/texobj.h"
43 #include "main/texstore.h"
45 #include "state_tracker/st_context.h"
46 #include "state_tracker/st_cb_fbo.h"
47 #include "state_tracker/st_cb_texture.h"
48 #include "state_tracker/st_format.h"
49 #include "state_tracker/st_public.h"
50 #include "state_tracker/st_texture.h"
51 #include "state_tracker/st_gen_mipmap.h"
53 #include "pipe/p_context.h"
54 #include "pipe/p_defines.h"
55 #include "pipe/p_inlines.h"
56 #include "util/u_tile.h"
57 #include "util/u_blit.h"
60 #define DBG if (0) printf
63 static enum pipe_texture_target
64 gl_target_to_pipe(GLenum target
)
68 return PIPE_TEXTURE_1D
;
71 case GL_TEXTURE_RECTANGLE_NV
:
72 return PIPE_TEXTURE_2D
;
75 return PIPE_TEXTURE_3D
;
77 case GL_TEXTURE_CUBE_MAP_ARB
:
78 return PIPE_TEXTURE_CUBE
;
88 * Return nominal bytes per texel for a compressed format, 0 for non-compressed
92 compressed_num_bytes(GLuint mesaFormat
)
95 #if FEATURE_texture_fxt1
96 case MESA_FORMAT_RGB_FXT1
:
97 case MESA_FORMAT_RGBA_FXT1
:
99 #if FEATURE_texture_s3tc
100 case MESA_FORMAT_RGB_DXT1
:
101 case MESA_FORMAT_RGBA_DXT1
:
103 case MESA_FORMAT_RGBA_DXT3
:
104 case MESA_FORMAT_RGBA_DXT5
:
113 /** called via ctx->Driver.NewTextureImage() */
114 static struct gl_texture_image
*
115 st_NewTextureImage(GLcontext
* ctx
)
117 DBG("%s\n", __FUNCTION__
);
119 return (struct gl_texture_image
*) ST_CALLOC_STRUCT(st_texture_image
);
123 /** called via ctx->Driver.NewTextureObject() */
124 static struct gl_texture_object
*
125 st_NewTextureObject(GLcontext
* ctx
, GLuint name
, GLenum target
)
127 struct st_texture_object
*obj
= ST_CALLOC_STRUCT(st_texture_object
);
129 DBG("%s\n", __FUNCTION__
);
130 _mesa_initialize_texture_object(&obj
->base
, name
, target
);
135 /** called via ctx->Driver.DeleteTextureImage() */
137 st_DeleteTextureObject(GLcontext
*ctx
,
138 struct gl_texture_object
*texObj
)
140 struct st_texture_object
*stObj
= st_texture_object(texObj
);
142 pipe_texture_reference(&stObj
->pt
, NULL
);
144 _mesa_delete_texture_object(ctx
, texObj
);
148 /** called via ctx->Driver.FreeTexImageData() */
150 st_FreeTextureImageData(GLcontext
* ctx
, struct gl_texture_image
*texImage
)
152 struct st_texture_image
*stImage
= st_texture_image(texImage
);
154 DBG("%s\n", __FUNCTION__
);
157 pipe_texture_reference(&stImage
->pt
, NULL
);
160 if (texImage
->Data
) {
161 _mesa_align_free(texImage
->Data
);
162 texImage
->Data
= NULL
;
168 * From linux kernel i386 header files, copes with odd sizes better
169 * than COPY_DWORDS would:
170 * XXX Put this in src/mesa/main/imports.h ???
172 #if defined(i386) || defined(__i386__)
174 __memcpy(void *to
, const void *from
, size_t n
)
177 __asm__
__volatile__("rep ; movsl\n\t"
181 "1:\ttestb $1,%b4\n\t"
183 "movsb\n" "2:":"=&c"(d0
), "=&D"(d1
), "=&S"(d2
)
184 :"0"(n
/ 4), "q"(n
), "1"((long) to
), "2"((long) from
)
189 #define __memcpy(a,b,c) memcpy(a,b,c)
194 * The system memcpy (at least on ubuntu 5.10) has problems copying
195 * to agp (writecombined) memory from a source which isn't 64-byte
196 * aligned - there is a 4x performance falloff.
198 * The x86 __memcpy is immune to this but is slightly slower
199 * (10%-ish) than the system memcpy.
201 * The sse_memcpy seems to have a slight cliff at 64/32 bytes, but
202 * isn't much faster than x86_memcpy for agp copies.
204 * TODO: switch dynamically.
207 do_memcpy(void *dest
, const void *src
, size_t n
)
209 if ((((unsigned long) src
) & 63) || (((unsigned long) dest
) & 63)) {
210 return __memcpy(dest
, src
, n
);
213 return memcpy(dest
, src
, n
);
220 GLint i
= 1, log2
= 0;
230 * Allocate a pipe_texture object for the given st_texture_object using
231 * the given st_texture_image to guess the mipmap size/levels.
234 * Otherwise, store it in memory if (Border != 0) or (any dimension ==
237 * Otherwise, if max_level >= level >= min_level, create texture with
238 * space for images from min_level down to max_level.
240 * Otherwise, create texture with space for images from (level 0)..(1x1).
241 * Consider pruning this texture at a validation if the saving is worth it.
244 guess_and_alloc_texture(struct st_context
*st
,
245 struct st_texture_object
*stObj
,
246 const struct st_texture_image
*stImage
)
250 GLuint width
= stImage
->base
.Width2
; /* size w/out border */
251 GLuint height
= stImage
->base
.Height2
;
252 GLuint depth
= stImage
->base
.Depth2
;
253 GLuint i
, comp_byte
= 0;
254 enum pipe_format fmt
;
256 DBG("%s\n", __FUNCTION__
);
261 (GLint
) stImage
->level
> stObj
->base
.BaseLevel
&&
262 (stImage
->base
.Width
== 1 ||
263 (stObj
->base
.Target
!= GL_TEXTURE_1D
&&
264 stImage
->base
.Height
== 1) ||
265 (stObj
->base
.Target
== GL_TEXTURE_3D
&&
266 stImage
->base
.Depth
== 1)))
269 /* If this image disrespects BaseLevel, allocate from level zero.
270 * Usually BaseLevel == 0, so it's unlikely to happen.
272 if ((GLint
) stImage
->level
< stObj
->base
.BaseLevel
)
275 firstLevel
= stObj
->base
.BaseLevel
;
278 /* Figure out image dimensions at start level.
280 for (i
= stImage
->level
; i
> firstLevel
; i
--) {
289 if (width
== 0 || height
== 0 || depth
== 0) {
290 /* no texture needed */
294 /* Guess a reasonable value for lastLevel. This is probably going
295 * to be wrong fairly often and might mean that we have to look at
296 * resizable buffers, or require that buffers implement lazy
297 * pagetable arrangements.
299 if ((stObj
->base
.MinFilter
== GL_NEAREST
||
300 stObj
->base
.MinFilter
== GL_LINEAR
) &&
301 stImage
->level
== firstLevel
) {
302 lastLevel
= firstLevel
;
305 GLuint l2width
= logbase2(width
);
306 GLuint l2height
= logbase2(height
);
307 GLuint l2depth
= logbase2(depth
);
308 lastLevel
= firstLevel
+ MAX2(MAX2(l2width
, l2height
), l2depth
);
311 if (stImage
->base
.IsCompressed
)
312 comp_byte
= compressed_num_bytes(stImage
->base
.TexFormat
->MesaFormat
);
314 fmt
= st_mesa_format_to_pipe_format(stImage
->base
.TexFormat
->MesaFormat
);
315 stObj
->pt
= st_texture_create(st
,
316 gl_target_to_pipe(stObj
->base
.Target
),
323 ( (pf_is_depth_stencil(fmt
) ?
324 PIPE_TEXTURE_USAGE_DEPTH_STENCIL
:
325 PIPE_TEXTURE_USAGE_RENDER_TARGET
) |
326 PIPE_TEXTURE_USAGE_SAMPLER
));
328 DBG("%s - success\n", __FUNCTION__
);
333 * Adjust pixel unpack params and image dimensions to strip off the
335 * Gallium doesn't support texture borders. They've seldem been used
336 * and seldom been implemented correctly anyway.
337 * \param unpackNew returns the new pixel unpack parameters
340 strip_texture_border(GLint border
,
341 GLint
*width
, GLint
*height
, GLint
*depth
,
342 const struct gl_pixelstore_attrib
*unpack
,
343 struct gl_pixelstore_attrib
*unpackNew
)
345 assert(border
> 0); /* sanity check */
347 *unpackNew
= *unpack
;
349 if (unpackNew
->RowLength
== 0)
350 unpackNew
->RowLength
= *width
;
352 if (depth
&& unpackNew
->ImageHeight
== 0)
353 unpackNew
->ImageHeight
= *height
;
355 unpackNew
->SkipPixels
+= border
;
357 unpackNew
->SkipRows
+= border
;
359 unpackNew
->SkipImages
+= border
;
362 *width
= *width
- 2 * border
;
363 if (height
&& *height
>= 3)
364 *height
= *height
- 2 * border
;
365 if (depth
&& *depth
>= 3)
366 *depth
= *depth
- 2 * border
;
371 * Do glTexImage1/2/3D().
374 st_TexImage(GLcontext
* ctx
,
376 GLenum target
, GLint level
,
377 GLint internalFormat
,
378 GLint width
, GLint height
, GLint depth
,
380 GLenum format
, GLenum type
, const void *pixels
,
381 const struct gl_pixelstore_attrib
*unpack
,
382 struct gl_texture_object
*texObj
,
383 struct gl_texture_image
*texImage
,
384 GLsizei imageSize
, int compressed
)
386 struct st_texture_object
*stObj
= st_texture_object(texObj
);
387 struct st_texture_image
*stImage
= st_texture_image(texImage
);
388 GLint postConvWidth
, postConvHeight
;
389 GLint texelBytes
, sizeInBytes
;
391 struct gl_pixelstore_attrib unpackNB
;
393 DBG("%s target %s level %d %dx%dx%d border %d\n", __FUNCTION__
,
394 _mesa_lookup_enum_by_nr(target
), level
, width
, height
, depth
, border
);
396 /* gallium does not support texture borders, strip it off */
398 strip_texture_border(border
, &width
, &height
, &depth
,
401 texImage
->Width
= width
;
402 texImage
->Height
= height
;
403 texImage
->Depth
= depth
;
404 texImage
->Border
= 0;
408 postConvWidth
= width
;
409 postConvHeight
= height
;
411 stImage
->face
= _mesa_tex_target_to_face(target
);
412 stImage
->level
= level
;
415 if (ctx
->_ImageTransferState
& IMAGE_CONVOLUTION_BIT
) {
416 _mesa_adjust_image_for_convolution(ctx
, dims
, &postConvWidth
,
421 /* choose the texture format */
422 texImage
->TexFormat
= st_ChooseTextureFormat(ctx
, internalFormat
,
425 _mesa_set_fetch_functions(texImage
, dims
);
427 if (texImage
->TexFormat
->TexelBytes
== 0) {
428 /* must be a compressed format */
430 texImage
->IsCompressed
= GL_TRUE
;
431 texImage
->CompressedSize
=
432 ctx
->Driver
.CompressedTextureSize(ctx
, texImage
->Width
,
433 texImage
->Height
, texImage
->Depth
,
434 texImage
->TexFormat
->MesaFormat
);
437 texelBytes
= texImage
->TexFormat
->TexelBytes
;
439 /* Minimum pitch of 32 bytes */
440 if (postConvWidth
* texelBytes
< 32) {
441 postConvWidth
= 32 / texelBytes
;
442 texImage
->RowStride
= postConvWidth
;
445 /* we'll set RowStride elsewhere when the texture is a "mapped" state */
446 /*assert(texImage->RowStride == postConvWidth);*/
449 /* Release the reference to a potentially orphaned buffer.
450 * Release any old malloced memory.
453 pipe_texture_reference(&stImage
->pt
, NULL
);
454 assert(!texImage
->Data
);
456 else if (texImage
->Data
) {
457 _mesa_align_free(texImage
->Data
);
460 if (width
== 0 || height
== 0 || depth
== 0) {
461 /* stop after freeing old image */
465 /* If this is the only mipmap level in the texture, could call
466 * bmBufferData with NULL data to free the old block and avoid
467 * waiting on any outstanding fences.
470 if (stObj
->teximage_realloc
||
471 level
> (GLint
) stObj
->pt
->last_level
||
472 (stObj
->pt
->last_level
== level
&&
473 stObj
->pt
->target
!= PIPE_TEXTURE_CUBE
&&
474 !st_texture_match_image(stObj
->pt
, &stImage
->base
,
475 stImage
->face
, stImage
->level
))) {
477 pipe_texture_reference(&stObj
->pt
, NULL
);
479 stObj
->teximage_realloc
= FALSE
;
484 guess_and_alloc_texture(ctx
->st
, stObj
, stImage
);
486 /* Probably out of memory.
487 * Try flushing any pending rendering, then retry.
490 guess_and_alloc_texture(ctx
->st
, stObj
, stImage
);
492 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexImage");
498 assert(!stImage
->pt
);
501 st_texture_match_image(stObj
->pt
, &stImage
->base
,
502 stImage
->face
, stImage
->level
)) {
504 pipe_texture_reference(&stImage
->pt
, stObj
->pt
);
509 DBG("XXX: Image did not fit into texture - storing in local memory!\n");
511 /* st_CopyTexImage calls this function with pixels == NULL, with
512 * the expectation that the texture will be set up but nothing
513 * more will be done. This is where those calls return:
516 pixels
= _mesa_validate_pbo_compressed_teximage(ctx
, imageSize
, pixels
,
518 "glCompressedTexImage");
520 pixels
= _mesa_validate_pbo_teximage(ctx
, dims
, width
, height
, 1,
522 pixels
, unpack
, "glTexImage");
528 texImage
->Data
= st_texture_image_map(ctx
->st
, stImage
, 0,
529 PIPE_TRANSFER_WRITE
, 0, 0,
531 stImage
->base
.Height
);
532 dstRowStride
= stImage
->transfer
->stride
;
535 /* Allocate regular memory and store the image there temporarily. */
536 if (texImage
->IsCompressed
) {
537 sizeInBytes
= texImage
->CompressedSize
;
539 _mesa_compressed_row_stride(texImage
->TexFormat
->MesaFormat
, width
);
543 dstRowStride
= postConvWidth
* texelBytes
;
544 sizeInBytes
= depth
* dstRowStride
* postConvHeight
;
547 texImage
->Data
= _mesa_align_malloc(sizeInBytes
, 16);
550 if (!texImage
->Data
) {
551 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexImage");
555 DBG("Upload image %dx%dx%d row_len %x pitch %x\n",
556 width
, height
, depth
, width
* texelBytes
, dstRowStride
);
558 /* Copy data. Would like to know when it's ok for us to eg. use
559 * the blitter to copy. Or, use the hardware to do the format
560 * conversion and copy:
563 memcpy(texImage
->Data
, pixels
, imageSize
);
566 GLuint srcImageStride
= _mesa_image_image_stride(unpack
, width
, height
,
569 const GLubyte
*src
= (const GLubyte
*) pixels
;
571 for (i
= 0; i
++ < depth
;) {
572 if (!texImage
->TexFormat
->StoreImage(ctx
, dims
,
573 texImage
->_BaseFormat
,
576 0, 0, 0, /* dstX/Y/Zoffset */
578 texImage
->ImageOffsets
,
580 format
, type
, src
, unpack
)) {
581 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexImage");
584 if (stImage
->pt
&& i
< depth
) {
585 st_texture_image_unmap(ctx
->st
, stImage
);
586 texImage
->Data
= st_texture_image_map(ctx
->st
, stImage
, i
,
587 PIPE_TRANSFER_WRITE
, 0, 0,
589 stImage
->base
.Height
);
590 src
+= srcImageStride
;
595 _mesa_unmap_teximage_pbo(ctx
, unpack
);
598 st_texture_image_unmap(ctx
->st
, stImage
);
599 texImage
->Data
= NULL
;
602 if (level
== texObj
->BaseLevel
&& texObj
->GenerateMipmap
) {
603 ctx
->Driver
.GenerateMipmap(ctx
, target
, texObj
);
609 st_TexImage3D(GLcontext
* ctx
,
610 GLenum target
, GLint level
,
611 GLint internalFormat
,
612 GLint width
, GLint height
, GLint depth
,
614 GLenum format
, GLenum type
, const void *pixels
,
615 const struct gl_pixelstore_attrib
*unpack
,
616 struct gl_texture_object
*texObj
,
617 struct gl_texture_image
*texImage
)
619 st_TexImage(ctx
, 3, target
, level
,
620 internalFormat
, width
, height
, depth
, border
,
621 format
, type
, pixels
, unpack
, texObj
, texImage
, 0, 0);
626 st_TexImage2D(GLcontext
* ctx
,
627 GLenum target
, GLint level
,
628 GLint internalFormat
,
629 GLint width
, GLint height
, GLint border
,
630 GLenum format
, GLenum type
, const void *pixels
,
631 const struct gl_pixelstore_attrib
*unpack
,
632 struct gl_texture_object
*texObj
,
633 struct gl_texture_image
*texImage
)
635 st_TexImage(ctx
, 2, target
, level
,
636 internalFormat
, width
, height
, 1, border
,
637 format
, type
, pixels
, unpack
, texObj
, texImage
, 0, 0);
642 st_TexImage1D(GLcontext
* ctx
,
643 GLenum target
, GLint level
,
644 GLint internalFormat
,
645 GLint width
, GLint border
,
646 GLenum format
, GLenum type
, const void *pixels
,
647 const struct gl_pixelstore_attrib
*unpack
,
648 struct gl_texture_object
*texObj
,
649 struct gl_texture_image
*texImage
)
651 st_TexImage(ctx
, 1, target
, level
,
652 internalFormat
, width
, 1, 1, border
,
653 format
, type
, pixels
, unpack
, texObj
, texImage
, 0, 0);
658 st_CompressedTexImage2D(GLcontext
*ctx
, GLenum target
, GLint level
,
659 GLint internalFormat
,
660 GLint width
, GLint height
, GLint border
,
661 GLsizei imageSize
, const GLvoid
*data
,
662 struct gl_texture_object
*texObj
,
663 struct gl_texture_image
*texImage
)
665 st_TexImage(ctx
, 2, target
, level
,
666 internalFormat
, width
, height
, 1, border
,
667 0, 0, data
, &ctx
->Unpack
, texObj
, texImage
, imageSize
, 1);
672 * Need to map texture image into memory before copying image data,
676 st_get_tex_image(GLcontext
* ctx
, GLenum target
, GLint level
,
677 GLenum format
, GLenum type
, GLvoid
* pixels
,
678 struct gl_texture_object
*texObj
,
679 struct gl_texture_image
*texImage
, int compressed
)
681 struct st_texture_image
*stImage
= st_texture_image(texImage
);
682 GLuint dstImageStride
= _mesa_image_image_stride(&ctx
->Pack
,
692 /* Image is stored in hardware format in a buffer managed by the
693 * kernel. Need to explicitly map and unmap it.
695 texImage
->Data
= st_texture_image_map(ctx
->st
, stImage
, 0,
696 PIPE_TRANSFER_READ
, 0, 0,
698 stImage
->base
.Height
);
699 texImage
->RowStride
= stImage
->transfer
->stride
/ stImage
->pt
->block
.size
;
702 /* Otherwise, the image should actually be stored in
703 * texImage->Data. This is pretty confusing for
704 * everybody, I'd much prefer to separate the two functions of
705 * texImage->Data - storage for texture images in main memory
706 * and access (ie mappings) of images. In other words, we'd
707 * create a new texImage->Map field and leave Data simply for
710 assert(texImage
->Data
);
713 depth
= texImage
->Depth
;
716 dest
= (GLubyte
*) pixels
;
718 for (i
= 0; i
++ < depth
;) {
720 _mesa_get_compressed_teximage(ctx
, target
, level
, dest
,
723 _mesa_get_teximage(ctx
, target
, level
, format
, type
, dest
,
727 if (stImage
->pt
&& i
< depth
) {
728 st_texture_image_unmap(ctx
->st
, stImage
);
729 texImage
->Data
= st_texture_image_map(ctx
->st
, stImage
, i
,
730 PIPE_TRANSFER_READ
, 0, 0,
732 stImage
->base
.Height
);
733 dest
+= dstImageStride
;
737 texImage
->Depth
= depth
;
741 st_texture_image_unmap(ctx
->st
, stImage
);
742 texImage
->Data
= NULL
;
748 st_GetTexImage(GLcontext
* ctx
, GLenum target
, GLint level
,
749 GLenum format
, GLenum type
, GLvoid
* pixels
,
750 struct gl_texture_object
*texObj
,
751 struct gl_texture_image
*texImage
)
753 st_get_tex_image(ctx
, target
, level
, format
, type
, pixels
,
754 texObj
, texImage
, 0);
759 st_GetCompressedTexImage(GLcontext
*ctx
, GLenum target
, GLint level
,
761 struct gl_texture_object
*texObj
,
762 struct gl_texture_image
*texImage
)
764 st_get_tex_image(ctx
, target
, level
, 0, 0, pixels
,
765 (struct gl_texture_object
*) texObj
,
766 (struct gl_texture_image
*) texImage
, 1);
772 st_TexSubimage(GLcontext
* ctx
,
774 GLenum target
, GLint level
,
775 GLint xoffset
, GLint yoffset
, GLint zoffset
,
776 GLint width
, GLint height
, GLint depth
,
777 GLenum format
, GLenum type
, const void *pixels
,
778 const struct gl_pixelstore_attrib
*packing
,
779 struct gl_texture_object
*texObj
,
780 struct gl_texture_image
*texImage
)
782 struct st_texture_image
*stImage
= st_texture_image(texImage
);
784 GLuint srcImageStride
= _mesa_image_image_stride(packing
, width
, height
,
789 DBG("%s target %s level %d offset %d,%d %dx%d\n", __FUNCTION__
,
790 _mesa_lookup_enum_by_nr(target
),
791 level
, xoffset
, yoffset
, width
, height
);
794 _mesa_validate_pbo_teximage(ctx
, dims
, width
, height
, depth
, format
,
795 type
, pixels
, packing
, "glTexSubImage2D");
799 /* Map buffer if necessary. Need to lock to prevent other contexts
800 * from uploading the buffer under us.
803 texImage
->Data
= st_texture_image_map(ctx
->st
, stImage
, zoffset
,
809 if (!texImage
->Data
) {
810 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexSubImage");
814 src
= (const GLubyte
*) pixels
;
815 dstRowStride
= stImage
->transfer
->stride
;
817 for (i
= 0; i
++ < depth
;) {
818 if (!texImage
->TexFormat
->StoreImage(ctx
, dims
, texImage
->_BaseFormat
,
823 texImage
->ImageOffsets
,
825 format
, type
, src
, packing
)) {
826 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexSubImage");
829 if (stImage
->pt
&& i
< depth
) {
830 /* map next slice of 3D texture */
831 st_texture_image_unmap(ctx
->st
, stImage
);
832 texImage
->Data
= st_texture_image_map(ctx
->st
, stImage
, zoffset
+ i
,
836 src
+= srcImageStride
;
840 if (level
== texObj
->BaseLevel
&& texObj
->GenerateMipmap
) {
841 ctx
->Driver
.GenerateMipmap(ctx
, target
, texObj
);
844 _mesa_unmap_teximage_pbo(ctx
, packing
);
847 st_texture_image_unmap(ctx
->st
, stImage
);
848 texImage
->Data
= NULL
;
855 st_TexSubImage3D(GLcontext
* ctx
,
858 GLint xoffset
, GLint yoffset
, GLint zoffset
,
859 GLsizei width
, GLsizei height
, GLsizei depth
,
860 GLenum format
, GLenum type
,
861 const GLvoid
* pixels
,
862 const struct gl_pixelstore_attrib
*packing
,
863 struct gl_texture_object
*texObj
,
864 struct gl_texture_image
*texImage
)
866 st_TexSubimage(ctx
, 3, target
, level
,
867 xoffset
, yoffset
, zoffset
,
868 width
, height
, depth
,
869 format
, type
, pixels
, packing
, texObj
, texImage
);
874 st_TexSubImage2D(GLcontext
* ctx
,
877 GLint xoffset
, GLint yoffset
,
878 GLsizei width
, GLsizei height
,
879 GLenum format
, GLenum type
,
880 const GLvoid
* pixels
,
881 const struct gl_pixelstore_attrib
*packing
,
882 struct gl_texture_object
*texObj
,
883 struct gl_texture_image
*texImage
)
885 st_TexSubimage(ctx
, 2, target
, level
,
888 format
, type
, pixels
, packing
, texObj
, texImage
);
893 st_TexSubImage1D(GLcontext
* ctx
,
898 GLenum format
, GLenum type
,
899 const GLvoid
* pixels
,
900 const struct gl_pixelstore_attrib
*packing
,
901 struct gl_texture_object
*texObj
,
902 struct gl_texture_image
*texImage
)
904 st_TexSubimage(ctx
, 1, target
, level
,
907 format
, type
, pixels
, packing
, texObj
, texImage
);
913 * Do a CopyTexSubImage operation using a read transfer from the source, a write
914 * transfer to the destination and get_tile()/put_tile() to access the pixels/texels.
916 * Note: srcY=0=TOP of renderbuffer
919 fallback_copy_texsubimage(GLcontext
*ctx
,
922 struct st_renderbuffer
*strb
,
923 struct st_texture_image
*stImage
,
925 GLint destX
, GLint destY
, GLint destZ
,
926 GLint srcX
, GLint srcY
,
927 GLsizei width
, GLsizei height
)
929 struct pipe_context
*pipe
= ctx
->st
->pipe
;
930 struct pipe_screen
*screen
= pipe
->screen
;
931 struct pipe_transfer
*src_trans
;
934 assert(width
<= MAX_WIDTH
);
936 if (st_fb_orientation(ctx
->ReadBuffer
) == Y_0_TOP
) {
937 srcY
= strb
->Base
.Height
- srcY
- height
;
940 src_trans
= screen
->get_tex_transfer( screen
,
947 texDest
= st_texture_image_map(ctx
->st
, stImage
, 0, PIPE_TRANSFER_WRITE
,
948 destX
, destY
, width
, height
);
950 if (baseFormat
== GL_DEPTH_COMPONENT
||
951 baseFormat
== GL_DEPTH24_STENCIL8
) {
952 const GLboolean scaleOrBias
= (ctx
->Pixel
.DepthScale
!= 1.0F
||
953 ctx
->Pixel
.DepthBias
!= 0.0F
);
956 /* determine bottom-to-top vs. top-to-bottom order for src buffer */
957 if (st_fb_orientation(ctx
->ReadBuffer
) == Y_0_TOP
) {
966 /* To avoid a large temp memory allocation, do copy row by row */
967 for (row
= 0; row
< height
; row
++, srcY
+= yStep
) {
968 uint data
[MAX_WIDTH
];
969 pipe_get_tile_z(src_trans
, 0, srcY
, width
, 1, data
);
971 _mesa_scale_and_bias_depth_uint(ctx
, width
, data
);
973 pipe_put_tile_z(stImage
->transfer
, 0, row
, width
, 1, data
);
979 (GLfloat
*) _mesa_malloc(width
* height
* 4 * sizeof(GLfloat
));
981 if (tempSrc
&& texDest
) {
982 const GLint dims
= 2;
983 struct gl_texture_image
*texImage
= &stImage
->base
;
984 GLint dstRowStride
= stImage
->transfer
->stride
;
985 struct gl_pixelstore_attrib unpack
= ctx
->DefaultPacking
;
987 if (st_fb_orientation(ctx
->ReadBuffer
) == Y_0_TOP
) {
988 unpack
.Invert
= GL_TRUE
;
991 /* get float/RGBA image from framebuffer */
992 /* XXX this usually involves a lot of int/float conversion.
993 * try to avoid that someday.
995 pipe_get_tile_rgba(src_trans
, 0, 0, width
, height
, tempSrc
);
997 /* Store into texture memory.
998 * Note that this does some special things such as pixel transfer
999 * ops and format conversion. In particular, if the dest tex format
1000 * is actually RGBA but the user created the texture as GL_RGB we
1001 * need to fill-in/override the alpha channel with 1.0.
1003 texImage
->TexFormat
->StoreImage(ctx
, dims
,
1004 texImage
->_BaseFormat
,
1005 texImage
->TexFormat
,
1009 texImage
->ImageOffsets
,
1011 GL_RGBA
, GL_FLOAT
, tempSrc
, /* src */
1015 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexSubImage");
1019 _mesa_free(tempSrc
);
1022 st_texture_image_unmap(ctx
->st
, stImage
);
1023 screen
->tex_transfer_destroy(src_trans
);
1028 * Do a CopyTex[Sub]Image1/2/3D() using a hardware (blit) path if possible.
1029 * Note that the region to copy has already been clipped so we know we
1030 * won't read from outside the source renderbuffer's bounds.
1032 * Note: srcY=0=Bottom of renderbuffer (GL convention)
1035 st_copy_texsubimage(GLcontext
*ctx
,
1036 GLenum target
, GLint level
,
1037 GLint destX
, GLint destY
, GLint destZ
,
1038 GLint srcX
, GLint srcY
,
1039 GLsizei width
, GLsizei height
)
1041 struct gl_texture_unit
*texUnit
=
1042 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1043 struct gl_texture_object
*texObj
=
1044 _mesa_select_tex_object(ctx
, texUnit
, target
);
1045 struct gl_texture_image
*texImage
=
1046 _mesa_select_tex_image(ctx
, texObj
, target
, level
);
1047 struct st_texture_image
*stImage
= st_texture_image(texImage
);
1048 const GLenum texBaseFormat
= texImage
->InternalFormat
;
1049 struct gl_framebuffer
*fb
= ctx
->ReadBuffer
;
1050 struct st_renderbuffer
*strb
;
1051 struct pipe_context
*pipe
= ctx
->st
->pipe
;
1052 struct pipe_screen
*screen
= pipe
->screen
;
1053 enum pipe_format dest_format
, src_format
;
1054 GLboolean use_fallback
= GL_TRUE
;
1055 GLboolean matching_base_formats
;
1057 /* any rendering in progress must complete before we grab the fb image */
1060 /* determine if copying depth or color data */
1061 if (texBaseFormat
== GL_DEPTH_COMPONENT
||
1062 texBaseFormat
== GL_DEPTH24_STENCIL8
) {
1063 strb
= st_renderbuffer(fb
->_DepthBuffer
);
1065 else if (texBaseFormat
== GL_DEPTH_STENCIL_EXT
) {
1066 strb
= st_renderbuffer(fb
->_StencilBuffer
);
1069 /* texBaseFormat == GL_RGB, GL_RGBA, GL_ALPHA, etc */
1070 strb
= st_renderbuffer(fb
->_ColorReadBuffer
);
1074 assert(strb
->surface
);
1075 assert(stImage
->pt
);
1077 src_format
= strb
->surface
->format
;
1078 dest_format
= stImage
->pt
->format
;
1081 * Determine if the src framebuffer and dest texture have the same
1082 * base format. We need this to detect a case such as the framebuffer
1083 * being GL_RGBA but the texture being GL_RGB. If the actual hardware
1084 * texture format stores RGBA we need to set A=1 (overriding the
1085 * framebuffer's alpha values). We can't do that with the blit or
1086 * textured-quad paths.
1088 matching_base_formats
= (strb
->Base
._BaseFormat
== texImage
->_BaseFormat
);
1090 if (matching_base_formats
&& ctx
->_ImageTransferState
== 0x0) {
1091 /* try potential hardware path */
1092 struct pipe_surface
*dest_surface
= NULL
;
1093 boolean do_flip
= (st_fb_orientation(ctx
->ReadBuffer
) == Y_0_TOP
);
1095 if (src_format
== dest_format
&& !do_flip
) {
1096 /* use surface_copy() / blit */
1099 dest_surface
= screen
->get_tex_surface(screen
, stImage
->pt
,
1100 stImage
->face
, stImage
->level
,
1102 PIPE_BUFFER_USAGE_GPU_WRITE
);
1104 /* for surface_copy(), y=0=top, always */
1105 pipe
->surface_copy(pipe
,
1114 use_fallback
= GL_FALSE
;
1116 else if (screen
->is_format_supported(screen
, src_format
,
1118 PIPE_TEXTURE_USAGE_SAMPLER
,
1120 screen
->is_format_supported(screen
, dest_format
,
1122 PIPE_TEXTURE_USAGE_RENDER_TARGET
,
1124 /* draw textured quad to do the copy */
1127 dest_surface
= screen
->get_tex_surface(screen
, stImage
->pt
,
1128 stImage
->face
, stImage
->level
,
1130 PIPE_BUFFER_USAGE_GPU_WRITE
);
1133 srcY1
= strb
->Base
.Height
- srcY
- height
;
1134 srcY0
= srcY1
+ height
;
1138 srcY1
= srcY0
+ height
;
1140 util_blit_pixels(ctx
->st
->blit
,
1143 srcX
+ width
, srcY1
,
1146 destX
+ width
, destY
+ height
,
1147 0.0, PIPE_TEX_MIPFILTER_NEAREST
);
1148 use_fallback
= GL_FALSE
;
1152 pipe_surface_reference(&dest_surface
, NULL
);
1156 /* software fallback */
1157 fallback_copy_texsubimage(ctx
, target
, level
,
1158 strb
, stImage
, texBaseFormat
,
1159 destX
, destY
, destZ
,
1160 srcX
, srcY
, width
, height
);
1163 if (level
== texObj
->BaseLevel
&& texObj
->GenerateMipmap
) {
1164 ctx
->Driver
.GenerateMipmap(ctx
, target
, texObj
);
1171 st_CopyTexImage1D(GLcontext
* ctx
, GLenum target
, GLint level
,
1172 GLenum internalFormat
,
1173 GLint x
, GLint y
, GLsizei width
, GLint border
)
1175 struct gl_texture_unit
*texUnit
=
1176 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1177 struct gl_texture_object
*texObj
=
1178 _mesa_select_tex_object(ctx
, texUnit
, target
);
1179 struct gl_texture_image
*texImage
=
1180 _mesa_select_tex_image(ctx
, texObj
, target
, level
);
1187 /* Setup or redefine the texture object, texture and texture
1188 * image. Don't populate yet.
1190 ctx
->Driver
.TexImage1D(ctx
, target
, level
, internalFormat
,
1192 GL_RGBA
, CHAN_TYPE
, NULL
,
1193 &ctx
->DefaultPacking
, texObj
, texImage
);
1195 st_copy_texsubimage(ctx
, target
, level
,
1196 0, 0, 0, /* destX,Y,Z */
1197 x
, y
, width
, 1); /* src X, Y, size */
1202 st_CopyTexImage2D(GLcontext
* ctx
, GLenum target
, GLint level
,
1203 GLenum internalFormat
,
1204 GLint x
, GLint y
, GLsizei width
, GLsizei height
,
1207 struct gl_texture_unit
*texUnit
=
1208 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1209 struct gl_texture_object
*texObj
=
1210 _mesa_select_tex_object(ctx
, texUnit
, target
);
1211 struct gl_texture_image
*texImage
=
1212 _mesa_select_tex_image(ctx
, texObj
, target
, level
);
1214 /* Setup or redefine the texture object, texture and texture
1215 * image. Don't populate yet.
1217 ctx
->Driver
.TexImage2D(ctx
, target
, level
, internalFormat
,
1218 width
, height
, border
,
1219 GL_RGBA
, CHAN_TYPE
, NULL
,
1220 &ctx
->DefaultPacking
, texObj
, texImage
);
1222 st_copy_texsubimage(ctx
, target
, level
,
1223 0, 0, 0, /* destX,Y,Z */
1224 x
, y
, width
, height
); /* src X, Y, size */
1229 st_CopyTexSubImage1D(GLcontext
* ctx
, GLenum target
, GLint level
,
1230 GLint xoffset
, GLint x
, GLint y
, GLsizei width
)
1232 const GLint yoffset
= 0, zoffset
= 0;
1233 const GLsizei height
= 1;
1234 st_copy_texsubimage(ctx
, target
, level
,
1235 xoffset
, yoffset
, zoffset
, /* destX,Y,Z */
1236 x
, y
, width
, height
); /* src X, Y, size */
1241 st_CopyTexSubImage2D(GLcontext
* ctx
, GLenum target
, GLint level
,
1242 GLint xoffset
, GLint yoffset
,
1243 GLint x
, GLint y
, GLsizei width
, GLsizei height
)
1245 const GLint zoffset
= 0;
1246 st_copy_texsubimage(ctx
, target
, level
,
1247 xoffset
, yoffset
, zoffset
, /* destX,Y,Z */
1248 x
, y
, width
, height
); /* src X, Y, size */
1253 st_CopyTexSubImage3D(GLcontext
* ctx
, GLenum target
, GLint level
,
1254 GLint xoffset
, GLint yoffset
, GLint zoffset
,
1255 GLint x
, GLint y
, GLsizei width
, GLsizei height
)
1257 st_copy_texsubimage(ctx
, target
, level
,
1258 xoffset
, yoffset
, zoffset
, /* destX,Y,Z */
1259 x
, y
, width
, height
); /* src X, Y, size */
1264 * Compute which mipmap levels that really need to be sent to the hardware.
1265 * This depends on the base image size, GL_TEXTURE_MIN_LOD,
1266 * GL_TEXTURE_MAX_LOD, GL_TEXTURE_BASE_LEVEL, and GL_TEXTURE_MAX_LEVEL.
1269 calculate_first_last_level(struct st_texture_object
*stObj
)
1271 struct gl_texture_object
*tObj
= &stObj
->base
;
1273 /* These must be signed values. MinLod and MaxLod can be negative numbers,
1274 * and having firstLevel and lastLevel as signed prevents the need for
1275 * extra sign checks.
1280 /* Yes, this looks overly complicated, but it's all needed.
1282 switch (tObj
->Target
) {
1286 case GL_TEXTURE_CUBE_MAP
:
1287 if (tObj
->MinFilter
== GL_NEAREST
|| tObj
->MinFilter
== GL_LINEAR
) {
1288 /* GL_NEAREST and GL_LINEAR only care about GL_TEXTURE_BASE_LEVEL.
1290 firstLevel
= lastLevel
= tObj
->BaseLevel
;
1294 lastLevel
= MIN2(tObj
->MaxLevel
,
1295 (int) tObj
->Image
[0][tObj
->BaseLevel
]->WidthLog2
);
1298 case GL_TEXTURE_RECTANGLE_NV
:
1299 case GL_TEXTURE_4D_SGIS
:
1300 firstLevel
= lastLevel
= 0;
1306 stObj
->lastLevel
= lastLevel
;
1311 copy_image_data_to_texture(struct st_context
*st
,
1312 struct st_texture_object
*stObj
,
1314 struct st_texture_image
*stImage
)
1317 /* Copy potentially with the blitter:
1319 st_texture_image_copy(st
->pipe
,
1320 stObj
->pt
, dstLevel
, /* dest texture, level */
1321 stImage
->pt
, /* src texture */
1325 pipe_texture_reference(&stImage
->pt
, NULL
);
1327 else if (stImage
->base
.Data
) {
1328 assert(stImage
->base
.Data
!= NULL
);
1330 /* More straightforward upload.
1332 st_texture_image_data(st
->pipe
,
1337 stImage
->base
.RowStride
*
1338 stObj
->pt
->block
.size
,
1339 stImage
->base
.RowStride
*
1340 stImage
->base
.Height
*
1341 stObj
->pt
->block
.size
);
1342 _mesa_align_free(stImage
->base
.Data
);
1343 stImage
->base
.Data
= NULL
;
1346 pipe_texture_reference(&stImage
->pt
, stObj
->pt
);
1351 * Called during state validation. When this function is finished,
1352 * the texture object should be ready for rendering.
1353 * \return GL_TRUE for success, GL_FALSE for failure (out of mem)
1356 st_finalize_texture(GLcontext
*ctx
,
1357 struct pipe_context
*pipe
,
1358 struct gl_texture_object
*tObj
,
1359 GLboolean
*needFlush
)
1361 struct st_texture_object
*stObj
= st_texture_object(tObj
);
1362 const GLuint nr_faces
= (stObj
->base
.Target
== GL_TEXTURE_CUBE_MAP
) ? 6 : 1;
1366 struct st_texture_image
*firstImage
;
1368 *needFlush
= GL_FALSE
;
1370 /* We know/require this is true by now:
1372 assert(stObj
->base
._Complete
);
1374 /* What levels must the texture include at a minimum?
1376 calculate_first_last_level(stObj
);
1377 firstImage
= st_texture_image(stObj
->base
.Image
[0][stObj
->base
.BaseLevel
]);
1379 /* If both firstImage and stObj point to a texture which can contain
1380 * all active images, favour firstImage. Note that because of the
1381 * completeness requirement, we know that the image dimensions
1384 if (firstImage
->pt
&&
1385 firstImage
->pt
!= stObj
->pt
&&
1386 firstImage
->pt
->last_level
>= stObj
->lastLevel
) {
1388 pipe_texture_reference(&stObj
->pt
, firstImage
->pt
);
1391 /* FIXME: determine format block instead of cpp */
1392 if (firstImage
->base
.IsCompressed
) {
1393 comp_byte
= compressed_num_bytes(firstImage
->base
.TexFormat
->MesaFormat
);
1397 cpp
= firstImage
->base
.TexFormat
->TexelBytes
;
1400 /* If we already have a gallium texture, check that it matches the texture
1401 * object's format, target, size, num_levels, etc.
1404 const enum pipe_format fmt
=
1405 st_mesa_format_to_pipe_format(firstImage
->base
.TexFormat
->MesaFormat
);
1406 if (stObj
->pt
->target
!= gl_target_to_pipe(stObj
->base
.Target
) ||
1407 stObj
->pt
->format
!= fmt
||
1408 stObj
->pt
->last_level
< stObj
->lastLevel
||
1409 stObj
->pt
->width
[0] != firstImage
->base
.Width2
||
1410 stObj
->pt
->height
[0] != firstImage
->base
.Height2
||
1411 stObj
->pt
->depth
[0] != firstImage
->base
.Depth2
||
1412 stObj
->pt
->block
.size
/stObj
->pt
->block
.width
!= cpp
|| /* Nominal bytes per pixel */
1413 stObj
->pt
->compressed
!= firstImage
->base
.IsCompressed
) {
1414 pipe_texture_reference(&stObj
->pt
, NULL
);
1415 ctx
->st
->dirty
.st
|= ST_NEW_FRAMEBUFFER
;
1419 /* May need to create a new gallium texture:
1422 const enum pipe_format fmt
=
1423 st_mesa_format_to_pipe_format(firstImage
->base
.TexFormat
->MesaFormat
);
1424 stObj
->pt
= st_texture_create(ctx
->st
,
1425 gl_target_to_pipe(stObj
->base
.Target
),
1428 firstImage
->base
.Width2
,
1429 firstImage
->base
.Height2
,
1430 firstImage
->base
.Depth2
,
1432 ( (pf_is_depth_stencil(fmt
) ?
1433 PIPE_TEXTURE_USAGE_DEPTH_STENCIL
:
1434 PIPE_TEXTURE_USAGE_RENDER_TARGET
) |
1435 PIPE_TEXTURE_USAGE_SAMPLER
));
1438 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexImage");
1443 /* Pull in any images not in the object's texture:
1445 for (face
= 0; face
< nr_faces
; face
++) {
1447 for (level
= 0; level
<= stObj
->lastLevel
; level
++) {
1448 struct st_texture_image
*stImage
=
1449 st_texture_image(stObj
->base
.Image
[face
][stObj
->base
.BaseLevel
+ level
]);
1451 /* Need to import images in main memory or held in other textures.
1453 if (stImage
&& stObj
->pt
!= stImage
->pt
) {
1454 copy_image_data_to_texture(ctx
->st
, stObj
, level
, stImage
);
1455 *needFlush
= GL_TRUE
;
1465 * Returns pointer to a default/dummy texture.
1466 * This is typically used when the current shader has tex/sample instructions
1467 * but the user has not provided a (any) texture(s).
1469 struct gl_texture_object
*
1470 st_get_default_texture(struct st_context
*st
)
1472 if (!st
->default_texture
) {
1473 static const GLenum target
= GL_TEXTURE_2D
;
1474 GLubyte pixels
[16][16][4];
1475 struct gl_texture_object
*texObj
;
1476 struct gl_texture_image
*texImg
;
1479 /* The ARB_fragment_program spec says (0,0,0,1) should be returned
1480 * when attempting to sample incomplete textures.
1482 for (i
= 0; i
< 16; i
++) {
1483 for (j
= 0; j
< 16; j
++) {
1484 pixels
[i
][j
][0] = 0;
1485 pixels
[i
][j
][1] = 0;
1486 pixels
[i
][j
][2] = 0;
1487 pixels
[i
][j
][3] = 255;
1491 texObj
= st
->ctx
->Driver
.NewTextureObject(st
->ctx
, 0, target
);
1493 texImg
= _mesa_get_tex_image(st
->ctx
, texObj
, target
, 0);
1495 _mesa_init_teximage_fields(st
->ctx
, target
, texImg
,
1496 16, 16, 1, 0, /* w, h, d, border */
1499 st_TexImage(st
->ctx
, 2, target
,
1500 0, GL_RGBA
, /* level, intformat */
1501 16, 16, 1, 0, /* w, h, d, border */
1502 GL_RGBA
, GL_UNSIGNED_BYTE
, pixels
,
1503 &st
->ctx
->DefaultPacking
,
1507 texObj
->MinFilter
= GL_NEAREST
;
1508 texObj
->MagFilter
= GL_NEAREST
;
1509 texObj
->_Complete
= GL_TRUE
;
1511 st
->default_texture
= texObj
;
1513 return st
->default_texture
;
1518 st_init_texture_functions(struct dd_function_table
*functions
)
1520 functions
->ChooseTextureFormat
= st_ChooseTextureFormat
;
1521 functions
->TexImage1D
= st_TexImage1D
;
1522 functions
->TexImage2D
= st_TexImage2D
;
1523 functions
->TexImage3D
= st_TexImage3D
;
1524 functions
->TexSubImage1D
= st_TexSubImage1D
;
1525 functions
->TexSubImage2D
= st_TexSubImage2D
;
1526 functions
->TexSubImage3D
= st_TexSubImage3D
;
1527 functions
->CopyTexImage1D
= st_CopyTexImage1D
;
1528 functions
->CopyTexImage2D
= st_CopyTexImage2D
;
1529 functions
->CopyTexSubImage1D
= st_CopyTexSubImage1D
;
1530 functions
->CopyTexSubImage2D
= st_CopyTexSubImage2D
;
1531 functions
->CopyTexSubImage3D
= st_CopyTexSubImage3D
;
1532 functions
->GenerateMipmap
= st_generate_mipmap
;
1534 functions
->GetTexImage
= st_GetTexImage
;
1536 /* compressed texture functions */
1537 functions
->CompressedTexImage2D
= st_CompressedTexImage2D
;
1538 functions
->GetCompressedTexImage
= st_GetCompressedTexImage
;
1539 functions
->CompressedTextureSize
= _mesa_compressed_texture_size
;
1541 functions
->NewTextureObject
= st_NewTextureObject
;
1542 functions
->NewTextureImage
= st_NewTextureImage
;
1543 functions
->DeleteTexture
= st_DeleteTextureObject
;
1544 functions
->FreeTexImageData
= st_FreeTextureImageData
;
1545 functions
->UpdateTexturePalette
= 0;
1547 functions
->TextureMemCpy
= do_memcpy
;
1549 /* XXX Temporary until we can query pipe's texture sizes */
1550 functions
->TestProxyTexImage
= _mesa_test_proxy_teximage
;