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.
56 #include "bufferobj.h"
57 #include "format_pack.h"
58 #include "format_utils.h"
66 #include "texcompress.h"
67 #include "texcompress_fxt1.h"
68 #include "texcompress_rgtc.h"
69 #include "texcompress_s3tc.h"
70 #include "texcompress_etc.h"
71 #include "texcompress_bptc.h"
75 #include "glformats.h"
76 #include "pixeltransfer.h"
77 #include "util/format_rgb9e5.h"
78 #include "util/format_r11g11b10f.h"
88 * Texture image storage function.
90 typedef GLboolean (*StoreTexImageFunc
)(TEXSTORE_PARAMS
);
94 * Teximage storage routine for when a simple memcpy will do.
95 * No pixel transfer operations or special texel encodings allowed.
96 * 1D, 2D and 3D images supported.
99 _mesa_memcpy_texture(struct gl_context
*ctx
,
101 mesa_format dstFormat
,
104 GLint srcWidth
, GLint srcHeight
, GLint srcDepth
,
105 GLenum srcFormat
, GLenum srcType
,
106 const GLvoid
*srcAddr
,
107 const struct gl_pixelstore_attrib
*srcPacking
)
109 const GLint srcRowStride
= _mesa_image_row_stride(srcPacking
, srcWidth
,
111 const GLint srcImageStride
= _mesa_image_image_stride(srcPacking
,
112 srcWidth
, srcHeight
, srcFormat
, srcType
);
113 const GLubyte
*srcImage
= (const GLubyte
*) _mesa_image_address(dimensions
,
114 srcPacking
, srcAddr
, srcWidth
, srcHeight
, srcFormat
, srcType
, 0, 0, 0);
115 const GLuint texelBytes
= _mesa_get_format_bytes(dstFormat
);
116 const GLint bytesPerRow
= srcWidth
* texelBytes
;
118 if (dstRowStride
== srcRowStride
&&
119 dstRowStride
== bytesPerRow
) {
120 /* memcpy image by image */
122 for (img
= 0; img
< srcDepth
; img
++) {
123 GLubyte
*dstImage
= dstSlices
[img
];
124 memcpy(dstImage
, srcImage
, bytesPerRow
* srcHeight
);
125 srcImage
+= srcImageStride
;
129 /* memcpy row by row */
131 for (img
= 0; img
< srcDepth
; img
++) {
132 const GLubyte
*srcRow
= srcImage
;
133 GLubyte
*dstRow
= dstSlices
[img
];
134 for (row
= 0; row
< srcHeight
; row
++) {
135 memcpy(dstRow
, srcRow
, bytesPerRow
);
136 dstRow
+= dstRowStride
;
137 srcRow
+= srcRowStride
;
139 srcImage
+= srcImageStride
;
146 * Store a 32-bit integer or float depth component texture image.
149 _mesa_texstore_z32(TEXSTORE_PARAMS
)
151 const GLuint depthScale
= 0xffffffff;
154 assert(dstFormat
== MESA_FORMAT_Z_UNORM32
||
155 dstFormat
== MESA_FORMAT_Z_FLOAT32
);
156 assert(_mesa_get_format_bytes(dstFormat
) == sizeof(GLuint
));
158 if (dstFormat
== MESA_FORMAT_Z_UNORM32
)
159 dstType
= GL_UNSIGNED_INT
;
166 for (img
= 0; img
< srcDepth
; img
++) {
167 GLubyte
*dstRow
= dstSlices
[img
];
168 for (row
= 0; row
< srcHeight
; row
++) {
169 const GLvoid
*src
= _mesa_image_address(dims
, srcPacking
,
170 srcAddr
, srcWidth
, srcHeight
, srcFormat
, srcType
, img
, row
, 0);
171 _mesa_unpack_depth_span(ctx
, srcWidth
,
173 depthScale
, srcType
, src
, srcPacking
);
174 dstRow
+= dstRowStride
;
183 * Store a 24-bit integer depth component texture image.
186 _mesa_texstore_x8_z24(TEXSTORE_PARAMS
)
188 const GLuint depthScale
= 0xffffff;
191 assert(dstFormat
== MESA_FORMAT_Z24_UNORM_X8_UINT
);
196 for (img
= 0; img
< srcDepth
; img
++) {
197 GLubyte
*dstRow
= dstSlices
[img
];
198 for (row
= 0; row
< srcHeight
; row
++) {
199 const GLvoid
*src
= _mesa_image_address(dims
, srcPacking
,
200 srcAddr
, srcWidth
, srcHeight
, srcFormat
, srcType
, img
, row
, 0);
201 _mesa_unpack_depth_span(ctx
, srcWidth
,
202 GL_UNSIGNED_INT
, (GLuint
*) dstRow
,
203 depthScale
, srcType
, src
, srcPacking
);
204 dstRow
+= dstRowStride
;
213 * Store a 24-bit integer depth component texture image.
216 _mesa_texstore_z24_x8(TEXSTORE_PARAMS
)
218 const GLuint depthScale
= 0xffffff;
221 assert(dstFormat
== MESA_FORMAT_X8_UINT_Z24_UNORM
);
226 for (img
= 0; img
< srcDepth
; img
++) {
227 GLubyte
*dstRow
= dstSlices
[img
];
228 for (row
= 0; row
< srcHeight
; row
++) {
229 const GLvoid
*src
= _mesa_image_address(dims
, srcPacking
,
230 srcAddr
, srcWidth
, srcHeight
, srcFormat
, srcType
, img
, row
, 0);
231 GLuint
*dst
= (GLuint
*) dstRow
;
233 _mesa_unpack_depth_span(ctx
, srcWidth
,
234 GL_UNSIGNED_INT
, dst
,
235 depthScale
, srcType
, src
, srcPacking
);
236 for (i
= 0; i
< srcWidth
; i
++)
238 dstRow
+= dstRowStride
;
247 * Store a 16-bit integer depth component texture image.
250 _mesa_texstore_z16(TEXSTORE_PARAMS
)
252 const GLuint depthScale
= 0xffff;
254 assert(dstFormat
== MESA_FORMAT_Z_UNORM16
);
255 assert(_mesa_get_format_bytes(dstFormat
) == sizeof(GLushort
));
260 for (img
= 0; img
< srcDepth
; img
++) {
261 GLubyte
*dstRow
= dstSlices
[img
];
262 for (row
= 0; row
< srcHeight
; row
++) {
263 const GLvoid
*src
= _mesa_image_address(dims
, srcPacking
,
264 srcAddr
, srcWidth
, srcHeight
, srcFormat
, srcType
, img
, row
, 0);
265 GLushort
*dst16
= (GLushort
*) dstRow
;
266 _mesa_unpack_depth_span(ctx
, srcWidth
,
267 GL_UNSIGNED_SHORT
, dst16
, depthScale
,
268 srcType
, src
, srcPacking
);
269 dstRow
+= dstRowStride
;
278 * Texstore for _mesa_texformat_ycbcr or _mesa_texformat_ycbcr_REV.
281 _mesa_texstore_ycbcr(TEXSTORE_PARAMS
)
283 const GLboolean littleEndian
= _mesa_little_endian();
285 (void) ctx
; (void) dims
; (void) baseInternalFormat
;
287 assert((dstFormat
== MESA_FORMAT_YCBCR
) ||
288 (dstFormat
== MESA_FORMAT_YCBCR_REV
));
289 assert(_mesa_get_format_bytes(dstFormat
) == 2);
290 assert(ctx
->Extensions
.MESA_ycbcr_texture
);
291 assert(srcFormat
== GL_YCBCR_MESA
);
292 assert((srcType
== GL_UNSIGNED_SHORT_8_8_MESA
) ||
293 (srcType
== GL_UNSIGNED_SHORT_8_8_REV_MESA
));
294 assert(baseInternalFormat
== GL_YCBCR_MESA
);
296 /* always just memcpy since no pixel transfer ops apply */
297 _mesa_memcpy_texture(ctx
, dims
,
299 dstRowStride
, dstSlices
,
300 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
301 srcAddr
, srcPacking
);
303 /* Check if we need byte swapping */
304 /* XXX the logic here _might_ be wrong */
305 if (srcPacking
->SwapBytes
^
306 (srcType
== GL_UNSIGNED_SHORT_8_8_REV_MESA
) ^
307 (dstFormat
== MESA_FORMAT_YCBCR_REV
) ^
310 for (img
= 0; img
< srcDepth
; img
++) {
311 GLubyte
*dstRow
= dstSlices
[img
];
312 for (row
= 0; row
< srcHeight
; row
++) {
313 _mesa_swap2((GLushort
*) dstRow
, srcWidth
);
314 dstRow
+= dstRowStride
;
323 * Store a combined depth/stencil texture image.
326 _mesa_texstore_z24_s8(TEXSTORE_PARAMS
)
328 const GLuint depthScale
= 0xffffff;
329 const GLint srcRowStride
330 = _mesa_image_row_stride(srcPacking
, srcWidth
, srcFormat
, srcType
);
332 GLuint
*depth
= malloc(srcWidth
* sizeof(GLuint
));
333 GLubyte
*stencil
= malloc(srcWidth
* sizeof(GLubyte
));
335 assert(dstFormat
== MESA_FORMAT_S8_UINT_Z24_UNORM
);
336 assert(srcFormat
== GL_DEPTH_STENCIL_EXT
||
337 srcFormat
== GL_DEPTH_COMPONENT
||
338 srcFormat
== GL_STENCIL_INDEX
);
339 assert(srcFormat
!= GL_DEPTH_STENCIL_EXT
||
340 srcType
== GL_UNSIGNED_INT_24_8_EXT
||
341 srcType
== GL_FLOAT_32_UNSIGNED_INT_24_8_REV
);
343 if (!depth
|| !stencil
) {
349 /* In case we only upload depth we need to preserve the stencil */
350 for (img
= 0; img
< srcDepth
; img
++) {
351 GLuint
*dstRow
= (GLuint
*) dstSlices
[img
];
353 = (const GLubyte
*) _mesa_image_address(dims
, srcPacking
, srcAddr
,
357 for (row
= 0; row
< srcHeight
; row
++) {
359 GLboolean keepdepth
= GL_FALSE
, keepstencil
= GL_FALSE
;
361 if (srcFormat
== GL_DEPTH_COMPONENT
) { /* preserve stencil */
362 keepstencil
= GL_TRUE
;
364 else if (srcFormat
== GL_STENCIL_INDEX
) { /* preserve depth */
368 if (keepdepth
== GL_FALSE
)
369 /* the 24 depth bits will be in the low position: */
370 _mesa_unpack_depth_span(ctx
, srcWidth
,
371 GL_UNSIGNED_INT
, /* dst type */
372 keepstencil
? depth
: dstRow
, /* dst addr */
374 srcType
, src
, srcPacking
);
376 if (keepstencil
== GL_FALSE
)
377 /* get the 8-bit stencil values */
378 _mesa_unpack_stencil_span(ctx
, srcWidth
,
379 GL_UNSIGNED_BYTE
, /* dst type */
380 stencil
, /* dst addr */
381 srcType
, src
, srcPacking
,
382 ctx
->_ImageTransferState
);
384 for (i
= 0; i
< srcWidth
; i
++) {
386 dstRow
[i
] = depth
[i
] << 8 | (dstRow
[i
] & 0x000000FF);
388 dstRow
[i
] = (dstRow
[i
] & 0xFFFFFF00) | (stencil
[i
] & 0xFF);
391 dstRow
+= dstRowStride
/ sizeof(GLuint
);
402 * Store a combined depth/stencil texture image.
405 _mesa_texstore_s8_z24(TEXSTORE_PARAMS
)
407 const GLuint depthScale
= 0xffffff;
408 const GLint srcRowStride
409 = _mesa_image_row_stride(srcPacking
, srcWidth
, srcFormat
, srcType
);
414 assert(dstFormat
== MESA_FORMAT_Z24_UNORM_S8_UINT
);
415 assert(srcFormat
== GL_DEPTH_STENCIL_EXT
||
416 srcFormat
== GL_DEPTH_COMPONENT
||
417 srcFormat
== GL_STENCIL_INDEX
);
418 assert(srcFormat
!= GL_DEPTH_STENCIL_EXT
||
419 srcType
== GL_UNSIGNED_INT_24_8_EXT
||
420 srcType
== GL_FLOAT_32_UNSIGNED_INT_24_8_REV
);
422 depth
= malloc(srcWidth
* sizeof(GLuint
));
423 stencil
= malloc(srcWidth
* sizeof(GLubyte
));
425 if (!depth
|| !stencil
) {
431 for (img
= 0; img
< srcDepth
; img
++) {
432 GLuint
*dstRow
= (GLuint
*) dstSlices
[img
];
434 = (const GLubyte
*) _mesa_image_address(dims
, srcPacking
, srcAddr
,
438 for (row
= 0; row
< srcHeight
; row
++) {
440 GLboolean keepdepth
= GL_FALSE
, keepstencil
= GL_FALSE
;
442 if (srcFormat
== GL_DEPTH_COMPONENT
) { /* preserve stencil */
443 keepstencil
= GL_TRUE
;
445 else if (srcFormat
== GL_STENCIL_INDEX
) { /* preserve depth */
449 if (keepdepth
== GL_FALSE
)
450 /* the 24 depth bits will be in the low position: */
451 _mesa_unpack_depth_span(ctx
, srcWidth
,
452 GL_UNSIGNED_INT
, /* dst type */
453 keepstencil
? depth
: dstRow
, /* dst addr */
455 srcType
, src
, srcPacking
);
457 if (keepstencil
== GL_FALSE
)
458 /* get the 8-bit stencil values */
459 _mesa_unpack_stencil_span(ctx
, srcWidth
,
460 GL_UNSIGNED_BYTE
, /* dst type */
461 stencil
, /* dst addr */
462 srcType
, src
, srcPacking
,
463 ctx
->_ImageTransferState
);
465 /* merge stencil values into depth values */
466 for (i
= 0; i
< srcWidth
; i
++) {
468 dstRow
[i
] = depth
[i
] | (dstRow
[i
] & 0xFF000000);
470 dstRow
[i
] = (dstRow
[i
] & 0xFFFFFF) | (stencil
[i
] << 24);
474 dstRow
+= dstRowStride
/ sizeof(GLuint
);
486 * Store simple 8-bit/value stencil texture data.
489 _mesa_texstore_s8(TEXSTORE_PARAMS
)
491 assert(dstFormat
== MESA_FORMAT_S_UINT8
);
492 assert(srcFormat
== GL_STENCIL_INDEX
);
495 const GLint srcRowStride
496 = _mesa_image_row_stride(srcPacking
, srcWidth
, srcFormat
, srcType
);
498 GLubyte
*stencil
= malloc(srcWidth
* sizeof(GLubyte
));
503 for (img
= 0; img
< srcDepth
; img
++) {
504 GLubyte
*dstRow
= dstSlices
[img
];
506 = (const GLubyte
*) _mesa_image_address(dims
, srcPacking
, srcAddr
,
510 for (row
= 0; row
< srcHeight
; row
++) {
513 /* get the 8-bit stencil values */
514 _mesa_unpack_stencil_span(ctx
, srcWidth
,
515 GL_UNSIGNED_BYTE
, /* dst type */
516 stencil
, /* dst addr */
517 srcType
, src
, srcPacking
,
518 ctx
->_ImageTransferState
);
519 /* merge stencil values into depth values */
520 for (i
= 0; i
< srcWidth
; i
++)
521 dstRow
[i
] = stencil
[i
];
524 dstRow
+= dstRowStride
/ sizeof(GLubyte
);
536 _mesa_texstore_z32f_x24s8(TEXSTORE_PARAMS
)
539 const GLint srcRowStride
540 = _mesa_image_row_stride(srcPacking
, srcWidth
, srcFormat
, srcType
)
543 assert(dstFormat
== MESA_FORMAT_Z32_FLOAT_S8X24_UINT
);
544 assert(srcFormat
== GL_DEPTH_STENCIL
||
545 srcFormat
== GL_DEPTH_COMPONENT
||
546 srcFormat
== GL_STENCIL_INDEX
);
547 assert(srcFormat
!= GL_DEPTH_STENCIL
||
548 srcType
== GL_UNSIGNED_INT_24_8
||
549 srcType
== GL_FLOAT_32_UNSIGNED_INT_24_8_REV
);
551 /* In case we only upload depth we need to preserve the stencil */
552 for (img
= 0; img
< srcDepth
; img
++) {
553 uint64_t *dstRow
= (uint64_t *) dstSlices
[img
];
555 = (const uint64_t *) _mesa_image_address(dims
, srcPacking
, srcAddr
,
559 for (row
= 0; row
< srcHeight
; row
++) {
560 /* The unpack functions with:
561 * dstType = GL_FLOAT_32_UNSIGNED_INT_24_8_REV
562 * only write their own dword, so the other dword (stencil
563 * or depth) is preserved. */
564 if (srcFormat
!= GL_STENCIL_INDEX
)
565 _mesa_unpack_depth_span(ctx
, srcWidth
,
566 GL_FLOAT_32_UNSIGNED_INT_24_8_REV
, /* dst type */
567 dstRow
, /* dst addr */
568 ~0U, srcType
, src
, srcPacking
);
570 if (srcFormat
!= GL_DEPTH_COMPONENT
)
571 _mesa_unpack_stencil_span(ctx
, srcWidth
,
572 GL_FLOAT_32_UNSIGNED_INT_24_8_REV
, /* dst type */
573 dstRow
, /* dst addr */
574 srcType
, src
, srcPacking
,
575 ctx
->_ImageTransferState
);
578 dstRow
+= dstRowStride
/ sizeof(uint64_t);
585 texstore_depth_stencil(TEXSTORE_PARAMS
)
587 static StoreTexImageFunc table
[MESA_FORMAT_COUNT
];
588 static GLboolean initialized
= GL_FALSE
;
591 memset(table
, 0, sizeof table
);
593 table
[MESA_FORMAT_S8_UINT_Z24_UNORM
] = _mesa_texstore_z24_s8
;
594 table
[MESA_FORMAT_Z24_UNORM_S8_UINT
] = _mesa_texstore_s8_z24
;
595 table
[MESA_FORMAT_Z_UNORM16
] = _mesa_texstore_z16
;
596 table
[MESA_FORMAT_Z24_UNORM_X8_UINT
] = _mesa_texstore_x8_z24
;
597 table
[MESA_FORMAT_X8_UINT_Z24_UNORM
] = _mesa_texstore_z24_x8
;
598 table
[MESA_FORMAT_Z_UNORM32
] = _mesa_texstore_z32
;
599 table
[MESA_FORMAT_S_UINT8
] = _mesa_texstore_s8
;
600 table
[MESA_FORMAT_Z_FLOAT32
] = _mesa_texstore_z32
;
601 table
[MESA_FORMAT_Z32_FLOAT_S8X24_UINT
] = _mesa_texstore_z32f_x24s8
;
603 initialized
= GL_TRUE
;
606 assert(table
[dstFormat
]);
607 return table
[dstFormat
](ctx
, dims
, baseInternalFormat
,
608 dstFormat
, dstRowStride
, dstSlices
,
609 srcWidth
, srcHeight
, srcDepth
,
610 srcFormat
, srcType
, srcAddr
, srcPacking
);
614 texstore_compressed(TEXSTORE_PARAMS
)
616 static StoreTexImageFunc table
[MESA_FORMAT_COUNT
];
617 static GLboolean initialized
= GL_FALSE
;
620 memset(table
, 0, sizeof table
);
622 table
[MESA_FORMAT_SRGB_DXT1
] = _mesa_texstore_rgb_dxt1
;
623 table
[MESA_FORMAT_SRGBA_DXT1
] = _mesa_texstore_rgba_dxt1
;
624 table
[MESA_FORMAT_SRGBA_DXT3
] = _mesa_texstore_rgba_dxt3
;
625 table
[MESA_FORMAT_SRGBA_DXT5
] = _mesa_texstore_rgba_dxt5
;
626 table
[MESA_FORMAT_RGB_FXT1
] = _mesa_texstore_rgb_fxt1
;
627 table
[MESA_FORMAT_RGBA_FXT1
] = _mesa_texstore_rgba_fxt1
;
628 table
[MESA_FORMAT_RGB_DXT1
] = _mesa_texstore_rgb_dxt1
;
629 table
[MESA_FORMAT_RGBA_DXT1
] = _mesa_texstore_rgba_dxt1
;
630 table
[MESA_FORMAT_RGBA_DXT3
] = _mesa_texstore_rgba_dxt3
;
631 table
[MESA_FORMAT_RGBA_DXT5
] = _mesa_texstore_rgba_dxt5
;
632 table
[MESA_FORMAT_R_RGTC1_UNORM
] = _mesa_texstore_red_rgtc1
;
633 table
[MESA_FORMAT_R_RGTC1_SNORM
] = _mesa_texstore_signed_red_rgtc1
;
634 table
[MESA_FORMAT_RG_RGTC2_UNORM
] = _mesa_texstore_rg_rgtc2
;
635 table
[MESA_FORMAT_RG_RGTC2_SNORM
] = _mesa_texstore_signed_rg_rgtc2
;
636 table
[MESA_FORMAT_L_LATC1_UNORM
] = _mesa_texstore_red_rgtc1
;
637 table
[MESA_FORMAT_L_LATC1_SNORM
] = _mesa_texstore_signed_red_rgtc1
;
638 table
[MESA_FORMAT_LA_LATC2_UNORM
] = _mesa_texstore_rg_rgtc2
;
639 table
[MESA_FORMAT_LA_LATC2_SNORM
] = _mesa_texstore_signed_rg_rgtc2
;
640 table
[MESA_FORMAT_ETC1_RGB8
] = _mesa_texstore_etc1_rgb8
;
641 table
[MESA_FORMAT_ETC2_RGB8
] = _mesa_texstore_etc2_rgb8
;
642 table
[MESA_FORMAT_ETC2_SRGB8
] = _mesa_texstore_etc2_srgb8
;
643 table
[MESA_FORMAT_ETC2_RGBA8_EAC
] = _mesa_texstore_etc2_rgba8_eac
;
644 table
[MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC
] = _mesa_texstore_etc2_srgb8_alpha8_eac
;
645 table
[MESA_FORMAT_ETC2_R11_EAC
] = _mesa_texstore_etc2_r11_eac
;
646 table
[MESA_FORMAT_ETC2_RG11_EAC
] = _mesa_texstore_etc2_rg11_eac
;
647 table
[MESA_FORMAT_ETC2_SIGNED_R11_EAC
] = _mesa_texstore_etc2_signed_r11_eac
;
648 table
[MESA_FORMAT_ETC2_SIGNED_RG11_EAC
] = _mesa_texstore_etc2_signed_rg11_eac
;
649 table
[MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1
] =
650 _mesa_texstore_etc2_rgb8_punchthrough_alpha1
;
651 table
[MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
] =
652 _mesa_texstore_etc2_srgb8_punchthrough_alpha1
;
654 table
[MESA_FORMAT_BPTC_RGBA_UNORM
] =
655 _mesa_texstore_bptc_rgba_unorm
;
656 table
[MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM
] =
657 _mesa_texstore_bptc_rgba_unorm
;
658 table
[MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT
] =
659 _mesa_texstore_bptc_rgb_signed_float
;
660 table
[MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT
] =
661 _mesa_texstore_bptc_rgb_unsigned_float
;
663 initialized
= GL_TRUE
;
666 assert(table
[dstFormat
]);
667 return table
[dstFormat
](ctx
, dims
, baseInternalFormat
,
668 dstFormat
, dstRowStride
, dstSlices
,
669 srcWidth
, srcHeight
, srcDepth
,
670 srcFormat
, srcType
, srcAddr
, srcPacking
);
674 texstore_rgba(TEXSTORE_PARAMS
)
676 void *tempImage
= NULL
;
679 uint8_t rebaseSwizzle
[4];
680 bool transferOpsDone
= false;
682 /* We have to handle MESA_FORMAT_YCBCR manually because it is a special case
683 * and _mesa_format_convert does not support it. In this case the we only
684 * allow conversions between YCBCR formats and it is mostly a memcpy.
686 if (dstFormat
== MESA_FORMAT_YCBCR
|| dstFormat
== MESA_FORMAT_YCBCR_REV
) {
687 return _mesa_texstore_ycbcr(ctx
, dims
, baseInternalFormat
,
688 dstFormat
, dstRowStride
, dstSlices
,
689 srcWidth
, srcHeight
, srcDepth
,
690 srcFormat
, srcType
, srcAddr
,
694 /* We have to deal with GL_COLOR_INDEX manually because
695 * _mesa_format_convert does not handle this format. So what we do here is
696 * convert it to RGBA ubyte first and then convert from that to dst as usual.
698 if (srcFormat
== GL_COLOR_INDEX
) {
699 /* Notice that this will already handle byte swapping if necessary */
701 _mesa_unpack_color_index_to_rgba_ubyte(ctx
, dims
,
702 srcAddr
, srcFormat
, srcType
,
703 srcWidth
, srcHeight
, srcDepth
,
705 ctx
->_ImageTransferState
);
709 /* _mesa_unpack_color_index_to_rgba_ubyte has handled transferops
712 transferOpsDone
= true;
714 /* Now we only have to adjust our src info for a conversion from
715 * the RGBA ubyte and then we continue as usual.
719 srcType
= GL_UNSIGNED_BYTE
;
720 } else if (srcPacking
->SwapBytes
) {
721 /* We have to handle byte-swapping scenarios before calling
722 * _mesa_format_convert
724 GLint swapSize
= _mesa_sizeof_packed_type(srcType
);
725 if (swapSize
== 2 || swapSize
== 4) {
726 int imageStride
= _mesa_image_image_stride(srcPacking
, srcWidth
,
727 srcHeight
, srcFormat
,
729 int bufferSize
= imageStride
* srcDepth
;
734 tempImage
= malloc(bufferSize
);
739 for (layer
= 0; layer
< srcDepth
; layer
++) {
740 _mesa_swap_bytes_2d_image(srcFormat
, srcType
,
752 _mesa_image_row_stride(srcPacking
, srcWidth
, srcFormat
, srcType
);
754 uint32_t srcMesaFormat
=
755 _mesa_format_from_format_and_type(srcFormat
, srcType
);
757 dstFormat
= _mesa_get_srgb_format_linear(dstFormat
);
759 /* If we have transferOps then we need to convert to RGBA float first,
760 then apply transferOps, then do the conversion to dst
762 void *tempRGBA
= NULL
;
763 if (!transferOpsDone
&&
764 _mesa_texstore_needs_transfer_ops(ctx
, baseInternalFormat
, dstFormat
)) {
765 /* Allocate RGBA float image */
766 int elementCount
= srcWidth
* srcHeight
* srcDepth
;
767 tempRGBA
= malloc(4 * elementCount
* sizeof(float));
773 /* Convert from src to RGBA float */
774 src
= (GLubyte
*) srcAddr
;
775 dst
= (GLubyte
*) tempRGBA
;
776 for (img
= 0; img
< srcDepth
; img
++) {
777 _mesa_format_convert(dst
, RGBA32_FLOAT
, 4 * srcWidth
* sizeof(float),
778 src
, srcMesaFormat
, srcRowStride
,
779 srcWidth
, srcHeight
, NULL
);
780 src
+= srcHeight
* srcRowStride
;
781 dst
+= srcHeight
* 4 * srcWidth
* sizeof(float);
784 /* Apply transferOps */
785 _mesa_apply_rgba_transfer_ops(ctx
, ctx
->_ImageTransferState
, elementCount
,
786 (float(*)[4]) tempRGBA
);
788 /* Now we have to adjust our src info for a conversion from
789 * the RGBA float image and then we continue as usual.
794 srcRowStride
= srcWidth
* 4 * sizeof(float);
795 srcMesaFormat
= RGBA32_FLOAT
;
796 srcPacking
= &ctx
->DefaultPacking
;
800 _mesa_image_address(dims
, srcPacking
, srcAddr
, srcWidth
, srcHeight
,
801 srcFormat
, srcType
, 0, 0, 0);
804 if (_mesa_get_format_base_format(dstFormat
) != baseInternalFormat
) {
806 _mesa_compute_rgba2base2rgba_component_mapping(baseInternalFormat
,
812 for (img
= 0; img
< srcDepth
; img
++) {
813 _mesa_format_convert(dstSlices
[img
], dstFormat
, dstRowStride
,
814 src
, srcMesaFormat
, srcRowStride
,
816 needRebase
? rebaseSwizzle
: NULL
);
817 src
+= srcHeight
* srcRowStride
;
827 _mesa_texstore_needs_transfer_ops(struct gl_context
*ctx
,
828 GLenum baseInternalFormat
,
829 mesa_format dstFormat
)
833 /* There are different rules depending on the base format. */
834 switch (baseInternalFormat
) {
835 case GL_DEPTH_COMPONENT
:
836 case GL_DEPTH_STENCIL
:
837 return ctx
->Pixel
.DepthScale
!= 1.0f
||
838 ctx
->Pixel
.DepthBias
!= 0.0f
;
840 case GL_STENCIL_INDEX
:
845 * Pixel transfer ops (scale, bias, table lookup) do not apply
846 * to integer formats.
848 dstType
= _mesa_get_format_datatype(dstFormat
);
850 return dstType
!= GL_INT
&& dstType
!= GL_UNSIGNED_INT
&&
851 ctx
->_ImageTransferState
;
857 _mesa_texstore_can_use_memcpy(struct gl_context
*ctx
,
858 GLenum baseInternalFormat
, mesa_format dstFormat
,
859 GLenum srcFormat
, GLenum srcType
,
860 const struct gl_pixelstore_attrib
*srcPacking
)
862 if (_mesa_texstore_needs_transfer_ops(ctx
, baseInternalFormat
, dstFormat
)) {
866 /* The base internal format and the base Mesa format must match. */
867 if (baseInternalFormat
!= _mesa_get_format_base_format(dstFormat
)) {
871 /* The Mesa format must match the input format and type. */
872 if (!_mesa_format_matches_format_and_type(dstFormat
, srcFormat
, srcType
,
873 srcPacking
->SwapBytes
, NULL
)) {
877 /* Depth texture data needs clamping in following cases:
878 * - Floating point dstFormat with signed srcType: clamp to [0.0, 1.0].
879 * - Fixed point dstFormat with signed srcType: clamp to [0, 2^n -1].
881 * All the cases except one (float dstFormat with float srcType) are ruled
882 * out by _mesa_format_matches_format_and_type() check above. Handle the
883 * remaining case here.
885 if ((baseInternalFormat
== GL_DEPTH_COMPONENT
||
886 baseInternalFormat
== GL_DEPTH_STENCIL
) &&
887 (srcType
== GL_FLOAT
||
888 srcType
== GL_FLOAT_32_UNSIGNED_INT_24_8_REV
)) {
896 _mesa_texstore_memcpy(TEXSTORE_PARAMS
)
898 if (!_mesa_texstore_can_use_memcpy(ctx
, baseInternalFormat
, dstFormat
,
899 srcFormat
, srcType
, srcPacking
)) {
903 _mesa_memcpy_texture(ctx
, dims
,
905 dstRowStride
, dstSlices
,
906 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
907 srcAddr
, srcPacking
);
913 * Store user data into texture memory.
914 * Called via glTex[Sub]Image1/2/3D()
915 * \return GL_TRUE for success, GL_FALSE for failure (out of memory).
918 _mesa_texstore(TEXSTORE_PARAMS
)
920 if (_mesa_texstore_memcpy(ctx
, dims
, baseInternalFormat
,
922 dstRowStride
, dstSlices
,
923 srcWidth
, srcHeight
, srcDepth
,
924 srcFormat
, srcType
, srcAddr
, srcPacking
)) {
928 if (_mesa_is_depth_or_stencil_format(baseInternalFormat
)) {
929 return texstore_depth_stencil(ctx
, dims
, baseInternalFormat
,
930 dstFormat
, dstRowStride
, dstSlices
,
931 srcWidth
, srcHeight
, srcDepth
,
932 srcFormat
, srcType
, srcAddr
, srcPacking
);
933 } else if (_mesa_is_format_compressed(dstFormat
)) {
934 return texstore_compressed(ctx
, dims
, baseInternalFormat
,
935 dstFormat
, dstRowStride
, dstSlices
,
936 srcWidth
, srcHeight
, srcDepth
,
937 srcFormat
, srcType
, srcAddr
, srcPacking
);
939 return texstore_rgba(ctx
, dims
, baseInternalFormat
,
940 dstFormat
, dstRowStride
, dstSlices
,
941 srcWidth
, srcHeight
, srcDepth
,
942 srcFormat
, srcType
, srcAddr
, srcPacking
);
948 * Normally, we'll only _write_ texel data to a texture when we map it.
949 * But if the user is providing depth or stencil values and the texture
950 * image is a combined depth/stencil format, we'll actually read from
951 * the texture buffer too (in order to insert the depth or stencil values.
952 * \param userFormat the user-provided image format
953 * \param texFormat the destination texture format
956 get_read_write_mode(GLenum userFormat
, mesa_format texFormat
)
958 if ((userFormat
== GL_STENCIL_INDEX
|| userFormat
== GL_DEPTH_COMPONENT
)
959 && _mesa_get_format_base_format(texFormat
) == GL_DEPTH_STENCIL
)
960 return GL_MAP_READ_BIT
| GL_MAP_WRITE_BIT
;
962 return GL_MAP_WRITE_BIT
| GL_MAP_INVALIDATE_RANGE_BIT
;
967 * Helper function for storing 1D, 2D, 3D whole and subimages into texture
969 * The source of the image data may be user memory or a PBO. In the later
970 * case, we'll map the PBO, copy from it, then unmap it.
973 store_texsubimage(struct gl_context
*ctx
,
974 struct gl_texture_image
*texImage
,
975 GLint xoffset
, GLint yoffset
, GLint zoffset
,
976 GLint width
, GLint height
, GLint depth
,
977 GLenum format
, GLenum type
, const GLvoid
*pixels
,
978 const struct gl_pixelstore_attrib
*packing
,
982 const GLbitfield mapMode
= get_read_write_mode(format
, texImage
->TexFormat
);
983 const GLenum target
= texImage
->TexObject
->Target
;
984 GLboolean success
= GL_FALSE
;
985 GLuint dims
, slice
, numSlices
= 1, sliceOffset
= 0;
986 GLint srcImageStride
= 0;
989 assert(xoffset
+ width
<= texImage
->Width
);
990 assert(yoffset
+ height
<= texImage
->Height
);
991 assert(zoffset
+ depth
<= texImage
->Depth
);
997 case GL_TEXTURE_2D_ARRAY
:
998 case GL_TEXTURE_CUBE_MAP_ARRAY
:
1006 /* get pointer to src pixels (may be in a pbo which we'll map here) */
1007 src
= (const GLubyte
*)
1008 _mesa_validate_pbo_teximage(ctx
, dims
, width
, height
, depth
,
1009 format
, type
, pixels
, packing
, caller
);
1013 /* compute slice info (and do some sanity checks) */
1016 case GL_TEXTURE_2D_MULTISAMPLE
:
1017 case GL_TEXTURE_RECTANGLE
:
1018 case GL_TEXTURE_CUBE_MAP
:
1019 case GL_TEXTURE_EXTERNAL_OES
:
1020 /* one image slice, nothing special needs to be done */
1023 assert(height
== 1);
1025 assert(yoffset
== 0);
1026 assert(zoffset
== 0);
1028 case GL_TEXTURE_1D_ARRAY
:
1030 assert(zoffset
== 0);
1032 sliceOffset
= yoffset
;
1035 srcImageStride
= _mesa_image_row_stride(packing
, width
, format
, type
);
1037 case GL_TEXTURE_2D_ARRAY
:
1038 case GL_TEXTURE_2D_MULTISAMPLE_ARRAY
:
1040 sliceOffset
= zoffset
;
1043 srcImageStride
= _mesa_image_image_stride(packing
, width
, height
,
1047 /* we'll store 3D images as a series of slices */
1049 sliceOffset
= zoffset
;
1050 srcImageStride
= _mesa_image_image_stride(packing
, width
, height
,
1053 case GL_TEXTURE_CUBE_MAP_ARRAY
:
1055 sliceOffset
= zoffset
;
1056 srcImageStride
= _mesa_image_image_stride(packing
, width
, height
,
1060 _mesa_warning(ctx
, "Unexpected target 0x%x in store_texsubimage()",
1065 assert(numSlices
== 1 || srcImageStride
!= 0);
1067 for (slice
= 0; slice
< numSlices
; slice
++) {
1071 ctx
->Driver
.MapTextureImage(ctx
, texImage
,
1072 slice
+ sliceOffset
,
1073 xoffset
, yoffset
, width
, height
,
1074 mapMode
, &dstMap
, &dstRowStride
);
1076 /* Note: we're only storing a 2D (or 1D) slice at a time but we need
1077 * to pass the right 'dims' value so that GL_UNPACK_SKIP_IMAGES is
1078 * used for 3D images.
1080 success
= _mesa_texstore(ctx
, dims
, texImage
->_BaseFormat
,
1081 texImage
->TexFormat
,
1084 width
, height
, 1, /* w, h, d */
1085 format
, type
, src
, packing
);
1087 ctx
->Driver
.UnmapTextureImage(ctx
, texImage
, slice
+ sliceOffset
);
1090 src
+= srcImageStride
;
1097 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "%s", caller
);
1099 _mesa_unmap_teximage_pbo(ctx
, packing
);
1105 * Fallback code for ctx->Driver.TexImage().
1106 * Basically, allocate storage for the texture image, then copy the
1107 * user's image into it.
1110 _mesa_store_teximage(struct gl_context
*ctx
,
1112 struct gl_texture_image
*texImage
,
1113 GLenum format
, GLenum type
, const GLvoid
*pixels
,
1114 const struct gl_pixelstore_attrib
*packing
)
1116 assert(dims
== 1 || dims
== 2 || dims
== 3);
1118 if (texImage
->Width
== 0 || texImage
->Height
== 0 || texImage
->Depth
== 0)
1121 /* allocate storage for texture data */
1122 if (!ctx
->Driver
.AllocTextureImageBuffer(ctx
, texImage
)) {
1123 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexImage%uD", dims
);
1127 store_texsubimage(ctx
, texImage
,
1128 0, 0, 0, texImage
->Width
, texImage
->Height
, texImage
->Depth
,
1129 format
, type
, pixels
, packing
, "glTexImage");
1134 * Fallback for Driver.TexSubImage().
1137 _mesa_store_texsubimage(struct gl_context
*ctx
, GLuint dims
,
1138 struct gl_texture_image
*texImage
,
1139 GLint xoffset
, GLint yoffset
, GLint zoffset
,
1140 GLint width
, GLint height
, GLint depth
,
1141 GLenum format
, GLenum type
, const void *pixels
,
1142 const struct gl_pixelstore_attrib
*packing
)
1144 store_texsubimage(ctx
, texImage
,
1145 xoffset
, yoffset
, zoffset
, width
, height
, depth
,
1146 format
, type
, pixels
, packing
, "glTexSubImage");
1150 clear_image_to_zero(GLubyte
*dstMap
, GLint dstRowStride
,
1151 GLsizei width
, GLsizei height
,
1152 GLsizei clearValueSize
)
1156 for (y
= 0; y
< height
; y
++) {
1157 memset(dstMap
, 0, clearValueSize
* width
);
1158 dstMap
+= dstRowStride
;
1163 clear_image_to_value(GLubyte
*dstMap
, GLint dstRowStride
,
1164 GLsizei width
, GLsizei height
,
1165 const GLvoid
*clearValue
,
1166 GLsizei clearValueSize
)
1170 for (y
= 0; y
< height
; y
++) {
1171 for (x
= 0; x
< width
; x
++) {
1172 memcpy(dstMap
, clearValue
, clearValueSize
);
1173 dstMap
+= clearValueSize
;
1175 dstMap
+= dstRowStride
- clearValueSize
* width
;
1180 * Fallback for Driver.ClearTexSubImage().
1183 _mesa_store_cleartexsubimage(struct gl_context
*ctx
,
1184 struct gl_texture_image
*texImage
,
1185 GLint xoffset
, GLint yoffset
, GLint zoffset
,
1186 GLsizei width
, GLsizei height
, GLsizei depth
,
1187 const GLvoid
*clearValue
)
1191 GLsizeiptr clearValueSize
;
1194 clearValueSize
= _mesa_get_format_bytes(texImage
->TexFormat
);
1196 for (z
= 0; z
< depth
; z
++) {
1197 ctx
->Driver
.MapTextureImage(ctx
, texImage
,
1198 z
+ zoffset
, xoffset
, yoffset
,
1201 &dstMap
, &dstRowStride
);
1202 if (dstMap
== NULL
) {
1203 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glClearTex*Image");
1208 clear_image_to_value(dstMap
, dstRowStride
,
1213 clear_image_to_zero(dstMap
, dstRowStride
,
1218 ctx
->Driver
.UnmapTextureImage(ctx
, texImage
, z
+ zoffset
);
1223 * Fallback for Driver.CompressedTexImage()
1226 _mesa_store_compressed_teximage(struct gl_context
*ctx
, GLuint dims
,
1227 struct gl_texture_image
*texImage
,
1228 GLsizei imageSize
, const GLvoid
*data
)
1230 /* only 2D and 3D compressed images are supported at this time */
1232 _mesa_problem(ctx
, "Unexpected glCompressedTexImage1D call");
1236 /* This is pretty simple, because unlike the general texstore path we don't
1237 * have to worry about the usual image unpacking or image transfer
1241 assert(texImage
->Width
> 0);
1242 assert(texImage
->Height
> 0);
1243 assert(texImage
->Depth
> 0);
1245 /* allocate storage for texture data */
1246 if (!ctx
->Driver
.AllocTextureImageBuffer(ctx
, texImage
)) {
1247 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glCompressedTexImage%uD", dims
);
1251 ctx
->Driver
.CompressedTexSubImage(ctx
, dims
, texImage
,
1253 texImage
->Width
, texImage
->Height
, texImage
->Depth
,
1254 texImage
->TexFormat
,
1260 * Compute compressed_pixelstore parameters for copying compressed
1262 * \param dims number of texture image dimensions: 1, 2 or 3
1263 * \param texFormat the compressed texture format
1264 * \param width, height, depth size of image to copy
1265 * \param packing pixelstore parameters describing user-space image packing
1266 * \param store returns the compressed_pixelstore parameters
1269 _mesa_compute_compressed_pixelstore(GLuint dims
, mesa_format texFormat
,
1270 GLsizei width
, GLsizei height
,
1272 const struct gl_pixelstore_attrib
*packing
,
1273 struct compressed_pixelstore
*store
)
1277 _mesa_get_format_block_size_3d(texFormat
, &bw
, &bh
, &bd
);
1279 store
->SkipBytes
= 0;
1280 store
->TotalBytesPerRow
= store
->CopyBytesPerRow
=
1281 _mesa_format_row_stride(texFormat
, width
);
1282 store
->TotalRowsPerSlice
= store
->CopyRowsPerSlice
=
1283 (height
+ bh
- 1) / bh
;
1284 store
->CopySlices
= (depth
+ bd
- 1) / bd
;
1286 if (packing
->CompressedBlockWidth
&&
1287 packing
->CompressedBlockSize
) {
1289 bw
= packing
->CompressedBlockWidth
;
1291 if (packing
->RowLength
) {
1292 store
->TotalBytesPerRow
= packing
->CompressedBlockSize
*
1293 ((packing
->RowLength
+ bw
- 1) / bw
);
1297 packing
->SkipPixels
* packing
->CompressedBlockSize
/ bw
;
1300 if (dims
> 1 && packing
->CompressedBlockHeight
&&
1301 packing
->CompressedBlockSize
) {
1303 bh
= packing
->CompressedBlockHeight
;
1305 store
->SkipBytes
+= packing
->SkipRows
* store
->TotalBytesPerRow
/ bh
;
1306 store
->CopyRowsPerSlice
= (height
+ bh
- 1) / bh
; /* rows in blocks */
1308 if (packing
->ImageHeight
) {
1309 store
->TotalRowsPerSlice
= (packing
->ImageHeight
+ bh
- 1) / bh
;
1313 if (dims
> 2 && packing
->CompressedBlockDepth
&&
1314 packing
->CompressedBlockSize
) {
1316 int bd
= packing
->CompressedBlockDepth
;
1318 store
->SkipBytes
+= packing
->SkipImages
* store
->TotalBytesPerRow
*
1319 store
->TotalRowsPerSlice
/ bd
;
1325 * Fallback for Driver.CompressedTexSubImage()
1328 _mesa_store_compressed_texsubimage(struct gl_context
*ctx
, GLuint dims
,
1329 struct gl_texture_image
*texImage
,
1330 GLint xoffset
, GLint yoffset
, GLint zoffset
,
1331 GLsizei width
, GLsizei height
, GLsizei depth
,
1333 GLsizei imageSize
, const GLvoid
*data
)
1335 struct compressed_pixelstore store
;
1342 _mesa_problem(ctx
, "Unexpected 1D compressed texsubimage call");
1346 _mesa_compute_compressed_pixelstore(dims
, texImage
->TexFormat
,
1347 width
, height
, depth
,
1348 &ctx
->Unpack
, &store
);
1350 /* get pointer to src pixels (may be in a pbo which we'll map here) */
1351 data
= _mesa_validate_pbo_compressed_teximage(ctx
, dims
, imageSize
, data
,
1353 "glCompressedTexSubImage");
1357 src
= (const GLubyte
*) data
+ store
.SkipBytes
;
1359 for (slice
= 0; slice
< store
.CopySlices
; slice
++) {
1360 /* Map dest texture buffer */
1361 ctx
->Driver
.MapTextureImage(ctx
, texImage
, slice
+ zoffset
,
1362 xoffset
, yoffset
, width
, height
,
1363 GL_MAP_WRITE_BIT
| GL_MAP_INVALIDATE_RANGE_BIT
,
1364 &dstMap
, &dstRowStride
);
1368 /* copy rows of blocks */
1369 if (dstRowStride
== store
.TotalBytesPerRow
&&
1370 dstRowStride
== store
.CopyBytesPerRow
) {
1371 memcpy(dstMap
, src
, store
.CopyBytesPerRow
* store
.CopyRowsPerSlice
);
1372 src
+= store
.CopyBytesPerRow
* store
.CopyRowsPerSlice
;
1375 for (i
= 0; i
< store
.CopyRowsPerSlice
; i
++) {
1376 memcpy(dstMap
, src
, store
.CopyBytesPerRow
);
1377 dstMap
+= dstRowStride
;
1378 src
+= store
.TotalBytesPerRow
;
1382 ctx
->Driver
.UnmapTextureImage(ctx
, texImage
, slice
+ zoffset
);
1384 /* advance to next slice */
1385 src
+= store
.TotalBytesPerRow
* (store
.TotalRowsPerSlice
1386 - store
.CopyRowsPerSlice
);
1389 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glCompressedTexSubImage%uD",
1394 _mesa_unmap_teximage_pbo(ctx
, &ctx
->Unpack
);