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
, struct gl_texture_image
*texImage
)
158 struct st_texture_image
*stImage
= st_texture_image(texImage
);
160 DBG("%s\n", __FUNCTION__
);
163 pipe_resource_reference(&stImage
->pt
, NULL
);
166 if (stImage
->TexData
) {
167 _mesa_align_free(stImage
->TexData
);
168 stImage
->TexData
= NULL
;
173 /** called via ctx->Driver.MapTextureImage() */
175 st_MapTextureImage(struct gl_context
*ctx
,
176 struct gl_texture_image
*texImage
,
177 GLuint slice
, GLuint x
, GLuint y
, GLuint w
, GLuint h
,
179 GLubyte
**mapOut
, GLint
*rowStrideOut
)
181 struct st_context
*st
= st_context(ctx
);
182 struct st_texture_image
*stImage
= st_texture_image(texImage
);
187 if (mode
& GL_MAP_READ_BIT
)
188 pipeMode
|= PIPE_TRANSFER_READ
;
189 if (mode
& GL_MAP_WRITE_BIT
)
190 pipeMode
|= PIPE_TRANSFER_WRITE
;
192 map
= st_texture_image_map(st
, stImage
, slice
, pipeMode
, x
, y
, w
, h
);
195 *rowStrideOut
= stImage
->transfer
->stride
;
204 /** called via ctx->Driver.UnmapTextureImage() */
206 st_UnmapTextureImage(struct gl_context
*ctx
,
207 struct gl_texture_image
*texImage
,
210 struct st_context
*st
= st_context(ctx
);
211 struct st_texture_image
*stImage
= st_texture_image(texImage
);
212 st_texture_image_unmap(st
, stImage
);
217 * Return default texture resource binding bitmask for the given format.
220 default_bindings(struct st_context
*st
, enum pipe_format format
)
222 struct pipe_screen
*screen
= st
->pipe
->screen
;
223 const unsigned target
= PIPE_TEXTURE_2D
;
226 if (util_format_is_depth_or_stencil(format
))
227 bindings
= PIPE_BIND_SAMPLER_VIEW
| PIPE_BIND_DEPTH_STENCIL
;
229 bindings
= PIPE_BIND_SAMPLER_VIEW
| PIPE_BIND_RENDER_TARGET
;
231 if (screen
->is_format_supported(screen
, format
, target
, 0, bindings
))
235 format
= util_format_linear(format
);
237 if (screen
->is_format_supported(screen
, format
, target
, 0, bindings
))
240 return PIPE_BIND_SAMPLER_VIEW
;
245 /** Return number of image dimensions (1, 2 or 3) for a texture target. */
247 get_texture_dims(GLenum target
)
251 case GL_TEXTURE_1D_ARRAY_EXT
:
252 case GL_TEXTURE_BUFFER
:
255 case GL_TEXTURE_CUBE_MAP_ARB
:
256 case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB
:
257 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB
:
258 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB
:
259 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB
:
260 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB
:
261 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB
:
262 case GL_TEXTURE_RECTANGLE_NV
:
263 case GL_TEXTURE_2D_ARRAY_EXT
:
264 case GL_TEXTURE_EXTERNAL_OES
:
269 assert(0 && "invalid texture target in get_texture_dims()");
276 * Given the size of a mipmap image, try to compute the size of the level=0
279 * Note that this isn't always accurate for odd-sized, non-POW textures.
280 * For example, if level=1 and width=40 then the level=0 width may be 80 or 81.
282 * \return GL_TRUE for success, GL_FALSE for failure
285 guess_base_level_size(GLenum target
,
286 GLuint width
, GLuint height
, GLuint depth
, GLuint level
,
287 GLuint
*width0
, GLuint
*height0
, GLuint
*depth0
)
289 const GLuint dims
= get_texture_dims(target
);
296 /* Depending on the image's size, we can't always make a guess here */
297 if ((dims
>= 1 && width
== 1) ||
298 (dims
>= 2 && height
== 1) ||
299 (dims
>= 3 && depth
== 1)) {
300 /* we can't determine the image size at level=0 */
304 /* grow the image size until we hit level = 0 */
325 * Try to allocate a pipe_resource object for the given st_texture_object.
327 * We use the given st_texture_image as a clue to determine the size of the
328 * mipmap image at level=0.
330 * \return GL_TRUE for success, GL_FALSE if out of memory.
333 guess_and_alloc_texture(struct st_context
*st
,
334 struct st_texture_object
*stObj
,
335 const struct st_texture_image
*stImage
)
337 GLuint lastLevel
, width
, height
, depth
;
339 GLuint ptWidth
, ptHeight
, ptDepth
, ptLayers
;
340 enum pipe_format fmt
;
342 DBG("%s\n", __FUNCTION__
);
346 if (!guess_base_level_size(stObj
->base
.Target
,
347 stImage
->base
.Width2
,
348 stImage
->base
.Height2
,
349 stImage
->base
.Depth2
,
351 &width
, &height
, &depth
)) {
352 /* we can't determine the image size at level=0 */
353 stObj
->width0
= stObj
->height0
= stObj
->depth0
= 0;
354 /* this is not an out of memory error */
358 /* At this point, (width x height x depth) is the expected size of
359 * the level=0 mipmap image.
362 /* Guess a reasonable value for lastLevel. With OpenGL we have no
363 * idea how many mipmap levels will be in a texture until we start
364 * to render with it. Make an educated guess here but be prepared
365 * to re-allocating a texture buffer with space for more (or fewer)
366 * mipmap levels later.
368 if ((stObj
->base
.Sampler
.MinFilter
== GL_NEAREST
||
369 stObj
->base
.Sampler
.MinFilter
== GL_LINEAR
||
370 stImage
->base
._BaseFormat
== GL_DEPTH_COMPONENT
||
371 stImage
->base
._BaseFormat
== GL_DEPTH_STENCIL_EXT
) &&
372 !stObj
->base
.GenerateMipmap
&&
373 stImage
->base
.Level
== 0) {
374 /* only alloc space for a single mipmap level */
378 /* alloc space for a full mipmap */
379 GLuint l2width
= util_logbase2(width
);
380 GLuint l2height
= util_logbase2(height
);
381 GLuint l2depth
= util_logbase2(depth
);
382 lastLevel
= MAX2(MAX2(l2width
, l2height
), l2depth
);
385 /* Save the level=0 dimensions */
386 stObj
->width0
= width
;
387 stObj
->height0
= height
;
388 stObj
->depth0
= depth
;
390 fmt
= st_mesa_format_to_pipe_format(stImage
->base
.TexFormat
);
392 bindings
= default_bindings(st
, fmt
);
394 st_gl_texture_dims_to_pipe_dims(stObj
->base
.Target
,
395 width
, height
, depth
,
396 &ptWidth
, &ptHeight
, &ptDepth
, &ptLayers
);
398 stObj
->pt
= st_texture_create(st
,
399 gl_target_to_pipe(stObj
->base
.Target
),
408 DBG("%s returning %d\n", __FUNCTION__
, (stObj
->pt
!= NULL
));
410 return stObj
->pt
!= NULL
;
415 * Called via ctx->Driver.AllocTextureImageBuffer().
416 * If the texture object/buffer already has space for the indicated image,
417 * we're done. Otherwise, allocate memory for the new texture image.
420 st_AllocTextureImageBuffer(struct gl_context
*ctx
,
421 struct gl_texture_image
*texImage
,
422 gl_format format
, GLsizei width
,
423 GLsizei height
, GLsizei depth
)
425 struct st_context
*st
= st_context(ctx
);
426 struct st_texture_image
*stImage
= st_texture_image(texImage
);
427 struct st_texture_object
*stObj
= st_texture_object(texImage
->TexObject
);
428 const GLuint level
= texImage
->Level
;
430 DBG("%s\n", __FUNCTION__
);
435 assert(!stImage
->TexData
);
436 assert(!stImage
->pt
); /* xxx this might be wrong */
438 /* Look if the parent texture object has space for this image */
440 level
<= stObj
->pt
->last_level
&&
441 st_texture_match_image(stObj
->pt
, texImage
)) {
442 /* this image will fit in the existing texture object's memory */
443 pipe_resource_reference(&stImage
->pt
, stObj
->pt
);
447 /* The parent texture object does not have space for this image */
449 pipe_resource_reference(&stObj
->pt
, NULL
);
450 pipe_sampler_view_reference(&stObj
->sampler_view
, NULL
);
452 if (!guess_and_alloc_texture(st
, stObj
, stImage
)) {
453 /* Probably out of memory.
454 * Try flushing any pending rendering, then retry.
457 if (!guess_and_alloc_texture(st
, stObj
, stImage
)) {
458 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexImage");
464 st_texture_match_image(stObj
->pt
, texImage
)) {
465 /* The image will live in the object's mipmap memory */
466 pipe_resource_reference(&stImage
->pt
, stObj
->pt
);
471 /* Create a new, temporary texture/resource/buffer to hold this
472 * one texture image. Note that when we later access this image
473 * (either for mapping or copying) we'll want to always specify
474 * mipmap level=0, even if the image represents some other mipmap
477 enum pipe_format format
=
478 st_mesa_format_to_pipe_format(texImage
->TexFormat
);
479 GLuint bindings
= default_bindings(st
, format
);
480 GLuint ptWidth
, ptHeight
, ptDepth
, ptLayers
;
482 st_gl_texture_dims_to_pipe_dims(stObj
->base
.Target
,
483 width
, height
, depth
,
484 &ptWidth
, &ptHeight
, &ptDepth
, &ptLayers
);
486 stImage
->pt
= st_texture_create(st
,
487 gl_target_to_pipe(stObj
->base
.Target
),
495 return stImage
->pt
!= NULL
;
501 * Preparation prior to glTexImage. Basically check the 'surface_based'
502 * field and switch to a "normal" tex image if necessary.
505 prep_teximage(struct gl_context
*ctx
, struct gl_texture_image
*texImage
,
506 GLint internalFormat
,
507 GLint width
, GLint height
, GLint depth
, GLint border
,
508 GLenum format
, GLenum type
)
510 struct gl_texture_object
*texObj
= texImage
->TexObject
;
511 struct st_texture_object
*stObj
= st_texture_object(texObj
);
513 /* switch to "normal" */
514 if (stObj
->surface_based
) {
515 const GLenum target
= texObj
->Target
;
516 const GLuint level
= texImage
->Level
;
519 _mesa_clear_texture_object(ctx
, texObj
);
520 pipe_resource_reference(&stObj
->pt
, NULL
);
522 /* oops, need to init this image again */
523 texFormat
= _mesa_choose_texture_format(ctx
, texObj
, target
, level
,
524 internalFormat
, format
, type
);
526 _mesa_init_teximage_fields(ctx
, texImage
,
527 width
, height
, depth
, border
,
528 internalFormat
, texFormat
);
530 stObj
->surface_based
= GL_FALSE
;
536 st_TexImage3D(struct gl_context
* ctx
,
537 struct gl_texture_image
*texImage
,
538 GLint internalFormat
,
539 GLint width
, GLint height
, GLint depth
,
541 GLenum format
, GLenum type
, const void *pixels
,
542 const struct gl_pixelstore_attrib
*unpack
)
544 prep_teximage(ctx
, texImage
, internalFormat
, width
, height
, depth
, border
,
546 _mesa_store_teximage3d(ctx
, texImage
, internalFormat
, width
, height
, depth
,
547 border
, format
, type
, pixels
, unpack
);
552 st_TexImage2D(struct gl_context
* ctx
,
553 struct gl_texture_image
*texImage
,
554 GLint internalFormat
,
555 GLint width
, GLint height
, GLint border
,
556 GLenum format
, GLenum type
, const void *pixels
,
557 const struct gl_pixelstore_attrib
*unpack
)
559 prep_teximage(ctx
, texImage
, internalFormat
, width
, height
, 1, border
,
561 _mesa_store_teximage2d(ctx
, texImage
, internalFormat
, width
, height
,
562 border
, format
, type
, pixels
, unpack
);
567 st_TexImage1D(struct gl_context
* ctx
,
568 struct gl_texture_image
*texImage
,
569 GLint internalFormat
,
570 GLint width
, GLint border
,
571 GLenum format
, GLenum type
, const void *pixels
,
572 const struct gl_pixelstore_attrib
*unpack
)
574 prep_teximage(ctx
, texImage
, internalFormat
, width
, 1, 1, border
,
576 _mesa_store_teximage1d(ctx
, texImage
, internalFormat
, width
,
577 border
, format
, type
, pixels
, unpack
);
582 st_CompressedTexImage2D(struct gl_context
*ctx
,
583 struct gl_texture_image
*texImage
,
584 GLint internalFormat
,
585 GLint width
, GLint height
, GLint border
,
586 GLsizei imageSize
, const GLvoid
*data
)
588 prep_teximage(ctx
, texImage
, internalFormat
, width
, 1, 1, border
,
590 _mesa_store_compressed_teximage2d(ctx
, texImage
, internalFormat
, width
,
591 height
, border
, imageSize
, data
);
597 * glGetTexImage() helper: decompress a compressed texture by rendering
598 * a textured quad. Store the results in the user's buffer.
601 decompress_with_blit(struct gl_context
* ctx
,
602 GLenum format
, GLenum type
, GLvoid
*pixels
,
603 struct gl_texture_image
*texImage
)
605 struct st_context
*st
= st_context(ctx
);
606 struct pipe_context
*pipe
= st
->pipe
;
607 struct st_texture_image
*stImage
= st_texture_image(texImage
);
608 struct st_texture_object
*stObj
= st_texture_object(texImage
->TexObject
);
609 struct pipe_sampler_view
*src_view
=
610 st_get_texture_sampler_view(stObj
, pipe
);
611 const GLuint width
= texImage
->Width
;
612 const GLuint height
= texImage
->Height
;
613 struct pipe_surface
*dst_surface
;
614 struct pipe_resource
*dst_texture
;
615 struct pipe_transfer
*tex_xfer
;
616 unsigned bind
= (PIPE_BIND_RENDER_TARGET
| /* util_blit may choose to render */
617 PIPE_BIND_TRANSFER_READ
);
619 /* create temp / dest surface */
620 if (!util_create_rgba_surface(pipe
, width
, height
, bind
,
621 &dst_texture
, &dst_surface
)) {
622 _mesa_problem(ctx
, "util_create_rgba_surface() failed "
623 "in decompress_with_blit()");
627 /* Disable conditional rendering. */
628 if (st
->render_condition
) {
629 pipe
->render_condition(pipe
, NULL
, 0);
632 /* Choose the source mipmap level */
633 src_view
->u
.tex
.first_level
= src_view
->u
.tex
.last_level
= texImage
->Level
;
635 /* blit/render/decompress */
636 util_blit_pixels_tex(st
->blit
,
637 src_view
, /* pipe_resource (src) */
638 0, 0, /* src x0, y0 */
639 width
, height
, /* src x1, y1 */
640 dst_surface
, /* pipe_surface (dst) */
641 0, 0, /* dst x0, y0 */
642 width
, height
, /* dst x1, y1 */
644 PIPE_TEX_MIPFILTER_NEAREST
);
646 /* Restore conditional rendering state. */
647 if (st
->render_condition
) {
648 pipe
->render_condition(pipe
, st
->render_condition
,
652 /* map the dst_surface so we can read from it */
653 tex_xfer
= pipe_get_transfer(pipe
,
656 0, 0, width
, height
);
658 pixels
= _mesa_map_pbo_dest(ctx
, &ctx
->Pack
, pixels
);
660 /* copy/pack data into user buffer */
661 if (st_equal_formats(stImage
->pt
->format
, format
, type
)) {
663 const uint bytesPerRow
= width
* util_format_get_blocksize(stImage
->pt
->format
);
664 ubyte
*map
= pipe_transfer_map(pipe
, tex_xfer
);
666 for (row
= 0; row
< height
; row
++) {
667 GLvoid
*dest
= _mesa_image_address2d(&ctx
->Pack
, pixels
, width
,
668 height
, format
, type
, row
, 0);
669 memcpy(dest
, map
, bytesPerRow
);
670 map
+= tex_xfer
->stride
;
672 pipe_transfer_unmap(pipe
, tex_xfer
);
675 /* format translation via floats */
677 enum pipe_format pformat
= util_format_linear(dst_texture
->format
);
678 for (row
= 0; row
< height
; row
++) {
679 const GLbitfield transferOps
= 0x0; /* bypassed for glGetTexImage() */
680 GLfloat rgba
[4 * MAX_WIDTH
];
681 GLvoid
*dest
= _mesa_image_address2d(&ctx
->Pack
, pixels
, width
,
682 height
, format
, type
, row
, 0);
684 if (ST_DEBUG
& DEBUG_FALLBACK
)
685 debug_printf("%s: fallback format translation\n", __FUNCTION__
);
687 /* get float[4] rgba row from surface */
688 pipe_get_tile_rgba_format(pipe
, tex_xfer
, 0, row
, width
, 1,
691 _mesa_pack_rgba_span_float(ctx
, width
, (GLfloat (*)[4]) rgba
, format
,
692 type
, dest
, &ctx
->Pack
, transferOps
);
696 _mesa_unmap_pbo_dest(ctx
, &ctx
->Pack
);
698 pipe
->transfer_destroy(pipe
, tex_xfer
);
700 /* destroy the temp / dest surface */
701 util_destroy_rgba_surface(dst_texture
, dst_surface
);
707 * Called via ctx->Driver.GetTexImage()
710 st_GetTexImage(struct gl_context
* ctx
,
711 GLenum format
, GLenum type
, GLvoid
* pixels
,
712 struct gl_texture_image
*texImage
)
714 struct st_texture_image
*stImage
= st_texture_image(texImage
);
716 if (stImage
->pt
&& util_format_is_s3tc(stImage
->pt
->format
)) {
717 /* Need to decompress the texture.
718 * We'll do this by rendering a textured quad (which is hopefully
719 * faster than using the fallback code in texcompress.c).
720 * Note that we only expect RGBA formats (no Z/depth formats).
722 decompress_with_blit(ctx
, format
, type
, pixels
, texImage
);
725 _mesa_get_teximage(ctx
, format
, type
, pixels
, texImage
);
731 * Do a CopyTexSubImage operation using a read transfer from the source,
732 * a write transfer to the destination and get_tile()/put_tile() to access
735 * Note: srcY=0=TOP of renderbuffer
738 fallback_copy_texsubimage(struct gl_context
*ctx
, GLenum target
, GLint level
,
739 struct st_renderbuffer
*strb
,
740 struct st_texture_image
*stImage
,
742 GLint destX
, GLint destY
, GLint destZ
,
743 GLint srcX
, GLint srcY
,
744 GLsizei width
, GLsizei height
)
746 struct st_context
*st
= st_context(ctx
);
747 struct pipe_context
*pipe
= st
->pipe
;
748 struct pipe_transfer
*src_trans
;
750 enum pipe_transfer_usage transfer_usage
;
752 if (ST_DEBUG
& DEBUG_FALLBACK
)
753 debug_printf("%s: fallback processing\n", __FUNCTION__
);
755 assert(width
<= MAX_WIDTH
);
757 if (st_fb_orientation(ctx
->ReadBuffer
) == Y_0_TOP
) {
758 srcY
= strb
->Base
.Height
- srcY
- height
;
761 src_trans
= pipe_get_transfer(pipe
,
764 strb
->rtt_face
+ strb
->rtt_slice
,
769 if ((baseFormat
== GL_DEPTH_COMPONENT
||
770 baseFormat
== GL_DEPTH_STENCIL
) &&
771 util_format_is_depth_and_stencil(stImage
->pt
->format
))
772 transfer_usage
= PIPE_TRANSFER_READ_WRITE
;
774 transfer_usage
= PIPE_TRANSFER_WRITE
;
776 /* XXX this used to ignore destZ param */
777 texDest
= st_texture_image_map(st
, stImage
, destZ
, transfer_usage
,
778 destX
, destY
, width
, height
);
780 if (baseFormat
== GL_DEPTH_COMPONENT
||
781 baseFormat
== GL_DEPTH_STENCIL
) {
782 const GLboolean scaleOrBias
= (ctx
->Pixel
.DepthScale
!= 1.0F
||
783 ctx
->Pixel
.DepthBias
!= 0.0F
);
786 /* determine bottom-to-top vs. top-to-bottom order for src buffer */
787 if (st_fb_orientation(ctx
->ReadBuffer
) == Y_0_TOP
) {
796 /* To avoid a large temp memory allocation, do copy row by row */
797 for (row
= 0; row
< height
; row
++, srcY
+= yStep
) {
798 uint data
[MAX_WIDTH
];
799 pipe_get_tile_z(pipe
, src_trans
, 0, srcY
, width
, 1, data
);
801 _mesa_scale_and_bias_depth_uint(ctx
, width
, data
);
803 pipe_put_tile_z(pipe
, stImage
->transfer
, 0, row
, width
, 1, data
);
809 (GLfloat
*) malloc(width
* height
* 4 * sizeof(GLfloat
));
811 if (tempSrc
&& texDest
) {
812 const GLint dims
= 2;
813 const GLint dstRowStride
= stImage
->transfer
->stride
;
814 struct gl_texture_image
*texImage
= &stImage
->base
;
815 struct gl_pixelstore_attrib unpack
= ctx
->DefaultPacking
;
817 if (st_fb_orientation(ctx
->ReadBuffer
) == Y_0_TOP
) {
818 unpack
.Invert
= GL_TRUE
;
821 /* get float/RGBA image from framebuffer */
822 /* XXX this usually involves a lot of int/float conversion.
823 * try to avoid that someday.
825 pipe_get_tile_rgba_format(pipe
, src_trans
, 0, 0, width
, height
,
826 util_format_linear(strb
->texture
->format
),
829 /* Store into texture memory.
830 * Note that this does some special things such as pixel transfer
831 * ops and format conversion. In particular, if the dest tex format
832 * is actually RGBA but the user created the texture as GL_RGB we
833 * need to fill-in/override the alpha channel with 1.0.
835 _mesa_texstore(ctx
, dims
,
836 texImage
->_BaseFormat
,
839 (GLubyte
**) &texDest
,
841 GL_RGBA
, GL_FLOAT
, tempSrc
, /* src */
845 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexSubImage");
852 st_texture_image_unmap(st
, stImage
);
853 pipe
->transfer_destroy(pipe
, src_trans
);
859 * If the format of the src renderbuffer and the format of the dest
860 * texture are compatible (in terms of blitting), return a TGSI writemask
861 * to be used during the blit.
862 * If the src/dest are incompatible, return 0.
865 compatible_src_dst_formats(struct gl_context
*ctx
,
866 const struct gl_renderbuffer
*src
,
867 const struct gl_texture_image
*dst
)
869 /* Get logical base formats for the src and dest.
870 * That is, use the user-requested formats and not the actual, device-
872 * For example, the user may have requested an A8 texture but the
873 * driver may actually be using an RGBA texture format. When we
874 * copy/blit to that texture, we only want to copy the Alpha channel
875 * and not the RGB channels.
877 * Similarly, when the src FBO was created an RGB format may have been
878 * requested but the driver actually chose an RGBA format. In that case,
879 * we don't want to copy the undefined Alpha channel to the dest texture
880 * (it should be 1.0).
882 const GLenum srcFormat
= _mesa_base_fbo_format(ctx
, src
->InternalFormat
);
883 const GLenum dstFormat
= _mesa_base_tex_format(ctx
, dst
->InternalFormat
);
886 * XXX when we have red-only and red/green renderbuffers we'll need
887 * to add more cases here (or implement a general-purpose routine that
888 * queries the existance of the R,G,B,A channels in the src and dest).
890 if (srcFormat
== dstFormat
) {
891 /* This is the same as matching_base_formats, which should
892 * always pass, as it did previously.
894 return TGSI_WRITEMASK_XYZW
;
896 else if (srcFormat
== GL_RGB
&& dstFormat
== GL_RGBA
) {
897 /* Make sure that A in the dest is 1. The actual src format
898 * may be RGBA and have undefined A values.
900 return TGSI_WRITEMASK_XYZ
;
902 else if (srcFormat
== GL_RGBA
&& dstFormat
== GL_RGB
) {
903 /* Make sure that A in the dest is 1. The actual dst format
904 * may be RGBA and will need A=1 to provide proper alpha values
905 * when sampled later.
907 return TGSI_WRITEMASK_XYZ
;
910 if (ST_DEBUG
& DEBUG_FALLBACK
)
911 debug_printf("%s failed for src %s, dst %s\n",
913 _mesa_lookup_enum_by_nr(srcFormat
),
914 _mesa_lookup_enum_by_nr(dstFormat
));
925 * Do a CopyTex[Sub]Image1/2/3D() using a hardware (blit) path if possible.
926 * Note that the region to copy has already been clipped so we know we
927 * won't read from outside the source renderbuffer's bounds.
929 * Note: srcY=0=Bottom of renderbuffer (GL convention)
932 st_copy_texsubimage(struct gl_context
*ctx
,
933 GLenum target
, GLint level
,
934 GLint destX
, GLint destY
, GLint destZ
,
935 GLint srcX
, GLint srcY
,
936 GLsizei width
, GLsizei height
)
938 struct gl_texture_unit
*texUnit
=
939 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
940 struct gl_texture_object
*texObj
=
941 _mesa_select_tex_object(ctx
, texUnit
, target
);
942 struct gl_texture_image
*texImage
=
943 _mesa_select_tex_image(ctx
, texObj
, target
, level
);
944 struct st_texture_image
*stImage
= st_texture_image(texImage
);
945 const GLenum texBaseFormat
= texImage
->_BaseFormat
;
946 struct gl_framebuffer
*fb
= ctx
->ReadBuffer
;
947 struct st_renderbuffer
*strb
;
948 struct st_context
*st
= st_context(ctx
);
949 struct pipe_context
*pipe
= st
->pipe
;
950 struct pipe_screen
*screen
= pipe
->screen
;
951 enum pipe_format dest_format
, src_format
;
952 GLboolean matching_base_formats
;
953 GLuint format_writemask
, sample_count
;
954 struct pipe_surface
*dest_surface
= NULL
;
955 GLboolean do_flip
= (st_fb_orientation(ctx
->ReadBuffer
) == Y_0_TOP
);
956 struct pipe_surface surf_tmpl
;
957 unsigned int dst_usage
;
960 /* make sure finalize_textures has been called?
962 if (0) st_validate_state(st
);
964 /* determine if copying depth or color data */
965 if (texBaseFormat
== GL_DEPTH_COMPONENT
||
966 texBaseFormat
== GL_DEPTH_STENCIL
) {
967 strb
= st_renderbuffer(fb
->Attachment
[BUFFER_DEPTH
].Renderbuffer
);
970 /* texBaseFormat == GL_RGB, GL_RGBA, GL_ALPHA, etc */
971 strb
= st_renderbuffer(fb
->_ColorReadBuffer
);
974 if (!strb
|| !strb
->surface
|| !stImage
->pt
) {
975 debug_printf("%s: null strb or stImage\n", __FUNCTION__
);
979 sample_count
= strb
->surface
->texture
->nr_samples
;
980 /* I believe this would be legal, presumably would need to do a resolve
981 for color, and for depth/stencil spec says to just use one of the
982 depth/stencil samples per pixel? Need some transfer clarifications. */
983 assert(sample_count
< 2);
986 assert(strb
->surface
);
989 src_format
= strb
->surface
->format
;
990 dest_format
= stImage
->pt
->format
;
993 * Determine if the src framebuffer and dest texture have the same
994 * base format. We need this to detect a case such as the framebuffer
995 * being GL_RGBA but the texture being GL_RGB. If the actual hardware
996 * texture format stores RGBA we need to set A=1 (overriding the
997 * framebuffer's alpha values). We can't do that with the blit or
998 * textured-quad paths.
1000 matching_base_formats
=
1001 (_mesa_get_format_base_format(strb
->Base
.Format
) ==
1002 _mesa_get_format_base_format(texImage
->TexFormat
));
1004 if (ctx
->_ImageTransferState
) {
1008 if (matching_base_formats
&&
1009 src_format
== dest_format
&&
1011 /* use surface_copy() / blit */
1012 struct pipe_box src_box
;
1013 u_box_2d_zslice(srcX
, srcY
, strb
->surface
->u
.tex
.first_layer
,
1014 width
, height
, &src_box
);
1016 /* for resource_copy_region(), y=0=top, always */
1017 pipe
->resource_copy_region(pipe
,
1020 stImage
->base
.Level
,
1021 destX
, destY
, destZ
+ stImage
->base
.Face
,
1024 strb
->surface
->u
.tex
.level
,
1029 if (texBaseFormat
== GL_DEPTH_STENCIL
) {
1033 if (texBaseFormat
== GL_DEPTH_COMPONENT
) {
1034 format_writemask
= TGSI_WRITEMASK_XYZW
;
1035 dst_usage
= PIPE_BIND_DEPTH_STENCIL
;
1038 format_writemask
= compatible_src_dst_formats(ctx
, &strb
->Base
, texImage
);
1039 dst_usage
= PIPE_BIND_RENDER_TARGET
;
1042 if (!format_writemask
||
1043 !screen
->is_format_supported(screen
, src_format
,
1044 PIPE_TEXTURE_2D
, sample_count
,
1045 PIPE_BIND_SAMPLER_VIEW
) ||
1046 !screen
->is_format_supported(screen
, dest_format
,
1053 srcY1
= strb
->Base
.Height
- srcY
- height
;
1054 srcY0
= srcY1
+ height
;
1058 srcY1
= srcY0
+ height
;
1061 /* Disable conditional rendering. */
1062 if (st
->render_condition
) {
1063 pipe
->render_condition(pipe
, NULL
, 0);
1066 memset(&surf_tmpl
, 0, sizeof(surf_tmpl
));
1067 surf_tmpl
.format
= util_format_linear(stImage
->pt
->format
);
1068 surf_tmpl
.usage
= dst_usage
;
1069 surf_tmpl
.u
.tex
.level
= stImage
->base
.Level
;
1070 surf_tmpl
.u
.tex
.first_layer
= stImage
->base
.Face
+ destZ
;
1071 surf_tmpl
.u
.tex
.last_layer
= stImage
->base
.Face
+ destZ
;
1073 dest_surface
= pipe
->create_surface(pipe
, stImage
->pt
,
1075 util_blit_pixels_writemask(st
->blit
,
1077 strb
->surface
->u
.tex
.level
,
1079 srcX
+ width
, srcY1
,
1080 strb
->surface
->u
.tex
.first_layer
,
1083 destX
+ width
, destY
+ height
,
1084 0.0, PIPE_TEX_MIPFILTER_NEAREST
,
1086 pipe_surface_reference(&dest_surface
, NULL
);
1088 /* Restore conditional rendering state. */
1089 if (st
->render_condition
) {
1090 pipe
->render_condition(pipe
, st
->render_condition
,
1091 st
->condition_mode
);
1097 /* software fallback */
1098 fallback_copy_texsubimage(ctx
, target
, level
,
1099 strb
, stImage
, texBaseFormat
,
1100 destX
, destY
, destZ
,
1101 srcX
, srcY
, width
, height
);
1107 st_CopyTexSubImage1D(struct gl_context
* ctx
, GLenum target
, GLint level
,
1108 GLint xoffset
, GLint x
, GLint y
, GLsizei width
)
1110 const GLint yoffset
= 0, zoffset
= 0;
1111 const GLsizei height
= 1;
1112 st_copy_texsubimage(ctx
, target
, level
,
1113 xoffset
, yoffset
, zoffset
, /* destX,Y,Z */
1114 x
, y
, width
, height
); /* src X, Y, size */
1119 st_CopyTexSubImage2D(struct gl_context
* ctx
, GLenum target
, GLint level
,
1120 GLint xoffset
, GLint yoffset
,
1121 GLint x
, GLint y
, GLsizei width
, GLsizei height
)
1123 const GLint zoffset
= 0;
1124 st_copy_texsubimage(ctx
, target
, level
,
1125 xoffset
, yoffset
, zoffset
, /* destX,Y,Z */
1126 x
, y
, width
, height
); /* src X, Y, size */
1131 st_CopyTexSubImage3D(struct gl_context
* ctx
, GLenum target
, GLint level
,
1132 GLint xoffset
, GLint yoffset
, GLint zoffset
,
1133 GLint x
, GLint y
, GLsizei width
, GLsizei height
)
1135 st_copy_texsubimage(ctx
, target
, level
,
1136 xoffset
, yoffset
, zoffset
, /* destX,Y,Z */
1137 x
, y
, width
, height
); /* src X, Y, size */
1142 * Copy image data from stImage into the texture object 'stObj' at level
1146 copy_image_data_to_texture(struct st_context
*st
,
1147 struct st_texture_object
*stObj
,
1149 struct st_texture_image
*stImage
)
1153 const struct gl_texture_image
*dstImage
=
1154 stObj
->base
.Image
[stImage
->base
.Face
][dstLevel
];
1156 assert(dstImage
->Width
== stImage
->base
.Width
);
1157 assert(dstImage
->Height
== stImage
->base
.Height
);
1158 assert(dstImage
->Depth
== stImage
->base
.Depth
);
1162 /* Copy potentially with the blitter:
1165 if (stImage
->pt
!= stObj
->pt
)
1168 src_level
= stImage
->base
.Level
;
1170 st_texture_image_copy(st
->pipe
,
1171 stObj
->pt
, dstLevel
, /* dest texture, level */
1172 stImage
->pt
, src_level
, /* src texture, level */
1173 stImage
->base
.Face
);
1175 pipe_resource_reference(&stImage
->pt
, NULL
);
1177 else if (stImage
->TexData
) {
1178 /* Copy from malloc'd memory */
1179 /* XXX this should be re-examined/tested with a compressed format */
1180 GLuint blockSize
= util_format_get_blocksize(stObj
->pt
->format
);
1181 GLuint srcRowStride
= stImage
->base
.Width
* blockSize
;
1182 GLuint srcSliceStride
= stImage
->base
.Height
* srcRowStride
;
1183 st_texture_image_data(st
,
1190 _mesa_align_free(stImage
->TexData
);
1191 stImage
->TexData
= NULL
;
1194 pipe_resource_reference(&stImage
->pt
, stObj
->pt
);
1199 * Called during state validation. When this function is finished,
1200 * the texture object should be ready for rendering.
1201 * \return GL_TRUE for success, GL_FALSE for failure (out of mem)
1204 st_finalize_texture(struct gl_context
*ctx
,
1205 struct pipe_context
*pipe
,
1206 struct gl_texture_object
*tObj
)
1208 struct st_context
*st
= st_context(ctx
);
1209 struct st_texture_object
*stObj
= st_texture_object(tObj
);
1210 const GLuint nr_faces
= (stObj
->base
.Target
== GL_TEXTURE_CUBE_MAP
) ? 6 : 1;
1212 struct st_texture_image
*firstImage
;
1213 enum pipe_format firstImageFormat
;
1214 GLuint ptWidth
, ptHeight
, ptDepth
, ptLayers
;
1216 if (stObj
->base
._Complete
) {
1217 /* The texture is complete and we know exactly how many mipmap levels
1218 * are present/needed. This is conditional because we may be called
1219 * from the st_generate_mipmap() function when the texture object is
1220 * incomplete. In that case, we'll have set stObj->lastLevel before
1223 if (stObj
->base
.Sampler
.MinFilter
== GL_LINEAR
||
1224 stObj
->base
.Sampler
.MinFilter
== GL_NEAREST
)
1225 stObj
->lastLevel
= stObj
->base
.BaseLevel
;
1227 stObj
->lastLevel
= stObj
->base
._MaxLevel
;
1230 firstImage
= st_texture_image(stObj
->base
.Image
[0][stObj
->base
.BaseLevel
]);
1233 /* If both firstImage and stObj point to a texture which can contain
1234 * all active images, favour firstImage. Note that because of the
1235 * completeness requirement, we know that the image dimensions
1238 if (firstImage
->pt
&&
1239 firstImage
->pt
!= stObj
->pt
&&
1240 (!stObj
->pt
|| firstImage
->pt
->last_level
>= stObj
->pt
->last_level
)) {
1241 pipe_resource_reference(&stObj
->pt
, firstImage
->pt
);
1242 pipe_sampler_view_reference(&stObj
->sampler_view
, NULL
);
1245 /* Find gallium format for the Mesa texture */
1246 firstImageFormat
= st_mesa_format_to_pipe_format(firstImage
->base
.TexFormat
);
1248 /* Find size of level=0 Gallium mipmap image, plus number of texture layers */
1250 GLuint width
, height
, depth
;
1251 if (!guess_base_level_size(stObj
->base
.Target
,
1252 firstImage
->base
.Width2
,
1253 firstImage
->base
.Height2
,
1254 firstImage
->base
.Depth2
,
1255 firstImage
->base
.Level
,
1256 &width
, &height
, &depth
)) {
1257 width
= stObj
->width0
;
1258 height
= stObj
->height0
;
1259 depth
= stObj
->depth0
;
1261 /* convert GL dims to Gallium dims */
1262 st_gl_texture_dims_to_pipe_dims(stObj
->base
.Target
, width
, height
, depth
,
1263 &ptWidth
, &ptHeight
, &ptDepth
, &ptLayers
);
1266 /* If we already have a gallium texture, check that it matches the texture
1267 * object's format, target, size, num_levels, etc.
1270 if (stObj
->pt
->target
!= gl_target_to_pipe(stObj
->base
.Target
) ||
1271 !st_sampler_compat_formats(stObj
->pt
->format
, firstImageFormat
) ||
1272 stObj
->pt
->last_level
< stObj
->lastLevel
||
1273 stObj
->pt
->width0
!= ptWidth
||
1274 stObj
->pt
->height0
!= ptHeight
||
1275 stObj
->pt
->depth0
!= ptDepth
||
1276 stObj
->pt
->array_size
!= ptLayers
)
1278 /* The gallium texture does not match the Mesa texture so delete the
1279 * gallium texture now. We'll make a new one below.
1281 pipe_resource_reference(&stObj
->pt
, NULL
);
1282 pipe_sampler_view_reference(&stObj
->sampler_view
, NULL
);
1283 st
->dirty
.st
|= ST_NEW_FRAMEBUFFER
;
1287 /* May need to create a new gallium texture:
1290 GLuint bindings
= default_bindings(st
, firstImageFormat
);
1292 stObj
->pt
= st_texture_create(st
,
1293 gl_target_to_pipe(stObj
->base
.Target
),
1303 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexImage");
1308 /* Pull in any images not in the object's texture:
1310 for (face
= 0; face
< nr_faces
; face
++) {
1312 for (level
= stObj
->base
.BaseLevel
; level
<= stObj
->lastLevel
; level
++) {
1313 struct st_texture_image
*stImage
=
1314 st_texture_image(stObj
->base
.Image
[face
][level
]);
1316 /* Need to import images in main memory or held in other textures.
1318 if (stImage
&& stObj
->pt
!= stImage
->pt
) {
1320 (stImage
->base
.Width
== u_minify(stObj
->width0
, level
) &&
1321 stImage
->base
.Height
== u_minify(stObj
->height0
, level
) &&
1322 stImage
->base
.Depth
== u_minify(stObj
->depth0
, level
))) {
1323 /* src image fits expected dest mipmap level size */
1324 copy_image_data_to_texture(st
, stObj
, level
, stImage
);
1335 * Returns pointer to a default/dummy texture.
1336 * This is typically used when the current shader has tex/sample instructions
1337 * but the user has not provided a (any) texture(s).
1339 struct gl_texture_object
*
1340 st_get_default_texture(struct st_context
*st
)
1342 if (!st
->default_texture
) {
1343 static const GLenum target
= GL_TEXTURE_2D
;
1344 GLubyte pixels
[16][16][4];
1345 struct gl_texture_object
*texObj
;
1346 struct gl_texture_image
*texImg
;
1349 /* The ARB_fragment_program spec says (0,0,0,1) should be returned
1350 * when attempting to sample incomplete textures.
1352 for (i
= 0; i
< 16; i
++) {
1353 for (j
= 0; j
< 16; j
++) {
1354 pixels
[i
][j
][0] = 0;
1355 pixels
[i
][j
][1] = 0;
1356 pixels
[i
][j
][2] = 0;
1357 pixels
[i
][j
][3] = 255;
1361 texObj
= st
->ctx
->Driver
.NewTextureObject(st
->ctx
, 0, target
);
1363 texImg
= _mesa_get_tex_image(st
->ctx
, texObj
, target
, 0);
1365 _mesa_init_teximage_fields(st
->ctx
, texImg
,
1366 16, 16, 1, 0, /* w, h, d, border */
1367 GL_RGBA
, MESA_FORMAT_RGBA8888
);
1369 _mesa_store_teximage2d(st
->ctx
, texImg
,
1370 GL_RGBA
, /* level, intformat */
1371 16, 16, 1, /* w, h, d, border */
1372 GL_RGBA
, GL_UNSIGNED_BYTE
, pixels
,
1373 &st
->ctx
->DefaultPacking
);
1375 texObj
->Sampler
.MinFilter
= GL_NEAREST
;
1376 texObj
->Sampler
.MagFilter
= GL_NEAREST
;
1377 texObj
->_Complete
= GL_TRUE
;
1379 st
->default_texture
= texObj
;
1381 return st
->default_texture
;
1386 * Called via ctx->Driver.AllocTextureStorage() to allocate texture memory
1387 * for a whole mipmap stack.
1390 st_AllocTextureStorage(struct gl_context
*ctx
,
1391 struct gl_texture_object
*texObj
,
1392 GLsizei levels
, GLsizei width
,
1393 GLsizei height
, GLsizei depth
)
1395 const GLuint numFaces
= (texObj
->Target
== GL_TEXTURE_CUBE_MAP
) ? 6 : 1;
1396 struct st_context
*st
= st_context(ctx
);
1397 struct st_texture_object
*stObj
= st_texture_object(texObj
);
1398 GLuint ptWidth
, ptHeight
, ptDepth
, ptLayers
, bindings
;
1399 enum pipe_format fmt
;
1404 /* Save the level=0 dimensions */
1405 stObj
->width0
= width
;
1406 stObj
->height0
= height
;
1407 stObj
->depth0
= depth
;
1408 stObj
->lastLevel
= levels
- 1;
1410 fmt
= st_mesa_format_to_pipe_format(texObj
->Image
[0][0]->TexFormat
);
1412 bindings
= default_bindings(st
, fmt
);
1414 st_gl_texture_dims_to_pipe_dims(texObj
->Target
,
1415 width
, height
, depth
,
1416 &ptWidth
, &ptHeight
, &ptDepth
, &ptLayers
);
1418 stObj
->pt
= st_texture_create(st
,
1419 gl_target_to_pipe(texObj
->Target
),
1430 /* Set image resource pointers */
1431 for (level
= 0; level
< levels
; level
++) {
1433 for (face
= 0; face
< numFaces
; face
++) {
1434 struct st_texture_image
*stImage
=
1435 st_texture_image(texObj
->Image
[face
][level
]);
1436 pipe_resource_reference(&stImage
->pt
, stObj
->pt
);
1446 st_init_texture_functions(struct dd_function_table
*functions
)
1448 functions
->ChooseTextureFormat
= st_ChooseTextureFormat
;
1449 functions
->TexImage1D
= st_TexImage1D
;
1450 functions
->TexImage2D
= st_TexImage2D
;
1451 functions
->TexImage3D
= st_TexImage3D
;
1452 functions
->TexSubImage1D
= _mesa_store_texsubimage1d
;
1453 functions
->TexSubImage2D
= _mesa_store_texsubimage2d
;
1454 functions
->TexSubImage3D
= _mesa_store_texsubimage3d
;
1455 functions
->CompressedTexSubImage1D
= _mesa_store_compressed_texsubimage1d
;
1456 functions
->CompressedTexSubImage2D
= _mesa_store_compressed_texsubimage2d
;
1457 functions
->CompressedTexSubImage3D
= _mesa_store_compressed_texsubimage3d
;
1458 functions
->CopyTexSubImage1D
= st_CopyTexSubImage1D
;
1459 functions
->CopyTexSubImage2D
= st_CopyTexSubImage2D
;
1460 functions
->CopyTexSubImage3D
= st_CopyTexSubImage3D
;
1461 functions
->GenerateMipmap
= st_generate_mipmap
;
1463 functions
->GetTexImage
= st_GetTexImage
;
1465 /* compressed texture functions */
1466 functions
->CompressedTexImage2D
= st_CompressedTexImage2D
;
1467 functions
->GetCompressedTexImage
= _mesa_get_compressed_teximage
;
1469 functions
->NewTextureObject
= st_NewTextureObject
;
1470 functions
->NewTextureImage
= st_NewTextureImage
;
1471 functions
->DeleteTextureImage
= st_DeleteTextureImage
;
1472 functions
->DeleteTexture
= st_DeleteTextureObject
;
1473 functions
->AllocTextureImageBuffer
= st_AllocTextureImageBuffer
;
1474 functions
->FreeTextureImageBuffer
= st_FreeTextureImageBuffer
;
1475 functions
->MapTextureImage
= st_MapTextureImage
;
1476 functions
->UnmapTextureImage
= st_UnmapTextureImage
;
1478 /* XXX Temporary until we can query pipe's texture sizes */
1479 functions
->TestProxyTexImage
= _mesa_test_proxy_teximage
;
1481 functions
->AllocTextureStorage
= st_AllocTextureStorage
;