3 from mako
.template
import Template
7 * Mesa 3-D graphics library
9 * Copyright (c) 2011 VMware, Inc.
10 * Copyright (c) 2014 Intel Corporation.
12 * Permission is hereby granted, free of charge, to any person obtaining a
13 * copy of this software and associated documentation files (the "Software"),
14 * to deal in the Software without restriction, including without limitation
15 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 * and/or sell copies of the Software, and to permit persons to whom the
17 * Software is furnished to do so, subject to the following conditions:
19 * The above copyright notice and this permission notice shall be included
20 * in all copies or substantial portions of the Software.
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28 * OTHER DEALINGS IN THE SOFTWARE.
33 * Color, depth, stencil packing functions.
34 * Used to pack basic color, depth and stencil formats to specific
37 * There are both per-pixel and per-row packing functions:
38 * - The former will be used by swrast to write values to the color, depth,
39 * stencil buffers when drawing points, lines and masked spans.
40 * - The later will be used for image-oriented functions like glDrawPixels,
41 * glAccum, and glTexImage.
46 #include "format_unpack.h"
47 #include "format_utils.h"
49 #include "../../gallium/auxiliary/util/u_format_rgb9e5.h"
50 #include "../../gallium/auxiliary/util/u_format_r11g11b10f.h"
51 #include "util/format_srgb.h"
53 #define UNPACK(SRC, OFFSET, BITS) (((SRC) >> (OFFSET)) & MAX_UINT(BITS))
56 import format_parser as parser
58 formats = parser.parse(argv[1])
62 if f.name == 'MESA_FORMAT_NONE':
64 if f.colorspace not in ('rgb', 'srgb'):
70 /* float unpacking functions */
72 %for f in rgb_formats:
73 %if f.name in ('MESA_FORMAT_R9G9B9E5_FLOAT', 'MESA_FORMAT_R11G11B10_FLOAT'):
75 %elif f.is_int() and not f.is_normalized():
77 %elif f.is_compressed():
82 unpack_float_${f.short_name()}(const void *void_src, GLfloat dst[4])
84 ${f.datatype()} *src = (${f.datatype()} *)void_src;
85 %if f.layout == parser.PACKED:
88 ${c.datatype()} ${c.name} = UNPACK(*src, ${c.shift}, ${c.size});
91 %elif f.layout == parser.ARRAY:
92 %for (i, c) in enumerate(f.channels):
94 ${c.datatype()} ${c.name} = src[${i}];
102 <% s = f.swizzle[i] %>
103 %if 0 <= s and s <= parser.Swizzle.SWIZZLE_W:
104 <% c = f.channels[s] %>
105 %if c.type == parser.UNSIGNED:
106 %if f.colorspace == 'srgb' and c.name in 'rgb':
107 <% assert c.size == 8 %>
108 dst[${i}] = util_format_srgb_8unorm_to_linear_float(${c.name});
110 dst[${i}] = _mesa_unorm_to_float(${c.name}, ${c.size});
112 %elif c.type == parser.SIGNED:
113 dst[${i}] = _mesa_snorm_to_float(${c.name}, ${c.size});
114 %elif c.type == parser.FLOAT:
116 dst[${i}] = ${c.name};
118 dst[${i}] = _mesa_half_to_float(${c.name});
125 %elif s == parser.Swizzle.SWIZZLE_ZERO:
127 %elif s == parser.Swizzle.SWIZZLE_ONE:
137 unpack_float_r9g9b9e5_float(const void *src, GLfloat dst[4])
139 rgb9e5_to_float3(*(const GLuint *)src, dst);
144 unpack_float_r11g11b10_float(const void *src, GLfloat dst[4])
146 r11g11b10f_to_float3(*(const GLuint *)src, dst);
151 unpack_float_ycbcr(const void *src, GLfloat dst[][4], GLuint n)
154 for (i = 0; i < n; i++) {
155 const GLushort *src0 = ((const GLushort *) src) + i * 2; /* even */
156 const GLushort *src1 = src0 + 1; /* odd */
157 const GLubyte y0 = (*src0 >> 8) & 0xff; /* luminance */
158 const GLubyte cb = *src0 & 0xff; /* chroma U */
159 const GLubyte y1 = (*src1 >> 8) & 0xff; /* luminance */
160 const GLubyte cr = *src1 & 0xff; /* chroma V */
161 const GLubyte y = (i & 1) ? y1 : y0; /* choose even/odd luminance */
162 GLfloat r = 1.164F * (y - 16) + 1.596F * (cr - 128);
163 GLfloat g = 1.164F * (y - 16) - 0.813F * (cr - 128) - 0.391F * (cb - 128);
164 GLfloat b = 1.164F * (y - 16) + 2.018F * (cb - 128);
165 r *= (1.0F / 255.0F);
166 g *= (1.0F / 255.0F);
167 b *= (1.0F / 255.0F);
168 dst[i][0] = CLAMP(r, 0.0F, 1.0F);
169 dst[i][1] = CLAMP(g, 0.0F, 1.0F);
170 dst[i][2] = CLAMP(b, 0.0F, 1.0F);
176 unpack_float_ycbcr_rev(const void *src, GLfloat dst[][4], GLuint n)
179 for (i = 0; i < n; i++) {
180 const GLushort *src0 = ((const GLushort *) src) + i * 2; /* even */
181 const GLushort *src1 = src0 + 1; /* odd */
182 const GLubyte y0 = *src0 & 0xff; /* luminance */
183 const GLubyte cr = (*src0 >> 8) & 0xff; /* chroma V */
184 const GLubyte y1 = *src1 & 0xff; /* luminance */
185 const GLubyte cb = (*src1 >> 8) & 0xff; /* chroma U */
186 const GLubyte y = (i & 1) ? y1 : y0; /* choose even/odd luminance */
187 GLfloat r = 1.164F * (y - 16) + 1.596F * (cr - 128);
188 GLfloat g = 1.164F * (y - 16) - 0.813F * (cr - 128) - 0.391F * (cb - 128);
189 GLfloat b = 1.164F * (y - 16) + 2.018F * (cb - 128);
190 r *= (1.0F / 255.0F);
191 g *= (1.0F / 255.0F);
192 b *= (1.0F / 255.0F);
193 dst[i][0] = CLAMP(r, 0.0F, 1.0F);
194 dst[i][1] = CLAMP(g, 0.0F, 1.0F);
195 dst[i][2] = CLAMP(b, 0.0F, 1.0F);
200 /* ubyte packing functions */
202 %for f in rgb_formats:
203 %if not f.is_normalized():
208 unpack_ubyte_${f.short_name()}(const void *void_src, GLubyte dst[4])
210 ${f.datatype()} *src = (${f.datatype()} *)void_src;
211 %if f.layout == parser.PACKED:
212 %for c in f.channels:
214 ${c.datatype()} ${c.name} = UNPACK(*src, ${c.shift}, ${c.size});
217 %elif f.layout == parser.ARRAY:
218 %for (i, c) in enumerate(f.channels):
220 ${c.datatype()} ${c.name} = src[${i}];
228 <% s = f.swizzle[i] %>
229 %if 0 <= s and s <= parser.Swizzle.SWIZZLE_W:
230 <% c = f.channels[s] %>
231 %if c.type == parser.UNSIGNED:
232 %if f.colorspace == 'srgb' and c.name in 'rgb':
233 <% assert c.size == 8 %>
234 dst[${i}] = util_format_srgb_to_linear_8unorm(${c.name});
236 dst[${i}] = _mesa_unorm_to_unorm(${c.name}, ${c.size}, 8);
238 %elif c.type == parser.SIGNED:
239 dst[${i}] = _mesa_snorm_to_unorm(${c.name}, ${c.size}, 8);
240 %elif c.type == parser.FLOAT:
242 dst[${i}] = _mesa_float_to_unorm(${c.name}, 8);
244 dst[${i}] = _mesa_half_to_unorm(${c.name}, 8);
251 %elif s == parser.Swizzle.SWIZZLE_ZERO:
253 %elif s == parser.Swizzle.SWIZZLE_ONE:
262 /* integer packing functions */
264 %for f in rgb_formats:
267 %elif f.is_normalized():
272 unpack_int_${f.short_name()}(const void *void_src, GLuint dst[4])
274 ${f.datatype()} *src = (${f.datatype()} *)void_src;
275 %if f.layout == parser.PACKED:
276 %for c in f.channels:
278 ${c.datatype()} ${c.name} = UNPACK(*src, ${c.shift}, ${c.size});
281 %elif f.layout == parser.ARRAY:
282 %for (i, c) in enumerate(f.channels):
284 ${c.datatype()} ${c.name} = src[${i}];
292 <% s = f.swizzle[i] %>
293 %if 0 <= s and s <= parser.Swizzle.SWIZZLE_W:
294 dst[${i}] = ${f.channels[s].name};
295 %elif s == parser.Swizzle.SWIZZLE_ZERO:
297 %elif s == parser.Swizzle.SWIZZLE_ONE:
308 _mesa_unpack_rgba_row(mesa_format format, GLuint n,
309 const void *src, GLfloat dst[][4])
311 GLubyte *s = (GLubyte *)src;
315 %for f in rgb_formats:
316 %if f.is_compressed():
318 %elif f.is_int() and not f.is_normalized():
322 for (i = 0; i < n; ++i) {
323 unpack_float_${f.short_name()}(s, dst[i]);
324 s += ${f.block_size() / 8};
328 case MESA_FORMAT_YCBCR:
329 unpack_float_ycbcr(src, dst, n);
331 case MESA_FORMAT_YCBCR_REV:
332 unpack_float_ycbcr_rev(src, dst, n);
335 _mesa_problem(NULL, "%s: bad format %s", __func__,
336 _mesa_get_format_name(format));
342 _mesa_unpack_ubyte_rgba_row(mesa_format format, GLuint n,
343 const void *src, GLubyte dst[][4])
345 GLubyte *s = (GLubyte *)src;
349 %for f in rgb_formats:
350 %if not f.is_normalized():
355 for (i = 0; i < n; ++i) {
356 unpack_ubyte_${f.short_name()}(s, dst[i]);
357 s += ${f.block_size() / 8};
362 /* get float values, convert to ubyte */
364 GLfloat *tmp = malloc(n * 4 * sizeof(GLfloat));
367 _mesa_unpack_rgba_row(format, n, src, (GLfloat (*)[4]) tmp);
368 for (i = 0; i < n; i++) {
369 dst[i][0] = _mesa_float_to_unorm(tmp[i*4+0], 8);
370 dst[i][1] = _mesa_float_to_unorm(tmp[i*4+1], 8);
371 dst[i][2] = _mesa_float_to_unorm(tmp[i*4+2], 8);
372 dst[i][3] = _mesa_float_to_unorm(tmp[i*4+3], 8);
382 _mesa_unpack_uint_rgba_row(mesa_format format, GLuint n,
383 const void *src, GLuint dst[][4])
385 GLubyte *s = (GLubyte *)src;
389 %for f in rgb_formats:
392 %elif f.is_normalized():
397 for (i = 0; i < n; ++i) {
398 unpack_int_${f.short_name()}(s, dst[i]);
399 s += ${f.block_size() / 8};
404 _mesa_problem(NULL, "%s: bad format %s", __func__,
405 _mesa_get_format_name(format));
411 * Unpack a 2D rect of pixels returning float RGBA colors.
412 * \param format the source image format
413 * \param src start address of the source image
414 * \param srcRowStride source image row stride in bytes
415 * \param dst start address of the dest image
416 * \param dstRowStride dest image row stride in bytes
417 * \param x source image start X pos
418 * \param y source image start Y pos
419 * \param width width of rect region to convert
420 * \param height height of rect region to convert
423 _mesa_unpack_rgba_block(mesa_format format,
424 const void *src, GLint srcRowStride,
425 GLfloat dst[][4], GLint dstRowStride,
426 GLuint x, GLuint y, GLuint width, GLuint height)
428 const GLuint srcPixStride = _mesa_get_format_bytes(format);
429 const GLuint dstPixStride = 4 * sizeof(GLfloat);
430 const GLubyte *srcRow;
434 /* XXX needs to be fixed for compressed formats */
436 srcRow = ((const GLubyte *) src) + srcRowStride * y + srcPixStride * x;
437 dstRow = ((GLubyte *) dst) + dstRowStride * y + dstPixStride * x;
439 for (i = 0; i < height; i++) {
440 _mesa_unpack_rgba_row(format, width, srcRow, (GLfloat (*)[4]) dstRow);
442 dstRow += dstRowStride;
443 srcRow += srcRowStride;
447 /** Helper struct for MESA_FORMAT_Z32_FLOAT_S8X24_UINT */
454 typedef void (*unpack_float_z_func)(GLuint n, const void *src, GLfloat *dst);
457 unpack_float_z_X8_UINT_Z24_UNORM(GLuint n, const void *src, GLfloat *dst)
459 /* only return Z, not stencil data */
460 const GLuint *s = ((const GLuint *) src);
461 const GLdouble scale = 1.0 / (GLdouble) 0xffffff;
463 for (i = 0; i < n; i++) {
464 dst[i] = (GLfloat) ((s[i] >> 8) * scale);
465 assert(dst[i] >= 0.0F);
466 assert(dst[i] <= 1.0F);
471 unpack_float_z_Z24_UNORM_X8_UINT(GLuint n, const void *src, GLfloat *dst)
473 /* only return Z, not stencil data */
474 const GLuint *s = ((const GLuint *) src);
475 const GLdouble scale = 1.0 / (GLdouble) 0xffffff;
477 for (i = 0; i < n; i++) {
478 dst[i] = (GLfloat) ((s[i] & 0x00ffffff) * scale);
479 assert(dst[i] >= 0.0F);
480 assert(dst[i] <= 1.0F);
485 unpack_float_Z_UNORM16(GLuint n, const void *src, GLfloat *dst)
487 const GLushort *s = ((const GLushort *) src);
489 for (i = 0; i < n; i++) {
490 dst[i] = s[i] * (1.0F / 65535.0F);
495 unpack_float_Z_UNORM32(GLuint n, const void *src, GLfloat *dst)
497 const GLuint *s = ((const GLuint *) src);
499 for (i = 0; i < n; i++) {
500 dst[i] = s[i] * (1.0F / 0xffffffff);
505 unpack_float_Z_FLOAT32(GLuint n, const void *src, GLfloat *dst)
507 memcpy(dst, src, n * sizeof(float));
511 unpack_float_z_Z32X24S8(GLuint n, const void *src, GLfloat *dst)
513 const struct z32f_x24s8 *s = (const struct z32f_x24s8 *) src;
515 for (i = 0; i < n; i++) {
524 * The returned values will always be in the range [0.0, 1.0].
527 _mesa_unpack_float_z_row(mesa_format format, GLuint n,
528 const void *src, GLfloat *dst)
530 unpack_float_z_func unpack;
533 case MESA_FORMAT_S8_UINT_Z24_UNORM:
534 case MESA_FORMAT_X8_UINT_Z24_UNORM:
535 unpack = unpack_float_z_X8_UINT_Z24_UNORM;
537 case MESA_FORMAT_Z24_UNORM_S8_UINT:
538 case MESA_FORMAT_Z24_UNORM_X8_UINT:
539 unpack = unpack_float_z_Z24_UNORM_X8_UINT;
541 case MESA_FORMAT_Z_UNORM16:
542 unpack = unpack_float_Z_UNORM16;
544 case MESA_FORMAT_Z_UNORM32:
545 unpack = unpack_float_Z_UNORM32;
547 case MESA_FORMAT_Z_FLOAT32:
548 unpack = unpack_float_Z_FLOAT32;
550 case MESA_FORMAT_Z32_FLOAT_S8X24_UINT:
551 unpack = unpack_float_z_Z32X24S8;
554 _mesa_problem(NULL, "bad format %s in _mesa_unpack_float_z_row",
555 _mesa_get_format_name(format));
564 typedef void (*unpack_uint_z_func)(const void *src, GLuint *dst, GLuint n);
567 unpack_uint_z_X8_UINT_Z24_UNORM(const void *src, GLuint *dst, GLuint n)
569 /* only return Z, not stencil data */
570 const GLuint *s = ((const GLuint *) src);
572 for (i = 0; i < n; i++) {
573 dst[i] = (s[i] & 0xffffff00) | (s[i] >> 24);
578 unpack_uint_z_Z24_UNORM_X8_UINT(const void *src, GLuint *dst, GLuint n)
580 /* only return Z, not stencil data */
581 const GLuint *s = ((const GLuint *) src);
583 for (i = 0; i < n; i++) {
584 dst[i] = (s[i] << 8) | ((s[i] >> 16) & 0xff);
589 unpack_uint_Z_UNORM16(const void *src, GLuint *dst, GLuint n)
591 const GLushort *s = ((const GLushort *)src);
593 for (i = 0; i < n; i++) {
594 dst[i] = (s[i] << 16) | s[i];
599 unpack_uint_Z_UNORM32(const void *src, GLuint *dst, GLuint n)
601 memcpy(dst, src, n * sizeof(GLuint));
605 unpack_uint_Z_FLOAT32(const void *src, GLuint *dst, GLuint n)
607 const float *s = (const float *)src;
609 for (i = 0; i < n; i++) {
610 dst[i] = FLOAT_TO_UINT(CLAMP(s[i], 0.0F, 1.0F));
615 unpack_uint_Z_FLOAT32_X24S8(const void *src, GLuint *dst, GLuint n)
617 const struct z32f_x24s8 *s = (const struct z32f_x24s8 *) src;
620 for (i = 0; i < n; i++) {
621 dst[i] = FLOAT_TO_UINT(CLAMP(s[i].z, 0.0F, 1.0F));
628 * The returned values will always be in the range [0, 0xffffffff].
631 _mesa_unpack_uint_z_row(mesa_format format, GLuint n,
632 const void *src, GLuint *dst)
634 unpack_uint_z_func unpack;
635 const GLubyte *srcPtr = (GLubyte *) src;
638 case MESA_FORMAT_S8_UINT_Z24_UNORM:
639 case MESA_FORMAT_X8_UINT_Z24_UNORM:
640 unpack = unpack_uint_z_X8_UINT_Z24_UNORM;
642 case MESA_FORMAT_Z24_UNORM_S8_UINT:
643 case MESA_FORMAT_Z24_UNORM_X8_UINT:
644 unpack = unpack_uint_z_Z24_UNORM_X8_UINT;
646 case MESA_FORMAT_Z_UNORM16:
647 unpack = unpack_uint_Z_UNORM16;
649 case MESA_FORMAT_Z_UNORM32:
650 unpack = unpack_uint_Z_UNORM32;
652 case MESA_FORMAT_Z_FLOAT32:
653 unpack = unpack_uint_Z_FLOAT32;
655 case MESA_FORMAT_Z32_FLOAT_S8X24_UINT:
656 unpack = unpack_uint_Z_FLOAT32_X24S8;
659 _mesa_problem(NULL, "bad format %s in _mesa_unpack_uint_z_row",
660 _mesa_get_format_name(format));
664 unpack(srcPtr, dst, n);
669 unpack_ubyte_s_S_UINT8(const void *src, GLubyte *dst, GLuint n)
675 unpack_ubyte_s_S8_UINT_Z24_UNORM(const void *src, GLubyte *dst, GLuint n)
678 const GLuint *src32 = src;
680 for (i = 0; i < n; i++)
681 dst[i] = src32[i] & 0xff;
685 unpack_ubyte_s_Z24_UNORM_S8_UINT(const void *src, GLubyte *dst, GLuint n)
688 const GLuint *src32 = src;
690 for (i = 0; i < n; i++)
691 dst[i] = src32[i] >> 24;
695 unpack_ubyte_s_Z32_FLOAT_S8X24_UINT(const void *src, GLubyte *dst, GLuint n)
698 const struct z32f_x24s8 *s = (const struct z32f_x24s8 *) src;
700 for (i = 0; i < n; i++)
701 dst[i] = s[i].x24s8 & 0xff;
705 _mesa_unpack_ubyte_stencil_row(mesa_format format, GLuint n,
706 const void *src, GLubyte *dst)
709 case MESA_FORMAT_S_UINT8:
710 unpack_ubyte_s_S_UINT8(src, dst, n);
712 case MESA_FORMAT_S8_UINT_Z24_UNORM:
713 unpack_ubyte_s_S8_UINT_Z24_UNORM(src, dst, n);
715 case MESA_FORMAT_Z24_UNORM_S8_UINT:
716 unpack_ubyte_s_Z24_UNORM_S8_UINT(src, dst, n);
718 case MESA_FORMAT_Z32_FLOAT_S8X24_UINT:
719 unpack_ubyte_s_Z32_FLOAT_S8X24_UINT(src, dst, n);
722 _mesa_problem(NULL, "bad format %s in _mesa_unpack_ubyte_s_row",
723 _mesa_get_format_name(format));
729 unpack_uint_24_8_depth_stencil_Z24_UNORM_S8_UINT(const GLuint *src, GLuint *dst, GLuint n)
733 for (i = 0; i < n; i++) {
735 dst[i] = val >> 24 | val << 8;
740 unpack_uint_24_8_depth_stencil_Z32_S8X24(const GLuint *src,
741 GLuint *dst, GLuint n)
745 for (i = 0; i < n; i++) {
746 /* 8 bytes per pixel (float + uint32) */
747 GLfloat zf = ((GLfloat *) src)[i * 2 + 0];
748 GLuint z24 = (GLuint) (zf * (GLfloat) 0xffffff);
749 GLuint s = src[i * 2 + 1] & 0xff;
750 dst[i] = (z24 << 8) | s;
755 unpack_uint_24_8_depth_stencil_S8_UINT_Z24_UNORM(const GLuint *src, GLuint *dst, GLuint n)
757 memcpy(dst, src, n * 4);
761 * Unpack depth/stencil returning as GL_UNSIGNED_INT_24_8.
762 * \param format the source data format
765 _mesa_unpack_uint_24_8_depth_stencil_row(mesa_format format, GLuint n,
766 const void *src, GLuint *dst)
769 case MESA_FORMAT_S8_UINT_Z24_UNORM:
770 unpack_uint_24_8_depth_stencil_S8_UINT_Z24_UNORM(src, dst, n);
772 case MESA_FORMAT_Z24_UNORM_S8_UINT:
773 unpack_uint_24_8_depth_stencil_Z24_UNORM_S8_UINT(src, dst, n);
775 case MESA_FORMAT_Z32_FLOAT_S8X24_UINT:
776 unpack_uint_24_8_depth_stencil_Z32_S8X24(src, dst, n);
780 "bad format %s in _mesa_unpack_uint_24_8_depth_stencil_row",
781 _mesa_get_format_name(format));
787 unpack_float_32_uint_24_8_Z24_UNORM_S8_UINT(const GLuint *src,
788 GLuint *dst, GLuint n)
791 struct z32f_x24s8 *d = (struct z32f_x24s8 *) dst;
792 const GLdouble scale = 1.0 / (GLdouble) 0xffffff;
794 for (i = 0; i < n; i++) {
795 const GLuint z24 = src[i] & 0xffffff;
796 d[i].z = z24 * scale;
797 d[i].x24s8 = src[i] >> 24;
798 assert(d[i].z >= 0.0f);
799 assert(d[i].z <= 1.0f);
804 unpack_float_32_uint_24_8_Z32_FLOAT_S8X24_UINT(const GLuint *src,
805 GLuint *dst, GLuint n)
807 memcpy(dst, src, n * sizeof(struct z32f_x24s8));
811 unpack_float_32_uint_24_8_S8_UINT_Z24_UNORM(const GLuint *src,
812 GLuint *dst, GLuint n)
815 struct z32f_x24s8 *d = (struct z32f_x24s8 *) dst;
816 const GLdouble scale = 1.0 / (GLdouble) 0xffffff;
818 for (i = 0; i < n; i++) {
819 const GLuint z24 = src[i] >> 8;
820 d[i].z = z24 * scale;
821 d[i].x24s8 = src[i] & 0xff;
822 assert(d[i].z >= 0.0f);
823 assert(d[i].z <= 1.0f);
828 * Unpack depth/stencil returning as GL_FLOAT_32_UNSIGNED_INT_24_8_REV.
829 * \param format the source data format
831 * In GL_FLOAT_32_UNSIGNED_INT_24_8_REV lower 4 bytes contain float
832 * component and higher 4 bytes contain packed 24-bit and 8-bit
835 * 31 30 29 28 ... 4 3 2 1 0 31 30 29 ... 9 8 7 6 5 ... 2 1 0
836 * +-------------------------+ +--------------------------------+
837 * | Float Component | | Unused | 8 bit stencil |
838 * +-------------------------+ +--------------------------------+
839 * lower 4 bytes higher 4 bytes
842 _mesa_unpack_float_32_uint_24_8_depth_stencil_row(mesa_format format, GLuint n,
843 const void *src, GLuint *dst)
846 case MESA_FORMAT_S8_UINT_Z24_UNORM:
847 unpack_float_32_uint_24_8_S8_UINT_Z24_UNORM(src, dst, n);
849 case MESA_FORMAT_Z24_UNORM_S8_UINT:
850 unpack_float_32_uint_24_8_Z24_UNORM_S8_UINT(src, dst, n);
852 case MESA_FORMAT_Z32_FLOAT_S8X24_UINT:
853 unpack_float_32_uint_24_8_Z32_FLOAT_S8X24_UINT(src, dst, n);
857 "bad format %s in _mesa_unpack_uint_24_8_depth_stencil_row",
858 _mesa_get_format_name(format));
864 * Unpack depth/stencil
865 * \param format the source data format
866 * \param type the destination data type
869 _mesa_unpack_depth_stencil_row(mesa_format format, GLuint n,
870 const void *src, GLenum type,
873 assert(type == GL_UNSIGNED_INT_24_8 ||
874 type == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
877 case GL_UNSIGNED_INT_24_8:
878 _mesa_unpack_uint_24_8_depth_stencil_row(format, n, src, dst);
880 case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
881 _mesa_unpack_float_32_uint_24_8_depth_stencil_row(format, n, src, dst);
885 "bad type 0x%x in _mesa_unpack_depth_stencil_row",
892 template
= Template(string
);
894 print template
.render(argv
= argv
[0:])