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/imports.h"
29 #if FEATURE_convolution
30 #include "main/convolve.h"
32 #include "main/enums.h"
33 #include "main/image.h"
34 #include "main/macros.h"
35 #include "main/mipmap.h"
36 #include "main/pixel.h"
37 #include "main/texcompress.h"
38 #include "main/texformat.h"
39 #include "main/teximage.h"
40 #include "main/texobj.h"
41 #include "main/texstore.h"
43 #include "state_tracker/st_context.h"
44 #include "state_tracker/st_cb_fbo.h"
45 #include "state_tracker/st_cb_texture.h"
46 #include "state_tracker/st_format.h"
47 #include "state_tracker/st_public.h"
48 #include "state_tracker/st_texture.h"
49 #include "state_tracker/st_gen_mipmap.h"
51 #include "pipe/p_context.h"
52 #include "pipe/p_defines.h"
53 #include "pipe/p_inlines.h"
54 #include "util/p_tile.h"
55 #include "util/u_blit.h"
58 #define DBG if (0) printf
61 static INLINE
struct st_texture_image
*
62 st_texture_image(struct gl_texture_image
*img
)
64 return (struct st_texture_image
*) img
;
68 static enum pipe_texture_target
69 gl_target_to_pipe(GLenum target
)
73 return PIPE_TEXTURE_1D
;
76 case GL_TEXTURE_RECTANGLE_NV
:
77 return PIPE_TEXTURE_2D
;
80 return PIPE_TEXTURE_3D
;
82 case GL_TEXTURE_CUBE_MAP_ARB
:
83 return PIPE_TEXTURE_CUBE
;
93 * Return nominal bytes per texel for a compressed format, 0 for non-compressed
97 compressed_num_bytes(GLuint mesaFormat
)
100 #if FEATURE_texture_fxt1
101 case MESA_FORMAT_RGB_FXT1
:
102 case MESA_FORMAT_RGBA_FXT1
:
104 #if FEATURE_texture_s3tc
105 case MESA_FORMAT_RGB_DXT1
:
106 case MESA_FORMAT_RGBA_DXT1
:
108 case MESA_FORMAT_RGBA_DXT3
:
109 case MESA_FORMAT_RGBA_DXT5
:
119 st_IsTextureResident(GLcontext
* ctx
, struct gl_texture_object
*texObj
)
122 struct intel_context
*intel
= intel_context(ctx
);
123 struct st_texture_object
*stObj
= st_texture_object(texObj
);
128 intel_is_region_resident(intel
, stObj
->pt
->region
);
134 static struct gl_texture_image
*
135 st_NewTextureImage(GLcontext
* ctx
)
137 DBG("%s\n", __FUNCTION__
);
139 return (struct gl_texture_image
*) CALLOC_STRUCT(st_texture_image
);
143 static struct gl_texture_object
*
144 st_NewTextureObject(GLcontext
* ctx
, GLuint name
, GLenum target
)
146 struct st_texture_object
*obj
= CALLOC_STRUCT(st_texture_object
);
148 DBG("%s\n", __FUNCTION__
);
149 _mesa_initialize_texture_object(&obj
->base
, name
, target
);
155 st_DeleteTextureObject(GLcontext
*ctx
,
156 struct gl_texture_object
*texObj
)
158 struct st_texture_object
*stObj
= st_texture_object(texObj
);
160 pipe_texture_reference(&stObj
->pt
, NULL
);
162 _mesa_delete_texture_object(ctx
, texObj
);
167 st_FreeTextureImageData(GLcontext
* ctx
, struct gl_texture_image
*texImage
)
169 struct st_texture_image
*stImage
= st_texture_image(texImage
);
171 DBG("%s\n", __FUNCTION__
);
174 pipe_texture_reference(&stImage
->pt
, NULL
);
177 if (texImage
->Data
) {
178 free(texImage
->Data
);
179 texImage
->Data
= NULL
;
184 /* ================================================================
185 * From linux kernel i386 header files, copes with odd sizes better
186 * than COPY_DWORDS would:
187 * XXX Put this in src/mesa/main/imports.h ???
189 #if defined(i386) || defined(__i386__)
191 __memcpy(void *to
, const void *from
, size_t n
)
194 __asm__
__volatile__("rep ; movsl\n\t"
198 "1:\ttestb $1,%b4\n\t"
200 "movsb\n" "2:":"=&c"(d0
), "=&D"(d1
), "=&S"(d2
)
201 :"0"(n
/ 4), "q"(n
), "1"((long) to
), "2"((long) from
)
206 #define __memcpy(a,b,c) memcpy(a,b,c)
210 /* The system memcpy (at least on ubuntu 5.10) has problems copying
211 * to agp (writecombined) memory from a source which isn't 64-byte
212 * aligned - there is a 4x performance falloff.
214 * The x86 __memcpy is immune to this but is slightly slower
215 * (10%-ish) than the system memcpy.
217 * The sse_memcpy seems to have a slight cliff at 64/32 bytes, but
218 * isn't much faster than x86_memcpy for agp copies.
220 * TODO: switch dynamically.
223 do_memcpy(void *dest
, const void *src
, size_t n
)
225 if ((((unsigned) src
) & 63) || (((unsigned) dest
) & 63)) {
226 return __memcpy(dest
, src
, n
);
229 return memcpy(dest
, src
, n
);
233 /* Functions to store texture images. Where possible, textures
234 * will be created or further instantiated with image data, otherwise
235 * images will be stored in malloc'd memory. A validation step is
236 * required to pull those images into a texture, or otherwise
237 * decide a fallback is required.
257 * Allocate a pipe_texture object for the given st_texture_object using
258 * the given st_texture_image to guess the mipmap size/levels.
261 * Otherwise, store it in memory if (Border != 0) or (any dimension ==
264 * Otherwise, if max_level >= level >= min_level, create texture with
265 * space for images from min_level down to max_level.
267 * Otherwise, create texture with space for images from (level 0)..(1x1).
268 * Consider pruning this texture at a validation if the saving is worth it.
271 guess_and_alloc_texture(struct st_context
*st
,
272 struct st_texture_object
*stObj
,
273 const struct st_texture_image
*stImage
)
277 GLuint width
= stImage
->base
.Width2
; /* size w/out border */
278 GLuint height
= stImage
->base
.Height2
;
279 GLuint depth
= stImage
->base
.Depth2
;
280 GLuint i
, comp_byte
= 0;
281 enum pipe_format fmt
;
283 DBG("%s\n", __FUNCTION__
);
288 stImage
->level
> stObj
->base
.BaseLevel
&&
289 (stImage
->base
.Width
== 1 ||
290 (stObj
->base
.Target
!= GL_TEXTURE_1D
&&
291 stImage
->base
.Height
== 1) ||
292 (stObj
->base
.Target
== GL_TEXTURE_3D
&&
293 stImage
->base
.Depth
== 1)))
296 /* If this image disrespects BaseLevel, allocate from level zero.
297 * Usually BaseLevel == 0, so it's unlikely to happen.
299 if (stImage
->level
< stObj
->base
.BaseLevel
)
302 firstLevel
= stObj
->base
.BaseLevel
;
305 /* Figure out image dimensions at start level.
307 for (i
= stImage
->level
; i
> firstLevel
; i
--) {
316 if (width
== 0 || height
== 0 || depth
== 0) {
317 /* no texture needed */
321 /* Guess a reasonable value for lastLevel. This is probably going
322 * to be wrong fairly often and might mean that we have to look at
323 * resizable buffers, or require that buffers implement lazy
324 * pagetable arrangements.
326 if ((stObj
->base
.MinFilter
== GL_NEAREST
||
327 stObj
->base
.MinFilter
== GL_LINEAR
) &&
328 stImage
->level
== firstLevel
) {
329 lastLevel
= firstLevel
;
332 GLuint l2width
= logbase2(width
);
333 GLuint l2height
= logbase2(height
);
334 GLuint l2depth
= logbase2(depth
);
335 lastLevel
= firstLevel
+ MAX2(MAX2(l2width
, l2height
), l2depth
);
338 if (stImage
->base
.IsCompressed
)
339 comp_byte
= compressed_num_bytes(stImage
->base
.TexFormat
->MesaFormat
);
341 fmt
= st_mesa_format_to_pipe_format(stImage
->base
.TexFormat
->MesaFormat
);
342 stObj
->pt
= st_texture_create(st
,
343 gl_target_to_pipe(stObj
->base
.Target
),
350 ( (pf_is_depth_stencil(fmt
) ?
351 PIPE_TEXTURE_USAGE_DEPTH_STENCIL
:
352 PIPE_TEXTURE_USAGE_RENDER_TARGET
) |
353 PIPE_TEXTURE_USAGE_SAMPLER
));
355 DBG("%s - success\n", __FUNCTION__
);
359 /* There are actually quite a few combinations this will work for,
360 * more than what I've listed here.
363 check_pbo_format(GLint internalFormat
,
364 GLenum format
, GLenum type
,
365 const struct gl_texture_format
*mesa_format
)
367 switch (internalFormat
) {
370 return (format
== GL_BGRA
&&
371 (type
== GL_UNSIGNED_BYTE
||
372 type
== GL_UNSIGNED_INT_8_8_8_8_REV
) &&
373 mesa_format
== &_mesa_texformat_argb8888
);
376 return (format
== GL_RGB
&&
377 type
== GL_UNSIGNED_SHORT_5_6_5
&&
378 mesa_format
== &_mesa_texformat_rgb565
);
380 return (type
== GL_UNSIGNED_SHORT_8_8_MESA
|| type
== GL_UNSIGNED_BYTE
);
387 /* XXX: Do this for TexSubImage also:
390 try_pbo_upload(GLcontext
*ctx
,
391 struct st_texture_image
*stImage
,
392 const struct gl_pixelstore_attrib
*unpack
,
393 GLint internalFormat
,
394 GLint width
, GLint height
,
395 GLenum format
, GLenum type
, const void *pixels
)
397 return GL_FALSE
; /* XXX fix flushing/locking/blitting below */
399 struct intel_context
*intel
= intel_context(ctx
);
400 struct intel_buffer_object
*pbo
= intel_buffer_object(unpack
->BufferObj
);
401 GLuint src_offset
, src_stride
;
402 GLuint dst_offset
, dst_stride
;
405 ctx
._ImageTransferState
||
406 unpack
->SkipPixels
|| unpack
->SkipRows
) {
407 _mesa_printf("%s: failure 1\n", __FUNCTION__
);
411 src_offset
= (GLuint
) pixels
;
413 if (unpack
->RowLength
> 0)
414 src_stride
= unpack
->RowLength
;
418 dst_offset
= st_texture_image_offset(stImage
->pt
,
422 dst_stride
= stImage
->pt
->pitch
;
425 struct _DriBufferObject
*src_buffer
=
426 intel_bufferobj_buffer(intel
, pbo
, INTEL_READ
);
428 /* Temporary hack: cast to _DriBufferObject:
430 struct _DriBufferObject
*dst_buffer
=
431 (struct _DriBufferObject
*)stImage
->pt
->region
->buffer
;
434 intelEmitCopyBlit(intel
,
436 src_stride
, src_buffer
, src_offset
,
437 dst_stride
, dst_buffer
, dst_offset
,
438 0, 0, 0, 0, width
, height
,
448 * Adjust pixel unpack params and image dimensions to strip off the
450 * Gallium doesn't support texture borders. They've seldem been used
451 * and seldom been implemented correctly anyway.
452 * \param unpackNew returns the new pixel unpack parameters
455 strip_texture_border(GLint border
,
456 GLint
*width
, GLint
*height
, GLint
*depth
,
457 const struct gl_pixelstore_attrib
*unpack
,
458 struct gl_pixelstore_attrib
*unpackNew
)
460 assert(border
> 0); /* sanity check */
462 *unpackNew
= *unpack
;
464 if (unpackNew
->RowLength
== 0)
465 unpackNew
->RowLength
= *width
;
467 if (depth
&& unpackNew
->ImageHeight
== 0)
468 unpackNew
->ImageHeight
= *height
;
470 unpackNew
->SkipPixels
+= border
;
472 unpackNew
->SkipRows
+= border
;
474 unpackNew
->SkipImages
+= border
;
477 *width
= *width
- 2 * border
;
478 if (height
&& *height
>= 3)
479 *height
= *height
- 2 * border
;
480 if (depth
&& *depth
>= 3)
481 *depth
= *depth
- 2 * border
;
486 st_TexImage(GLcontext
* ctx
,
488 GLenum target
, GLint level
,
489 GLint internalFormat
,
490 GLint width
, GLint height
, GLint depth
,
492 GLenum format
, GLenum type
, const void *pixels
,
493 const struct gl_pixelstore_attrib
*unpack
,
494 struct gl_texture_object
*texObj
,
495 struct gl_texture_image
*texImage
,
496 GLsizei imageSize
, int compressed
)
498 struct st_texture_object
*stObj
= st_texture_object(texObj
);
499 struct st_texture_image
*stImage
= st_texture_image(texImage
);
500 GLint postConvWidth
, postConvHeight
;
501 GLint texelBytes
, sizeInBytes
;
503 struct gl_pixelstore_attrib unpackNB
;
505 DBG("%s target %s level %d %dx%dx%d border %d\n", __FUNCTION__
,
506 _mesa_lookup_enum_by_nr(target
), level
, width
, height
, depth
, border
);
508 /* gallium does not support texture borders, strip it off */
510 strip_texture_border(border
, &width
, &height
, &depth
,
513 texImage
->Width
= width
;
514 texImage
->Height
= height
;
515 texImage
->Depth
= depth
;
516 texImage
->Border
= 0;
520 postConvWidth
= width
;
521 postConvHeight
= height
;
523 stImage
->face
= _mesa_tex_target_to_face(target
);
524 stImage
->level
= level
;
526 #if FEATURE_convolution
527 if (ctx
->_ImageTransferState
& IMAGE_CONVOLUTION_BIT
) {
528 _mesa_adjust_image_for_convolution(ctx
, dims
, &postConvWidth
,
533 /* choose the texture format */
534 texImage
->TexFormat
= st_ChooseTextureFormat(ctx
, internalFormat
,
537 _mesa_set_fetch_functions(texImage
, dims
);
539 if (texImage
->TexFormat
->TexelBytes
== 0) {
540 /* must be a compressed format */
542 texImage
->IsCompressed
= GL_TRUE
;
543 texImage
->CompressedSize
=
544 ctx
->Driver
.CompressedTextureSize(ctx
, texImage
->Width
,
545 texImage
->Height
, texImage
->Depth
,
546 texImage
->TexFormat
->MesaFormat
);
549 texelBytes
= texImage
->TexFormat
->TexelBytes
;
551 /* Minimum pitch of 32 bytes */
552 if (postConvWidth
* texelBytes
< 32) {
553 postConvWidth
= 32 / texelBytes
;
554 texImage
->RowStride
= postConvWidth
;
557 /* we'll set RowStride elsewhere when the texture is a "mapped" state */
558 /*assert(texImage->RowStride == postConvWidth);*/
561 /* Release the reference to a potentially orphaned buffer.
562 * Release any old malloced memory.
565 pipe_texture_reference(&stImage
->pt
, NULL
);
566 assert(!texImage
->Data
);
568 else if (texImage
->Data
) {
569 _mesa_align_free(texImage
->Data
);
572 /* If this is the only mipmap level in the texture, could call
573 * bmBufferData with NULL data to free the old block and avoid
574 * waiting on any outstanding fences.
577 (stObj
->teximage_realloc
||
578 (/*stObj->pt->first_level == level &&*/
579 stObj
->pt
->last_level
== level
&&
580 stObj
->pt
->target
!= PIPE_TEXTURE_CUBE
&&
581 !st_texture_match_image(stObj
->pt
, &stImage
->base
,
582 stImage
->face
, stImage
->level
)))) {
585 pipe_texture_reference(&stObj
->pt
, NULL
);
587 stObj
->teximage_realloc
= FALSE
;
591 guess_and_alloc_texture(ctx
->st
, stObj
, stImage
);
593 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexImage");
598 assert(!stImage
->pt
);
601 st_texture_match_image(stObj
->pt
, &stImage
->base
,
602 stImage
->face
, stImage
->level
)) {
604 pipe_texture_reference(&stImage
->pt
, stObj
->pt
);
609 DBG("XXX: Image did not fit into texture - storing in local memory!\n");
611 #if 0 /* XXX FIX when st_buffer_objects are in place */
616 intel_buffer_object(unpack
->BufferObj
) &&
617 check_pbo_format(internalFormat
, format
,
618 type
, texImage
->TexFormat
)) {
620 DBG("trying pbo upload\n");
624 /* Otherwise, attempt to use the blitter for PBO image uploads.
626 if (try_pbo_upload(intel
, stImage
, unpack
,
628 width
, height
, format
, type
, pixels
)) {
629 DBG("pbo upload succeeded\n");
633 DBG("pbo upload failed\n");
636 (void) try_pbo_upload
;
637 (void) check_pbo_format
;
641 /* st_CopyTexImage calls this function with pixels == NULL, with
642 * the expectation that the texture will be set up but nothing
643 * more will be done. This is where those calls return:
646 pixels
= _mesa_validate_pbo_compressed_teximage(ctx
, imageSize
, pixels
,
648 "glCompressedTexImage");
650 pixels
= _mesa_validate_pbo_teximage(ctx
, dims
, width
, height
, 1,
652 pixels
, unpack
, "glTexImage");
658 texImage
->Data
= st_texture_image_map(ctx
->st
, stImage
, 0,
659 PIPE_BUFFER_USAGE_CPU_WRITE
);
660 if (stImage
->surface
)
661 dstRowStride
= stImage
->surface
->stride
;
664 /* Allocate regular memory and store the image there temporarily. */
665 if (texImage
->IsCompressed
) {
666 sizeInBytes
= texImage
->CompressedSize
;
668 _mesa_compressed_row_stride(texImage
->TexFormat
->MesaFormat
, width
);
672 dstRowStride
= postConvWidth
* texelBytes
;
673 sizeInBytes
= depth
* dstRowStride
* postConvHeight
;
676 texImage
->Data
= malloc(sizeInBytes
);
679 if (!texImage
->Data
) {
680 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexImage");
684 DBG("Upload image %dx%dx%d row_len %x pitch %x\n",
685 width
, height
, depth
, width
* texelBytes
, dstRowStride
);
687 /* Copy data. Would like to know when it's ok for us to eg. use
688 * the blitter to copy. Or, use the hardware to do the format
689 * conversion and copy:
692 memcpy(texImage
->Data
, pixels
, imageSize
);
695 GLuint srcImageStride
= _mesa_image_image_stride(unpack
, width
, height
,
698 const GLubyte
*src
= (const GLubyte
*) pixels
;
700 for (i
= 0; i
++ < depth
;) {
701 if (!texImage
->TexFormat
->StoreImage(ctx
, dims
,
702 texImage
->_BaseFormat
,
705 0, 0, 0, /* dstX/Y/Zoffset */
707 texImage
->ImageOffsets
,
709 format
, type
, src
, unpack
)) {
710 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexImage");
713 if (stImage
->pt
&& i
< depth
) {
714 st_texture_image_unmap(ctx
->st
, stImage
);
715 texImage
->Data
= st_texture_image_map(ctx
->st
, stImage
, i
,
716 PIPE_BUFFER_USAGE_CPU_WRITE
);
717 src
+= srcImageStride
;
722 _mesa_unmap_teximage_pbo(ctx
, unpack
);
725 st_texture_image_unmap(ctx
->st
, stImage
);
726 texImage
->Data
= NULL
;
729 if (level
== texObj
->BaseLevel
&& texObj
->GenerateMipmap
) {
730 ctx
->Driver
.GenerateMipmap(ctx
, target
, texObj
);
736 st_TexImage3D(GLcontext
* ctx
,
737 GLenum target
, GLint level
,
738 GLint internalFormat
,
739 GLint width
, GLint height
, GLint depth
,
741 GLenum format
, GLenum type
, const void *pixels
,
742 const struct gl_pixelstore_attrib
*unpack
,
743 struct gl_texture_object
*texObj
,
744 struct gl_texture_image
*texImage
)
746 st_TexImage(ctx
, 3, target
, level
,
747 internalFormat
, width
, height
, depth
, border
,
748 format
, type
, pixels
, unpack
, texObj
, texImage
, 0, 0);
753 st_TexImage2D(GLcontext
* ctx
,
754 GLenum target
, GLint level
,
755 GLint internalFormat
,
756 GLint width
, GLint height
, GLint border
,
757 GLenum format
, GLenum type
, const void *pixels
,
758 const struct gl_pixelstore_attrib
*unpack
,
759 struct gl_texture_object
*texObj
,
760 struct gl_texture_image
*texImage
)
762 st_TexImage(ctx
, 2, target
, level
,
763 internalFormat
, width
, height
, 1, border
,
764 format
, type
, pixels
, unpack
, texObj
, texImage
, 0, 0);
769 st_TexImage1D(GLcontext
* ctx
,
770 GLenum target
, GLint level
,
771 GLint internalFormat
,
772 GLint width
, GLint border
,
773 GLenum format
, GLenum type
, const void *pixels
,
774 const struct gl_pixelstore_attrib
*unpack
,
775 struct gl_texture_object
*texObj
,
776 struct gl_texture_image
*texImage
)
778 st_TexImage(ctx
, 1, target
, level
,
779 internalFormat
, width
, 1, 1, border
,
780 format
, type
, pixels
, unpack
, texObj
, texImage
, 0, 0);
785 st_CompressedTexImage2D( GLcontext
*ctx
, GLenum target
, GLint level
,
786 GLint internalFormat
,
787 GLint width
, GLint height
, GLint border
,
788 GLsizei imageSize
, const GLvoid
*data
,
789 struct gl_texture_object
*texObj
,
790 struct gl_texture_image
*texImage
)
792 st_TexImage(ctx
, 2, target
, level
,
793 internalFormat
, width
, height
, 1, border
,
794 0, 0, data
, &ctx
->Unpack
, texObj
, texImage
, imageSize
, 1);
799 * Need to map texture image into memory before copying image data,
803 st_get_tex_image(GLcontext
* ctx
, GLenum target
, GLint level
,
804 GLenum format
, GLenum type
, GLvoid
* pixels
,
805 struct gl_texture_object
*texObj
,
806 struct gl_texture_image
*texImage
, int compressed
)
808 struct st_texture_image
*stImage
= st_texture_image(texImage
);
809 GLuint dstImageStride
= _mesa_image_image_stride(&ctx
->Pack
, texImage
->Width
,
810 texImage
->Height
, format
,
818 /* Image is stored in hardware format in a buffer managed by the
819 * kernel. Need to explicitly map and unmap it.
821 texImage
->Data
= st_texture_image_map(ctx
->st
, stImage
, 0,
822 PIPE_BUFFER_USAGE_CPU_READ
);
823 texImage
->RowStride
= stImage
->surface
->stride
/ stImage
->pt
->block
.size
;
826 /* Otherwise, the image should actually be stored in
827 * texImage->Data. This is pretty confusing for
828 * everybody, I'd much prefer to separate the two functions of
829 * texImage->Data - storage for texture images in main memory
830 * and access (ie mappings) of images. In other words, we'd
831 * create a new texImage->Map field and leave Data simply for
834 assert(texImage
->Data
);
837 depth
= texImage
->Depth
;
840 dest
= (GLubyte
*) pixels
;
842 for (i
= 0; i
++ < depth
;) {
844 _mesa_get_compressed_teximage(ctx
, target
, level
, dest
,
847 _mesa_get_teximage(ctx
, target
, level
, format
, type
, dest
,
851 if (stImage
->pt
&& i
< depth
) {
852 st_texture_image_unmap(ctx
->st
, stImage
);
853 texImage
->Data
= st_texture_image_map(ctx
->st
, stImage
, i
,
854 PIPE_BUFFER_USAGE_CPU_READ
);
855 dest
+= dstImageStride
;
859 texImage
->Depth
= depth
;
863 st_texture_image_unmap(ctx
->st
, stImage
);
864 texImage
->Data
= NULL
;
870 st_GetTexImage(GLcontext
* ctx
, GLenum target
, GLint level
,
871 GLenum format
, GLenum type
, GLvoid
* pixels
,
872 struct gl_texture_object
*texObj
,
873 struct gl_texture_image
*texImage
)
875 st_get_tex_image(ctx
, target
, level
, format
, type
, pixels
,
876 texObj
, texImage
, 0);
881 st_GetCompressedTexImage(GLcontext
*ctx
, GLenum target
, GLint level
,
883 const struct gl_texture_object
*texObj
,
884 const struct gl_texture_image
*texImage
)
886 st_get_tex_image(ctx
, target
, level
, 0, 0, pixels
,
887 (struct gl_texture_object
*) texObj
,
888 (struct gl_texture_image
*) texImage
, 1);
894 st_TexSubimage(GLcontext
* ctx
,
896 GLenum target
, GLint level
,
897 GLint xoffset
, GLint yoffset
, GLint zoffset
,
898 GLint width
, GLint height
, GLint depth
,
899 GLenum format
, GLenum type
, const void *pixels
,
900 const struct gl_pixelstore_attrib
*packing
,
901 struct gl_texture_object
*texObj
,
902 struct gl_texture_image
*texImage
)
904 struct st_texture_image
*stImage
= st_texture_image(texImage
);
906 GLuint srcImageStride
= _mesa_image_image_stride(packing
, width
, height
,
911 DBG("%s target %s level %d offset %d,%d %dx%d\n", __FUNCTION__
,
912 _mesa_lookup_enum_by_nr(target
),
913 level
, xoffset
, yoffset
, width
, height
);
916 _mesa_validate_pbo_teximage(ctx
, dims
, width
, height
, depth
, format
,
917 type
, pixels
, packing
, "glTexSubImage2D");
921 /* Map buffer if necessary. Need to lock to prevent other contexts
922 * from uploading the buffer under us.
925 texImage
->Data
= st_texture_image_map(ctx
->st
, stImage
, zoffset
,
926 PIPE_BUFFER_USAGE_CPU_WRITE
);
927 if (stImage
->surface
)
928 dstRowStride
= stImage
->surface
->stride
;
931 if (!texImage
->Data
) {
932 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexSubImage");
936 src
= (const GLubyte
*) pixels
;
938 for (i
= 0; i
++ < depth
;) {
939 if (!texImage
->TexFormat
->StoreImage(ctx
, dims
, texImage
->_BaseFormat
,
944 texImage
->ImageOffsets
,
946 format
, type
, src
, packing
)) {
947 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexSubImage");
950 if (stImage
->pt
&& i
< depth
) {
951 /* map next slice of 3D texture */
952 st_texture_image_unmap(ctx
->st
, stImage
);
953 texImage
->Data
= st_texture_image_map(ctx
->st
, stImage
, zoffset
+ i
,
954 PIPE_BUFFER_USAGE_CPU_WRITE
);
955 src
+= srcImageStride
;
959 if (level
== texObj
->BaseLevel
&& texObj
->GenerateMipmap
) {
960 ctx
->Driver
.GenerateMipmap(ctx
, target
, texObj
);
963 _mesa_unmap_teximage_pbo(ctx
, packing
);
966 st_texture_image_unmap(ctx
->st
, stImage
);
967 texImage
->Data
= NULL
;
974 st_TexSubImage3D(GLcontext
* ctx
,
977 GLint xoffset
, GLint yoffset
, GLint zoffset
,
978 GLsizei width
, GLsizei height
, GLsizei depth
,
979 GLenum format
, GLenum type
,
980 const GLvoid
* pixels
,
981 const struct gl_pixelstore_attrib
*packing
,
982 struct gl_texture_object
*texObj
,
983 struct gl_texture_image
*texImage
)
985 st_TexSubimage(ctx
, 3, target
, level
,
986 xoffset
, yoffset
, zoffset
,
987 width
, height
, depth
,
988 format
, type
, pixels
, packing
, texObj
, texImage
);
994 st_TexSubImage2D(GLcontext
* ctx
,
997 GLint xoffset
, GLint yoffset
,
998 GLsizei width
, GLsizei height
,
999 GLenum format
, GLenum type
,
1000 const GLvoid
* pixels
,
1001 const struct gl_pixelstore_attrib
*packing
,
1002 struct gl_texture_object
*texObj
,
1003 struct gl_texture_image
*texImage
)
1005 st_TexSubimage(ctx
, 2, target
, level
,
1006 xoffset
, yoffset
, 0,
1008 format
, type
, pixels
, packing
, texObj
, texImage
);
1013 st_TexSubImage1D(GLcontext
* ctx
,
1018 GLenum format
, GLenum type
,
1019 const GLvoid
* pixels
,
1020 const struct gl_pixelstore_attrib
*packing
,
1021 struct gl_texture_object
*texObj
,
1022 struct gl_texture_image
*texImage
)
1024 st_TexSubimage(ctx
, 1, target
, level
,
1027 format
, type
, pixels
, packing
, texObj
, texImage
);
1033 * Return 0 for GL_TEXTURE_CUBE_MAP_POSITIVE_X,
1034 * 1 for GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
1036 * XXX duplicated from main/teximage.c
1039 texture_face(GLenum target
)
1041 if (target
>= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB
&&
1042 target
<= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB
)
1043 return (GLuint
) target
- (GLuint
) GL_TEXTURE_CUBE_MAP_POSITIVE_X
;
1051 * Do a CopyTexSubImage operation by mapping the source surface and
1052 * dest surface and using get_tile()/put_tile() to access the pixels/texels.
1054 * Note: srcY=0=TOP of renderbuffer
1057 fallback_copy_texsubimage(GLcontext
*ctx
,
1060 struct st_renderbuffer
*strb
,
1061 struct st_texture_image
*stImage
,
1063 GLint destX
, GLint destY
, GLint destZ
,
1064 GLint srcX
, GLint srcY
,
1065 GLsizei width
, GLsizei height
)
1067 struct pipe_context
*pipe
= ctx
->st
->pipe
;
1068 struct pipe_screen
*screen
= pipe
->screen
;
1069 const uint face
= texture_face(target
);
1070 struct pipe_texture
*pt
= stImage
->pt
;
1071 struct pipe_surface
*src_surf
, *dest_surf
;
1074 st_flush(ctx
->st
, PIPE_FLUSH_RENDER_CACHE
, NULL
);
1076 /* determine bottom-to-top vs. top-to-bottom order */
1077 if (st_fb_orientation(ctx
->ReadBuffer
) == Y_0_TOP
) {
1078 destY
= height
- 1 - destY
;
1085 src_surf
= strb
->surface
;
1086 src_surf
= screen
->get_tex_surface(screen
, strb
->texture
, face
, level
, destZ
,
1087 PIPE_BUFFER_USAGE_CPU_READ
);
1089 dest_surf
= screen
->get_tex_surface(screen
, pt
, face
, level
, destZ
,
1090 PIPE_BUFFER_USAGE_CPU_WRITE
);
1092 assert(width
<= MAX_WIDTH
);
1095 * To avoid a large temp memory allocation, do copy row by row.
1097 if (baseFormat
== GL_DEPTH_COMPONENT
) {
1098 const GLboolean scaleOrBias
= (ctx
->Pixel
.DepthScale
!= 1.0F
||
1099 ctx
->Pixel
.DepthBias
!= 0.0F
);
1101 for (row
= 0; row
< height
; row
++, srcY
++, destY
+= yStep
) {
1102 uint data
[MAX_WIDTH
];
1103 pipe_get_tile_z(src_surf
, srcX
, srcY
, width
, 1, data
);
1105 _mesa_scale_and_bias_depth_uint(ctx
, width
, data
);
1107 pipe_put_tile_z(dest_surf
, destX
, destY
, width
, 1, data
);
1112 for (row
= 0; row
< height
; row
++, srcY
++, destY
+= yStep
) {
1113 float data
[4 * MAX_WIDTH
];
1114 pipe_get_tile_rgba(src_surf
, srcX
, srcY
, width
, 1, data
);
1115 /* XXX we're ignoring convolution for now */
1116 if (ctx
->_ImageTransferState
) {
1117 _mesa_apply_rgba_transfer_ops(ctx
,
1118 ctx
->_ImageTransferState
& ~IMAGE_CONVOLUTION_BIT
,
1119 width
, (GLfloat (*)[4]) data
);
1121 pipe_put_tile_rgba(dest_surf
, destX
, destY
, width
, 1, data
);
1125 screen
->tex_surface_release(screen
, &dest_surf
);
1126 screen
->tex_surface_release(screen
, &src_surf
);
1133 * Do a CopyTex[Sub]Image using an optimized hardware (blit) path.
1134 * Note that the region to copy has already been clip tested.
1136 * Note: srcY=0=Bottom of renderbuffer
1138 * \return GL_TRUE if success, GL_FALSE if failure (use a fallback)
1141 do_copy_texsubimage(GLcontext
*ctx
,
1142 GLenum target
, GLint level
,
1143 GLint destX
, GLint destY
, GLint destZ
,
1144 GLint srcX
, GLint srcY
,
1145 GLsizei width
, GLsizei height
)
1147 struct gl_texture_unit
*texUnit
=
1148 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1149 struct gl_texture_object
*texObj
=
1150 _mesa_select_tex_object(ctx
, texUnit
, target
);
1151 struct gl_texture_image
*texImage
=
1152 _mesa_select_tex_image(ctx
, texObj
, target
, level
);
1153 struct st_texture_image
*stImage
= st_texture_image(texImage
);
1154 GLenum baseFormat
= texImage
->InternalFormat
;
1155 struct gl_framebuffer
*fb
= ctx
->ReadBuffer
;
1156 struct st_renderbuffer
*strb
;
1157 struct pipe_context
*pipe
= ctx
->st
->pipe
;
1158 struct pipe_screen
*screen
= pipe
->screen
;
1159 uint dest_format
, src_format
;
1160 GLboolean use_fallback
= GL_TRUE
;
1165 st_flush(ctx
->st
, PIPE_FLUSH_RENDER_CACHE
, NULL
);
1167 /* determine if copying depth or color data */
1168 if (baseFormat
== GL_DEPTH_COMPONENT
) {
1169 strb
= st_renderbuffer(fb
->_DepthBuffer
);
1171 else if (baseFormat
== GL_DEPTH_STENCIL_EXT
) {
1172 strb
= st_renderbuffer(fb
->_StencilBuffer
);
1175 /* baseFormat == GL_RGB, GL_RGBA, GL_ALPHA, etc */
1176 strb
= st_renderbuffer(fb
->_ColorReadBuffer
);
1180 assert(strb
->surface
);
1181 assert(stImage
->pt
);
1183 src_format
= strb
->surface
->format
;
1184 dest_format
= stImage
->pt
->format
;
1186 if (ctx
->_ImageTransferState
== 0x0) {
1187 /* do blit-style copy */
1188 struct pipe_surface
*dest_surface
;
1190 dest_surface
= screen
->get_tex_surface(screen
, stImage
->pt
,
1192 stImage
->level
, destZ
,
1193 PIPE_BUFFER_USAGE_GPU_WRITE
);
1195 assert(strb
->surface
->buffer
);
1196 assert(dest_surface
->buffer
);
1198 if (src_format
== dest_format
) {
1199 boolean do_flip
= (st_fb_orientation(ctx
->ReadBuffer
) == Y_0_TOP
);
1200 pipe
->surface_copy(pipe
,
1210 use_fallback
= GL_FALSE
;
1212 else if (screen
->is_format_supported(screen
, strb
->surface
->format
,
1214 screen
->is_format_supported(screen
, dest_surface
->format
,
1216 boolean do_flip
= (st_fb_orientation(ctx
->ReadBuffer
) == Y_0_TOP
);
1219 srcY1
= strb
->Base
.Height
- srcY
- height
;
1220 srcY0
= srcY1
+ height
;
1224 srcY1
= srcY0
+ height
;
1226 util_blit_pixels(ctx
->st
->blit
,
1229 srcX
+ width
, srcY1
,
1232 destX
+ width
, destY
+ height
,
1233 0.0, PIPE_TEX_MIPFILTER_NEAREST
);
1234 use_fallback
= GL_FALSE
;
1237 pipe_surface_reference(&dest_surface
, NULL
);
1241 fallback_copy_texsubimage(ctx
, target
, level
,
1242 strb
, stImage
, baseFormat
,
1243 destX
, destY
, destZ
,
1244 srcX
, srcY
, width
, height
);
1247 if (level
== texObj
->BaseLevel
&& texObj
->GenerateMipmap
) {
1248 ctx
->Driver
.GenerateMipmap(ctx
, target
, texObj
);
1255 st_CopyTexImage1D(GLcontext
* ctx
, GLenum target
, GLint level
,
1256 GLenum internalFormat
,
1257 GLint x
, GLint y
, GLsizei width
, GLint border
)
1259 struct gl_texture_unit
*texUnit
=
1260 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1261 struct gl_texture_object
*texObj
=
1262 _mesa_select_tex_object(ctx
, texUnit
, target
);
1263 struct gl_texture_image
*texImage
=
1264 _mesa_select_tex_image(ctx
, texObj
, target
, level
);
1271 /* Setup or redefine the texture object, texture and texture
1272 * image. Don't populate yet.
1274 ctx
->Driver
.TexImage1D(ctx
, target
, level
, internalFormat
,
1276 GL_RGBA
, CHAN_TYPE
, NULL
,
1277 &ctx
->DefaultPacking
, texObj
, texImage
);
1279 do_copy_texsubimage(ctx
, target
, level
,
1286 st_CopyTexImage2D(GLcontext
* ctx
, GLenum target
, GLint level
,
1287 GLenum internalFormat
,
1288 GLint x
, GLint y
, GLsizei width
, GLsizei height
,
1291 struct gl_texture_unit
*texUnit
=
1292 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1293 struct gl_texture_object
*texObj
=
1294 _mesa_select_tex_object(ctx
, texUnit
, target
);
1295 struct gl_texture_image
*texImage
=
1296 _mesa_select_tex_image(ctx
, texObj
, target
, level
);
1303 /* Setup or redefine the texture object, texture and texture
1304 * image. Don't populate yet.
1306 ctx
->Driver
.TexImage2D(ctx
, target
, level
, internalFormat
,
1307 width
, height
, border
,
1308 GL_RGBA
, CHAN_TYPE
, NULL
,
1309 &ctx
->DefaultPacking
, texObj
, texImage
);
1312 do_copy_texsubimage(ctx
, target
, level
,
1314 x
, y
, width
, height
);
1319 st_CopyTexSubImage1D(GLcontext
* ctx
, GLenum target
, GLint level
,
1320 GLint xoffset
, GLint x
, GLint y
, GLsizei width
)
1322 const GLint yoffset
= 0, zoffset
= 0;
1323 const GLsizei height
= 1;
1324 do_copy_texsubimage(ctx
, target
, level
,
1325 xoffset
, yoffset
, zoffset
,
1326 x
, y
, width
, height
);
1331 st_CopyTexSubImage2D(GLcontext
* ctx
, GLenum target
, GLint level
,
1332 GLint xoffset
, GLint yoffset
,
1333 GLint x
, GLint y
, GLsizei width
, GLsizei height
)
1335 const GLint zoffset
= 0;
1336 do_copy_texsubimage(ctx
, target
, level
,
1337 xoffset
, yoffset
, zoffset
,
1338 x
, y
, width
, height
);
1343 st_CopyTexSubImage3D(GLcontext
* ctx
, GLenum target
, GLint level
,
1344 GLint xoffset
, GLint yoffset
, GLint zoffset
,
1345 GLint x
, GLint y
, GLsizei width
, GLsizei height
)
1347 do_copy_texsubimage(ctx
, target
, level
,
1348 xoffset
, yoffset
, zoffset
,
1349 x
, y
, width
, height
);
1356 * Compute which mipmap levels that really need to be sent to the hardware.
1357 * This depends on the base image size, GL_TEXTURE_MIN_LOD,
1358 * GL_TEXTURE_MAX_LOD, GL_TEXTURE_BASE_LEVEL, and GL_TEXTURE_MAX_LEVEL.
1361 calculate_first_last_level(struct st_texture_object
*stObj
)
1363 struct gl_texture_object
*tObj
= &stObj
->base
;
1365 /* These must be signed values. MinLod and MaxLod can be negative numbers,
1366 * and having firstLevel and lastLevel as signed prevents the need for
1367 * extra sign checks.
1372 /* Yes, this looks overly complicated, but it's all needed.
1374 switch (tObj
->Target
) {
1378 case GL_TEXTURE_CUBE_MAP
:
1379 if (tObj
->MinFilter
== GL_NEAREST
|| tObj
->MinFilter
== GL_LINEAR
) {
1380 /* GL_NEAREST and GL_LINEAR only care about GL_TEXTURE_BASE_LEVEL.
1382 firstLevel
= lastLevel
= tObj
->BaseLevel
;
1386 lastLevel
= MIN2(tObj
->MaxLevel
, tObj
->Image
[0][tObj
->BaseLevel
]->WidthLog2
);
1389 case GL_TEXTURE_RECTANGLE_NV
:
1390 case GL_TEXTURE_4D_SGIS
:
1391 firstLevel
= lastLevel
= 0;
1397 stObj
->lastLevel
= lastLevel
;
1402 copy_image_data_to_texture(struct st_context
*st
,
1403 struct st_texture_object
*stObj
,
1405 struct st_texture_image
*stImage
)
1408 /* Copy potentially with the blitter:
1410 st_texture_image_copy(st
->pipe
,
1411 stObj
->pt
, dstLevel
, /* dest texture, level */
1412 stImage
->pt
, /* src texture */
1416 pipe_texture_reference(&stImage
->pt
, NULL
);
1418 else if (stImage
->base
.Data
) {
1419 assert(stImage
->base
.Data
!= NULL
);
1421 /* More straightforward upload.
1423 st_texture_image_data(st
->pipe
,
1428 stImage
->base
.RowStride
*
1429 stObj
->pt
->block
.size
,
1430 stImage
->base
.RowStride
*
1431 stImage
->base
.Height
*
1432 stObj
->pt
->block
.size
);
1433 _mesa_align_free(stImage
->base
.Data
);
1434 stImage
->base
.Data
= NULL
;
1437 pipe_texture_reference(&stImage
->pt
, stObj
->pt
);
1442 * Called during state validation. When this function is finished,
1443 * the texture object should be ready for rendering.
1444 * \return GL_TRUE for success, GL_FALSE for failure (out of mem)
1447 st_finalize_texture(GLcontext
*ctx
,
1448 struct pipe_context
*pipe
,
1449 struct gl_texture_object
*tObj
,
1450 GLboolean
*needFlush
)
1452 struct st_texture_object
*stObj
= st_texture_object(tObj
);
1453 const GLuint nr_faces
= (stObj
->base
.Target
== GL_TEXTURE_CUBE_MAP
) ? 6 : 1;
1457 struct st_texture_image
*firstImage
;
1459 *needFlush
= GL_FALSE
;
1461 /* We know/require this is true by now:
1463 assert(stObj
->base
._Complete
);
1465 /* What levels must the texture include at a minimum?
1467 calculate_first_last_level(stObj
);
1468 firstImage
= st_texture_image(stObj
->base
.Image
[0][stObj
->base
.BaseLevel
]);
1470 /* If both firstImage and stObj point to a texture which can contain
1471 * all active images, favour firstImage. Note that because of the
1472 * completeness requirement, we know that the image dimensions
1475 if (firstImage
->pt
&&
1476 firstImage
->pt
!= stObj
->pt
&&
1477 firstImage
->pt
->last_level
>= stObj
->lastLevel
) {
1479 pipe_texture_reference(&stObj
->pt
, firstImage
->pt
);
1482 /* FIXME: determine format block instead of cpp */
1483 if (firstImage
->base
.IsCompressed
) {
1484 comp_byte
= compressed_num_bytes(firstImage
->base
.TexFormat
->MesaFormat
);
1488 cpp
= firstImage
->base
.TexFormat
->TexelBytes
;
1491 /* If we already have a gallium texture, check that it matches the texture
1492 * object's format, target, size, num_levels, etc.
1495 const enum pipe_format fmt
=
1496 st_mesa_format_to_pipe_format(firstImage
->base
.TexFormat
->MesaFormat
);
1497 if (stObj
->pt
->target
!= gl_target_to_pipe(stObj
->base
.Target
) ||
1498 stObj
->pt
->format
!= fmt
||
1499 stObj
->pt
->last_level
< stObj
->lastLevel
||
1500 stObj
->pt
->width
[0] != firstImage
->base
.Width2
||
1501 stObj
->pt
->height
[0] != firstImage
->base
.Height2
||
1502 stObj
->pt
->depth
[0] != firstImage
->base
.Depth2
||
1503 stObj
->pt
->block
.size
!= cpp
||
1504 stObj
->pt
->block
.width
!= 1 ||
1505 stObj
->pt
->block
.height
!= 1 ||
1506 stObj
->pt
->compressed
!= firstImage
->base
.IsCompressed
) {
1507 pipe_texture_release(&stObj
->pt
);
1508 ctx
->st
->dirty
.st
|= ST_NEW_FRAMEBUFFER
;
1512 /* May need to create a new gallium texture:
1515 const enum pipe_format fmt
=
1516 st_mesa_format_to_pipe_format(firstImage
->base
.TexFormat
->MesaFormat
);
1517 stObj
->pt
= st_texture_create(ctx
->st
,
1518 gl_target_to_pipe(stObj
->base
.Target
),
1521 firstImage
->base
.Width2
,
1522 firstImage
->base
.Height2
,
1523 firstImage
->base
.Depth2
,
1525 ( (pf_is_depth_stencil(fmt
) ?
1526 PIPE_TEXTURE_USAGE_DEPTH_STENCIL
:
1527 PIPE_TEXTURE_USAGE_RENDER_TARGET
) |
1528 PIPE_TEXTURE_USAGE_SAMPLER
));
1531 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexImage");
1536 /* Pull in any images not in the object's texture:
1538 for (face
= 0; face
< nr_faces
; face
++) {
1540 for (level
= 0; level
<= stObj
->lastLevel
; level
++) {
1541 struct st_texture_image
*stImage
=
1542 st_texture_image(stObj
->base
.Image
[face
][stObj
->base
.BaseLevel
+ level
]);
1544 /* Need to import images in main memory or held in other textures.
1546 if (stImage
&& stObj
->pt
!= stImage
->pt
) {
1547 copy_image_data_to_texture(ctx
->st
, stObj
, level
, stImage
);
1548 *needFlush
= GL_TRUE
;
1560 st_init_texture_functions(struct dd_function_table
*functions
)
1562 functions
->ChooseTextureFormat
= st_ChooseTextureFormat
;
1563 functions
->TexImage1D
= st_TexImage1D
;
1564 functions
->TexImage2D
= st_TexImage2D
;
1565 functions
->TexImage3D
= st_TexImage3D
;
1566 functions
->TexSubImage1D
= st_TexSubImage1D
;
1567 functions
->TexSubImage2D
= st_TexSubImage2D
;
1568 functions
->TexSubImage3D
= st_TexSubImage3D
;
1569 functions
->CopyTexImage1D
= st_CopyTexImage1D
;
1570 functions
->CopyTexImage2D
= st_CopyTexImage2D
;
1571 functions
->CopyTexSubImage1D
= st_CopyTexSubImage1D
;
1572 functions
->CopyTexSubImage2D
= st_CopyTexSubImage2D
;
1573 functions
->CopyTexSubImage3D
= st_CopyTexSubImage3D
;
1574 functions
->GenerateMipmap
= st_generate_mipmap
;
1576 functions
->GetTexImage
= st_GetTexImage
;
1578 /* compressed texture functions */
1579 functions
->CompressedTexImage2D
= st_CompressedTexImage2D
;
1580 functions
->GetCompressedTexImage
= st_GetCompressedTexImage
;
1581 functions
->CompressedTextureSize
= _mesa_compressed_texture_size
;
1583 functions
->NewTextureObject
= st_NewTextureObject
;
1584 functions
->NewTextureImage
= st_NewTextureImage
;
1585 functions
->DeleteTexture
= st_DeleteTextureObject
;
1586 functions
->FreeTexImageData
= st_FreeTextureImageData
;
1587 functions
->UpdateTexturePalette
= 0;
1588 functions
->IsTextureResident
= st_IsTextureResident
;
1590 functions
->TextureMemCpy
= do_memcpy
;
1592 /* XXX Temporary until we can query pipe's texture sizes */
1593 functions
->TestProxyTexImage
= _mesa_test_proxy_teximage
;