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"
29 #include "main/bufferobj.h"
30 #include "main/enums.h"
31 #include "main/fbobject.h"
32 #include "main/formats.h"
33 #include "main/image.h"
34 #include "main/imports.h"
35 #include "main/macros.h"
36 #include "main/mipmap.h"
37 #include "main/pack.h"
39 #include "main/pixeltransfer.h"
40 #include "main/texcompress.h"
41 #include "main/texgetimage.h"
42 #include "main/teximage.h"
43 #include "main/texobj.h"
44 #include "main/texstore.h"
46 #include "state_tracker/st_debug.h"
47 #include "state_tracker/st_context.h"
48 #include "state_tracker/st_cb_fbo.h"
49 #include "state_tracker/st_cb_flush.h"
50 #include "state_tracker/st_cb_texture.h"
51 #include "state_tracker/st_format.h"
52 #include "state_tracker/st_texture.h"
53 #include "state_tracker/st_gen_mipmap.h"
54 #include "state_tracker/st_atom.h"
56 #include "pipe/p_context.h"
57 #include "pipe/p_defines.h"
58 #include "util/u_inlines.h"
59 #include "pipe/p_shader_tokens.h"
60 #include "util/u_tile.h"
61 #include "util/u_blit.h"
62 #include "util/u_format.h"
63 #include "util/u_surface.h"
64 #include "util/u_sampler.h"
65 #include "util/u_math.h"
66 #include "util/u_box.h"
68 #define DBG if (0) printf
71 static enum pipe_texture_target
72 gl_target_to_pipe(GLenum target
)
76 return PIPE_TEXTURE_1D
;
78 case GL_TEXTURE_EXTERNAL_OES
:
79 return PIPE_TEXTURE_2D
;
80 case GL_TEXTURE_RECTANGLE_NV
:
81 return PIPE_TEXTURE_RECT
;
83 return PIPE_TEXTURE_3D
;
84 case GL_TEXTURE_CUBE_MAP_ARB
:
85 return PIPE_TEXTURE_CUBE
;
86 case GL_TEXTURE_1D_ARRAY_EXT
:
87 return PIPE_TEXTURE_1D_ARRAY
;
88 case GL_TEXTURE_2D_ARRAY_EXT
:
89 return PIPE_TEXTURE_2D_ARRAY
;
90 case GL_TEXTURE_BUFFER
:
99 /** called via ctx->Driver.NewTextureImage() */
100 static struct gl_texture_image
*
101 st_NewTextureImage(struct gl_context
* ctx
)
103 DBG("%s\n", __FUNCTION__
);
105 return (struct gl_texture_image
*) ST_CALLOC_STRUCT(st_texture_image
);
109 /** called via ctx->Driver.DeleteTextureImage() */
111 st_DeleteTextureImage(struct gl_context
* ctx
, struct gl_texture_image
*img
)
113 /* nothing special (yet) for st_texture_image */
114 _mesa_delete_texture_image(ctx
, img
);
118 /** called via ctx->Driver.NewTextureObject() */
119 static struct gl_texture_object
*
120 st_NewTextureObject(struct gl_context
* ctx
, GLuint name
, GLenum target
)
122 struct st_texture_object
*obj
= ST_CALLOC_STRUCT(st_texture_object
);
124 DBG("%s\n", __FUNCTION__
);
125 _mesa_initialize_texture_object(&obj
->base
, name
, target
);
130 /** called via ctx->Driver.DeleteTextureObject() */
132 st_DeleteTextureObject(struct gl_context
*ctx
,
133 struct gl_texture_object
*texObj
)
135 struct st_context
*st
= st_context(ctx
);
136 struct st_texture_object
*stObj
= st_texture_object(texObj
);
138 pipe_resource_reference(&stObj
->pt
, NULL
);
139 if (stObj
->sampler_view
) {
140 if (stObj
->sampler_view
->context
!= st
->pipe
) {
141 /* Take "ownership" of this texture sampler view by setting
142 * its context pointer to this context. This avoids potential
143 * crashes when the texture object is shared among contexts
144 * and the original/owner context has already been destroyed.
146 stObj
->sampler_view
->context
= st
->pipe
;
148 pipe_sampler_view_reference(&stObj
->sampler_view
, NULL
);
150 _mesa_delete_texture_object(ctx
, texObj
);
154 /** called via ctx->Driver.FreeTextureImageBuffer() */
156 st_FreeTextureImageBuffer(struct gl_context
*ctx
,
157 struct gl_texture_image
*texImage
)
159 struct st_texture_image
*stImage
= st_texture_image(texImage
);
161 DBG("%s\n", __FUNCTION__
);
164 pipe_resource_reference(&stImage
->pt
, NULL
);
167 if (stImage
->TexData
) {
168 _mesa_align_free(stImage
->TexData
);
169 stImage
->TexData
= NULL
;
174 /** called via ctx->Driver.MapTextureImage() */
176 st_MapTextureImage(struct gl_context
*ctx
,
177 struct gl_texture_image
*texImage
,
178 GLuint slice
, GLuint x
, GLuint y
, GLuint w
, GLuint h
,
180 GLubyte
**mapOut
, GLint
*rowStrideOut
)
182 struct st_context
*st
= st_context(ctx
);
183 struct st_texture_image
*stImage
= st_texture_image(texImage
);
188 if (mode
& GL_MAP_READ_BIT
)
189 pipeMode
|= PIPE_TRANSFER_READ
;
190 if (mode
& GL_MAP_WRITE_BIT
)
191 pipeMode
|= PIPE_TRANSFER_WRITE
;
193 map
= st_texture_image_map(st
, stImage
, slice
, pipeMode
, x
, y
, w
, h
);
196 *rowStrideOut
= stImage
->transfer
->stride
;
205 /** called via ctx->Driver.UnmapTextureImage() */
207 st_UnmapTextureImage(struct gl_context
*ctx
,
208 struct gl_texture_image
*texImage
,
211 struct st_context
*st
= st_context(ctx
);
212 struct st_texture_image
*stImage
= st_texture_image(texImage
);
213 st_texture_image_unmap(st
, stImage
);
218 * Return default texture resource binding bitmask for the given format.
221 default_bindings(struct st_context
*st
, enum pipe_format format
)
223 struct pipe_screen
*screen
= st
->pipe
->screen
;
224 const unsigned target
= PIPE_TEXTURE_2D
;
227 if (util_format_is_depth_or_stencil(format
))
228 bindings
= PIPE_BIND_SAMPLER_VIEW
| PIPE_BIND_DEPTH_STENCIL
;
230 bindings
= PIPE_BIND_SAMPLER_VIEW
| PIPE_BIND_RENDER_TARGET
;
232 if (screen
->is_format_supported(screen
, format
, target
, 0, bindings
))
236 format
= util_format_linear(format
);
238 if (screen
->is_format_supported(screen
, format
, target
, 0, bindings
))
241 return PIPE_BIND_SAMPLER_VIEW
;
246 /** Return number of image dimensions (1, 2 or 3) for a texture target. */
248 get_texture_dims(GLenum target
)
252 case GL_TEXTURE_1D_ARRAY_EXT
:
253 case GL_TEXTURE_BUFFER
:
256 case GL_TEXTURE_CUBE_MAP_ARB
:
257 case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB
:
258 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB
:
259 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB
:
260 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB
:
261 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB
:
262 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB
:
263 case GL_TEXTURE_RECTANGLE_NV
:
264 case GL_TEXTURE_2D_ARRAY_EXT
:
265 case GL_TEXTURE_EXTERNAL_OES
:
270 assert(0 && "invalid texture target in get_texture_dims()");
277 * Given the size of a mipmap image, try to compute the size of the level=0
280 * Note that this isn't always accurate for odd-sized, non-POW textures.
281 * For example, if level=1 and width=40 then the level=0 width may be 80 or 81.
283 * \return GL_TRUE for success, GL_FALSE for failure
286 guess_base_level_size(GLenum target
,
287 GLuint width
, GLuint height
, GLuint depth
, GLuint level
,
288 GLuint
*width0
, GLuint
*height0
, GLuint
*depth0
)
290 const GLuint dims
= get_texture_dims(target
);
297 /* Depending on the image's size, we can't always make a guess here */
298 if ((dims
>= 1 && width
== 1) ||
299 (dims
>= 2 && height
== 1) ||
300 (dims
>= 3 && depth
== 1)) {
301 /* we can't determine the image size at level=0 */
305 /* grow the image size until we hit level = 0 */
326 * Try to allocate a pipe_resource object for the given st_texture_object.
328 * We use the given st_texture_image as a clue to determine the size of the
329 * mipmap image at level=0.
331 * \return GL_TRUE for success, GL_FALSE if out of memory.
334 guess_and_alloc_texture(struct st_context
*st
,
335 struct st_texture_object
*stObj
,
336 const struct st_texture_image
*stImage
)
338 GLuint lastLevel
, width
, height
, depth
;
340 GLuint ptWidth
, ptHeight
, ptDepth
, ptLayers
;
341 enum pipe_format fmt
;
343 DBG("%s\n", __FUNCTION__
);
347 if (!guess_base_level_size(stObj
->base
.Target
,
348 stImage
->base
.Width2
,
349 stImage
->base
.Height2
,
350 stImage
->base
.Depth2
,
352 &width
, &height
, &depth
)) {
353 /* we can't determine the image size at level=0 */
354 stObj
->width0
= stObj
->height0
= stObj
->depth0
= 0;
355 /* this is not an out of memory error */
359 /* At this point, (width x height x depth) is the expected size of
360 * the level=0 mipmap image.
363 /* Guess a reasonable value for lastLevel. With OpenGL we have no
364 * idea how many mipmap levels will be in a texture until we start
365 * to render with it. Make an educated guess here but be prepared
366 * to re-allocating a texture buffer with space for more (or fewer)
367 * mipmap levels later.
369 if ((stObj
->base
.Sampler
.MinFilter
== GL_NEAREST
||
370 stObj
->base
.Sampler
.MinFilter
== GL_LINEAR
||
371 stImage
->base
._BaseFormat
== GL_DEPTH_COMPONENT
||
372 stImage
->base
._BaseFormat
== GL_DEPTH_STENCIL_EXT
) &&
373 !stObj
->base
.GenerateMipmap
&&
374 stImage
->base
.Level
== 0) {
375 /* only alloc space for a single mipmap level */
379 /* alloc space for a full mipmap */
380 GLuint l2width
= util_logbase2(width
);
381 GLuint l2height
= util_logbase2(height
);
382 GLuint l2depth
= util_logbase2(depth
);
383 lastLevel
= MAX2(MAX2(l2width
, l2height
), l2depth
);
386 /* Save the level=0 dimensions */
387 stObj
->width0
= width
;
388 stObj
->height0
= height
;
389 stObj
->depth0
= depth
;
391 fmt
= st_mesa_format_to_pipe_format(stImage
->base
.TexFormat
);
393 bindings
= default_bindings(st
, fmt
);
395 st_gl_texture_dims_to_pipe_dims(stObj
->base
.Target
,
396 width
, height
, depth
,
397 &ptWidth
, &ptHeight
, &ptDepth
, &ptLayers
);
399 stObj
->pt
= st_texture_create(st
,
400 gl_target_to_pipe(stObj
->base
.Target
),
409 DBG("%s returning %d\n", __FUNCTION__
, (stObj
->pt
!= NULL
));
411 return stObj
->pt
!= NULL
;
416 * Called via ctx->Driver.AllocTextureImageBuffer().
417 * If the texture object/buffer already has space for the indicated image,
418 * we're done. Otherwise, allocate memory for the new texture image.
421 st_AllocTextureImageBuffer(struct gl_context
*ctx
,
422 struct gl_texture_image
*texImage
,
423 gl_format format
, GLsizei width
,
424 GLsizei height
, GLsizei depth
)
426 struct st_context
*st
= st_context(ctx
);
427 struct st_texture_image
*stImage
= st_texture_image(texImage
);
428 struct st_texture_object
*stObj
= st_texture_object(texImage
->TexObject
);
429 const GLuint level
= texImage
->Level
;
431 DBG("%s\n", __FUNCTION__
);
436 assert(!stImage
->TexData
);
437 assert(!stImage
->pt
); /* xxx this might be wrong */
439 /* Look if the parent texture object has space for this image */
441 level
<= stObj
->pt
->last_level
&&
442 st_texture_match_image(stObj
->pt
, texImage
)) {
443 /* this image will fit in the existing texture object's memory */
444 pipe_resource_reference(&stImage
->pt
, stObj
->pt
);
448 /* The parent texture object does not have space for this image */
450 pipe_resource_reference(&stObj
->pt
, NULL
);
451 pipe_sampler_view_reference(&stObj
->sampler_view
, NULL
);
453 if (!guess_and_alloc_texture(st
, stObj
, stImage
)) {
454 /* Probably out of memory.
455 * Try flushing any pending rendering, then retry.
458 if (!guess_and_alloc_texture(st
, stObj
, stImage
)) {
459 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexImage");
465 st_texture_match_image(stObj
->pt
, texImage
)) {
466 /* The image will live in the object's mipmap memory */
467 pipe_resource_reference(&stImage
->pt
, stObj
->pt
);
472 /* Create a new, temporary texture/resource/buffer to hold this
473 * one texture image. Note that when we later access this image
474 * (either for mapping or copying) we'll want to always specify
475 * mipmap level=0, even if the image represents some other mipmap
478 enum pipe_format format
=
479 st_mesa_format_to_pipe_format(texImage
->TexFormat
);
480 GLuint bindings
= default_bindings(st
, format
);
481 GLuint ptWidth
, ptHeight
, ptDepth
, ptLayers
;
483 st_gl_texture_dims_to_pipe_dims(stObj
->base
.Target
,
484 width
, height
, depth
,
485 &ptWidth
, &ptHeight
, &ptDepth
, &ptLayers
);
487 stImage
->pt
= st_texture_create(st
,
488 gl_target_to_pipe(stObj
->base
.Target
),
496 return stImage
->pt
!= NULL
;
502 * Preparation prior to glTexImage. Basically check the 'surface_based'
503 * field and switch to a "normal" tex image if necessary.
506 prep_teximage(struct gl_context
*ctx
, struct gl_texture_image
*texImage
,
507 GLint internalFormat
,
508 GLint width
, GLint height
, GLint depth
, GLint border
,
509 GLenum format
, GLenum type
)
511 struct gl_texture_object
*texObj
= texImage
->TexObject
;
512 struct st_texture_object
*stObj
= st_texture_object(texObj
);
514 /* switch to "normal" */
515 if (stObj
->surface_based
) {
516 const GLenum target
= texObj
->Target
;
517 const GLuint level
= texImage
->Level
;
520 _mesa_clear_texture_object(ctx
, texObj
);
521 pipe_resource_reference(&stObj
->pt
, NULL
);
523 /* oops, need to init this image again */
524 texFormat
= _mesa_choose_texture_format(ctx
, texObj
, target
, level
,
525 internalFormat
, format
, type
);
527 _mesa_init_teximage_fields(ctx
, texImage
,
528 width
, height
, depth
, border
,
529 internalFormat
, texFormat
);
531 stObj
->surface_based
= GL_FALSE
;
537 st_TexImage3D(struct gl_context
* ctx
,
538 struct gl_texture_image
*texImage
,
539 GLint internalFormat
,
540 GLint width
, GLint height
, GLint depth
,
542 GLenum format
, GLenum type
, const void *pixels
,
543 const struct gl_pixelstore_attrib
*unpack
)
545 prep_teximage(ctx
, texImage
, internalFormat
, width
, height
, depth
, border
,
547 _mesa_store_teximage3d(ctx
, texImage
, internalFormat
, width
, height
, depth
,
548 border
, format
, type
, pixels
, unpack
);
553 st_TexImage2D(struct gl_context
* ctx
,
554 struct gl_texture_image
*texImage
,
555 GLint internalFormat
,
556 GLint width
, GLint height
, GLint border
,
557 GLenum format
, GLenum type
, const void *pixels
,
558 const struct gl_pixelstore_attrib
*unpack
)
560 prep_teximage(ctx
, texImage
, internalFormat
, width
, height
, 1, border
,
562 _mesa_store_teximage2d(ctx
, texImage
, internalFormat
, width
, height
,
563 border
, format
, type
, pixels
, unpack
);
568 st_TexImage1D(struct gl_context
* ctx
,
569 struct gl_texture_image
*texImage
,
570 GLint internalFormat
,
571 GLint width
, GLint border
,
572 GLenum format
, GLenum type
, const void *pixels
,
573 const struct gl_pixelstore_attrib
*unpack
)
575 prep_teximage(ctx
, texImage
, internalFormat
, width
, 1, 1, border
,
577 _mesa_store_teximage1d(ctx
, texImage
, internalFormat
, width
,
578 border
, format
, type
, pixels
, unpack
);
583 st_CompressedTexImage2D(struct gl_context
*ctx
,
584 struct gl_texture_image
*texImage
,
585 GLint internalFormat
,
586 GLint width
, GLint height
, GLint border
,
587 GLsizei imageSize
, const GLvoid
*data
)
589 prep_teximage(ctx
, texImage
, internalFormat
, width
, 1, 1, border
,
591 _mesa_store_compressed_teximage2d(ctx
, texImage
, internalFormat
, width
,
592 height
, border
, imageSize
, data
);
598 * glGetTexImage() helper: decompress a compressed texture by rendering
599 * a textured quad. Store the results in the user's buffer.
602 decompress_with_blit(struct gl_context
* ctx
,
603 GLenum format
, GLenum type
, GLvoid
*pixels
,
604 struct gl_texture_image
*texImage
)
606 struct st_context
*st
= st_context(ctx
);
607 struct pipe_context
*pipe
= st
->pipe
;
608 struct st_texture_image
*stImage
= st_texture_image(texImage
);
609 struct st_texture_object
*stObj
= st_texture_object(texImage
->TexObject
);
610 struct pipe_sampler_view
*src_view
=
611 st_get_texture_sampler_view(stObj
, pipe
);
612 const GLuint width
= texImage
->Width
;
613 const GLuint height
= texImage
->Height
;
614 struct pipe_surface
*dst_surface
;
615 struct pipe_resource
*dst_texture
;
616 struct pipe_transfer
*tex_xfer
;
617 unsigned bind
= (PIPE_BIND_RENDER_TARGET
| /* util_blit may choose to render */
618 PIPE_BIND_TRANSFER_READ
);
620 /* create temp / dest surface */
621 if (!util_create_rgba_surface(pipe
, width
, height
, bind
,
622 &dst_texture
, &dst_surface
)) {
623 _mesa_problem(ctx
, "util_create_rgba_surface() failed "
624 "in decompress_with_blit()");
628 /* Disable conditional rendering. */
629 if (st
->render_condition
) {
630 pipe
->render_condition(pipe
, NULL
, 0);
633 /* Choose the source mipmap level */
634 src_view
->u
.tex
.first_level
= src_view
->u
.tex
.last_level
= texImage
->Level
;
636 /* blit/render/decompress */
637 util_blit_pixels_tex(st
->blit
,
638 src_view
, /* pipe_resource (src) */
639 0, 0, /* src x0, y0 */
640 width
, height
, /* src x1, y1 */
641 dst_surface
, /* pipe_surface (dst) */
642 0, 0, /* dst x0, y0 */
643 width
, height
, /* dst x1, y1 */
645 PIPE_TEX_MIPFILTER_NEAREST
);
647 /* Restore conditional rendering state. */
648 if (st
->render_condition
) {
649 pipe
->render_condition(pipe
, st
->render_condition
,
653 /* map the dst_surface so we can read from it */
654 tex_xfer
= pipe_get_transfer(pipe
,
657 0, 0, width
, height
);
659 pixels
= _mesa_map_pbo_dest(ctx
, &ctx
->Pack
, pixels
);
661 /* copy/pack data into user buffer */
662 if (st_equal_formats(stImage
->pt
->format
, format
, type
)) {
664 const uint bytesPerRow
= width
* util_format_get_blocksize(stImage
->pt
->format
);
665 ubyte
*map
= pipe_transfer_map(pipe
, tex_xfer
);
667 for (row
= 0; row
< height
; row
++) {
668 GLvoid
*dest
= _mesa_image_address2d(&ctx
->Pack
, pixels
, width
,
669 height
, format
, type
, row
, 0);
670 memcpy(dest
, map
, bytesPerRow
);
671 map
+= tex_xfer
->stride
;
673 pipe_transfer_unmap(pipe
, tex_xfer
);
676 /* format translation via floats */
678 enum pipe_format pformat
= util_format_linear(dst_texture
->format
);
679 for (row
= 0; row
< height
; row
++) {
680 const GLbitfield transferOps
= 0x0; /* bypassed for glGetTexImage() */
681 GLfloat rgba
[4 * MAX_WIDTH
];
682 GLvoid
*dest
= _mesa_image_address2d(&ctx
->Pack
, pixels
, width
,
683 height
, format
, type
, row
, 0);
685 if (ST_DEBUG
& DEBUG_FALLBACK
)
686 debug_printf("%s: fallback format translation\n", __FUNCTION__
);
688 /* get float[4] rgba row from surface */
689 pipe_get_tile_rgba_format(pipe
, tex_xfer
, 0, row
, width
, 1,
692 _mesa_pack_rgba_span_float(ctx
, width
, (GLfloat (*)[4]) rgba
, format
,
693 type
, dest
, &ctx
->Pack
, transferOps
);
697 _mesa_unmap_pbo_dest(ctx
, &ctx
->Pack
);
699 pipe
->transfer_destroy(pipe
, tex_xfer
);
701 /* destroy the temp / dest surface */
702 util_destroy_rgba_surface(dst_texture
, dst_surface
);
708 * Called via ctx->Driver.GetTexImage()
711 st_GetTexImage(struct gl_context
* ctx
,
712 GLenum format
, GLenum type
, GLvoid
* pixels
,
713 struct gl_texture_image
*texImage
)
715 struct st_texture_image
*stImage
= st_texture_image(texImage
);
717 if (stImage
->pt
&& util_format_is_s3tc(stImage
->pt
->format
)) {
718 /* Need to decompress the texture.
719 * We'll do this by rendering a textured quad (which is hopefully
720 * faster than using the fallback code in texcompress.c).
721 * Note that we only expect RGBA formats (no Z/depth formats).
723 decompress_with_blit(ctx
, format
, type
, pixels
, texImage
);
726 _mesa_get_teximage(ctx
, format
, type
, pixels
, texImage
);
732 * Do a CopyTexSubImage operation using a read transfer from the source,
733 * a write transfer to the destination and get_tile()/put_tile() to access
736 * Note: srcY=0=TOP of renderbuffer
739 fallback_copy_texsubimage(struct gl_context
*ctx
, GLenum target
, GLint level
,
740 struct st_renderbuffer
*strb
,
741 struct st_texture_image
*stImage
,
743 GLint destX
, GLint destY
, GLint destZ
,
744 GLint srcX
, GLint srcY
,
745 GLsizei width
, GLsizei height
)
747 struct st_context
*st
= st_context(ctx
);
748 struct pipe_context
*pipe
= st
->pipe
;
749 struct pipe_transfer
*src_trans
;
751 enum pipe_transfer_usage transfer_usage
;
753 if (ST_DEBUG
& DEBUG_FALLBACK
)
754 debug_printf("%s: fallback processing\n", __FUNCTION__
);
756 assert(width
<= MAX_WIDTH
);
758 if (st_fb_orientation(ctx
->ReadBuffer
) == Y_0_TOP
) {
759 srcY
= strb
->Base
.Height
- srcY
- height
;
762 src_trans
= pipe_get_transfer(pipe
,
765 strb
->rtt_face
+ strb
->rtt_slice
,
770 if ((baseFormat
== GL_DEPTH_COMPONENT
||
771 baseFormat
== GL_DEPTH_STENCIL
) &&
772 util_format_is_depth_and_stencil(stImage
->pt
->format
))
773 transfer_usage
= PIPE_TRANSFER_READ_WRITE
;
775 transfer_usage
= PIPE_TRANSFER_WRITE
;
777 /* XXX this used to ignore destZ param */
778 texDest
= st_texture_image_map(st
, stImage
, destZ
, transfer_usage
,
779 destX
, destY
, width
, height
);
781 if (baseFormat
== GL_DEPTH_COMPONENT
||
782 baseFormat
== GL_DEPTH_STENCIL
) {
783 const GLboolean scaleOrBias
= (ctx
->Pixel
.DepthScale
!= 1.0F
||
784 ctx
->Pixel
.DepthBias
!= 0.0F
);
787 /* determine bottom-to-top vs. top-to-bottom order for src buffer */
788 if (st_fb_orientation(ctx
->ReadBuffer
) == Y_0_TOP
) {
797 /* To avoid a large temp memory allocation, do copy row by row */
798 for (row
= 0; row
< height
; row
++, srcY
+= yStep
) {
799 uint data
[MAX_WIDTH
];
800 pipe_get_tile_z(pipe
, src_trans
, 0, srcY
, width
, 1, data
);
802 _mesa_scale_and_bias_depth_uint(ctx
, width
, data
);
804 pipe_put_tile_z(pipe
, stImage
->transfer
, 0, row
, width
, 1, data
);
810 (GLfloat
*) malloc(width
* height
* 4 * sizeof(GLfloat
));
812 if (tempSrc
&& texDest
) {
813 const GLint dims
= 2;
814 const GLint dstRowStride
= stImage
->transfer
->stride
;
815 struct gl_texture_image
*texImage
= &stImage
->base
;
816 struct gl_pixelstore_attrib unpack
= ctx
->DefaultPacking
;
818 if (st_fb_orientation(ctx
->ReadBuffer
) == Y_0_TOP
) {
819 unpack
.Invert
= GL_TRUE
;
822 /* get float/RGBA image from framebuffer */
823 /* XXX this usually involves a lot of int/float conversion.
824 * try to avoid that someday.
826 pipe_get_tile_rgba_format(pipe
, src_trans
, 0, 0, width
, height
,
827 util_format_linear(strb
->texture
->format
),
830 /* Store into texture memory.
831 * Note that this does some special things such as pixel transfer
832 * ops and format conversion. In particular, if the dest tex format
833 * is actually RGBA but the user created the texture as GL_RGB we
834 * need to fill-in/override the alpha channel with 1.0.
836 _mesa_texstore(ctx
, dims
,
837 texImage
->_BaseFormat
,
840 (GLubyte
**) &texDest
,
842 GL_RGBA
, GL_FLOAT
, tempSrc
, /* src */
846 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexSubImage");
853 st_texture_image_unmap(st
, stImage
);
854 pipe
->transfer_destroy(pipe
, src_trans
);
860 * If the format of the src renderbuffer and the format of the dest
861 * texture are compatible (in terms of blitting), return a TGSI writemask
862 * to be used during the blit.
863 * If the src/dest are incompatible, return 0.
866 compatible_src_dst_formats(struct gl_context
*ctx
,
867 const struct gl_renderbuffer
*src
,
868 const struct gl_texture_image
*dst
)
870 /* Get logical base formats for the src and dest.
871 * That is, use the user-requested formats and not the actual, device-
873 * For example, the user may have requested an A8 texture but the
874 * driver may actually be using an RGBA texture format. When we
875 * copy/blit to that texture, we only want to copy the Alpha channel
876 * and not the RGB channels.
878 * Similarly, when the src FBO was created an RGB format may have been
879 * requested but the driver actually chose an RGBA format. In that case,
880 * we don't want to copy the undefined Alpha channel to the dest texture
881 * (it should be 1.0).
883 const GLenum srcFormat
= _mesa_base_fbo_format(ctx
, src
->InternalFormat
);
884 const GLenum dstFormat
= _mesa_base_tex_format(ctx
, dst
->InternalFormat
);
887 * XXX when we have red-only and red/green renderbuffers we'll need
888 * to add more cases here (or implement a general-purpose routine that
889 * queries the existance of the R,G,B,A channels in the src and dest).
891 if (srcFormat
== dstFormat
) {
892 /* This is the same as matching_base_formats, which should
893 * always pass, as it did previously.
895 return TGSI_WRITEMASK_XYZW
;
897 else if (srcFormat
== GL_RGB
&& dstFormat
== GL_RGBA
) {
898 /* Make sure that A in the dest is 1. The actual src format
899 * may be RGBA and have undefined A values.
901 return TGSI_WRITEMASK_XYZ
;
903 else if (srcFormat
== GL_RGBA
&& dstFormat
== GL_RGB
) {
904 /* Make sure that A in the dest is 1. The actual dst format
905 * may be RGBA and will need A=1 to provide proper alpha values
906 * when sampled later.
908 return TGSI_WRITEMASK_XYZ
;
911 if (ST_DEBUG
& DEBUG_FALLBACK
)
912 debug_printf("%s failed for src %s, dst %s\n",
914 _mesa_lookup_enum_by_nr(srcFormat
),
915 _mesa_lookup_enum_by_nr(dstFormat
));
926 * Do a CopyTex[Sub]Image1/2/3D() using a hardware (blit) path if possible.
927 * Note that the region to copy has already been clipped so we know we
928 * won't read from outside the source renderbuffer's bounds.
930 * Note: srcY=0=Bottom of renderbuffer (GL convention)
933 st_copy_texsubimage(struct gl_context
*ctx
,
934 GLenum target
, GLint level
,
935 GLint destX
, GLint destY
, GLint destZ
,
936 GLint srcX
, GLint srcY
,
937 GLsizei width
, GLsizei height
)
939 struct gl_texture_unit
*texUnit
=
940 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
941 struct gl_texture_object
*texObj
=
942 _mesa_select_tex_object(ctx
, texUnit
, target
);
943 struct gl_texture_image
*texImage
=
944 _mesa_select_tex_image(ctx
, texObj
, target
, level
);
945 struct st_texture_image
*stImage
= st_texture_image(texImage
);
946 const GLenum texBaseFormat
= texImage
->_BaseFormat
;
947 struct gl_framebuffer
*fb
= ctx
->ReadBuffer
;
948 struct st_renderbuffer
*strb
;
949 struct st_context
*st
= st_context(ctx
);
950 struct pipe_context
*pipe
= st
->pipe
;
951 struct pipe_screen
*screen
= pipe
->screen
;
952 enum pipe_format dest_format
, src_format
;
953 GLboolean matching_base_formats
;
954 GLuint format_writemask
, sample_count
;
955 struct pipe_surface
*dest_surface
= NULL
;
956 GLboolean do_flip
= (st_fb_orientation(ctx
->ReadBuffer
) == Y_0_TOP
);
957 struct pipe_surface surf_tmpl
;
958 unsigned int dst_usage
;
961 /* make sure finalize_textures has been called?
963 if (0) st_validate_state(st
);
965 /* determine if copying depth or color data */
966 if (texBaseFormat
== GL_DEPTH_COMPONENT
||
967 texBaseFormat
== GL_DEPTH_STENCIL
) {
968 strb
= st_renderbuffer(fb
->Attachment
[BUFFER_DEPTH
].Renderbuffer
);
971 /* texBaseFormat == GL_RGB, GL_RGBA, GL_ALPHA, etc */
972 strb
= st_renderbuffer(fb
->_ColorReadBuffer
);
975 if (!strb
|| !strb
->surface
|| !stImage
->pt
) {
976 debug_printf("%s: null strb or stImage\n", __FUNCTION__
);
980 sample_count
= strb
->surface
->texture
->nr_samples
;
981 /* I believe this would be legal, presumably would need to do a resolve
982 for color, and for depth/stencil spec says to just use one of the
983 depth/stencil samples per pixel? Need some transfer clarifications. */
984 assert(sample_count
< 2);
987 assert(strb
->surface
);
990 src_format
= strb
->surface
->format
;
991 dest_format
= stImage
->pt
->format
;
994 * Determine if the src framebuffer and dest texture have the same
995 * base format. We need this to detect a case such as the framebuffer
996 * being GL_RGBA but the texture being GL_RGB. If the actual hardware
997 * texture format stores RGBA we need to set A=1 (overriding the
998 * framebuffer's alpha values). We can't do that with the blit or
999 * textured-quad paths.
1001 matching_base_formats
=
1002 (_mesa_get_format_base_format(strb
->Base
.Format
) ==
1003 _mesa_get_format_base_format(texImage
->TexFormat
));
1005 if (ctx
->_ImageTransferState
) {
1009 if (matching_base_formats
&&
1010 src_format
== dest_format
&&
1012 /* use surface_copy() / blit */
1013 struct pipe_box src_box
;
1014 u_box_2d_zslice(srcX
, srcY
, strb
->surface
->u
.tex
.first_layer
,
1015 width
, height
, &src_box
);
1017 /* for resource_copy_region(), y=0=top, always */
1018 pipe
->resource_copy_region(pipe
,
1021 stImage
->base
.Level
,
1022 destX
, destY
, destZ
+ stImage
->base
.Face
,
1025 strb
->surface
->u
.tex
.level
,
1030 if (texBaseFormat
== GL_DEPTH_STENCIL
) {
1034 if (texBaseFormat
== GL_DEPTH_COMPONENT
) {
1035 format_writemask
= TGSI_WRITEMASK_XYZW
;
1036 dst_usage
= PIPE_BIND_DEPTH_STENCIL
;
1039 format_writemask
= compatible_src_dst_formats(ctx
, &strb
->Base
, texImage
);
1040 dst_usage
= PIPE_BIND_RENDER_TARGET
;
1043 if (!format_writemask
||
1044 !screen
->is_format_supported(screen
, src_format
,
1045 PIPE_TEXTURE_2D
, sample_count
,
1046 PIPE_BIND_SAMPLER_VIEW
) ||
1047 !screen
->is_format_supported(screen
, dest_format
,
1054 srcY1
= strb
->Base
.Height
- srcY
- height
;
1055 srcY0
= srcY1
+ height
;
1059 srcY1
= srcY0
+ height
;
1062 /* Disable conditional rendering. */
1063 if (st
->render_condition
) {
1064 pipe
->render_condition(pipe
, NULL
, 0);
1067 memset(&surf_tmpl
, 0, sizeof(surf_tmpl
));
1068 surf_tmpl
.format
= util_format_linear(stImage
->pt
->format
);
1069 surf_tmpl
.usage
= dst_usage
;
1070 surf_tmpl
.u
.tex
.level
= stImage
->base
.Level
;
1071 surf_tmpl
.u
.tex
.first_layer
= stImage
->base
.Face
+ destZ
;
1072 surf_tmpl
.u
.tex
.last_layer
= stImage
->base
.Face
+ destZ
;
1074 dest_surface
= pipe
->create_surface(pipe
, stImage
->pt
,
1076 util_blit_pixels_writemask(st
->blit
,
1078 strb
->surface
->u
.tex
.level
,
1080 srcX
+ width
, srcY1
,
1081 strb
->surface
->u
.tex
.first_layer
,
1084 destX
+ width
, destY
+ height
,
1085 0.0, PIPE_TEX_MIPFILTER_NEAREST
,
1087 pipe_surface_reference(&dest_surface
, NULL
);
1089 /* Restore conditional rendering state. */
1090 if (st
->render_condition
) {
1091 pipe
->render_condition(pipe
, st
->render_condition
,
1092 st
->condition_mode
);
1098 /* software fallback */
1099 fallback_copy_texsubimage(ctx
, target
, level
,
1100 strb
, stImage
, texBaseFormat
,
1101 destX
, destY
, destZ
,
1102 srcX
, srcY
, width
, height
);
1108 st_CopyTexSubImage1D(struct gl_context
* ctx
, GLenum target
, GLint level
,
1109 GLint xoffset
, GLint x
, GLint y
, GLsizei width
)
1111 const GLint yoffset
= 0, zoffset
= 0;
1112 const GLsizei height
= 1;
1113 st_copy_texsubimage(ctx
, target
, level
,
1114 xoffset
, yoffset
, zoffset
, /* destX,Y,Z */
1115 x
, y
, width
, height
); /* src X, Y, size */
1120 st_CopyTexSubImage2D(struct gl_context
* ctx
, GLenum target
, GLint level
,
1121 GLint xoffset
, GLint yoffset
,
1122 GLint x
, GLint y
, GLsizei width
, GLsizei height
)
1124 const GLint zoffset
= 0;
1125 st_copy_texsubimage(ctx
, target
, level
,
1126 xoffset
, yoffset
, zoffset
, /* destX,Y,Z */
1127 x
, y
, width
, height
); /* src X, Y, size */
1132 st_CopyTexSubImage3D(struct gl_context
* ctx
, GLenum target
, GLint level
,
1133 GLint xoffset
, GLint yoffset
, GLint zoffset
,
1134 GLint x
, GLint y
, GLsizei width
, GLsizei height
)
1136 st_copy_texsubimage(ctx
, target
, level
,
1137 xoffset
, yoffset
, zoffset
, /* destX,Y,Z */
1138 x
, y
, width
, height
); /* src X, Y, size */
1143 * Copy image data from stImage into the texture object 'stObj' at level
1147 copy_image_data_to_texture(struct st_context
*st
,
1148 struct st_texture_object
*stObj
,
1150 struct st_texture_image
*stImage
)
1154 const struct gl_texture_image
*dstImage
=
1155 stObj
->base
.Image
[stImage
->base
.Face
][dstLevel
];
1157 assert(dstImage
->Width
== stImage
->base
.Width
);
1158 assert(dstImage
->Height
== stImage
->base
.Height
);
1159 assert(dstImage
->Depth
== stImage
->base
.Depth
);
1163 /* Copy potentially with the blitter:
1166 if (stImage
->pt
!= stObj
->pt
)
1169 src_level
= stImage
->base
.Level
;
1171 st_texture_image_copy(st
->pipe
,
1172 stObj
->pt
, dstLevel
, /* dest texture, level */
1173 stImage
->pt
, src_level
, /* src texture, level */
1174 stImage
->base
.Face
);
1176 pipe_resource_reference(&stImage
->pt
, NULL
);
1178 else if (stImage
->TexData
) {
1179 /* Copy from malloc'd memory */
1180 /* XXX this should be re-examined/tested with a compressed format */
1181 GLuint blockSize
= util_format_get_blocksize(stObj
->pt
->format
);
1182 GLuint srcRowStride
= stImage
->base
.Width
* blockSize
;
1183 GLuint srcSliceStride
= stImage
->base
.Height
* srcRowStride
;
1184 st_texture_image_data(st
,
1191 _mesa_align_free(stImage
->TexData
);
1192 stImage
->TexData
= NULL
;
1195 pipe_resource_reference(&stImage
->pt
, stObj
->pt
);
1200 * Called during state validation. When this function is finished,
1201 * the texture object should be ready for rendering.
1202 * \return GL_TRUE for success, GL_FALSE for failure (out of mem)
1205 st_finalize_texture(struct gl_context
*ctx
,
1206 struct pipe_context
*pipe
,
1207 struct gl_texture_object
*tObj
)
1209 struct st_context
*st
= st_context(ctx
);
1210 struct st_texture_object
*stObj
= st_texture_object(tObj
);
1211 const GLuint nr_faces
= (stObj
->base
.Target
== GL_TEXTURE_CUBE_MAP
) ? 6 : 1;
1213 struct st_texture_image
*firstImage
;
1214 enum pipe_format firstImageFormat
;
1215 GLuint ptWidth
, ptHeight
, ptDepth
, ptLayers
;
1217 if (stObj
->base
._Complete
) {
1218 /* The texture is complete and we know exactly how many mipmap levels
1219 * are present/needed. This is conditional because we may be called
1220 * from the st_generate_mipmap() function when the texture object is
1221 * incomplete. In that case, we'll have set stObj->lastLevel before
1224 if (stObj
->base
.Sampler
.MinFilter
== GL_LINEAR
||
1225 stObj
->base
.Sampler
.MinFilter
== GL_NEAREST
)
1226 stObj
->lastLevel
= stObj
->base
.BaseLevel
;
1228 stObj
->lastLevel
= stObj
->base
._MaxLevel
;
1231 firstImage
= st_texture_image(stObj
->base
.Image
[0][stObj
->base
.BaseLevel
]);
1234 /* If both firstImage and stObj point to a texture which can contain
1235 * all active images, favour firstImage. Note that because of the
1236 * completeness requirement, we know that the image dimensions
1239 if (firstImage
->pt
&&
1240 firstImage
->pt
!= stObj
->pt
&&
1241 (!stObj
->pt
|| firstImage
->pt
->last_level
>= stObj
->pt
->last_level
)) {
1242 pipe_resource_reference(&stObj
->pt
, firstImage
->pt
);
1243 pipe_sampler_view_reference(&stObj
->sampler_view
, NULL
);
1246 /* Find gallium format for the Mesa texture */
1247 firstImageFormat
= st_mesa_format_to_pipe_format(firstImage
->base
.TexFormat
);
1249 /* Find size of level=0 Gallium mipmap image, plus number of texture layers */
1251 GLuint width
, height
, depth
;
1252 if (!guess_base_level_size(stObj
->base
.Target
,
1253 firstImage
->base
.Width2
,
1254 firstImage
->base
.Height2
,
1255 firstImage
->base
.Depth2
,
1256 firstImage
->base
.Level
,
1257 &width
, &height
, &depth
)) {
1258 width
= stObj
->width0
;
1259 height
= stObj
->height0
;
1260 depth
= stObj
->depth0
;
1262 /* convert GL dims to Gallium dims */
1263 st_gl_texture_dims_to_pipe_dims(stObj
->base
.Target
, width
, height
, depth
,
1264 &ptWidth
, &ptHeight
, &ptDepth
, &ptLayers
);
1267 /* If we already have a gallium texture, check that it matches the texture
1268 * object's format, target, size, num_levels, etc.
1271 if (stObj
->pt
->target
!= gl_target_to_pipe(stObj
->base
.Target
) ||
1272 !st_sampler_compat_formats(stObj
->pt
->format
, firstImageFormat
) ||
1273 stObj
->pt
->last_level
< stObj
->lastLevel
||
1274 stObj
->pt
->width0
!= ptWidth
||
1275 stObj
->pt
->height0
!= ptHeight
||
1276 stObj
->pt
->depth0
!= ptDepth
||
1277 stObj
->pt
->array_size
!= ptLayers
)
1279 /* The gallium texture does not match the Mesa texture so delete the
1280 * gallium texture now. We'll make a new one below.
1282 pipe_resource_reference(&stObj
->pt
, NULL
);
1283 pipe_sampler_view_reference(&stObj
->sampler_view
, NULL
);
1284 st
->dirty
.st
|= ST_NEW_FRAMEBUFFER
;
1288 /* May need to create a new gallium texture:
1291 GLuint bindings
= default_bindings(st
, firstImageFormat
);
1293 stObj
->pt
= st_texture_create(st
,
1294 gl_target_to_pipe(stObj
->base
.Target
),
1304 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexImage");
1309 /* Pull in any images not in the object's texture:
1311 for (face
= 0; face
< nr_faces
; face
++) {
1313 for (level
= stObj
->base
.BaseLevel
; level
<= stObj
->lastLevel
; level
++) {
1314 struct st_texture_image
*stImage
=
1315 st_texture_image(stObj
->base
.Image
[face
][level
]);
1317 /* Need to import images in main memory or held in other textures.
1319 if (stImage
&& stObj
->pt
!= stImage
->pt
) {
1321 (stImage
->base
.Width
== u_minify(stObj
->width0
, level
) &&
1322 stImage
->base
.Height
== u_minify(stObj
->height0
, level
) &&
1323 stImage
->base
.Depth
== u_minify(stObj
->depth0
, level
))) {
1324 /* src image fits expected dest mipmap level size */
1325 copy_image_data_to_texture(st
, stObj
, level
, stImage
);
1336 * Returns pointer to a default/dummy texture.
1337 * This is typically used when the current shader has tex/sample instructions
1338 * but the user has not provided a (any) texture(s).
1340 struct gl_texture_object
*
1341 st_get_default_texture(struct st_context
*st
)
1343 if (!st
->default_texture
) {
1344 static const GLenum target
= GL_TEXTURE_2D
;
1345 GLubyte pixels
[16][16][4];
1346 struct gl_texture_object
*texObj
;
1347 struct gl_texture_image
*texImg
;
1350 /* The ARB_fragment_program spec says (0,0,0,1) should be returned
1351 * when attempting to sample incomplete textures.
1353 for (i
= 0; i
< 16; i
++) {
1354 for (j
= 0; j
< 16; j
++) {
1355 pixels
[i
][j
][0] = 0;
1356 pixels
[i
][j
][1] = 0;
1357 pixels
[i
][j
][2] = 0;
1358 pixels
[i
][j
][3] = 255;
1362 texObj
= st
->ctx
->Driver
.NewTextureObject(st
->ctx
, 0, target
);
1364 texImg
= _mesa_get_tex_image(st
->ctx
, texObj
, target
, 0);
1366 _mesa_init_teximage_fields(st
->ctx
, texImg
,
1367 16, 16, 1, 0, /* w, h, d, border */
1368 GL_RGBA
, MESA_FORMAT_RGBA8888
);
1370 _mesa_store_teximage2d(st
->ctx
, texImg
,
1371 GL_RGBA
, /* level, intformat */
1372 16, 16, 1, /* w, h, d, border */
1373 GL_RGBA
, GL_UNSIGNED_BYTE
, pixels
,
1374 &st
->ctx
->DefaultPacking
);
1376 texObj
->Sampler
.MinFilter
= GL_NEAREST
;
1377 texObj
->Sampler
.MagFilter
= GL_NEAREST
;
1378 texObj
->_Complete
= GL_TRUE
;
1380 st
->default_texture
= texObj
;
1382 return st
->default_texture
;
1387 * Called via ctx->Driver.AllocTextureStorage() to allocate texture memory
1388 * for a whole mipmap stack.
1391 st_AllocTextureStorage(struct gl_context
*ctx
,
1392 struct gl_texture_object
*texObj
,
1393 GLsizei levels
, GLsizei width
,
1394 GLsizei height
, GLsizei depth
)
1396 const GLuint numFaces
= (texObj
->Target
== GL_TEXTURE_CUBE_MAP
) ? 6 : 1;
1397 struct st_context
*st
= st_context(ctx
);
1398 struct st_texture_object
*stObj
= st_texture_object(texObj
);
1399 GLuint ptWidth
, ptHeight
, ptDepth
, ptLayers
, bindings
;
1400 enum pipe_format fmt
;
1405 /* Save the level=0 dimensions */
1406 stObj
->width0
= width
;
1407 stObj
->height0
= height
;
1408 stObj
->depth0
= depth
;
1409 stObj
->lastLevel
= levels
- 1;
1411 fmt
= st_mesa_format_to_pipe_format(texObj
->Image
[0][0]->TexFormat
);
1413 bindings
= default_bindings(st
, fmt
);
1415 st_gl_texture_dims_to_pipe_dims(texObj
->Target
,
1416 width
, height
, depth
,
1417 &ptWidth
, &ptHeight
, &ptDepth
, &ptLayers
);
1419 stObj
->pt
= st_texture_create(st
,
1420 gl_target_to_pipe(texObj
->Target
),
1431 /* Set image resource pointers */
1432 for (level
= 0; level
< levels
; level
++) {
1434 for (face
= 0; face
< numFaces
; face
++) {
1435 struct st_texture_image
*stImage
=
1436 st_texture_image(texObj
->Image
[face
][level
]);
1437 pipe_resource_reference(&stImage
->pt
, stObj
->pt
);
1447 st_init_texture_functions(struct dd_function_table
*functions
)
1449 functions
->ChooseTextureFormat
= st_ChooseTextureFormat
;
1450 functions
->TexImage1D
= st_TexImage1D
;
1451 functions
->TexImage2D
= st_TexImage2D
;
1452 functions
->TexImage3D
= st_TexImage3D
;
1453 functions
->TexSubImage1D
= _mesa_store_texsubimage1d
;
1454 functions
->TexSubImage2D
= _mesa_store_texsubimage2d
;
1455 functions
->TexSubImage3D
= _mesa_store_texsubimage3d
;
1456 functions
->CompressedTexSubImage1D
= _mesa_store_compressed_texsubimage1d
;
1457 functions
->CompressedTexSubImage2D
= _mesa_store_compressed_texsubimage2d
;
1458 functions
->CompressedTexSubImage3D
= _mesa_store_compressed_texsubimage3d
;
1459 functions
->CopyTexSubImage1D
= st_CopyTexSubImage1D
;
1460 functions
->CopyTexSubImage2D
= st_CopyTexSubImage2D
;
1461 functions
->CopyTexSubImage3D
= st_CopyTexSubImage3D
;
1462 functions
->GenerateMipmap
= st_generate_mipmap
;
1464 functions
->GetTexImage
= st_GetTexImage
;
1466 /* compressed texture functions */
1467 functions
->CompressedTexImage2D
= st_CompressedTexImage2D
;
1468 functions
->GetCompressedTexImage
= _mesa_get_compressed_teximage
;
1470 functions
->NewTextureObject
= st_NewTextureObject
;
1471 functions
->NewTextureImage
= st_NewTextureImage
;
1472 functions
->DeleteTextureImage
= st_DeleteTextureImage
;
1473 functions
->DeleteTexture
= st_DeleteTextureObject
;
1474 functions
->AllocTextureImageBuffer
= st_AllocTextureImageBuffer
;
1475 functions
->FreeTextureImageBuffer
= st_FreeTextureImageBuffer
;
1476 functions
->MapTextureImage
= st_MapTextureImage
;
1477 functions
->UnmapTextureImage
= st_UnmapTextureImage
;
1479 /* XXX Temporary until we can query pipe's texture sizes */
1480 functions
->TestProxyTexImage
= _mesa_test_proxy_teximage
;
1482 functions
->AllocTextureStorage
= st_AllocTextureStorage
;