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
, GLboolean 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
, unpack
, &unpackNB
);
400 texImage
->Width
= width
;
401 texImage
->Height
= height
;
402 texImage
->Depth
= depth
;
403 texImage
->Border
= 0;
407 postConvWidth
= width
;
408 postConvHeight
= height
;
410 stImage
->face
= _mesa_tex_target_to_face(target
);
411 stImage
->level
= level
;
414 if (ctx
->_ImageTransferState
& IMAGE_CONVOLUTION_BIT
) {
415 _mesa_adjust_image_for_convolution(ctx
, dims
, &postConvWidth
,
420 /* choose the texture format */
421 texImage
->TexFormat
= st_ChooseTextureFormat(ctx
, internalFormat
,
424 _mesa_set_fetch_functions(texImage
, dims
);
426 if (texImage
->TexFormat
->TexelBytes
== 0) {
427 /* must be a compressed format */
429 texImage
->IsCompressed
= GL_TRUE
;
430 texImage
->CompressedSize
=
431 ctx
->Driver
.CompressedTextureSize(ctx
, texImage
->Width
,
432 texImage
->Height
, texImage
->Depth
,
433 texImage
->TexFormat
->MesaFormat
);
436 texelBytes
= texImage
->TexFormat
->TexelBytes
;
438 /* Minimum pitch of 32 bytes */
439 if (postConvWidth
* texelBytes
< 32) {
440 postConvWidth
= 32 / texelBytes
;
441 texImage
->RowStride
= postConvWidth
;
444 /* we'll set RowStride elsewhere when the texture is a "mapped" state */
445 /*assert(texImage->RowStride == postConvWidth);*/
448 /* Release the reference to a potentially orphaned buffer.
449 * Release any old malloced memory.
452 pipe_texture_reference(&stImage
->pt
, NULL
);
453 assert(!texImage
->Data
);
455 else if (texImage
->Data
) {
456 _mesa_align_free(texImage
->Data
);
459 if (width
== 0 || height
== 0 || depth
== 0) {
460 /* stop after freeing old image */
464 /* If this is the only mipmap level in the texture, could call
465 * bmBufferData with NULL data to free the old block and avoid
466 * waiting on any outstanding fences.
469 if (stObj
->teximage_realloc
||
470 level
> (GLint
) stObj
->pt
->last_level
||
471 (stObj
->pt
->last_level
== level
&&
472 stObj
->pt
->target
!= PIPE_TEXTURE_CUBE
&&
473 !st_texture_match_image(stObj
->pt
, &stImage
->base
,
474 stImage
->face
, stImage
->level
))) {
476 pipe_texture_reference(&stObj
->pt
, NULL
);
478 stObj
->teximage_realloc
= FALSE
;
483 guess_and_alloc_texture(ctx
->st
, stObj
, stImage
);
485 /* Probably out of memory.
486 * Try flushing any pending rendering, then retry.
489 guess_and_alloc_texture(ctx
->st
, stObj
, stImage
);
491 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexImage");
497 assert(!stImage
->pt
);
500 st_texture_match_image(stObj
->pt
, &stImage
->base
,
501 stImage
->face
, stImage
->level
)) {
503 pipe_texture_reference(&stImage
->pt
, stObj
->pt
);
508 DBG("XXX: Image did not fit into texture - storing in local memory!\n");
510 /* st_CopyTexImage calls this function with pixels == NULL, with
511 * the expectation that the texture will be set up but nothing
512 * more will be done. This is where those calls return:
515 pixels
= _mesa_validate_pbo_compressed_teximage(ctx
, imageSize
, pixels
,
517 "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
; i
++) {
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
+ 1 < depth
) {
585 /* unmap this slice */
586 st_texture_image_unmap(ctx
->st
, stImage
);
587 /* map next slice of 3D texture */
588 texImage
->Data
= st_texture_image_map(ctx
->st
, stImage
, i
+ 1,
589 PIPE_TRANSFER_WRITE
, 0, 0,
591 stImage
->base
.Height
);
592 src
+= srcImageStride
;
597 _mesa_unmap_teximage_pbo(ctx
, unpack
);
600 st_texture_image_unmap(ctx
->st
, stImage
);
601 texImage
->Data
= NULL
;
604 if (level
== texObj
->BaseLevel
&& texObj
->GenerateMipmap
) {
605 ctx
->Driver
.GenerateMipmap(ctx
, target
, texObj
);
611 st_TexImage3D(GLcontext
* ctx
,
612 GLenum target
, GLint level
,
613 GLint internalFormat
,
614 GLint width
, GLint height
, GLint depth
,
616 GLenum format
, GLenum type
, const void *pixels
,
617 const struct gl_pixelstore_attrib
*unpack
,
618 struct gl_texture_object
*texObj
,
619 struct gl_texture_image
*texImage
)
621 st_TexImage(ctx
, 3, target
, level
, internalFormat
, width
, height
, depth
,
622 border
, format
, type
, pixels
, unpack
, texObj
, texImage
,
628 st_TexImage2D(GLcontext
* ctx
,
629 GLenum target
, GLint level
,
630 GLint internalFormat
,
631 GLint width
, GLint height
, GLint border
,
632 GLenum format
, GLenum type
, const void *pixels
,
633 const struct gl_pixelstore_attrib
*unpack
,
634 struct gl_texture_object
*texObj
,
635 struct gl_texture_image
*texImage
)
637 st_TexImage(ctx
, 2, target
, level
, internalFormat
, width
, height
, 1, border
,
638 format
, type
, pixels
, unpack
, texObj
, texImage
, 0, GL_FALSE
);
643 st_TexImage1D(GLcontext
* ctx
,
644 GLenum target
, GLint level
,
645 GLint internalFormat
,
646 GLint width
, GLint border
,
647 GLenum format
, GLenum type
, const void *pixels
,
648 const struct gl_pixelstore_attrib
*unpack
,
649 struct gl_texture_object
*texObj
,
650 struct gl_texture_image
*texImage
)
652 st_TexImage(ctx
, 1, target
, level
, internalFormat
, width
, 1, 1, border
,
653 format
, type
, pixels
, unpack
, texObj
, texImage
, 0, GL_FALSE
);
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
, internalFormat
, width
, height
, 1, border
,
666 0, 0, data
, &ctx
->Unpack
, texObj
, texImage
, imageSize
, GL_TRUE
);
671 * Need to map texture image into memory before copying image data,
675 st_get_tex_image(GLcontext
* ctx
, GLenum target
, GLint level
,
676 GLenum format
, GLenum type
, GLvoid
* pixels
,
677 struct gl_texture_object
*texObj
,
678 struct gl_texture_image
*texImage
, GLboolean compressed
)
680 struct st_texture_image
*stImage
= st_texture_image(texImage
);
681 GLuint dstImageStride
= _mesa_image_image_stride(&ctx
->Pack
,
690 /* Image is stored in hardware format in a buffer managed by the
691 * kernel. Need to explicitly map and unmap it.
693 texImage
->Data
= st_texture_image_map(ctx
->st
, stImage
, 0,
694 PIPE_TRANSFER_READ
, 0, 0,
696 stImage
->base
.Height
);
697 texImage
->RowStride
= stImage
->transfer
->stride
/ stImage
->pt
->block
.size
;
700 /* Otherwise, the image should actually be stored in
701 * texImage->Data. This is pretty confusing for
702 * everybody, I'd much prefer to separate the two functions of
703 * texImage->Data - storage for texture images in main memory
704 * and access (ie mappings) of images. In other words, we'd
705 * create a new texImage->Map field and leave Data simply for
708 assert(texImage
->Data
);
711 depth
= texImage
->Depth
;
714 dest
= (GLubyte
*) pixels
;
716 for (i
= 0; i
< depth
; i
++) {
718 _mesa_get_compressed_teximage(ctx
, target
, level
, dest
,
722 _mesa_get_teximage(ctx
, target
, level
, format
, type
, dest
,
726 if (stImage
->pt
&& i
+ 1 < depth
) {
727 /* unmap this slice */
728 st_texture_image_unmap(ctx
->st
, stImage
);
729 /* map next slice of 3D texture */
730 texImage
->Data
= st_texture_image_map(ctx
->st
, stImage
, i
+ 1,
731 PIPE_TRANSFER_READ
, 0, 0,
733 stImage
->base
.Height
);
734 dest
+= dstImageStride
;
738 texImage
->Depth
= depth
;
742 st_texture_image_unmap(ctx
->st
, stImage
);
743 texImage
->Data
= NULL
;
749 st_GetTexImage(GLcontext
* ctx
, GLenum target
, GLint level
,
750 GLenum format
, GLenum type
, GLvoid
* pixels
,
751 struct gl_texture_object
*texObj
,
752 struct gl_texture_image
*texImage
)
754 st_get_tex_image(ctx
, target
, level
, format
, type
, pixels
, texObj
, texImage
,
760 st_GetCompressedTexImage(GLcontext
*ctx
, GLenum target
, GLint level
,
762 struct gl_texture_object
*texObj
,
763 struct gl_texture_image
*texImage
)
765 st_get_tex_image(ctx
, target
, level
, 0, 0, pixels
, texObj
, texImage
,
772 st_TexSubimage(GLcontext
*ctx
, GLint dims
, GLenum target
, GLint level
,
773 GLint xoffset
, GLint yoffset
, GLint zoffset
,
774 GLint width
, GLint height
, GLint depth
,
775 GLenum format
, GLenum type
, const void *pixels
,
776 const struct gl_pixelstore_attrib
*packing
,
777 struct gl_texture_object
*texObj
,
778 struct gl_texture_image
*texImage
)
780 struct st_texture_image
*stImage
= st_texture_image(texImage
);
782 GLuint srcImageStride
= _mesa_image_image_stride(packing
, width
, height
,
787 DBG("%s target %s level %d offset %d,%d %dx%d\n", __FUNCTION__
,
788 _mesa_lookup_enum_by_nr(target
),
789 level
, xoffset
, yoffset
, width
, height
);
792 _mesa_validate_pbo_teximage(ctx
, dims
, width
, height
, depth
, format
,
793 type
, pixels
, packing
, "glTexSubImage2D");
797 /* Map buffer if necessary. Need to lock to prevent other contexts
798 * from uploading the buffer under us.
801 texImage
->Data
= st_texture_image_map(ctx
->st
, stImage
, zoffset
,
807 if (!texImage
->Data
) {
808 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexSubImage");
812 src
= (const GLubyte
*) pixels
;
813 dstRowStride
= stImage
->transfer
->stride
;
815 for (i
= 0; i
< depth
; i
++) {
816 if (!texImage
->TexFormat
->StoreImage(ctx
, dims
, texImage
->_BaseFormat
,
821 texImage
->ImageOffsets
,
823 format
, type
, src
, packing
)) {
824 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexSubImage");
827 if (stImage
->pt
&& i
+ 1 < depth
) {
828 /* unmap this slice */
829 st_texture_image_unmap(ctx
->st
, stImage
);
830 /* map next slice of 3D texture */
831 texImage
->Data
= st_texture_image_map(ctx
->st
, stImage
,
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
, GLenum target
, GLint level
,
856 GLint xoffset
, GLint yoffset
, GLint zoffset
,
857 GLsizei width
, GLsizei height
, GLsizei depth
,
858 GLenum format
, GLenum type
, const GLvoid
*pixels
,
859 const struct gl_pixelstore_attrib
*packing
,
860 struct gl_texture_object
*texObj
,
861 struct gl_texture_image
*texImage
)
863 st_TexSubimage(ctx
, 3, target
, level
, xoffset
, yoffset
, zoffset
,
864 width
, height
, depth
, format
, type
,
865 pixels
, packing
, texObj
, texImage
);
870 st_TexSubImage2D(GLcontext
*ctx
, GLenum target
, GLint level
,
871 GLint xoffset
, GLint yoffset
,
872 GLsizei width
, GLsizei height
,
873 GLenum format
, GLenum type
, const GLvoid
* pixels
,
874 const struct gl_pixelstore_attrib
*packing
,
875 struct gl_texture_object
*texObj
,
876 struct gl_texture_image
*texImage
)
878 st_TexSubimage(ctx
, 2, target
, level
, xoffset
, yoffset
, 0,
879 width
, height
, 1, format
, type
,
880 pixels
, packing
, texObj
, texImage
);
885 st_TexSubImage1D(GLcontext
*ctx
, GLenum target
, GLint level
,
886 GLint xoffset
, GLsizei width
, GLenum format
, GLenum type
,
887 const GLvoid
* pixels
,
888 const struct gl_pixelstore_attrib
*packing
,
889 struct gl_texture_object
*texObj
,
890 struct gl_texture_image
*texImage
)
892 st_TexSubimage(ctx
, 1, target
, level
, xoffset
, 0, 0, width
, 1, 1,
893 format
, type
, pixels
, packing
, texObj
, texImage
);
899 * Do a CopyTexSubImage operation using a read transfer from the source,
900 * a write transfer to the destination and get_tile()/put_tile() to access
903 * Note: srcY=0=TOP of renderbuffer
906 fallback_copy_texsubimage(GLcontext
*ctx
, GLenum target
, GLint level
,
907 struct st_renderbuffer
*strb
,
908 struct st_texture_image
*stImage
,
910 GLint destX
, GLint destY
, GLint destZ
,
911 GLint srcX
, GLint srcY
,
912 GLsizei width
, GLsizei height
)
914 struct pipe_context
*pipe
= ctx
->st
->pipe
;
915 struct pipe_screen
*screen
= pipe
->screen
;
916 struct pipe_transfer
*src_trans
;
919 assert(width
<= MAX_WIDTH
);
921 if (st_fb_orientation(ctx
->ReadBuffer
) == Y_0_TOP
) {
922 srcY
= strb
->Base
.Height
- srcY
- height
;
925 src_trans
= screen
->get_tex_transfer( screen
,
932 texDest
= st_texture_image_map(ctx
->st
, stImage
, 0, PIPE_TRANSFER_WRITE
,
933 destX
, destY
, width
, height
);
935 if (baseFormat
== GL_DEPTH_COMPONENT
||
936 baseFormat
== GL_DEPTH24_STENCIL8
) {
937 const GLboolean scaleOrBias
= (ctx
->Pixel
.DepthScale
!= 1.0F
||
938 ctx
->Pixel
.DepthBias
!= 0.0F
);
941 /* determine bottom-to-top vs. top-to-bottom order for src buffer */
942 if (st_fb_orientation(ctx
->ReadBuffer
) == Y_0_TOP
) {
951 /* To avoid a large temp memory allocation, do copy row by row */
952 for (row
= 0; row
< height
; row
++, srcY
+= yStep
) {
953 uint data
[MAX_WIDTH
];
954 pipe_get_tile_z(src_trans
, 0, srcY
, width
, 1, data
);
956 _mesa_scale_and_bias_depth_uint(ctx
, width
, data
);
958 pipe_put_tile_z(stImage
->transfer
, 0, row
, width
, 1, data
);
964 (GLfloat
*) _mesa_malloc(width
* height
* 4 * sizeof(GLfloat
));
966 if (tempSrc
&& texDest
) {
967 const GLint dims
= 2;
968 const GLint dstRowStride
= stImage
->transfer
->stride
;
969 struct gl_texture_image
*texImage
= &stImage
->base
;
970 struct gl_pixelstore_attrib unpack
= ctx
->DefaultPacking
;
972 if (st_fb_orientation(ctx
->ReadBuffer
) == Y_0_TOP
) {
973 unpack
.Invert
= GL_TRUE
;
976 /* get float/RGBA image from framebuffer */
977 /* XXX this usually involves a lot of int/float conversion.
978 * try to avoid that someday.
980 pipe_get_tile_rgba(src_trans
, 0, 0, width
, height
, tempSrc
);
982 /* Store into texture memory.
983 * Note that this does some special things such as pixel transfer
984 * ops and format conversion. In particular, if the dest tex format
985 * is actually RGBA but the user created the texture as GL_RGB we
986 * need to fill-in/override the alpha channel with 1.0.
988 texImage
->TexFormat
->StoreImage(ctx
, dims
,
989 texImage
->_BaseFormat
,
994 texImage
->ImageOffsets
,
996 GL_RGBA
, GL_FLOAT
, tempSrc
, /* src */
1000 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexSubImage");
1004 _mesa_free(tempSrc
);
1007 st_texture_image_unmap(ctx
->st
, stImage
);
1008 screen
->tex_transfer_destroy(src_trans
);
1013 * Do a CopyTex[Sub]Image1/2/3D() using a hardware (blit) path if possible.
1014 * Note that the region to copy has already been clipped so we know we
1015 * won't read from outside the source renderbuffer's bounds.
1017 * Note: srcY=0=Bottom of renderbuffer (GL convention)
1020 st_copy_texsubimage(GLcontext
*ctx
,
1021 GLenum target
, GLint level
,
1022 GLint destX
, GLint destY
, GLint destZ
,
1023 GLint srcX
, GLint srcY
,
1024 GLsizei width
, GLsizei height
)
1026 struct gl_texture_unit
*texUnit
=
1027 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1028 struct gl_texture_object
*texObj
=
1029 _mesa_select_tex_object(ctx
, texUnit
, target
);
1030 struct gl_texture_image
*texImage
=
1031 _mesa_select_tex_image(ctx
, texObj
, target
, level
);
1032 struct st_texture_image
*stImage
= st_texture_image(texImage
);
1033 const GLenum texBaseFormat
= texImage
->InternalFormat
;
1034 struct gl_framebuffer
*fb
= ctx
->ReadBuffer
;
1035 struct st_renderbuffer
*strb
;
1036 struct pipe_context
*pipe
= ctx
->st
->pipe
;
1037 struct pipe_screen
*screen
= pipe
->screen
;
1038 enum pipe_format dest_format
, src_format
;
1039 GLboolean use_fallback
= GL_TRUE
;
1040 GLboolean matching_base_formats
;
1042 /* any rendering in progress must complete before we grab the fb image */
1045 /* determine if copying depth or color data */
1046 if (texBaseFormat
== GL_DEPTH_COMPONENT
||
1047 texBaseFormat
== GL_DEPTH24_STENCIL8
) {
1048 strb
= st_renderbuffer(fb
->_DepthBuffer
);
1050 else if (texBaseFormat
== GL_DEPTH_STENCIL_EXT
) {
1051 strb
= st_renderbuffer(fb
->_StencilBuffer
);
1054 /* texBaseFormat == GL_RGB, GL_RGBA, GL_ALPHA, etc */
1055 strb
= st_renderbuffer(fb
->_ColorReadBuffer
);
1059 assert(strb
->surface
);
1060 assert(stImage
->pt
);
1062 src_format
= strb
->surface
->format
;
1063 dest_format
= stImage
->pt
->format
;
1066 * Determine if the src framebuffer and dest texture have the same
1067 * base format. We need this to detect a case such as the framebuffer
1068 * being GL_RGBA but the texture being GL_RGB. If the actual hardware
1069 * texture format stores RGBA we need to set A=1 (overriding the
1070 * framebuffer's alpha values). We can't do that with the blit or
1071 * textured-quad paths.
1073 matching_base_formats
= (strb
->Base
._BaseFormat
== texImage
->_BaseFormat
);
1075 if (matching_base_formats
&& ctx
->_ImageTransferState
== 0x0) {
1076 /* try potential hardware path */
1077 struct pipe_surface
*dest_surface
= NULL
;
1078 boolean do_flip
= (st_fb_orientation(ctx
->ReadBuffer
) == Y_0_TOP
);
1080 if (src_format
== dest_format
&& !do_flip
) {
1081 /* use surface_copy() / blit */
1083 dest_surface
= screen
->get_tex_surface(screen
, stImage
->pt
,
1084 stImage
->face
, stImage
->level
,
1086 PIPE_BUFFER_USAGE_GPU_WRITE
);
1088 /* for surface_copy(), y=0=top, always */
1089 pipe
->surface_copy(pipe
,
1098 use_fallback
= GL_FALSE
;
1100 else if (screen
->is_format_supported(screen
, src_format
,
1102 PIPE_TEXTURE_USAGE_SAMPLER
,
1104 screen
->is_format_supported(screen
, dest_format
,
1106 PIPE_TEXTURE_USAGE_RENDER_TARGET
,
1108 /* draw textured quad to do the copy */
1111 dest_surface
= screen
->get_tex_surface(screen
, stImage
->pt
,
1112 stImage
->face
, stImage
->level
,
1114 PIPE_BUFFER_USAGE_GPU_WRITE
);
1117 srcY1
= strb
->Base
.Height
- srcY
- height
;
1118 srcY0
= srcY1
+ height
;
1122 srcY1
= srcY0
+ height
;
1124 util_blit_pixels(ctx
->st
->blit
,
1127 srcX
+ width
, srcY1
,
1130 destX
+ width
, destY
+ height
,
1131 0.0, PIPE_TEX_MIPFILTER_NEAREST
);
1132 use_fallback
= GL_FALSE
;
1136 pipe_surface_reference(&dest_surface
, NULL
);
1140 /* software fallback */
1141 fallback_copy_texsubimage(ctx
, target
, level
,
1142 strb
, stImage
, texBaseFormat
,
1143 destX
, destY
, destZ
,
1144 srcX
, srcY
, width
, height
);
1147 if (level
== texObj
->BaseLevel
&& texObj
->GenerateMipmap
) {
1148 ctx
->Driver
.GenerateMipmap(ctx
, target
, texObj
);
1155 st_CopyTexImage1D(GLcontext
* ctx
, GLenum target
, GLint level
,
1156 GLenum internalFormat
,
1157 GLint x
, GLint y
, GLsizei width
, GLint border
)
1159 struct gl_texture_unit
*texUnit
=
1160 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1161 struct gl_texture_object
*texObj
=
1162 _mesa_select_tex_object(ctx
, texUnit
, target
);
1163 struct gl_texture_image
*texImage
=
1164 _mesa_select_tex_image(ctx
, texObj
, target
, level
);
1166 /* Setup or redefine the texture object, texture and texture
1167 * image. Don't populate yet.
1169 ctx
->Driver
.TexImage1D(ctx
, target
, level
, internalFormat
,
1171 GL_RGBA
, CHAN_TYPE
, NULL
,
1172 &ctx
->DefaultPacking
, texObj
, texImage
);
1174 st_copy_texsubimage(ctx
, target
, level
,
1175 0, 0, 0, /* destX,Y,Z */
1176 x
, y
, width
, 1); /* src X, Y, size */
1181 st_CopyTexImage2D(GLcontext
* ctx
, GLenum target
, GLint level
,
1182 GLenum internalFormat
,
1183 GLint x
, GLint y
, GLsizei width
, GLsizei height
,
1186 struct gl_texture_unit
*texUnit
=
1187 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1188 struct gl_texture_object
*texObj
=
1189 _mesa_select_tex_object(ctx
, texUnit
, target
);
1190 struct gl_texture_image
*texImage
=
1191 _mesa_select_tex_image(ctx
, texObj
, target
, level
);
1193 /* Setup or redefine the texture object, texture and texture
1194 * image. Don't populate yet.
1196 ctx
->Driver
.TexImage2D(ctx
, target
, level
, internalFormat
,
1197 width
, height
, border
,
1198 GL_RGBA
, CHAN_TYPE
, NULL
,
1199 &ctx
->DefaultPacking
, texObj
, texImage
);
1201 st_copy_texsubimage(ctx
, target
, level
,
1202 0, 0, 0, /* destX,Y,Z */
1203 x
, y
, width
, height
); /* src X, Y, size */
1208 st_CopyTexSubImage1D(GLcontext
* ctx
, GLenum target
, GLint level
,
1209 GLint xoffset
, GLint x
, GLint y
, GLsizei width
)
1211 const GLint yoffset
= 0, zoffset
= 0;
1212 const GLsizei height
= 1;
1213 st_copy_texsubimage(ctx
, target
, level
,
1214 xoffset
, yoffset
, zoffset
, /* destX,Y,Z */
1215 x
, y
, width
, height
); /* src X, Y, size */
1220 st_CopyTexSubImage2D(GLcontext
* ctx
, GLenum target
, GLint level
,
1221 GLint xoffset
, GLint yoffset
,
1222 GLint x
, GLint y
, GLsizei width
, GLsizei height
)
1224 const GLint zoffset
= 0;
1225 st_copy_texsubimage(ctx
, target
, level
,
1226 xoffset
, yoffset
, zoffset
, /* destX,Y,Z */
1227 x
, y
, width
, height
); /* src X, Y, size */
1232 st_CopyTexSubImage3D(GLcontext
* ctx
, GLenum target
, GLint level
,
1233 GLint xoffset
, GLint yoffset
, GLint zoffset
,
1234 GLint x
, GLint y
, GLsizei width
, GLsizei height
)
1236 st_copy_texsubimage(ctx
, target
, level
,
1237 xoffset
, yoffset
, zoffset
, /* destX,Y,Z */
1238 x
, y
, width
, height
); /* src X, Y, size */
1243 * Compute which mipmap levels that really need to be sent to the hardware.
1244 * This depends on the base image size, GL_TEXTURE_MIN_LOD,
1245 * GL_TEXTURE_MAX_LOD, GL_TEXTURE_BASE_LEVEL, and GL_TEXTURE_MAX_LEVEL.
1248 calculate_first_last_level(struct st_texture_object
*stObj
)
1250 struct gl_texture_object
*tObj
= &stObj
->base
;
1252 /* These must be signed values. MinLod and MaxLod can be negative numbers,
1253 * and having firstLevel and lastLevel as signed prevents the need for
1254 * extra sign checks.
1259 /* Yes, this looks overly complicated, but it's all needed.
1261 switch (tObj
->Target
) {
1265 case GL_TEXTURE_CUBE_MAP
:
1266 if (tObj
->MinFilter
== GL_NEAREST
|| tObj
->MinFilter
== GL_LINEAR
) {
1267 /* GL_NEAREST and GL_LINEAR only care about GL_TEXTURE_BASE_LEVEL.
1269 firstLevel
= lastLevel
= tObj
->BaseLevel
;
1273 lastLevel
= MIN2(tObj
->MaxLevel
,
1274 (int) tObj
->Image
[0][tObj
->BaseLevel
]->WidthLog2
);
1277 case GL_TEXTURE_RECTANGLE_NV
:
1278 case GL_TEXTURE_4D_SGIS
:
1279 firstLevel
= lastLevel
= 0;
1285 stObj
->lastLevel
= lastLevel
;
1290 copy_image_data_to_texture(struct st_context
*st
,
1291 struct st_texture_object
*stObj
,
1293 struct st_texture_image
*stImage
)
1296 /* Copy potentially with the blitter:
1298 st_texture_image_copy(st
->pipe
,
1299 stObj
->pt
, dstLevel
, /* dest texture, level */
1300 stImage
->pt
, /* src texture */
1304 pipe_texture_reference(&stImage
->pt
, NULL
);
1306 else if (stImage
->base
.Data
) {
1307 assert(stImage
->base
.Data
!= NULL
);
1309 /* More straightforward upload.
1311 st_texture_image_data(st
->pipe
,
1316 stImage
->base
.RowStride
*
1317 stObj
->pt
->block
.size
,
1318 stImage
->base
.RowStride
*
1319 stImage
->base
.Height
*
1320 stObj
->pt
->block
.size
);
1321 _mesa_align_free(stImage
->base
.Data
);
1322 stImage
->base
.Data
= NULL
;
1325 pipe_texture_reference(&stImage
->pt
, stObj
->pt
);
1330 * Called during state validation. When this function is finished,
1331 * the texture object should be ready for rendering.
1332 * \return GL_TRUE for success, GL_FALSE for failure (out of mem)
1335 st_finalize_texture(GLcontext
*ctx
,
1336 struct pipe_context
*pipe
,
1337 struct gl_texture_object
*tObj
,
1338 GLboolean
*needFlush
)
1340 struct st_texture_object
*stObj
= st_texture_object(tObj
);
1341 const GLuint nr_faces
= (stObj
->base
.Target
== GL_TEXTURE_CUBE_MAP
) ? 6 : 1;
1345 struct st_texture_image
*firstImage
;
1347 *needFlush
= GL_FALSE
;
1349 /* We know/require this is true by now:
1351 assert(stObj
->base
._Complete
);
1353 /* What levels must the texture include at a minimum?
1355 calculate_first_last_level(stObj
);
1356 firstImage
= st_texture_image(stObj
->base
.Image
[0][stObj
->base
.BaseLevel
]);
1358 /* If both firstImage and stObj point to a texture which can contain
1359 * all active images, favour firstImage. Note that because of the
1360 * completeness requirement, we know that the image dimensions
1363 if (firstImage
->pt
&&
1364 firstImage
->pt
!= stObj
->pt
&&
1365 firstImage
->pt
->last_level
>= stObj
->lastLevel
) {
1366 pipe_texture_reference(&stObj
->pt
, firstImage
->pt
);
1369 /* FIXME: determine format block instead of cpp */
1370 if (firstImage
->base
.IsCompressed
) {
1371 comp_byte
= compressed_num_bytes(firstImage
->base
.TexFormat
->MesaFormat
);
1375 cpp
= firstImage
->base
.TexFormat
->TexelBytes
;
1378 /* If we already have a gallium texture, check that it matches the texture
1379 * object's format, target, size, num_levels, etc.
1382 const enum pipe_format fmt
=
1383 st_mesa_format_to_pipe_format(firstImage
->base
.TexFormat
->MesaFormat
);
1384 if (stObj
->pt
->target
!= gl_target_to_pipe(stObj
->base
.Target
) ||
1385 stObj
->pt
->format
!= fmt
||
1386 stObj
->pt
->last_level
< stObj
->lastLevel
||
1387 stObj
->pt
->width
[0] != firstImage
->base
.Width2
||
1388 stObj
->pt
->height
[0] != firstImage
->base
.Height2
||
1389 stObj
->pt
->depth
[0] != firstImage
->base
.Depth2
||
1390 stObj
->pt
->block
.size
/stObj
->pt
->block
.width
!= cpp
|| /* Nominal bytes per pixel */
1391 stObj
->pt
->compressed
!= firstImage
->base
.IsCompressed
) {
1392 pipe_texture_reference(&stObj
->pt
, NULL
);
1393 ctx
->st
->dirty
.st
|= ST_NEW_FRAMEBUFFER
;
1397 /* May need to create a new gallium texture:
1400 const enum pipe_format fmt
=
1401 st_mesa_format_to_pipe_format(firstImage
->base
.TexFormat
->MesaFormat
);
1402 stObj
->pt
= st_texture_create(ctx
->st
,
1403 gl_target_to_pipe(stObj
->base
.Target
),
1406 firstImage
->base
.Width2
,
1407 firstImage
->base
.Height2
,
1408 firstImage
->base
.Depth2
,
1410 ( (pf_is_depth_stencil(fmt
) ?
1411 PIPE_TEXTURE_USAGE_DEPTH_STENCIL
:
1412 PIPE_TEXTURE_USAGE_RENDER_TARGET
) |
1413 PIPE_TEXTURE_USAGE_SAMPLER
));
1416 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexImage");
1421 /* Pull in any images not in the object's texture:
1423 for (face
= 0; face
< nr_faces
; face
++) {
1425 for (level
= 0; level
<= stObj
->lastLevel
; level
++) {
1426 struct st_texture_image
*stImage
=
1427 st_texture_image(stObj
->base
.Image
[face
][stObj
->base
.BaseLevel
+ level
]);
1429 /* Need to import images in main memory or held in other textures.
1431 if (stImage
&& stObj
->pt
!= stImage
->pt
) {
1432 copy_image_data_to_texture(ctx
->st
, stObj
, level
, stImage
);
1433 *needFlush
= GL_TRUE
;
1443 * Returns pointer to a default/dummy texture.
1444 * This is typically used when the current shader has tex/sample instructions
1445 * but the user has not provided a (any) texture(s).
1447 struct gl_texture_object
*
1448 st_get_default_texture(struct st_context
*st
)
1450 if (!st
->default_texture
) {
1451 static const GLenum target
= GL_TEXTURE_2D
;
1452 GLubyte pixels
[16][16][4];
1453 struct gl_texture_object
*texObj
;
1454 struct gl_texture_image
*texImg
;
1457 /* The ARB_fragment_program spec says (0,0,0,1) should be returned
1458 * when attempting to sample incomplete textures.
1460 for (i
= 0; i
< 16; i
++) {
1461 for (j
= 0; j
< 16; j
++) {
1462 pixels
[i
][j
][0] = 0;
1463 pixels
[i
][j
][1] = 0;
1464 pixels
[i
][j
][2] = 0;
1465 pixels
[i
][j
][3] = 255;
1469 texObj
= st
->ctx
->Driver
.NewTextureObject(st
->ctx
, 0, target
);
1471 texImg
= _mesa_get_tex_image(st
->ctx
, texObj
, target
, 0);
1473 _mesa_init_teximage_fields(st
->ctx
, target
, texImg
,
1474 16, 16, 1, 0, /* w, h, d, border */
1477 st_TexImage(st
->ctx
, 2, target
,
1478 0, GL_RGBA
, /* level, intformat */
1479 16, 16, 1, 0, /* w, h, d, border */
1480 GL_RGBA
, GL_UNSIGNED_BYTE
, pixels
,
1481 &st
->ctx
->DefaultPacking
,
1485 texObj
->MinFilter
= GL_NEAREST
;
1486 texObj
->MagFilter
= GL_NEAREST
;
1487 texObj
->_Complete
= GL_TRUE
;
1489 st
->default_texture
= texObj
;
1491 return st
->default_texture
;
1496 st_init_texture_functions(struct dd_function_table
*functions
)
1498 functions
->ChooseTextureFormat
= st_ChooseTextureFormat
;
1499 functions
->TexImage1D
= st_TexImage1D
;
1500 functions
->TexImage2D
= st_TexImage2D
;
1501 functions
->TexImage3D
= st_TexImage3D
;
1502 functions
->TexSubImage1D
= st_TexSubImage1D
;
1503 functions
->TexSubImage2D
= st_TexSubImage2D
;
1504 functions
->TexSubImage3D
= st_TexSubImage3D
;
1505 functions
->CopyTexImage1D
= st_CopyTexImage1D
;
1506 functions
->CopyTexImage2D
= st_CopyTexImage2D
;
1507 functions
->CopyTexSubImage1D
= st_CopyTexSubImage1D
;
1508 functions
->CopyTexSubImage2D
= st_CopyTexSubImage2D
;
1509 functions
->CopyTexSubImage3D
= st_CopyTexSubImage3D
;
1510 functions
->GenerateMipmap
= st_generate_mipmap
;
1512 functions
->GetTexImage
= st_GetTexImage
;
1514 /* compressed texture functions */
1515 functions
->CompressedTexImage2D
= st_CompressedTexImage2D
;
1516 functions
->GetCompressedTexImage
= st_GetCompressedTexImage
;
1517 functions
->CompressedTextureSize
= _mesa_compressed_texture_size
;
1519 functions
->NewTextureObject
= st_NewTextureObject
;
1520 functions
->NewTextureImage
= st_NewTextureImage
;
1521 functions
->DeleteTexture
= st_DeleteTextureObject
;
1522 functions
->FreeTexImageData
= st_FreeTextureImageData
;
1523 functions
->UpdateTexturePalette
= 0;
1525 functions
->TextureMemCpy
= do_memcpy
;
1527 /* XXX Temporary until we can query pipe's texture sizes */
1528 functions
->TestProxyTexImage
= _mesa_test_proxy_teximage
;