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 (void) ctx
; (void) dims
; (void) baseInternalFormat
;
285 assert((dstFormat
== MESA_FORMAT_YCBCR
) ||
286 (dstFormat
== MESA_FORMAT_YCBCR_REV
));
287 assert(_mesa_get_format_bytes(dstFormat
) == 2);
288 assert(ctx
->Extensions
.MESA_ycbcr_texture
);
289 assert(srcFormat
== GL_YCBCR_MESA
);
290 assert((srcType
== GL_UNSIGNED_SHORT_8_8_MESA
) ||
291 (srcType
== GL_UNSIGNED_SHORT_8_8_REV_MESA
));
292 assert(baseInternalFormat
== GL_YCBCR_MESA
);
294 /* always just memcpy since no pixel transfer ops apply */
295 _mesa_memcpy_texture(ctx
, dims
,
297 dstRowStride
, dstSlices
,
298 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
299 srcAddr
, srcPacking
);
301 /* Check if we need byte swapping */
302 /* XXX the logic here _might_ be wrong */
303 if (srcPacking
->SwapBytes
^
304 (srcType
== GL_UNSIGNED_SHORT_8_8_REV_MESA
) ^
305 (dstFormat
== MESA_FORMAT_YCBCR_REV
) ^
306 !UTIL_ARCH_LITTLE_ENDIAN
) {
308 for (img
= 0; img
< srcDepth
; img
++) {
309 GLubyte
*dstRow
= dstSlices
[img
];
310 for (row
= 0; row
< srcHeight
; row
++) {
311 _mesa_swap2((GLushort
*) dstRow
, srcWidth
);
312 dstRow
+= dstRowStride
;
321 * Store a combined depth/stencil texture image.
324 _mesa_texstore_z24_s8(TEXSTORE_PARAMS
)
326 const GLuint depthScale
= 0xffffff;
327 const GLint srcRowStride
328 = _mesa_image_row_stride(srcPacking
, srcWidth
, srcFormat
, srcType
);
330 GLuint
*depth
= malloc(srcWidth
* sizeof(GLuint
));
331 GLubyte
*stencil
= malloc(srcWidth
* sizeof(GLubyte
));
333 assert(dstFormat
== MESA_FORMAT_S8_UINT_Z24_UNORM
);
334 assert(srcFormat
== GL_DEPTH_STENCIL_EXT
||
335 srcFormat
== GL_DEPTH_COMPONENT
||
336 srcFormat
== GL_STENCIL_INDEX
);
337 assert(srcFormat
!= GL_DEPTH_STENCIL_EXT
||
338 srcType
== GL_UNSIGNED_INT_24_8_EXT
||
339 srcType
== GL_FLOAT_32_UNSIGNED_INT_24_8_REV
);
341 if (!depth
|| !stencil
) {
347 /* In case we only upload depth we need to preserve the stencil */
348 for (img
= 0; img
< srcDepth
; img
++) {
349 GLuint
*dstRow
= (GLuint
*) dstSlices
[img
];
351 = (const GLubyte
*) _mesa_image_address(dims
, srcPacking
, srcAddr
,
355 for (row
= 0; row
< srcHeight
; row
++) {
357 GLboolean keepdepth
= GL_FALSE
, keepstencil
= GL_FALSE
;
359 if (srcFormat
== GL_DEPTH_COMPONENT
) { /* preserve stencil */
360 keepstencil
= GL_TRUE
;
362 else if (srcFormat
== GL_STENCIL_INDEX
) { /* preserve depth */
366 if (keepdepth
== GL_FALSE
)
367 /* the 24 depth bits will be in the low position: */
368 _mesa_unpack_depth_span(ctx
, srcWidth
,
369 GL_UNSIGNED_INT
, /* dst type */
370 keepstencil
? depth
: dstRow
, /* dst addr */
372 srcType
, src
, srcPacking
);
374 if (keepstencil
== GL_FALSE
)
375 /* get the 8-bit stencil values */
376 _mesa_unpack_stencil_span(ctx
, srcWidth
,
377 GL_UNSIGNED_BYTE
, /* dst type */
378 stencil
, /* dst addr */
379 srcType
, src
, srcPacking
,
380 ctx
->_ImageTransferState
);
382 for (i
= 0; i
< srcWidth
; i
++) {
384 dstRow
[i
] = depth
[i
] << 8 | (dstRow
[i
] & 0x000000FF);
386 dstRow
[i
] = (dstRow
[i
] & 0xFFFFFF00) | (stencil
[i
] & 0xFF);
389 dstRow
+= dstRowStride
/ sizeof(GLuint
);
400 * Store a combined depth/stencil texture image.
403 _mesa_texstore_s8_z24(TEXSTORE_PARAMS
)
405 const GLuint depthScale
= 0xffffff;
406 const GLint srcRowStride
407 = _mesa_image_row_stride(srcPacking
, srcWidth
, srcFormat
, srcType
);
412 assert(dstFormat
== MESA_FORMAT_Z24_UNORM_S8_UINT
);
413 assert(srcFormat
== GL_DEPTH_STENCIL_EXT
||
414 srcFormat
== GL_DEPTH_COMPONENT
||
415 srcFormat
== GL_STENCIL_INDEX
);
416 assert(srcFormat
!= GL_DEPTH_STENCIL_EXT
||
417 srcType
== GL_UNSIGNED_INT_24_8_EXT
||
418 srcType
== GL_FLOAT_32_UNSIGNED_INT_24_8_REV
);
420 depth
= malloc(srcWidth
* sizeof(GLuint
));
421 stencil
= malloc(srcWidth
* sizeof(GLubyte
));
423 if (!depth
|| !stencil
) {
429 for (img
= 0; img
< srcDepth
; img
++) {
430 GLuint
*dstRow
= (GLuint
*) dstSlices
[img
];
432 = (const GLubyte
*) _mesa_image_address(dims
, srcPacking
, srcAddr
,
436 for (row
= 0; row
< srcHeight
; row
++) {
438 GLboolean keepdepth
= GL_FALSE
, keepstencil
= GL_FALSE
;
440 if (srcFormat
== GL_DEPTH_COMPONENT
) { /* preserve stencil */
441 keepstencil
= GL_TRUE
;
443 else if (srcFormat
== GL_STENCIL_INDEX
) { /* preserve depth */
447 if (keepdepth
== GL_FALSE
)
448 /* the 24 depth bits will be in the low position: */
449 _mesa_unpack_depth_span(ctx
, srcWidth
,
450 GL_UNSIGNED_INT
, /* dst type */
451 keepstencil
? depth
: dstRow
, /* dst addr */
453 srcType
, src
, srcPacking
);
455 if (keepstencil
== GL_FALSE
)
456 /* get the 8-bit stencil values */
457 _mesa_unpack_stencil_span(ctx
, srcWidth
,
458 GL_UNSIGNED_BYTE
, /* dst type */
459 stencil
, /* dst addr */
460 srcType
, src
, srcPacking
,
461 ctx
->_ImageTransferState
);
463 /* merge stencil values into depth values */
464 for (i
= 0; i
< srcWidth
; i
++) {
466 dstRow
[i
] = depth
[i
] | (dstRow
[i
] & 0xFF000000);
468 dstRow
[i
] = (dstRow
[i
] & 0xFFFFFF) | (stencil
[i
] << 24);
472 dstRow
+= dstRowStride
/ sizeof(GLuint
);
484 * Store simple 8-bit/value stencil texture data.
487 _mesa_texstore_s8(TEXSTORE_PARAMS
)
489 assert(dstFormat
== MESA_FORMAT_S_UINT8
);
490 assert(srcFormat
== GL_STENCIL_INDEX
);
493 const GLint srcRowStride
494 = _mesa_image_row_stride(srcPacking
, srcWidth
, srcFormat
, srcType
);
496 GLubyte
*stencil
= malloc(srcWidth
* sizeof(GLubyte
));
501 for (img
= 0; img
< srcDepth
; img
++) {
502 GLubyte
*dstRow
= dstSlices
[img
];
504 = (const GLubyte
*) _mesa_image_address(dims
, srcPacking
, srcAddr
,
508 for (row
= 0; row
< srcHeight
; row
++) {
511 /* get the 8-bit stencil values */
512 _mesa_unpack_stencil_span(ctx
, srcWidth
,
513 GL_UNSIGNED_BYTE
, /* dst type */
514 stencil
, /* dst addr */
515 srcType
, src
, srcPacking
,
516 ctx
->_ImageTransferState
);
517 /* merge stencil values into depth values */
518 for (i
= 0; i
< srcWidth
; i
++)
519 dstRow
[i
] = stencil
[i
];
522 dstRow
+= dstRowStride
/ sizeof(GLubyte
);
534 _mesa_texstore_z32f_x24s8(TEXSTORE_PARAMS
)
537 const GLint srcRowStride
538 = _mesa_image_row_stride(srcPacking
, srcWidth
, srcFormat
, srcType
)
541 assert(dstFormat
== MESA_FORMAT_Z32_FLOAT_S8X24_UINT
);
542 assert(srcFormat
== GL_DEPTH_STENCIL
||
543 srcFormat
== GL_DEPTH_COMPONENT
||
544 srcFormat
== GL_STENCIL_INDEX
);
545 assert(srcFormat
!= GL_DEPTH_STENCIL
||
546 srcType
== GL_UNSIGNED_INT_24_8
||
547 srcType
== GL_FLOAT_32_UNSIGNED_INT_24_8_REV
);
549 /* In case we only upload depth we need to preserve the stencil */
550 for (img
= 0; img
< srcDepth
; img
++) {
551 uint64_t *dstRow
= (uint64_t *) dstSlices
[img
];
553 = (const int32_t *) _mesa_image_address(dims
, srcPacking
, srcAddr
,
557 for (row
= 0; row
< srcHeight
; row
++) {
558 /* The unpack functions with:
559 * dstType = GL_FLOAT_32_UNSIGNED_INT_24_8_REV
560 * only write their own dword, so the other dword (stencil
561 * or depth) is preserved. */
562 if (srcFormat
!= GL_STENCIL_INDEX
)
563 _mesa_unpack_depth_span(ctx
, srcWidth
,
564 GL_FLOAT_32_UNSIGNED_INT_24_8_REV
, /* dst type */
565 dstRow
, /* dst addr */
566 ~0U, srcType
, src
, srcPacking
);
568 if (srcFormat
!= GL_DEPTH_COMPONENT
)
569 _mesa_unpack_stencil_span(ctx
, srcWidth
,
570 GL_FLOAT_32_UNSIGNED_INT_24_8_REV
, /* dst type */
571 dstRow
, /* dst addr */
572 srcType
, src
, srcPacking
,
573 ctx
->_ImageTransferState
);
576 dstRow
+= dstRowStride
/ sizeof(uint64_t);
583 texstore_depth_stencil(TEXSTORE_PARAMS
)
585 static StoreTexImageFunc table
[MESA_FORMAT_COUNT
];
586 static GLboolean initialized
= GL_FALSE
;
589 memset(table
, 0, sizeof table
);
591 table
[MESA_FORMAT_S8_UINT_Z24_UNORM
] = _mesa_texstore_z24_s8
;
592 table
[MESA_FORMAT_Z24_UNORM_S8_UINT
] = _mesa_texstore_s8_z24
;
593 table
[MESA_FORMAT_Z_UNORM16
] = _mesa_texstore_z16
;
594 table
[MESA_FORMAT_Z24_UNORM_X8_UINT
] = _mesa_texstore_x8_z24
;
595 table
[MESA_FORMAT_X8_UINT_Z24_UNORM
] = _mesa_texstore_z24_x8
;
596 table
[MESA_FORMAT_Z_UNORM32
] = _mesa_texstore_z32
;
597 table
[MESA_FORMAT_S_UINT8
] = _mesa_texstore_s8
;
598 table
[MESA_FORMAT_Z_FLOAT32
] = _mesa_texstore_z32
;
599 table
[MESA_FORMAT_Z32_FLOAT_S8X24_UINT
] = _mesa_texstore_z32f_x24s8
;
601 initialized
= GL_TRUE
;
604 assert(table
[dstFormat
]);
605 return table
[dstFormat
](ctx
, dims
, baseInternalFormat
,
606 dstFormat
, dstRowStride
, dstSlices
,
607 srcWidth
, srcHeight
, srcDepth
,
608 srcFormat
, srcType
, srcAddr
, srcPacking
);
612 texstore_compressed(TEXSTORE_PARAMS
)
614 static StoreTexImageFunc table
[MESA_FORMAT_COUNT
];
615 static GLboolean initialized
= GL_FALSE
;
618 memset(table
, 0, sizeof table
);
620 table
[MESA_FORMAT_SRGB_DXT1
] = _mesa_texstore_rgb_dxt1
;
621 table
[MESA_FORMAT_SRGBA_DXT1
] = _mesa_texstore_rgba_dxt1
;
622 table
[MESA_FORMAT_SRGBA_DXT3
] = _mesa_texstore_rgba_dxt3
;
623 table
[MESA_FORMAT_SRGBA_DXT5
] = _mesa_texstore_rgba_dxt5
;
624 table
[MESA_FORMAT_RGB_FXT1
] = _mesa_texstore_rgb_fxt1
;
625 table
[MESA_FORMAT_RGBA_FXT1
] = _mesa_texstore_rgba_fxt1
;
626 table
[MESA_FORMAT_RGB_DXT1
] = _mesa_texstore_rgb_dxt1
;
627 table
[MESA_FORMAT_RGBA_DXT1
] = _mesa_texstore_rgba_dxt1
;
628 table
[MESA_FORMAT_RGBA_DXT3
] = _mesa_texstore_rgba_dxt3
;
629 table
[MESA_FORMAT_RGBA_DXT5
] = _mesa_texstore_rgba_dxt5
;
630 table
[MESA_FORMAT_R_RGTC1_UNORM
] = _mesa_texstore_red_rgtc1
;
631 table
[MESA_FORMAT_R_RGTC1_SNORM
] = _mesa_texstore_signed_red_rgtc1
;
632 table
[MESA_FORMAT_RG_RGTC2_UNORM
] = _mesa_texstore_rg_rgtc2
;
633 table
[MESA_FORMAT_RG_RGTC2_SNORM
] = _mesa_texstore_signed_rg_rgtc2
;
634 table
[MESA_FORMAT_L_LATC1_UNORM
] = _mesa_texstore_red_rgtc1
;
635 table
[MESA_FORMAT_L_LATC1_SNORM
] = _mesa_texstore_signed_red_rgtc1
;
636 table
[MESA_FORMAT_LA_LATC2_UNORM
] = _mesa_texstore_rg_rgtc2
;
637 table
[MESA_FORMAT_LA_LATC2_SNORM
] = _mesa_texstore_signed_rg_rgtc2
;
638 table
[MESA_FORMAT_ETC1_RGB8
] = _mesa_texstore_etc1_rgb8
;
639 table
[MESA_FORMAT_ETC2_RGB8
] = _mesa_texstore_etc2_rgb8
;
640 table
[MESA_FORMAT_ETC2_SRGB8
] = _mesa_texstore_etc2_srgb8
;
641 table
[MESA_FORMAT_ETC2_RGBA8_EAC
] = _mesa_texstore_etc2_rgba8_eac
;
642 table
[MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC
] = _mesa_texstore_etc2_srgb8_alpha8_eac
;
643 table
[MESA_FORMAT_ETC2_R11_EAC
] = _mesa_texstore_etc2_r11_eac
;
644 table
[MESA_FORMAT_ETC2_RG11_EAC
] = _mesa_texstore_etc2_rg11_eac
;
645 table
[MESA_FORMAT_ETC2_SIGNED_R11_EAC
] = _mesa_texstore_etc2_signed_r11_eac
;
646 table
[MESA_FORMAT_ETC2_SIGNED_RG11_EAC
] = _mesa_texstore_etc2_signed_rg11_eac
;
647 table
[MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1
] =
648 _mesa_texstore_etc2_rgb8_punchthrough_alpha1
;
649 table
[MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
] =
650 _mesa_texstore_etc2_srgb8_punchthrough_alpha1
;
652 table
[MESA_FORMAT_BPTC_RGBA_UNORM
] =
653 _mesa_texstore_bptc_rgba_unorm
;
654 table
[MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM
] =
655 _mesa_texstore_bptc_rgba_unorm
;
656 table
[MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT
] =
657 _mesa_texstore_bptc_rgb_signed_float
;
658 table
[MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT
] =
659 _mesa_texstore_bptc_rgb_unsigned_float
;
661 initialized
= GL_TRUE
;
664 assert(table
[dstFormat
]);
665 return table
[dstFormat
](ctx
, dims
, baseInternalFormat
,
666 dstFormat
, dstRowStride
, dstSlices
,
667 srcWidth
, srcHeight
, srcDepth
,
668 srcFormat
, srcType
, srcAddr
, srcPacking
);
672 texstore_rgba(TEXSTORE_PARAMS
)
674 void *tempImage
= NULL
;
677 uint8_t rebaseSwizzle
[4];
678 bool transferOpsDone
= false;
680 /* We have to handle MESA_FORMAT_YCBCR manually because it is a special case
681 * and _mesa_format_convert does not support it. In this case the we only
682 * allow conversions between YCBCR formats and it is mostly a memcpy.
684 if (dstFormat
== MESA_FORMAT_YCBCR
|| dstFormat
== MESA_FORMAT_YCBCR_REV
) {
685 return _mesa_texstore_ycbcr(ctx
, dims
, baseInternalFormat
,
686 dstFormat
, dstRowStride
, dstSlices
,
687 srcWidth
, srcHeight
, srcDepth
,
688 srcFormat
, srcType
, srcAddr
,
692 /* We have to deal with GL_COLOR_INDEX manually because
693 * _mesa_format_convert does not handle this format. So what we do here is
694 * convert it to RGBA ubyte first and then convert from that to dst as usual.
696 if (srcFormat
== GL_COLOR_INDEX
) {
697 /* Notice that this will already handle byte swapping if necessary */
699 _mesa_unpack_color_index_to_rgba_ubyte(ctx
, dims
,
700 srcAddr
, srcFormat
, srcType
,
701 srcWidth
, srcHeight
, srcDepth
,
703 ctx
->_ImageTransferState
);
707 /* _mesa_unpack_color_index_to_rgba_ubyte has handled transferops
710 transferOpsDone
= true;
712 /* Now we only have to adjust our src info for a conversion from
713 * the RGBA ubyte and then we continue as usual.
717 srcType
= GL_UNSIGNED_BYTE
;
718 } else if (srcPacking
->SwapBytes
) {
719 /* We have to handle byte-swapping scenarios before calling
720 * _mesa_format_convert
722 GLint swapSize
= _mesa_sizeof_packed_type(srcType
);
723 if (swapSize
== 2 || swapSize
== 4) {
724 int imageStride
= _mesa_image_image_stride(srcPacking
, srcWidth
,
725 srcHeight
, srcFormat
,
727 int bufferSize
= imageStride
* srcDepth
;
732 tempImage
= malloc(bufferSize
);
737 for (layer
= 0; layer
< srcDepth
; layer
++) {
738 _mesa_swap_bytes_2d_image(srcFormat
, srcType
,
750 _mesa_image_row_stride(srcPacking
, srcWidth
, srcFormat
, srcType
);
752 uint32_t srcMesaFormat
=
753 _mesa_format_from_format_and_type(srcFormat
, srcType
);
755 dstFormat
= _mesa_get_srgb_format_linear(dstFormat
);
757 /* If we have transferOps then we need to convert to RGBA float first,
758 then apply transferOps, then do the conversion to dst
760 void *tempRGBA
= NULL
;
761 if (!transferOpsDone
&&
762 _mesa_texstore_needs_transfer_ops(ctx
, baseInternalFormat
, dstFormat
)) {
763 /* Allocate RGBA float image */
764 int elementCount
= srcWidth
* srcHeight
* srcDepth
;
765 tempRGBA
= malloc(4 * elementCount
* sizeof(float));
771 /* Convert from src to RGBA float */
772 src
= (GLubyte
*) srcAddr
;
773 dst
= (GLubyte
*) tempRGBA
;
774 for (img
= 0; img
< srcDepth
; img
++) {
775 _mesa_format_convert(dst
, RGBA32_FLOAT
, 4 * srcWidth
* sizeof(float),
776 src
, srcMesaFormat
, srcRowStride
,
777 srcWidth
, srcHeight
, NULL
);
778 src
+= srcHeight
* srcRowStride
;
779 dst
+= srcHeight
* 4 * srcWidth
* sizeof(float);
782 /* Apply transferOps */
783 _mesa_apply_rgba_transfer_ops(ctx
, ctx
->_ImageTransferState
, elementCount
,
784 (float(*)[4]) tempRGBA
);
786 /* Now we have to adjust our src info for a conversion from
787 * the RGBA float image and then we continue as usual.
792 srcRowStride
= srcWidth
* 4 * sizeof(float);
793 srcMesaFormat
= RGBA32_FLOAT
;
794 srcPacking
= &ctx
->DefaultPacking
;
798 _mesa_image_address(dims
, srcPacking
, srcAddr
, srcWidth
, srcHeight
,
799 srcFormat
, srcType
, 0, 0, 0);
802 if (_mesa_get_format_base_format(dstFormat
) != baseInternalFormat
) {
804 _mesa_compute_rgba2base2rgba_component_mapping(baseInternalFormat
,
810 for (img
= 0; img
< srcDepth
; img
++) {
811 _mesa_format_convert(dstSlices
[img
], dstFormat
, dstRowStride
,
812 src
, srcMesaFormat
, srcRowStride
,
814 needRebase
? rebaseSwizzle
: NULL
);
815 src
+= srcHeight
* srcRowStride
;
825 _mesa_texstore_needs_transfer_ops(struct gl_context
*ctx
,
826 GLenum baseInternalFormat
,
827 mesa_format dstFormat
)
831 /* There are different rules depending on the base format. */
832 switch (baseInternalFormat
) {
833 case GL_DEPTH_COMPONENT
:
834 case GL_DEPTH_STENCIL
:
835 return ctx
->Pixel
.DepthScale
!= 1.0f
||
836 ctx
->Pixel
.DepthBias
!= 0.0f
;
838 case GL_STENCIL_INDEX
:
843 * Pixel transfer ops (scale, bias, table lookup) do not apply
844 * to integer formats.
846 dstType
= _mesa_get_format_datatype(dstFormat
);
848 return dstType
!= GL_INT
&& dstType
!= GL_UNSIGNED_INT
&&
849 ctx
->_ImageTransferState
;
855 _mesa_texstore_can_use_memcpy(struct gl_context
*ctx
,
856 GLenum baseInternalFormat
, mesa_format dstFormat
,
857 GLenum srcFormat
, GLenum srcType
,
858 const struct gl_pixelstore_attrib
*srcPacking
)
860 if (_mesa_texstore_needs_transfer_ops(ctx
, baseInternalFormat
, dstFormat
)) {
864 /* The base internal format and the base Mesa format must match. */
865 if (baseInternalFormat
!= _mesa_get_format_base_format(dstFormat
)) {
869 /* The Mesa format must match the input format and type. */
870 if (!_mesa_format_matches_format_and_type(dstFormat
, srcFormat
, srcType
,
871 srcPacking
->SwapBytes
, NULL
)) {
875 /* Depth texture data needs clamping in following cases:
876 * - Floating point dstFormat with signed srcType: clamp to [0.0, 1.0].
877 * - Fixed point dstFormat with signed srcType: clamp to [0, 2^n -1].
879 * All the cases except one (float dstFormat with float srcType) are ruled
880 * out by _mesa_format_matches_format_and_type() check above. Handle the
881 * remaining case here.
883 if ((baseInternalFormat
== GL_DEPTH_COMPONENT
||
884 baseInternalFormat
== GL_DEPTH_STENCIL
) &&
885 (srcType
== GL_FLOAT
||
886 srcType
== GL_FLOAT_32_UNSIGNED_INT_24_8_REV
)) {
894 _mesa_texstore_memcpy(TEXSTORE_PARAMS
)
896 if (!_mesa_texstore_can_use_memcpy(ctx
, baseInternalFormat
, dstFormat
,
897 srcFormat
, srcType
, srcPacking
)) {
901 _mesa_memcpy_texture(ctx
, dims
,
903 dstRowStride
, dstSlices
,
904 srcWidth
, srcHeight
, srcDepth
, srcFormat
, srcType
,
905 srcAddr
, srcPacking
);
911 * Store user data into texture memory.
912 * Called via glTex[Sub]Image1/2/3D()
913 * \return GL_TRUE for success, GL_FALSE for failure (out of memory).
916 _mesa_texstore(TEXSTORE_PARAMS
)
918 if (_mesa_texstore_memcpy(ctx
, dims
, baseInternalFormat
,
920 dstRowStride
, dstSlices
,
921 srcWidth
, srcHeight
, srcDepth
,
922 srcFormat
, srcType
, srcAddr
, srcPacking
)) {
926 if (_mesa_is_depth_or_stencil_format(baseInternalFormat
)) {
927 return texstore_depth_stencil(ctx
, dims
, baseInternalFormat
,
928 dstFormat
, dstRowStride
, dstSlices
,
929 srcWidth
, srcHeight
, srcDepth
,
930 srcFormat
, srcType
, srcAddr
, srcPacking
);
931 } else if (_mesa_is_format_compressed(dstFormat
)) {
932 return texstore_compressed(ctx
, dims
, baseInternalFormat
,
933 dstFormat
, dstRowStride
, dstSlices
,
934 srcWidth
, srcHeight
, srcDepth
,
935 srcFormat
, srcType
, srcAddr
, srcPacking
);
937 return texstore_rgba(ctx
, dims
, baseInternalFormat
,
938 dstFormat
, dstRowStride
, dstSlices
,
939 srcWidth
, srcHeight
, srcDepth
,
940 srcFormat
, srcType
, srcAddr
, srcPacking
);
946 * Normally, we'll only _write_ texel data to a texture when we map it.
947 * But if the user is providing depth or stencil values and the texture
948 * image is a combined depth/stencil format, we'll actually read from
949 * the texture buffer too (in order to insert the depth or stencil values.
950 * \param userFormat the user-provided image format
951 * \param texFormat the destination texture format
954 get_read_write_mode(GLenum userFormat
, mesa_format texFormat
)
956 if ((userFormat
== GL_STENCIL_INDEX
|| userFormat
== GL_DEPTH_COMPONENT
)
957 && _mesa_get_format_base_format(texFormat
) == GL_DEPTH_STENCIL
)
958 return GL_MAP_READ_BIT
| GL_MAP_WRITE_BIT
;
960 return GL_MAP_WRITE_BIT
| GL_MAP_INVALIDATE_RANGE_BIT
;
965 * Helper function for storing 1D, 2D, 3D whole and subimages into texture
967 * The source of the image data may be user memory or a PBO. In the later
968 * case, we'll map the PBO, copy from it, then unmap it.
971 store_texsubimage(struct gl_context
*ctx
,
972 struct gl_texture_image
*texImage
,
973 GLint xoffset
, GLint yoffset
, GLint zoffset
,
974 GLint width
, GLint height
, GLint depth
,
975 GLenum format
, GLenum type
, const GLvoid
*pixels
,
976 const struct gl_pixelstore_attrib
*packing
,
980 const GLbitfield mapMode
= get_read_write_mode(format
, texImage
->TexFormat
);
981 const GLenum target
= texImage
->TexObject
->Target
;
982 GLboolean success
= GL_FALSE
;
983 GLuint dims
, slice
, numSlices
= 1, sliceOffset
= 0;
984 GLint srcImageStride
= 0;
987 assert(xoffset
+ width
<= texImage
->Width
);
988 assert(yoffset
+ height
<= texImage
->Height
);
989 assert(zoffset
+ depth
<= texImage
->Depth
);
995 case GL_TEXTURE_2D_ARRAY
:
996 case GL_TEXTURE_CUBE_MAP_ARRAY
:
1004 /* get pointer to src pixels (may be in a pbo which we'll map here) */
1005 src
= (const GLubyte
*)
1006 _mesa_validate_pbo_teximage(ctx
, dims
, width
, height
, depth
,
1007 format
, type
, pixels
, packing
, caller
);
1011 /* compute slice info (and do some sanity checks) */
1014 case GL_TEXTURE_2D_MULTISAMPLE
:
1015 case GL_TEXTURE_RECTANGLE
:
1016 case GL_TEXTURE_CUBE_MAP
:
1017 case GL_TEXTURE_EXTERNAL_OES
:
1018 /* one image slice, nothing special needs to be done */
1021 assert(height
== 1);
1023 assert(yoffset
== 0);
1024 assert(zoffset
== 0);
1026 case GL_TEXTURE_1D_ARRAY
:
1028 assert(zoffset
== 0);
1030 sliceOffset
= yoffset
;
1033 srcImageStride
= _mesa_image_row_stride(packing
, width
, format
, type
);
1035 case GL_TEXTURE_2D_ARRAY
:
1036 case GL_TEXTURE_2D_MULTISAMPLE_ARRAY
:
1038 sliceOffset
= zoffset
;
1041 srcImageStride
= _mesa_image_image_stride(packing
, width
, height
,
1045 /* we'll store 3D images as a series of slices */
1047 sliceOffset
= zoffset
;
1048 srcImageStride
= _mesa_image_image_stride(packing
, width
, height
,
1051 case GL_TEXTURE_CUBE_MAP_ARRAY
:
1053 sliceOffset
= zoffset
;
1054 srcImageStride
= _mesa_image_image_stride(packing
, width
, height
,
1058 _mesa_warning(ctx
, "Unexpected target 0x%x in store_texsubimage()",
1063 assert(numSlices
== 1 || srcImageStride
!= 0);
1065 for (slice
= 0; slice
< numSlices
; slice
++) {
1069 ctx
->Driver
.MapTextureImage(ctx
, texImage
,
1070 slice
+ sliceOffset
,
1071 xoffset
, yoffset
, width
, height
,
1072 mapMode
, &dstMap
, &dstRowStride
);
1074 /* Note: we're only storing a 2D (or 1D) slice at a time but we need
1075 * to pass the right 'dims' value so that GL_UNPACK_SKIP_IMAGES is
1076 * used for 3D images.
1078 success
= _mesa_texstore(ctx
, dims
, texImage
->_BaseFormat
,
1079 texImage
->TexFormat
,
1082 width
, height
, 1, /* w, h, d */
1083 format
, type
, src
, packing
);
1085 ctx
->Driver
.UnmapTextureImage(ctx
, texImage
, slice
+ sliceOffset
);
1088 src
+= srcImageStride
;
1095 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "%s", caller
);
1097 _mesa_unmap_teximage_pbo(ctx
, packing
);
1103 * Fallback code for ctx->Driver.TexImage().
1104 * Basically, allocate storage for the texture image, then copy the
1105 * user's image into it.
1108 _mesa_store_teximage(struct gl_context
*ctx
,
1110 struct gl_texture_image
*texImage
,
1111 GLenum format
, GLenum type
, const GLvoid
*pixels
,
1112 const struct gl_pixelstore_attrib
*packing
)
1114 assert(dims
== 1 || dims
== 2 || dims
== 3);
1116 if (texImage
->Width
== 0 || texImage
->Height
== 0 || texImage
->Depth
== 0)
1119 /* allocate storage for texture data */
1120 if (!ctx
->Driver
.AllocTextureImageBuffer(ctx
, texImage
)) {
1121 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glTexImage%uD", dims
);
1125 store_texsubimage(ctx
, texImage
,
1126 0, 0, 0, texImage
->Width
, texImage
->Height
, texImage
->Depth
,
1127 format
, type
, pixels
, packing
, "glTexImage");
1132 * Fallback for Driver.TexSubImage().
1135 _mesa_store_texsubimage(struct gl_context
*ctx
, GLuint dims
,
1136 struct gl_texture_image
*texImage
,
1137 GLint xoffset
, GLint yoffset
, GLint zoffset
,
1138 GLint width
, GLint height
, GLint depth
,
1139 GLenum format
, GLenum type
, const void *pixels
,
1140 const struct gl_pixelstore_attrib
*packing
)
1142 store_texsubimage(ctx
, texImage
,
1143 xoffset
, yoffset
, zoffset
, width
, height
, depth
,
1144 format
, type
, pixels
, packing
, "glTexSubImage");
1148 clear_image_to_zero(GLubyte
*dstMap
, GLint dstRowStride
,
1149 GLsizei width
, GLsizei height
,
1150 GLsizei clearValueSize
)
1154 for (y
= 0; y
< height
; y
++) {
1155 memset(dstMap
, 0, clearValueSize
* width
);
1156 dstMap
+= dstRowStride
;
1161 clear_image_to_value(GLubyte
*dstMap
, GLint dstRowStride
,
1162 GLsizei width
, GLsizei height
,
1163 const GLvoid
*clearValue
,
1164 GLsizei clearValueSize
)
1168 for (y
= 0; y
< height
; y
++) {
1169 for (x
= 0; x
< width
; x
++) {
1170 memcpy(dstMap
, clearValue
, clearValueSize
);
1171 dstMap
+= clearValueSize
;
1173 dstMap
+= dstRowStride
- clearValueSize
* width
;
1178 * Fallback for Driver.ClearTexSubImage().
1181 _mesa_store_cleartexsubimage(struct gl_context
*ctx
,
1182 struct gl_texture_image
*texImage
,
1183 GLint xoffset
, GLint yoffset
, GLint zoffset
,
1184 GLsizei width
, GLsizei height
, GLsizei depth
,
1185 const GLvoid
*clearValue
)
1189 GLsizeiptr clearValueSize
;
1192 clearValueSize
= _mesa_get_format_bytes(texImage
->TexFormat
);
1194 for (z
= 0; z
< depth
; z
++) {
1195 ctx
->Driver
.MapTextureImage(ctx
, texImage
,
1196 z
+ zoffset
, xoffset
, yoffset
,
1199 &dstMap
, &dstRowStride
);
1200 if (dstMap
== NULL
) {
1201 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glClearTex*Image");
1206 clear_image_to_value(dstMap
, dstRowStride
,
1211 clear_image_to_zero(dstMap
, dstRowStride
,
1216 ctx
->Driver
.UnmapTextureImage(ctx
, texImage
, z
+ zoffset
);
1221 * Fallback for Driver.CompressedTexImage()
1224 _mesa_store_compressed_teximage(struct gl_context
*ctx
, GLuint dims
,
1225 struct gl_texture_image
*texImage
,
1226 GLsizei imageSize
, const GLvoid
*data
)
1228 /* only 2D and 3D compressed images are supported at this time */
1230 _mesa_problem(ctx
, "Unexpected glCompressedTexImage1D call");
1234 /* This is pretty simple, because unlike the general texstore path we don't
1235 * have to worry about the usual image unpacking or image transfer
1239 assert(texImage
->Width
> 0);
1240 assert(texImage
->Height
> 0);
1241 assert(texImage
->Depth
> 0);
1243 /* allocate storage for texture data */
1244 if (!ctx
->Driver
.AllocTextureImageBuffer(ctx
, texImage
)) {
1245 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glCompressedTexImage%uD", dims
);
1249 ctx
->Driver
.CompressedTexSubImage(ctx
, dims
, texImage
,
1251 texImage
->Width
, texImage
->Height
, texImage
->Depth
,
1252 texImage
->TexFormat
,
1258 * Compute compressed_pixelstore parameters for copying compressed
1260 * \param dims number of texture image dimensions: 1, 2 or 3
1261 * \param texFormat the compressed texture format
1262 * \param width, height, depth size of image to copy
1263 * \param packing pixelstore parameters describing user-space image packing
1264 * \param store returns the compressed_pixelstore parameters
1267 _mesa_compute_compressed_pixelstore(GLuint dims
, mesa_format texFormat
,
1268 GLsizei width
, GLsizei height
,
1270 const struct gl_pixelstore_attrib
*packing
,
1271 struct compressed_pixelstore
*store
)
1275 _mesa_get_format_block_size_3d(texFormat
, &bw
, &bh
, &bd
);
1277 store
->SkipBytes
= 0;
1278 store
->TotalBytesPerRow
= store
->CopyBytesPerRow
=
1279 _mesa_format_row_stride(texFormat
, width
);
1280 store
->TotalRowsPerSlice
= store
->CopyRowsPerSlice
=
1281 (height
+ bh
- 1) / bh
;
1282 store
->CopySlices
= (depth
+ bd
- 1) / bd
;
1284 if (packing
->CompressedBlockWidth
&&
1285 packing
->CompressedBlockSize
) {
1287 bw
= packing
->CompressedBlockWidth
;
1289 if (packing
->RowLength
) {
1290 store
->TotalBytesPerRow
= packing
->CompressedBlockSize
*
1291 ((packing
->RowLength
+ bw
- 1) / bw
);
1295 packing
->SkipPixels
* packing
->CompressedBlockSize
/ bw
;
1298 if (dims
> 1 && packing
->CompressedBlockHeight
&&
1299 packing
->CompressedBlockSize
) {
1301 bh
= packing
->CompressedBlockHeight
;
1303 store
->SkipBytes
+= packing
->SkipRows
* store
->TotalBytesPerRow
/ bh
;
1304 store
->CopyRowsPerSlice
= (height
+ bh
- 1) / bh
; /* rows in blocks */
1306 if (packing
->ImageHeight
) {
1307 store
->TotalRowsPerSlice
= (packing
->ImageHeight
+ bh
- 1) / bh
;
1311 if (dims
> 2 && packing
->CompressedBlockDepth
&&
1312 packing
->CompressedBlockSize
) {
1314 int bd
= packing
->CompressedBlockDepth
;
1316 store
->SkipBytes
+= packing
->SkipImages
* store
->TotalBytesPerRow
*
1317 store
->TotalRowsPerSlice
/ bd
;
1323 * Fallback for Driver.CompressedTexSubImage()
1326 _mesa_store_compressed_texsubimage(struct gl_context
*ctx
, GLuint dims
,
1327 struct gl_texture_image
*texImage
,
1328 GLint xoffset
, GLint yoffset
, GLint zoffset
,
1329 GLsizei width
, GLsizei height
, GLsizei depth
,
1331 GLsizei imageSize
, const GLvoid
*data
)
1333 struct compressed_pixelstore store
;
1340 _mesa_problem(ctx
, "Unexpected 1D compressed texsubimage call");
1344 _mesa_compute_compressed_pixelstore(dims
, texImage
->TexFormat
,
1345 width
, height
, depth
,
1346 &ctx
->Unpack
, &store
);
1348 /* get pointer to src pixels (may be in a pbo which we'll map here) */
1349 data
= _mesa_validate_pbo_compressed_teximage(ctx
, dims
, imageSize
, data
,
1351 "glCompressedTexSubImage");
1355 src
= (const GLubyte
*) data
+ store
.SkipBytes
;
1357 for (slice
= 0; slice
< store
.CopySlices
; slice
++) {
1358 /* Map dest texture buffer */
1359 ctx
->Driver
.MapTextureImage(ctx
, texImage
, slice
+ zoffset
,
1360 xoffset
, yoffset
, width
, height
,
1361 GL_MAP_WRITE_BIT
| GL_MAP_INVALIDATE_RANGE_BIT
,
1362 &dstMap
, &dstRowStride
);
1366 /* copy rows of blocks */
1367 if (dstRowStride
== store
.TotalBytesPerRow
&&
1368 dstRowStride
== store
.CopyBytesPerRow
) {
1369 memcpy(dstMap
, src
, store
.CopyBytesPerRow
* store
.CopyRowsPerSlice
);
1370 src
+= store
.CopyBytesPerRow
* store
.CopyRowsPerSlice
;
1373 for (i
= 0; i
< store
.CopyRowsPerSlice
; i
++) {
1374 memcpy(dstMap
, src
, store
.CopyBytesPerRow
);
1375 dstMap
+= dstRowStride
;
1376 src
+= store
.TotalBytesPerRow
;
1380 ctx
->Driver
.UnmapTextureImage(ctx
, texImage
, slice
+ zoffset
);
1382 /* advance to next slice */
1383 src
+= store
.TotalBytesPerRow
* (store
.TotalRowsPerSlice
1384 - store
.CopyRowsPerSlice
);
1387 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glCompressedTexSubImage%uD",
1392 _mesa_unmap_teximage_pbo(ctx
, &ctx
->Unpack
);