2 * Mesa 3-D graphics library
4 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
5 * Copyright (c) 2008-2009 VMware, Inc.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * 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.TexImage = _mesa_store_teximage;
41 * ctx->Driver.TexSubImage = _mesa_store_texsubimage;
44 * Texture image processing is actually kind of complicated. We have to do:
45 * Format/type conversions
47 * pixel transfer (scale, bais, lookup, etc)
49 * These functions can handle most everything, including processing full
50 * images and sub-images.
55 #include "bufferobj.h"
56 #include "format_pack.h"
57 #include "format_utils.h"
65 #include "texcompress.h"
66 #include "texcompress_fxt1.h"
67 #include "texcompress_rgtc.h"
68 #include "texcompress_s3tc.h"
69 #include "texcompress_etc.h"
70 #include "texcompress_bptc.h"
74 #include "glformats.h"
75 #include "pixeltransfer.h"
76 #include "../../gallium/auxiliary/util/u_format_rgb9e5.h"
77 #include "../../gallium/auxiliary/util/u_format_r11g11b10f.h"
87 * Texture image storage function.
89 typedef GLboolean (*StoreTexImageFunc
)(TEXSTORE_PARAMS
);
93 * Teximage storage routine for when a simple memcpy will do.
94 * No pixel transfer operations or special texel encodings allowed.
95 * 1D, 2D and 3D images supported.
98 _mesa_memcpy_texture(struct gl_context
*ctx
,
100 mesa_format dstFormat
,
103 GLint srcWidth
, GLint srcHeight
, GLint srcDepth
,
104 GLenum srcFormat
, GLenum srcType
,
105 const GLvoid
*srcAddr
,
106 const struct gl_pixelstore_attrib
*srcPacking
)
108 const GLint srcRowStride
= _mesa_image_row_stride(srcPacking
, srcWidth
,
110 const GLint srcImageStride
= _mesa_image_image_stride(srcPacking
,
111 srcWidth
, srcHeight
, srcFormat
, srcType
);
112 const GLubyte
*srcImage
= (const GLubyte
*) _mesa_image_address(dimensions
,
113 srcPacking
, srcAddr
, srcWidth
, srcHeight
, srcFormat
, srcType
, 0, 0, 0);
114 const GLuint texelBytes
= _mesa_get_format_bytes(dstFormat
);
115 const GLint bytesPerRow
= srcWidth
* texelBytes
;
117 if (dstRowStride
== srcRowStride
&&
118 dstRowStride
== bytesPerRow
) {
119 /* memcpy image by image */
121 for (img
= 0; img
< srcDepth
; img
++) {
122 GLubyte
*dstImage
= dstSlices
[img
];
123 memcpy(dstImage
, srcImage
, bytesPerRow
* srcHeight
);
124 srcImage
+= srcImageStride
;
128 /* memcpy row by row */
130 for (img
= 0; img
< srcDepth
; img
++) {
131 const GLubyte
*srcRow
= srcImage
;
132 GLubyte
*dstRow
= dstSlices
[img
];
133 for (row
= 0; row
< srcHeight
; row
++) {
134 memcpy(dstRow
, srcRow
, bytesPerRow
);
135 dstRow
+= dstRowStride
;
136 srcRow
+= srcRowStride
;
138 srcImage
+= srcImageStride
;
145 * Store a 32-bit integer or float depth component texture image.
148 _mesa_texstore_z32(TEXSTORE_PARAMS
)
150 const GLuint depthScale
= 0xffffffff;
153 assert(dstFormat
== MESA_FORMAT_Z_UNORM32
||
154 dstFormat
== MESA_FORMAT_Z_FLOAT32
);
155 assert(_mesa_get_format_bytes(dstFormat
) == sizeof(GLuint
));
157 if (dstFormat
== MESA_FORMAT_Z_UNORM32
)
158 dstType
= GL_UNSIGNED_INT
;
165 for (img
= 0; img
< srcDepth
; img
++) {
166 GLubyte
*dstRow
= dstSlices
[img
];
167 for (row
= 0; row
< srcHeight
; row
++) {
168 const GLvoid
*src
= _mesa_image_address(dims
, srcPacking
,
169 srcAddr
, srcWidth
, srcHeight
, srcFormat
, srcType
, img
, row
, 0);
170 _mesa_unpack_depth_span(ctx
, srcWidth
,
172 depthScale
, srcType
, src
, srcPacking
);
173 dstRow
+= dstRowStride
;
182 * Store a 24-bit integer depth component texture image.
185 _mesa_texstore_x8_z24(TEXSTORE_PARAMS
)
187 const GLuint depthScale
= 0xffffff;
190 assert(dstFormat
== MESA_FORMAT_Z24_UNORM_X8_UINT
);
195 for (img
= 0; img
< srcDepth
; img
++) {
196 GLubyte
*dstRow
= dstSlices
[img
];
197 for (row
= 0; row
< srcHeight
; row
++) {
198 const GLvoid
*src
= _mesa_image_address(dims
, srcPacking
,
199 srcAddr
, srcWidth
, srcHeight
, srcFormat
, srcType
, img
, row
, 0);
200 _mesa_unpack_depth_span(ctx
, srcWidth
,
201 GL_UNSIGNED_INT
, (GLuint
*) dstRow
,
202 depthScale
, srcType
, src
, srcPacking
);
203 dstRow
+= dstRowStride
;
212 * Store a 24-bit integer depth component texture image.
215 _mesa_texstore_z24_x8(TEXSTORE_PARAMS
)
217 const GLuint depthScale
= 0xffffff;
220 assert(dstFormat
== MESA_FORMAT_X8_UINT_Z24_UNORM
);
225 for (img
= 0; img
< srcDepth
; img
++) {
226 GLubyte
*dstRow
= dstSlices
[img
];
227 for (row
= 0; row
< srcHeight
; row
++) {
228 const GLvoid
*src
= _mesa_image_address(dims
, srcPacking
,
229 srcAddr
, srcWidth
, srcHeight
, srcFormat
, srcType
, img
, row
, 0);
230 GLuint
*dst
= (GLuint
*) dstRow
;
232 _mesa_unpack_depth_span(ctx
, srcWidth
,
233 GL_UNSIGNED_INT
, dst
,
234 depthScale
, srcType
, src
, srcPacking
);
235 for (i
= 0; i
< srcWidth
; i
++)
237 dstRow
+= dstRowStride
;
246 * Store a 16-bit integer depth component texture image.
249 _mesa_texstore_z16(TEXSTORE_PARAMS
)
251 const GLuint depthScale
= 0xffff;
253 assert(dstFormat
== MESA_FORMAT_Z_UNORM16
);
254 assert(_mesa_get_format_bytes(dstFormat
) == sizeof(GLushort
));
259 for (img
= 0; img
< srcDepth
; img
++) {
260 GLubyte
*dstRow
= dstSlices
[img
];
261 for (row
= 0; row
< srcHeight
; row
++) {
262 const GLvoid
*src
= _mesa_image_address(dims
, srcPacking
,
263 srcAddr
, srcWidth
, srcHeight
, srcFormat
, srcType
, img
, row
, 0);
264 GLushort
*dst16
= (GLushort
*) dstRow
;
265 _mesa_unpack_depth_span(ctx
, srcWidth
,
266 GL_UNSIGNED_SHORT
, dst16
, depthScale
,
267 srcType
, src
, srcPacking
);
268 dstRow
+= dstRowStride
;
277 * Texstore for _mesa_texformat_ycbcr or _mesa_texformat_ycbcr_REV.
280 _mesa_texstore_ycbcr(TEXSTORE_PARAMS
)
282 const GLboolean littleEndian
= _mesa_little_endian();
284 (void) ctx
; (void) dims
; (void) baseInternalFormat
;
286 assert((dstFormat
== MESA_FORMAT_YCBCR
) ||
287 (dstFormat
== MESA_FORMAT_YCBCR_REV
));
288 assert(_mesa_get_format_bytes(dstFormat
) == 2);
289 assert(ctx
->Extensions
.MESA_ycbcr_texture
);
290 assert(srcFormat
== GL_YCBCR_MESA
);
291 assert((srcType
== GL_UNSIGNED_SHORT_8_8_MESA
) ||
292 (srcType
== GL_UNSIGNED_SHORT_8_8_REV_MESA
));
293 assert(baseInternalFormat
== GL_YCBCR_MESA
);
295 /* always just memcpy since no pixel transfer ops apply */
296 _mesa_memcpy_texture(ctx
, dims
,
298 dstRowStride
, dstSlices
,
299 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
300 srcAddr
, srcPacking
);
302 /* Check if we need byte swapping */
303 /* XXX the logic here _might_ be wrong */
304 if (srcPacking
->SwapBytes
^
305 (srcType
== GL_UNSIGNED_SHORT_8_8_REV_MESA
) ^
306 (dstFormat
== MESA_FORMAT_YCBCR_REV
) ^
309 for (img
= 0; img
< srcDepth
; img
++) {
310 GLubyte
*dstRow
= dstSlices
[img
];
311 for (row
= 0; row
< srcHeight
; row
++) {
312 _mesa_swap2((GLushort
*) dstRow
, srcWidth
);
313 dstRow
+= dstRowStride
;
322 * Store a combined depth/stencil texture image.
325 _mesa_texstore_z24_s8(TEXSTORE_PARAMS
)
327 const GLuint depthScale
= 0xffffff;
328 const GLint srcRowStride
329 = _mesa_image_row_stride(srcPacking
, srcWidth
, srcFormat
, srcType
);
331 GLuint
*depth
= malloc(srcWidth
* sizeof(GLuint
));
332 GLubyte
*stencil
= malloc(srcWidth
* sizeof(GLubyte
));
334 assert(dstFormat
== MESA_FORMAT_S8_UINT_Z24_UNORM
);
335 assert(srcFormat
== GL_DEPTH_STENCIL_EXT
||
336 srcFormat
== GL_DEPTH_COMPONENT
||
337 srcFormat
== GL_STENCIL_INDEX
);
338 assert(srcFormat
!= GL_DEPTH_STENCIL_EXT
||
339 srcType
== GL_UNSIGNED_INT_24_8_EXT
||
340 srcType
== GL_FLOAT_32_UNSIGNED_INT_24_8_REV
);
342 if (!depth
|| !stencil
) {
348 /* In case we only upload depth we need to preserve the stencil */
349 for (img
= 0; img
< srcDepth
; img
++) {
350 GLuint
*dstRow
= (GLuint
*) dstSlices
[img
];
352 = (const GLubyte
*) _mesa_image_address(dims
, srcPacking
, srcAddr
,
356 for (row
= 0; row
< srcHeight
; row
++) {
358 GLboolean keepdepth
= GL_FALSE
, keepstencil
= GL_FALSE
;
360 if (srcFormat
== GL_DEPTH_COMPONENT
) { /* preserve stencil */
361 keepstencil
= GL_TRUE
;
363 else if (srcFormat
== GL_STENCIL_INDEX
) { /* preserve depth */
367 if (keepdepth
== GL_FALSE
)
368 /* the 24 depth bits will be in the low position: */
369 _mesa_unpack_depth_span(ctx
, srcWidth
,
370 GL_UNSIGNED_INT
, /* dst type */
371 keepstencil
? depth
: dstRow
, /* dst addr */
373 srcType
, src
, srcPacking
);
375 if (keepstencil
== GL_FALSE
)
376 /* get the 8-bit stencil values */
377 _mesa_unpack_stencil_span(ctx
, srcWidth
,
378 GL_UNSIGNED_BYTE
, /* dst type */
379 stencil
, /* dst addr */
380 srcType
, src
, srcPacking
,
381 ctx
->_ImageTransferState
);
383 for (i
= 0; i
< srcWidth
; i
++) {
385 dstRow
[i
] = depth
[i
] << 8 | (dstRow
[i
] & 0x000000FF);
387 dstRow
[i
] = (dstRow
[i
] & 0xFFFFFF00) | (stencil
[i
] & 0xFF);
390 dstRow
+= dstRowStride
/ sizeof(GLuint
);
401 * Store a combined depth/stencil texture image.
404 _mesa_texstore_s8_z24(TEXSTORE_PARAMS
)
406 const GLuint depthScale
= 0xffffff;
407 const GLint srcRowStride
408 = _mesa_image_row_stride(srcPacking
, srcWidth
, srcFormat
, srcType
);
413 assert(dstFormat
== MESA_FORMAT_Z24_UNORM_S8_UINT
);
414 assert(srcFormat
== GL_DEPTH_STENCIL_EXT
||
415 srcFormat
== GL_DEPTH_COMPONENT
||
416 srcFormat
== GL_STENCIL_INDEX
);
417 assert(srcFormat
!= GL_DEPTH_STENCIL_EXT
||
418 srcType
== GL_UNSIGNED_INT_24_8_EXT
||
419 srcType
== GL_FLOAT_32_UNSIGNED_INT_24_8_REV
);
421 depth
= malloc(srcWidth
* sizeof(GLuint
));
422 stencil
= malloc(srcWidth
* sizeof(GLubyte
));
424 if (!depth
|| !stencil
) {
430 for (img
= 0; img
< srcDepth
; img
++) {
431 GLuint
*dstRow
= (GLuint
*) dstSlices
[img
];
433 = (const GLubyte
*) _mesa_image_address(dims
, srcPacking
, srcAddr
,
437 for (row
= 0; row
< srcHeight
; row
++) {
439 GLboolean keepdepth
= GL_FALSE
, keepstencil
= GL_FALSE
;
441 if (srcFormat
== GL_DEPTH_COMPONENT
) { /* preserve stencil */
442 keepstencil
= GL_TRUE
;
444 else if (srcFormat
== GL_STENCIL_INDEX
) { /* preserve depth */
448 if (keepdepth
== GL_FALSE
)
449 /* the 24 depth bits will be in the low position: */
450 _mesa_unpack_depth_span(ctx
, srcWidth
,
451 GL_UNSIGNED_INT
, /* dst type */
452 keepstencil
? depth
: dstRow
, /* dst addr */
454 srcType
, src
, srcPacking
);
456 if (keepstencil
== GL_FALSE
)
457 /* get the 8-bit stencil values */
458 _mesa_unpack_stencil_span(ctx
, srcWidth
,
459 GL_UNSIGNED_BYTE
, /* dst type */
460 stencil
, /* dst addr */
461 srcType
, src
, srcPacking
,
462 ctx
->_ImageTransferState
);
464 /* merge stencil values into depth values */
465 for (i
= 0; i
< srcWidth
; i
++) {
467 dstRow
[i
] = depth
[i
] | (dstRow
[i
] & 0xFF000000);
469 dstRow
[i
] = (dstRow
[i
] & 0xFFFFFF) | (stencil
[i
] << 24);
473 dstRow
+= dstRowStride
/ sizeof(GLuint
);
485 * Store simple 8-bit/value stencil texture data.
488 _mesa_texstore_s8(TEXSTORE_PARAMS
)
490 assert(dstFormat
== MESA_FORMAT_S_UINT8
);
491 assert(srcFormat
== GL_STENCIL_INDEX
);
494 const GLint srcRowStride
495 = _mesa_image_row_stride(srcPacking
, srcWidth
, srcFormat
, srcType
);
497 GLubyte
*stencil
= malloc(srcWidth
* sizeof(GLubyte
));
502 for (img
= 0; img
< srcDepth
; img
++) {
503 GLubyte
*dstRow
= dstSlices
[img
];
505 = (const GLubyte
*) _mesa_image_address(dims
, srcPacking
, srcAddr
,
509 for (row
= 0; row
< srcHeight
; row
++) {
512 /* get the 8-bit stencil values */
513 _mesa_unpack_stencil_span(ctx
, srcWidth
,
514 GL_UNSIGNED_BYTE
, /* dst type */
515 stencil
, /* dst addr */
516 srcType
, src
, srcPacking
,
517 ctx
->_ImageTransferState
);
518 /* merge stencil values into depth values */
519 for (i
= 0; i
< srcWidth
; i
++)
520 dstRow
[i
] = stencil
[i
];
523 dstRow
+= dstRowStride
/ sizeof(GLubyte
);
535 _mesa_texstore_z32f_x24s8(TEXSTORE_PARAMS
)
538 const GLint srcRowStride
539 = _mesa_image_row_stride(srcPacking
, srcWidth
, srcFormat
, srcType
)
542 assert(dstFormat
== MESA_FORMAT_Z32_FLOAT_S8X24_UINT
);
543 assert(srcFormat
== GL_DEPTH_STENCIL
||
544 srcFormat
== GL_DEPTH_COMPONENT
||
545 srcFormat
== GL_STENCIL_INDEX
);
546 assert(srcFormat
!= GL_DEPTH_STENCIL
||
547 srcType
== GL_UNSIGNED_INT_24_8
||
548 srcType
== GL_FLOAT_32_UNSIGNED_INT_24_8_REV
);
550 /* In case we only upload depth we need to preserve the stencil */
551 for (img
= 0; img
< srcDepth
; img
++) {
552 uint64_t *dstRow
= (uint64_t *) dstSlices
[img
];
554 = (const uint64_t *) _mesa_image_address(dims
, srcPacking
, srcAddr
,
558 for (row
= 0; row
< srcHeight
; row
++) {
559 /* The unpack functions with:
560 * dstType = GL_FLOAT_32_UNSIGNED_INT_24_8_REV
561 * only write their own dword, so the other dword (stencil
562 * or depth) is preserved. */
563 if (srcFormat
!= GL_STENCIL_INDEX
)
564 _mesa_unpack_depth_span(ctx
, srcWidth
,
565 GL_FLOAT_32_UNSIGNED_INT_24_8_REV
, /* dst type */
566 dstRow
, /* dst addr */
567 ~0U, srcType
, src
, srcPacking
);
569 if (srcFormat
!= GL_DEPTH_COMPONENT
)
570 _mesa_unpack_stencil_span(ctx
, srcWidth
,
571 GL_FLOAT_32_UNSIGNED_INT_24_8_REV
, /* dst type */
572 dstRow
, /* dst addr */
573 srcType
, src
, srcPacking
,
574 ctx
->_ImageTransferState
);
577 dstRow
+= dstRowStride
/ sizeof(uint64_t);
584 texstore_depth_stencil(TEXSTORE_PARAMS
)
586 static StoreTexImageFunc table
[MESA_FORMAT_COUNT
];
587 static GLboolean initialized
= GL_FALSE
;
590 memset(table
, 0, sizeof table
);
592 table
[MESA_FORMAT_S8_UINT_Z24_UNORM
] = _mesa_texstore_z24_s8
;
593 table
[MESA_FORMAT_Z24_UNORM_S8_UINT
] = _mesa_texstore_s8_z24
;
594 table
[MESA_FORMAT_Z_UNORM16
] = _mesa_texstore_z16
;
595 table
[MESA_FORMAT_Z24_UNORM_X8_UINT
] = _mesa_texstore_x8_z24
;
596 table
[MESA_FORMAT_X8_UINT_Z24_UNORM
] = _mesa_texstore_z24_x8
;
597 table
[MESA_FORMAT_Z_UNORM32
] = _mesa_texstore_z32
;
598 table
[MESA_FORMAT_S_UINT8
] = _mesa_texstore_s8
;
599 table
[MESA_FORMAT_Z_FLOAT32
] = _mesa_texstore_z32
;
600 table
[MESA_FORMAT_Z32_FLOAT_S8X24_UINT
] = _mesa_texstore_z32f_x24s8
;
602 initialized
= GL_TRUE
;
605 assert(table
[dstFormat
]);
606 return table
[dstFormat
](ctx
, dims
, baseInternalFormat
,
607 dstFormat
, dstRowStride
, dstSlices
,
608 srcWidth
, srcHeight
, srcDepth
,
609 srcFormat
, srcType
, srcAddr
, srcPacking
);
613 texstore_compressed(TEXSTORE_PARAMS
)
615 static StoreTexImageFunc table
[MESA_FORMAT_COUNT
];
616 static GLboolean initialized
= GL_FALSE
;
619 memset(table
, 0, sizeof table
);
621 table
[MESA_FORMAT_SRGB_DXT1
] = _mesa_texstore_rgb_dxt1
;
622 table
[MESA_FORMAT_SRGBA_DXT1
] = _mesa_texstore_rgba_dxt1
;
623 table
[MESA_FORMAT_SRGBA_DXT3
] = _mesa_texstore_rgba_dxt3
;
624 table
[MESA_FORMAT_SRGBA_DXT5
] = _mesa_texstore_rgba_dxt5
;
625 table
[MESA_FORMAT_RGB_FXT1
] = _mesa_texstore_rgb_fxt1
;
626 table
[MESA_FORMAT_RGBA_FXT1
] = _mesa_texstore_rgba_fxt1
;
627 table
[MESA_FORMAT_RGB_DXT1
] = _mesa_texstore_rgb_dxt1
;
628 table
[MESA_FORMAT_RGBA_DXT1
] = _mesa_texstore_rgba_dxt1
;
629 table
[MESA_FORMAT_RGBA_DXT3
] = _mesa_texstore_rgba_dxt3
;
630 table
[MESA_FORMAT_RGBA_DXT5
] = _mesa_texstore_rgba_dxt5
;
631 table
[MESA_FORMAT_R_RGTC1_UNORM
] = _mesa_texstore_red_rgtc1
;
632 table
[MESA_FORMAT_R_RGTC1_SNORM
] = _mesa_texstore_signed_red_rgtc1
;
633 table
[MESA_FORMAT_RG_RGTC2_UNORM
] = _mesa_texstore_rg_rgtc2
;
634 table
[MESA_FORMAT_RG_RGTC2_SNORM
] = _mesa_texstore_signed_rg_rgtc2
;
635 table
[MESA_FORMAT_L_LATC1_UNORM
] = _mesa_texstore_red_rgtc1
;
636 table
[MESA_FORMAT_L_LATC1_SNORM
] = _mesa_texstore_signed_red_rgtc1
;
637 table
[MESA_FORMAT_LA_LATC2_UNORM
] = _mesa_texstore_rg_rgtc2
;
638 table
[MESA_FORMAT_LA_LATC2_SNORM
] = _mesa_texstore_signed_rg_rgtc2
;
639 table
[MESA_FORMAT_ETC1_RGB8
] = _mesa_texstore_etc1_rgb8
;
640 table
[MESA_FORMAT_ETC2_RGB8
] = _mesa_texstore_etc2_rgb8
;
641 table
[MESA_FORMAT_ETC2_SRGB8
] = _mesa_texstore_etc2_srgb8
;
642 table
[MESA_FORMAT_ETC2_RGBA8_EAC
] = _mesa_texstore_etc2_rgba8_eac
;
643 table
[MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC
] = _mesa_texstore_etc2_srgb8_alpha8_eac
;
644 table
[MESA_FORMAT_ETC2_R11_EAC
] = _mesa_texstore_etc2_r11_eac
;
645 table
[MESA_FORMAT_ETC2_RG11_EAC
] = _mesa_texstore_etc2_rg11_eac
;
646 table
[MESA_FORMAT_ETC2_SIGNED_R11_EAC
] = _mesa_texstore_etc2_signed_r11_eac
;
647 table
[MESA_FORMAT_ETC2_SIGNED_RG11_EAC
] = _mesa_texstore_etc2_signed_rg11_eac
;
648 table
[MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1
] =
649 _mesa_texstore_etc2_rgb8_punchthrough_alpha1
;
650 table
[MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
] =
651 _mesa_texstore_etc2_srgb8_punchthrough_alpha1
;
653 table
[MESA_FORMAT_BPTC_RGBA_UNORM
] =
654 _mesa_texstore_bptc_rgba_unorm
;
655 table
[MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM
] =
656 _mesa_texstore_bptc_rgba_unorm
;
657 table
[MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT
] =
658 _mesa_texstore_bptc_rgb_signed_float
;
659 table
[MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT
] =
660 _mesa_texstore_bptc_rgb_unsigned_float
;
662 initialized
= GL_TRUE
;
665 assert(table
[dstFormat
]);
666 return table
[dstFormat
](ctx
, dims
, baseInternalFormat
,
667 dstFormat
, dstRowStride
, dstSlices
,
668 srcWidth
, srcHeight
, srcDepth
,
669 srcFormat
, srcType
, srcAddr
, srcPacking
);
673 texstore_rgba(TEXSTORE_PARAMS
)
675 void *tempImage
= NULL
, *tempRGBA
= NULL
;
676 int srcRowStride
, img
;
678 uint32_t srcMesaFormat
;
679 uint8_t rebaseSwizzle
[4];
681 bool transferOpsDone
= false;
683 /* We have to handle MESA_FORMAT_YCBCR manually because it is a special case
684 * and _mesa_format_convert does not support it. In this case the we only
685 * allow conversions between YCBCR formats and it is mostly a memcpy.
687 if (dstFormat
== MESA_FORMAT_YCBCR
|| dstFormat
== MESA_FORMAT_YCBCR_REV
) {
688 return _mesa_texstore_ycbcr(ctx
, dims
, baseInternalFormat
,
689 dstFormat
, dstRowStride
, dstSlices
,
690 srcWidth
, srcHeight
, srcDepth
,
691 srcFormat
, srcType
, srcAddr
,
695 /* We have to deal with GL_COLOR_INDEX manually because
696 * _mesa_format_convert does not handle this format. So what we do here is
697 * convert it to RGBA ubyte first and then convert from that to dst as usual.
699 if (srcFormat
== GL_COLOR_INDEX
) {
700 /* Notice that this will already handle byte swapping if necessary */
702 _mesa_unpack_color_index_to_rgba_ubyte(ctx
, dims
,
703 srcAddr
, srcFormat
, srcType
,
704 srcWidth
, srcHeight
, srcDepth
,
706 ctx
->_ImageTransferState
);
710 /* _mesa_unpack_color_index_to_rgba_ubyte has handled transferops
713 transferOpsDone
= true;
715 /* Now we only have to adjust our src info for a conversion from
716 * the RGBA ubyte and then we continue as usual.
720 srcType
= GL_UNSIGNED_BYTE
;
721 } else if (srcPacking
->SwapBytes
) {
722 /* We have to handle byte-swapping scenarios before calling
723 * _mesa_format_convert
725 GLint swapSize
= _mesa_sizeof_packed_type(srcType
);
726 if (swapSize
== 2 || swapSize
== 4) {
727 int imageStride
= _mesa_image_image_stride(srcPacking
, srcWidth
, srcHeight
, srcFormat
, srcType
);
728 int bufferSize
= imageStride
* srcDepth
;
733 tempImage
= malloc(bufferSize
);
738 for (layer
= 0; layer
< srcDepth
; layer
++) {
739 _mesa_swap_bytes_2d_image(srcFormat
, srcType
,
751 _mesa_image_row_stride(srcPacking
, srcWidth
, srcFormat
, srcType
);
753 srcMesaFormat
= _mesa_format_from_format_and_type(srcFormat
, srcType
);
754 dstFormat
= _mesa_get_srgb_format_linear(dstFormat
);
756 /* If we have transferOps then we need to convert to RGBA float first,
757 then apply transferOps, then do the conversion to dst
759 if (!transferOpsDone
&&
760 _mesa_texstore_needs_transfer_ops(ctx
, baseInternalFormat
, dstFormat
)) {
761 /* Allocate RGBA float image */
762 int elementCount
= srcWidth
* srcHeight
* srcDepth
;
763 tempRGBA
= malloc(4 * elementCount
* sizeof(float));
770 /* Convert from src to RGBA float */
771 src
= (GLubyte
*) srcAddr
;
772 dst
= (GLubyte
*) tempRGBA
;
773 for (img
= 0; img
< srcDepth
; img
++) {
774 _mesa_format_convert(dst
, RGBA32_FLOAT
, 4 * srcWidth
* sizeof(float),
775 src
, srcMesaFormat
, srcRowStride
,
776 srcWidth
, srcHeight
, NULL
);
777 src
+= srcHeight
* srcRowStride
;
778 dst
+= srcHeight
* 4 * srcWidth
* sizeof(float);
781 /* Apply transferOps */
782 _mesa_apply_rgba_transfer_ops(ctx
, ctx
->_ImageTransferState
, elementCount
,
783 (float(*)[4]) tempRGBA
);
785 /* Now we have to adjust our src info for a conversion from
786 * the RGBA float image and then we continue as usual.
791 srcRowStride
= srcWidth
* 4 * sizeof(float);
792 srcMesaFormat
= RGBA32_FLOAT
;
793 srcPacking
= &ctx
->DefaultPacking
;
797 _mesa_image_address(dims
, srcPacking
, srcAddr
, srcWidth
, srcHeight
,
798 srcFormat
, srcType
, 0, 0, 0);
800 if (_mesa_get_format_base_format(dstFormat
) != baseInternalFormat
) {
802 _mesa_compute_rgba2base2rgba_component_mapping(baseInternalFormat
,
808 for (img
= 0; img
< srcDepth
; img
++) {
809 _mesa_format_convert(dstSlices
[img
], dstFormat
, dstRowStride
,
810 src
, srcMesaFormat
, srcRowStride
,
812 needRebase
? rebaseSwizzle
: NULL
);
813 src
+= srcHeight
* srcRowStride
;
823 _mesa_texstore_needs_transfer_ops(struct gl_context
*ctx
,
824 GLenum baseInternalFormat
,
825 mesa_format dstFormat
)
829 /* There are different rules depending on the base format. */
830 switch (baseInternalFormat
) {
831 case GL_DEPTH_COMPONENT
:
832 case GL_DEPTH_STENCIL
:
833 return ctx
->Pixel
.DepthScale
!= 1.0f
||
834 ctx
->Pixel
.DepthBias
!= 0.0f
;
836 case GL_STENCIL_INDEX
:
841 * Pixel transfer ops (scale, bias, table lookup) do not apply
842 * to integer formats.
844 dstType
= _mesa_get_format_datatype(dstFormat
);
846 return dstType
!= GL_INT
&& dstType
!= GL_UNSIGNED_INT
&&
847 ctx
->_ImageTransferState
;
853 _mesa_texstore_can_use_memcpy(struct gl_context
*ctx
,
854 GLenum baseInternalFormat
, mesa_format dstFormat
,
855 GLenum srcFormat
, GLenum srcType
,
856 const struct gl_pixelstore_attrib
*srcPacking
)
858 if (_mesa_texstore_needs_transfer_ops(ctx
, baseInternalFormat
, dstFormat
)) {
862 /* The base internal format and the base Mesa format must match. */
863 if (baseInternalFormat
!= _mesa_get_format_base_format(dstFormat
)) {
867 /* The Mesa format must match the input format and type. */
868 if (!_mesa_format_matches_format_and_type(dstFormat
, srcFormat
, srcType
,
869 srcPacking
->SwapBytes
, NULL
)) {
873 /* Depth texture data needs clamping in following cases:
874 * - Floating point dstFormat with signed srcType: clamp to [0.0, 1.0].
875 * - Fixed point dstFormat with signed srcType: clamp to [0, 2^n -1].
877 * All the cases except one (float dstFormat with float srcType) are ruled
878 * out by _mesa_format_matches_format_and_type() check above. Handle the
879 * remaining case here.
881 if ((baseInternalFormat
== GL_DEPTH_COMPONENT
||
882 baseInternalFormat
== GL_DEPTH_STENCIL
) &&
883 (srcType
== GL_FLOAT
||
884 srcType
== GL_FLOAT_32_UNSIGNED_INT_24_8_REV
)) {
892 _mesa_texstore_memcpy(TEXSTORE_PARAMS
)
894 if (!_mesa_texstore_can_use_memcpy(ctx
, baseInternalFormat
, dstFormat
,
895 srcFormat
, srcType
, srcPacking
)) {
899 _mesa_memcpy_texture(ctx
, dims
,
901 dstRowStride
, dstSlices
,
902 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
903 srcAddr
, srcPacking
);
909 * Store user data into texture memory.
910 * Called via glTex[Sub]Image1/2/3D()
911 * \return GL_TRUE for success, GL_FALSE for failure (out of memory).
914 _mesa_texstore(TEXSTORE_PARAMS
)
916 if (_mesa_texstore_memcpy(ctx
, dims
, baseInternalFormat
,
918 dstRowStride
, dstSlices
,
919 srcWidth
, srcHeight
, srcDepth
,
920 srcFormat
, srcType
, srcAddr
, srcPacking
)) {
924 if (_mesa_is_depth_or_stencil_format(baseInternalFormat
)) {
925 return texstore_depth_stencil(ctx
, dims
, baseInternalFormat
,
926 dstFormat
, dstRowStride
, dstSlices
,
927 srcWidth
, srcHeight
, srcDepth
,
928 srcFormat
, srcType
, srcAddr
, srcPacking
);
929 } else if (_mesa_is_format_compressed(dstFormat
)) {
930 return texstore_compressed(ctx
, dims
, baseInternalFormat
,
931 dstFormat
, dstRowStride
, dstSlices
,
932 srcWidth
, srcHeight
, srcDepth
,
933 srcFormat
, srcType
, srcAddr
, srcPacking
);
935 return texstore_rgba(ctx
, dims
, baseInternalFormat
,
936 dstFormat
, dstRowStride
, dstSlices
,
937 srcWidth
, srcHeight
, srcDepth
,
938 srcFormat
, srcType
, srcAddr
, srcPacking
);
944 * Normally, we'll only _write_ texel data to a texture when we map it.
945 * But if the user is providing depth or stencil values and the texture
946 * image is a combined depth/stencil format, we'll actually read from
947 * the texture buffer too (in order to insert the depth or stencil values.
948 * \param userFormat the user-provided image format
949 * \param texFormat the destination texture format
952 get_read_write_mode(GLenum userFormat
, mesa_format texFormat
)
954 if ((userFormat
== GL_STENCIL_INDEX
|| userFormat
== GL_DEPTH_COMPONENT
)
955 && _mesa_get_format_base_format(texFormat
) == GL_DEPTH_STENCIL
)
956 return GL_MAP_READ_BIT
| GL_MAP_WRITE_BIT
;
958 return GL_MAP_WRITE_BIT
| GL_MAP_INVALIDATE_RANGE_BIT
;
963 * Helper function for storing 1D, 2D, 3D whole and subimages into texture
965 * The source of the image data may be user memory or a PBO. In the later
966 * case, we'll map the PBO, copy from it, then unmap it.
969 store_texsubimage(struct gl_context
*ctx
,
970 struct gl_texture_image
*texImage
,
971 GLint xoffset
, GLint yoffset
, GLint zoffset
,
972 GLint width
, GLint height
, GLint depth
,
973 GLenum format
, GLenum type
, const GLvoid
*pixels
,
974 const struct gl_pixelstore_attrib
*packing
,
978 const GLbitfield mapMode
= get_read_write_mode(format
, texImage
->TexFormat
);
979 const GLenum target
= texImage
->TexObject
->Target
;
980 GLboolean success
= GL_FALSE
;
981 GLuint dims
, slice
, numSlices
= 1, sliceOffset
= 0;
982 GLint srcImageStride
= 0;
985 assert(xoffset
+ width
<= texImage
->Width
);
986 assert(yoffset
+ height
<= texImage
->Height
);
987 assert(zoffset
+ depth
<= texImage
->Depth
);
993 case GL_TEXTURE_2D_ARRAY
:
994 case GL_TEXTURE_CUBE_MAP_ARRAY
:
1002 /* get pointer to src pixels (may be in a pbo which we'll map here) */
1003 src
= (const GLubyte
*)
1004 _mesa_validate_pbo_teximage(ctx
, dims
, width
, height
, depth
,
1005 format
, type
, pixels
, packing
, caller
);
1009 /* compute slice info (and do some sanity checks) */
1012 case GL_TEXTURE_2D_MULTISAMPLE
:
1013 case GL_TEXTURE_RECTANGLE
:
1014 case GL_TEXTURE_CUBE_MAP
:
1015 case GL_TEXTURE_EXTERNAL_OES
:
1016 /* one image slice, nothing special needs to be done */
1019 assert(height
== 1);
1021 assert(yoffset
== 0);
1022 assert(zoffset
== 0);
1024 case GL_TEXTURE_1D_ARRAY
:
1026 assert(zoffset
== 0);
1028 sliceOffset
= yoffset
;
1031 srcImageStride
= _mesa_image_row_stride(packing
, width
, format
, type
);
1033 case GL_TEXTURE_2D_ARRAY
:
1034 case GL_TEXTURE_2D_MULTISAMPLE_ARRAY
:
1036 sliceOffset
= zoffset
;
1039 srcImageStride
= _mesa_image_image_stride(packing
, width
, height
,
1043 /* we'll store 3D images as a series of slices */
1045 sliceOffset
= zoffset
;
1046 srcImageStride
= _mesa_image_image_stride(packing
, width
, height
,
1049 case GL_TEXTURE_CUBE_MAP_ARRAY
:
1051 sliceOffset
= zoffset
;
1052 srcImageStride
= _mesa_image_image_stride(packing
, width
, height
,
1056 _mesa_warning(ctx
, "Unexpected target 0x%x in store_texsubimage()", target
);
1060 assert(numSlices
== 1 || srcImageStride
!= 0);
1062 for (slice
= 0; slice
< numSlices
; slice
++) {
1066 ctx
->Driver
.MapTextureImage(ctx
, texImage
,
1067 slice
+ sliceOffset
,
1068 xoffset
, yoffset
, width
, height
,
1069 mapMode
, &dstMap
, &dstRowStride
);
1071 /* Note: we're only storing a 2D (or 1D) slice at a time but we need
1072 * to pass the right 'dims' value so that GL_UNPACK_SKIP_IMAGES is
1073 * used for 3D images.
1075 success
= _mesa_texstore(ctx
, dims
, texImage
->_BaseFormat
,
1076 texImage
->TexFormat
,
1079 width
, height
, 1, /* w, h, d */
1080 format
, type
, src
, packing
);
1082 ctx
->Driver
.UnmapTextureImage(ctx
, texImage
, slice
+ sliceOffset
);
1085 src
+= srcImageStride
;
1092 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "%s", caller
);
1094 _mesa_unmap_teximage_pbo(ctx
, packing
);
1100 * Fallback code for ctx->Driver.TexImage().
1101 * Basically, allocate storage for the texture image, then copy the
1102 * user's image into it.
1105 _mesa_store_teximage(struct gl_context
*ctx
,
1107 struct gl_texture_image
*texImage
,
1108 GLenum format
, GLenum type
, const GLvoid
*pixels
,
1109 const struct gl_pixelstore_attrib
*packing
)
1111 assert(dims
== 1 || dims
== 2 || dims
== 3);
1113 if (texImage
->Width
== 0 || texImage
->Height
== 0 || texImage
->Depth
== 0)
1116 /* allocate storage for texture data */
1117 if (!ctx
->Driver
.AllocTextureImageBuffer(ctx
, texImage
)) {
1118 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexImage%uD", dims
);
1122 store_texsubimage(ctx
, texImage
,
1123 0, 0, 0, texImage
->Width
, texImage
->Height
, texImage
->Depth
,
1124 format
, type
, pixels
, packing
, "glTexImage");
1129 * Fallback for Driver.TexSubImage().
1132 _mesa_store_texsubimage(struct gl_context
*ctx
, GLuint dims
,
1133 struct gl_texture_image
*texImage
,
1134 GLint xoffset
, GLint yoffset
, GLint zoffset
,
1135 GLint width
, GLint height
, GLint depth
,
1136 GLenum format
, GLenum type
, const void *pixels
,
1137 const struct gl_pixelstore_attrib
*packing
)
1139 store_texsubimage(ctx
, texImage
,
1140 xoffset
, yoffset
, zoffset
, width
, height
, depth
,
1141 format
, type
, pixels
, packing
, "glTexSubImage");
1145 clear_image_to_zero(GLubyte
*dstMap
, GLint dstRowStride
,
1146 GLsizei width
, GLsizei height
,
1147 GLsizei clearValueSize
)
1151 for (y
= 0; y
< height
; y
++) {
1152 memset(dstMap
, 0, clearValueSize
* width
);
1153 dstMap
+= dstRowStride
;
1158 clear_image_to_value(GLubyte
*dstMap
, GLint dstRowStride
,
1159 GLsizei width
, GLsizei height
,
1160 const GLvoid
*clearValue
,
1161 GLsizei clearValueSize
)
1165 for (y
= 0; y
< height
; y
++) {
1166 for (x
= 0; x
< width
; x
++) {
1167 memcpy(dstMap
, clearValue
, clearValueSize
);
1168 dstMap
+= clearValueSize
;
1170 dstMap
+= dstRowStride
- clearValueSize
* width
;
1175 * Fallback for Driver.ClearTexSubImage().
1178 _mesa_store_cleartexsubimage(struct gl_context
*ctx
,
1179 struct gl_texture_image
*texImage
,
1180 GLint xoffset
, GLint yoffset
, GLint zoffset
,
1181 GLsizei width
, GLsizei height
, GLsizei depth
,
1182 const GLvoid
*clearValue
)
1186 GLsizeiptr clearValueSize
;
1189 clearValueSize
= _mesa_get_format_bytes(texImage
->TexFormat
);
1191 for (z
= 0; z
< depth
; z
++) {
1192 ctx
->Driver
.MapTextureImage(ctx
, texImage
,
1193 z
+ zoffset
, xoffset
, yoffset
,
1196 &dstMap
, &dstRowStride
);
1197 if (dstMap
== NULL
) {
1198 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glClearTex*Image");
1203 clear_image_to_value(dstMap
, dstRowStride
,
1208 clear_image_to_zero(dstMap
, dstRowStride
,
1213 ctx
->Driver
.UnmapTextureImage(ctx
, texImage
, z
+ zoffset
);
1218 * Fallback for Driver.CompressedTexImage()
1221 _mesa_store_compressed_teximage(struct gl_context
*ctx
, GLuint dims
,
1222 struct gl_texture_image
*texImage
,
1223 GLsizei imageSize
, const GLvoid
*data
)
1225 /* only 2D and 3D compressed images are supported at this time */
1227 _mesa_problem(ctx
, "Unexpected glCompressedTexImage1D call");
1231 /* This is pretty simple, because unlike the general texstore path we don't
1232 * have to worry about the usual image unpacking or image transfer
1236 assert(texImage
->Width
> 0);
1237 assert(texImage
->Height
> 0);
1238 assert(texImage
->Depth
> 0);
1240 /* allocate storage for texture data */
1241 if (!ctx
->Driver
.AllocTextureImageBuffer(ctx
, texImage
)) {
1242 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glCompressedTexImage%uD", dims
);
1246 ctx
->Driver
.CompressedTexSubImage(ctx
, dims
, texImage
,
1248 texImage
->Width
, texImage
->Height
, texImage
->Depth
,
1249 texImage
->TexFormat
,
1255 * Compute compressed_pixelstore parameters for copying compressed
1257 * \param dims number of texture image dimensions: 1, 2 or 3
1258 * \param texFormat the compressed texture format
1259 * \param width, height, depth size of image to copy
1260 * \param packing pixelstore parameters describing user-space image packing
1261 * \param store returns the compressed_pixelstore parameters
1264 _mesa_compute_compressed_pixelstore(GLuint dims
, mesa_format texFormat
,
1265 GLsizei width
, GLsizei height
,
1267 const struct gl_pixelstore_attrib
*packing
,
1268 struct compressed_pixelstore
*store
)
1272 _mesa_get_format_block_size(texFormat
, &bw
, &bh
);
1274 store
->SkipBytes
= 0;
1275 store
->TotalBytesPerRow
= store
->CopyBytesPerRow
=
1276 _mesa_format_row_stride(texFormat
, width
);
1277 store
->TotalRowsPerSlice
= store
->CopyRowsPerSlice
=
1278 (height
+ bh
- 1) / bh
;
1279 store
->CopySlices
= depth
;
1281 if (packing
->CompressedBlockWidth
&&
1282 packing
->CompressedBlockSize
) {
1284 bw
= packing
->CompressedBlockWidth
;
1286 if (packing
->RowLength
) {
1287 store
->TotalBytesPerRow
= packing
->CompressedBlockSize
*
1288 ((packing
->RowLength
+ bw
- 1) / bw
);
1291 store
->SkipBytes
+= packing
->SkipPixels
* packing
->CompressedBlockSize
/ bw
;
1294 if (dims
> 1 && packing
->CompressedBlockHeight
&&
1295 packing
->CompressedBlockSize
) {
1297 bh
= packing
->CompressedBlockHeight
;
1299 store
->SkipBytes
+= packing
->SkipRows
* store
->TotalBytesPerRow
/ bh
;
1300 store
->CopyRowsPerSlice
= (height
+ bh
- 1) / bh
; /* rows in blocks */
1302 if (packing
->ImageHeight
) {
1303 store
->TotalRowsPerSlice
= (packing
->ImageHeight
+ bh
- 1) / bh
;
1307 if (dims
> 2 && packing
->CompressedBlockDepth
&&
1308 packing
->CompressedBlockSize
) {
1310 int bd
= packing
->CompressedBlockDepth
;
1312 store
->SkipBytes
+= packing
->SkipImages
* store
->TotalBytesPerRow
*
1313 store
->TotalRowsPerSlice
/ bd
;
1319 * Fallback for Driver.CompressedTexSubImage()
1322 _mesa_store_compressed_texsubimage(struct gl_context
*ctx
, GLuint dims
,
1323 struct gl_texture_image
*texImage
,
1324 GLint xoffset
, GLint yoffset
, GLint zoffset
,
1325 GLsizei width
, GLsizei height
, GLsizei depth
,
1327 GLsizei imageSize
, const GLvoid
*data
)
1329 struct compressed_pixelstore store
;
1336 _mesa_problem(ctx
, "Unexpected 1D compressed texsubimage call");
1340 _mesa_compute_compressed_pixelstore(dims
, texImage
->TexFormat
,
1341 width
, height
, depth
,
1342 &ctx
->Unpack
, &store
);
1344 /* get pointer to src pixels (may be in a pbo which we'll map here) */
1345 data
= _mesa_validate_pbo_compressed_teximage(ctx
, dims
, imageSize
, data
,
1347 "glCompressedTexSubImage");
1351 src
= (const GLubyte
*) data
+ store
.SkipBytes
;
1353 for (slice
= 0; slice
< store
.CopySlices
; slice
++) {
1354 /* Map dest texture buffer */
1355 ctx
->Driver
.MapTextureImage(ctx
, texImage
, slice
+ zoffset
,
1356 xoffset
, yoffset
, width
, height
,
1357 GL_MAP_WRITE_BIT
| GL_MAP_INVALIDATE_RANGE_BIT
,
1358 &dstMap
, &dstRowStride
);
1362 /* copy rows of blocks */
1363 for (i
= 0; i
< store
.CopyRowsPerSlice
; i
++) {
1364 memcpy(dstMap
, src
, store
.CopyBytesPerRow
);
1365 dstMap
+= dstRowStride
;
1366 src
+= store
.TotalBytesPerRow
;
1369 ctx
->Driver
.UnmapTextureImage(ctx
, texImage
, slice
+ zoffset
);
1371 /* advance to next slice */
1372 src
+= store
.TotalBytesPerRow
* (store
.TotalRowsPerSlice
- store
.CopyRowsPerSlice
);
1375 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glCompressedTexSubImage%uD",
1380 _mesa_unmap_teximage_pbo(ctx
, &ctx
->Unpack
);