2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
6 * Copyright (c) 2008-2009 VMware, Inc.
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 * The GL texture image functions in teximage.c basically just do
33 * error checking and data structure allocation. They in turn call
34 * device driver functions which actually copy/convert/store the user's
37 * However, most device drivers will be able to use the fallback functions
38 * in this file. That is, most drivers will have the following bit of
40 * ctx->Driver.TexImage1D = _mesa_store_teximage1d;
41 * ctx->Driver.TexImage2D = _mesa_store_teximage2d;
42 * ctx->Driver.TexImage3D = _mesa_store_teximage3d;
45 * Texture image processing is actually kind of complicated. We have to do:
46 * Format/type conversions
48 * pixel transfer (scale, bais, lookup, etc)
50 * These functions can handle most everything, including processing full
51 * images and sub-images.
56 #include "bufferobj.h"
61 #include "mfeatures.h"
66 #include "texcompress.h"
67 #include "texcompress_fxt1.h"
68 #include "texcompress_rgtc.h"
69 #include "texcompress_s3tc.h"
73 #include "../../gallium/auxiliary/util/u_format_rgb9e5.h"
74 #include "../../gallium/auxiliary/util/u_format_r11g11b10f.h"
84 * Texture image storage function.
86 typedef GLboolean (*StoreTexImageFunc
)(TEXSTORE_PARAMS
);
90 * Return GL_TRUE if the given image format is one that be converted
91 * to another format by swizzling.
94 can_swizzle(GLenum logicalBaseFormat
)
96 switch (logicalBaseFormat
) {
99 case GL_LUMINANCE_ALPHA
:
135 #define MAP1(x) MAP4(x, ZERO, ZERO, ZERO)
136 #define MAP2(x,y) MAP4(x, y, ZERO, ZERO)
137 #define MAP3(x,y,z) MAP4(x, y, z, ZERO)
138 #define MAP4(x,y,z,w) { x, y, z, w, ZERO, ONE }
141 static const struct {
144 GLubyte from_rgba
[6];
145 } mappings
[MAX_IDX
] =
155 MAP4(ZERO
, ZERO
, ZERO
, 0),
185 MAP4(0, ZERO
, ZERO
, ONE
),
191 MAP4(ZERO
, 0, ZERO
, ONE
),
197 MAP4(ZERO
, ZERO
, 0, ONE
),
221 MAP4(0, 1, ZERO
, ONE
),
229 * Convert a GL image format enum to an IDX_* value (see above).
232 get_map_idx(GLenum value
)
235 case GL_LUMINANCE
: return IDX_LUMINANCE
;
236 case GL_ALPHA
: return IDX_ALPHA
;
237 case GL_INTENSITY
: return IDX_INTENSITY
;
238 case GL_LUMINANCE_ALPHA
: return IDX_LUMINANCE_ALPHA
;
239 case GL_RGB
: return IDX_RGB
;
240 case GL_RGBA
: return IDX_RGBA
;
241 case GL_RED
: return IDX_RED
;
242 case GL_GREEN
: return IDX_GREEN
;
243 case GL_BLUE
: return IDX_BLUE
;
244 case GL_BGR
: return IDX_BGR
;
245 case GL_BGRA
: return IDX_BGRA
;
246 case GL_ABGR_EXT
: return IDX_ABGR
;
247 case GL_RG
: return IDX_RG
;
249 _mesa_problem(NULL
, "Unexpected inFormat");
256 * When promoting texture formats (see below) we need to compute the
257 * mapping of dest components back to source components.
258 * This function does that.
259 * \param inFormat the incoming format of the texture
260 * \param outFormat the final texture format
261 * \return map[6] a full 6-component map
264 compute_component_mapping(GLenum inFormat
, GLenum outFormat
,
267 const int inFmt
= get_map_idx(inFormat
);
268 const int outFmt
= get_map_idx(outFormat
);
269 const GLubyte
*in2rgba
= mappings
[inFmt
].to_rgba
;
270 const GLubyte
*rgba2out
= mappings
[outFmt
].from_rgba
;
273 for (i
= 0; i
< 4; i
++)
274 map
[i
] = in2rgba
[rgba2out
[i
]];
280 printf("from %x/%s to %x/%s map %d %d %d %d %d %d\n",
281 inFormat
, _mesa_lookup_enum_by_nr(inFormat
),
282 outFormat
, _mesa_lookup_enum_by_nr(outFormat
),
294 * Make a temporary (color) texture image with GLfloat components.
295 * Apply all needed pixel unpacking and pixel transfer operations.
296 * Note that there are both logicalBaseFormat and textureBaseFormat parameters.
297 * Suppose the user specifies GL_LUMINANCE as the internal texture format
298 * but the graphics hardware doesn't support luminance textures. So, we might
299 * use an RGB hardware format instead.
300 * If logicalBaseFormat != textureBaseFormat we have some extra work to do.
302 * \param ctx the rendering context
303 * \param dims image dimensions: 1, 2 or 3
304 * \param logicalBaseFormat basic texture derived from the user's
305 * internal texture format value
306 * \param textureBaseFormat the actual basic format of the texture
307 * \param srcWidth source image width
308 * \param srcHeight source image height
309 * \param srcDepth source image depth
310 * \param srcFormat source image format
311 * \param srcType source image type
312 * \param srcAddr source image address
313 * \param srcPacking source image pixel packing
314 * \return resulting image with format = textureBaseFormat and type = GLfloat.
317 _mesa_make_temp_float_image(struct gl_context
*ctx
, GLuint dims
,
318 GLenum logicalBaseFormat
,
319 GLenum textureBaseFormat
,
320 GLint srcWidth
, GLint srcHeight
, GLint srcDepth
,
321 GLenum srcFormat
, GLenum srcType
,
322 const GLvoid
*srcAddr
,
323 const struct gl_pixelstore_attrib
*srcPacking
,
324 GLbitfield transferOps
)
327 const GLint components
= _mesa_components_in_format(logicalBaseFormat
);
328 const GLint srcStride
=
329 _mesa_image_row_stride(srcPacking
, srcWidth
, srcFormat
, srcType
);
333 ASSERT(dims
>= 1 && dims
<= 3);
335 ASSERT(logicalBaseFormat
== GL_RGBA
||
336 logicalBaseFormat
== GL_RGB
||
337 logicalBaseFormat
== GL_RG
||
338 logicalBaseFormat
== GL_RED
||
339 logicalBaseFormat
== GL_LUMINANCE_ALPHA
||
340 logicalBaseFormat
== GL_LUMINANCE
||
341 logicalBaseFormat
== GL_ALPHA
||
342 logicalBaseFormat
== GL_INTENSITY
||
343 logicalBaseFormat
== GL_DEPTH_COMPONENT
);
345 ASSERT(textureBaseFormat
== GL_RGBA
||
346 textureBaseFormat
== GL_RGB
||
347 textureBaseFormat
== GL_RG
||
348 textureBaseFormat
== GL_RED
||
349 textureBaseFormat
== GL_LUMINANCE_ALPHA
||
350 textureBaseFormat
== GL_LUMINANCE
||
351 textureBaseFormat
== GL_ALPHA
||
352 textureBaseFormat
== GL_INTENSITY
||
353 textureBaseFormat
== GL_DEPTH_COMPONENT
);
355 tempImage
= (GLfloat
*) malloc(srcWidth
* srcHeight
* srcDepth
356 * components
* sizeof(GLfloat
));
361 for (img
= 0; img
< srcDepth
; img
++) {
363 = (const GLubyte
*) _mesa_image_address(dims
, srcPacking
, srcAddr
,
367 for (row
= 0; row
< srcHeight
; row
++) {
368 _mesa_unpack_color_span_float(ctx
, srcWidth
, logicalBaseFormat
,
369 dst
, srcFormat
, srcType
, src
,
370 srcPacking
, transferOps
);
371 dst
+= srcWidth
* components
;
376 if (logicalBaseFormat
!= textureBaseFormat
) {
378 GLint texComponents
= _mesa_components_in_format(textureBaseFormat
);
379 GLint logComponents
= _mesa_components_in_format(logicalBaseFormat
);
384 /* we only promote up to RGB, RGBA and LUMINANCE_ALPHA formats for now */
385 ASSERT(textureBaseFormat
== GL_RGB
|| textureBaseFormat
== GL_RGBA
||
386 textureBaseFormat
== GL_LUMINANCE_ALPHA
);
388 /* The actual texture format should have at least as many components
389 * as the logical texture format.
391 ASSERT(texComponents
>= logComponents
);
393 newImage
= (GLfloat
*) malloc(srcWidth
* srcHeight
* srcDepth
394 * texComponents
* sizeof(GLfloat
));
400 compute_component_mapping(logicalBaseFormat
, textureBaseFormat
, map
);
402 n
= srcWidth
* srcHeight
* srcDepth
;
403 for (i
= 0; i
< n
; i
++) {
405 for (k
= 0; k
< texComponents
; k
++) {
408 newImage
[i
* texComponents
+ k
] = 0.0F
;
410 newImage
[i
* texComponents
+ k
] = 1.0F
;
412 newImage
[i
* texComponents
+ k
] = tempImage
[i
* logComponents
+ j
];
417 tempImage
= newImage
;
425 * Make temporary image with uint pixel values. Used for unsigned
426 * integer-valued textures.
429 make_temp_uint_image(struct gl_context
*ctx
, GLuint dims
,
430 GLenum logicalBaseFormat
,
431 GLenum textureBaseFormat
,
432 GLint srcWidth
, GLint srcHeight
, GLint srcDepth
,
433 GLenum srcFormat
, GLenum srcType
,
434 const GLvoid
*srcAddr
,
435 const struct gl_pixelstore_attrib
*srcPacking
)
438 const GLint components
= _mesa_components_in_format(logicalBaseFormat
);
439 const GLint srcStride
=
440 _mesa_image_row_stride(srcPacking
, srcWidth
, srcFormat
, srcType
);
444 ASSERT(dims
>= 1 && dims
<= 3);
446 ASSERT(logicalBaseFormat
== GL_RGBA
||
447 logicalBaseFormat
== GL_RGB
||
448 logicalBaseFormat
== GL_RG
||
449 logicalBaseFormat
== GL_RED
||
450 logicalBaseFormat
== GL_LUMINANCE_ALPHA
||
451 logicalBaseFormat
== GL_LUMINANCE
||
452 logicalBaseFormat
== GL_INTENSITY
||
453 logicalBaseFormat
== GL_ALPHA
);
455 ASSERT(textureBaseFormat
== GL_RGBA
||
456 textureBaseFormat
== GL_RGB
||
457 textureBaseFormat
== GL_RG
||
458 textureBaseFormat
== GL_RED
||
459 textureBaseFormat
== GL_LUMINANCE_ALPHA
||
460 textureBaseFormat
== GL_LUMINANCE
||
461 textureBaseFormat
== GL_INTENSITY
||
462 textureBaseFormat
== GL_ALPHA
);
464 tempImage
= (GLuint
*) malloc(srcWidth
* srcHeight
* srcDepth
465 * components
* sizeof(GLuint
));
470 for (img
= 0; img
< srcDepth
; img
++) {
472 = (const GLubyte
*) _mesa_image_address(dims
, srcPacking
, srcAddr
,
476 for (row
= 0; row
< srcHeight
; row
++) {
477 _mesa_unpack_color_span_uint(ctx
, srcWidth
, logicalBaseFormat
,
478 dst
, srcFormat
, srcType
, src
,
480 dst
+= srcWidth
* components
;
485 if (logicalBaseFormat
!= textureBaseFormat
) {
487 GLint texComponents
= _mesa_components_in_format(textureBaseFormat
);
488 GLint logComponents
= _mesa_components_in_format(logicalBaseFormat
);
493 /* we only promote up to RGB, RGBA and LUMINANCE_ALPHA formats for now */
494 ASSERT(textureBaseFormat
== GL_RGB
|| textureBaseFormat
== GL_RGBA
||
495 textureBaseFormat
== GL_LUMINANCE_ALPHA
);
497 /* The actual texture format should have at least as many components
498 * as the logical texture format.
500 ASSERT(texComponents
>= logComponents
);
502 newImage
= (GLuint
*) malloc(srcWidth
* srcHeight
* srcDepth
503 * texComponents
* sizeof(GLuint
));
509 compute_component_mapping(logicalBaseFormat
, textureBaseFormat
, map
);
511 n
= srcWidth
* srcHeight
* srcDepth
;
512 for (i
= 0; i
< n
; i
++) {
514 for (k
= 0; k
< texComponents
; k
++) {
517 newImage
[i
* texComponents
+ k
] = 0.0F
;
519 newImage
[i
* texComponents
+ k
] = 1.0F
;
521 newImage
[i
* texComponents
+ k
] = tempImage
[i
* logComponents
+ j
];
526 tempImage
= newImage
;
535 * Make a temporary (color) texture image with GLubyte components.
536 * Apply all needed pixel unpacking and pixel transfer operations.
537 * Note that there are both logicalBaseFormat and textureBaseFormat parameters.
538 * Suppose the user specifies GL_LUMINANCE as the internal texture format
539 * but the graphics hardware doesn't support luminance textures. So, we might
540 * use an RGB hardware format instead.
541 * If logicalBaseFormat != textureBaseFormat we have some extra work to do.
543 * \param ctx the rendering context
544 * \param dims image dimensions: 1, 2 or 3
545 * \param logicalBaseFormat basic texture derived from the user's
546 * internal texture format value
547 * \param textureBaseFormat the actual basic format of the texture
548 * \param srcWidth source image width
549 * \param srcHeight source image height
550 * \param srcDepth source image depth
551 * \param srcFormat source image format
552 * \param srcType source image type
553 * \param srcAddr source image address
554 * \param srcPacking source image pixel packing
555 * \return resulting image with format = textureBaseFormat and type = GLubyte.
558 _mesa_make_temp_ubyte_image(struct gl_context
*ctx
, GLuint dims
,
559 GLenum logicalBaseFormat
,
560 GLenum textureBaseFormat
,
561 GLint srcWidth
, GLint srcHeight
, GLint srcDepth
,
562 GLenum srcFormat
, GLenum srcType
,
563 const GLvoid
*srcAddr
,
564 const struct gl_pixelstore_attrib
*srcPacking
)
566 GLuint transferOps
= ctx
->_ImageTransferState
;
567 const GLint components
= _mesa_components_in_format(logicalBaseFormat
);
569 GLubyte
*tempImage
, *dst
;
571 ASSERT(dims
>= 1 && dims
<= 3);
573 ASSERT(logicalBaseFormat
== GL_RGBA
||
574 logicalBaseFormat
== GL_RGB
||
575 logicalBaseFormat
== GL_RG
||
576 logicalBaseFormat
== GL_RED
||
577 logicalBaseFormat
== GL_LUMINANCE_ALPHA
||
578 logicalBaseFormat
== GL_LUMINANCE
||
579 logicalBaseFormat
== GL_ALPHA
||
580 logicalBaseFormat
== GL_INTENSITY
);
582 ASSERT(textureBaseFormat
== GL_RGBA
||
583 textureBaseFormat
== GL_RGB
||
584 textureBaseFormat
== GL_RG
||
585 textureBaseFormat
== GL_RED
||
586 textureBaseFormat
== GL_LUMINANCE_ALPHA
||
587 textureBaseFormat
== GL_LUMINANCE
||
588 textureBaseFormat
== GL_ALPHA
||
589 textureBaseFormat
== GL_INTENSITY
);
591 /* unpack and transfer the source image */
592 tempImage
= (GLubyte
*) malloc(srcWidth
* srcHeight
* srcDepth
593 * components
* sizeof(GLubyte
));
599 for (img
= 0; img
< srcDepth
; img
++) {
600 const GLint srcStride
=
601 _mesa_image_row_stride(srcPacking
, srcWidth
, srcFormat
, srcType
);
603 (const GLubyte
*) _mesa_image_address(dims
, srcPacking
, srcAddr
,
607 for (row
= 0; row
< srcHeight
; row
++) {
608 _mesa_unpack_color_span_ubyte(ctx
, srcWidth
, logicalBaseFormat
, dst
,
609 srcFormat
, srcType
, src
, srcPacking
,
611 dst
+= srcWidth
* components
;
616 if (logicalBaseFormat
!= textureBaseFormat
) {
617 /* one more conversion step */
618 GLint texComponents
= _mesa_components_in_format(textureBaseFormat
);
619 GLint logComponents
= _mesa_components_in_format(logicalBaseFormat
);
624 /* we only promote up to RGB, RGBA and LUMINANCE_ALPHA formats for now */
625 ASSERT(textureBaseFormat
== GL_RGB
|| textureBaseFormat
== GL_RGBA
||
626 textureBaseFormat
== GL_LUMINANCE_ALPHA
);
628 /* The actual texture format should have at least as many components
629 * as the logical texture format.
631 ASSERT(texComponents
>= logComponents
);
633 newImage
= (GLubyte
*) malloc(srcWidth
* srcHeight
* srcDepth
634 * texComponents
* sizeof(GLubyte
));
640 compute_component_mapping(logicalBaseFormat
, textureBaseFormat
, map
);
642 n
= srcWidth
* srcHeight
* srcDepth
;
643 for (i
= 0; i
< n
; i
++) {
645 for (k
= 0; k
< texComponents
; k
++) {
648 newImage
[i
* texComponents
+ k
] = 0;
650 newImage
[i
* texComponents
+ k
] = 255;
652 newImage
[i
* texComponents
+ k
] = tempImage
[i
* logComponents
+ j
];
657 tempImage
= newImage
;
665 * Copy GLubyte pixels from <src> to <dst> with swizzling.
666 * \param dst destination pixels
667 * \param dstComponents number of color components in destination pixels
668 * \param src source pixels
669 * \param srcComponents number of color components in source pixels
670 * \param map the swizzle mapping. map[X] says where to find the X component
671 * in the source image's pixels. For example, if the source image
672 * is GL_BGRA and X = red, map[0] yields 2.
673 * \param count number of pixels to copy/swizzle.
676 swizzle_copy(GLubyte
*dst
, GLuint dstComponents
, const GLubyte
*src
,
677 GLuint srcComponents
, const GLubyte
*map
, GLuint count
)
679 #define SWZ_CPY(dst, src, count, dstComps, srcComps) \
682 for (i = 0; i < count; i++) { \
684 if (srcComps == 4) { \
685 COPY_4UBV(tmp, src); \
688 for (j = 0; j < srcComps; j++) { \
693 for (j = 0; j < dstComps; j++) { \
694 dst[j] = tmp[map[j]]; \
705 ASSERT(srcComponents
<= 4);
706 ASSERT(dstComponents
<= 4);
708 switch (dstComponents
) {
710 switch (srcComponents
) {
712 SWZ_CPY(dst
, src
, count
, 4, 4);
715 SWZ_CPY(dst
, src
, count
, 4, 3);
718 SWZ_CPY(dst
, src
, count
, 4, 2);
721 SWZ_CPY(dst
, src
, count
, 4, 1);
728 switch (srcComponents
) {
730 SWZ_CPY(dst
, src
, count
, 3, 4);
733 SWZ_CPY(dst
, src
, count
, 3, 3);
736 SWZ_CPY(dst
, src
, count
, 3, 2);
739 SWZ_CPY(dst
, src
, count
, 3, 1);
746 switch (srcComponents
) {
748 SWZ_CPY(dst
, src
, count
, 2, 4);
751 SWZ_CPY(dst
, src
, count
, 2, 3);
754 SWZ_CPY(dst
, src
, count
, 2, 2);
757 SWZ_CPY(dst
, src
, count
, 2, 1);
764 switch (srcComponents
) {
766 SWZ_CPY(dst
, src
, count
, 1, 4);
769 SWZ_CPY(dst
, src
, count
, 1, 3);
772 SWZ_CPY(dst
, src
, count
, 1, 2);
775 SWZ_CPY(dst
, src
, count
, 1, 1);
789 static const GLubyte map_identity
[6] = { 0, 1, 2, 3, ZERO
, ONE
};
790 static const GLubyte map_3210
[6] = { 3, 2, 1, 0, ZERO
, ONE
};
794 * For 1-byte/pixel formats (or 8_8_8_8 packed formats), return a
795 * mapping array depending on endianness.
797 static const GLubyte
*
798 type_mapping( GLenum srcType
)
802 case GL_UNSIGNED_BYTE
:
804 case GL_UNSIGNED_INT_8_8_8_8
:
805 return _mesa_little_endian() ? map_3210
: map_identity
;
806 case GL_UNSIGNED_INT_8_8_8_8_REV
:
807 return _mesa_little_endian() ? map_identity
: map_3210
;
815 * For 1-byte/pixel formats (or 8_8_8_8 packed formats), return a
816 * mapping array depending on pixelstore byte swapping state.
818 static const GLubyte
*
819 byteswap_mapping( GLboolean swapBytes
,
827 case GL_UNSIGNED_BYTE
:
829 case GL_UNSIGNED_INT_8_8_8_8
:
830 case GL_UNSIGNED_INT_8_8_8_8_REV
:
840 * Transfer a GLubyte texture image with component swizzling.
843 _mesa_swizzle_ubyte_image(struct gl_context
*ctx
,
848 GLenum baseInternalFormat
,
850 const GLubyte
*rgba2dst
,
851 GLuint dstComponents
,
854 GLint dstXoffset
, GLint dstYoffset
, GLint dstZoffset
,
856 const GLuint
*dstImageOffsets
,
858 GLint srcWidth
, GLint srcHeight
, GLint srcDepth
,
859 const GLvoid
*srcAddr
,
860 const struct gl_pixelstore_attrib
*srcPacking
)
862 GLint srcComponents
= _mesa_components_in_format(srcFormat
);
863 const GLubyte
*srctype2ubyte
, *swap
;
864 GLubyte map
[4], src2base
[6], base2rgba
[6];
866 const GLint srcRowStride
=
867 _mesa_image_row_stride(srcPacking
, srcWidth
,
868 srcFormat
, GL_UNSIGNED_BYTE
);
869 const GLint srcImageStride
870 = _mesa_image_image_stride(srcPacking
, srcWidth
, srcHeight
, srcFormat
,
872 const GLubyte
*srcImage
873 = (const GLubyte
*) _mesa_image_address(dimensions
, srcPacking
, srcAddr
,
874 srcWidth
, srcHeight
, srcFormat
,
875 GL_UNSIGNED_BYTE
, 0, 0, 0);
879 /* Translate from src->baseInternal->GL_RGBA->dst. This will
880 * correctly deal with RGBA->RGB->RGBA conversions where the final
881 * A value must be 0xff regardless of the incoming alpha values.
883 compute_component_mapping(srcFormat
, baseInternalFormat
, src2base
);
884 compute_component_mapping(baseInternalFormat
, GL_RGBA
, base2rgba
);
885 swap
= byteswap_mapping(srcPacking
->SwapBytes
, srcType
);
886 srctype2ubyte
= type_mapping(srcType
);
889 for (i
= 0; i
< 4; i
++)
890 map
[i
] = srctype2ubyte
[swap
[src2base
[base2rgba
[rgba2dst
[i
]]]]];
892 /* printf("map %d %d %d %d\n", map[0], map[1], map[2], map[3]); */
894 if (srcComponents
== dstComponents
&&
895 srcRowStride
== dstRowStride
&&
896 srcRowStride
== srcWidth
* srcComponents
&&
898 /* 1 and 2D images only */
899 GLubyte
*dstImage
= (GLubyte
*) dstAddr
900 + dstYoffset
* dstRowStride
901 + dstXoffset
* dstComponents
;
902 swizzle_copy(dstImage
, dstComponents
, srcImage
, srcComponents
, map
,
903 srcWidth
* srcHeight
);
907 for (img
= 0; img
< srcDepth
; img
++) {
908 const GLubyte
*srcRow
= srcImage
;
909 GLubyte
*dstRow
= (GLubyte
*) dstAddr
910 + dstImageOffsets
[dstZoffset
+ img
] * dstComponents
911 + dstYoffset
* dstRowStride
912 + dstXoffset
* dstComponents
;
913 for (row
= 0; row
< srcHeight
; row
++) {
914 swizzle_copy(dstRow
, dstComponents
, srcRow
, srcComponents
, map
, srcWidth
);
915 dstRow
+= dstRowStride
;
916 srcRow
+= srcRowStride
;
918 srcImage
+= srcImageStride
;
925 * Teximage storage routine for when a simple memcpy will do.
926 * No pixel transfer operations or special texel encodings allowed.
927 * 1D, 2D and 3D images supported.
930 memcpy_texture(struct gl_context
*ctx
,
934 GLint dstXoffset
, GLint dstYoffset
, GLint dstZoffset
,
936 const GLuint
*dstImageOffsets
,
937 GLint srcWidth
, GLint srcHeight
, GLint srcDepth
,
938 GLenum srcFormat
, GLenum srcType
,
939 const GLvoid
*srcAddr
,
940 const struct gl_pixelstore_attrib
*srcPacking
)
942 const GLint srcRowStride
= _mesa_image_row_stride(srcPacking
, srcWidth
,
944 const GLint srcImageStride
= _mesa_image_image_stride(srcPacking
,
945 srcWidth
, srcHeight
, srcFormat
, srcType
);
946 const GLubyte
*srcImage
= (const GLubyte
*) _mesa_image_address(dimensions
,
947 srcPacking
, srcAddr
, srcWidth
, srcHeight
, srcFormat
, srcType
, 0, 0, 0);
948 const GLuint texelBytes
= _mesa_get_format_bytes(dstFormat
);
949 const GLint bytesPerRow
= srcWidth
* texelBytes
;
952 /* XXX update/re-enable for dstImageOffsets array */
953 const GLint bytesPerImage
= srcHeight
* bytesPerRow
;
954 const GLint bytesPerTexture
= srcDepth
* bytesPerImage
;
955 GLubyte
*dstImage
= (GLubyte
*) dstAddr
956 + dstZoffset
* dstImageStride
957 + dstYoffset
* dstRowStride
958 + dstXoffset
* texelBytes
;
960 if (dstRowStride
== srcRowStride
&&
961 dstRowStride
== bytesPerRow
&&
962 ((dstImageStride
== srcImageStride
&&
963 dstImageStride
== bytesPerImage
) ||
966 ctx
->Driver
.TextureMemCpy(dstImage
, srcImage
, bytesPerTexture
);
971 for (img
= 0; img
< srcDepth
; img
++) {
972 const GLubyte
*srcRow
= srcImage
;
973 GLubyte
*dstRow
= dstImage
;
974 for (row
= 0; row
< srcHeight
; row
++) {
975 ctx
->Driver
.TextureMemCpy(dstRow
, srcRow
, bytesPerRow
);
976 dstRow
+= dstRowStride
;
977 srcRow
+= srcRowStride
;
979 srcImage
+= srcImageStride
;
980 dstImage
+= dstImageStride
;
986 for (img
= 0; img
< srcDepth
; img
++) {
987 const GLubyte
*srcRow
= srcImage
;
988 GLubyte
*dstRow
= (GLubyte
*) dstAddr
989 + dstImageOffsets
[dstZoffset
+ img
] * texelBytes
990 + dstYoffset
* dstRowStride
991 + dstXoffset
* texelBytes
;
992 for (row
= 0; row
< srcHeight
; row
++) {
993 ctx
->Driver
.TextureMemCpy(dstRow
, srcRow
, bytesPerRow
);
994 dstRow
+= dstRowStride
;
995 srcRow
+= srcRowStride
;
997 srcImage
+= srcImageStride
;
1004 * Store a 32-bit integer or float depth component texture image.
1007 _mesa_texstore_z32(TEXSTORE_PARAMS
)
1009 const GLuint depthScale
= 0xffffffff;
1010 const GLuint texelBytes
= _mesa_get_format_bytes(dstFormat
);
1011 const GLenum dstType
= _mesa_get_format_datatype(dstFormat
);
1013 ASSERT(dstFormat
== MESA_FORMAT_Z32
||
1014 dstFormat
== MESA_FORMAT_Z32_FLOAT
);
1015 ASSERT(texelBytes
== sizeof(GLuint
));
1017 if (ctx
->Pixel
.DepthScale
== 1.0f
&&
1018 ctx
->Pixel
.DepthBias
== 0.0f
&&
1019 !srcPacking
->SwapBytes
&&
1020 baseInternalFormat
== GL_DEPTH_COMPONENT
&&
1021 srcFormat
== GL_DEPTH_COMPONENT
&&
1022 srcType
== dstType
) {
1023 /* simple memcpy path */
1024 memcpy_texture(ctx
, dims
,
1025 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
1028 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
1029 srcAddr
, srcPacking
);
1034 for (img
= 0; img
< srcDepth
; img
++) {
1035 GLubyte
*dstRow
= (GLubyte
*) dstAddr
1036 + dstImageOffsets
[dstZoffset
+ img
] * texelBytes
1037 + dstYoffset
* dstRowStride
1038 + dstXoffset
* texelBytes
;
1039 for (row
= 0; row
< srcHeight
; row
++) {
1040 const GLvoid
*src
= _mesa_image_address(dims
, srcPacking
,
1041 srcAddr
, srcWidth
, srcHeight
, srcFormat
, srcType
, img
, row
, 0);
1042 _mesa_unpack_depth_span(ctx
, srcWidth
,
1044 depthScale
, srcType
, src
, srcPacking
);
1045 dstRow
+= dstRowStride
;
1054 * Store a 24-bit integer depth component texture image.
1057 _mesa_texstore_x8_z24(TEXSTORE_PARAMS
)
1059 const GLuint depthScale
= 0xffffff;
1060 const GLuint texelBytes
= 4;
1063 ASSERT(dstFormat
== MESA_FORMAT_X8_Z24
);
1068 for (img
= 0; img
< srcDepth
; img
++) {
1069 GLubyte
*dstRow
= (GLubyte
*) dstAddr
1070 + dstImageOffsets
[dstZoffset
+ img
] * texelBytes
1071 + dstYoffset
* dstRowStride
1072 + dstXoffset
* texelBytes
;
1073 for (row
= 0; row
< srcHeight
; row
++) {
1074 const GLvoid
*src
= _mesa_image_address(dims
, srcPacking
,
1075 srcAddr
, srcWidth
, srcHeight
, srcFormat
, srcType
, img
, row
, 0);
1076 _mesa_unpack_depth_span(ctx
, srcWidth
,
1077 GL_UNSIGNED_INT
, (GLuint
*) dstRow
,
1078 depthScale
, srcType
, src
, srcPacking
);
1079 dstRow
+= dstRowStride
;
1088 * Store a 24-bit integer depth component texture image.
1091 _mesa_texstore_z24_x8(TEXSTORE_PARAMS
)
1093 const GLuint depthScale
= 0xffffff;
1094 const GLuint texelBytes
= 4;
1097 ASSERT(dstFormat
== MESA_FORMAT_Z24_X8
);
1102 for (img
= 0; img
< srcDepth
; img
++) {
1103 GLubyte
*dstRow
= (GLubyte
*) dstAddr
1104 + dstImageOffsets
[dstZoffset
+ img
] * texelBytes
1105 + dstYoffset
* dstRowStride
1106 + dstXoffset
* texelBytes
;
1107 for (row
= 0; row
< srcHeight
; row
++) {
1108 const GLvoid
*src
= _mesa_image_address(dims
, srcPacking
,
1109 srcAddr
, srcWidth
, srcHeight
, srcFormat
, srcType
, img
, row
, 0);
1110 GLuint
*dst
= (GLuint
*) dstRow
;
1112 _mesa_unpack_depth_span(ctx
, srcWidth
,
1113 GL_UNSIGNED_INT
, dst
,
1114 depthScale
, srcType
, src
, srcPacking
);
1115 for (i
= 0; i
< srcWidth
; i
++)
1117 dstRow
+= dstRowStride
;
1126 * Store a 16-bit integer depth component texture image.
1129 _mesa_texstore_z16(TEXSTORE_PARAMS
)
1131 const GLuint depthScale
= 0xffff;
1132 const GLuint texelBytes
= _mesa_get_format_bytes(dstFormat
);
1134 ASSERT(dstFormat
== MESA_FORMAT_Z16
);
1135 ASSERT(texelBytes
== sizeof(GLushort
));
1137 if (ctx
->Pixel
.DepthScale
== 1.0f
&&
1138 ctx
->Pixel
.DepthBias
== 0.0f
&&
1139 !srcPacking
->SwapBytes
&&
1140 baseInternalFormat
== GL_DEPTH_COMPONENT
&&
1141 srcFormat
== GL_DEPTH_COMPONENT
&&
1142 srcType
== GL_UNSIGNED_SHORT
) {
1143 /* simple memcpy path */
1144 memcpy_texture(ctx
, dims
,
1145 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
1148 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
1149 srcAddr
, srcPacking
);
1154 for (img
= 0; img
< srcDepth
; img
++) {
1155 GLubyte
*dstRow
= (GLubyte
*) dstAddr
1156 + dstImageOffsets
[dstZoffset
+ img
] * texelBytes
1157 + dstYoffset
* dstRowStride
1158 + dstXoffset
* texelBytes
;
1159 for (row
= 0; row
< srcHeight
; row
++) {
1160 const GLvoid
*src
= _mesa_image_address(dims
, srcPacking
,
1161 srcAddr
, srcWidth
, srcHeight
, srcFormat
, srcType
, img
, row
, 0);
1162 GLushort
*dst16
= (GLushort
*) dstRow
;
1163 _mesa_unpack_depth_span(ctx
, srcWidth
,
1164 GL_UNSIGNED_SHORT
, dst16
, depthScale
,
1165 srcType
, src
, srcPacking
);
1166 dstRow
+= dstRowStride
;
1175 * Store an rgb565 or rgb565_rev texture image.
1178 _mesa_texstore_rgb565(TEXSTORE_PARAMS
)
1180 const GLuint texelBytes
= _mesa_get_format_bytes(dstFormat
);
1181 const GLenum baseFormat
= _mesa_get_format_base_format(dstFormat
);
1183 ASSERT(dstFormat
== MESA_FORMAT_RGB565
||
1184 dstFormat
== MESA_FORMAT_RGB565_REV
);
1185 ASSERT(texelBytes
== 2);
1187 if (!ctx
->_ImageTransferState
&&
1188 !srcPacking
->SwapBytes
&&
1189 dstFormat
== MESA_FORMAT_RGB565
&&
1190 baseInternalFormat
== GL_RGB
&&
1191 srcFormat
== GL_RGB
&&
1192 srcType
== GL_UNSIGNED_SHORT_5_6_5
) {
1193 /* simple memcpy path */
1194 memcpy_texture(ctx
, dims
,
1195 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
1198 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
1199 srcAddr
, srcPacking
);
1201 else if (!ctx
->_ImageTransferState
&&
1202 !srcPacking
->SwapBytes
&&
1203 baseInternalFormat
== GL_RGB
&&
1204 srcFormat
== GL_RGB
&&
1205 srcType
== GL_UNSIGNED_BYTE
&&
1207 /* do optimized tex store */
1208 const GLint srcRowStride
=
1209 _mesa_image_row_stride(srcPacking
, srcWidth
, srcFormat
, srcType
);
1210 const GLubyte
*src
= (const GLubyte
*)
1211 _mesa_image_address(dims
, srcPacking
, srcAddr
, srcWidth
, srcHeight
,
1212 srcFormat
, srcType
, 0, 0, 0);
1213 GLubyte
*dst
= (GLubyte
*) dstAddr
1214 + dstYoffset
* dstRowStride
1215 + dstXoffset
* texelBytes
;
1217 for (row
= 0; row
< srcHeight
; row
++) {
1218 const GLubyte
*srcUB
= (const GLubyte
*) src
;
1219 GLushort
*dstUS
= (GLushort
*) dst
;
1220 /* check for byteswapped format */
1221 if (dstFormat
== MESA_FORMAT_RGB565
) {
1222 for (col
= 0; col
< srcWidth
; col
++) {
1223 dstUS
[col
] = PACK_COLOR_565( srcUB
[0], srcUB
[1], srcUB
[2] );
1228 for (col
= 0; col
< srcWidth
; col
++) {
1229 dstUS
[col
] = PACK_COLOR_565_REV( srcUB
[0], srcUB
[1], srcUB
[2] );
1233 dst
+= dstRowStride
;
1234 src
+= srcRowStride
;
1239 const GLubyte
*tempImage
= _mesa_make_temp_ubyte_image(ctx
, dims
,
1242 srcWidth
, srcHeight
, srcDepth
,
1243 srcFormat
, srcType
, srcAddr
,
1245 const GLubyte
*src
= tempImage
;
1246 GLint img
, row
, col
;
1249 for (img
= 0; img
< srcDepth
; img
++) {
1250 GLubyte
*dstRow
= (GLubyte
*) dstAddr
1251 + dstImageOffsets
[dstZoffset
+ img
] * texelBytes
1252 + dstYoffset
* dstRowStride
1253 + dstXoffset
* texelBytes
;
1254 for (row
= 0; row
< srcHeight
; row
++) {
1255 GLushort
*dstUS
= (GLushort
*) dstRow
;
1256 /* check for byteswapped format */
1257 if (dstFormat
== MESA_FORMAT_RGB565
) {
1258 for (col
= 0; col
< srcWidth
; col
++) {
1259 dstUS
[col
] = PACK_COLOR_565( src
[RCOMP
],
1266 for (col
= 0; col
< srcWidth
; col
++) {
1267 dstUS
[col
] = PACK_COLOR_565_REV( src
[RCOMP
],
1273 dstRow
+= dstRowStride
;
1276 free((void *) tempImage
);
1283 * Store a texture in MESA_FORMAT_RGBA8888 or MESA_FORMAT_RGBA8888_REV.
1286 _mesa_texstore_rgba8888(TEXSTORE_PARAMS
)
1288 const GLboolean littleEndian
= _mesa_little_endian();
1289 const GLuint texelBytes
= _mesa_get_format_bytes(dstFormat
);
1290 const GLenum baseFormat
= _mesa_get_format_base_format(dstFormat
);
1292 ASSERT(dstFormat
== MESA_FORMAT_RGBA8888
||
1293 dstFormat
== MESA_FORMAT_RGBA8888_REV
);
1294 ASSERT(texelBytes
== 4);
1296 if (!ctx
->_ImageTransferState
&&
1297 !srcPacking
->SwapBytes
&&
1298 dstFormat
== MESA_FORMAT_RGBA8888
&&
1299 baseInternalFormat
== GL_RGBA
&&
1300 ((srcFormat
== GL_RGBA
&& srcType
== GL_UNSIGNED_INT_8_8_8_8
) ||
1301 (srcFormat
== GL_RGBA
&& srcType
== GL_UNSIGNED_BYTE
&& !littleEndian
) ||
1302 (srcFormat
== GL_ABGR_EXT
&& srcType
== GL_UNSIGNED_INT_8_8_8_8_REV
) ||
1303 (srcFormat
== GL_ABGR_EXT
&& srcType
== GL_UNSIGNED_BYTE
&& littleEndian
))) {
1304 /* simple memcpy path */
1305 memcpy_texture(ctx
, dims
,
1306 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
1309 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
1310 srcAddr
, srcPacking
);
1312 else if (!ctx
->_ImageTransferState
&&
1313 !srcPacking
->SwapBytes
&&
1314 dstFormat
== MESA_FORMAT_RGBA8888_REV
&&
1315 baseInternalFormat
== GL_RGBA
&&
1316 ((srcFormat
== GL_RGBA
&& srcType
== GL_UNSIGNED_INT_8_8_8_8_REV
) ||
1317 (srcFormat
== GL_RGBA
&& srcType
== GL_UNSIGNED_BYTE
&& littleEndian
) ||
1318 (srcFormat
== GL_ABGR_EXT
&& srcType
== GL_UNSIGNED_INT_8_8_8_8
) ||
1319 (srcFormat
== GL_ABGR_EXT
&& srcType
== GL_UNSIGNED_BYTE
&& !littleEndian
))) {
1320 /* simple memcpy path */
1321 memcpy_texture(ctx
, dims
,
1322 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
1325 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
1326 srcAddr
, srcPacking
);
1328 else if (!ctx
->_ImageTransferState
&&
1329 (srcType
== GL_UNSIGNED_BYTE
||
1330 srcType
== GL_UNSIGNED_INT_8_8_8_8
||
1331 srcType
== GL_UNSIGNED_INT_8_8_8_8_REV
) &&
1332 can_swizzle(baseInternalFormat
) &&
1333 can_swizzle(srcFormat
)) {
1337 /* dstmap - how to swizzle from RGBA to dst format:
1339 if ((littleEndian
&& dstFormat
== MESA_FORMAT_RGBA8888
) ||
1340 (!littleEndian
&& dstFormat
== MESA_FORMAT_RGBA8888_REV
)) {
1353 _mesa_swizzle_ubyte_image(ctx
, dims
,
1358 dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
1359 dstRowStride
, dstImageOffsets
,
1360 srcWidth
, srcHeight
, srcDepth
, srcAddr
,
1365 const GLubyte
*tempImage
= _mesa_make_temp_ubyte_image(ctx
, dims
,
1368 srcWidth
, srcHeight
, srcDepth
,
1369 srcFormat
, srcType
, srcAddr
,
1371 const GLubyte
*src
= tempImage
;
1372 GLint img
, row
, col
;
1375 for (img
= 0; img
< srcDepth
; img
++) {
1376 GLubyte
*dstRow
= (GLubyte
*) dstAddr
1377 + dstImageOffsets
[dstZoffset
+ img
] * texelBytes
1378 + dstYoffset
* dstRowStride
1379 + dstXoffset
* texelBytes
;
1380 for (row
= 0; row
< srcHeight
; row
++) {
1381 GLuint
*dstUI
= (GLuint
*) dstRow
;
1382 if (dstFormat
== MESA_FORMAT_RGBA8888
) {
1383 for (col
= 0; col
< srcWidth
; col
++) {
1384 dstUI
[col
] = PACK_COLOR_8888( src
[RCOMP
],
1392 for (col
= 0; col
< srcWidth
; col
++) {
1393 dstUI
[col
] = PACK_COLOR_8888_REV( src
[RCOMP
],
1400 dstRow
+= dstRowStride
;
1403 free((void *) tempImage
);
1410 _mesa_texstore_argb8888(TEXSTORE_PARAMS
)
1412 const GLboolean littleEndian
= _mesa_little_endian();
1413 const GLuint texelBytes
= _mesa_get_format_bytes(dstFormat
);
1414 const GLenum baseFormat
= GL_RGBA
;
1416 ASSERT(dstFormat
== MESA_FORMAT_ARGB8888
||
1417 dstFormat
== MESA_FORMAT_ARGB8888_REV
||
1418 dstFormat
== MESA_FORMAT_XRGB8888
||
1419 dstFormat
== MESA_FORMAT_XRGB8888_REV
);
1420 ASSERT(texelBytes
== 4);
1422 if (!ctx
->_ImageTransferState
&&
1423 !srcPacking
->SwapBytes
&&
1424 (dstFormat
== MESA_FORMAT_ARGB8888
||
1425 dstFormat
== MESA_FORMAT_XRGB8888
) &&
1426 baseInternalFormat
== GL_RGBA
&&
1427 srcFormat
== GL_BGRA
&&
1428 ((srcType
== GL_UNSIGNED_BYTE
&& littleEndian
) ||
1429 srcType
== GL_UNSIGNED_INT_8_8_8_8_REV
)) {
1430 /* simple memcpy path (little endian) */
1431 memcpy_texture(ctx
, dims
,
1432 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
1435 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
1436 srcAddr
, srcPacking
);
1438 else if (!ctx
->_ImageTransferState
&&
1439 !srcPacking
->SwapBytes
&&
1440 (dstFormat
== MESA_FORMAT_ARGB8888_REV
||
1441 dstFormat
== MESA_FORMAT_XRGB8888_REV
) &&
1442 baseInternalFormat
== GL_RGBA
&&
1443 srcFormat
== GL_BGRA
&&
1444 ((srcType
== GL_UNSIGNED_BYTE
&& !littleEndian
) ||
1445 srcType
== GL_UNSIGNED_INT_8_8_8_8
)) {
1446 /* simple memcpy path (big endian) */
1447 memcpy_texture(ctx
, dims
,
1448 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
1451 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
1452 srcAddr
, srcPacking
);
1454 else if (!ctx
->_ImageTransferState
&&
1455 !srcPacking
->SwapBytes
&&
1456 (dstFormat
== MESA_FORMAT_ARGB8888
||
1457 dstFormat
== MESA_FORMAT_XRGB8888
) &&
1458 srcFormat
== GL_RGB
&&
1459 (baseInternalFormat
== GL_RGBA
||
1460 baseInternalFormat
== GL_RGB
) &&
1461 srcType
== GL_UNSIGNED_BYTE
) {
1463 for (img
= 0; img
< srcDepth
; img
++) {
1464 const GLint srcRowStride
=
1465 _mesa_image_row_stride(srcPacking
, srcWidth
, srcFormat
, srcType
);
1466 GLubyte
*srcRow
= (GLubyte
*) _mesa_image_address(dims
, srcPacking
,
1467 srcAddr
, srcWidth
, srcHeight
, srcFormat
, srcType
, img
, 0, 0);
1468 GLubyte
*dstRow
= (GLubyte
*) dstAddr
1469 + dstImageOffsets
[dstZoffset
+ img
] * texelBytes
1470 + dstYoffset
* dstRowStride
1471 + dstXoffset
* texelBytes
;
1472 for (row
= 0; row
< srcHeight
; row
++) {
1473 GLuint
*d4
= (GLuint
*) dstRow
;
1474 for (col
= 0; col
< srcWidth
; col
++) {
1475 d4
[col
] = PACK_COLOR_8888(0xff,
1476 srcRow
[col
* 3 + RCOMP
],
1477 srcRow
[col
* 3 + GCOMP
],
1478 srcRow
[col
* 3 + BCOMP
]);
1480 dstRow
+= dstRowStride
;
1481 srcRow
+= srcRowStride
;
1485 else if (!ctx
->_ImageTransferState
&&
1486 !srcPacking
->SwapBytes
&&
1487 dstFormat
== MESA_FORMAT_ARGB8888
&&
1488 srcFormat
== GL_RGBA
&&
1489 baseInternalFormat
== GL_RGBA
&&
1490 srcType
== GL_UNSIGNED_BYTE
) {
1491 /* same as above case, but src data has alpha too */
1492 GLint img
, row
, col
;
1493 /* For some reason, streaming copies to write-combined regions
1494 * are extremely sensitive to the characteristics of how the
1495 * source data is retrieved. By reordering the source reads to
1496 * be in-order, the speed of this operation increases by half.
1497 * Strangely the same isn't required for the RGB path, above.
1499 for (img
= 0; img
< srcDepth
; img
++) {
1500 const GLint srcRowStride
=
1501 _mesa_image_row_stride(srcPacking
, srcWidth
, srcFormat
, srcType
);
1502 GLubyte
*srcRow
= (GLubyte
*) _mesa_image_address(dims
, srcPacking
,
1503 srcAddr
, srcWidth
, srcHeight
, srcFormat
, srcType
, img
, 0, 0);
1504 GLubyte
*dstRow
= (GLubyte
*) dstAddr
1505 + dstImageOffsets
[dstZoffset
+ img
] * texelBytes
1506 + dstYoffset
* dstRowStride
1507 + dstXoffset
* texelBytes
;
1508 for (row
= 0; row
< srcHeight
; row
++) {
1509 GLuint
*d4
= (GLuint
*) dstRow
;
1510 for (col
= 0; col
< srcWidth
; col
++) {
1511 d4
[col
] = PACK_COLOR_8888(srcRow
[col
* 4 + ACOMP
],
1512 srcRow
[col
* 4 + RCOMP
],
1513 srcRow
[col
* 4 + GCOMP
],
1514 srcRow
[col
* 4 + BCOMP
]);
1516 dstRow
+= dstRowStride
;
1517 srcRow
+= srcRowStride
;
1521 else if (!ctx
->_ImageTransferState
&&
1522 (srcType
== GL_UNSIGNED_BYTE
||
1523 srcType
== GL_UNSIGNED_INT_8_8_8_8
||
1524 srcType
== GL_UNSIGNED_INT_8_8_8_8_REV
) &&
1525 can_swizzle(baseInternalFormat
) &&
1526 can_swizzle(srcFormat
)) {
1530 /* dstmap - how to swizzle from RGBA to dst format:
1532 if ((littleEndian
&& dstFormat
== MESA_FORMAT_ARGB8888
) ||
1533 (littleEndian
&& dstFormat
== MESA_FORMAT_XRGB8888
) ||
1534 (!littleEndian
&& dstFormat
== MESA_FORMAT_ARGB8888_REV
) ||
1535 (!littleEndian
&& dstFormat
== MESA_FORMAT_XRGB8888_REV
)) {
1536 dstmap
[3] = 3; /* alpha */
1537 dstmap
[2] = 0; /* red */
1538 dstmap
[1] = 1; /* green */
1539 dstmap
[0] = 2; /* blue */
1542 assert((littleEndian
&& dstFormat
== MESA_FORMAT_ARGB8888_REV
) ||
1543 (!littleEndian
&& dstFormat
== MESA_FORMAT_ARGB8888
) ||
1544 (littleEndian
&& dstFormat
== MESA_FORMAT_XRGB8888_REV
) ||
1545 (!littleEndian
&& dstFormat
== MESA_FORMAT_XRGB8888
));
1552 _mesa_swizzle_ubyte_image(ctx
, dims
,
1557 dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
1560 srcWidth
, srcHeight
, srcDepth
, srcAddr
,
1565 const GLubyte
*tempImage
= _mesa_make_temp_ubyte_image(ctx
, dims
,
1568 srcWidth
, srcHeight
, srcDepth
,
1569 srcFormat
, srcType
, srcAddr
,
1571 const GLubyte
*src
= tempImage
;
1572 GLint img
, row
, col
;
1575 for (img
= 0; img
< srcDepth
; img
++) {
1576 GLubyte
*dstRow
= (GLubyte
*) dstAddr
1577 + dstImageOffsets
[dstZoffset
+ img
] * texelBytes
1578 + dstYoffset
* dstRowStride
1579 + dstXoffset
* texelBytes
;
1580 for (row
= 0; row
< srcHeight
; row
++) {
1581 GLuint
*dstUI
= (GLuint
*) dstRow
;
1582 if (dstFormat
== MESA_FORMAT_ARGB8888
) {
1583 for (col
= 0; col
< srcWidth
; col
++) {
1584 dstUI
[col
] = PACK_COLOR_8888( src
[ACOMP
],
1591 else if (dstFormat
== MESA_FORMAT_XRGB8888
) {
1592 for (col
= 0; col
< srcWidth
; col
++) {
1593 dstUI
[col
] = PACK_COLOR_8888( 0xff,
1601 for (col
= 0; col
< srcWidth
; col
++) {
1602 dstUI
[col
] = PACK_COLOR_8888_REV( src
[ACOMP
],
1609 dstRow
+= dstRowStride
;
1612 free((void *) tempImage
);
1619 _mesa_texstore_rgb888(TEXSTORE_PARAMS
)
1621 const GLboolean littleEndian
= _mesa_little_endian();
1622 const GLuint texelBytes
= _mesa_get_format_bytes(dstFormat
);
1623 const GLenum baseFormat
= _mesa_get_format_base_format(dstFormat
);
1625 ASSERT(dstFormat
== MESA_FORMAT_RGB888
);
1626 ASSERT(texelBytes
== 3);
1628 if (!ctx
->_ImageTransferState
&&
1629 !srcPacking
->SwapBytes
&&
1630 baseInternalFormat
== GL_RGB
&&
1631 srcFormat
== GL_BGR
&&
1632 srcType
== GL_UNSIGNED_BYTE
&&
1634 /* simple memcpy path */
1635 memcpy_texture(ctx
, dims
,
1636 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
1639 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
1640 srcAddr
, srcPacking
);
1642 else if (!ctx
->_ImageTransferState
&&
1643 !srcPacking
->SwapBytes
&&
1644 srcFormat
== GL_RGBA
&&
1645 srcType
== GL_UNSIGNED_BYTE
) {
1646 /* extract RGB from RGBA */
1647 GLint img
, row
, col
;
1648 for (img
= 0; img
< srcDepth
; img
++) {
1649 const GLint srcRowStride
=
1650 _mesa_image_row_stride(srcPacking
, srcWidth
, srcFormat
, srcType
);
1651 GLubyte
*srcRow
= (GLubyte
*) _mesa_image_address(dims
, srcPacking
,
1652 srcAddr
, srcWidth
, srcHeight
, srcFormat
, srcType
, img
, 0, 0);
1653 GLubyte
*dstRow
= (GLubyte
*) dstAddr
1654 + dstImageOffsets
[dstZoffset
+ img
] * texelBytes
1655 + dstYoffset
* dstRowStride
1656 + dstXoffset
* texelBytes
;
1657 for (row
= 0; row
< srcHeight
; row
++) {
1658 for (col
= 0; col
< srcWidth
; col
++) {
1659 dstRow
[col
* 3 + 0] = srcRow
[col
* 4 + BCOMP
];
1660 dstRow
[col
* 3 + 1] = srcRow
[col
* 4 + GCOMP
];
1661 dstRow
[col
* 3 + 2] = srcRow
[col
* 4 + RCOMP
];
1663 dstRow
+= dstRowStride
;
1664 srcRow
+= srcRowStride
;
1668 else if (!ctx
->_ImageTransferState
&&
1669 srcType
== GL_UNSIGNED_BYTE
&&
1670 can_swizzle(baseInternalFormat
) &&
1671 can_swizzle(srcFormat
)) {
1675 /* dstmap - how to swizzle from RGBA to dst format:
1680 dstmap
[3] = ONE
; /* ? */
1682 _mesa_swizzle_ubyte_image(ctx
, dims
,
1687 dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
1688 dstRowStride
, dstImageOffsets
,
1689 srcWidth
, srcHeight
, srcDepth
, srcAddr
,
1694 const GLubyte
*tempImage
= _mesa_make_temp_ubyte_image(ctx
, dims
,
1697 srcWidth
, srcHeight
, srcDepth
,
1698 srcFormat
, srcType
, srcAddr
,
1700 const GLubyte
*src
= (const GLubyte
*) tempImage
;
1701 GLint img
, row
, col
;
1704 for (img
= 0; img
< srcDepth
; img
++) {
1705 GLubyte
*dstRow
= (GLubyte
*) dstAddr
1706 + dstImageOffsets
[dstZoffset
+ img
] * texelBytes
1707 + dstYoffset
* dstRowStride
1708 + dstXoffset
* texelBytes
;
1709 for (row
= 0; row
< srcHeight
; row
++) {
1712 for (col
= 0; col
< srcWidth
; col
++) {
1713 dstRow
[col
* 3 + 0] = src
[RCOMP
];
1714 dstRow
[col
* 3 + 1] = src
[GCOMP
];
1715 dstRow
[col
* 3 + 2] = src
[BCOMP
];
1720 for (col
= 0; col
< srcWidth
; col
++) {
1721 dstRow
[col
* 3 + 0] = srcUB
[BCOMP
];
1722 dstRow
[col
* 3 + 1] = srcUB
[GCOMP
];
1723 dstRow
[col
* 3 + 2] = srcUB
[RCOMP
];
1728 for (col
= 0; col
< srcWidth
; col
++) {
1729 dstRow
[col
* 3 + 0] = src
[BCOMP
];
1730 dstRow
[col
* 3 + 1] = src
[GCOMP
];
1731 dstRow
[col
* 3 + 2] = src
[RCOMP
];
1735 dstRow
+= dstRowStride
;
1738 free((void *) tempImage
);
1745 _mesa_texstore_bgr888(TEXSTORE_PARAMS
)
1747 const GLboolean littleEndian
= _mesa_little_endian();
1748 const GLuint texelBytes
= _mesa_get_format_bytes(dstFormat
);
1749 const GLenum baseFormat
= _mesa_get_format_base_format(dstFormat
);
1751 ASSERT(dstFormat
== MESA_FORMAT_BGR888
);
1752 ASSERT(texelBytes
== 3);
1754 if (!ctx
->_ImageTransferState
&&
1755 !srcPacking
->SwapBytes
&&
1756 baseInternalFormat
== GL_RGB
&&
1757 srcFormat
== GL_RGB
&&
1758 srcType
== GL_UNSIGNED_BYTE
&&
1760 /* simple memcpy path */
1761 memcpy_texture(ctx
, dims
,
1762 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
1765 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
1766 srcAddr
, srcPacking
);
1768 else if (!ctx
->_ImageTransferState
&&
1769 !srcPacking
->SwapBytes
&&
1770 srcFormat
== GL_RGBA
&&
1771 srcType
== GL_UNSIGNED_BYTE
) {
1772 /* extract BGR from RGBA */
1774 for (img
= 0; img
< srcDepth
; img
++) {
1775 const GLint srcRowStride
=
1776 _mesa_image_row_stride(srcPacking
, srcWidth
, srcFormat
, srcType
);
1777 GLubyte
*srcRow
= (GLubyte
*) _mesa_image_address(dims
, srcPacking
,
1778 srcAddr
, srcWidth
, srcHeight
, srcFormat
, srcType
, img
, 0, 0);
1779 GLubyte
*dstRow
= (GLubyte
*) dstAddr
1780 + dstImageOffsets
[dstZoffset
+ img
] * texelBytes
1781 + dstYoffset
* dstRowStride
1782 + dstXoffset
* texelBytes
;
1783 for (row
= 0; row
< srcHeight
; row
++) {
1784 for (col
= 0; col
< srcWidth
; col
++) {
1785 dstRow
[col
* 3 + 0] = srcRow
[col
* 4 + RCOMP
];
1786 dstRow
[col
* 3 + 1] = srcRow
[col
* 4 + GCOMP
];
1787 dstRow
[col
* 3 + 2] = srcRow
[col
* 4 + BCOMP
];
1789 dstRow
+= dstRowStride
;
1790 srcRow
+= srcRowStride
;
1794 else if (!ctx
->_ImageTransferState
&&
1795 srcType
== GL_UNSIGNED_BYTE
&&
1796 can_swizzle(baseInternalFormat
) &&
1797 can_swizzle(srcFormat
)) {
1801 /* dstmap - how to swizzle from RGBA to dst format:
1806 dstmap
[3] = ONE
; /* ? */
1808 _mesa_swizzle_ubyte_image(ctx
, dims
,
1813 dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
1814 dstRowStride
, dstImageOffsets
,
1815 srcWidth
, srcHeight
, srcDepth
, srcAddr
,
1820 const GLubyte
*tempImage
= _mesa_make_temp_ubyte_image(ctx
, dims
,
1823 srcWidth
, srcHeight
, srcDepth
,
1824 srcFormat
, srcType
, srcAddr
,
1826 const GLubyte
*src
= (const GLubyte
*) tempImage
;
1827 GLint img
, row
, col
;
1830 for (img
= 0; img
< srcDepth
; img
++) {
1831 GLubyte
*dstRow
= (GLubyte
*) dstAddr
1832 + dstImageOffsets
[dstZoffset
+ img
] * texelBytes
1833 + dstYoffset
* dstRowStride
1834 + dstXoffset
* texelBytes
;
1835 for (row
= 0; row
< srcHeight
; row
++) {
1836 for (col
= 0; col
< srcWidth
; col
++) {
1837 dstRow
[col
* 3 + 0] = src
[RCOMP
];
1838 dstRow
[col
* 3 + 1] = src
[GCOMP
];
1839 dstRow
[col
* 3 + 2] = src
[BCOMP
];
1842 dstRow
+= dstRowStride
;
1845 free((void *) tempImage
);
1852 _mesa_texstore_argb4444(TEXSTORE_PARAMS
)
1854 const GLuint texelBytes
= _mesa_get_format_bytes(dstFormat
);
1855 const GLenum baseFormat
= _mesa_get_format_base_format(dstFormat
);
1857 ASSERT(dstFormat
== MESA_FORMAT_ARGB4444
||
1858 dstFormat
== MESA_FORMAT_ARGB4444_REV
);
1859 ASSERT(texelBytes
== 2);
1861 if (!ctx
->_ImageTransferState
&&
1862 !srcPacking
->SwapBytes
&&
1863 dstFormat
== MESA_FORMAT_ARGB4444
&&
1864 baseInternalFormat
== GL_RGBA
&&
1865 srcFormat
== GL_BGRA
&&
1866 srcType
== GL_UNSIGNED_SHORT_4_4_4_4_REV
) {
1867 /* simple memcpy path */
1868 memcpy_texture(ctx
, dims
,
1869 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
1872 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
1873 srcAddr
, srcPacking
);
1877 const GLubyte
*tempImage
= _mesa_make_temp_ubyte_image(ctx
, dims
,
1880 srcWidth
, srcHeight
, srcDepth
,
1881 srcFormat
, srcType
, srcAddr
,
1883 const GLubyte
*src
= tempImage
;
1884 GLint img
, row
, col
;
1887 for (img
= 0; img
< srcDepth
; img
++) {
1888 GLubyte
*dstRow
= (GLubyte
*) dstAddr
1889 + dstImageOffsets
[dstZoffset
+ img
] * texelBytes
1890 + dstYoffset
* dstRowStride
1891 + dstXoffset
* texelBytes
;
1892 for (row
= 0; row
< srcHeight
; row
++) {
1893 GLushort
*dstUS
= (GLushort
*) dstRow
;
1894 if (dstFormat
== MESA_FORMAT_ARGB4444
) {
1895 for (col
= 0; col
< srcWidth
; col
++) {
1896 dstUS
[col
] = PACK_COLOR_4444( src
[ACOMP
],
1904 for (col
= 0; col
< srcWidth
; col
++) {
1905 dstUS
[col
] = PACK_COLOR_4444_REV( src
[ACOMP
],
1912 dstRow
+= dstRowStride
;
1915 free((void *) tempImage
);
1921 _mesa_texstore_rgba5551(TEXSTORE_PARAMS
)
1923 const GLuint texelBytes
= _mesa_get_format_bytes(dstFormat
);
1924 const GLenum baseFormat
= _mesa_get_format_base_format(dstFormat
);
1926 ASSERT(dstFormat
== MESA_FORMAT_RGBA5551
);
1927 ASSERT(texelBytes
== 2);
1929 if (!ctx
->_ImageTransferState
&&
1930 !srcPacking
->SwapBytes
&&
1931 dstFormat
== MESA_FORMAT_RGBA5551
&&
1932 baseInternalFormat
== GL_RGBA
&&
1933 srcFormat
== GL_RGBA
&&
1934 srcType
== GL_UNSIGNED_SHORT_5_5_5_1
) {
1935 /* simple memcpy path */
1936 memcpy_texture(ctx
, dims
,
1937 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
1940 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
1941 srcAddr
, srcPacking
);
1945 const GLubyte
*tempImage
= _mesa_make_temp_ubyte_image(ctx
, dims
,
1948 srcWidth
, srcHeight
, srcDepth
,
1949 srcFormat
, srcType
, srcAddr
,
1951 const GLubyte
*src
=tempImage
;
1952 GLint img
, row
, col
;
1955 for (img
= 0; img
< srcDepth
; img
++) {
1956 GLubyte
*dstRow
= (GLubyte
*) dstAddr
1957 + dstImageOffsets
[dstZoffset
+ img
] * texelBytes
1958 + dstYoffset
* dstRowStride
1959 + dstXoffset
* texelBytes
;
1960 for (row
= 0; row
< srcHeight
; row
++) {
1961 GLushort
*dstUS
= (GLushort
*) dstRow
;
1962 for (col
= 0; col
< srcWidth
; col
++) {
1963 dstUS
[col
] = PACK_COLOR_5551( src
[RCOMP
],
1969 dstRow
+= dstRowStride
;
1972 free((void *) tempImage
);
1978 _mesa_texstore_argb1555(TEXSTORE_PARAMS
)
1980 const GLuint texelBytes
= _mesa_get_format_bytes(dstFormat
);
1981 const GLenum baseFormat
= _mesa_get_format_base_format(dstFormat
);
1983 ASSERT(dstFormat
== MESA_FORMAT_ARGB1555
||
1984 dstFormat
== MESA_FORMAT_ARGB1555_REV
);
1985 ASSERT(texelBytes
== 2);
1987 if (!ctx
->_ImageTransferState
&&
1988 !srcPacking
->SwapBytes
&&
1989 dstFormat
== MESA_FORMAT_ARGB1555
&&
1990 baseInternalFormat
== GL_RGBA
&&
1991 srcFormat
== GL_BGRA
&&
1992 srcType
== GL_UNSIGNED_SHORT_1_5_5_5_REV
) {
1993 /* simple memcpy path */
1994 memcpy_texture(ctx
, dims
,
1995 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
1998 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
1999 srcAddr
, srcPacking
);
2003 const GLubyte
*tempImage
= _mesa_make_temp_ubyte_image(ctx
, dims
,
2006 srcWidth
, srcHeight
, srcDepth
,
2007 srcFormat
, srcType
, srcAddr
,
2009 const GLubyte
*src
=tempImage
;
2010 GLint img
, row
, col
;
2013 for (img
= 0; img
< srcDepth
; img
++) {
2014 GLubyte
*dstRow
= (GLubyte
*) dstAddr
2015 + dstImageOffsets
[dstZoffset
+ img
] * texelBytes
2016 + dstYoffset
* dstRowStride
2017 + dstXoffset
* texelBytes
;
2018 for (row
= 0; row
< srcHeight
; row
++) {
2019 GLushort
*dstUS
= (GLushort
*) dstRow
;
2020 if (dstFormat
== MESA_FORMAT_ARGB1555
) {
2021 for (col
= 0; col
< srcWidth
; col
++) {
2022 dstUS
[col
] = PACK_COLOR_1555( src
[ACOMP
],
2030 for (col
= 0; col
< srcWidth
; col
++) {
2031 dstUS
[col
] = PACK_COLOR_1555_REV( src
[ACOMP
],
2038 dstRow
+= dstRowStride
;
2041 free((void *) tempImage
);
2048 _mesa_texstore_argb2101010(TEXSTORE_PARAMS
)
2050 const GLuint texelBytes
= _mesa_get_format_bytes(dstFormat
);
2051 const GLenum baseFormat
= _mesa_get_format_base_format(dstFormat
);
2053 ASSERT(dstFormat
== MESA_FORMAT_ARGB2101010
);
2054 ASSERT(texelBytes
== 4);
2056 if (!ctx
->_ImageTransferState
&&
2057 !srcPacking
->SwapBytes
&&
2058 dstFormat
== MESA_FORMAT_ARGB2101010
&&
2059 srcFormat
== GL_BGRA
&&
2060 srcType
== GL_UNSIGNED_INT_2_10_10_10_REV
&&
2061 baseInternalFormat
== GL_RGBA
) {
2062 /* simple memcpy path */
2063 memcpy_texture(ctx
, dims
,
2064 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
2067 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
2068 srcAddr
, srcPacking
);
2072 const GLfloat
*tempImage
= _mesa_make_temp_float_image(ctx
, dims
,
2075 srcWidth
, srcHeight
, srcDepth
,
2076 srcFormat
, srcType
, srcAddr
,
2078 ctx
->_ImageTransferState
);
2079 const GLfloat
*src
= tempImage
;
2080 GLint img
, row
, col
;
2083 for (img
= 0; img
< srcDepth
; img
++) {
2084 GLubyte
*dstRow
= (GLubyte
*) dstAddr
2085 + dstImageOffsets
[dstZoffset
+ img
] * texelBytes
2086 + dstYoffset
* dstRowStride
2087 + dstXoffset
* texelBytes
;
2088 if (baseInternalFormat
== GL_RGBA
) {
2089 for (row
= 0; row
< srcHeight
; row
++) {
2090 GLuint
*dstUI
= (GLuint
*) dstRow
;
2091 for (col
= 0; col
< srcWidth
; col
++) {
2094 UNCLAMPED_FLOAT_TO_USHORT(a
, src
[ACOMP
]);
2095 UNCLAMPED_FLOAT_TO_USHORT(r
, src
[RCOMP
]);
2096 UNCLAMPED_FLOAT_TO_USHORT(g
, src
[GCOMP
]);
2097 UNCLAMPED_FLOAT_TO_USHORT(b
, src
[BCOMP
]);
2098 dstUI
[col
] = PACK_COLOR_2101010_US(a
, r
, g
, b
);
2101 dstRow
+= dstRowStride
;
2103 } else if (baseInternalFormat
== GL_RGB
) {
2104 for (row
= 0; row
< srcHeight
; row
++) {
2105 GLuint
*dstUI
= (GLuint
*) dstRow
;
2106 for (col
= 0; col
< srcWidth
; col
++) {
2109 UNCLAMPED_FLOAT_TO_USHORT(r
, src
[RCOMP
]);
2110 UNCLAMPED_FLOAT_TO_USHORT(g
, src
[GCOMP
]);
2111 UNCLAMPED_FLOAT_TO_USHORT(b
, src
[BCOMP
]);
2112 dstUI
[col
] = PACK_COLOR_2101010_US(0xffff, r
, g
, b
);
2115 dstRow
+= dstRowStride
;
2121 free((void *) tempImage
);
2128 * Do texstore for 2-channel, 4-bit/channel, unsigned normalized formats.
2131 _mesa_texstore_unorm44(TEXSTORE_PARAMS
)
2133 const GLuint texelBytes
= _mesa_get_format_bytes(dstFormat
);
2134 const GLenum baseFormat
= _mesa_get_format_base_format(dstFormat
);
2136 ASSERT(dstFormat
== MESA_FORMAT_AL44
);
2137 ASSERT(texelBytes
== 1);
2141 const GLubyte
*tempImage
= _mesa_make_temp_ubyte_image(ctx
, dims
,
2144 srcWidth
, srcHeight
, srcDepth
,
2145 srcFormat
, srcType
, srcAddr
,
2147 const GLubyte
*src
= tempImage
;
2148 GLint img
, row
, col
;
2151 for (img
= 0; img
< srcDepth
; img
++) {
2152 GLubyte
*dstRow
= (GLubyte
*) dstAddr
2153 + dstImageOffsets
[dstZoffset
+ img
] * texelBytes
2154 + dstYoffset
* dstRowStride
2155 + dstXoffset
* texelBytes
;
2156 for (row
= 0; row
< srcHeight
; row
++) {
2157 GLubyte
*dstUS
= (GLubyte
*) dstRow
;
2158 for (col
= 0; col
< srcWidth
; col
++) {
2159 /* src[0] is luminance, src[1] is alpha */
2160 dstUS
[col
] = PACK_COLOR_44( src
[1],
2164 dstRow
+= dstRowStride
;
2167 free((void *) tempImage
);
2174 * Do texstore for 2-channel, 8-bit/channel, unsigned normalized formats.
2177 _mesa_texstore_unorm88(TEXSTORE_PARAMS
)
2179 const GLboolean littleEndian
= _mesa_little_endian();
2180 const GLuint texelBytes
= _mesa_get_format_bytes(dstFormat
);
2181 const GLenum baseFormat
= _mesa_get_format_base_format(dstFormat
);
2183 ASSERT(dstFormat
== MESA_FORMAT_AL88
||
2184 dstFormat
== MESA_FORMAT_AL88_REV
||
2185 dstFormat
== MESA_FORMAT_RG88
||
2186 dstFormat
== MESA_FORMAT_RG88_REV
);
2187 ASSERT(texelBytes
== 2);
2189 if (!ctx
->_ImageTransferState
&&
2190 !srcPacking
->SwapBytes
&&
2191 ((dstFormat
== MESA_FORMAT_AL88
&&
2192 baseInternalFormat
== GL_LUMINANCE_ALPHA
&&
2193 srcFormat
== GL_LUMINANCE_ALPHA
) ||
2194 (dstFormat
== MESA_FORMAT_RG88
&&
2195 baseInternalFormat
== srcFormat
)) &&
2196 srcType
== GL_UNSIGNED_BYTE
&&
2198 /* simple memcpy path */
2199 memcpy_texture(ctx
, dims
,
2200 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
2203 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
2204 srcAddr
, srcPacking
);
2206 else if (!ctx
->_ImageTransferState
&&
2208 srcType
== GL_UNSIGNED_BYTE
&&
2209 can_swizzle(baseInternalFormat
) &&
2210 can_swizzle(srcFormat
)) {
2213 /* dstmap - how to swizzle from RGBA to dst format:
2215 if (dstFormat
== MESA_FORMAT_AL88
|| dstFormat
== MESA_FORMAT_AL88_REV
) {
2216 if ((littleEndian
&& dstFormat
== MESA_FORMAT_AL88
) ||
2217 (!littleEndian
&& dstFormat
== MESA_FORMAT_AL88_REV
)) {
2227 if ((littleEndian
&& dstFormat
== MESA_FORMAT_RG88
) ||
2228 (!littleEndian
&& dstFormat
== MESA_FORMAT_RG88_REV
)) {
2237 dstmap
[2] = ZERO
; /* ? */
2238 dstmap
[3] = ONE
; /* ? */
2240 _mesa_swizzle_ubyte_image(ctx
, dims
,
2245 dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
2246 dstRowStride
, dstImageOffsets
,
2247 srcWidth
, srcHeight
, srcDepth
, srcAddr
,
2252 const GLubyte
*tempImage
= _mesa_make_temp_ubyte_image(ctx
, dims
,
2255 srcWidth
, srcHeight
, srcDepth
,
2256 srcFormat
, srcType
, srcAddr
,
2258 const GLubyte
*src
= tempImage
;
2259 GLint img
, row
, col
;
2262 for (img
= 0; img
< srcDepth
; img
++) {
2263 GLubyte
*dstRow
= (GLubyte
*) dstAddr
2264 + dstImageOffsets
[dstZoffset
+ img
] * texelBytes
2265 + dstYoffset
* dstRowStride
2266 + dstXoffset
* texelBytes
;
2267 for (row
= 0; row
< srcHeight
; row
++) {
2268 GLushort
*dstUS
= (GLushort
*) dstRow
;
2269 if (dstFormat
== MESA_FORMAT_AL88
||
2270 dstFormat
== MESA_FORMAT_RG88
) {
2271 for (col
= 0; col
< srcWidth
; col
++) {
2272 /* src[0] is luminance, src[1] is alpha */
2273 dstUS
[col
] = PACK_COLOR_88( src
[1],
2279 for (col
= 0; col
< srcWidth
; col
++) {
2280 /* src[0] is luminance, src[1] is alpha */
2281 dstUS
[col
] = PACK_COLOR_88_REV( src
[1],
2286 dstRow
+= dstRowStride
;
2289 free((void *) tempImage
);
2296 * Do texstore for 2-channel, 16-bit/channel, unsigned normalized formats.
2299 _mesa_texstore_unorm1616(TEXSTORE_PARAMS
)
2301 const GLboolean littleEndian
= _mesa_little_endian();
2302 const GLuint texelBytes
= _mesa_get_format_bytes(dstFormat
);
2303 const GLenum baseFormat
= _mesa_get_format_base_format(dstFormat
);
2305 ASSERT(dstFormat
== MESA_FORMAT_AL1616
||
2306 dstFormat
== MESA_FORMAT_AL1616_REV
||
2307 dstFormat
== MESA_FORMAT_RG1616
||
2308 dstFormat
== MESA_FORMAT_RG1616_REV
);
2309 ASSERT(texelBytes
== 4);
2311 if (!ctx
->_ImageTransferState
&&
2312 !srcPacking
->SwapBytes
&&
2313 ((dstFormat
== MESA_FORMAT_AL1616
&&
2314 baseInternalFormat
== GL_LUMINANCE_ALPHA
&&
2315 srcFormat
== GL_LUMINANCE_ALPHA
) ||
2316 (dstFormat
== MESA_FORMAT_RG1616
&&
2317 baseInternalFormat
== srcFormat
)) &&
2318 srcType
== GL_UNSIGNED_SHORT
&&
2320 /* simple memcpy path */
2321 memcpy_texture(ctx
, dims
,
2322 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
2325 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
2326 srcAddr
, srcPacking
);
2330 const GLfloat
*tempImage
= _mesa_make_temp_float_image(ctx
, dims
,
2333 srcWidth
, srcHeight
, srcDepth
,
2334 srcFormat
, srcType
, srcAddr
,
2336 ctx
->_ImageTransferState
);
2337 const GLfloat
*src
= tempImage
;
2338 GLint img
, row
, col
;
2341 for (img
= 0; img
< srcDepth
; img
++) {
2342 GLubyte
*dstRow
= (GLubyte
*) dstAddr
2343 + dstImageOffsets
[dstZoffset
+ img
] * texelBytes
2344 + dstYoffset
* dstRowStride
2345 + dstXoffset
* texelBytes
;
2346 for (row
= 0; row
< srcHeight
; row
++) {
2347 GLuint
*dstUI
= (GLuint
*) dstRow
;
2348 if (dstFormat
== MESA_FORMAT_AL1616
||
2349 dstFormat
== MESA_FORMAT_RG1616
) {
2350 for (col
= 0; col
< srcWidth
; col
++) {
2353 UNCLAMPED_FLOAT_TO_USHORT(l
, src
[0]);
2354 UNCLAMPED_FLOAT_TO_USHORT(a
, src
[1]);
2355 dstUI
[col
] = PACK_COLOR_1616(a
, l
);
2360 for (col
= 0; col
< srcWidth
; col
++) {
2363 UNCLAMPED_FLOAT_TO_USHORT(l
, src
[0]);
2364 UNCLAMPED_FLOAT_TO_USHORT(a
, src
[1]);
2365 dstUI
[col
] = PACK_COLOR_1616_REV(a
, l
);
2369 dstRow
+= dstRowStride
;
2372 free((void *) tempImage
);
2378 /* Texstore for R16, A16, L16, I16. */
2380 _mesa_texstore_unorm16(TEXSTORE_PARAMS
)
2382 const GLboolean littleEndian
= _mesa_little_endian();
2383 const GLuint texelBytes
= _mesa_get_format_bytes(dstFormat
);
2384 const GLenum baseFormat
= _mesa_get_format_base_format(dstFormat
);
2386 ASSERT(dstFormat
== MESA_FORMAT_R16
||
2387 dstFormat
== MESA_FORMAT_A16
||
2388 dstFormat
== MESA_FORMAT_L16
||
2389 dstFormat
== MESA_FORMAT_I16
);
2390 ASSERT(texelBytes
== 2);
2392 if (!ctx
->_ImageTransferState
&&
2393 !srcPacking
->SwapBytes
&&
2394 baseInternalFormat
== srcFormat
&&
2395 srcType
== GL_UNSIGNED_SHORT
&&
2397 /* simple memcpy path */
2398 memcpy_texture(ctx
, dims
,
2399 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
2402 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
2403 srcAddr
, srcPacking
);
2407 const GLfloat
*tempImage
= _mesa_make_temp_float_image(ctx
, dims
,
2410 srcWidth
, srcHeight
, srcDepth
,
2411 srcFormat
, srcType
, srcAddr
,
2413 ctx
->_ImageTransferState
);
2414 const GLfloat
*src
= tempImage
;
2415 GLint img
, row
, col
;
2418 for (img
= 0; img
< srcDepth
; img
++) {
2419 GLubyte
*dstRow
= (GLubyte
*) dstAddr
2420 + dstImageOffsets
[dstZoffset
+ img
] * texelBytes
2421 + dstYoffset
* dstRowStride
2422 + dstXoffset
* texelBytes
;
2423 for (row
= 0; row
< srcHeight
; row
++) {
2424 GLushort
*dstUS
= (GLushort
*) dstRow
;
2425 for (col
= 0; col
< srcWidth
; col
++) {
2428 UNCLAMPED_FLOAT_TO_USHORT(r
, src
[0]);
2432 dstRow
+= dstRowStride
;
2435 free((void *) tempImage
);
2442 _mesa_texstore_rgba_16(TEXSTORE_PARAMS
)
2444 const GLuint texelBytes
= _mesa_get_format_bytes(dstFormat
);
2445 const GLenum baseFormat
= _mesa_get_format_base_format(dstFormat
);
2447 ASSERT(dstFormat
== MESA_FORMAT_RGBA_16
);
2448 ASSERT(texelBytes
== 8);
2450 if (!ctx
->_ImageTransferState
&&
2451 !srcPacking
->SwapBytes
&&
2452 baseInternalFormat
== GL_RGBA
&&
2453 srcFormat
== GL_RGBA
&&
2454 srcType
== GL_UNSIGNED_SHORT
) {
2455 /* simple memcpy path */
2456 memcpy_texture(ctx
, dims
,
2457 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
2460 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
2461 srcAddr
, srcPacking
);
2465 const GLfloat
*tempImage
= _mesa_make_temp_float_image(ctx
, dims
,
2468 srcWidth
, srcHeight
, srcDepth
,
2469 srcFormat
, srcType
, srcAddr
,
2471 ctx
->_ImageTransferState
);
2472 const GLfloat
*src
= tempImage
;
2473 GLint img
, row
, col
;
2476 for (img
= 0; img
< srcDepth
; img
++) {
2477 GLubyte
*dstRow
= (GLubyte
*) dstAddr
2478 + dstImageOffsets
[dstZoffset
+ img
] * texelBytes
2479 + dstYoffset
* dstRowStride
2480 + dstXoffset
* texelBytes
;
2481 for (row
= 0; row
< srcHeight
; row
++) {
2482 GLushort
*dstUS
= (GLushort
*) dstRow
;
2483 for (col
= 0; col
< srcWidth
; col
++) {
2484 GLushort r
, g
, b
, a
;
2486 UNCLAMPED_FLOAT_TO_USHORT(r
, src
[0]);
2487 UNCLAMPED_FLOAT_TO_USHORT(g
, src
[1]);
2488 UNCLAMPED_FLOAT_TO_USHORT(b
, src
[2]);
2489 UNCLAMPED_FLOAT_TO_USHORT(a
, src
[3]);
2496 dstRow
+= dstRowStride
;
2499 free((void *) tempImage
);
2506 _mesa_texstore_signed_rgba_16(TEXSTORE_PARAMS
)
2508 const GLuint texelBytes
= _mesa_get_format_bytes(dstFormat
);
2509 const GLenum baseFormat
= _mesa_get_format_base_format(dstFormat
);
2511 ASSERT(dstFormat
== MESA_FORMAT_SIGNED_RGB_16
||
2512 dstFormat
== MESA_FORMAT_SIGNED_RGBA_16
);
2514 if (!ctx
->_ImageTransferState
&&
2515 !srcPacking
->SwapBytes
&&
2516 baseInternalFormat
== GL_RGBA
&&
2517 dstFormat
== MESA_FORMAT_SIGNED_RGBA_16
&&
2518 srcFormat
== GL_RGBA
&&
2519 srcType
== GL_SHORT
) {
2520 /* simple memcpy path */
2521 memcpy_texture(ctx
, dims
,
2522 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
2525 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
2526 srcAddr
, srcPacking
);
2530 const GLfloat
*tempImage
= _mesa_make_temp_float_image(ctx
, dims
,
2533 srcWidth
, srcHeight
, srcDepth
,
2534 srcFormat
, srcType
, srcAddr
,
2536 ctx
->_ImageTransferState
);
2537 const GLfloat
*src
= tempImage
;
2538 const GLuint comps
= _mesa_get_format_bytes(dstFormat
) / 2;
2539 GLint img
, row
, col
;
2544 /* Note: tempImage is always float[4] / RGBA. We convert to 1, 2,
2545 * 3 or 4 components/pixel here.
2547 for (img
= 0; img
< srcDepth
; img
++) {
2548 GLubyte
*dstRow
= (GLubyte
*) dstAddr
2549 + dstImageOffsets
[dstZoffset
+ img
] * texelBytes
2550 + dstYoffset
* dstRowStride
2551 + dstXoffset
* texelBytes
;
2552 for (row
= 0; row
< srcHeight
; row
++) {
2553 GLshort
*dstRowS
= (GLshort
*) dstRow
;
2554 if (dstFormat
== MESA_FORMAT_SIGNED_RGBA_16
) {
2555 for (col
= 0; col
< srcWidth
; col
++) {
2557 for (c
= 0; c
< comps
; c
++) {
2559 UNCLAMPED_FLOAT_TO_SHORT(p
, src
[col
* 4 + c
]);
2560 dstRowS
[col
* comps
+ c
] = p
;
2563 dstRow
+= dstRowStride
;
2564 src
+= 4 * srcWidth
;
2566 for (col
= 0; col
< srcWidth
; col
++) {
2568 for (c
= 0; c
< comps
; c
++) {
2570 UNCLAMPED_FLOAT_TO_SHORT(p
, src
[col
* 3 + c
]);
2571 dstRowS
[col
* comps
+ c
] = p
;
2574 dstRow
+= dstRowStride
;
2575 src
+= 3 * srcWidth
;
2579 free((void *) tempImage
);
2586 _mesa_texstore_rgb332(TEXSTORE_PARAMS
)
2588 const GLuint texelBytes
= _mesa_get_format_bytes(dstFormat
);
2589 const GLenum baseFormat
= _mesa_get_format_base_format(dstFormat
);
2591 ASSERT(dstFormat
== MESA_FORMAT_RGB332
);
2592 ASSERT(texelBytes
== 1);
2594 if (!ctx
->_ImageTransferState
&&
2595 !srcPacking
->SwapBytes
&&
2596 baseInternalFormat
== GL_RGB
&&
2597 srcFormat
== GL_RGB
&& srcType
== GL_UNSIGNED_BYTE_3_3_2
) {
2598 /* simple memcpy path */
2599 memcpy_texture(ctx
, dims
,
2600 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
2603 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
2604 srcAddr
, srcPacking
);
2608 const GLubyte
*tempImage
= _mesa_make_temp_ubyte_image(ctx
, dims
,
2611 srcWidth
, srcHeight
, srcDepth
,
2612 srcFormat
, srcType
, srcAddr
,
2614 const GLubyte
*src
= tempImage
;
2615 GLint img
, row
, col
;
2618 for (img
= 0; img
< srcDepth
; img
++) {
2619 GLubyte
*dstRow
= (GLubyte
*) dstAddr
2620 + dstImageOffsets
[dstZoffset
+ img
] * texelBytes
2621 + dstYoffset
* dstRowStride
2622 + dstXoffset
* texelBytes
;
2623 for (row
= 0; row
< srcHeight
; row
++) {
2624 for (col
= 0; col
< srcWidth
; col
++) {
2625 dstRow
[col
] = PACK_COLOR_332( src
[RCOMP
],
2630 dstRow
+= dstRowStride
;
2633 free((void *) tempImage
);
2640 * Texstore for _mesa_texformat_a8, _mesa_texformat_l8, _mesa_texformat_i8.
2643 _mesa_texstore_unorm8(TEXSTORE_PARAMS
)
2645 const GLuint texelBytes
= _mesa_get_format_bytes(dstFormat
);
2646 const GLenum baseFormat
= _mesa_get_format_base_format(dstFormat
);
2648 ASSERT(dstFormat
== MESA_FORMAT_A8
||
2649 dstFormat
== MESA_FORMAT_L8
||
2650 dstFormat
== MESA_FORMAT_I8
||
2651 dstFormat
== MESA_FORMAT_R8
);
2652 ASSERT(texelBytes
== 1);
2654 if (!ctx
->_ImageTransferState
&&
2655 !srcPacking
->SwapBytes
&&
2656 baseInternalFormat
== srcFormat
&&
2657 srcType
== GL_UNSIGNED_BYTE
) {
2658 /* simple memcpy path */
2659 memcpy_texture(ctx
, dims
,
2660 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
2663 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
2664 srcAddr
, srcPacking
);
2666 else if (!ctx
->_ImageTransferState
&&
2667 srcType
== GL_UNSIGNED_BYTE
&&
2668 can_swizzle(baseInternalFormat
) &&
2669 can_swizzle(srcFormat
)) {
2672 /* dstmap - how to swizzle from RGBA to dst format:
2674 if (dstFormat
== MESA_FORMAT_A8
) {
2680 dstmap
[1] = ZERO
; /* ? */
2681 dstmap
[2] = ZERO
; /* ? */
2682 dstmap
[3] = ONE
; /* ? */
2684 _mesa_swizzle_ubyte_image(ctx
, dims
,
2689 dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
2690 dstRowStride
, dstImageOffsets
,
2691 srcWidth
, srcHeight
, srcDepth
, srcAddr
,
2696 const GLubyte
*tempImage
= _mesa_make_temp_ubyte_image(ctx
, dims
,
2699 srcWidth
, srcHeight
, srcDepth
,
2700 srcFormat
, srcType
, srcAddr
,
2702 const GLubyte
*src
= tempImage
;
2703 GLint img
, row
, col
;
2706 for (img
= 0; img
< srcDepth
; img
++) {
2707 GLubyte
*dstRow
= (GLubyte
*) dstAddr
2708 + dstImageOffsets
[dstZoffset
+ img
] * texelBytes
2709 + dstYoffset
* dstRowStride
2710 + dstXoffset
* texelBytes
;
2711 for (row
= 0; row
< srcHeight
; row
++) {
2712 for (col
= 0; col
< srcWidth
; col
++) {
2713 dstRow
[col
] = src
[col
];
2715 dstRow
+= dstRowStride
;
2719 free((void *) tempImage
);
2727 * Texstore for _mesa_texformat_ycbcr or _mesa_texformat_ycbcr_REV.
2730 _mesa_texstore_ycbcr(TEXSTORE_PARAMS
)
2732 const GLboolean littleEndian
= _mesa_little_endian();
2733 const GLuint texelBytes
= _mesa_get_format_bytes(dstFormat
);
2735 (void) ctx
; (void) dims
; (void) baseInternalFormat
;
2737 ASSERT((dstFormat
== MESA_FORMAT_YCBCR
) ||
2738 (dstFormat
== MESA_FORMAT_YCBCR_REV
));
2739 ASSERT(texelBytes
== 2);
2740 ASSERT(ctx
->Extensions
.MESA_ycbcr_texture
);
2741 ASSERT(srcFormat
== GL_YCBCR_MESA
);
2742 ASSERT((srcType
== GL_UNSIGNED_SHORT_8_8_MESA
) ||
2743 (srcType
== GL_UNSIGNED_SHORT_8_8_REV_MESA
));
2744 ASSERT(baseInternalFormat
== GL_YCBCR_MESA
);
2746 /* always just memcpy since no pixel transfer ops apply */
2747 memcpy_texture(ctx
, dims
,
2748 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
2751 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
2752 srcAddr
, srcPacking
);
2754 /* Check if we need byte swapping */
2755 /* XXX the logic here _might_ be wrong */
2756 if (srcPacking
->SwapBytes
^
2757 (srcType
== GL_UNSIGNED_SHORT_8_8_REV_MESA
) ^
2758 (dstFormat
== MESA_FORMAT_YCBCR_REV
) ^
2761 for (img
= 0; img
< srcDepth
; img
++) {
2762 GLubyte
*dstRow
= (GLubyte
*) dstAddr
2763 + dstImageOffsets
[dstZoffset
+ img
] * texelBytes
2764 + dstYoffset
* dstRowStride
2765 + dstXoffset
* texelBytes
;
2766 for (row
= 0; row
< srcHeight
; row
++) {
2767 _mesa_swap2((GLushort
*) dstRow
, srcWidth
);
2768 dstRow
+= dstRowStride
;
2776 _mesa_texstore_dudv8(TEXSTORE_PARAMS
)
2778 const GLboolean littleEndian
= _mesa_little_endian();
2779 const GLuint texelBytes
= _mesa_get_format_bytes(dstFormat
);
2781 ASSERT(dstFormat
== MESA_FORMAT_DUDV8
);
2782 ASSERT(texelBytes
== 2);
2783 ASSERT(ctx
->Extensions
.ATI_envmap_bumpmap
);
2784 ASSERT((srcFormat
== GL_DU8DV8_ATI
) ||
2785 (srcFormat
== GL_DUDV_ATI
));
2786 ASSERT(baseInternalFormat
== GL_DUDV_ATI
);
2788 if (!srcPacking
->SwapBytes
&& srcType
== GL_BYTE
&&
2790 /* simple memcpy path */
2791 memcpy_texture(ctx
, dims
,
2792 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
2795 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
2796 srcAddr
, srcPacking
);
2798 else if (srcType
== GL_BYTE
) {
2801 /* dstmap - how to swizzle from RGBA to dst format:
2811 dstmap
[2] = ZERO
; /* ? */
2812 dstmap
[3] = ONE
; /* ? */
2814 _mesa_swizzle_ubyte_image(ctx
, dims
,
2815 GL_LUMINANCE_ALPHA
, /* hack */
2816 GL_UNSIGNED_BYTE
, /* hack */
2817 GL_LUMINANCE_ALPHA
, /* hack */
2819 dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
2820 dstRowStride
, dstImageOffsets
,
2821 srcWidth
, srcHeight
, srcDepth
, srcAddr
,
2825 /* general path - note this is defined for 2d textures only */
2826 const GLint components
= _mesa_components_in_format(baseInternalFormat
);
2827 const GLint srcStride
= _mesa_image_row_stride(srcPacking
, srcWidth
,
2828 srcFormat
, srcType
);
2829 GLbyte
*tempImage
, *dst
, *src
;
2832 tempImage
= (GLbyte
*) malloc(srcWidth
* srcHeight
* srcDepth
2833 * components
* sizeof(GLbyte
));
2837 src
= (GLbyte
*) _mesa_image_address(dims
, srcPacking
, srcAddr
,
2838 srcWidth
, srcHeight
,
2843 for (row
= 0; row
< srcHeight
; row
++) {
2844 _mesa_unpack_dudv_span_byte(ctx
, srcWidth
, baseInternalFormat
,
2845 dst
, srcFormat
, srcType
, src
,
2847 dst
+= srcWidth
* components
;
2852 dst
= (GLbyte
*) dstAddr
2853 + dstYoffset
* dstRowStride
2854 + dstXoffset
* texelBytes
;
2855 for (row
= 0; row
< srcHeight
; row
++) {
2856 memcpy(dst
, src
, srcWidth
* texelBytes
);
2857 dst
+= dstRowStride
;
2858 src
+= srcWidth
* texelBytes
;
2860 free((void *) tempImage
);
2867 * Store a texture in a signed normalized 8-bit format.
2870 _mesa_texstore_snorm8(TEXSTORE_PARAMS
)
2872 const GLuint texelBytes
= _mesa_get_format_bytes(dstFormat
);
2873 const GLenum baseFormat
= _mesa_get_format_base_format(dstFormat
);
2875 ASSERT(dstFormat
== MESA_FORMAT_SIGNED_A8
||
2876 dstFormat
== MESA_FORMAT_SIGNED_L8
||
2877 dstFormat
== MESA_FORMAT_SIGNED_I8
||
2878 dstFormat
== MESA_FORMAT_SIGNED_R8
);
2879 ASSERT(texelBytes
== 1);
2881 if (!ctx
->_ImageTransferState
&&
2882 !srcPacking
->SwapBytes
&&
2883 baseInternalFormat
== srcFormat
&&
2884 srcType
== GL_BYTE
) {
2885 /* simple memcpy path */
2886 memcpy_texture(ctx
, dims
,
2887 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
2890 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
2891 srcAddr
, srcPacking
);
2895 const GLfloat
*tempImage
= _mesa_make_temp_float_image(ctx
, dims
,
2898 srcWidth
, srcHeight
, srcDepth
,
2899 srcFormat
, srcType
, srcAddr
,
2901 ctx
->_ImageTransferState
);
2902 const GLfloat
*src
= tempImage
;
2903 GLint img
, row
, col
;
2906 for (img
= 0; img
< srcDepth
; img
++) {
2907 GLbyte
*dstRow
= (GLbyte
*) dstAddr
2908 + dstImageOffsets
[dstZoffset
+ img
] * texelBytes
2909 + dstYoffset
* dstRowStride
2910 + dstXoffset
* texelBytes
;
2911 for (row
= 0; row
< srcHeight
; row
++) {
2912 for (col
= 0; col
< srcWidth
; col
++) {
2913 dstRow
[col
] = FLOAT_TO_BYTE_TEX(src
[col
]);
2915 dstRow
+= dstRowStride
;
2919 free((void *) tempImage
);
2926 * Store a texture in a signed normalized two-channel 16-bit format.
2929 _mesa_texstore_snorm88(TEXSTORE_PARAMS
)
2931 const GLboolean littleEndian
= _mesa_little_endian();
2932 const GLuint texelBytes
= _mesa_get_format_bytes(dstFormat
);
2933 const GLenum baseFormat
= _mesa_get_format_base_format(dstFormat
);
2935 ASSERT(dstFormat
== MESA_FORMAT_SIGNED_AL88
||
2936 dstFormat
== MESA_FORMAT_SIGNED_RG88_REV
);
2937 ASSERT(texelBytes
== 2);
2939 if (!ctx
->_ImageTransferState
&&
2940 !srcPacking
->SwapBytes
&&
2941 baseInternalFormat
== srcFormat
&&
2942 srcType
== GL_BYTE
&&
2944 /* simple memcpy path */
2945 memcpy_texture(ctx
, dims
,
2946 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
2949 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
2950 srcAddr
, srcPacking
);
2954 const GLfloat
*tempImage
= _mesa_make_temp_float_image(ctx
, dims
,
2957 srcWidth
, srcHeight
, srcDepth
,
2958 srcFormat
, srcType
, srcAddr
,
2960 ctx
->_ImageTransferState
);
2961 const GLfloat
*src
= tempImage
;
2962 GLint img
, row
, col
;
2965 for (img
= 0; img
< srcDepth
; img
++) {
2966 GLbyte
*dstRow
= (GLbyte
*) dstAddr
2967 + dstImageOffsets
[dstZoffset
+ img
] * texelBytes
2968 + dstYoffset
* dstRowStride
2969 + dstXoffset
* texelBytes
;
2970 for (row
= 0; row
< srcHeight
; row
++) {
2971 GLbyte
*dst
= dstRow
;
2972 for (col
= 0; col
< srcWidth
; col
++) {
2973 dst
[0] = FLOAT_TO_BYTE_TEX(src
[0]);
2974 dst
[1] = FLOAT_TO_BYTE_TEX(src
[1]);
2978 dstRow
+= dstRowStride
;
2981 free((void *) tempImage
);
2986 /* Texstore for signed R16, A16, L16, I16. */
2988 _mesa_texstore_snorm16(TEXSTORE_PARAMS
)
2990 const GLboolean littleEndian
= _mesa_little_endian();
2991 const GLuint texelBytes
= _mesa_get_format_bytes(dstFormat
);
2992 const GLenum baseFormat
= _mesa_get_format_base_format(dstFormat
);
2994 ASSERT(dstFormat
== MESA_FORMAT_SIGNED_R16
||
2995 dstFormat
== MESA_FORMAT_SIGNED_A16
||
2996 dstFormat
== MESA_FORMAT_SIGNED_L16
||
2997 dstFormat
== MESA_FORMAT_SIGNED_I16
);
2998 ASSERT(texelBytes
== 2);
3000 if (!ctx
->_ImageTransferState
&&
3001 !srcPacking
->SwapBytes
&&
3002 baseInternalFormat
== srcFormat
&&
3003 srcType
== GL_SHORT
&&
3005 /* simple memcpy path */
3006 memcpy_texture(ctx
, dims
,
3007 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
3010 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
3011 srcAddr
, srcPacking
);
3015 const GLfloat
*tempImage
= _mesa_make_temp_float_image(ctx
, dims
,
3018 srcWidth
, srcHeight
, srcDepth
,
3019 srcFormat
, srcType
, srcAddr
,
3021 ctx
->_ImageTransferState
);
3022 const GLfloat
*src
= tempImage
;
3023 GLint img
, row
, col
;
3026 for (img
= 0; img
< srcDepth
; img
++) {
3027 GLubyte
*dstRow
= (GLubyte
*) dstAddr
3028 + dstImageOffsets
[dstZoffset
+ img
] * texelBytes
3029 + dstYoffset
* dstRowStride
3030 + dstXoffset
* texelBytes
;
3031 for (row
= 0; row
< srcHeight
; row
++) {
3032 GLshort
*dstUS
= (GLshort
*) dstRow
;
3033 for (col
= 0; col
< srcWidth
; col
++) {
3036 UNCLAMPED_FLOAT_TO_SHORT(r
, src
[0]);
3040 dstRow
+= dstRowStride
;
3043 free((void *) tempImage
);
3049 * Do texstore for 2-channel, 16-bit/channel, signed normalized formats.
3052 _mesa_texstore_snorm1616(TEXSTORE_PARAMS
)
3054 const GLboolean littleEndian
= _mesa_little_endian();
3055 const GLuint texelBytes
= _mesa_get_format_bytes(dstFormat
);
3056 const GLenum baseFormat
= _mesa_get_format_base_format(dstFormat
);
3058 ASSERT(dstFormat
== MESA_FORMAT_SIGNED_AL1616
||
3059 dstFormat
== MESA_FORMAT_SIGNED_GR1616
);
3060 ASSERT(texelBytes
== 4);
3062 if (!ctx
->_ImageTransferState
&&
3063 !srcPacking
->SwapBytes
&&
3064 baseInternalFormat
== srcFormat
&&
3065 srcType
== GL_SHORT
&&
3067 /* simple memcpy path */
3068 memcpy_texture(ctx
, dims
,
3069 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
3072 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
3073 srcAddr
, srcPacking
);
3077 const GLfloat
*tempImage
= _mesa_make_temp_float_image(ctx
, dims
,
3080 srcWidth
, srcHeight
, srcDepth
,
3081 srcFormat
, srcType
, srcAddr
,
3083 ctx
->_ImageTransferState
);
3084 const GLfloat
*src
= tempImage
;
3085 GLint img
, row
, col
;
3088 for (img
= 0; img
< srcDepth
; img
++) {
3089 GLubyte
*dstRow
= (GLubyte
*) dstAddr
3090 + dstImageOffsets
[dstZoffset
+ img
] * texelBytes
3091 + dstYoffset
* dstRowStride
3092 + dstXoffset
* texelBytes
;
3093 for (row
= 0; row
< srcHeight
; row
++) {
3094 GLshort
*dst
= (GLshort
*) dstRow
;
3095 for (col
= 0; col
< srcWidth
; col
++) {
3098 UNCLAMPED_FLOAT_TO_SHORT(l
, src
[0]);
3099 UNCLAMPED_FLOAT_TO_SHORT(a
, src
[1]);
3105 dstRow
+= dstRowStride
;
3108 free((void *) tempImage
);
3114 * Store a texture in MESA_FORMAT_SIGNED_RGBX8888.
3117 _mesa_texstore_signed_rgbx8888(TEXSTORE_PARAMS
)
3119 const GLuint texelBytes
= _mesa_get_format_bytes(dstFormat
);
3120 const GLenum baseFormat
= _mesa_get_format_base_format(dstFormat
);
3122 ASSERT(dstFormat
== MESA_FORMAT_SIGNED_RGBX8888
);
3123 ASSERT(texelBytes
== 4);
3127 const GLfloat
*tempImage
= _mesa_make_temp_float_image(ctx
, dims
,
3130 srcWidth
, srcHeight
, srcDepth
,
3131 srcFormat
, srcType
, srcAddr
,
3133 ctx
->_ImageTransferState
);
3134 const GLfloat
*srcRow
= tempImage
;
3135 GLint img
, row
, col
;
3138 for (img
= 0; img
< srcDepth
; img
++) {
3139 GLbyte
*dstRow
= (GLbyte
*) dstAddr
3140 + dstImageOffsets
[dstZoffset
+ img
] * texelBytes
3141 + dstYoffset
* dstRowStride
3142 + dstXoffset
* texelBytes
;
3143 for (row
= 0; row
< srcHeight
; row
++) {
3144 GLbyte
*dst
= dstRow
;
3145 for (col
= 0; col
< srcWidth
; col
++) {
3146 dst
[3] = FLOAT_TO_BYTE_TEX(srcRow
[RCOMP
]);
3147 dst
[2] = FLOAT_TO_BYTE_TEX(srcRow
[GCOMP
]);
3148 dst
[1] = FLOAT_TO_BYTE_TEX(srcRow
[BCOMP
]);
3153 dstRow
+= dstRowStride
;
3156 free((void *) tempImage
);
3164 * Store a texture in MESA_FORMAT_SIGNED_RGBA8888 or
3165 * MESA_FORMAT_SIGNED_RGBA8888_REV
3168 _mesa_texstore_signed_rgba8888(TEXSTORE_PARAMS
)
3170 const GLboolean littleEndian
= _mesa_little_endian();
3171 const GLuint texelBytes
= _mesa_get_format_bytes(dstFormat
);
3172 const GLenum baseFormat
= _mesa_get_format_base_format(dstFormat
);
3174 ASSERT(dstFormat
== MESA_FORMAT_SIGNED_RGBA8888
||
3175 dstFormat
== MESA_FORMAT_SIGNED_RGBA8888_REV
);
3176 ASSERT(texelBytes
== 4);
3178 if (!ctx
->_ImageTransferState
&&
3179 !srcPacking
->SwapBytes
&&
3180 dstFormat
== MESA_FORMAT_SIGNED_RGBA8888
&&
3181 baseInternalFormat
== GL_RGBA
&&
3182 ((srcFormat
== GL_RGBA
&& srcType
== GL_BYTE
&& !littleEndian
) ||
3183 (srcFormat
== GL_ABGR_EXT
&& srcType
== GL_BYTE
&& littleEndian
))) {
3184 /* simple memcpy path */
3185 memcpy_texture(ctx
, dims
,
3186 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
3189 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
3190 srcAddr
, srcPacking
);
3192 else if (!ctx
->_ImageTransferState
&&
3193 !srcPacking
->SwapBytes
&&
3194 dstFormat
== MESA_FORMAT_SIGNED_RGBA8888_REV
&&
3195 baseInternalFormat
== GL_RGBA
&&
3196 ((srcFormat
== GL_RGBA
&& srcType
== GL_BYTE
&& littleEndian
) ||
3197 (srcFormat
== GL_ABGR_EXT
&& srcType
== GL_BYTE
&& !littleEndian
))) {
3198 /* simple memcpy path */
3199 memcpy_texture(ctx
, dims
,
3200 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
3203 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
3204 srcAddr
, srcPacking
);
3208 const GLfloat
*tempImage
= _mesa_make_temp_float_image(ctx
, dims
,
3211 srcWidth
, srcHeight
, srcDepth
,
3212 srcFormat
, srcType
, srcAddr
,
3214 ctx
->_ImageTransferState
);
3215 const GLfloat
*srcRow
= tempImage
;
3216 GLint img
, row
, col
;
3219 for (img
= 0; img
< srcDepth
; img
++) {
3220 GLbyte
*dstRow
= (GLbyte
*) dstAddr
3221 + dstImageOffsets
[dstZoffset
+ img
] * texelBytes
3222 + dstYoffset
* dstRowStride
3223 + dstXoffset
* texelBytes
;
3224 for (row
= 0; row
< srcHeight
; row
++) {
3225 GLbyte
*dst
= dstRow
;
3226 if (dstFormat
== MESA_FORMAT_SIGNED_RGBA8888
) {
3227 for (col
= 0; col
< srcWidth
; col
++) {
3228 dst
[3] = FLOAT_TO_BYTE_TEX(srcRow
[RCOMP
]);
3229 dst
[2] = FLOAT_TO_BYTE_TEX(srcRow
[GCOMP
]);
3230 dst
[1] = FLOAT_TO_BYTE_TEX(srcRow
[BCOMP
]);
3231 dst
[0] = FLOAT_TO_BYTE_TEX(srcRow
[ACOMP
]);
3237 for (col
= 0; col
< srcWidth
; col
++) {
3238 dst
[0] = FLOAT_TO_BYTE_TEX(srcRow
[RCOMP
]);
3239 dst
[1] = FLOAT_TO_BYTE_TEX(srcRow
[GCOMP
]);
3240 dst
[2] = FLOAT_TO_BYTE_TEX(srcRow
[BCOMP
]);
3241 dst
[3] = FLOAT_TO_BYTE_TEX(srcRow
[ACOMP
]);
3246 dstRow
+= dstRowStride
;
3249 free((void *) tempImage
);
3256 * Store a combined depth/stencil texture image.
3259 _mesa_texstore_z24_s8(TEXSTORE_PARAMS
)
3261 const GLuint depthScale
= 0xffffff;
3262 const GLint srcRowStride
3263 = _mesa_image_row_stride(srcPacking
, srcWidth
, srcFormat
, srcType
);
3266 ASSERT(dstFormat
== MESA_FORMAT_Z24_S8
);
3267 ASSERT(srcFormat
== GL_DEPTH_STENCIL_EXT
||
3268 srcFormat
== GL_DEPTH_COMPONENT
||
3269 srcFormat
== GL_STENCIL_INDEX
);
3270 ASSERT(srcFormat
!= GL_DEPTH_STENCIL_EXT
|| srcType
== GL_UNSIGNED_INT_24_8_EXT
);
3272 if (srcFormat
== GL_DEPTH_STENCIL
&& ctx
->Pixel
.DepthScale
== 1.0f
&&
3273 ctx
->Pixel
.DepthBias
== 0.0f
&&
3274 !srcPacking
->SwapBytes
) {
3276 memcpy_texture(ctx
, dims
,
3277 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
3280 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
3281 srcAddr
, srcPacking
);
3283 else if (srcFormat
== GL_DEPTH_COMPONENT
||
3284 srcFormat
== GL_STENCIL_INDEX
) {
3285 /* In case we only upload depth we need to preserve the stencil */
3286 for (img
= 0; img
< srcDepth
; img
++) {
3287 GLuint
*dstRow
= (GLuint
*) dstAddr
3288 + dstImageOffsets
[dstZoffset
+ img
]
3289 + dstYoffset
* dstRowStride
/ sizeof(GLuint
)
3292 = (const GLubyte
*) _mesa_image_address(dims
, srcPacking
, srcAddr
,
3293 srcWidth
, srcHeight
,
3296 for (row
= 0; row
< srcHeight
; row
++) {
3297 GLuint depth
[MAX_WIDTH
];
3298 GLubyte stencil
[MAX_WIDTH
];
3300 GLboolean keepdepth
= GL_FALSE
, keepstencil
= GL_FALSE
;
3302 if (srcFormat
== GL_DEPTH_COMPONENT
) { /* preserve stencil */
3303 keepstencil
= GL_TRUE
;
3305 else if (srcFormat
== GL_STENCIL_INDEX
) { /* preserve depth */
3306 keepdepth
= GL_TRUE
;
3309 if (keepdepth
== GL_FALSE
)
3310 /* the 24 depth bits will be in the low position: */
3311 _mesa_unpack_depth_span(ctx
, srcWidth
,
3312 GL_UNSIGNED_INT
, /* dst type */
3313 keepstencil
? depth
: dstRow
, /* dst addr */
3315 srcType
, src
, srcPacking
);
3317 if (keepstencil
== GL_FALSE
)
3318 /* get the 8-bit stencil values */
3319 _mesa_unpack_stencil_span(ctx
, srcWidth
,
3320 GL_UNSIGNED_BYTE
, /* dst type */
3321 stencil
, /* dst addr */
3322 srcType
, src
, srcPacking
,
3323 ctx
->_ImageTransferState
);
3325 for (i
= 0; i
< srcWidth
; i
++) {
3327 dstRow
[i
] = depth
[i
] << 8 | (dstRow
[i
] & 0x000000FF);
3329 dstRow
[i
] = (dstRow
[i
] & 0xFFFFFF00) | (stencil
[i
] & 0xFF);
3332 src
+= srcRowStride
;
3333 dstRow
+= dstRowStride
/ sizeof(GLuint
);
3342 * Store a combined depth/stencil texture image.
3345 _mesa_texstore_s8_z24(TEXSTORE_PARAMS
)
3347 const GLuint depthScale
= 0xffffff;
3348 const GLint srcRowStride
3349 = _mesa_image_row_stride(srcPacking
, srcWidth
, srcFormat
, srcType
);
3352 ASSERT(dstFormat
== MESA_FORMAT_S8_Z24
);
3353 ASSERT(srcFormat
== GL_DEPTH_STENCIL_EXT
||
3354 srcFormat
== GL_DEPTH_COMPONENT
||
3355 srcFormat
== GL_STENCIL_INDEX
);
3356 ASSERT(srcFormat
!= GL_DEPTH_STENCIL_EXT
||
3357 srcType
== GL_UNSIGNED_INT_24_8_EXT
);
3359 for (img
= 0; img
< srcDepth
; img
++) {
3360 GLuint
*dstRow
= (GLuint
*) dstAddr
3361 + dstImageOffsets
[dstZoffset
+ img
]
3362 + dstYoffset
* dstRowStride
/ sizeof(GLuint
)
3365 = (const GLubyte
*) _mesa_image_address(dims
, srcPacking
, srcAddr
,
3366 srcWidth
, srcHeight
,
3369 for (row
= 0; row
< srcHeight
; row
++) {
3370 GLuint depth
[MAX_WIDTH
];
3371 GLubyte stencil
[MAX_WIDTH
];
3373 GLboolean keepdepth
= GL_FALSE
, keepstencil
= GL_FALSE
;
3375 if (srcFormat
== GL_DEPTH_COMPONENT
) { /* preserve stencil */
3376 keepstencil
= GL_TRUE
;
3378 else if (srcFormat
== GL_STENCIL_INDEX
) { /* preserve depth */
3379 keepdepth
= GL_TRUE
;
3382 if (keepdepth
== GL_FALSE
)
3383 /* the 24 depth bits will be in the low position: */
3384 _mesa_unpack_depth_span(ctx
, srcWidth
,
3385 GL_UNSIGNED_INT
, /* dst type */
3386 keepstencil
? depth
: dstRow
, /* dst addr */
3388 srcType
, src
, srcPacking
);
3390 if (keepstencil
== GL_FALSE
)
3391 /* get the 8-bit stencil values */
3392 _mesa_unpack_stencil_span(ctx
, srcWidth
,
3393 GL_UNSIGNED_BYTE
, /* dst type */
3394 stencil
, /* dst addr */
3395 srcType
, src
, srcPacking
,
3396 ctx
->_ImageTransferState
);
3398 /* merge stencil values into depth values */
3399 for (i
= 0; i
< srcWidth
; i
++) {
3401 dstRow
[i
] = depth
[i
] | (dstRow
[i
] & 0xFF000000);
3403 dstRow
[i
] = (dstRow
[i
] & 0xFFFFFF) | (stencil
[i
] << 24);
3406 src
+= srcRowStride
;
3407 dstRow
+= dstRowStride
/ sizeof(GLuint
);
3415 * Store simple 8-bit/value stencil texture data.
3418 _mesa_texstore_s8(TEXSTORE_PARAMS
)
3420 ASSERT(dstFormat
== MESA_FORMAT_S8
);
3421 ASSERT(srcFormat
== GL_STENCIL_INDEX
);
3423 if (!ctx
->_ImageTransferState
&&
3424 !srcPacking
->SwapBytes
&&
3425 baseInternalFormat
== srcFormat
&&
3426 srcType
== GL_UNSIGNED_BYTE
) {
3427 /* simple memcpy path */
3428 memcpy_texture(ctx
, dims
,
3429 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
3432 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
3433 srcAddr
, srcPacking
);
3436 const GLint srcRowStride
3437 = _mesa_image_row_stride(srcPacking
, srcWidth
, srcFormat
, srcType
);
3440 for (img
= 0; img
< srcDepth
; img
++) {
3441 GLubyte
*dstRow
= (GLubyte
*) dstAddr
3442 + dstImageOffsets
[dstZoffset
+ img
]
3443 + dstYoffset
* dstRowStride
/ sizeof(GLuint
)
3446 = (const GLubyte
*) _mesa_image_address(dims
, srcPacking
, srcAddr
,
3447 srcWidth
, srcHeight
,
3450 for (row
= 0; row
< srcHeight
; row
++) {
3451 GLubyte stencil
[MAX_WIDTH
];
3454 /* get the 8-bit stencil values */
3455 _mesa_unpack_stencil_span(ctx
, srcWidth
,
3456 GL_UNSIGNED_BYTE
, /* dst type */
3457 stencil
, /* dst addr */
3458 srcType
, src
, srcPacking
,
3459 ctx
->_ImageTransferState
);
3460 /* merge stencil values into depth values */
3461 for (i
= 0; i
< srcWidth
; i
++)
3462 dstRow
[i
] = stencil
[i
];
3464 src
+= srcRowStride
;
3465 dstRow
+= dstRowStride
/ sizeof(GLubyte
);
3476 * Store an image in any of the formats:
3477 * _mesa_texformat_rgba_float32
3478 * _mesa_texformat_rgb_float32
3479 * _mesa_texformat_alpha_float32
3480 * _mesa_texformat_luminance_float32
3481 * _mesa_texformat_luminance_alpha_float32
3482 * _mesa_texformat_intensity_float32
3485 _mesa_texstore_rgba_float32(TEXSTORE_PARAMS
)
3487 const GLuint texelBytes
= _mesa_get_format_bytes(dstFormat
);
3488 const GLenum baseFormat
= _mesa_get_format_base_format(dstFormat
);
3489 const GLint components
= _mesa_components_in_format(baseFormat
);
3491 ASSERT(dstFormat
== MESA_FORMAT_RGBA_FLOAT32
||
3492 dstFormat
== MESA_FORMAT_RGB_FLOAT32
||
3493 dstFormat
== MESA_FORMAT_ALPHA_FLOAT32
||
3494 dstFormat
== MESA_FORMAT_LUMINANCE_FLOAT32
||
3495 dstFormat
== MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32
||
3496 dstFormat
== MESA_FORMAT_INTENSITY_FLOAT32
||
3497 dstFormat
== MESA_FORMAT_R_FLOAT32
||
3498 dstFormat
== MESA_FORMAT_RG_FLOAT32
);
3499 ASSERT(baseInternalFormat
== GL_RGBA
||
3500 baseInternalFormat
== GL_RGB
||
3501 baseInternalFormat
== GL_ALPHA
||
3502 baseInternalFormat
== GL_LUMINANCE
||
3503 baseInternalFormat
== GL_LUMINANCE_ALPHA
||
3504 baseInternalFormat
== GL_INTENSITY
||
3505 baseInternalFormat
== GL_RED
||
3506 baseInternalFormat
== GL_RG
);
3507 ASSERT(texelBytes
== components
* sizeof(GLfloat
));
3509 if (!ctx
->_ImageTransferState
&&
3510 !srcPacking
->SwapBytes
&&
3511 baseInternalFormat
== srcFormat
&&
3512 baseInternalFormat
== baseFormat
&&
3513 srcType
== GL_FLOAT
) {
3514 /* simple memcpy path */
3515 memcpy_texture(ctx
, dims
,
3516 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
3519 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
3520 srcAddr
, srcPacking
);
3524 const GLfloat
*tempImage
= _mesa_make_temp_float_image(ctx
, dims
,
3527 srcWidth
, srcHeight
, srcDepth
,
3528 srcFormat
, srcType
, srcAddr
,
3530 ctx
->_ImageTransferState
);
3531 const GLfloat
*srcRow
= tempImage
;
3536 bytesPerRow
= srcWidth
* components
* sizeof(GLfloat
);
3537 for (img
= 0; img
< srcDepth
; img
++) {
3538 GLubyte
*dstRow
= (GLubyte
*) dstAddr
3539 + dstImageOffsets
[dstZoffset
+ img
] * texelBytes
3540 + dstYoffset
* dstRowStride
3541 + dstXoffset
* texelBytes
;
3542 for (row
= 0; row
< srcHeight
; row
++) {
3543 memcpy(dstRow
, srcRow
, bytesPerRow
);
3544 dstRow
+= dstRowStride
;
3545 srcRow
+= srcWidth
* components
;
3549 free((void *) tempImage
);
3557 * As above, but store 16-bit floats.
3560 _mesa_texstore_rgba_float16(TEXSTORE_PARAMS
)
3562 const GLuint texelBytes
= _mesa_get_format_bytes(dstFormat
);
3563 const GLenum baseFormat
= _mesa_get_format_base_format(dstFormat
);
3564 const GLint components
= _mesa_components_in_format(baseFormat
);
3566 ASSERT(dstFormat
== MESA_FORMAT_RGBA_FLOAT16
||
3567 dstFormat
== MESA_FORMAT_RGB_FLOAT16
||
3568 dstFormat
== MESA_FORMAT_ALPHA_FLOAT16
||
3569 dstFormat
== MESA_FORMAT_LUMINANCE_FLOAT16
||
3570 dstFormat
== MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16
||
3571 dstFormat
== MESA_FORMAT_INTENSITY_FLOAT16
||
3572 dstFormat
== MESA_FORMAT_R_FLOAT16
||
3573 dstFormat
== MESA_FORMAT_RG_FLOAT16
);
3574 ASSERT(baseInternalFormat
== GL_RGBA
||
3575 baseInternalFormat
== GL_RGB
||
3576 baseInternalFormat
== GL_ALPHA
||
3577 baseInternalFormat
== GL_LUMINANCE
||
3578 baseInternalFormat
== GL_LUMINANCE_ALPHA
||
3579 baseInternalFormat
== GL_INTENSITY
||
3580 baseInternalFormat
== GL_RED
||
3581 baseInternalFormat
== GL_RG
);
3582 ASSERT(texelBytes
== components
* sizeof(GLhalfARB
));
3584 if (!ctx
->_ImageTransferState
&&
3585 !srcPacking
->SwapBytes
&&
3586 baseInternalFormat
== srcFormat
&&
3587 baseInternalFormat
== baseFormat
&&
3588 srcType
== GL_HALF_FLOAT_ARB
) {
3589 /* simple memcpy path */
3590 memcpy_texture(ctx
, dims
,
3591 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
3594 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
3595 srcAddr
, srcPacking
);
3599 const GLfloat
*tempImage
= _mesa_make_temp_float_image(ctx
, dims
,
3602 srcWidth
, srcHeight
, srcDepth
,
3603 srcFormat
, srcType
, srcAddr
,
3605 ctx
->_ImageTransferState
);
3606 const GLfloat
*src
= tempImage
;
3610 for (img
= 0; img
< srcDepth
; img
++) {
3611 GLubyte
*dstRow
= (GLubyte
*) dstAddr
3612 + dstImageOffsets
[dstZoffset
+ img
] * texelBytes
3613 + dstYoffset
* dstRowStride
3614 + dstXoffset
* texelBytes
;
3615 for (row
= 0; row
< srcHeight
; row
++) {
3616 GLhalfARB
*dstTexel
= (GLhalfARB
*) dstRow
;
3618 for (i
= 0; i
< srcWidth
* components
; i
++) {
3619 dstTexel
[i
] = _mesa_float_to_half(src
[i
]);
3621 dstRow
+= dstRowStride
;
3622 src
+= srcWidth
* components
;
3626 free((void *) tempImage
);
3632 /* non-normalized, signed int8 */
3634 _mesa_texstore_rgba_int8(TEXSTORE_PARAMS
)
3636 const GLuint texelBytes
= _mesa_get_format_bytes(dstFormat
);
3637 const GLenum baseFormat
= _mesa_get_format_base_format(dstFormat
);
3638 const GLint components
= _mesa_components_in_format(baseFormat
);
3640 ASSERT(dstFormat
== MESA_FORMAT_R_INT8
||
3641 dstFormat
== MESA_FORMAT_RG_INT8
||
3642 dstFormat
== MESA_FORMAT_RGB_INT8
||
3643 dstFormat
== MESA_FORMAT_RGBA_INT8
||
3644 dstFormat
== MESA_FORMAT_ALPHA_INT8
||
3645 dstFormat
== MESA_FORMAT_INTENSITY_INT8
||
3646 dstFormat
== MESA_FORMAT_LUMINANCE_INT8
||
3647 dstFormat
== MESA_FORMAT_LUMINANCE_ALPHA_INT8
);
3648 ASSERT(baseInternalFormat
== GL_RGBA
||
3649 baseInternalFormat
== GL_RGB
||
3650 baseInternalFormat
== GL_ALPHA
||
3651 baseInternalFormat
== GL_LUMINANCE
||
3652 baseInternalFormat
== GL_LUMINANCE_ALPHA
||
3653 baseInternalFormat
== GL_INTENSITY
);
3654 ASSERT(texelBytes
== components
* sizeof(GLbyte
));
3656 /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply
3657 * to integer formats.
3659 if (!srcPacking
->SwapBytes
&&
3660 baseInternalFormat
== srcFormat
&&
3661 srcType
== GL_BYTE
) {
3662 /* simple memcpy path */
3663 memcpy_texture(ctx
, dims
,
3664 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
3667 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
3668 srcAddr
, srcPacking
);
3672 const GLfloat
*tempImage
= _mesa_make_temp_float_image(ctx
, dims
,
3675 srcWidth
, srcHeight
, srcDepth
,
3676 srcFormat
, srcType
, srcAddr
,
3678 const GLfloat
*src
= tempImage
;
3682 for (img
= 0; img
< srcDepth
; img
++) {
3683 GLubyte
*dstRow
= (GLubyte
*) dstAddr
3684 + dstImageOffsets
[dstZoffset
+ img
] * texelBytes
3685 + dstYoffset
* dstRowStride
3686 + dstXoffset
* texelBytes
;
3687 for (row
= 0; row
< srcHeight
; row
++) {
3688 GLbyte
*dstTexel
= (GLbyte
*) dstRow
;
3690 for (i
= 0; i
< srcWidth
* components
; i
++) {
3691 dstTexel
[i
] = (GLbyte
) src
[i
];
3693 dstRow
+= dstRowStride
;
3694 src
+= srcWidth
* components
;
3698 free((void *) tempImage
);
3704 /* non-normalized, signed int16 */
3706 _mesa_texstore_rgba_int16(TEXSTORE_PARAMS
)
3708 const GLuint texelBytes
= _mesa_get_format_bytes(dstFormat
);
3709 const GLenum baseFormat
= _mesa_get_format_base_format(dstFormat
);
3710 const GLint components
= _mesa_components_in_format(baseFormat
);
3712 ASSERT(dstFormat
== MESA_FORMAT_R_INT16
||
3713 dstFormat
== MESA_FORMAT_RG_INT16
||
3714 dstFormat
== MESA_FORMAT_RGB_INT16
||
3715 dstFormat
== MESA_FORMAT_RGBA_INT16
||
3716 dstFormat
== MESA_FORMAT_ALPHA_INT16
||
3717 dstFormat
== MESA_FORMAT_LUMINANCE_INT16
||
3718 dstFormat
== MESA_FORMAT_INTENSITY_INT16
||
3719 dstFormat
== MESA_FORMAT_LUMINANCE_ALPHA_INT16
);
3720 ASSERT(baseInternalFormat
== GL_RGBA
||
3721 baseInternalFormat
== GL_RGB
||
3722 baseInternalFormat
== GL_ALPHA
||
3723 baseInternalFormat
== GL_LUMINANCE
||
3724 baseInternalFormat
== GL_LUMINANCE_ALPHA
||
3725 baseInternalFormat
== GL_INTENSITY
);
3726 ASSERT(texelBytes
== components
* sizeof(GLshort
));
3728 /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply
3729 * to integer formats.
3731 if (!srcPacking
->SwapBytes
&&
3732 baseInternalFormat
== srcFormat
&&
3733 srcType
== GL_SHORT
) {
3734 /* simple memcpy path */
3735 memcpy_texture(ctx
, dims
,
3736 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
3739 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
3740 srcAddr
, srcPacking
);
3744 const GLfloat
*tempImage
= _mesa_make_temp_float_image(ctx
, dims
,
3747 srcWidth
, srcHeight
, srcDepth
,
3748 srcFormat
, srcType
, srcAddr
,
3750 const GLfloat
*src
= tempImage
;
3754 for (img
= 0; img
< srcDepth
; img
++) {
3755 GLubyte
*dstRow
= (GLubyte
*) dstAddr
3756 + dstImageOffsets
[dstZoffset
+ img
] * texelBytes
3757 + dstYoffset
* dstRowStride
3758 + dstXoffset
* texelBytes
;
3759 for (row
= 0; row
< srcHeight
; row
++) {
3760 GLshort
*dstTexel
= (GLshort
*) dstRow
;
3762 for (i
= 0; i
< srcWidth
* components
; i
++) {
3763 dstTexel
[i
] = (GLint
) src
[i
];
3765 dstRow
+= dstRowStride
;
3766 src
+= srcWidth
* components
;
3770 free((void *) tempImage
);
3776 /* non-normalized, signed int32 */
3778 _mesa_texstore_rgba_int32(TEXSTORE_PARAMS
)
3780 const GLuint texelBytes
= _mesa_get_format_bytes(dstFormat
);
3781 const GLenum baseFormat
= _mesa_get_format_base_format(dstFormat
);
3782 const GLint components
= _mesa_components_in_format(baseFormat
);
3784 ASSERT(dstFormat
== MESA_FORMAT_R_INT32
||
3785 dstFormat
== MESA_FORMAT_RG_INT32
||
3786 dstFormat
== MESA_FORMAT_RGB_INT32
||
3787 dstFormat
== MESA_FORMAT_RGBA_INT32
||
3788 dstFormat
== MESA_FORMAT_ALPHA_INT32
||
3789 dstFormat
== MESA_FORMAT_INTENSITY_INT32
||
3790 dstFormat
== MESA_FORMAT_LUMINANCE_INT32
||
3791 dstFormat
== MESA_FORMAT_LUMINANCE_ALPHA_INT32
);
3792 ASSERT(baseInternalFormat
== GL_RGBA
||
3793 baseInternalFormat
== GL_RGB
||
3794 baseInternalFormat
== GL_ALPHA
||
3795 baseInternalFormat
== GL_LUMINANCE
||
3796 baseInternalFormat
== GL_LUMINANCE_ALPHA
||
3797 baseInternalFormat
== GL_INTENSITY
);
3798 ASSERT(texelBytes
== components
* sizeof(GLint
));
3800 /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply
3801 * to integer formats.
3803 if (!srcPacking
->SwapBytes
&&
3804 baseInternalFormat
== srcFormat
&&
3805 srcType
== GL_INT
) {
3806 /* simple memcpy path */
3807 memcpy_texture(ctx
, dims
,
3808 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
3811 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
3812 srcAddr
, srcPacking
);
3816 const GLfloat
*tempImage
= _mesa_make_temp_float_image(ctx
, dims
,
3819 srcWidth
, srcHeight
, srcDepth
,
3820 srcFormat
, srcType
, srcAddr
,
3822 const GLfloat
*src
= tempImage
;
3826 for (img
= 0; img
< srcDepth
; img
++) {
3827 GLubyte
*dstRow
= (GLubyte
*) dstAddr
3828 + dstImageOffsets
[dstZoffset
+ img
] * texelBytes
3829 + dstYoffset
* dstRowStride
3830 + dstXoffset
* texelBytes
;
3831 for (row
= 0; row
< srcHeight
; row
++) {
3832 GLint
*dstTexel
= (GLint
*) dstRow
;
3834 for (i
= 0; i
< srcWidth
* components
; i
++) {
3835 dstTexel
[i
] = (GLint
) src
[i
];
3837 dstRow
+= dstRowStride
;
3838 src
+= srcWidth
* components
;
3842 free((void *) tempImage
);
3848 /* non-normalized, unsigned int8 */
3850 _mesa_texstore_rgba_uint8(TEXSTORE_PARAMS
)
3852 const GLuint texelBytes
= _mesa_get_format_bytes(dstFormat
);
3853 const GLenum baseFormat
= _mesa_get_format_base_format(dstFormat
);
3854 const GLint components
= _mesa_components_in_format(baseFormat
);
3856 ASSERT(dstFormat
== MESA_FORMAT_R_UINT8
||
3857 dstFormat
== MESA_FORMAT_RG_UINT8
||
3858 dstFormat
== MESA_FORMAT_RGB_UINT8
||
3859 dstFormat
== MESA_FORMAT_RGBA_UINT8
||
3860 dstFormat
== MESA_FORMAT_ALPHA_UINT8
||
3861 dstFormat
== MESA_FORMAT_INTENSITY_UINT8
||
3862 dstFormat
== MESA_FORMAT_LUMINANCE_UINT8
||
3863 dstFormat
== MESA_FORMAT_LUMINANCE_ALPHA_UINT8
);
3864 ASSERT(baseInternalFormat
== GL_RGBA
||
3865 baseInternalFormat
== GL_RGB
||
3866 baseInternalFormat
== GL_ALPHA
||
3867 baseInternalFormat
== GL_LUMINANCE
||
3868 baseInternalFormat
== GL_LUMINANCE_ALPHA
||
3869 baseInternalFormat
== GL_INTENSITY
);
3870 ASSERT(texelBytes
== components
* sizeof(GLubyte
));
3872 /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply
3873 * to integer formats.
3875 if (!srcPacking
->SwapBytes
&&
3876 baseInternalFormat
== srcFormat
&&
3877 srcType
== GL_UNSIGNED_BYTE
) {
3878 /* simple memcpy path */
3879 memcpy_texture(ctx
, dims
,
3880 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
3883 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
3884 srcAddr
, srcPacking
);
3888 const GLuint
*tempImage
=
3889 make_temp_uint_image(ctx
, dims
, baseInternalFormat
, baseFormat
,
3890 srcWidth
, srcHeight
, srcDepth
,
3891 srcFormat
, srcType
, srcAddr
, srcPacking
);
3892 const GLuint
*src
= tempImage
;
3896 for (img
= 0; img
< srcDepth
; img
++) {
3897 GLubyte
*dstRow
= (GLubyte
*) dstAddr
3898 + dstImageOffsets
[dstZoffset
+ img
] * texelBytes
3899 + dstYoffset
* dstRowStride
3900 + dstXoffset
* texelBytes
;
3901 for (row
= 0; row
< srcHeight
; row
++) {
3902 GLubyte
*dstTexel
= (GLubyte
*) dstRow
;
3904 for (i
= 0; i
< srcWidth
* components
; i
++) {
3905 dstTexel
[i
] = (GLubyte
) CLAMP(src
[i
], 0, 0xff);
3907 dstRow
+= dstRowStride
;
3908 src
+= srcWidth
* components
;
3912 free((void *) tempImage
);
3918 /* non-normalized, unsigned int16 */
3920 _mesa_texstore_rgba_uint16(TEXSTORE_PARAMS
)
3922 const GLuint texelBytes
= _mesa_get_format_bytes(dstFormat
);
3923 const GLenum baseFormat
= _mesa_get_format_base_format(dstFormat
);
3924 const GLint components
= _mesa_components_in_format(baseFormat
);
3926 ASSERT(dstFormat
== MESA_FORMAT_R_UINT16
||
3927 dstFormat
== MESA_FORMAT_RG_UINT16
||
3928 dstFormat
== MESA_FORMAT_RGB_UINT16
||
3929 dstFormat
== MESA_FORMAT_RGBA_UINT16
||
3930 dstFormat
== MESA_FORMAT_ALPHA_UINT16
||
3931 dstFormat
== MESA_FORMAT_INTENSITY_UINT16
||
3932 dstFormat
== MESA_FORMAT_LUMINANCE_UINT16
||
3933 dstFormat
== MESA_FORMAT_LUMINANCE_ALPHA_UINT16
);
3934 ASSERT(baseInternalFormat
== GL_RGBA
||
3935 baseInternalFormat
== GL_RGB
||
3936 baseInternalFormat
== GL_ALPHA
||
3937 baseInternalFormat
== GL_LUMINANCE
||
3938 baseInternalFormat
== GL_LUMINANCE_ALPHA
||
3939 baseInternalFormat
== GL_INTENSITY
);
3940 ASSERT(texelBytes
== components
* sizeof(GLushort
));
3942 /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply
3943 * to integer formats.
3945 if (!srcPacking
->SwapBytes
&&
3946 baseInternalFormat
== srcFormat
&&
3947 srcType
== GL_UNSIGNED_SHORT
) {
3948 /* simple memcpy path */
3949 memcpy_texture(ctx
, dims
,
3950 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
3953 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
3954 srcAddr
, srcPacking
);
3958 const GLuint
*tempImage
=
3959 make_temp_uint_image(ctx
, dims
, baseInternalFormat
, baseFormat
,
3960 srcWidth
, srcHeight
, srcDepth
,
3961 srcFormat
, srcType
, srcAddr
, srcPacking
);
3962 const GLuint
*src
= tempImage
;
3966 for (img
= 0; img
< srcDepth
; img
++) {
3967 GLubyte
*dstRow
= (GLubyte
*) dstAddr
3968 + dstImageOffsets
[dstZoffset
+ img
] * texelBytes
3969 + dstYoffset
* dstRowStride
3970 + dstXoffset
* texelBytes
;
3971 for (row
= 0; row
< srcHeight
; row
++) {
3972 GLushort
*dstTexel
= (GLushort
*) dstRow
;
3974 for (i
= 0; i
< srcWidth
* components
; i
++) {
3975 dstTexel
[i
] = (GLushort
) CLAMP(src
[i
], 0, 0xffff);
3977 dstRow
+= dstRowStride
;
3978 src
+= srcWidth
* components
;
3982 free((void *) tempImage
);
3988 /* non-normalized, unsigned int32 */
3990 _mesa_texstore_rgba_uint32(TEXSTORE_PARAMS
)
3992 const GLuint texelBytes
= _mesa_get_format_bytes(dstFormat
);
3993 const GLenum baseFormat
= _mesa_get_format_base_format(dstFormat
);
3994 const GLint components
= _mesa_components_in_format(baseFormat
);
3996 ASSERT(dstFormat
== MESA_FORMAT_R_UINT32
||
3997 dstFormat
== MESA_FORMAT_RG_UINT32
||
3998 dstFormat
== MESA_FORMAT_RGB_UINT32
||
3999 dstFormat
== MESA_FORMAT_RGBA_UINT32
||
4000 dstFormat
== MESA_FORMAT_ALPHA_UINT32
||
4001 dstFormat
== MESA_FORMAT_INTENSITY_UINT32
||
4002 dstFormat
== MESA_FORMAT_LUMINANCE_UINT32
||
4003 dstFormat
== MESA_FORMAT_LUMINANCE_ALPHA_UINT32
);
4004 ASSERT(baseInternalFormat
== GL_RGBA
||
4005 baseInternalFormat
== GL_RGB
||
4006 baseInternalFormat
== GL_ALPHA
||
4007 baseInternalFormat
== GL_LUMINANCE
||
4008 baseInternalFormat
== GL_LUMINANCE_ALPHA
||
4009 baseInternalFormat
== GL_INTENSITY
);
4010 ASSERT(texelBytes
== components
* sizeof(GLuint
));
4012 /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply
4013 * to integer formats.
4015 if (!srcPacking
->SwapBytes
&&
4016 baseInternalFormat
== srcFormat
&&
4017 srcType
== GL_UNSIGNED_INT
) {
4018 /* simple memcpy path */
4019 memcpy_texture(ctx
, dims
,
4020 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
4023 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
4024 srcAddr
, srcPacking
);
4028 const GLuint
*tempImage
=
4029 make_temp_uint_image(ctx
, dims
, baseInternalFormat
, baseFormat
,
4030 srcWidth
, srcHeight
, srcDepth
,
4031 srcFormat
, srcType
, srcAddr
, srcPacking
);
4032 const GLuint
*src
= tempImage
;
4036 for (img
= 0; img
< srcDepth
; img
++) {
4037 GLubyte
*dstRow
= (GLubyte
*) dstAddr
4038 + dstImageOffsets
[dstZoffset
+ img
] * texelBytes
4039 + dstYoffset
* dstRowStride
4040 + dstXoffset
* texelBytes
;
4041 for (row
= 0; row
< srcHeight
; row
++) {
4042 GLuint
*dstTexel
= (GLuint
*) dstRow
;
4044 for (i
= 0; i
< srcWidth
* components
; i
++) {
4045 dstTexel
[i
] = src
[i
];
4047 dstRow
+= dstRowStride
;
4048 src
+= srcWidth
* components
;
4052 free((void *) tempImage
);
4060 #if FEATURE_EXT_texture_sRGB
4062 _mesa_texstore_srgb8(TEXSTORE_PARAMS
)
4064 gl_format newDstFormat
;
4067 ASSERT(dstFormat
== MESA_FORMAT_SRGB8
);
4069 /* reuse normal rgb texstore code */
4070 newDstFormat
= MESA_FORMAT_RGB888
;
4072 k
= _mesa_texstore_rgb888(ctx
, dims
, baseInternalFormat
,
4073 newDstFormat
, dstAddr
,
4074 dstXoffset
, dstYoffset
, dstZoffset
,
4075 dstRowStride
, dstImageOffsets
,
4076 srcWidth
, srcHeight
, srcDepth
,
4078 srcAddr
, srcPacking
);
4084 _mesa_texstore_srgba8(TEXSTORE_PARAMS
)
4086 gl_format newDstFormat
;
4089 ASSERT(dstFormat
== MESA_FORMAT_SRGBA8
);
4091 /* reuse normal rgba texstore code */
4092 newDstFormat
= MESA_FORMAT_RGBA8888
;
4093 k
= _mesa_texstore_rgba8888(ctx
, dims
, baseInternalFormat
,
4094 newDstFormat
, dstAddr
,
4095 dstXoffset
, dstYoffset
, dstZoffset
,
4096 dstRowStride
, dstImageOffsets
,
4097 srcWidth
, srcHeight
, srcDepth
,
4099 srcAddr
, srcPacking
);
4105 _mesa_texstore_sargb8(TEXSTORE_PARAMS
)
4107 gl_format newDstFormat
;
4110 ASSERT(dstFormat
== MESA_FORMAT_SARGB8
);
4112 /* reuse normal rgba texstore code */
4113 newDstFormat
= MESA_FORMAT_ARGB8888
;
4115 k
= _mesa_texstore_argb8888(ctx
, dims
, baseInternalFormat
,
4116 newDstFormat
, dstAddr
,
4117 dstXoffset
, dstYoffset
, dstZoffset
,
4118 dstRowStride
, dstImageOffsets
,
4119 srcWidth
, srcHeight
, srcDepth
,
4121 srcAddr
, srcPacking
);
4127 _mesa_texstore_sl8(TEXSTORE_PARAMS
)
4129 gl_format newDstFormat
;
4132 ASSERT(dstFormat
== MESA_FORMAT_SL8
);
4134 newDstFormat
= MESA_FORMAT_L8
;
4136 /* _mesa_textore_a8 handles luminance8 too */
4137 k
= _mesa_texstore_unorm8(ctx
, dims
, baseInternalFormat
,
4138 newDstFormat
, dstAddr
,
4139 dstXoffset
, dstYoffset
, dstZoffset
,
4140 dstRowStride
, dstImageOffsets
,
4141 srcWidth
, srcHeight
, srcDepth
,
4143 srcAddr
, srcPacking
);
4149 _mesa_texstore_sla8(TEXSTORE_PARAMS
)
4151 gl_format newDstFormat
;
4154 ASSERT(dstFormat
== MESA_FORMAT_SLA8
);
4156 /* reuse normal luminance/alpha texstore code */
4157 newDstFormat
= MESA_FORMAT_AL88
;
4159 k
= _mesa_texstore_unorm88(ctx
, dims
, baseInternalFormat
,
4160 newDstFormat
, dstAddr
,
4161 dstXoffset
, dstYoffset
, dstZoffset
,
4162 dstRowStride
, dstImageOffsets
,
4163 srcWidth
, srcHeight
, srcDepth
,
4165 srcAddr
, srcPacking
);
4171 /* these are used only in texstore_funcs[] below */
4172 #define _mesa_texstore_srgb8 NULL
4173 #define _mesa_texstore_srgba8 NULL
4174 #define _mesa_texstore_sargb8 NULL
4175 #define _mesa_texstore_sl8 NULL
4176 #define _mesa_texstore_sla8 NULL
4178 #endif /* FEATURE_EXT_texture_sRGB */
4181 _mesa_texstore_rgb9_e5(TEXSTORE_PARAMS
)
4183 const GLenum baseFormat
= _mesa_get_format_base_format(dstFormat
);
4185 ASSERT(dstFormat
== MESA_FORMAT_RGB9_E5_FLOAT
);
4186 ASSERT(baseInternalFormat
== GL_RGB
);
4188 if (!ctx
->_ImageTransferState
&&
4189 !srcPacking
->SwapBytes
&&
4190 srcFormat
== GL_RGB
&&
4191 srcType
== GL_UNSIGNED_INT_5_9_9_9_REV
) {
4192 /* simple memcpy path */
4193 memcpy_texture(ctx
, dims
,
4194 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
4197 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
4198 srcAddr
, srcPacking
);
4202 const GLfloat
*tempImage
= _mesa_make_temp_float_image(ctx
, dims
,
4205 srcWidth
, srcHeight
, srcDepth
,
4206 srcFormat
, srcType
, srcAddr
,
4208 ctx
->_ImageTransferState
);
4209 const GLfloat
*srcRow
= tempImage
;
4210 GLint img
, row
, col
;
4213 for (img
= 0; img
< srcDepth
; img
++) {
4214 GLubyte
*dstRow
= (GLubyte
*) dstAddr
4215 + dstImageOffsets
[dstZoffset
+ img
] * 4
4216 + dstYoffset
* dstRowStride
4218 for (row
= 0; row
< srcHeight
; row
++) {
4219 GLuint
*dstUI
= (GLuint
*)dstRow
;
4220 for (col
= 0; col
< srcWidth
; col
++) {
4221 dstUI
[col
] = float3_to_rgb9e5(&srcRow
[col
* 3]);
4223 dstRow
+= dstRowStride
;
4224 srcRow
+= srcWidth
* 3;
4228 free((void *) tempImage
);
4234 _mesa_texstore_r11_g11_b10f(TEXSTORE_PARAMS
)
4236 const GLenum baseFormat
= _mesa_get_format_base_format(dstFormat
);
4238 ASSERT(dstFormat
== MESA_FORMAT_R11_G11_B10_FLOAT
);
4239 ASSERT(baseInternalFormat
== GL_RGB
);
4241 if (!ctx
->_ImageTransferState
&&
4242 !srcPacking
->SwapBytes
&&
4243 srcFormat
== GL_RGB
&&
4244 srcType
== GL_UNSIGNED_INT_10F_11F_11F_REV
) {
4245 /* simple memcpy path */
4246 memcpy_texture(ctx
, dims
,
4247 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
4250 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
4251 srcAddr
, srcPacking
);
4255 const GLfloat
*tempImage
= _mesa_make_temp_float_image(ctx
, dims
,
4258 srcWidth
, srcHeight
, srcDepth
,
4259 srcFormat
, srcType
, srcAddr
,
4261 ctx
->_ImageTransferState
);
4262 const GLfloat
*srcRow
= tempImage
;
4263 GLint img
, row
, col
;
4266 for (img
= 0; img
< srcDepth
; img
++) {
4267 GLubyte
*dstRow
= (GLubyte
*) dstAddr
4268 + dstImageOffsets
[dstZoffset
+ img
] * 4
4269 + dstYoffset
* dstRowStride
4271 for (row
= 0; row
< srcHeight
; row
++) {
4272 GLuint
*dstUI
= (GLuint
*)dstRow
;
4273 for (col
= 0; col
< srcWidth
; col
++) {
4274 dstUI
[col
] = float3_to_r11g11b10f(&srcRow
[col
* 3]);
4276 dstRow
+= dstRowStride
;
4277 srcRow
+= srcWidth
* 3;
4281 free((void *) tempImage
);
4288 _mesa_texstore_z32f_x24s8(TEXSTORE_PARAMS
)
4290 ASSERT(dstFormat
== MESA_FORMAT_Z32_FLOAT_X24S8
);
4291 ASSERT(srcFormat
== GL_DEPTH_STENCIL
||
4292 srcFormat
== GL_DEPTH_COMPONENT
||
4293 srcFormat
== GL_STENCIL_INDEX
);
4294 ASSERT(srcFormat
!= GL_DEPTH_STENCIL
||
4295 srcType
== GL_FLOAT_32_UNSIGNED_INT_24_8_REV
);
4297 if (srcFormat
== GL_DEPTH_STENCIL
&&
4298 ctx
->Pixel
.DepthScale
== 1.0f
&&
4299 ctx
->Pixel
.DepthBias
== 0.0f
&&
4300 !srcPacking
->SwapBytes
) {
4302 memcpy_texture(ctx
, dims
,
4303 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
4306 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
4307 srcAddr
, srcPacking
);
4309 else if (srcFormat
== GL_DEPTH_COMPONENT
||
4310 srcFormat
== GL_STENCIL_INDEX
) {
4312 const GLint srcRowStride
4313 = _mesa_image_row_stride(srcPacking
, srcWidth
, srcFormat
, srcType
)
4316 /* In case we only upload depth we need to preserve the stencil */
4317 for (img
= 0; img
< srcDepth
; img
++) {
4318 uint64_t *dstRow
= (uint64_t *) dstAddr
4319 + dstImageOffsets
[dstZoffset
+ img
]
4320 + dstYoffset
* dstRowStride
/ sizeof(uint64_t)
4323 = (const uint64_t *) _mesa_image_address(dims
, srcPacking
, srcAddr
,
4324 srcWidth
, srcHeight
,
4327 for (row
= 0; row
< srcHeight
; row
++) {
4328 /* The unpack functions with:
4329 * dstType = GL_FLOAT_32_UNSIGNED_INT_24_8_REV
4330 * only write their own dword, so the other dword (stencil
4331 * or depth) is preserved. */
4332 if (srcFormat
!= GL_STENCIL_INDEX
)
4333 _mesa_unpack_depth_span(ctx
, srcWidth
,
4334 GL_FLOAT_32_UNSIGNED_INT_24_8_REV
, /* dst type */
4335 dstRow
, /* dst addr */
4336 1.0f
, srcType
, src
, srcPacking
);
4338 if (srcFormat
!= GL_DEPTH_COMPONENT
)
4339 _mesa_unpack_stencil_span(ctx
, srcWidth
,
4340 GL_FLOAT_32_UNSIGNED_INT_24_8_REV
, /* dst type */
4341 dstRow
, /* dst addr */
4342 srcType
, src
, srcPacking
,
4343 ctx
->_ImageTransferState
);
4345 src
+= srcRowStride
;
4346 dstRow
+= dstRowStride
/ sizeof(uint64_t);
4354 _mesa_texstore_null(TEXSTORE_PARAMS
)
4356 (void) ctx
; (void) dims
;
4357 (void) baseInternalFormat
;
4360 (void) dstXoffset
; (void) dstYoffset
; (void) dstZoffset
;
4361 (void) dstRowStride
; (void) dstImageOffsets
;
4362 (void) srcWidth
; (void) srcHeight
; (void) srcDepth
;
4363 (void) srcFormat
; (void) srcType
;
4367 /* should never happen */
4368 _mesa_problem(NULL
, "_mesa_texstore_null() is called");
4374 * Return the StoreTexImageFunc pointer to store an image in the given format.
4376 static StoreTexImageFunc
4377 _mesa_get_texstore_func(gl_format format
)
4379 static StoreTexImageFunc table
[MESA_FORMAT_COUNT
];
4380 static GLboolean initialized
= GL_FALSE
;
4383 table
[MESA_FORMAT_NONE
] = _mesa_texstore_null
;
4385 table
[MESA_FORMAT_RGBA8888
] = _mesa_texstore_rgba8888
;
4386 table
[MESA_FORMAT_RGBA8888_REV
] = _mesa_texstore_rgba8888
;
4387 table
[MESA_FORMAT_ARGB8888
] = _mesa_texstore_argb8888
;
4388 table
[MESA_FORMAT_ARGB8888_REV
] = _mesa_texstore_argb8888
;
4389 table
[MESA_FORMAT_XRGB8888
] = _mesa_texstore_argb8888
;
4390 table
[MESA_FORMAT_XRGB8888_REV
] = _mesa_texstore_argb8888
;
4391 table
[MESA_FORMAT_RGB888
] = _mesa_texstore_rgb888
;
4392 table
[MESA_FORMAT_BGR888
] = _mesa_texstore_bgr888
;
4393 table
[MESA_FORMAT_RGB565
] = _mesa_texstore_rgb565
;
4394 table
[MESA_FORMAT_RGB565_REV
] = _mesa_texstore_rgb565
;
4395 table
[MESA_FORMAT_ARGB4444
] = _mesa_texstore_argb4444
;
4396 table
[MESA_FORMAT_ARGB4444_REV
] = _mesa_texstore_argb4444
;
4397 table
[MESA_FORMAT_RGBA5551
] = _mesa_texstore_rgba5551
;
4398 table
[MESA_FORMAT_ARGB1555
] = _mesa_texstore_argb1555
;
4399 table
[MESA_FORMAT_ARGB1555_REV
] = _mesa_texstore_argb1555
;
4400 table
[MESA_FORMAT_AL44
] = _mesa_texstore_unorm44
;
4401 table
[MESA_FORMAT_AL88
] = _mesa_texstore_unorm88
;
4402 table
[MESA_FORMAT_AL88_REV
] = _mesa_texstore_unorm88
;
4403 table
[MESA_FORMAT_AL1616
] = _mesa_texstore_unorm1616
;
4404 table
[MESA_FORMAT_AL1616_REV
] = _mesa_texstore_unorm1616
;
4405 table
[MESA_FORMAT_RGB332
] = _mesa_texstore_rgb332
;
4406 table
[MESA_FORMAT_A8
] = _mesa_texstore_unorm8
;
4407 table
[MESA_FORMAT_A16
] = _mesa_texstore_unorm16
;
4408 table
[MESA_FORMAT_L8
] = _mesa_texstore_unorm8
;
4409 table
[MESA_FORMAT_L16
] = _mesa_texstore_unorm16
;
4410 table
[MESA_FORMAT_I8
] = _mesa_texstore_unorm8
;
4411 table
[MESA_FORMAT_I16
] = _mesa_texstore_unorm16
;
4412 table
[MESA_FORMAT_YCBCR
] = _mesa_texstore_ycbcr
;
4413 table
[MESA_FORMAT_YCBCR_REV
] = _mesa_texstore_ycbcr
;
4414 table
[MESA_FORMAT_R8
] = _mesa_texstore_unorm8
;
4415 table
[MESA_FORMAT_RG88
] = _mesa_texstore_unorm88
;
4416 table
[MESA_FORMAT_RG88_REV
] = _mesa_texstore_unorm88
;
4417 table
[MESA_FORMAT_R16
] = _mesa_texstore_unorm16
;
4418 table
[MESA_FORMAT_RG1616
] = _mesa_texstore_unorm1616
;
4419 table
[MESA_FORMAT_RG1616_REV
] = _mesa_texstore_unorm1616
;
4420 table
[MESA_FORMAT_ARGB2101010
] = _mesa_texstore_argb2101010
;
4421 table
[MESA_FORMAT_Z24_S8
] = _mesa_texstore_z24_s8
;
4422 table
[MESA_FORMAT_S8_Z24
] = _mesa_texstore_s8_z24
;
4423 table
[MESA_FORMAT_Z16
] = _mesa_texstore_z16
;
4424 table
[MESA_FORMAT_X8_Z24
] = _mesa_texstore_x8_z24
;
4425 table
[MESA_FORMAT_Z24_X8
] = _mesa_texstore_z24_x8
;
4426 table
[MESA_FORMAT_Z32
] = _mesa_texstore_z32
;
4427 table
[MESA_FORMAT_S8
] = _mesa_texstore_s8
;
4428 table
[MESA_FORMAT_SRGB8
] = _mesa_texstore_srgb8
;
4429 table
[MESA_FORMAT_SRGBA8
] = _mesa_texstore_srgba8
;
4430 table
[MESA_FORMAT_SARGB8
] = _mesa_texstore_sargb8
;
4431 table
[MESA_FORMAT_SL8
] = _mesa_texstore_sl8
;
4432 table
[MESA_FORMAT_SLA8
] = _mesa_texstore_sla8
;
4433 table
[MESA_FORMAT_SRGB_DXT1
] = _mesa_texstore_rgb_dxt1
;
4434 table
[MESA_FORMAT_SRGBA_DXT1
] = _mesa_texstore_rgba_dxt1
;
4435 table
[MESA_FORMAT_SRGBA_DXT3
] = _mesa_texstore_rgba_dxt3
;
4436 table
[MESA_FORMAT_SRGBA_DXT5
] = _mesa_texstore_rgba_dxt5
;
4437 table
[MESA_FORMAT_RGB_FXT1
] = _mesa_texstore_rgb_fxt1
;
4438 table
[MESA_FORMAT_RGBA_FXT1
] = _mesa_texstore_rgba_fxt1
;
4439 table
[MESA_FORMAT_RGB_DXT1
] = _mesa_texstore_rgb_dxt1
;
4440 table
[MESA_FORMAT_RGBA_DXT1
] = _mesa_texstore_rgba_dxt1
;
4441 table
[MESA_FORMAT_RGBA_DXT3
] = _mesa_texstore_rgba_dxt3
;
4442 table
[MESA_FORMAT_RGBA_DXT5
] = _mesa_texstore_rgba_dxt5
;
4443 table
[MESA_FORMAT_RGBA_FLOAT32
] = _mesa_texstore_rgba_float32
;
4444 table
[MESA_FORMAT_RGBA_FLOAT16
] = _mesa_texstore_rgba_float16
;
4445 table
[MESA_FORMAT_RGB_FLOAT32
] = _mesa_texstore_rgba_float32
;
4446 table
[MESA_FORMAT_RGB_FLOAT16
] = _mesa_texstore_rgba_float16
;
4447 table
[MESA_FORMAT_ALPHA_FLOAT32
] = _mesa_texstore_rgba_float32
;
4448 table
[MESA_FORMAT_ALPHA_FLOAT16
] = _mesa_texstore_rgba_float16
;
4449 table
[MESA_FORMAT_LUMINANCE_FLOAT32
] = _mesa_texstore_rgba_float32
;
4450 table
[MESA_FORMAT_LUMINANCE_FLOAT16
] = _mesa_texstore_rgba_float16
;
4451 table
[MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32
] = _mesa_texstore_rgba_float32
;
4452 table
[MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16
] = _mesa_texstore_rgba_float16
;
4453 table
[MESA_FORMAT_INTENSITY_FLOAT32
] = _mesa_texstore_rgba_float32
;
4454 table
[MESA_FORMAT_INTENSITY_FLOAT16
] = _mesa_texstore_rgba_float16
;
4455 table
[MESA_FORMAT_R_FLOAT32
] = _mesa_texstore_rgba_float32
;
4456 table
[MESA_FORMAT_R_FLOAT16
] = _mesa_texstore_rgba_float16
;
4457 table
[MESA_FORMAT_RG_FLOAT32
] = _mesa_texstore_rgba_float32
;
4458 table
[MESA_FORMAT_RG_FLOAT16
] = _mesa_texstore_rgba_float16
;
4459 table
[MESA_FORMAT_DUDV8
] = _mesa_texstore_dudv8
;
4460 table
[MESA_FORMAT_SIGNED_R8
] = _mesa_texstore_snorm8
;
4461 table
[MESA_FORMAT_SIGNED_RG88_REV
] = _mesa_texstore_snorm88
;
4462 table
[MESA_FORMAT_SIGNED_RGBX8888
] = _mesa_texstore_signed_rgbx8888
;
4463 table
[MESA_FORMAT_SIGNED_RGBA8888
] = _mesa_texstore_signed_rgba8888
;
4464 table
[MESA_FORMAT_SIGNED_RGBA8888_REV
] = _mesa_texstore_signed_rgba8888
;
4465 table
[MESA_FORMAT_SIGNED_R16
] = _mesa_texstore_snorm16
;
4466 table
[MESA_FORMAT_SIGNED_GR1616
] = _mesa_texstore_snorm1616
;
4467 table
[MESA_FORMAT_SIGNED_RGB_16
] = _mesa_texstore_signed_rgba_16
;
4468 table
[MESA_FORMAT_SIGNED_RGBA_16
] = _mesa_texstore_signed_rgba_16
;
4469 table
[MESA_FORMAT_RGBA_16
] = _mesa_texstore_rgba_16
;
4470 table
[MESA_FORMAT_RED_RGTC1
] = _mesa_texstore_red_rgtc1
;
4471 table
[MESA_FORMAT_SIGNED_RED_RGTC1
] = _mesa_texstore_signed_red_rgtc1
;
4472 table
[MESA_FORMAT_RG_RGTC2
] = _mesa_texstore_rg_rgtc2
;
4473 table
[MESA_FORMAT_SIGNED_RG_RGTC2
] = _mesa_texstore_signed_rg_rgtc2
;
4474 table
[MESA_FORMAT_L_LATC1
] = _mesa_texstore_red_rgtc1
;
4475 table
[MESA_FORMAT_SIGNED_L_LATC1
] = _mesa_texstore_signed_red_rgtc1
;
4476 table
[MESA_FORMAT_LA_LATC2
] = _mesa_texstore_rg_rgtc2
;
4477 table
[MESA_FORMAT_SIGNED_LA_LATC2
] = _mesa_texstore_signed_rg_rgtc2
;
4478 table
[MESA_FORMAT_SIGNED_A8
] = _mesa_texstore_snorm8
;
4479 table
[MESA_FORMAT_SIGNED_L8
] = _mesa_texstore_snorm8
;
4480 table
[MESA_FORMAT_SIGNED_AL88
] = _mesa_texstore_snorm88
;
4481 table
[MESA_FORMAT_SIGNED_I8
] = _mesa_texstore_snorm8
;
4482 table
[MESA_FORMAT_SIGNED_A16
] = _mesa_texstore_snorm16
;
4483 table
[MESA_FORMAT_SIGNED_L16
] = _mesa_texstore_snorm16
;
4484 table
[MESA_FORMAT_SIGNED_AL1616
] = _mesa_texstore_snorm1616
;
4485 table
[MESA_FORMAT_SIGNED_I16
] = _mesa_texstore_snorm16
;
4486 table
[MESA_FORMAT_RGB9_E5_FLOAT
] = _mesa_texstore_rgb9_e5
;
4487 table
[MESA_FORMAT_R11_G11_B10_FLOAT
] = _mesa_texstore_r11_g11_b10f
;
4488 table
[MESA_FORMAT_Z32_FLOAT
] = _mesa_texstore_z32
;
4489 table
[MESA_FORMAT_Z32_FLOAT_X24S8
] = _mesa_texstore_z32f_x24s8
;
4491 table
[MESA_FORMAT_ALPHA_UINT8
] = _mesa_texstore_rgba_uint8
;
4492 table
[MESA_FORMAT_ALPHA_UINT16
] = _mesa_texstore_rgba_uint16
;
4493 table
[MESA_FORMAT_ALPHA_UINT32
] = _mesa_texstore_rgba_uint32
;
4494 table
[MESA_FORMAT_ALPHA_INT8
] = _mesa_texstore_rgba_int8
;
4495 table
[MESA_FORMAT_ALPHA_INT16
] = _mesa_texstore_rgba_int16
;
4496 table
[MESA_FORMAT_ALPHA_INT32
] = _mesa_texstore_rgba_int32
;
4498 table
[MESA_FORMAT_INTENSITY_UINT8
] = _mesa_texstore_rgba_uint8
;
4499 table
[MESA_FORMAT_INTENSITY_UINT16
] = _mesa_texstore_rgba_uint16
;
4500 table
[MESA_FORMAT_INTENSITY_UINT32
] = _mesa_texstore_rgba_uint32
;
4501 table
[MESA_FORMAT_INTENSITY_INT8
] = _mesa_texstore_rgba_int8
;
4502 table
[MESA_FORMAT_INTENSITY_INT16
] = _mesa_texstore_rgba_int16
;
4503 table
[MESA_FORMAT_INTENSITY_INT32
] = _mesa_texstore_rgba_int32
;
4505 table
[MESA_FORMAT_LUMINANCE_UINT8
] = _mesa_texstore_rgba_uint8
;
4506 table
[MESA_FORMAT_LUMINANCE_UINT16
] = _mesa_texstore_rgba_uint16
;
4507 table
[MESA_FORMAT_LUMINANCE_UINT32
] = _mesa_texstore_rgba_uint32
;
4508 table
[MESA_FORMAT_LUMINANCE_INT8
] = _mesa_texstore_rgba_int8
;
4509 table
[MESA_FORMAT_LUMINANCE_INT16
] = _mesa_texstore_rgba_int16
;
4510 table
[MESA_FORMAT_LUMINANCE_INT32
] = _mesa_texstore_rgba_int32
;
4512 table
[MESA_FORMAT_LUMINANCE_ALPHA_UINT8
] = _mesa_texstore_rgba_uint8
;
4513 table
[MESA_FORMAT_LUMINANCE_ALPHA_UINT16
] = _mesa_texstore_rgba_uint16
;
4514 table
[MESA_FORMAT_LUMINANCE_ALPHA_UINT32
] = _mesa_texstore_rgba_uint32
;
4515 table
[MESA_FORMAT_LUMINANCE_ALPHA_INT8
] = _mesa_texstore_rgba_int8
;
4516 table
[MESA_FORMAT_LUMINANCE_ALPHA_INT16
] = _mesa_texstore_rgba_int16
;
4517 table
[MESA_FORMAT_LUMINANCE_ALPHA_INT32
] = _mesa_texstore_rgba_int32
;
4519 table
[MESA_FORMAT_R_INT8
] = _mesa_texstore_rgba_int8
;
4520 table
[MESA_FORMAT_RG_INT8
] = _mesa_texstore_rgba_int8
;
4521 table
[MESA_FORMAT_RGB_INT8
] = _mesa_texstore_rgba_int8
;
4522 table
[MESA_FORMAT_RGBA_INT8
] = _mesa_texstore_rgba_int8
;
4523 table
[MESA_FORMAT_R_INT16
] = _mesa_texstore_rgba_int16
;
4524 table
[MESA_FORMAT_RG_INT16
] = _mesa_texstore_rgba_int16
;
4525 table
[MESA_FORMAT_RGB_INT16
] = _mesa_texstore_rgba_int16
;
4526 table
[MESA_FORMAT_RGBA_INT16
] = _mesa_texstore_rgba_int16
;
4527 table
[MESA_FORMAT_R_INT32
] = _mesa_texstore_rgba_int32
;
4528 table
[MESA_FORMAT_RG_INT32
] = _mesa_texstore_rgba_int32
;
4529 table
[MESA_FORMAT_RGB_INT32
] = _mesa_texstore_rgba_int32
;
4530 table
[MESA_FORMAT_RGBA_INT32
] = _mesa_texstore_rgba_int32
;
4532 table
[MESA_FORMAT_R_UINT8
] = _mesa_texstore_rgba_uint8
;
4533 table
[MESA_FORMAT_RG_UINT8
] = _mesa_texstore_rgba_uint8
;
4534 table
[MESA_FORMAT_RGB_UINT8
] = _mesa_texstore_rgba_uint8
;
4535 table
[MESA_FORMAT_RGBA_UINT8
] = _mesa_texstore_rgba_uint8
;
4536 table
[MESA_FORMAT_R_UINT16
] = _mesa_texstore_rgba_uint16
;
4537 table
[MESA_FORMAT_RG_UINT16
] = _mesa_texstore_rgba_uint16
;
4538 table
[MESA_FORMAT_RGB_UINT16
] = _mesa_texstore_rgba_uint16
;
4539 table
[MESA_FORMAT_RGBA_UINT16
] = _mesa_texstore_rgba_uint16
;
4540 table
[MESA_FORMAT_R_UINT32
] = _mesa_texstore_rgba_uint32
;
4541 table
[MESA_FORMAT_RG_UINT32
] = _mesa_texstore_rgba_uint32
;
4542 table
[MESA_FORMAT_RGB_UINT32
] = _mesa_texstore_rgba_uint32
;
4543 table
[MESA_FORMAT_RGBA_UINT32
] = _mesa_texstore_rgba_uint32
;
4545 initialized
= GL_TRUE
;
4548 ASSERT(table
[format
]);
4549 return table
[format
];
4554 * Store user data into texture memory.
4555 * Called via glTex[Sub]Image1/2/3D()
4558 _mesa_texstore(TEXSTORE_PARAMS
)
4560 StoreTexImageFunc storeImage
;
4563 storeImage
= _mesa_get_texstore_func(dstFormat
);
4565 success
= storeImage(ctx
, dims
, baseInternalFormat
,
4566 dstFormat
, dstAddr
, dstXoffset
, dstYoffset
, dstZoffset
,
4567 dstRowStride
, dstImageOffsets
,
4568 srcWidth
, srcHeight
, srcDepth
,
4569 srcFormat
, srcType
, srcAddr
, srcPacking
);
4575 * Normally, we'll only _write_ texel data to a texture when we map it.
4576 * But if the user is providing depth or stencil values and the texture
4577 * image is a combined depth/stencil format, we'll actually read from
4578 * the texture buffer too (in order to insert the depth or stencil values.
4579 * \param userFormat the user-provided image format
4580 * \param texFormat the destination texture format
4583 get_read_write_mode(GLenum userFormat
, gl_format texFormat
)
4585 if ((userFormat
== GL_STENCIL_INDEX
|| userFormat
== GL_DEPTH_COMPONENT
)
4586 && _mesa_get_format_base_format(texFormat
) == GL_DEPTH_STENCIL
)
4587 return GL_MAP_READ_BIT
| GL_MAP_WRITE_BIT
;
4589 return GL_MAP_WRITE_BIT
;
4593 * This is the software fallback for Driver.TexImage1D().
4594 * \sa _mesa_store_teximage2d()
4597 _mesa_store_teximage1d(struct gl_context
*ctx
, GLenum target
, GLint level
,
4598 GLint internalFormat
,
4599 GLint width
, GLint border
,
4600 GLenum format
, GLenum type
, const GLvoid
*pixels
,
4601 const struct gl_pixelstore_attrib
*packing
,
4602 struct gl_texture_object
*texObj
,
4603 struct gl_texture_image
*texImage
)
4605 const GLbitfield rwMode
= get_read_write_mode(format
, texImage
->TexFormat
);
4606 const GLuint zeroImageOffset
= 0;
4613 /* allocate storage for texture data */
4614 if (!ctx
->Driver
.AllocTextureImageBuffer(ctx
, texImage
, texImage
->TexFormat
,
4616 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexImage1D");
4620 pixels
= _mesa_validate_pbo_teximage(ctx
, 1, width
, 1, 1, format
, type
,
4621 pixels
, packing
, "glTexImage1D");
4623 /* Note: we check for a NULL image pointer here, _after_ we allocated
4624 * memory for the texture. That's what the GL spec calls for.
4629 /* Map dest texture buffer (write to whole region) */
4630 ctx
->Driver
.MapTextureImage(ctx
, texImage
, 0,
4633 &dstMap
, &dstRowStride
);
4635 success
= _mesa_texstore(ctx
, 1, texImage
->_BaseFormat
,
4636 texImage
->TexFormat
,
4638 0, 0, 0, /* dstX/Y/Zoffset */
4639 0, /* dstRowStride */
4642 format
, type
, pixels
, packing
);
4644 ctx
->Driver
.UnmapTextureImage(ctx
, texImage
, 0);
4647 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexImage1D");
4649 _mesa_unmap_teximage_pbo(ctx
, packing
);
4654 * This is the software fallback for Driver.TexImage2D().
4656 * This function is oriented toward storing images in main memory, rather
4657 * than VRAM. Device driver's can easily plug in their own replacement.
4660 _mesa_store_teximage2d(struct gl_context
*ctx
, GLenum target
, GLint level
,
4661 GLint internalFormat
,
4662 GLint width
, GLint height
, GLint border
,
4663 GLenum format
, GLenum type
, const void *pixels
,
4664 const struct gl_pixelstore_attrib
*packing
,
4665 struct gl_texture_object
*texObj
,
4666 struct gl_texture_image
*texImage
)
4668 const GLbitfield rwMode
= get_read_write_mode(format
, texImage
->TexFormat
);
4669 const GLuint zeroImageOffset
= 0;
4676 /* allocate storage for texture data */
4677 if (!ctx
->Driver
.AllocTextureImageBuffer(ctx
, texImage
, texImage
->TexFormat
,
4678 width
, height
, 1)) {
4679 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexImage2D");
4683 pixels
= _mesa_validate_pbo_teximage(ctx
, 2, width
, height
, 1, format
, type
,
4684 pixels
, packing
, "glTexImage2D");
4686 /* Note: we check for a NULL image pointer here, _after_ we allocated
4687 * memory for the texture. That's what the GL spec calls for.
4692 if (target
== GL_TEXTURE_1D_ARRAY
) {
4693 const GLint srcStride
=
4694 _mesa_image_row_stride(packing
, width
, format
, type
);
4699 for (y
= 0; y
< height
; y
++) {
4700 /* Map dest texture buffer (write to whole region) */
4701 ctx
->Driver
.MapTextureImage(ctx
, texImage
, y
,
4704 &dstMap
, &dstRowStride
);
4706 success
= _mesa_texstore(ctx
, 2, texImage
->_BaseFormat
,
4707 texImage
->TexFormat
,
4709 0, 0, 0, /* dstX/Y/Zoffset */
4713 format
, type
, pixels
, packing
);
4714 ctx
->Driver
.UnmapTextureImage(ctx
, texImage
, y
);
4719 pixels
= (const GLubyte
*) pixels
+ srcStride
;
4722 /* Map dest texture buffer (write to whole region) */
4723 ctx
->Driver
.MapTextureImage(ctx
, texImage
, 0,
4724 0, 0, width
, height
,
4726 &dstMap
, &dstRowStride
);
4728 success
= _mesa_texstore(ctx
, 2, texImage
->_BaseFormat
,
4729 texImage
->TexFormat
,
4731 0, 0, 0, /* dstX/Y/Zoffset */
4735 format
, type
, pixels
, packing
);
4737 ctx
->Driver
.UnmapTextureImage(ctx
, texImage
, 0);
4741 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexImage2D");
4743 _mesa_unmap_teximage_pbo(ctx
, packing
);
4749 * This is the software fallback for Driver.TexImage3D().
4750 * \sa _mesa_store_teximage2d()
4753 _mesa_store_teximage3d(struct gl_context
*ctx
, GLenum target
, GLint level
,
4754 GLint internalFormat
,
4755 GLint width
, GLint height
, GLint depth
, GLint border
,
4756 GLenum format
, GLenum type
, const void *pixels
,
4757 const struct gl_pixelstore_attrib
*packing
,
4758 struct gl_texture_object
*texObj
,
4759 struct gl_texture_image
*texImage
)
4761 const GLbitfield rwMode
= get_read_write_mode(format
, texImage
->TexFormat
);
4764 GLubyte
**sliceMaps
;
4765 GLuint
*dstImageOffsets
;
4767 GLuint texelSize
= _mesa_get_format_bytes(texImage
->TexFormat
);
4771 /* allocate storage for texture data */
4772 if (!ctx
->Driver
.AllocTextureImageBuffer(ctx
, texImage
, texImage
->TexFormat
,
4773 width
, height
, depth
)) {
4774 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexImage3D");
4778 pixels
= _mesa_validate_pbo_teximage(ctx
, 3, width
, height
, depth
,
4780 pixels
, packing
, "glTexImage3D");
4782 /* Note: we check for a NULL image pointer here, _after_ we allocated
4783 * memory for the texture. That's what the GL spec calls for.
4788 if (target
== GL_TEXTURE_1D_ARRAY
) {
4793 sliceMaps
= (GLubyte
**) malloc(depth
* sizeof(GLubyte
*));
4794 dstImageOffsets
= (GLuint
*) malloc(depth
* sizeof(GLuint
));
4796 /* Map dest texture buffer slices */
4797 for (slice
= 0; slice
< depth
; slice
++) {
4798 ctx
->Driver
.MapTextureImage(ctx
, texImage
, slice
,
4799 0, 0, width
, height
,
4801 &sliceMaps
[slice
], &dstRowStride
);
4803 /* Compute image slice offsets */
4804 for (slice
= 0; slice
< depth
; slice
++) {
4805 dstImageOffsets
[slice
] = (sliceMaps
[slice
] - sliceMaps
[0]) / texelSize
;
4808 success
= _mesa_texstore(ctx
, 3, texImage
->_BaseFormat
,
4809 texImage
->TexFormat
,
4811 0, 0, 0, /* dstX/Y/Zoffset */
4814 width
, height
, depth
,
4815 format
, type
, pixels
, packing
);
4817 /* Unmap dest texture buffer slices */
4818 for (slice
= 0; slice
< depth
; slice
++) {
4819 ctx
->Driver
.UnmapTextureImage(ctx
, texImage
, slice
);
4823 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexImage3D");
4825 _mesa_unmap_teximage_pbo(ctx
, packing
);
4828 free(dstImageOffsets
);
4835 * This is the software fallback for Driver.TexSubImage1D()
4836 * and Driver.CopyTexSubImage1D().
4839 _mesa_store_texsubimage1d(struct gl_context
*ctx
, GLenum target
, GLint level
,
4840 GLint xoffset
, GLint width
,
4841 GLenum format
, GLenum type
, const void *pixels
,
4842 const struct gl_pixelstore_attrib
*packing
,
4843 struct gl_texture_object
*texObj
,
4844 struct gl_texture_image
*texImage
)
4846 const GLbitfield rwMode
= get_read_write_mode(format
, texImage
->TexFormat
);
4847 const GLuint zeroImageOffset
= 0;
4852 /* get pointer to src pixels (may be in a pbo which we'll map here) */
4853 pixels
= _mesa_validate_pbo_teximage(ctx
, 1, width
, 1, 1, format
, type
,
4854 pixels
, packing
, "glTexSubImage1D");
4858 /* Map dest texture buffer (write to whole region) */
4859 ctx
->Driver
.MapTextureImage(ctx
, texImage
, 0,
4860 xoffset
, 0, width
, 1,
4862 &dstMap
, &dstRowStride
);
4864 success
= _mesa_texstore(ctx
, 1, texImage
->_BaseFormat
,
4865 texImage
->TexFormat
,
4867 0, 0, 0, /* dstX/Y/Zoffset */
4871 format
, type
, pixels
, packing
);
4873 ctx
->Driver
.UnmapTextureImage(ctx
, texImage
, 0);
4876 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexSubImage1D");
4878 _mesa_unmap_teximage_pbo(ctx
, packing
);
4884 * This is the software fallback for Driver.TexSubImage2D()
4885 * and Driver.CopyTexSubImage2D().
4888 _mesa_store_texsubimage2d(struct gl_context
*ctx
, GLenum target
, GLint level
,
4889 GLint xoffset
, GLint yoffset
,
4890 GLint width
, GLint height
,
4891 GLenum format
, GLenum type
, const void *pixels
,
4892 const struct gl_pixelstore_attrib
*packing
,
4893 struct gl_texture_object
*texObj
,
4894 struct gl_texture_image
*texImage
)
4896 const GLbitfield rwMode
= get_read_write_mode(format
, texImage
->TexFormat
);
4897 const GLuint zeroImageOffset
= 0;
4902 /* get pointer to src pixels (may be in a pbo which we'll map here) */
4903 pixels
= _mesa_validate_pbo_teximage(ctx
, 2, width
, height
, 1, format
, type
,
4904 pixels
, packing
, "glTexSubImage2D");
4908 /* Map dest texture buffer (write to whole region) */
4909 ctx
->Driver
.MapTextureImage(ctx
, texImage
, 0,
4910 xoffset
, yoffset
, width
, height
,
4912 &dstMap
, &dstRowStride
);
4914 success
= _mesa_texstore(ctx
, 2, texImage
->_BaseFormat
,
4915 texImage
->TexFormat
,
4917 0, 0, 0, /* dstX/Y/Zoffset */
4921 format
, type
, pixels
, packing
);
4923 ctx
->Driver
.UnmapTextureImage(ctx
, texImage
, 0);
4926 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexSubImage2D");
4928 _mesa_unmap_teximage_pbo(ctx
, packing
);
4933 * This is the software fallback for Driver.TexSubImage3D().
4934 * and Driver.CopyTexSubImage3D().
4937 _mesa_store_texsubimage3d(struct gl_context
*ctx
, GLenum target
, GLint level
,
4938 GLint xoffset
, GLint yoffset
, GLint zoffset
,
4939 GLint width
, GLint height
, GLint depth
,
4940 GLenum format
, GLenum type
, const void *pixels
,
4941 const struct gl_pixelstore_attrib
*packing
,
4942 struct gl_texture_object
*texObj
,
4943 struct gl_texture_image
*texImage
)
4945 const GLbitfield rwMode
= get_read_write_mode(format
, texImage
->TexFormat
);
4948 GLubyte
**sliceMaps
;
4949 GLuint
*dstImageOffsets
;
4951 GLuint texelSize
= _mesa_get_format_bytes(texImage
->TexFormat
);
4953 /* get pointer to src pixels (may be in a pbo which we'll map here) */
4954 pixels
= _mesa_validate_pbo_teximage(ctx
, 3, width
, height
, depth
, format
,
4955 type
, pixels
, packing
,
4960 sliceMaps
= (GLubyte
**) malloc((zoffset
+ depth
) * sizeof(GLubyte
*));
4961 dstImageOffsets
= (GLuint
*) malloc((zoffset
+ depth
) * sizeof(GLuint
));
4963 /* Map dest texture buffer slices */
4964 for (slice
= 0; slice
< depth
; slice
++) {
4965 ctx
->Driver
.MapTextureImage(ctx
, texImage
, zoffset
+ slice
,
4966 xoffset
, yoffset
, width
, height
,
4968 &sliceMaps
[zoffset
+ slice
], &dstRowStride
);
4971 /* Compute image slice offsets */
4972 for (slice
= 0; slice
< depth
; slice
++) {
4973 dstImageOffsets
[slice
] =
4974 (sliceMaps
[zoffset
+ slice
] - sliceMaps
[zoffset
]) / texelSize
;
4977 success
= _mesa_texstore(ctx
, 3, texImage
->_BaseFormat
,
4978 texImage
->TexFormat
,
4980 0, 0, 0, /* dstX/Y/Zoffset */
4983 width
, height
, depth
,
4984 format
, type
, pixels
, packing
);
4986 /* Unmap dest texture buffer slices */
4987 for (slice
= 0; slice
< depth
; slice
++) {
4988 ctx
->Driver
.UnmapTextureImage(ctx
, texImage
, zoffset
+ slice
);
4992 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexSubImage3D");
4994 _mesa_unmap_teximage_pbo(ctx
, packing
);
4997 free(dstImageOffsets
);
5002 * Fallback for Driver.CompressedTexImage1D()
5005 _mesa_store_compressed_teximage1d(struct gl_context
*ctx
,
5006 GLenum target
, GLint level
,
5007 GLint internalFormat
,
5008 GLint width
, GLint border
,
5009 GLsizei imageSize
, const GLvoid
*data
,
5010 struct gl_texture_object
*texObj
,
5011 struct gl_texture_image
*texImage
)
5013 /* this space intentionally left blank */
5015 (void) target
; (void) level
;
5016 (void) internalFormat
;
5017 (void) width
; (void) border
;
5018 (void) imageSize
; (void) data
;
5026 * Fallback for Driver.CompressedTexImage2D()
5029 _mesa_store_compressed_teximage2d(struct gl_context
*ctx
,
5030 GLenum target
, GLint level
,
5031 GLint internalFormat
,
5032 GLint width
, GLint height
, GLint border
,
5033 GLsizei imageSize
, const GLvoid
*data
,
5034 struct gl_texture_object
*texObj
,
5035 struct gl_texture_image
*texImage
)
5040 /* This is pretty simple, basically just do a memcpy without worrying
5041 * about the usual image unpacking or image transfer operations.
5045 ASSERT(texImage
->Width
> 0);
5046 ASSERT(texImage
->Height
> 0);
5047 ASSERT(texImage
->Depth
== 1);
5048 ASSERT(texImage
->Data
== NULL
); /* was freed in glCompressedTexImage2DARB */
5050 /* allocate storage for texture data */
5051 if (!ctx
->Driver
.AllocTextureImageBuffer(ctx
, texImage
, texImage
->TexFormat
,
5052 width
, height
, 1)) {
5053 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glCompressedTexImage2D");
5057 data
= _mesa_validate_pbo_compressed_teximage(ctx
, imageSize
, data
,
5059 "glCompressedTexImage2D");
5064 /* Map dest texture buffer (write to whole region) */
5065 ctx
->Driver
.MapTextureImage(ctx
, texImage
, 0,
5066 0, 0, width
, height
,
5068 &dstMap
, &dstRowStride
);
5071 memcpy(dstMap
, data
, imageSize
);
5073 ctx
->Driver
.UnmapTextureImage(ctx
, texImage
, 0);
5075 _mesa_unmap_teximage_pbo(ctx
, &ctx
->Unpack
);
5081 * Fallback for Driver.CompressedTexImage3D()
5084 _mesa_store_compressed_teximage3d(struct gl_context
*ctx
,
5085 GLenum target
, GLint level
,
5086 GLint internalFormat
,
5087 GLint width
, GLint height
, GLint depth
,
5089 GLsizei imageSize
, const GLvoid
*data
,
5090 struct gl_texture_object
*texObj
,
5091 struct gl_texture_image
*texImage
)
5093 /* this space intentionally left blank */
5095 (void) target
; (void) level
;
5096 (void) internalFormat
;
5097 (void) width
; (void) height
; (void) depth
;
5099 (void) imageSize
; (void) data
;
5107 * Fallback for Driver.CompressedTexSubImage1D()
5110 _mesa_store_compressed_texsubimage1d(struct gl_context
*ctx
, GLenum target
,
5112 GLint xoffset
, GLsizei width
,
5114 GLsizei imageSize
, const GLvoid
*data
,
5115 struct gl_texture_object
*texObj
,
5116 struct gl_texture_image
*texImage
)
5118 /* there are no compressed 1D texture formats yet */
5120 (void) target
; (void) level
;
5121 (void) xoffset
; (void) width
;
5123 (void) imageSize
; (void) data
;
5130 * Fallback for Driver.CompressedTexSubImage2D()
5133 _mesa_store_compressed_texsubimage2d(struct gl_context
*ctx
, GLenum target
,
5135 GLint xoffset
, GLint yoffset
,
5136 GLsizei width
, GLsizei height
,
5138 GLsizei imageSize
, const GLvoid
*data
,
5139 struct gl_texture_object
*texObj
,
5140 struct gl_texture_image
*texImage
)
5142 GLint bytesPerRow
, dstRowStride
, srcRowStride
;
5146 const gl_format texFormat
= texImage
->TexFormat
;
5149 _mesa_get_format_block_size(texFormat
, &bw
, &bh
);
5151 /* these should have been caught sooner */
5152 ASSERT((width
% bw
) == 0 || width
== 2 || width
== 1);
5153 ASSERT((height
% bh
) == 0 || height
== 2 || height
== 1);
5154 ASSERT((xoffset
% bw
) == 0);
5155 ASSERT((yoffset
% bh
) == 0);
5157 /* get pointer to src pixels (may be in a pbo which we'll map here) */
5158 data
= _mesa_validate_pbo_compressed_teximage(ctx
, imageSize
, data
,
5160 "glCompressedTexSubImage2D");
5164 srcRowStride
= _mesa_format_row_stride(texFormat
, width
);
5165 src
= (const GLubyte
*) data
;
5167 /* Map dest texture buffer (write to whole region) */
5168 ctx
->Driver
.MapTextureImage(ctx
, texImage
, 0,
5169 xoffset
, yoffset
, width
, height
,
5171 &dstMap
, &dstRowStride
);
5173 bytesPerRow
= srcRowStride
; /* bytes per row of blocks */
5174 rows
= height
/ bh
; /* rows in blocks */
5176 /* copy rows of blocks */
5177 for (i
= 0; i
< rows
; i
++) {
5178 memcpy(dstMap
, src
, bytesPerRow
);
5179 dstMap
+= dstRowStride
;
5180 src
+= srcRowStride
;
5183 ctx
->Driver
.UnmapTextureImage(ctx
, texImage
, 0);
5185 _mesa_unmap_teximage_pbo(ctx
, &ctx
->Unpack
);
5190 * Fallback for Driver.CompressedTexSubImage3D()
5193 _mesa_store_compressed_texsubimage3d(struct gl_context
*ctx
, GLenum target
,
5195 GLint xoffset
, GLint yoffset
, GLint zoffset
,
5196 GLsizei width
, GLsizei height
, GLsizei depth
,
5198 GLsizei imageSize
, const GLvoid
*data
,
5199 struct gl_texture_object
*texObj
,
5200 struct gl_texture_image
*texImage
)
5202 /* there are no compressed 3D texture formats yet */
5204 (void) target
; (void) level
;
5205 (void) xoffset
; (void) yoffset
; (void) zoffset
;
5206 (void) width
; (void) height
; (void) depth
;
5208 (void) imageSize
; (void) data
;