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"
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/u_tile.h"
55 #include "util/u_blit.h"
58 #define DBG if (0) printf
61 static enum pipe_texture_target
62 gl_target_to_pipe(GLenum target
)
66 return PIPE_TEXTURE_1D
;
69 case GL_TEXTURE_RECTANGLE_NV
:
70 return PIPE_TEXTURE_2D
;
73 return PIPE_TEXTURE_3D
;
75 case GL_TEXTURE_CUBE_MAP_ARB
:
76 return PIPE_TEXTURE_CUBE
;
86 * Return nominal bytes per texel for a compressed format, 0 for non-compressed
90 compressed_num_bytes(GLuint mesaFormat
)
93 #if FEATURE_texture_fxt1
94 case MESA_FORMAT_RGB_FXT1
:
95 case MESA_FORMAT_RGBA_FXT1
:
97 #if FEATURE_texture_s3tc
98 case MESA_FORMAT_RGB_DXT1
:
99 case MESA_FORMAT_RGBA_DXT1
:
101 case MESA_FORMAT_RGBA_DXT3
:
102 case MESA_FORMAT_RGBA_DXT5
:
111 /** called via ctx->Driver.NewTextureImage() */
112 static struct gl_texture_image
*
113 st_NewTextureImage(GLcontext
* ctx
)
115 DBG("%s\n", __FUNCTION__
);
117 return (struct gl_texture_image
*) CALLOC_STRUCT(st_texture_image
);
121 /** called via ctx->Driver.NewTextureObject() */
122 static struct gl_texture_object
*
123 st_NewTextureObject(GLcontext
* ctx
, GLuint name
, GLenum target
)
125 struct st_texture_object
*obj
= CALLOC_STRUCT(st_texture_object
);
127 DBG("%s\n", __FUNCTION__
);
128 _mesa_initialize_texture_object(&obj
->base
, name
, target
);
133 /** called via ctx->Driver.DeleteTextureImage() */
135 st_DeleteTextureObject(GLcontext
*ctx
,
136 struct gl_texture_object
*texObj
)
138 struct st_texture_object
*stObj
= st_texture_object(texObj
);
140 pipe_texture_reference(&stObj
->pt
, NULL
);
142 _mesa_delete_texture_object(ctx
, texObj
);
146 /** called via ctx->Driver.FreeTexImageData() */
148 st_FreeTextureImageData(GLcontext
* ctx
, struct gl_texture_image
*texImage
)
150 struct st_texture_image
*stImage
= st_texture_image(texImage
);
152 DBG("%s\n", __FUNCTION__
);
155 pipe_texture_reference(&stImage
->pt
, NULL
);
158 if (texImage
->Data
) {
159 _mesa_align_free(texImage
->Data
);
160 texImage
->Data
= NULL
;
166 * From linux kernel i386 header files, copes with odd sizes better
167 * than COPY_DWORDS would:
168 * XXX Put this in src/mesa/main/imports.h ???
170 #if defined(i386) || defined(__i386__)
172 __memcpy(void *to
, const void *from
, size_t n
)
175 __asm__
__volatile__("rep ; movsl\n\t"
179 "1:\ttestb $1,%b4\n\t"
181 "movsb\n" "2:":"=&c"(d0
), "=&D"(d1
), "=&S"(d2
)
182 :"0"(n
/ 4), "q"(n
), "1"((long) to
), "2"((long) from
)
187 #define __memcpy(a,b,c) memcpy(a,b,c)
192 * The system memcpy (at least on ubuntu 5.10) has problems copying
193 * to agp (writecombined) memory from a source which isn't 64-byte
194 * aligned - there is a 4x performance falloff.
196 * The x86 __memcpy is immune to this but is slightly slower
197 * (10%-ish) than the system memcpy.
199 * The sse_memcpy seems to have a slight cliff at 64/32 bytes, but
200 * isn't much faster than x86_memcpy for agp copies.
202 * TODO: switch dynamically.
205 do_memcpy(void *dest
, const void *src
, size_t n
)
207 if ((((unsigned) src
) & 63) || (((unsigned) dest
) & 63)) {
208 return __memcpy(dest
, src
, n
);
211 return memcpy(dest
, src
, n
);
218 GLint i
= 1, log2
= 0;
228 * Allocate a pipe_texture object for the given st_texture_object using
229 * the given st_texture_image to guess the mipmap size/levels.
232 * Otherwise, store it in memory if (Border != 0) or (any dimension ==
235 * Otherwise, if max_level >= level >= min_level, create texture with
236 * space for images from min_level down to max_level.
238 * Otherwise, create texture with space for images from (level 0)..(1x1).
239 * Consider pruning this texture at a validation if the saving is worth it.
242 guess_and_alloc_texture(struct st_context
*st
,
243 struct st_texture_object
*stObj
,
244 const struct st_texture_image
*stImage
)
248 GLuint width
= stImage
->base
.Width2
; /* size w/out border */
249 GLuint height
= stImage
->base
.Height2
;
250 GLuint depth
= stImage
->base
.Depth2
;
251 GLuint i
, comp_byte
= 0;
252 enum pipe_format fmt
;
254 DBG("%s\n", __FUNCTION__
);
259 (GLint
) stImage
->level
> stObj
->base
.BaseLevel
&&
260 (stImage
->base
.Width
== 1 ||
261 (stObj
->base
.Target
!= GL_TEXTURE_1D
&&
262 stImage
->base
.Height
== 1) ||
263 (stObj
->base
.Target
== GL_TEXTURE_3D
&&
264 stImage
->base
.Depth
== 1)))
267 /* If this image disrespects BaseLevel, allocate from level zero.
268 * Usually BaseLevel == 0, so it's unlikely to happen.
270 if ((GLint
) stImage
->level
< stObj
->base
.BaseLevel
)
273 firstLevel
= stObj
->base
.BaseLevel
;
276 /* Figure out image dimensions at start level.
278 for (i
= stImage
->level
; i
> firstLevel
; i
--) {
287 if (width
== 0 || height
== 0 || depth
== 0) {
288 /* no texture needed */
292 /* Guess a reasonable value for lastLevel. This is probably going
293 * to be wrong fairly often and might mean that we have to look at
294 * resizable buffers, or require that buffers implement lazy
295 * pagetable arrangements.
297 if ((stObj
->base
.MinFilter
== GL_NEAREST
||
298 stObj
->base
.MinFilter
== GL_LINEAR
) &&
299 stImage
->level
== firstLevel
) {
300 lastLevel
= firstLevel
;
303 GLuint l2width
= logbase2(width
);
304 GLuint l2height
= logbase2(height
);
305 GLuint l2depth
= logbase2(depth
);
306 lastLevel
= firstLevel
+ MAX2(MAX2(l2width
, l2height
), l2depth
);
309 if (stImage
->base
.IsCompressed
)
310 comp_byte
= compressed_num_bytes(stImage
->base
.TexFormat
->MesaFormat
);
312 fmt
= st_mesa_format_to_pipe_format(stImage
->base
.TexFormat
->MesaFormat
);
313 stObj
->pt
= st_texture_create(st
,
314 gl_target_to_pipe(stObj
->base
.Target
),
321 ( (pf_is_depth_stencil(fmt
) ?
322 PIPE_TEXTURE_USAGE_DEPTH_STENCIL
:
323 PIPE_TEXTURE_USAGE_RENDER_TARGET
) |
324 PIPE_TEXTURE_USAGE_SAMPLER
));
326 DBG("%s - success\n", __FUNCTION__
);
331 * Adjust pixel unpack params and image dimensions to strip off the
333 * Gallium doesn't support texture borders. They've seldem been used
334 * and seldom been implemented correctly anyway.
335 * \param unpackNew returns the new pixel unpack parameters
338 strip_texture_border(GLint border
,
339 GLint
*width
, GLint
*height
, GLint
*depth
,
340 const struct gl_pixelstore_attrib
*unpack
,
341 struct gl_pixelstore_attrib
*unpackNew
)
343 assert(border
> 0); /* sanity check */
345 *unpackNew
= *unpack
;
347 if (unpackNew
->RowLength
== 0)
348 unpackNew
->RowLength
= *width
;
350 if (depth
&& unpackNew
->ImageHeight
== 0)
351 unpackNew
->ImageHeight
= *height
;
353 unpackNew
->SkipPixels
+= border
;
355 unpackNew
->SkipRows
+= border
;
357 unpackNew
->SkipImages
+= border
;
360 *width
= *width
- 2 * border
;
361 if (height
&& *height
>= 3)
362 *height
= *height
- 2 * border
;
363 if (depth
&& *depth
>= 3)
364 *depth
= *depth
- 2 * border
;
369 * Do glTexImage1/2/3D().
372 st_TexImage(GLcontext
* ctx
,
374 GLenum target
, GLint level
,
375 GLint internalFormat
,
376 GLint width
, GLint height
, GLint depth
,
378 GLenum format
, GLenum type
, const void *pixels
,
379 const struct gl_pixelstore_attrib
*unpack
,
380 struct gl_texture_object
*texObj
,
381 struct gl_texture_image
*texImage
,
382 GLsizei imageSize
, int compressed
)
384 struct st_texture_object
*stObj
= st_texture_object(texObj
);
385 struct st_texture_image
*stImage
= st_texture_image(texImage
);
386 GLint postConvWidth
, postConvHeight
;
387 GLint texelBytes
, sizeInBytes
;
389 struct gl_pixelstore_attrib unpackNB
;
391 DBG("%s target %s level %d %dx%dx%d border %d\n", __FUNCTION__
,
392 _mesa_lookup_enum_by_nr(target
), level
, width
, height
, depth
, border
);
394 /* gallium does not support texture borders, strip it off */
396 strip_texture_border(border
, &width
, &height
, &depth
,
399 texImage
->Width
= width
;
400 texImage
->Height
= height
;
401 texImage
->Depth
= depth
;
402 texImage
->Border
= 0;
406 postConvWidth
= width
;
407 postConvHeight
= height
;
409 stImage
->face
= _mesa_tex_target_to_face(target
);
410 stImage
->level
= level
;
413 if (ctx
->_ImageTransferState
& IMAGE_CONVOLUTION_BIT
) {
414 _mesa_adjust_image_for_convolution(ctx
, dims
, &postConvWidth
,
419 /* choose the texture format */
420 texImage
->TexFormat
= st_ChooseTextureFormat(ctx
, internalFormat
,
423 _mesa_set_fetch_functions(texImage
, dims
);
425 if (texImage
->TexFormat
->TexelBytes
== 0) {
426 /* must be a compressed format */
428 texImage
->IsCompressed
= GL_TRUE
;
429 texImage
->CompressedSize
=
430 ctx
->Driver
.CompressedTextureSize(ctx
, texImage
->Width
,
431 texImage
->Height
, texImage
->Depth
,
432 texImage
->TexFormat
->MesaFormat
);
435 texelBytes
= texImage
->TexFormat
->TexelBytes
;
437 /* Minimum pitch of 32 bytes */
438 if (postConvWidth
* texelBytes
< 32) {
439 postConvWidth
= 32 / texelBytes
;
440 texImage
->RowStride
= postConvWidth
;
443 /* we'll set RowStride elsewhere when the texture is a "mapped" state */
444 /*assert(texImage->RowStride == postConvWidth);*/
447 /* Release the reference to a potentially orphaned buffer.
448 * Release any old malloced memory.
451 pipe_texture_reference(&stImage
->pt
, NULL
);
452 assert(!texImage
->Data
);
454 else if (texImage
->Data
) {
455 _mesa_align_free(texImage
->Data
);
458 if (width
== 0 || height
== 0 || depth
== 0) {
459 /* stop after freeing old image */
463 /* If this is the only mipmap level in the texture, could call
464 * bmBufferData with NULL data to free the old block and avoid
465 * waiting on any outstanding fences.
468 (stObj
->teximage_realloc
||
469 (/*stObj->pt->first_level == level &&*/
470 stObj
->pt
->last_level
== level
&&
471 stObj
->pt
->target
!= PIPE_TEXTURE_CUBE
&&
472 !st_texture_match_image(stObj
->pt
, &stImage
->base
,
473 stImage
->face
, stImage
->level
)))) {
476 pipe_texture_reference(&stObj
->pt
, NULL
);
478 stObj
->teximage_realloc
= FALSE
;
482 guess_and_alloc_texture(ctx
->st
, stObj
, stImage
);
484 /* Probably out of memory.
485 * Try flushing any pending rendering, then retry.
488 guess_and_alloc_texture(ctx
->st
, stObj
, stImage
);
490 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexImage");
496 assert(!stImage
->pt
);
499 st_texture_match_image(stObj
->pt
, &stImage
->base
,
500 stImage
->face
, stImage
->level
)) {
502 pipe_texture_reference(&stImage
->pt
, stObj
->pt
);
507 DBG("XXX: Image did not fit into texture - storing in local memory!\n");
509 /* st_CopyTexImage calls this function with pixels == NULL, with
510 * the expectation that the texture will be set up but nothing
511 * more will be done. This is where those calls return:
514 pixels
= _mesa_validate_pbo_compressed_teximage(ctx
, imageSize
, pixels
,
516 "glCompressedTexImage");
518 pixels
= _mesa_validate_pbo_teximage(ctx
, dims
, width
, height
, 1,
520 pixels
, unpack
, "glTexImage");
526 texImage
->Data
= st_texture_image_map(ctx
->st
, stImage
, 0,
527 PIPE_BUFFER_USAGE_CPU_WRITE
);
528 if (stImage
->surface
)
529 dstRowStride
= stImage
->surface
->stride
;
532 /* Allocate regular memory and store the image there temporarily. */
533 if (texImage
->IsCompressed
) {
534 sizeInBytes
= texImage
->CompressedSize
;
536 _mesa_compressed_row_stride(texImage
->TexFormat
->MesaFormat
, width
);
540 dstRowStride
= postConvWidth
* texelBytes
;
541 sizeInBytes
= depth
* dstRowStride
* postConvHeight
;
544 texImage
->Data
= _mesa_align_malloc(sizeInBytes
, 16);
547 if (!texImage
->Data
) {
548 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexImage");
552 DBG("Upload image %dx%dx%d row_len %x pitch %x\n",
553 width
, height
, depth
, width
* texelBytes
, dstRowStride
);
555 /* Copy data. Would like to know when it's ok for us to eg. use
556 * the blitter to copy. Or, use the hardware to do the format
557 * conversion and copy:
560 memcpy(texImage
->Data
, pixels
, imageSize
);
563 GLuint srcImageStride
= _mesa_image_image_stride(unpack
, width
, height
,
566 const GLubyte
*src
= (const GLubyte
*) pixels
;
568 for (i
= 0; i
++ < depth
;) {
569 if (!texImage
->TexFormat
->StoreImage(ctx
, dims
,
570 texImage
->_BaseFormat
,
573 0, 0, 0, /* dstX/Y/Zoffset */
575 texImage
->ImageOffsets
,
577 format
, type
, src
, unpack
)) {
578 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexImage");
581 if (stImage
->pt
&& i
< depth
) {
582 st_texture_image_unmap(ctx
->st
, stImage
);
583 texImage
->Data
= st_texture_image_map(ctx
->st
, stImage
, i
,
584 PIPE_BUFFER_USAGE_CPU_WRITE
);
585 src
+= srcImageStride
;
590 _mesa_unmap_teximage_pbo(ctx
, unpack
);
593 st_texture_image_unmap(ctx
->st
, stImage
);
594 texImage
->Data
= NULL
;
597 if (level
== texObj
->BaseLevel
&& texObj
->GenerateMipmap
) {
598 ctx
->Driver
.GenerateMipmap(ctx
, target
, texObj
);
604 st_TexImage3D(GLcontext
* ctx
,
605 GLenum target
, GLint level
,
606 GLint internalFormat
,
607 GLint width
, GLint height
, GLint depth
,
609 GLenum format
, GLenum type
, const void *pixels
,
610 const struct gl_pixelstore_attrib
*unpack
,
611 struct gl_texture_object
*texObj
,
612 struct gl_texture_image
*texImage
)
614 st_TexImage(ctx
, 3, target
, level
,
615 internalFormat
, width
, height
, depth
, border
,
616 format
, type
, pixels
, unpack
, texObj
, texImage
, 0, 0);
621 st_TexImage2D(GLcontext
* ctx
,
622 GLenum target
, GLint level
,
623 GLint internalFormat
,
624 GLint width
, GLint height
, GLint border
,
625 GLenum format
, GLenum type
, const void *pixels
,
626 const struct gl_pixelstore_attrib
*unpack
,
627 struct gl_texture_object
*texObj
,
628 struct gl_texture_image
*texImage
)
630 st_TexImage(ctx
, 2, target
, level
,
631 internalFormat
, width
, height
, 1, border
,
632 format
, type
, pixels
, unpack
, texObj
, texImage
, 0, 0);
637 st_TexImage1D(GLcontext
* ctx
,
638 GLenum target
, GLint level
,
639 GLint internalFormat
,
640 GLint width
, GLint border
,
641 GLenum format
, GLenum type
, const void *pixels
,
642 const struct gl_pixelstore_attrib
*unpack
,
643 struct gl_texture_object
*texObj
,
644 struct gl_texture_image
*texImage
)
646 st_TexImage(ctx
, 1, target
, level
,
647 internalFormat
, width
, 1, 1, border
,
648 format
, type
, pixels
, unpack
, texObj
, texImage
, 0, 0);
653 st_CompressedTexImage2D(GLcontext
*ctx
, GLenum target
, GLint level
,
654 GLint internalFormat
,
655 GLint width
, GLint height
, GLint border
,
656 GLsizei imageSize
, const GLvoid
*data
,
657 struct gl_texture_object
*texObj
,
658 struct gl_texture_image
*texImage
)
660 st_TexImage(ctx
, 2, target
, level
,
661 internalFormat
, width
, height
, 1, border
,
662 0, 0, data
, &ctx
->Unpack
, texObj
, texImage
, imageSize
, 1);
667 * Need to map texture image into memory before copying image data,
671 st_get_tex_image(GLcontext
* ctx
, GLenum target
, GLint level
,
672 GLenum format
, GLenum type
, GLvoid
* pixels
,
673 struct gl_texture_object
*texObj
,
674 struct gl_texture_image
*texImage
, int compressed
)
676 struct st_texture_image
*stImage
= st_texture_image(texImage
);
677 GLuint dstImageStride
= _mesa_image_image_stride(&ctx
->Pack
,
687 /* Image is stored in hardware format in a buffer managed by the
688 * kernel. Need to explicitly map and unmap it.
690 texImage
->Data
= st_texture_image_map(ctx
->st
, stImage
, 0,
691 PIPE_BUFFER_USAGE_CPU_READ
);
692 texImage
->RowStride
= stImage
->surface
->stride
/ stImage
->pt
->block
.size
;
695 /* Otherwise, the image should actually be stored in
696 * texImage->Data. This is pretty confusing for
697 * everybody, I'd much prefer to separate the two functions of
698 * texImage->Data - storage for texture images in main memory
699 * and access (ie mappings) of images. In other words, we'd
700 * create a new texImage->Map field and leave Data simply for
703 assert(texImage
->Data
);
706 depth
= texImage
->Depth
;
709 dest
= (GLubyte
*) pixels
;
711 for (i
= 0; i
++ < depth
;) {
713 _mesa_get_compressed_teximage(ctx
, target
, level
, dest
,
716 _mesa_get_teximage(ctx
, target
, level
, format
, type
, dest
,
720 if (stImage
->pt
&& i
< depth
) {
721 st_texture_image_unmap(ctx
->st
, stImage
);
722 texImage
->Data
= st_texture_image_map(ctx
->st
, stImage
, i
,
723 PIPE_BUFFER_USAGE_CPU_READ
);
724 dest
+= dstImageStride
;
728 texImage
->Depth
= depth
;
732 st_texture_image_unmap(ctx
->st
, stImage
);
733 texImage
->Data
= NULL
;
739 st_GetTexImage(GLcontext
* ctx
, GLenum target
, GLint level
,
740 GLenum format
, GLenum type
, GLvoid
* pixels
,
741 struct gl_texture_object
*texObj
,
742 struct gl_texture_image
*texImage
)
744 st_get_tex_image(ctx
, target
, level
, format
, type
, pixels
,
745 texObj
, texImage
, 0);
750 st_GetCompressedTexImage(GLcontext
*ctx
, GLenum target
, GLint level
,
752 struct gl_texture_object
*texObj
,
753 struct gl_texture_image
*texImage
)
755 st_get_tex_image(ctx
, target
, level
, 0, 0, pixels
,
756 (struct gl_texture_object
*) texObj
,
757 (struct gl_texture_image
*) texImage
, 1);
763 st_TexSubimage(GLcontext
* ctx
,
765 GLenum target
, GLint level
,
766 GLint xoffset
, GLint yoffset
, GLint zoffset
,
767 GLint width
, GLint height
, GLint depth
,
768 GLenum format
, GLenum type
, const void *pixels
,
769 const struct gl_pixelstore_attrib
*packing
,
770 struct gl_texture_object
*texObj
,
771 struct gl_texture_image
*texImage
)
773 struct st_texture_image
*stImage
= st_texture_image(texImage
);
775 GLuint srcImageStride
= _mesa_image_image_stride(packing
, width
, height
,
780 DBG("%s target %s level %d offset %d,%d %dx%d\n", __FUNCTION__
,
781 _mesa_lookup_enum_by_nr(target
),
782 level
, xoffset
, yoffset
, width
, height
);
785 _mesa_validate_pbo_teximage(ctx
, dims
, width
, height
, depth
, format
,
786 type
, pixels
, packing
, "glTexSubImage2D");
790 /* Map buffer if necessary. Need to lock to prevent other contexts
791 * from uploading the buffer under us.
794 texImage
->Data
= st_texture_image_map(ctx
->st
, stImage
, zoffset
,
795 PIPE_BUFFER_USAGE_CPU_WRITE
);
796 if (stImage
->surface
)
797 dstRowStride
= stImage
->surface
->stride
;
800 if (!texImage
->Data
) {
801 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexSubImage");
805 src
= (const GLubyte
*) pixels
;
807 for (i
= 0; i
++ < depth
;) {
808 if (!texImage
->TexFormat
->StoreImage(ctx
, dims
, texImage
->_BaseFormat
,
813 texImage
->ImageOffsets
,
815 format
, type
, src
, packing
)) {
816 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexSubImage");
819 if (stImage
->pt
&& i
< depth
) {
820 /* map next slice of 3D texture */
821 st_texture_image_unmap(ctx
->st
, stImage
);
822 texImage
->Data
= st_texture_image_map(ctx
->st
, stImage
, zoffset
+ i
,
823 PIPE_BUFFER_USAGE_CPU_WRITE
);
824 src
+= srcImageStride
;
828 if (level
== texObj
->BaseLevel
&& texObj
->GenerateMipmap
) {
829 ctx
->Driver
.GenerateMipmap(ctx
, target
, texObj
);
832 _mesa_unmap_teximage_pbo(ctx
, packing
);
835 st_texture_image_unmap(ctx
->st
, stImage
);
836 texImage
->Data
= NULL
;
843 st_TexSubImage3D(GLcontext
* ctx
,
846 GLint xoffset
, GLint yoffset
, GLint zoffset
,
847 GLsizei width
, GLsizei height
, GLsizei depth
,
848 GLenum format
, GLenum type
,
849 const GLvoid
* pixels
,
850 const struct gl_pixelstore_attrib
*packing
,
851 struct gl_texture_object
*texObj
,
852 struct gl_texture_image
*texImage
)
854 st_TexSubimage(ctx
, 3, target
, level
,
855 xoffset
, yoffset
, zoffset
,
856 width
, height
, depth
,
857 format
, type
, pixels
, packing
, texObj
, texImage
);
862 st_TexSubImage2D(GLcontext
* ctx
,
865 GLint xoffset
, GLint yoffset
,
866 GLsizei width
, GLsizei height
,
867 GLenum format
, GLenum type
,
868 const GLvoid
* pixels
,
869 const struct gl_pixelstore_attrib
*packing
,
870 struct gl_texture_object
*texObj
,
871 struct gl_texture_image
*texImage
)
873 st_TexSubimage(ctx
, 2, target
, level
,
876 format
, type
, pixels
, packing
, texObj
, texImage
);
881 st_TexSubImage1D(GLcontext
* ctx
,
886 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
,
895 format
, type
, pixels
, packing
, texObj
, texImage
);
901 * Return 0 for GL_TEXTURE_CUBE_MAP_POSITIVE_X,
902 * 1 for GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
904 * XXX duplicated from main/teximage.c
907 texture_face(GLenum target
)
909 if (target
>= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB
&&
910 target
<= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB
)
911 return (GLuint
) target
- (GLuint
) GL_TEXTURE_CUBE_MAP_POSITIVE_X
;
919 * Do a CopyTexSubImage operation by mapping the source surface and
920 * dest surface and using get_tile()/put_tile() to access the pixels/texels.
922 * Note: srcY=0=TOP of renderbuffer
925 fallback_copy_texsubimage(GLcontext
*ctx
,
928 struct st_renderbuffer
*strb
,
929 struct st_texture_image
*stImage
,
931 GLint destX
, GLint destY
, GLint destZ
,
932 GLint srcX
, GLint srcY
,
933 GLsizei width
, GLsizei height
)
935 struct pipe_context
*pipe
= ctx
->st
->pipe
;
936 struct pipe_screen
*screen
= pipe
->screen
;
937 const uint face
= texture_face(target
);
938 struct pipe_texture
*pt
= stImage
->pt
;
939 struct pipe_surface
*src_surf
, *dest_surf
;
941 /* We'd use strb->surface, here but it's created for GPU read/write only */
942 src_surf
= pipe
->screen
->get_tex_surface( pipe
->screen
,
945 PIPE_BUFFER_USAGE_CPU_READ
);
947 dest_surf
= screen
->get_tex_surface(screen
, pt
, face
, level
, destZ
,
948 PIPE_BUFFER_USAGE_CPU_WRITE
);
950 assert(width
<= MAX_WIDTH
);
952 if (baseFormat
== GL_DEPTH_COMPONENT
) {
953 const GLboolean scaleOrBias
= (ctx
->Pixel
.DepthScale
!= 1.0F
||
954 ctx
->Pixel
.DepthBias
!= 0.0F
);
957 /* determine bottom-to-top vs. top-to-bottom order for src buffer */
958 if (st_fb_orientation(ctx
->ReadBuffer
) == Y_0_TOP
) {
959 srcY
= strb
->Base
.Height
- 1 - srcY
;
966 /* To avoid a large temp memory allocation, do copy row by row */
967 for (row
= 0; row
< height
; row
++, srcY
+= yStep
, destY
++) {
968 uint data
[MAX_WIDTH
];
969 pipe_get_tile_z(src_surf
, srcX
, srcY
, width
, 1, data
);
971 _mesa_scale_and_bias_depth_uint(ctx
, width
, data
);
973 pipe_put_tile_z(dest_surf
, destX
, destY
, width
, 1, data
);
979 (GLfloat
*) _mesa_malloc(width
* height
* 4 * sizeof(GLfloat
));
981 st_texture_image_map(ctx
->st
, stImage
, 0,PIPE_BUFFER_USAGE_CPU_WRITE
);
983 if (tempSrc
&& texDest
) {
984 const GLint dims
= 2;
985 struct gl_texture_image
*texImage
= &stImage
->base
;
986 GLint dstRowStride
= stImage
->surface
->stride
;
987 struct gl_pixelstore_attrib unpack
= ctx
->DefaultPacking
;
989 if (st_fb_orientation(ctx
->ReadBuffer
) == Y_0_TOP
) {
990 /* need to invert src */
991 srcY
= strb
->Base
.Height
- srcY
- height
;
992 unpack
.Invert
= GL_TRUE
;
995 /* get float/RGBA image from framebuffer */
996 /* XXX this usually involves a lot of int/float conversion.
997 * try to avoid that someday.
999 pipe_get_tile_rgba(src_surf
, srcX
, srcY
, width
, height
, tempSrc
);
1001 /* Store into texture memory.
1002 * Note that this does some special things such as pixel transfer
1003 * ops and format conversion. In particular, if the dest tex format
1004 * is actually RGBA but the user created the texture as GL_RGB we
1005 * need to fill-in/override the alpha channel with 1.0.
1007 texImage
->TexFormat
->StoreImage(ctx
, dims
,
1008 texImage
->_BaseFormat
,
1009 texImage
->TexFormat
,
1011 destX
, destY
, destZ
,
1013 texImage
->ImageOffsets
,
1015 GL_RGBA
, GL_FLOAT
, tempSrc
, /* src */
1019 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexSubImage");
1023 _mesa_free(tempSrc
);
1025 st_texture_image_unmap(ctx
->st
, stImage
);
1028 screen
->tex_surface_release(screen
, &dest_surf
);
1029 screen
->tex_surface_release(screen
, &src_surf
);
1034 * Do a CopyTex[Sub]Image1/2/3D() using a hardware (blit) path if possible.
1035 * Note that the region to copy has already been clipped so we know we
1036 * won't read from outside the source renderbuffer's bounds.
1038 * Note: srcY=0=Bottom of renderbuffer (GL convention)
1041 st_copy_texsubimage(GLcontext
*ctx
,
1042 GLenum target
, GLint level
,
1043 GLint destX
, GLint destY
, GLint destZ
,
1044 GLint srcX
, GLint srcY
,
1045 GLsizei width
, GLsizei height
)
1047 struct gl_texture_unit
*texUnit
=
1048 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1049 struct gl_texture_object
*texObj
=
1050 _mesa_select_tex_object(ctx
, texUnit
, target
);
1051 struct gl_texture_image
*texImage
=
1052 _mesa_select_tex_image(ctx
, texObj
, target
, level
);
1053 struct st_texture_image
*stImage
= st_texture_image(texImage
);
1054 const GLenum texBaseFormat
= texImage
->InternalFormat
;
1055 struct gl_framebuffer
*fb
= ctx
->ReadBuffer
;
1056 struct st_renderbuffer
*strb
;
1057 struct pipe_context
*pipe
= ctx
->st
->pipe
;
1058 struct pipe_screen
*screen
= pipe
->screen
;
1059 enum pipe_format dest_format
, src_format
;
1060 GLboolean use_fallback
= GL_TRUE
;
1061 GLboolean matching_base_formats
;
1063 /* any rendering in progress must complete before we grab the fb image */
1066 /* determine if copying depth or color data */
1067 if (texBaseFormat
== GL_DEPTH_COMPONENT
) {
1068 strb
= st_renderbuffer(fb
->_DepthBuffer
);
1070 else if (texBaseFormat
== GL_DEPTH_STENCIL_EXT
) {
1071 strb
= st_renderbuffer(fb
->_StencilBuffer
);
1074 /* texBaseFormat == GL_RGB, GL_RGBA, GL_ALPHA, etc */
1075 strb
= st_renderbuffer(fb
->_ColorReadBuffer
);
1079 assert(strb
->surface
);
1080 assert(stImage
->pt
);
1082 src_format
= strb
->surface
->format
;
1083 dest_format
= stImage
->pt
->format
;
1086 * Determine if the src framebuffer and dest texture have the same
1087 * base format. We need this to detect a case such as the framebuffer
1088 * being GL_RGBA but the texture being GL_RGB. If the actual hardware
1089 * texture format stores RGBA we need to set A=1 (overriding the
1090 * framebuffer's alpha values). We can't do that with the blit or
1091 * textured-quad paths.
1093 matching_base_formats
= (strb
->Base
._BaseFormat
== texImage
->_BaseFormat
);
1095 if (matching_base_formats
&& ctx
->_ImageTransferState
== 0x0) {
1096 /* try potential hardware path */
1097 struct pipe_surface
*dest_surface
= NULL
;
1099 if (src_format
== dest_format
) {
1100 /* use surface_copy() / blit */
1101 boolean do_flip
= (st_fb_orientation(ctx
->ReadBuffer
) == Y_0_TOP
);
1103 dest_surface
= screen
->get_tex_surface(screen
, stImage
->pt
,
1104 stImage
->face
, stImage
->level
,
1106 PIPE_BUFFER_USAGE_GPU_WRITE
);
1108 srcY
= strb
->surface
->height
- srcY
- height
;
1110 /* for surface_copy(), y=0=top, always */
1111 pipe
->surface_copy(pipe
,
1121 use_fallback
= GL_FALSE
;
1123 else if (screen
->is_format_supported(screen
, src_format
,
1125 PIPE_TEXTURE_USAGE_SAMPLER
,
1127 screen
->is_format_supported(screen
, dest_format
,
1129 PIPE_TEXTURE_USAGE_RENDER_TARGET
,
1131 /* draw textured quad to do the copy */
1132 boolean do_flip
= (st_fb_orientation(ctx
->ReadBuffer
) == Y_0_TOP
);
1135 dest_surface
= screen
->get_tex_surface(screen
, stImage
->pt
,
1136 stImage
->face
, stImage
->level
,
1138 PIPE_BUFFER_USAGE_GPU_WRITE
);
1141 srcY1
= strb
->Base
.Height
- srcY
- height
;
1142 srcY0
= srcY1
+ height
;
1146 srcY1
= srcY0
+ height
;
1148 util_blit_pixels(ctx
->st
->blit
,
1151 srcX
+ width
, srcY1
,
1154 destX
+ width
, destY
+ height
,
1155 0.0, PIPE_TEX_MIPFILTER_NEAREST
);
1156 use_fallback
= GL_FALSE
;
1160 pipe_surface_reference(&dest_surface
, NULL
);
1164 /* software fallback */
1165 fallback_copy_texsubimage(ctx
, target
, level
,
1166 strb
, stImage
, texBaseFormat
,
1167 destX
, destY
, destZ
,
1168 srcX
, srcY
, width
, height
);
1171 if (level
== texObj
->BaseLevel
&& texObj
->GenerateMipmap
) {
1172 ctx
->Driver
.GenerateMipmap(ctx
, target
, texObj
);
1179 st_CopyTexImage1D(GLcontext
* ctx
, GLenum target
, GLint level
,
1180 GLenum internalFormat
,
1181 GLint x
, GLint y
, GLsizei width
, GLint border
)
1183 struct gl_texture_unit
*texUnit
=
1184 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1185 struct gl_texture_object
*texObj
=
1186 _mesa_select_tex_object(ctx
, texUnit
, target
);
1187 struct gl_texture_image
*texImage
=
1188 _mesa_select_tex_image(ctx
, texObj
, target
, level
);
1195 /* Setup or redefine the texture object, texture and texture
1196 * image. Don't populate yet.
1198 ctx
->Driver
.TexImage1D(ctx
, target
, level
, internalFormat
,
1200 GL_RGBA
, CHAN_TYPE
, NULL
,
1201 &ctx
->DefaultPacking
, texObj
, texImage
);
1203 st_copy_texsubimage(ctx
, target
, level
,
1204 0, 0, 0, /* destX,Y,Z */
1205 x
, y
, width
, 1); /* src X, Y, size */
1210 st_CopyTexImage2D(GLcontext
* ctx
, GLenum target
, GLint level
,
1211 GLenum internalFormat
,
1212 GLint x
, GLint y
, GLsizei width
, GLsizei height
,
1215 struct gl_texture_unit
*texUnit
=
1216 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1217 struct gl_texture_object
*texObj
=
1218 _mesa_select_tex_object(ctx
, texUnit
, target
);
1219 struct gl_texture_image
*texImage
=
1220 _mesa_select_tex_image(ctx
, texObj
, target
, level
);
1222 /* Setup or redefine the texture object, texture and texture
1223 * image. Don't populate yet.
1225 ctx
->Driver
.TexImage2D(ctx
, target
, level
, internalFormat
,
1226 width
, height
, border
,
1227 GL_RGBA
, CHAN_TYPE
, NULL
,
1228 &ctx
->DefaultPacking
, texObj
, texImage
);
1230 st_copy_texsubimage(ctx
, target
, level
,
1231 0, 0, 0, /* destX,Y,Z */
1232 x
, y
, width
, height
); /* src X, Y, size */
1237 st_CopyTexSubImage1D(GLcontext
* ctx
, GLenum target
, GLint level
,
1238 GLint xoffset
, GLint x
, GLint y
, GLsizei width
)
1240 const GLint yoffset
= 0, zoffset
= 0;
1241 const GLsizei height
= 1;
1242 st_copy_texsubimage(ctx
, target
, level
,
1243 xoffset
, yoffset
, zoffset
, /* destX,Y,Z */
1244 x
, y
, width
, height
); /* src X, Y, size */
1249 st_CopyTexSubImage2D(GLcontext
* ctx
, GLenum target
, GLint level
,
1250 GLint xoffset
, GLint yoffset
,
1251 GLint x
, GLint y
, GLsizei width
, GLsizei height
)
1253 const GLint zoffset
= 0;
1254 st_copy_texsubimage(ctx
, target
, level
,
1255 xoffset
, yoffset
, zoffset
, /* destX,Y,Z */
1256 x
, y
, width
, height
); /* src X, Y, size */
1261 st_CopyTexSubImage3D(GLcontext
* ctx
, GLenum target
, GLint level
,
1262 GLint xoffset
, GLint yoffset
, GLint zoffset
,
1263 GLint x
, GLint y
, GLsizei width
, GLsizei height
)
1265 st_copy_texsubimage(ctx
, target
, level
,
1266 xoffset
, yoffset
, zoffset
, /* destX,Y,Z */
1267 x
, y
, width
, height
); /* src X, Y, size */
1272 * Compute which mipmap levels that really need to be sent to the hardware.
1273 * This depends on the base image size, GL_TEXTURE_MIN_LOD,
1274 * GL_TEXTURE_MAX_LOD, GL_TEXTURE_BASE_LEVEL, and GL_TEXTURE_MAX_LEVEL.
1277 calculate_first_last_level(struct st_texture_object
*stObj
)
1279 struct gl_texture_object
*tObj
= &stObj
->base
;
1281 /* These must be signed values. MinLod and MaxLod can be negative numbers,
1282 * and having firstLevel and lastLevel as signed prevents the need for
1283 * extra sign checks.
1288 /* Yes, this looks overly complicated, but it's all needed.
1290 switch (tObj
->Target
) {
1294 case GL_TEXTURE_CUBE_MAP
:
1295 if (tObj
->MinFilter
== GL_NEAREST
|| tObj
->MinFilter
== GL_LINEAR
) {
1296 /* GL_NEAREST and GL_LINEAR only care about GL_TEXTURE_BASE_LEVEL.
1298 firstLevel
= lastLevel
= tObj
->BaseLevel
;
1302 lastLevel
= MIN2(tObj
->MaxLevel
,
1303 (int) tObj
->Image
[0][tObj
->BaseLevel
]->WidthLog2
);
1306 case GL_TEXTURE_RECTANGLE_NV
:
1307 case GL_TEXTURE_4D_SGIS
:
1308 firstLevel
= lastLevel
= 0;
1314 stObj
->lastLevel
= lastLevel
;
1319 copy_image_data_to_texture(struct st_context
*st
,
1320 struct st_texture_object
*stObj
,
1322 struct st_texture_image
*stImage
)
1325 /* Copy potentially with the blitter:
1327 st_texture_image_copy(st
->pipe
,
1328 stObj
->pt
, dstLevel
, /* dest texture, level */
1329 stImage
->pt
, /* src texture */
1333 pipe_texture_reference(&stImage
->pt
, NULL
);
1335 else if (stImage
->base
.Data
) {
1336 assert(stImage
->base
.Data
!= NULL
);
1338 /* More straightforward upload.
1340 st_texture_image_data(st
->pipe
,
1345 stImage
->base
.RowStride
*
1346 stObj
->pt
->block
.size
,
1347 stImage
->base
.RowStride
*
1348 stImage
->base
.Height
*
1349 stObj
->pt
->block
.size
);
1350 _mesa_align_free(stImage
->base
.Data
);
1351 stImage
->base
.Data
= NULL
;
1354 pipe_texture_reference(&stImage
->pt
, stObj
->pt
);
1359 * Called during state validation. When this function is finished,
1360 * the texture object should be ready for rendering.
1361 * \return GL_TRUE for success, GL_FALSE for failure (out of mem)
1364 st_finalize_texture(GLcontext
*ctx
,
1365 struct pipe_context
*pipe
,
1366 struct gl_texture_object
*tObj
,
1367 GLboolean
*needFlush
)
1369 struct st_texture_object
*stObj
= st_texture_object(tObj
);
1370 const GLuint nr_faces
= (stObj
->base
.Target
== GL_TEXTURE_CUBE_MAP
) ? 6 : 1;
1374 struct st_texture_image
*firstImage
;
1376 *needFlush
= GL_FALSE
;
1378 /* We know/require this is true by now:
1380 assert(stObj
->base
._Complete
);
1382 /* What levels must the texture include at a minimum?
1384 calculate_first_last_level(stObj
);
1385 firstImage
= st_texture_image(stObj
->base
.Image
[0][stObj
->base
.BaseLevel
]);
1387 /* If both firstImage and stObj point to a texture which can contain
1388 * all active images, favour firstImage. Note that because of the
1389 * completeness requirement, we know that the image dimensions
1392 if (firstImage
->pt
&&
1393 firstImage
->pt
!= stObj
->pt
&&
1394 firstImage
->pt
->last_level
>= stObj
->lastLevel
) {
1396 pipe_texture_reference(&stObj
->pt
, firstImage
->pt
);
1399 /* FIXME: determine format block instead of cpp */
1400 if (firstImage
->base
.IsCompressed
) {
1401 comp_byte
= compressed_num_bytes(firstImage
->base
.TexFormat
->MesaFormat
);
1405 cpp
= firstImage
->base
.TexFormat
->TexelBytes
;
1408 /* If we already have a gallium texture, check that it matches the texture
1409 * object's format, target, size, num_levels, etc.
1412 const enum pipe_format fmt
=
1413 st_mesa_format_to_pipe_format(firstImage
->base
.TexFormat
->MesaFormat
);
1414 if (stObj
->pt
->target
!= gl_target_to_pipe(stObj
->base
.Target
) ||
1415 stObj
->pt
->format
!= fmt
||
1416 stObj
->pt
->last_level
< stObj
->lastLevel
||
1417 stObj
->pt
->width
[0] != firstImage
->base
.Width2
||
1418 stObj
->pt
->height
[0] != firstImage
->base
.Height2
||
1419 stObj
->pt
->depth
[0] != firstImage
->base
.Depth2
||
1420 stObj
->pt
->block
.size
!= cpp
||
1421 stObj
->pt
->block
.width
!= 1 ||
1422 stObj
->pt
->block
.height
!= 1 ||
1423 stObj
->pt
->compressed
!= firstImage
->base
.IsCompressed
) {
1424 pipe_texture_release(&stObj
->pt
);
1425 ctx
->st
->dirty
.st
|= ST_NEW_FRAMEBUFFER
;
1429 /* May need to create a new gallium texture:
1432 const enum pipe_format fmt
=
1433 st_mesa_format_to_pipe_format(firstImage
->base
.TexFormat
->MesaFormat
);
1434 stObj
->pt
= st_texture_create(ctx
->st
,
1435 gl_target_to_pipe(stObj
->base
.Target
),
1438 firstImage
->base
.Width2
,
1439 firstImage
->base
.Height2
,
1440 firstImage
->base
.Depth2
,
1442 ( (pf_is_depth_stencil(fmt
) ?
1443 PIPE_TEXTURE_USAGE_DEPTH_STENCIL
:
1444 PIPE_TEXTURE_USAGE_RENDER_TARGET
) |
1445 PIPE_TEXTURE_USAGE_SAMPLER
));
1448 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexImage");
1453 /* Pull in any images not in the object's texture:
1455 for (face
= 0; face
< nr_faces
; face
++) {
1457 for (level
= 0; level
<= stObj
->lastLevel
; level
++) {
1458 struct st_texture_image
*stImage
=
1459 st_texture_image(stObj
->base
.Image
[face
][stObj
->base
.BaseLevel
+ level
]);
1461 /* Need to import images in main memory or held in other textures.
1463 if (stImage
&& stObj
->pt
!= stImage
->pt
) {
1464 copy_image_data_to_texture(ctx
->st
, stObj
, level
, stImage
);
1465 *needFlush
= GL_TRUE
;
1475 * Returns pointer to a default/dummy texture.
1476 * This is typically used when the current shader has tex/sample instructions
1477 * but the user has not provided a (any) texture(s).
1479 struct gl_texture_object
*
1480 st_get_default_texture(struct st_context
*st
)
1482 if (!st
->default_texture
) {
1483 static const GLenum target
= GL_TEXTURE_2D
;
1484 GLubyte pixels
[16][16][4];
1485 struct gl_texture_object
*texObj
;
1486 struct gl_texture_image
*texImg
;
1488 /* init image to gray */
1489 memset(pixels
, 127, sizeof(pixels
));
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
;