2 * Mesa 3-D graphics library
4 * Copyright (c) 2011 VMware, Inc.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 #include "format_unpack.h"
28 #include "../../gallium/auxiliary/util/u_format_rgb9e5.h"
29 #include "../../gallium/auxiliary/util/u_format_r11g11b10f.h"
33 * Convert an 8-bit sRGB value from non-linear space to a
34 * linear RGB value in [0, 1].
35 * Implemented with a 256-entry lookup table.
38 nonlinear_to_linear(GLubyte cs8
)
40 static GLfloat table
[256];
41 static GLboolean tableReady
= GL_FALSE
;
43 /* compute lookup table now */
45 for (i
= 0; i
< 256; i
++) {
46 const GLfloat cs
= UBYTE_TO_FLOAT(i
);
48 table
[i
] = cs
/ 12.92f
;
51 table
[i
] = (GLfloat
) pow((cs
+ 0.055) / 1.055, 2.4);
60 typedef void (*unpack_rgba_func
)(const void *src
, GLfloat dst
[][4], GLuint n
);
64 unpack_RGBA8888(const void *src
, GLfloat dst
[][4], GLuint n
)
66 const GLuint
*s
= ((const GLuint
*) src
);
68 for (i
= 0; i
< n
; i
++) {
69 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 24) );
70 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 16) & 0xff );
71 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 8) & 0xff );
72 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( (s
[i
] ) & 0xff );
77 unpack_RGBA8888_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
79 const GLuint
*s
= ((const GLuint
*) src
);
81 for (i
= 0; i
< n
; i
++) {
82 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( (s
[i
] ) & 0xff );
83 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 8) & 0xff );
84 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 16) & 0xff );
85 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 24) );
90 unpack_ARGB8888(const void *src
, GLfloat dst
[][4], GLuint n
)
92 const GLuint
*s
= ((const GLuint
*) src
);
94 for (i
= 0; i
< n
; i
++) {
95 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 16) & 0xff );
96 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 8) & 0xff );
97 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( (s
[i
] ) & 0xff );
98 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 24) );
103 unpack_ARGB8888_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
105 const GLuint
*s
= ((const GLuint
*) src
);
107 for (i
= 0; i
< n
; i
++) {
108 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 8) & 0xff );
109 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 16) & 0xff );
110 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 24) );
111 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( (s
[i
] ) & 0xff );
116 unpack_RGBX8888(const void *src
, GLfloat dst
[][4], GLuint n
)
118 const GLuint
*s
= ((const GLuint
*) src
);
120 for (i
= 0; i
< n
; i
++) {
121 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 24) );
122 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 16) & 0xff );
123 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 8) & 0xff );
124 dst
[i
][ACOMP
] = 1.0f
;
129 unpack_RGBX8888_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
131 const GLuint
*s
= ((const GLuint
*) src
);
133 for (i
= 0; i
< n
; i
++) {
134 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( (s
[i
] ) & 0xff );
135 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 8) & 0xff );
136 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 16) & 0xff );
137 dst
[i
][ACOMP
] = 1.0f
;
142 unpack_XRGB8888(const void *src
, GLfloat dst
[][4], GLuint n
)
144 const GLuint
*s
= ((const GLuint
*) src
);
146 for (i
= 0; i
< n
; i
++) {
147 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 16) & 0xff );
148 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 8) & 0xff );
149 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( (s
[i
] ) & 0xff );
150 dst
[i
][ACOMP
] = 1.0f
;
155 unpack_XRGB8888_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
157 const GLuint
*s
= ((const GLuint
*) src
);
159 for (i
= 0; i
< n
; i
++) {
160 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 8) & 0xff );
161 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 16) & 0xff );
162 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 24) );
163 dst
[i
][ACOMP
] = 1.0f
;
168 unpack_RGB888(const void *src
, GLfloat dst
[][4], GLuint n
)
170 const GLubyte
*s
= (const GLubyte
*) src
;
172 for (i
= 0; i
< n
; i
++) {
173 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( s
[i
*3+2] );
174 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( s
[i
*3+1] );
175 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( s
[i
*3+0] );
176 dst
[i
][ACOMP
] = 1.0F
;
181 unpack_BGR888(const void *src
, GLfloat dst
[][4], GLuint n
)
183 const GLubyte
*s
= (const GLubyte
*) src
;
185 for (i
= 0; i
< n
; i
++) {
186 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( s
[i
*3+0] );
187 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( s
[i
*3+1] );
188 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( s
[i
*3+2] );
189 dst
[i
][ACOMP
] = 1.0F
;
194 unpack_RGB565(const void *src
, GLfloat dst
[][4], GLuint n
)
196 const GLushort
*s
= ((const GLushort
*) src
);
198 for (i
= 0; i
< n
; i
++) {
199 dst
[i
][RCOMP
] = ((s
[i
] >> 11) & 0x1f) * (1.0F
/ 31.0F
);
200 dst
[i
][GCOMP
] = ((s
[i
] >> 5 ) & 0x3f) * (1.0F
/ 63.0F
);
201 dst
[i
][BCOMP
] = ((s
[i
] ) & 0x1f) * (1.0F
/ 31.0F
);
202 dst
[i
][ACOMP
] = 1.0F
;
207 unpack_RGB565_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
209 const GLushort
*s
= ((const GLushort
*) src
);
211 for (i
= 0; i
< n
; i
++) {
212 GLuint t
= (s
[i
] >> 8) | (s
[i
] << 8); /* byte swap */
213 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( ((t
>> 8) & 0xf8) | ((t
>> 13) & 0x7) );
214 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( ((t
>> 3) & 0xfc) | ((t
>> 9) & 0x3) );
215 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( ((t
<< 3) & 0xf8) | ((t
>> 2) & 0x7) );
216 dst
[i
][ACOMP
] = 1.0F
;
221 unpack_ARGB4444(const void *src
, GLfloat dst
[][4], GLuint n
)
223 const GLushort
*s
= ((const GLushort
*) src
);
225 for (i
= 0; i
< n
; i
++) {
226 dst
[i
][RCOMP
] = ((s
[i
] >> 8) & 0xf) * (1.0F
/ 15.0F
);
227 dst
[i
][GCOMP
] = ((s
[i
] >> 4) & 0xf) * (1.0F
/ 15.0F
);
228 dst
[i
][BCOMP
] = ((s
[i
] ) & 0xf) * (1.0F
/ 15.0F
);
229 dst
[i
][ACOMP
] = ((s
[i
] >> 12) & 0xf) * (1.0F
/ 15.0F
);
234 unpack_ARGB4444_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
236 const GLushort
*s
= ((const GLushort
*) src
);
238 for (i
= 0; i
< n
; i
++) {
239 dst
[i
][RCOMP
] = ((s
[i
] ) & 0xf) * (1.0F
/ 15.0F
);
240 dst
[i
][GCOMP
] = ((s
[i
] >> 12) & 0xf) * (1.0F
/ 15.0F
);
241 dst
[i
][BCOMP
] = ((s
[i
] >> 8) & 0xf) * (1.0F
/ 15.0F
);
242 dst
[i
][ACOMP
] = ((s
[i
] >> 4) & 0xf) * (1.0F
/ 15.0F
);
247 unpack_RGBA5551(const void *src
, GLfloat dst
[][4], GLuint n
)
249 const GLushort
*s
= ((const GLushort
*) src
);
251 for (i
= 0; i
< n
; i
++) {
252 dst
[i
][RCOMP
] = ((s
[i
] >> 11) & 0x1f) * (1.0F
/ 31.0F
);
253 dst
[i
][GCOMP
] = ((s
[i
] >> 6) & 0x1f) * (1.0F
/ 31.0F
);
254 dst
[i
][BCOMP
] = ((s
[i
] >> 1) & 0x1f) * (1.0F
/ 31.0F
);
255 dst
[i
][ACOMP
] = ((s
[i
] ) & 0x01) * 1.0F
;
260 unpack_ARGB1555(const void *src
, GLfloat dst
[][4], GLuint n
)
262 const GLushort
*s
= ((const GLushort
*) src
);
264 for (i
= 0; i
< n
; i
++) {
265 dst
[i
][RCOMP
] = ((s
[i
] >> 10) & 0x1f) * (1.0F
/ 31.0F
);
266 dst
[i
][GCOMP
] = ((s
[i
] >> 5) & 0x1f) * (1.0F
/ 31.0F
);
267 dst
[i
][BCOMP
] = ((s
[i
] >> 0) & 0x1f) * (1.0F
/ 31.0F
);
268 dst
[i
][ACOMP
] = ((s
[i
] >> 15) & 0x01) * 1.0F
;
273 unpack_ARGB1555_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
275 const GLushort
*s
= ((const GLushort
*) src
);
277 for (i
= 0; i
< n
; i
++) {
278 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( ((s
[i
] >> 7) & 0xf8) | ((s
[i
] >> 12) & 0x7) );
279 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( ((s
[i
] >> 2) & 0xf8) | ((s
[i
] >> 7) & 0x7) );
280 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( ((s
[i
] << 3) & 0xf8) | ((s
[i
] >> 2) & 0x7) );
281 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( ((s
[i
] >> 15) & 0x01) * 255 );
286 unpack_AL44(const void *src
, GLfloat dst
[][4], GLuint n
)
288 const GLubyte
*s
= ((const GLubyte
*) src
);
290 for (i
= 0; i
< n
; i
++) {
293 dst
[i
][BCOMP
] = (s
[i
] & 0xf) * (1.0F
/ 15.0F
);
294 dst
[i
][ACOMP
] = ((s
[i
] >> 4) & 0xf) * (1.0F
/ 15.0F
);
299 unpack_AL88(const void *src
, GLfloat dst
[][4], GLuint n
)
301 const GLushort
*s
= ((const GLushort
*) src
);
303 for (i
= 0; i
< n
; i
++) {
306 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( s
[i
] & 0xff );
307 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 8 );
312 unpack_AL88_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
314 const GLushort
*s
= ((const GLushort
*) src
);
316 for (i
= 0; i
< n
; i
++) {
319 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 8 );
320 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( s
[i
] & 0xff );
325 unpack_AL1616(const void *src
, GLfloat dst
[][4], GLuint n
)
327 const GLuint
*s
= ((const GLuint
*) src
);
329 for (i
= 0; i
< n
; i
++) {
332 dst
[i
][BCOMP
] = USHORT_TO_FLOAT( s
[i
] & 0xffff );
333 dst
[i
][ACOMP
] = USHORT_TO_FLOAT( s
[i
] >> 16 );
338 unpack_AL1616_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
340 const GLuint
*s
= ((const GLuint
*) src
);
342 for (i
= 0; i
< n
; i
++) {
345 dst
[i
][BCOMP
] = USHORT_TO_FLOAT( s
[i
] >> 16 );
346 dst
[i
][ACOMP
] = USHORT_TO_FLOAT( s
[i
] & 0xffff );
351 unpack_RGB332(const void *src
, GLfloat dst
[][4], GLuint n
)
353 const GLubyte
*s
= ((const GLubyte
*) src
);
355 for (i
= 0; i
< n
; i
++) {
356 dst
[i
][RCOMP
] = ((s
[i
] >> 5) & 0x7) * (1.0F
/ 7.0F
);
357 dst
[i
][GCOMP
] = ((s
[i
] >> 2) & 0x7) * (1.0F
/ 7.0F
);
358 dst
[i
][BCOMP
] = ((s
[i
] ) & 0x3) * (1.0F
/ 3.0F
);
359 dst
[i
][ACOMP
] = 1.0F
;
365 unpack_A8(const void *src
, GLfloat dst
[][4], GLuint n
)
367 const GLubyte
*s
= ((const GLubyte
*) src
);
369 for (i
= 0; i
< n
; i
++) {
372 dst
[i
][BCOMP
] = 0.0F
;
373 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT(s
[i
]);
378 unpack_A16(const void *src
, GLfloat dst
[][4], GLuint n
)
380 const GLushort
*s
= ((const GLushort
*) src
);
382 for (i
= 0; i
< n
; i
++) {
385 dst
[i
][BCOMP
] = 0.0F
;
386 dst
[i
][ACOMP
] = USHORT_TO_FLOAT(s
[i
]);
391 unpack_L8(const void *src
, GLfloat dst
[][4], GLuint n
)
393 const GLubyte
*s
= ((const GLubyte
*) src
);
395 for (i
= 0; i
< n
; i
++) {
398 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT(s
[i
]);
399 dst
[i
][ACOMP
] = 1.0F
;
404 unpack_L16(const void *src
, GLfloat dst
[][4], GLuint n
)
406 const GLushort
*s
= ((const GLushort
*) src
);
408 for (i
= 0; i
< n
; i
++) {
411 dst
[i
][BCOMP
] = USHORT_TO_FLOAT(s
[i
]);
412 dst
[i
][ACOMP
] = 1.0F
;
417 unpack_I8(const void *src
, GLfloat dst
[][4], GLuint n
)
419 const GLubyte
*s
= ((const GLubyte
*) src
);
421 for (i
= 0; i
< n
; i
++) {
425 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT(s
[i
]);
430 unpack_I16(const void *src
, GLfloat dst
[][4], GLuint n
)
432 const GLushort
*s
= ((const GLushort
*) src
);
434 for (i
= 0; i
< n
; i
++) {
438 dst
[i
][ACOMP
] = USHORT_TO_FLOAT(s
[i
]);
443 unpack_YCBCR(const void *src
, GLfloat dst
[][4], GLuint n
)
446 for (i
= 0; i
< n
; i
++) {
447 const GLushort
*src0
= ((const GLushort
*) src
) + i
* 2; /* even */
448 const GLushort
*src1
= src0
+ 1; /* odd */
449 const GLubyte y0
= (*src0
>> 8) & 0xff; /* luminance */
450 const GLubyte cb
= *src0
& 0xff; /* chroma U */
451 const GLubyte y1
= (*src1
>> 8) & 0xff; /* luminance */
452 const GLubyte cr
= *src1
& 0xff; /* chroma V */
453 const GLubyte y
= (i
& 1) ? y1
: y0
; /* choose even/odd luminance */
454 GLfloat r
= 1.164F
* (y
- 16) + 1.596F
* (cr
- 128);
455 GLfloat g
= 1.164F
* (y
- 16) - 0.813F
* (cr
- 128) - 0.391F
* (cb
- 128);
456 GLfloat b
= 1.164F
* (y
- 16) + 2.018F
* (cb
- 128);
457 r
*= (1.0F
/ 255.0F
);
458 g
*= (1.0F
/ 255.0F
);
459 b
*= (1.0F
/ 255.0F
);
460 dst
[i
][RCOMP
] = CLAMP(r
, 0.0F
, 1.0F
);
461 dst
[i
][GCOMP
] = CLAMP(g
, 0.0F
, 1.0F
);
462 dst
[i
][BCOMP
] = CLAMP(b
, 0.0F
, 1.0F
);
463 dst
[i
][ACOMP
] = 1.0F
;
468 unpack_YCBCR_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
471 for (i
= 0; i
< n
; i
++) {
472 const GLushort
*src0
= ((const GLushort
*) src
) + i
* 2; /* even */
473 const GLushort
*src1
= src0
+ 1; /* odd */
474 const GLubyte y0
= *src0
& 0xff; /* luminance */
475 const GLubyte cr
= (*src0
>> 8) & 0xff; /* chroma V */
476 const GLubyte y1
= *src1
& 0xff; /* luminance */
477 const GLubyte cb
= (*src1
>> 8) & 0xff; /* chroma U */
478 const GLubyte y
= (i
& 1) ? y1
: y0
; /* choose even/odd luminance */
479 GLfloat r
= 1.164F
* (y
- 16) + 1.596F
* (cr
- 128);
480 GLfloat g
= 1.164F
* (y
- 16) - 0.813F
* (cr
- 128) - 0.391F
* (cb
- 128);
481 GLfloat b
= 1.164F
* (y
- 16) + 2.018F
* (cb
- 128);
482 r
*= (1.0F
/ 255.0F
);
483 g
*= (1.0F
/ 255.0F
);
484 b
*= (1.0F
/ 255.0F
);
485 dst
[i
][RCOMP
] = CLAMP(r
, 0.0F
, 1.0F
);
486 dst
[i
][GCOMP
] = CLAMP(g
, 0.0F
, 1.0F
);
487 dst
[i
][BCOMP
] = CLAMP(b
, 0.0F
, 1.0F
);
488 dst
[i
][ACOMP
] = 1.0F
;
493 unpack_R8(const void *src
, GLfloat dst
[][4], GLuint n
)
495 const GLubyte
*s
= ((const GLubyte
*) src
);
497 for (i
= 0; i
< n
; i
++) {
498 dst
[i
][0] = UBYTE_TO_FLOAT(s
[i
]);
506 unpack_RG88(const void *src
, GLfloat dst
[][4], GLuint n
)
508 const GLushort
*s
= ((const GLushort
*) src
);
510 for (i
= 0; i
< n
; i
++) {
511 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( s
[i
] & 0xff );
512 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 8 );
519 unpack_RG88_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
521 const GLushort
*s
= ((const GLushort
*) src
);
523 for (i
= 0; i
< n
; i
++) {
524 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( s
[i
] & 0xff );
525 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 8 );
532 unpack_R16(const void *src
, GLfloat dst
[][4], GLuint n
)
534 const GLushort
*s
= ((const GLushort
*) src
);
536 for (i
= 0; i
< n
; i
++) {
537 dst
[i
][RCOMP
] = USHORT_TO_FLOAT(s
[i
]);
545 unpack_RG1616(const void *src
, GLfloat dst
[][4], GLuint n
)
547 const GLuint
*s
= ((const GLuint
*) src
);
549 for (i
= 0; i
< n
; i
++) {
550 dst
[i
][RCOMP
] = USHORT_TO_FLOAT( s
[i
] & 0xffff );
551 dst
[i
][GCOMP
] = USHORT_TO_FLOAT( s
[i
] >> 16 );
558 unpack_RG1616_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
560 const GLuint
*s
= ((const GLuint
*) src
);
562 for (i
= 0; i
< n
; i
++) {
563 dst
[i
][RCOMP
] = USHORT_TO_FLOAT( s
[i
] >> 16 );
564 dst
[i
][GCOMP
] = USHORT_TO_FLOAT( s
[i
] & 0xffff );
571 unpack_ARGB2101010(const void *src
, GLfloat dst
[][4], GLuint n
)
573 const GLuint
*s
= ((const GLuint
*) src
);
575 for (i
= 0; i
< n
; i
++) {
576 dst
[i
][RCOMP
] = ((s
[i
] >> 20) & 0x3ff) * (1.0F
/ 1023.0F
);
577 dst
[i
][GCOMP
] = ((s
[i
] >> 10) & 0x3ff) * (1.0F
/ 1023.0F
);
578 dst
[i
][BCOMP
] = ((s
[i
] >> 0) & 0x3ff) * (1.0F
/ 1023.0F
);
579 dst
[i
][ACOMP
] = ((s
[i
] >> 30) & 0x03) * (1.0F
/ 3.0F
);
585 unpack_Z24_S8(const void *src
, GLfloat dst
[][4], GLuint n
)
587 /* only return Z, not stencil data */
588 const GLuint
*s
= ((const GLuint
*) src
);
589 const GLfloat scale
= 1.0F
/ (GLfloat
) 0xffffff;
591 for (i
= 0; i
< n
; i
++) {
594 dst
[i
][2] = (s
[i
] >> 8) * scale
;
596 ASSERT(dst
[i
][0] >= 0.0F
);
597 ASSERT(dst
[i
][0] <= 1.0F
);
602 unpack_S8_Z24(const void *src
, GLfloat dst
[][4], GLuint n
)
604 /* only return Z, not stencil data */
605 const GLuint
*s
= ((const GLuint
*) src
);
606 const GLfloat scale
= 1.0F
/ (GLfloat
) 0xffffff;
608 for (i
= 0; i
< n
; i
++) {
611 dst
[i
][2] = (s
[i
] & 0x00ffffff) * scale
;
613 ASSERT(dst
[i
][0] >= 0.0F
);
614 ASSERT(dst
[i
][0] <= 1.0F
);
619 unpack_Z16(const void *src
, GLfloat dst
[][4], GLuint n
)
621 const GLushort
*s
= ((const GLushort
*) src
);
623 for (i
= 0; i
< n
; i
++) {
626 dst
[i
][2] = s
[i
] * (1.0F
/ 65535.0F
);
632 unpack_X8_Z24(const void *src
, GLfloat dst
[][4], GLuint n
)
634 unpack_S8_Z24(src
, dst
, n
);
638 unpack_Z24_X8(const void *src
, GLfloat dst
[][4], GLuint n
)
640 unpack_Z24_S8(src
, dst
, n
);
644 unpack_Z32(const void *src
, GLfloat dst
[][4], GLuint n
)
646 const GLuint
*s
= ((const GLuint
*) src
);
648 for (i
= 0; i
< n
; i
++) {
651 dst
[i
][2] = s
[i
] * (1.0F
/ 0xffffffff);
657 unpack_Z32_FLOAT(const void *src
, GLfloat dst
[][4], GLuint n
)
659 const GLfloat
*s
= ((const GLfloat
*) src
);
661 for (i
= 0; i
< n
; i
++) {
664 dst
[i
][2] = s
[i
* 2];
670 unpack_Z32_FLOAT_X24S8(const void *src
, GLfloat dst
[][4], GLuint n
)
672 const GLfloat
*s
= ((const GLfloat
*) src
);
674 for (i
= 0; i
< n
; i
++) {
684 unpack_S8(const void *src
, GLfloat dst
[][4], GLuint n
)
686 /* should never be used */
688 for (i
= 0; i
< n
; i
++) {
698 unpack_SRGB8(const void *src
, GLfloat dst
[][4], GLuint n
)
700 const GLubyte
*s
= (const GLubyte
*) src
;
702 for (i
= 0; i
< n
; i
++) {
703 dst
[i
][RCOMP
] = nonlinear_to_linear(s
[i
*3+2]);
704 dst
[i
][GCOMP
] = nonlinear_to_linear(s
[i
*3+1]);
705 dst
[i
][BCOMP
] = nonlinear_to_linear(s
[i
*3+0]);
706 dst
[i
][ACOMP
] = 1.0F
;
711 unpack_SRGBA8(const void *src
, GLfloat dst
[][4], GLuint n
)
713 const GLuint
*s
= ((const GLuint
*) src
);
715 for (i
= 0; i
< n
; i
++) {
716 dst
[i
][RCOMP
] = nonlinear_to_linear( (s
[i
] >> 24) );
717 dst
[i
][GCOMP
] = nonlinear_to_linear( (s
[i
] >> 16) & 0xff );
718 dst
[i
][BCOMP
] = nonlinear_to_linear( (s
[i
] >> 8) & 0xff );
719 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( s
[i
] & 0xff ); /* linear! */
724 unpack_SARGB8(const void *src
, GLfloat dst
[][4], GLuint n
)
726 const GLuint
*s
= ((const GLuint
*) src
);
728 for (i
= 0; i
< n
; i
++) {
729 dst
[i
][RCOMP
] = nonlinear_to_linear( (s
[i
] >> 16) & 0xff );
730 dst
[i
][GCOMP
] = nonlinear_to_linear( (s
[i
] >> 8) & 0xff );
731 dst
[i
][BCOMP
] = nonlinear_to_linear( (s
[i
] ) & 0xff );
732 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 24 ); /* linear! */
737 unpack_SL8(const void *src
, GLfloat dst
[][4], GLuint n
)
739 const GLubyte
*s
= ((const GLubyte
*) src
);
741 for (i
= 0; i
< n
; i
++) {
744 dst
[i
][BCOMP
] = nonlinear_to_linear(s
[i
]);
745 dst
[i
][ACOMP
] = 1.0F
;
750 unpack_SLA8(const void *src
, GLfloat dst
[][4], GLuint n
)
752 const GLubyte
*s
= (const GLubyte
*) src
;
754 for (i
= 0; i
< n
; i
++) {
757 dst
[i
][BCOMP
] = nonlinear_to_linear(s
[i
*2+0]);
758 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT(s
[i
*2+1]); /* linear! */
763 unpack_SRGB_DXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
768 unpack_SRGBA_DXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
773 unpack_SRGBA_DXT3(const void *src
, GLfloat dst
[][4], GLuint n
)
778 unpack_SRGBA_DXT5(const void *src
, GLfloat dst
[][4], GLuint n
)
783 unpack_RGB_FXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
788 unpack_RGBA_FXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
793 unpack_RGB_DXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
798 unpack_RGBA_DXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
803 unpack_RGBA_DXT3(const void *src
, GLfloat dst
[][4], GLuint n
)
808 unpack_RGBA_DXT5(const void *src
, GLfloat dst
[][4], GLuint n
)
814 unpack_RGBA_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
816 const GLfloat
*s
= (const GLfloat
*) src
;
818 for (i
= 0; i
< n
; i
++) {
819 dst
[i
][RCOMP
] = s
[i
*4+0];
820 dst
[i
][GCOMP
] = s
[i
*4+1];
821 dst
[i
][BCOMP
] = s
[i
*4+2];
822 dst
[i
][ACOMP
] = s
[i
*4+3];
827 unpack_RGBA_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
829 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
831 for (i
= 0; i
< n
; i
++) {
832 dst
[i
][RCOMP
] = _mesa_half_to_float(s
[i
*4+0]);
833 dst
[i
][GCOMP
] = _mesa_half_to_float(s
[i
*4+1]);
834 dst
[i
][BCOMP
] = _mesa_half_to_float(s
[i
*4+2]);
835 dst
[i
][ACOMP
] = _mesa_half_to_float(s
[i
*4+3]);
840 unpack_RGB_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
842 const GLfloat
*s
= (const GLfloat
*) src
;
844 for (i
= 0; i
< n
; i
++) {
845 dst
[i
][RCOMP
] = s
[i
*3+0];
846 dst
[i
][GCOMP
] = s
[i
*3+1];
847 dst
[i
][BCOMP
] = s
[i
*3+2];
848 dst
[i
][ACOMP
] = 1.0F
;
853 unpack_RGB_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
855 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
857 for (i
= 0; i
< n
; i
++) {
858 dst
[i
][RCOMP
] = _mesa_half_to_float(s
[i
*3+0]);
859 dst
[i
][GCOMP
] = _mesa_half_to_float(s
[i
*3+1]);
860 dst
[i
][BCOMP
] = _mesa_half_to_float(s
[i
*3+2]);
861 dst
[i
][ACOMP
] = 1.0F
;
866 unpack_ALPHA_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
868 const GLfloat
*s
= (const GLfloat
*) src
;
870 for (i
= 0; i
< n
; i
++) {
873 dst
[i
][BCOMP
] = 0.0F
;
874 dst
[i
][ACOMP
] = s
[i
];
879 unpack_ALPHA_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
881 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
883 for (i
= 0; i
< n
; i
++) {
886 dst
[i
][BCOMP
] = 0.0F
;
887 dst
[i
][ACOMP
] = _mesa_half_to_float(s
[i
]);
892 unpack_LUMINANCE_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
894 const GLfloat
*s
= (const GLfloat
*) src
;
896 for (i
= 0; i
< n
; i
++) {
899 dst
[i
][BCOMP
] = s
[i
];
900 dst
[i
][ACOMP
] = 1.0F
;
905 unpack_LUMINANCE_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
907 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
909 for (i
= 0; i
< n
; i
++) {
912 dst
[i
][BCOMP
] = _mesa_half_to_float(s
[i
]);
913 dst
[i
][ACOMP
] = 1.0F
;
918 unpack_LUMINANCE_ALPHA_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
920 const GLfloat
*s
= (const GLfloat
*) src
;
922 for (i
= 0; i
< n
; i
++) {
925 dst
[i
][BCOMP
] = s
[i
*2+0];
926 dst
[i
][ACOMP
] = s
[i
*2+1];
931 unpack_LUMINANCE_ALPHA_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
933 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
935 for (i
= 0; i
< n
; i
++) {
938 dst
[i
][BCOMP
] = _mesa_half_to_float(s
[i
*2+0]);
939 dst
[i
][ACOMP
] = _mesa_half_to_float(s
[i
*2+1]);
944 unpack_INTENSITY_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
946 const GLfloat
*s
= (const GLfloat
*) src
;
948 for (i
= 0; i
< n
; i
++) {
952 dst
[i
][ACOMP
] = s
[i
];
957 unpack_INTENSITY_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
959 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
961 for (i
= 0; i
< n
; i
++) {
965 dst
[i
][ACOMP
] = _mesa_half_to_float(s
[i
]);
970 unpack_R_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
972 const GLfloat
*s
= (const GLfloat
*) src
;
974 for (i
= 0; i
< n
; i
++) {
975 dst
[i
][RCOMP
] = s
[i
];
976 dst
[i
][GCOMP
] = 0.0F
;
977 dst
[i
][BCOMP
] = 0.0F
;
978 dst
[i
][ACOMP
] = 1.0F
;
983 unpack_R_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
985 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
987 for (i
= 0; i
< n
; i
++) {
988 dst
[i
][RCOMP
] = _mesa_half_to_float(s
[i
]);
989 dst
[i
][GCOMP
] = 0.0F
;
990 dst
[i
][BCOMP
] = 0.0F
;
991 dst
[i
][ACOMP
] = 1.0F
;
996 unpack_RG_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
998 const GLfloat
*s
= (const GLfloat
*) src
;
1000 for (i
= 0; i
< n
; i
++) {
1001 dst
[i
][RCOMP
] = s
[i
*2+0];
1002 dst
[i
][GCOMP
] = s
[i
*2+1];
1003 dst
[i
][BCOMP
] = 0.0F
;
1004 dst
[i
][ACOMP
] = 1.0F
;
1009 unpack_RG_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1011 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
1013 for (i
= 0; i
< n
; i
++) {
1014 dst
[i
][RCOMP
] = _mesa_half_to_float(s
[i
*2+0]);
1015 dst
[i
][GCOMP
] = _mesa_half_to_float(s
[i
*2+1]);
1016 dst
[i
][BCOMP
] = 0.0F
;
1017 dst
[i
][ACOMP
] = 1.0F
;
1023 unpack_RGBA_INT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1025 const GLbyte
*s
= (const GLbyte
*) src
;
1027 for (i
= 0; i
< n
; i
++) {
1028 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1029 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1030 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1031 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1036 unpack_RGBA_INT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1038 const GLshort
*s
= (const GLshort
*) src
;
1040 for (i
= 0; i
< n
; i
++) {
1041 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1042 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1043 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1044 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1049 unpack_RGBA_INT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1051 const GLint
*s
= (const GLint
*) src
;
1053 for (i
= 0; i
< n
; i
++) {
1054 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1055 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1056 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1057 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1062 unpack_RGBA_UINT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1064 const GLubyte
*s
= (const GLubyte
*) src
;
1066 for (i
= 0; i
< n
; i
++) {
1067 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1068 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1069 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1070 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1075 unpack_RGBA_UINT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1077 const GLushort
*s
= (const GLushort
*) src
;
1079 for (i
= 0; i
< n
; i
++) {
1080 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1081 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1082 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1083 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1088 unpack_RGBA_UINT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1090 const GLuint
*s
= (const GLuint
*) src
;
1092 for (i
= 0; i
< n
; i
++) {
1093 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1094 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1095 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1096 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1101 unpack_DUDV8(const void *src
, GLfloat dst
[][4], GLuint n
)
1103 const GLbyte
*s
= (const GLbyte
*) src
;
1105 for (i
= 0; i
< n
; i
++) {
1106 dst
[i
][RCOMP
] = BYTE_TO_FLOAT(s
[i
*2+0]);
1107 dst
[i
][GCOMP
] = BYTE_TO_FLOAT(s
[i
*2+1]);
1114 unpack_SIGNED_R8(const void *src
, GLfloat dst
[][4], GLuint n
)
1116 const GLbyte
*s
= ((const GLbyte
*) src
);
1118 for (i
= 0; i
< n
; i
++) {
1119 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( s
[i
] );
1120 dst
[i
][GCOMP
] = 0.0F
;
1121 dst
[i
][BCOMP
] = 0.0F
;
1122 dst
[i
][ACOMP
] = 1.0F
;
1127 unpack_SIGNED_RG88_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
1129 const GLushort
*s
= ((const GLushort
*) src
);
1131 for (i
= 0; i
< n
; i
++) {
1132 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] & 0xff) );
1133 dst
[i
][GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
1134 dst
[i
][BCOMP
] = 0.0F
;
1135 dst
[i
][ACOMP
] = 1.0F
;
1140 unpack_SIGNED_RGBX8888(const void *src
, GLfloat dst
[][4], GLuint n
)
1142 const GLuint
*s
= ((const GLuint
*) src
);
1144 for (i
= 0; i
< n
; i
++) {
1145 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 24) );
1146 dst
[i
][GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 16) );
1147 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
1148 dst
[i
][ACOMP
] = 1.0f
;
1153 unpack_SIGNED_RGBA8888(const void *src
, GLfloat dst
[][4], GLuint n
)
1155 const GLuint
*s
= ((const GLuint
*) src
);
1157 for (i
= 0; i
< n
; i
++) {
1158 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 24) );
1159 dst
[i
][GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 16) );
1160 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
1161 dst
[i
][ACOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] ) );
1166 unpack_SIGNED_RGBA8888_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
1168 const GLuint
*s
= ((const GLuint
*) src
);
1170 for (i
= 0; i
< n
; i
++) {
1171 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] ) );
1172 dst
[i
][GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
1173 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 16) );
1174 dst
[i
][ACOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 24) );
1179 unpack_SIGNED_R16(const void *src
, GLfloat dst
[][4], GLuint n
)
1181 const GLshort
*s
= ((const GLshort
*) src
);
1183 for (i
= 0; i
< n
; i
++) {
1184 dst
[i
][RCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
] );
1185 dst
[i
][GCOMP
] = 0.0F
;
1186 dst
[i
][BCOMP
] = 0.0F
;
1187 dst
[i
][ACOMP
] = 1.0F
;
1192 unpack_SIGNED_GR1616(const void *src
, GLfloat dst
[][4], GLuint n
)
1194 const GLuint
*s
= ((const GLuint
*) src
);
1196 for (i
= 0; i
< n
; i
++) {
1197 dst
[i
][RCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
] & 0xffff );
1198 dst
[i
][GCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
] >> 16 );
1199 dst
[i
][BCOMP
] = 0.0F
;
1200 dst
[i
][ACOMP
] = 1.0F
;
1205 unpack_SIGNED_RGB_16(const void *src
, GLfloat dst
[][4], GLuint n
)
1207 const GLshort
*s
= (const GLshort
*) src
;
1209 for (i
= 0; i
< n
; i
++) {
1210 dst
[i
][RCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*3+0] );
1211 dst
[i
][GCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*3+1] );
1212 dst
[i
][BCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*3+2] );
1213 dst
[i
][ACOMP
] = 1.0F
;
1218 unpack_SIGNED_RGBA_16(const void *src
, GLfloat dst
[][4], GLuint n
)
1220 const GLshort
*s
= (const GLshort
*) src
;
1222 for (i
= 0; i
< n
; i
++) {
1223 dst
[i
][RCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+0] );
1224 dst
[i
][GCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+1] );
1225 dst
[i
][BCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+2] );
1226 dst
[i
][ACOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+3] );
1231 unpack_RGBA_16(const void *src
, GLfloat dst
[][4], GLuint n
)
1233 const GLushort
*s
= (const GLushort
*) src
;
1235 for (i
= 0; i
< n
; i
++) {
1236 dst
[i
][RCOMP
] = USHORT_TO_FLOAT( s
[i
*4+0] );
1237 dst
[i
][GCOMP
] = USHORT_TO_FLOAT( s
[i
*4+1] );
1238 dst
[i
][BCOMP
] = USHORT_TO_FLOAT( s
[i
*4+2] );
1239 dst
[i
][ACOMP
] = USHORT_TO_FLOAT( s
[i
*4+3] );
1244 unpack_RED_RGTC1(const void *src
, GLfloat dst
[][4], GLuint n
)
1250 unpack_SIGNED_RED_RGTC1(const void *src
, GLfloat dst
[][4], GLuint n
)
1256 unpack_RG_RGTC2(const void *src
, GLfloat dst
[][4], GLuint n
)
1262 unpack_SIGNED_RG_RGTC2(const void *src
, GLfloat dst
[][4], GLuint n
)
1268 unpack_L_LATC1(const void *src
, GLfloat dst
[][4], GLuint n
)
1274 unpack_SIGNED_L_LATC1(const void *src
, GLfloat dst
[][4], GLuint n
)
1280 unpack_LA_LATC2(const void *src
, GLfloat dst
[][4], GLuint n
)
1286 unpack_SIGNED_LA_LATC2(const void *src
, GLfloat dst
[][4], GLuint n
)
1292 unpack_SIGNED_A8(const void *src
, GLfloat dst
[][4], GLuint n
)
1294 const GLbyte
*s
= ((const GLbyte
*) src
);
1296 for (i
= 0; i
< n
; i
++) {
1297 dst
[i
][RCOMP
] = 0.0F
;
1298 dst
[i
][GCOMP
] = 0.0F
;
1299 dst
[i
][BCOMP
] = 0.0F
;
1300 dst
[i
][ACOMP
] = BYTE_TO_FLOAT_TEX( s
[i
] );
1305 unpack_SIGNED_L8(const void *src
, GLfloat dst
[][4], GLuint n
)
1307 const GLbyte
*s
= ((const GLbyte
*) src
);
1309 for (i
= 0; i
< n
; i
++) {
1312 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( s
[i
] );
1313 dst
[i
][ACOMP
] = 1.0F
;
1318 unpack_SIGNED_AL88(const void *src
, GLfloat dst
[][4], GLuint n
)
1320 const GLshort
*s
= ((const GLshort
*) src
);
1322 for (i
= 0; i
< n
; i
++) {
1325 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] & 0xff) );
1326 dst
[i
][ACOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
1331 unpack_SIGNED_I8(const void *src
, GLfloat dst
[][4], GLuint n
)
1333 const GLbyte
*s
= ((const GLbyte
*) src
);
1335 for (i
= 0; i
< n
; i
++) {
1339 dst
[i
][ACOMP
] = BYTE_TO_FLOAT_TEX( s
[i
] );
1344 unpack_SIGNED_A16(const void *src
, GLfloat dst
[][4], GLuint n
)
1346 const GLshort
*s
= ((const GLshort
*) src
);
1348 for (i
= 0; i
< n
; i
++) {
1349 dst
[i
][RCOMP
] = 0.0F
;
1350 dst
[i
][GCOMP
] = 0.0F
;
1351 dst
[i
][BCOMP
] = 0.0F
;
1352 dst
[i
][ACOMP
] = SHORT_TO_FLOAT_TEX( s
[i
] );
1357 unpack_SIGNED_L16(const void *src
, GLfloat dst
[][4], GLuint n
)
1359 const GLshort
*s
= ((const GLshort
*) src
);
1361 for (i
= 0; i
< n
; i
++) {
1364 dst
[i
][BCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
] );
1365 dst
[i
][ACOMP
] = 1.0F
;
1370 unpack_SIGNED_AL1616(const void *src
, GLfloat dst
[][4], GLuint n
)
1372 const GLshort
*s
= (const GLshort
*) src
;
1374 for (i
= 0; i
< n
; i
++) {
1377 dst
[i
][BCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*2+0] );
1378 dst
[i
][ACOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*2+1] );
1383 unpack_SIGNED_I16(const void *src
, GLfloat dst
[][4], GLuint n
)
1385 const GLshort
*s
= ((const GLshort
*) src
);
1387 for (i
= 0; i
< n
; i
++) {
1391 dst
[i
][ACOMP
] = SHORT_TO_FLOAT_TEX( s
[i
] );
1396 unpack_RGB9_E5_FLOAT(const void *src
, GLfloat dst
[][4], GLuint n
)
1398 const GLuint
*s
= (const GLuint
*) src
;
1400 for (i
= 0; i
< n
; i
++) {
1401 rgb9e5_to_float3(s
[i
], dst
[i
]);
1402 dst
[i
][ACOMP
] = 1.0F
;
1407 unpack_R11_G11_B10_FLOAT(const void *src
, GLfloat dst
[][4], GLuint n
)
1409 const GLuint
*s
= (const GLuint
*) src
;
1411 for (i
= 0; i
< n
; i
++) {
1412 r11g11b10f_to_float3(s
[i
], dst
[i
]);
1413 dst
[i
][ACOMP
] = 1.0F
;
1419 * Return the unpacker function for the given format.
1421 static unpack_rgba_func
1422 get_unpack_rgba_function(gl_format format
)
1424 static unpack_rgba_func table
[MESA_FORMAT_COUNT
];
1425 static GLboolean initialized
= GL_FALSE
;
1428 table
[MESA_FORMAT_NONE
] = NULL
;
1430 table
[MESA_FORMAT_RGBA8888
] = unpack_RGBA8888
;
1431 table
[MESA_FORMAT_RGBA8888_REV
] = unpack_RGBA8888_REV
;
1432 table
[MESA_FORMAT_ARGB8888
] = unpack_ARGB8888
;
1433 table
[MESA_FORMAT_ARGB8888_REV
] = unpack_ARGB8888_REV
;
1434 table
[MESA_FORMAT_RGBX8888
] = unpack_RGBX8888
;
1435 table
[MESA_FORMAT_RGBX8888_REV
] = unpack_RGBX8888_REV
;
1436 table
[MESA_FORMAT_XRGB8888
] = unpack_XRGB8888
;
1437 table
[MESA_FORMAT_XRGB8888_REV
] = unpack_XRGB8888_REV
;
1438 table
[MESA_FORMAT_RGB888
] = unpack_RGB888
;
1439 table
[MESA_FORMAT_BGR888
] = unpack_BGR888
;
1440 table
[MESA_FORMAT_RGB565
] = unpack_RGB565
;
1441 table
[MESA_FORMAT_RGB565_REV
] = unpack_RGB565_REV
;
1442 table
[MESA_FORMAT_ARGB4444
] = unpack_ARGB4444
;
1443 table
[MESA_FORMAT_ARGB4444_REV
] = unpack_ARGB4444_REV
;
1444 table
[MESA_FORMAT_RGBA5551
] = unpack_RGBA5551
;
1445 table
[MESA_FORMAT_ARGB1555
] = unpack_ARGB1555
;
1446 table
[MESA_FORMAT_ARGB1555_REV
] = unpack_ARGB1555_REV
;
1447 table
[MESA_FORMAT_AL44
] = unpack_AL44
;
1448 table
[MESA_FORMAT_AL88
] = unpack_AL88
;
1449 table
[MESA_FORMAT_AL88_REV
] = unpack_AL88_REV
;
1450 table
[MESA_FORMAT_AL1616
] = unpack_AL1616
;
1451 table
[MESA_FORMAT_AL1616_REV
] = unpack_AL1616_REV
;
1452 table
[MESA_FORMAT_RGB332
] = unpack_RGB332
;
1453 table
[MESA_FORMAT_A8
] = unpack_A8
;
1454 table
[MESA_FORMAT_A16
] = unpack_A16
;
1455 table
[MESA_FORMAT_L8
] = unpack_L8
;
1456 table
[MESA_FORMAT_L16
] = unpack_L16
;
1457 table
[MESA_FORMAT_I8
] = unpack_I8
;
1458 table
[MESA_FORMAT_I16
] = unpack_I16
;
1459 table
[MESA_FORMAT_YCBCR
] = unpack_YCBCR
;
1460 table
[MESA_FORMAT_YCBCR_REV
] = unpack_YCBCR_REV
;
1461 table
[MESA_FORMAT_R8
] = unpack_R8
;
1462 table
[MESA_FORMAT_RG88
] = unpack_RG88
;
1463 table
[MESA_FORMAT_RG88_REV
] = unpack_RG88_REV
;
1464 table
[MESA_FORMAT_R16
] = unpack_R16
;
1465 table
[MESA_FORMAT_RG1616
] = unpack_RG1616
;
1466 table
[MESA_FORMAT_RG1616_REV
] = unpack_RG1616_REV
;
1467 table
[MESA_FORMAT_ARGB2101010
] = unpack_ARGB2101010
;
1468 table
[MESA_FORMAT_Z24_S8
] = unpack_Z24_S8
;
1469 table
[MESA_FORMAT_S8_Z24
] = unpack_S8_Z24
;
1470 table
[MESA_FORMAT_Z16
] = unpack_Z16
;
1471 table
[MESA_FORMAT_X8_Z24
] = unpack_X8_Z24
;
1472 table
[MESA_FORMAT_Z24_X8
] = unpack_Z24_X8
;
1473 table
[MESA_FORMAT_Z32
] = unpack_Z32
;
1474 table
[MESA_FORMAT_S8
] = unpack_S8
;
1475 table
[MESA_FORMAT_SRGB8
] = unpack_SRGB8
;
1476 table
[MESA_FORMAT_SRGBA8
] = unpack_SRGBA8
;
1477 table
[MESA_FORMAT_SARGB8
] = unpack_SARGB8
;
1478 table
[MESA_FORMAT_SL8
] = unpack_SL8
;
1479 table
[MESA_FORMAT_SLA8
] = unpack_SLA8
;
1480 table
[MESA_FORMAT_SRGB_DXT1
] = unpack_SRGB_DXT1
;
1481 table
[MESA_FORMAT_SRGBA_DXT1
] = unpack_SRGBA_DXT1
;
1482 table
[MESA_FORMAT_SRGBA_DXT3
] = unpack_SRGBA_DXT3
;
1483 table
[MESA_FORMAT_SRGBA_DXT5
] = unpack_SRGBA_DXT5
;
1485 table
[MESA_FORMAT_RGB_FXT1
] = unpack_RGB_FXT1
;
1486 table
[MESA_FORMAT_RGBA_FXT1
] = unpack_RGBA_FXT1
;
1487 table
[MESA_FORMAT_RGB_DXT1
] = unpack_RGB_DXT1
;
1488 table
[MESA_FORMAT_RGBA_DXT1
] = unpack_RGBA_DXT1
;
1489 table
[MESA_FORMAT_RGBA_DXT3
] = unpack_RGBA_DXT3
;
1490 table
[MESA_FORMAT_RGBA_DXT5
] = unpack_RGBA_DXT5
;
1492 table
[MESA_FORMAT_RGBA_FLOAT32
] = unpack_RGBA_FLOAT32
;
1493 table
[MESA_FORMAT_RGBA_FLOAT16
] = unpack_RGBA_FLOAT16
;
1494 table
[MESA_FORMAT_RGB_FLOAT32
] = unpack_RGB_FLOAT32
;
1495 table
[MESA_FORMAT_RGB_FLOAT16
] = unpack_RGB_FLOAT16
;
1496 table
[MESA_FORMAT_ALPHA_FLOAT32
] = unpack_ALPHA_FLOAT32
;
1497 table
[MESA_FORMAT_ALPHA_FLOAT16
] = unpack_ALPHA_FLOAT16
;
1498 table
[MESA_FORMAT_LUMINANCE_FLOAT32
] = unpack_LUMINANCE_FLOAT32
;
1499 table
[MESA_FORMAT_LUMINANCE_FLOAT16
] = unpack_LUMINANCE_FLOAT16
;
1500 table
[MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32
] = unpack_LUMINANCE_ALPHA_FLOAT32
;
1501 table
[MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16
] = unpack_LUMINANCE_ALPHA_FLOAT16
;
1502 table
[MESA_FORMAT_INTENSITY_FLOAT32
] = unpack_INTENSITY_FLOAT32
;
1503 table
[MESA_FORMAT_INTENSITY_FLOAT16
] = unpack_INTENSITY_FLOAT16
;
1504 table
[MESA_FORMAT_R_FLOAT32
] = unpack_R_FLOAT32
;
1505 table
[MESA_FORMAT_R_FLOAT16
] = unpack_R_FLOAT16
;
1506 table
[MESA_FORMAT_RG_FLOAT32
] = unpack_RG_FLOAT32
;
1507 table
[MESA_FORMAT_RG_FLOAT16
] = unpack_RG_FLOAT16
;
1509 table
[MESA_FORMAT_RGBA_INT8
] = unpack_RGBA_INT8
;
1510 table
[MESA_FORMAT_RGBA_INT16
] = unpack_RGBA_INT16
;
1511 table
[MESA_FORMAT_RGBA_INT32
] = unpack_RGBA_INT32
;
1512 table
[MESA_FORMAT_RGBA_UINT8
] = unpack_RGBA_UINT8
;
1513 table
[MESA_FORMAT_RGBA_UINT16
] = unpack_RGBA_UINT16
;
1514 table
[MESA_FORMAT_RGBA_UINT32
] = unpack_RGBA_UINT32
;
1516 table
[MESA_FORMAT_DUDV8
] = unpack_DUDV8
;
1517 table
[MESA_FORMAT_SIGNED_R8
] = unpack_SIGNED_R8
;
1518 table
[MESA_FORMAT_SIGNED_RG88_REV
] = unpack_SIGNED_RG88_REV
;
1519 table
[MESA_FORMAT_SIGNED_RGBX8888
] = unpack_SIGNED_RGBX8888
;
1520 table
[MESA_FORMAT_SIGNED_RGBA8888
] = unpack_SIGNED_RGBA8888
;
1521 table
[MESA_FORMAT_SIGNED_RGBA8888_REV
] = unpack_SIGNED_RGBA8888_REV
;
1522 table
[MESA_FORMAT_SIGNED_R16
] = unpack_SIGNED_R16
;
1523 table
[MESA_FORMAT_SIGNED_GR1616
] = unpack_SIGNED_GR1616
;
1524 table
[MESA_FORMAT_SIGNED_RGB_16
] = unpack_SIGNED_RGB_16
;
1525 table
[MESA_FORMAT_SIGNED_RGBA_16
] = unpack_SIGNED_RGBA_16
;
1526 table
[MESA_FORMAT_RGBA_16
] = unpack_RGBA_16
;
1528 table
[MESA_FORMAT_RED_RGTC1
] = unpack_RED_RGTC1
;
1529 table
[MESA_FORMAT_SIGNED_RED_RGTC1
] = unpack_SIGNED_RED_RGTC1
;
1530 table
[MESA_FORMAT_RG_RGTC2
] = unpack_RG_RGTC2
;
1531 table
[MESA_FORMAT_SIGNED_RG_RGTC2
] = unpack_SIGNED_RG_RGTC2
;
1533 table
[MESA_FORMAT_L_LATC1
] = unpack_L_LATC1
;
1534 table
[MESA_FORMAT_SIGNED_L_LATC1
] = unpack_SIGNED_L_LATC1
;
1535 table
[MESA_FORMAT_LA_LATC2
] = unpack_LA_LATC2
;
1536 table
[MESA_FORMAT_SIGNED_LA_LATC2
] = unpack_SIGNED_LA_LATC2
;
1538 table
[MESA_FORMAT_SIGNED_A8
] = unpack_SIGNED_A8
;
1539 table
[MESA_FORMAT_SIGNED_L8
] = unpack_SIGNED_L8
;
1540 table
[MESA_FORMAT_SIGNED_AL88
] = unpack_SIGNED_AL88
;
1541 table
[MESA_FORMAT_SIGNED_I8
] = unpack_SIGNED_I8
;
1542 table
[MESA_FORMAT_SIGNED_A16
] = unpack_SIGNED_A16
;
1543 table
[MESA_FORMAT_SIGNED_L16
] = unpack_SIGNED_L16
;
1544 table
[MESA_FORMAT_SIGNED_AL1616
] = unpack_SIGNED_AL1616
;
1545 table
[MESA_FORMAT_SIGNED_I16
] = unpack_SIGNED_I16
;
1547 table
[MESA_FORMAT_RGB9_E5_FLOAT
] = unpack_RGB9_E5_FLOAT
;
1548 table
[MESA_FORMAT_R11_G11_B10_FLOAT
] = unpack_R11_G11_B10_FLOAT
;
1550 table
[MESA_FORMAT_Z32_FLOAT
] = unpack_Z32_FLOAT
;
1551 table
[MESA_FORMAT_Z32_FLOAT_X24S8
] = unpack_Z32_FLOAT_X24S8
;
1553 initialized
= GL_TRUE
;
1556 return table
[format
];
1561 _mesa_unpack_rgba_row(gl_format format
, GLuint n
,
1562 const void *src
, GLfloat dst
[][4])
1564 unpack_rgba_func unpack
= get_unpack_rgba_function(format
);
1565 unpack(src
, dst
, n
);
1569 unpack_int_rgba_RGBA_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
1571 memcpy(dst
, src
, n
* 4 * sizeof(GLuint
));
1575 unpack_int_rgba_RGB_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
1579 for (i
= 0; i
< n
; i
++) {
1580 dst
[i
][0] = src
[i
* 3 + 0];
1581 dst
[i
][1] = src
[i
* 3 + 1];
1582 dst
[i
][2] = src
[i
* 3 + 2];
1588 unpack_int_rgba_RG_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
1592 for (i
= 0; i
< n
; i
++) {
1593 dst
[i
][0] = src
[i
* 2 + 0];
1594 dst
[i
][1] = src
[i
* 2 + 1];
1601 unpack_int_rgba_R_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
1605 for (i
= 0; i
< n
; i
++) {
1614 unpack_int_rgba_LUMINANCE_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
1618 for (i
= 0; i
< n
; i
++) {
1619 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
];
1625 unpack_int_rgba_LUMINANCE_ALPHA_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
1629 for (i
= 0; i
< n
; i
++) {
1630 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
* 2 + 0];
1631 dst
[i
][3] = src
[i
* 2 + 1];
1636 unpack_int_rgba_INTENSITY_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
1640 for (i
= 0; i
< n
; i
++) {
1641 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = dst
[i
][3] = src
[i
];
1646 unpack_int_rgba_ARGB2101010_UINT(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
1650 for (i
= 0; i
< n
; i
++) {
1651 GLuint tmp
= src
[i
];
1652 dst
[i
][0] = (tmp
>> 20) & 0x3ff;
1653 dst
[i
][1] = (tmp
>> 10) & 0x3ff;
1654 dst
[i
][2] = (tmp
>> 0) & 0x3ff;
1655 dst
[i
][3] = (tmp
>> 30) & 0x3;
1660 _mesa_unpack_int_rgba_row(gl_format format
, GLuint n
,
1661 const void *src
, GLuint dst
[][4])
1664 /* Since there won't be any sign extension happening, there's no need to
1665 * make separate paths for 32-bit-to-32-bit integer unpack.
1667 case MESA_FORMAT_RGBA_UINT32
:
1668 case MESA_FORMAT_RGBA_INT32
:
1669 unpack_int_rgba_RGBA_UINT32(src
, dst
, n
);
1671 case MESA_FORMAT_RGB_UINT32
:
1672 case MESA_FORMAT_RGB_INT32
:
1673 unpack_int_rgba_RGB_UINT32(src
, dst
, n
);
1675 case MESA_FORMAT_RG_UINT32
:
1676 case MESA_FORMAT_RG_INT32
:
1677 unpack_int_rgba_RG_UINT32(src
, dst
, n
);
1679 case MESA_FORMAT_R_UINT32
:
1680 case MESA_FORMAT_R_INT32
:
1681 unpack_int_rgba_R_UINT32(src
, dst
, n
);
1684 case MESA_FORMAT_LUMINANCE_UINT32
:
1685 case MESA_FORMAT_LUMINANCE_INT32
:
1686 unpack_int_rgba_LUMINANCE_UINT32(src
, dst
, n
);
1688 case MESA_FORMAT_LUMINANCE_ALPHA_UINT32
:
1689 case MESA_FORMAT_LUMINANCE_ALPHA_INT32
:
1690 unpack_int_rgba_LUMINANCE_ALPHA_UINT32(src
, dst
, n
);
1692 case MESA_FORMAT_INTENSITY_UINT32
:
1693 case MESA_FORMAT_INTENSITY_INT32
:
1694 unpack_int_rgba_INTENSITY_UINT32(src
, dst
, n
);
1697 case MESA_FORMAT_ARGB2101010_UINT
:
1698 unpack_int_rgba_ARGB2101010_UINT(src
, dst
, n
);
1701 _mesa_problem(NULL
, "%s: bad format %s", __FUNCTION__
,
1702 _mesa_get_format_name(format
));
1708 * Unpack a 2D rect of pixels returning float RGBA colors.
1709 * \param format the source image format
1710 * \param src start address of the source image
1711 * \param srcRowStride source image row stride in bytes
1712 * \param dst start address of the dest image
1713 * \param dstRowStride dest image row stride in bytes
1714 * \param x source image start X pos
1715 * \param y source image start Y pos
1716 * \param width width of rect region to convert
1717 * \param height height of rect region to convert
1720 _mesa_unpack_rgba_block(gl_format format
,
1721 const void *src
, GLint srcRowStride
,
1722 GLfloat dst
[][4], GLint dstRowStride
,
1723 GLuint x
, GLuint y
, GLuint width
, GLuint height
)
1725 unpack_rgba_func unpack
= get_unpack_rgba_function(format
);
1726 const GLuint srcPixStride
= _mesa_get_format_bytes(format
);
1727 const GLuint dstPixStride
= 4 * sizeof(GLfloat
);
1728 const GLubyte
*srcRow
;
1732 /* XXX needs to be fixed for compressed formats */
1734 srcRow
= ((const GLubyte
*) src
) + srcRowStride
* y
+ srcPixStride
* x
;
1735 dstRow
= ((GLubyte
*) dst
) + dstRowStride
* y
+ dstPixStride
* x
;
1737 for (i
= 0; i
< height
; i
++) {
1738 unpack(srcRow
, (GLfloat (*)[4]) dstRow
, width
);
1740 dstRow
+= dstRowStride
;
1741 srcRow
+= srcRowStride
;
1748 typedef void (*unpack_float_z_func
)(GLuint n
, const void *src
, GLfloat
*dst
);
1751 unpack_float_z_Z24_X8(GLuint n
, const void *src
, GLfloat
*dst
)
1753 /* only return Z, not stencil data */
1754 const GLuint
*s
= ((const GLuint
*) src
);
1755 const GLfloat scale
= 1.0F
/ (GLfloat
) 0xffffff;
1757 for (i
= 0; i
< n
; i
++) {
1758 dst
[i
] = (s
[i
] >> 8) * scale
;
1759 ASSERT(dst
[i
] >= 0.0F
);
1760 ASSERT(dst
[i
] <= 1.0F
);
1765 unpack_float_z_X8_Z24(GLuint n
, const void *src
, GLfloat
*dst
)
1767 /* only return Z, not stencil data */
1768 const GLuint
*s
= ((const GLuint
*) src
);
1769 const GLfloat scale
= 1.0F
/ (GLfloat
) 0xffffff;
1771 for (i
= 0; i
< n
; i
++) {
1772 dst
[i
] = (s
[i
] & 0x00ffffff) * scale
;
1773 ASSERT(dst
[i
] >= 0.0F
);
1774 ASSERT(dst
[i
] <= 1.0F
);
1779 unpack_float_z_Z16(GLuint n
, const void *src
, GLfloat
*dst
)
1781 const GLushort
*s
= ((const GLushort
*) src
);
1783 for (i
= 0; i
< n
; i
++) {
1784 dst
[i
] = s
[i
] * (1.0F
/ 65535.0F
);
1789 unpack_float_z_Z32(GLuint n
, const void *src
, GLfloat
*dst
)
1791 const GLuint
*s
= ((const GLuint
*) src
);
1793 for (i
= 0; i
< n
; i
++) {
1794 dst
[i
] = s
[i
] * (1.0F
/ 0xffffffff);
1799 unpack_float_z_Z32F(GLuint n
, const void *src
, GLfloat
*dst
)
1801 memcpy(dst
, src
, n
* sizeof(float));
1805 unpack_float_z_Z32X24S8(GLuint n
, const void *src
, GLfloat
*dst
)
1807 const GLfloat
*s
= ((const GLfloat
*) src
);
1809 for (i
= 0; i
< n
; i
++) {
1817 _mesa_unpack_float_z_row(gl_format format
, GLuint n
,
1818 const void *src
, GLfloat
*dst
)
1820 unpack_float_z_func unpack
;
1823 case MESA_FORMAT_Z24_S8
:
1824 case MESA_FORMAT_Z24_X8
:
1825 unpack
= unpack_float_z_Z24_X8
;
1827 case MESA_FORMAT_S8_Z24
:
1828 case MESA_FORMAT_X8_Z24
:
1829 unpack
= unpack_float_z_X8_Z24
;
1831 case MESA_FORMAT_Z16
:
1832 unpack
= unpack_float_z_Z16
;
1834 case MESA_FORMAT_Z32
:
1835 unpack
= unpack_float_z_Z32
;
1837 case MESA_FORMAT_Z32_FLOAT
:
1838 unpack
= unpack_float_z_Z32F
;
1840 case MESA_FORMAT_Z32_FLOAT_X24S8
:
1841 unpack
= unpack_float_z_Z32X24S8
;
1844 _mesa_problem(NULL
, "bad format %s in _mesa_unpack_float_z_row",
1845 _mesa_get_format_name(format
));
1849 unpack(n
, src
, dst
);
1854 typedef void (*unpack_uint_z_func
)(const void *src
, GLuint
*dst
, GLuint n
);
1857 unpack_uint_z_Z24_X8(const void *src
, GLuint
*dst
, GLuint n
)
1859 /* only return Z, not stencil data */
1860 const GLuint
*s
= ((const GLuint
*) src
);
1862 for (i
= 0; i
< n
; i
++) {
1863 dst
[i
] = (s
[i
] & 0xffffff00) | (s
[i
] >> 24);
1868 unpack_uint_z_X8_Z24(const void *src
, GLuint
*dst
, GLuint n
)
1870 /* only return Z, not stencil data */
1871 const GLuint
*s
= ((const GLuint
*) src
);
1873 for (i
= 0; i
< n
; i
++) {
1874 dst
[i
] = (s
[i
] << 8) | ((s
[i
] >> 16) & 0xff);
1879 unpack_uint_z_Z16(const void *src
, GLuint
*dst
, GLuint n
)
1881 const GLushort
*s
= ((const GLushort
*)src
);
1883 for (i
= 0; i
< n
; i
++) {
1884 dst
[i
] = (s
[i
] << 16) | s
[i
];
1889 unpack_uint_z_Z32(const void *src
, GLuint
*dst
, GLuint n
)
1891 memcpy(dst
, src
, n
* sizeof(GLuint
));
1896 _mesa_unpack_uint_z_row(gl_format format
, GLuint n
,
1897 const void *src
, GLuint
*dst
)
1899 unpack_uint_z_func unpack
;
1900 const GLubyte
*srcPtr
= (GLubyte
*) src
;
1903 case MESA_FORMAT_Z24_S8
:
1904 case MESA_FORMAT_Z24_X8
:
1905 unpack
= unpack_uint_z_Z24_X8
;
1907 case MESA_FORMAT_S8_Z24
:
1908 case MESA_FORMAT_X8_Z24
:
1909 unpack
= unpack_uint_z_X8_Z24
;
1911 case MESA_FORMAT_Z16
:
1912 unpack
= unpack_uint_z_Z16
;
1914 case MESA_FORMAT_Z32
:
1915 unpack
= unpack_uint_z_Z32
;
1918 _mesa_problem(NULL
, "bad format %s in _mesa_unpack_uint_z_row",
1919 _mesa_get_format_name(format
));
1923 unpack(srcPtr
, dst
, n
);
1928 unpack_ubyte_s_S8(const void *src
, GLubyte
*dst
, GLuint n
)
1930 memcpy(dst
, src
, n
);
1934 unpack_ubyte_s_Z24_S8(const void *src
, GLubyte
*dst
, GLuint n
)
1937 const GLuint
*src32
= src
;
1939 for (i
= 0; i
< n
; i
++)
1940 dst
[i
] = src32
[i
] & 0xff;
1944 unpack_ubyte_s_S8_Z24(const void *src
, GLubyte
*dst
, GLuint n
)
1947 const GLuint
*src32
= src
;
1949 for (i
= 0; i
< n
; i
++)
1950 dst
[i
] = src32
[i
] >> 24;
1954 unpack_ubyte_s_Z32_FLOAT_X24S8(const void *src
, GLubyte
*dst
, GLuint n
)
1957 const GLuint
*src32
= src
;
1959 for (i
= 0; i
< n
; i
++)
1960 dst
[i
] = src32
[i
* 2 + 1] & 0xff;
1964 _mesa_unpack_ubyte_stencil_row(gl_format format
, GLuint n
,
1965 const void *src
, GLubyte
*dst
)
1968 case MESA_FORMAT_S8
:
1969 unpack_ubyte_s_S8(src
, dst
, n
);
1971 case MESA_FORMAT_Z24_S8
:
1972 unpack_ubyte_s_Z24_S8(src
, dst
, n
);
1974 case MESA_FORMAT_S8_Z24
:
1975 unpack_ubyte_s_S8_Z24(src
, dst
, n
);
1977 case MESA_FORMAT_Z32_FLOAT_X24S8
:
1978 unpack_ubyte_s_Z32_FLOAT_X24S8(src
, dst
, n
);
1981 _mesa_problem(NULL
, "bad format %s in _mesa_unpack_ubyte_s_row",
1982 _mesa_get_format_name(format
));
1988 unpack_uint_24_8_depth_stencil_S8_Z24(const GLuint
*src
, GLuint
*dst
, GLuint n
)
1992 for (i
= 0; i
< n
; i
++) {
1993 GLuint val
= src
[i
];
1994 dst
[i
] = val
>> 24 | val
<< 8;
1999 unpack_uint_24_8_depth_stencil_Z24_S8(const GLuint
*src
, GLuint
*dst
, GLuint n
)
2001 memcpy(dst
, src
, n
* 4);
2005 _mesa_unpack_uint_24_8_depth_stencil_row(gl_format format
, GLuint n
,
2006 const void *src
, GLuint
*dst
)
2009 case MESA_FORMAT_Z24_S8
:
2010 unpack_uint_24_8_depth_stencil_Z24_S8(src
, dst
, n
);
2012 case MESA_FORMAT_S8_Z24
:
2013 unpack_uint_24_8_depth_stencil_S8_Z24(src
, dst
, n
);
2017 "bad format %s in _mesa_unpack_uint_24_8_depth_stencil_row",
2018 _mesa_get_format_name(format
));