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 OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
27 #include "format_unpack.h"
29 #include "../../gallium/auxiliary/util/u_format_rgb9e5.h"
30 #include "../../gallium/auxiliary/util/u_format_r11g11b10f.h"
33 /** Helper struct for MESA_FORMAT_Z32_FLOAT_S8X24_UINT */
41 /* Expand 1, 2, 3, 4, 5, 6-bit values to fill 8 bits */
43 #define EXPAND_1_8(X) ( (X) ? 0xff : 0x0 )
45 #define EXPAND_2_8(X) ( ((X) << 6) | ((X) << 4) | ((X) << 2) | (X) )
47 #define EXPAND_3_8(X) ( ((X) << 5) | ((X) << 2) | ((X) >> 1) )
49 #define EXPAND_4_8(X) ( ((X) << 4) | (X) )
51 #define EXPAND_5_8(X) ( ((X) << 3) | ((X) >> 2) )
53 #define EXPAND_6_8(X) ( ((X) << 2) | ((X) >> 4) )
57 * Convert an 8-bit sRGB value from non-linear space to a
58 * linear RGB value in [0, 1].
59 * Implemented with a 256-entry lookup table.
62 _mesa_nonlinear_to_linear(GLubyte cs8
)
64 static GLfloat table
[256];
65 static GLboolean tableReady
= GL_FALSE
;
67 /* compute lookup table now */
69 for (i
= 0; i
< 256; i
++) {
70 const GLfloat cs
= UBYTE_TO_FLOAT(i
);
72 table
[i
] = cs
/ 12.92f
;
75 table
[i
] = (GLfloat
) pow((cs
+ 0.055) / 1.055, 2.4);
84 /**********************************************************************/
85 /* Unpack, returning GLfloat colors */
86 /**********************************************************************/
88 typedef void (*unpack_rgba_func
)(const void *src
, GLfloat dst
[][4], GLuint n
);
92 unpack_RGBA8888(const void *src
, GLfloat dst
[][4], GLuint n
)
94 const GLuint
*s
= ((const GLuint
*) src
);
96 for (i
= 0; i
< n
; i
++) {
97 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 24) );
98 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 16) & 0xff );
99 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 8) & 0xff );
100 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( (s
[i
] ) & 0xff );
105 unpack_RGBA8888_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
107 const GLuint
*s
= ((const GLuint
*) src
);
109 for (i
= 0; i
< n
; i
++) {
110 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( (s
[i
] ) & 0xff );
111 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 8) & 0xff );
112 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 16) & 0xff );
113 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 24) );
118 unpack_ARGB8888(const void *src
, GLfloat dst
[][4], GLuint n
)
120 const GLuint
*s
= ((const GLuint
*) src
);
122 for (i
= 0; i
< n
; i
++) {
123 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 16) & 0xff );
124 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 8) & 0xff );
125 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( (s
[i
] ) & 0xff );
126 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 24) );
131 unpack_ARGB8888_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
133 const GLuint
*s
= ((const GLuint
*) src
);
135 for (i
= 0; i
< n
; i
++) {
136 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 8) & 0xff );
137 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 16) & 0xff );
138 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 24) );
139 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( (s
[i
] ) & 0xff );
144 unpack_RGBX8888(const void *src
, GLfloat dst
[][4], GLuint n
)
146 const GLuint
*s
= ((const GLuint
*) src
);
148 for (i
= 0; i
< n
; i
++) {
149 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 24) );
150 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 16) & 0xff );
151 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 8) & 0xff );
152 dst
[i
][ACOMP
] = 1.0f
;
157 unpack_RGBX8888_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
159 const GLuint
*s
= ((const GLuint
*) src
);
161 for (i
= 0; i
< n
; i
++) {
162 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( (s
[i
] ) & 0xff );
163 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 8) & 0xff );
164 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 16) & 0xff );
165 dst
[i
][ACOMP
] = 1.0f
;
170 unpack_XRGB8888(const void *src
, GLfloat dst
[][4], GLuint n
)
172 const GLuint
*s
= ((const GLuint
*) src
);
174 for (i
= 0; i
< n
; i
++) {
175 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 16) & 0xff );
176 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 8) & 0xff );
177 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( (s
[i
] ) & 0xff );
178 dst
[i
][ACOMP
] = 1.0f
;
183 unpack_XRGB8888_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
185 const GLuint
*s
= ((const GLuint
*) src
);
187 for (i
= 0; i
< n
; i
++) {
188 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 8) & 0xff );
189 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 16) & 0xff );
190 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 24) );
191 dst
[i
][ACOMP
] = 1.0f
;
196 unpack_RGB888(const void *src
, GLfloat dst
[][4], GLuint n
)
198 const GLubyte
*s
= (const GLubyte
*) src
;
200 for (i
= 0; i
< n
; i
++) {
201 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( s
[i
*3+2] );
202 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( s
[i
*3+1] );
203 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( s
[i
*3+0] );
204 dst
[i
][ACOMP
] = 1.0F
;
209 unpack_BGR888(const void *src
, GLfloat dst
[][4], GLuint n
)
211 const GLubyte
*s
= (const GLubyte
*) src
;
213 for (i
= 0; i
< n
; i
++) {
214 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( s
[i
*3+0] );
215 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( s
[i
*3+1] );
216 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( s
[i
*3+2] );
217 dst
[i
][ACOMP
] = 1.0F
;
222 unpack_RGB565(const void *src
, GLfloat dst
[][4], GLuint n
)
224 const GLushort
*s
= ((const GLushort
*) src
);
226 for (i
= 0; i
< n
; i
++) {
227 dst
[i
][RCOMP
] = ((s
[i
] >> 11) & 0x1f) * (1.0F
/ 31.0F
);
228 dst
[i
][GCOMP
] = ((s
[i
] >> 5 ) & 0x3f) * (1.0F
/ 63.0F
);
229 dst
[i
][BCOMP
] = ((s
[i
] ) & 0x1f) * (1.0F
/ 31.0F
);
230 dst
[i
][ACOMP
] = 1.0F
;
235 unpack_RGB565_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
237 /* Warning: this function does not match the current Mesa definition
238 * of MESA_FORMAT_R5G6B5_UNORM.
240 const GLushort
*s
= ((const GLushort
*) src
);
242 for (i
= 0; i
< n
; i
++) {
243 GLuint t
= (s
[i
] >> 8) | (s
[i
] << 8); /* byte swap */
244 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( ((t
>> 8) & 0xf8) | ((t
>> 13) & 0x7) );
245 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( ((t
>> 3) & 0xfc) | ((t
>> 9) & 0x3) );
246 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( ((t
<< 3) & 0xf8) | ((t
>> 2) & 0x7) );
247 dst
[i
][ACOMP
] = 1.0F
;
252 unpack_ARGB4444(const void *src
, GLfloat dst
[][4], GLuint n
)
254 const GLushort
*s
= ((const GLushort
*) src
);
256 for (i
= 0; i
< n
; i
++) {
257 dst
[i
][RCOMP
] = ((s
[i
] >> 8) & 0xf) * (1.0F
/ 15.0F
);
258 dst
[i
][GCOMP
] = ((s
[i
] >> 4) & 0xf) * (1.0F
/ 15.0F
);
259 dst
[i
][BCOMP
] = ((s
[i
] ) & 0xf) * (1.0F
/ 15.0F
);
260 dst
[i
][ACOMP
] = ((s
[i
] >> 12) & 0xf) * (1.0F
/ 15.0F
);
265 unpack_ARGB4444_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
267 const GLushort
*s
= ((const GLushort
*) src
);
269 for (i
= 0; i
< n
; i
++) {
270 dst
[i
][RCOMP
] = ((s
[i
] ) & 0xf) * (1.0F
/ 15.0F
);
271 dst
[i
][GCOMP
] = ((s
[i
] >> 12) & 0xf) * (1.0F
/ 15.0F
);
272 dst
[i
][BCOMP
] = ((s
[i
] >> 8) & 0xf) * (1.0F
/ 15.0F
);
273 dst
[i
][ACOMP
] = ((s
[i
] >> 4) & 0xf) * (1.0F
/ 15.0F
);
278 unpack_RGBA5551(const void *src
, GLfloat dst
[][4], GLuint n
)
280 const GLushort
*s
= ((const GLushort
*) src
);
282 for (i
= 0; i
< n
; i
++) {
283 dst
[i
][RCOMP
] = ((s
[i
] >> 11) & 0x1f) * (1.0F
/ 31.0F
);
284 dst
[i
][GCOMP
] = ((s
[i
] >> 6) & 0x1f) * (1.0F
/ 31.0F
);
285 dst
[i
][BCOMP
] = ((s
[i
] >> 1) & 0x1f) * (1.0F
/ 31.0F
);
286 dst
[i
][ACOMP
] = ((s
[i
] ) & 0x01) * 1.0F
;
291 unpack_ARGB1555(const void *src
, GLfloat dst
[][4], GLuint n
)
293 const GLushort
*s
= ((const GLushort
*) src
);
295 for (i
= 0; i
< n
; i
++) {
296 dst
[i
][RCOMP
] = ((s
[i
] >> 10) & 0x1f) * (1.0F
/ 31.0F
);
297 dst
[i
][GCOMP
] = ((s
[i
] >> 5) & 0x1f) * (1.0F
/ 31.0F
);
298 dst
[i
][BCOMP
] = ((s
[i
] >> 0) & 0x1f) * (1.0F
/ 31.0F
);
299 dst
[i
][ACOMP
] = ((s
[i
] >> 15) & 0x01) * 1.0F
;
304 unpack_ARGB1555_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
306 /* Warning: this function does not match the current Mesa definition
307 * of MESA_FORMAT_A1R5G5B5_UNORM.
309 const GLushort
*s
= ((const GLushort
*) src
);
311 for (i
= 0; i
< n
; i
++) {
312 GLushort tmp
= (s
[i
] << 8) | (s
[i
] >> 8); /* byteswap */
313 dst
[i
][RCOMP
] = ((tmp
>> 10) & 0x1f) * (1.0F
/ 31.0F
);
314 dst
[i
][GCOMP
] = ((tmp
>> 5) & 0x1f) * (1.0F
/ 31.0F
);
315 dst
[i
][BCOMP
] = ((tmp
>> 0) & 0x1f) * (1.0F
/ 31.0F
);
316 dst
[i
][ACOMP
] = ((tmp
>> 15) & 0x01) * 1.0F
;
321 unpack_AL44(const void *src
, GLfloat dst
[][4], GLuint n
)
323 const GLubyte
*s
= ((const GLubyte
*) src
);
325 for (i
= 0; i
< n
; i
++) {
328 dst
[i
][BCOMP
] = (s
[i
] & 0xf) * (1.0F
/ 15.0F
);
329 dst
[i
][ACOMP
] = ((s
[i
] >> 4) & 0xf) * (1.0F
/ 15.0F
);
334 unpack_AL88(const void *src
, GLfloat dst
[][4], GLuint n
)
336 const GLushort
*s
= ((const GLushort
*) src
);
338 for (i
= 0; i
< n
; i
++) {
341 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( s
[i
] & 0xff );
342 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 8 );
347 unpack_AL88_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
349 const GLushort
*s
= ((const GLushort
*) src
);
351 for (i
= 0; i
< n
; i
++) {
354 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 8 );
355 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( s
[i
] & 0xff );
360 unpack_AL1616(const void *src
, GLfloat dst
[][4], GLuint n
)
362 const GLuint
*s
= ((const GLuint
*) src
);
364 for (i
= 0; i
< n
; i
++) {
367 dst
[i
][BCOMP
] = USHORT_TO_FLOAT( s
[i
] & 0xffff );
368 dst
[i
][ACOMP
] = USHORT_TO_FLOAT( s
[i
] >> 16 );
373 unpack_AL1616_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
375 const GLuint
*s
= ((const GLuint
*) src
);
377 for (i
= 0; i
< n
; i
++) {
380 dst
[i
][BCOMP
] = USHORT_TO_FLOAT( s
[i
] >> 16 );
381 dst
[i
][ACOMP
] = USHORT_TO_FLOAT( s
[i
] & 0xffff );
386 unpack_RGB332(const void *src
, GLfloat dst
[][4], GLuint n
)
388 const GLubyte
*s
= ((const GLubyte
*) src
);
390 for (i
= 0; i
< n
; i
++) {
391 dst
[i
][RCOMP
] = ((s
[i
] >> 5) & 0x7) * (1.0F
/ 7.0F
);
392 dst
[i
][GCOMP
] = ((s
[i
] >> 2) & 0x7) * (1.0F
/ 7.0F
);
393 dst
[i
][BCOMP
] = ((s
[i
] ) & 0x3) * (1.0F
/ 3.0F
);
394 dst
[i
][ACOMP
] = 1.0F
;
400 unpack_A8(const void *src
, GLfloat dst
[][4], GLuint n
)
402 const GLubyte
*s
= ((const GLubyte
*) src
);
404 for (i
= 0; i
< n
; i
++) {
407 dst
[i
][BCOMP
] = 0.0F
;
408 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT(s
[i
]);
413 unpack_A16(const void *src
, GLfloat dst
[][4], GLuint n
)
415 const GLushort
*s
= ((const GLushort
*) src
);
417 for (i
= 0; i
< n
; i
++) {
420 dst
[i
][BCOMP
] = 0.0F
;
421 dst
[i
][ACOMP
] = USHORT_TO_FLOAT(s
[i
]);
426 unpack_L8(const void *src
, GLfloat dst
[][4], GLuint n
)
428 const GLubyte
*s
= ((const GLubyte
*) src
);
430 for (i
= 0; i
< n
; i
++) {
433 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT(s
[i
]);
434 dst
[i
][ACOMP
] = 1.0F
;
439 unpack_L16(const void *src
, GLfloat dst
[][4], GLuint n
)
441 const GLushort
*s
= ((const GLushort
*) src
);
443 for (i
= 0; i
< n
; i
++) {
446 dst
[i
][BCOMP
] = USHORT_TO_FLOAT(s
[i
]);
447 dst
[i
][ACOMP
] = 1.0F
;
452 unpack_I8(const void *src
, GLfloat dst
[][4], GLuint n
)
454 const GLubyte
*s
= ((const GLubyte
*) src
);
456 for (i
= 0; i
< n
; i
++) {
460 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT(s
[i
]);
465 unpack_I16(const void *src
, GLfloat dst
[][4], GLuint n
)
467 const GLushort
*s
= ((const GLushort
*) src
);
469 for (i
= 0; i
< n
; i
++) {
473 dst
[i
][ACOMP
] = USHORT_TO_FLOAT(s
[i
]);
478 unpack_YCBCR(const void *src
, GLfloat dst
[][4], GLuint n
)
481 for (i
= 0; i
< n
; i
++) {
482 const GLushort
*src0
= ((const GLushort
*) src
) + i
* 2; /* even */
483 const GLushort
*src1
= src0
+ 1; /* odd */
484 const GLubyte y0
= (*src0
>> 8) & 0xff; /* luminance */
485 const GLubyte cb
= *src0
& 0xff; /* chroma U */
486 const GLubyte y1
= (*src1
>> 8) & 0xff; /* luminance */
487 const GLubyte cr
= *src1
& 0xff; /* chroma V */
488 const GLubyte y
= (i
& 1) ? y1
: y0
; /* choose even/odd luminance */
489 GLfloat r
= 1.164F
* (y
- 16) + 1.596F
* (cr
- 128);
490 GLfloat g
= 1.164F
* (y
- 16) - 0.813F
* (cr
- 128) - 0.391F
* (cb
- 128);
491 GLfloat b
= 1.164F
* (y
- 16) + 2.018F
* (cb
- 128);
492 r
*= (1.0F
/ 255.0F
);
493 g
*= (1.0F
/ 255.0F
);
494 b
*= (1.0F
/ 255.0F
);
495 dst
[i
][RCOMP
] = CLAMP(r
, 0.0F
, 1.0F
);
496 dst
[i
][GCOMP
] = CLAMP(g
, 0.0F
, 1.0F
);
497 dst
[i
][BCOMP
] = CLAMP(b
, 0.0F
, 1.0F
);
498 dst
[i
][ACOMP
] = 1.0F
;
503 unpack_YCBCR_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
506 for (i
= 0; i
< n
; i
++) {
507 const GLushort
*src0
= ((const GLushort
*) src
) + i
* 2; /* even */
508 const GLushort
*src1
= src0
+ 1; /* odd */
509 const GLubyte y0
= *src0
& 0xff; /* luminance */
510 const GLubyte cr
= (*src0
>> 8) & 0xff; /* chroma V */
511 const GLubyte y1
= *src1
& 0xff; /* luminance */
512 const GLubyte cb
= (*src1
>> 8) & 0xff; /* chroma U */
513 const GLubyte y
= (i
& 1) ? y1
: y0
; /* choose even/odd luminance */
514 GLfloat r
= 1.164F
* (y
- 16) + 1.596F
* (cr
- 128);
515 GLfloat g
= 1.164F
* (y
- 16) - 0.813F
* (cr
- 128) - 0.391F
* (cb
- 128);
516 GLfloat b
= 1.164F
* (y
- 16) + 2.018F
* (cb
- 128);
517 r
*= (1.0F
/ 255.0F
);
518 g
*= (1.0F
/ 255.0F
);
519 b
*= (1.0F
/ 255.0F
);
520 dst
[i
][RCOMP
] = CLAMP(r
, 0.0F
, 1.0F
);
521 dst
[i
][GCOMP
] = CLAMP(g
, 0.0F
, 1.0F
);
522 dst
[i
][BCOMP
] = CLAMP(b
, 0.0F
, 1.0F
);
523 dst
[i
][ACOMP
] = 1.0F
;
528 unpack_R8(const void *src
, GLfloat dst
[][4], GLuint n
)
530 const GLubyte
*s
= ((const GLubyte
*) src
);
532 for (i
= 0; i
< n
; i
++) {
533 dst
[i
][0] = UBYTE_TO_FLOAT(s
[i
]);
541 unpack_GR88(const void *src
, GLfloat dst
[][4], GLuint n
)
543 const GLushort
*s
= ((const GLushort
*) src
);
545 for (i
= 0; i
< n
; i
++) {
546 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( s
[i
] & 0xff );
547 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 8 );
554 unpack_RG88(const void *src
, GLfloat dst
[][4], GLuint n
)
556 const GLushort
*s
= ((const GLushort
*) src
);
558 for (i
= 0; i
< n
; i
++) {
559 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 8 );
560 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( s
[i
] & 0xff );
567 unpack_R16(const void *src
, GLfloat dst
[][4], GLuint n
)
569 const GLushort
*s
= ((const GLushort
*) src
);
571 for (i
= 0; i
< n
; i
++) {
572 dst
[i
][RCOMP
] = USHORT_TO_FLOAT(s
[i
]);
580 unpack_GR1616(const void *src
, GLfloat dst
[][4], GLuint n
)
582 const GLuint
*s
= ((const GLuint
*) src
);
584 for (i
= 0; i
< n
; i
++) {
585 dst
[i
][RCOMP
] = USHORT_TO_FLOAT( s
[i
] & 0xffff );
586 dst
[i
][GCOMP
] = USHORT_TO_FLOAT( s
[i
] >> 16 );
593 unpack_RG1616(const void *src
, GLfloat dst
[][4], GLuint n
)
595 const GLuint
*s
= ((const GLuint
*) src
);
597 for (i
= 0; i
< n
; i
++) {
598 dst
[i
][RCOMP
] = USHORT_TO_FLOAT( s
[i
] >> 16 );
599 dst
[i
][GCOMP
] = USHORT_TO_FLOAT( s
[i
] & 0xffff );
606 unpack_ARGB2101010(const void *src
, GLfloat dst
[][4], GLuint n
)
608 const GLuint
*s
= ((const GLuint
*) src
);
610 for (i
= 0; i
< n
; i
++) {
611 dst
[i
][RCOMP
] = ((s
[i
] >> 20) & 0x3ff) * (1.0F
/ 1023.0F
);
612 dst
[i
][GCOMP
] = ((s
[i
] >> 10) & 0x3ff) * (1.0F
/ 1023.0F
);
613 dst
[i
][BCOMP
] = ((s
[i
] >> 0) & 0x3ff) * (1.0F
/ 1023.0F
);
614 dst
[i
][ACOMP
] = ((s
[i
] >> 30) & 0x03) * (1.0F
/ 3.0F
);
620 unpack_ARGB2101010_UINT(const void *src
, GLfloat dst
[][4], GLuint n
)
622 const GLuint
*s
= (const GLuint
*) src
;
624 for (i
= 0; i
< n
; i
++) {
625 dst
[i
][RCOMP
] = (GLfloat
)((s
[i
] >> 20) & 0x3ff);
626 dst
[i
][GCOMP
] = (GLfloat
)((s
[i
] >> 10) & 0x3ff);
627 dst
[i
][BCOMP
] = (GLfloat
)((s
[i
] >> 0) & 0x3ff);
628 dst
[i
][ACOMP
] = (GLfloat
)((s
[i
] >> 30) & 0x03);
634 unpack_ABGR2101010_UINT(const void *src
, GLfloat dst
[][4], GLuint n
)
636 const GLuint
*s
= ((const GLuint
*) src
);
638 for (i
= 0; i
< n
; i
++) {
639 dst
[i
][RCOMP
] = (GLfloat
)((s
[i
] >> 0) & 0x3ff);
640 dst
[i
][GCOMP
] = (GLfloat
)((s
[i
] >> 10) & 0x3ff);
641 dst
[i
][BCOMP
] = (GLfloat
)((s
[i
] >> 20) & 0x3ff);
642 dst
[i
][ACOMP
] = (GLfloat
)((s
[i
] >> 30) & 0x03);
648 unpack_Z24_S8(const void *src
, GLfloat dst
[][4], GLuint n
)
650 /* only return Z, not stencil data */
651 const GLuint
*s
= ((const GLuint
*) src
);
652 const GLdouble scale
= 1.0 / (GLdouble
) 0xffffff;
654 for (i
= 0; i
< n
; i
++) {
657 dst
[i
][2] = (GLfloat
) ((s
[i
] >> 8) * scale
);
659 ASSERT(dst
[i
][0] >= 0.0F
);
660 ASSERT(dst
[i
][0] <= 1.0F
);
665 unpack_S8_Z24(const void *src
, GLfloat dst
[][4], GLuint n
)
667 /* only return Z, not stencil data */
668 const GLuint
*s
= ((const GLuint
*) src
);
669 const GLdouble scale
= 1.0 / (GLdouble
) 0xffffff;
671 for (i
= 0; i
< n
; i
++) {
674 dst
[i
][2] = (float) ((s
[i
] & 0x00ffffff) * scale
);
676 ASSERT(dst
[i
][0] >= 0.0F
);
677 ASSERT(dst
[i
][0] <= 1.0F
);
682 unpack_Z16(const void *src
, GLfloat dst
[][4], GLuint n
)
684 const GLushort
*s
= ((const GLushort
*) src
);
686 for (i
= 0; i
< n
; i
++) {
689 dst
[i
][2] = s
[i
] * (1.0F
/ 65535.0F
);
695 unpack_X8_Z24(const void *src
, GLfloat dst
[][4], GLuint n
)
697 unpack_S8_Z24(src
, dst
, n
);
701 unpack_Z24_X8(const void *src
, GLfloat dst
[][4], GLuint n
)
703 unpack_Z24_S8(src
, dst
, n
);
707 unpack_Z32(const void *src
, GLfloat dst
[][4], GLuint n
)
709 const GLuint
*s
= ((const GLuint
*) src
);
711 for (i
= 0; i
< n
; i
++) {
714 dst
[i
][2] = s
[i
] * (1.0F
/ 0xffffffff);
720 unpack_Z32_FLOAT(const void *src
, GLfloat dst
[][4], GLuint n
)
722 const GLfloat
*s
= ((const GLfloat
*) src
);
724 for (i
= 0; i
< n
; i
++) {
727 dst
[i
][2] = s
[i
* 2];
733 unpack_Z32_FLOAT_X24S8(const void *src
, GLfloat dst
[][4], GLuint n
)
735 const GLfloat
*s
= ((const GLfloat
*) src
);
737 for (i
= 0; i
< n
; i
++) {
747 unpack_S8(const void *src
, GLfloat dst
[][4], GLuint n
)
749 /* should never be used */
751 for (i
= 0; i
< n
; i
++) {
761 unpack_SRGB8(const void *src
, GLfloat dst
[][4], GLuint n
)
763 const GLubyte
*s
= (const GLubyte
*) src
;
765 for (i
= 0; i
< n
; i
++) {
766 dst
[i
][RCOMP
] = _mesa_nonlinear_to_linear(s
[i
*3+2]);
767 dst
[i
][GCOMP
] = _mesa_nonlinear_to_linear(s
[i
*3+1]);
768 dst
[i
][BCOMP
] = _mesa_nonlinear_to_linear(s
[i
*3+0]);
769 dst
[i
][ACOMP
] = 1.0F
;
774 unpack_SRGBA8(const void *src
, GLfloat dst
[][4], GLuint n
)
776 const GLuint
*s
= ((const GLuint
*) src
);
778 for (i
= 0; i
< n
; i
++) {
779 dst
[i
][RCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] >> 24) );
780 dst
[i
][GCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] >> 16) & 0xff );
781 dst
[i
][BCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] >> 8) & 0xff );
782 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( s
[i
] & 0xff ); /* linear! */
787 unpack_SARGB8(const void *src
, GLfloat dst
[][4], GLuint n
)
789 const GLuint
*s
= ((const GLuint
*) src
);
791 for (i
= 0; i
< n
; i
++) {
792 dst
[i
][RCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] >> 16) & 0xff );
793 dst
[i
][GCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] >> 8) & 0xff );
794 dst
[i
][BCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] ) & 0xff );
795 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 24 ); /* linear! */
800 unpack_SL8(const void *src
, GLfloat dst
[][4], GLuint n
)
802 const GLubyte
*s
= ((const GLubyte
*) src
);
804 for (i
= 0; i
< n
; i
++) {
807 dst
[i
][BCOMP
] = _mesa_nonlinear_to_linear(s
[i
]);
808 dst
[i
][ACOMP
] = 1.0F
;
813 unpack_SLA8(const void *src
, GLfloat dst
[][4], GLuint n
)
815 const GLushort
*s
= (const GLushort
*) src
;
817 for (i
= 0; i
< n
; i
++) {
820 dst
[i
][BCOMP
] = _mesa_nonlinear_to_linear(s
[i
] & 0xff);
821 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT(s
[i
] >> 8); /* linear! */
826 unpack_SRGB_DXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
831 unpack_SRGBA_DXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
836 unpack_SRGBA_DXT3(const void *src
, GLfloat dst
[][4], GLuint n
)
841 unpack_SRGBA_DXT5(const void *src
, GLfloat dst
[][4], GLuint n
)
846 unpack_RGB_FXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
851 unpack_RGBA_FXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
856 unpack_RGB_DXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
861 unpack_RGBA_DXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
866 unpack_RGBA_DXT3(const void *src
, GLfloat dst
[][4], GLuint n
)
871 unpack_RGBA_DXT5(const void *src
, GLfloat dst
[][4], GLuint n
)
877 unpack_RGBA_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
879 const GLfloat
*s
= (const GLfloat
*) src
;
881 for (i
= 0; i
< n
; i
++) {
882 dst
[i
][RCOMP
] = s
[i
*4+0];
883 dst
[i
][GCOMP
] = s
[i
*4+1];
884 dst
[i
][BCOMP
] = s
[i
*4+2];
885 dst
[i
][ACOMP
] = s
[i
*4+3];
890 unpack_RGBA_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
892 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
894 for (i
= 0; i
< n
; i
++) {
895 dst
[i
][RCOMP
] = _mesa_half_to_float(s
[i
*4+0]);
896 dst
[i
][GCOMP
] = _mesa_half_to_float(s
[i
*4+1]);
897 dst
[i
][BCOMP
] = _mesa_half_to_float(s
[i
*4+2]);
898 dst
[i
][ACOMP
] = _mesa_half_to_float(s
[i
*4+3]);
903 unpack_RGB_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
905 const GLfloat
*s
= (const GLfloat
*) src
;
907 for (i
= 0; i
< n
; i
++) {
908 dst
[i
][RCOMP
] = s
[i
*3+0];
909 dst
[i
][GCOMP
] = s
[i
*3+1];
910 dst
[i
][BCOMP
] = s
[i
*3+2];
911 dst
[i
][ACOMP
] = 1.0F
;
916 unpack_RGB_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
918 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
920 for (i
= 0; i
< n
; i
++) {
921 dst
[i
][RCOMP
] = _mesa_half_to_float(s
[i
*3+0]);
922 dst
[i
][GCOMP
] = _mesa_half_to_float(s
[i
*3+1]);
923 dst
[i
][BCOMP
] = _mesa_half_to_float(s
[i
*3+2]);
924 dst
[i
][ACOMP
] = 1.0F
;
929 unpack_ALPHA_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
931 const GLfloat
*s
= (const GLfloat
*) src
;
933 for (i
= 0; i
< n
; i
++) {
936 dst
[i
][BCOMP
] = 0.0F
;
937 dst
[i
][ACOMP
] = s
[i
];
942 unpack_ALPHA_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
944 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
946 for (i
= 0; i
< n
; i
++) {
949 dst
[i
][BCOMP
] = 0.0F
;
950 dst
[i
][ACOMP
] = _mesa_half_to_float(s
[i
]);
955 unpack_LUMINANCE_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
957 const GLfloat
*s
= (const GLfloat
*) src
;
959 for (i
= 0; i
< n
; i
++) {
962 dst
[i
][BCOMP
] = s
[i
];
963 dst
[i
][ACOMP
] = 1.0F
;
968 unpack_LUMINANCE_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
970 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
972 for (i
= 0; i
< n
; i
++) {
975 dst
[i
][BCOMP
] = _mesa_half_to_float(s
[i
]);
976 dst
[i
][ACOMP
] = 1.0F
;
981 unpack_LUMINANCE_ALPHA_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
983 const GLfloat
*s
= (const GLfloat
*) src
;
985 for (i
= 0; i
< n
; i
++) {
988 dst
[i
][BCOMP
] = s
[i
*2+0];
989 dst
[i
][ACOMP
] = s
[i
*2+1];
994 unpack_LUMINANCE_ALPHA_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
996 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
998 for (i
= 0; i
< n
; i
++) {
1001 dst
[i
][BCOMP
] = _mesa_half_to_float(s
[i
*2+0]);
1002 dst
[i
][ACOMP
] = _mesa_half_to_float(s
[i
*2+1]);
1007 unpack_INTENSITY_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1009 const GLfloat
*s
= (const GLfloat
*) src
;
1011 for (i
= 0; i
< n
; i
++) {
1015 dst
[i
][ACOMP
] = s
[i
];
1020 unpack_INTENSITY_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1022 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
1024 for (i
= 0; i
< n
; i
++) {
1028 dst
[i
][ACOMP
] = _mesa_half_to_float(s
[i
]);
1033 unpack_R_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1035 const GLfloat
*s
= (const GLfloat
*) src
;
1037 for (i
= 0; i
< n
; i
++) {
1038 dst
[i
][RCOMP
] = s
[i
];
1039 dst
[i
][GCOMP
] = 0.0F
;
1040 dst
[i
][BCOMP
] = 0.0F
;
1041 dst
[i
][ACOMP
] = 1.0F
;
1046 unpack_R_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1048 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
1050 for (i
= 0; i
< n
; i
++) {
1051 dst
[i
][RCOMP
] = _mesa_half_to_float(s
[i
]);
1052 dst
[i
][GCOMP
] = 0.0F
;
1053 dst
[i
][BCOMP
] = 0.0F
;
1054 dst
[i
][ACOMP
] = 1.0F
;
1059 unpack_RG_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1061 const GLfloat
*s
= (const GLfloat
*) src
;
1063 for (i
= 0; i
< n
; i
++) {
1064 dst
[i
][RCOMP
] = s
[i
*2+0];
1065 dst
[i
][GCOMP
] = s
[i
*2+1];
1066 dst
[i
][BCOMP
] = 0.0F
;
1067 dst
[i
][ACOMP
] = 1.0F
;
1072 unpack_RG_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1074 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
1076 for (i
= 0; i
< n
; i
++) {
1077 dst
[i
][RCOMP
] = _mesa_half_to_float(s
[i
*2+0]);
1078 dst
[i
][GCOMP
] = _mesa_half_to_float(s
[i
*2+1]);
1079 dst
[i
][BCOMP
] = 0.0F
;
1080 dst
[i
][ACOMP
] = 1.0F
;
1085 unpack_ALPHA_UINT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1087 const GLubyte
*s
= (const GLubyte
*) src
;
1089 for (i
= 0; i
< n
; i
++) {
1092 dst
[i
][BCOMP
] = 0.0;
1093 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1098 unpack_ALPHA_UINT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1100 const GLushort
*s
= (const GLushort
*) src
;
1102 for (i
= 0; i
< n
; i
++) {
1105 dst
[i
][BCOMP
] = 0.0;
1106 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1111 unpack_ALPHA_UINT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1113 const GLuint
*s
= (const GLuint
*) src
;
1115 for (i
= 0; i
< n
; i
++) {
1118 dst
[i
][BCOMP
] = 0.0;
1119 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1124 unpack_ALPHA_INT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1126 const GLbyte
*s
= (const GLbyte
*) src
;
1128 for (i
= 0; i
< n
; i
++) {
1131 dst
[i
][BCOMP
] = 0.0;
1132 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1137 unpack_ALPHA_INT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1139 const GLshort
*s
= (const GLshort
*) src
;
1141 for (i
= 0; i
< n
; i
++) {
1144 dst
[i
][BCOMP
] = 0.0;
1145 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1150 unpack_ALPHA_INT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1152 const GLint
*s
= (const GLint
*) src
;
1154 for (i
= 0; i
< n
; i
++) {
1157 dst
[i
][BCOMP
] = 0.0;
1158 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1163 unpack_INTENSITY_UINT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1165 const GLubyte
*s
= (const GLubyte
*) src
;
1167 for (i
= 0; i
< n
; i
++) {
1171 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1176 unpack_INTENSITY_UINT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1178 const GLushort
*s
= (const GLushort
*) src
;
1180 for (i
= 0; i
< n
; i
++) {
1184 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1189 unpack_INTENSITY_UINT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1191 const GLuint
*s
= (const GLuint
*) src
;
1193 for (i
= 0; i
< n
; i
++) {
1197 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1202 unpack_INTENSITY_INT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1204 const GLbyte
*s
= (const GLbyte
*) src
;
1206 for (i
= 0; i
< n
; i
++) {
1210 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1215 unpack_INTENSITY_INT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1217 const GLshort
*s
= (const GLshort
*) src
;
1219 for (i
= 0; i
< n
; i
++) {
1223 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1228 unpack_INTENSITY_INT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1230 const GLint
*s
= (const GLint
*) src
;
1232 for (i
= 0; i
< n
; i
++) {
1236 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1241 unpack_LUMINANCE_UINT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1243 const GLubyte
*s
= (const GLubyte
*) src
;
1245 for (i
= 0; i
< n
; i
++) {
1246 dst
[i
][RCOMP
] = dst
[i
][GCOMP
] = dst
[i
][BCOMP
] = (GLfloat
) s
[i
];
1247 dst
[i
][ACOMP
] = 1.0;
1252 unpack_LUMINANCE_UINT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1254 const GLushort
*s
= (const GLushort
*) src
;
1256 for (i
= 0; i
< n
; i
++) {
1257 dst
[i
][RCOMP
] = dst
[i
][GCOMP
] = dst
[i
][BCOMP
] = (GLfloat
) s
[i
];
1258 dst
[i
][ACOMP
] = 1.0;
1263 unpack_LUMINANCE_UINT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1265 const GLuint
*s
= (const GLuint
*) src
;
1267 for (i
= 0; i
< n
; i
++) {
1268 dst
[i
][RCOMP
] = dst
[i
][GCOMP
] = dst
[i
][BCOMP
] = (GLfloat
) s
[i
];
1269 dst
[i
][ACOMP
] = 1.0;
1274 unpack_LUMINANCE_INT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1276 const GLbyte
*s
= (const GLbyte
*) src
;
1278 for (i
= 0; i
< n
; i
++) {
1279 dst
[i
][RCOMP
] = dst
[i
][GCOMP
] = dst
[i
][BCOMP
] = (GLfloat
) s
[i
];
1280 dst
[i
][ACOMP
] = 1.0;
1285 unpack_LUMINANCE_INT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1287 const GLshort
*s
= (const GLshort
*) src
;
1289 for (i
= 0; i
< n
; i
++) {
1290 dst
[i
][RCOMP
] = dst
[i
][GCOMP
] = dst
[i
][BCOMP
] = (GLfloat
) s
[i
];
1291 dst
[i
][ACOMP
] = 1.0;
1296 unpack_LUMINANCE_INT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1298 const GLint
*s
= (const GLint
*) src
;
1300 for (i
= 0; i
< n
; i
++) {
1301 dst
[i
][RCOMP
] = dst
[i
][GCOMP
] = dst
[i
][BCOMP
] = (GLfloat
) s
[i
];
1302 dst
[i
][ACOMP
] = 1.0;
1307 unpack_LUMINANCE_ALPHA_UINT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1309 const GLubyte
*s
= (const GLubyte
*) src
;
1311 for (i
= 0; i
< n
; i
++) {
1314 dst
[i
][BCOMP
] = (GLfloat
) s
[2*i
+0];
1315 dst
[i
][ACOMP
] = (GLfloat
) s
[2*i
+1];
1320 unpack_LUMINANCE_ALPHA_UINT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1322 const GLushort
*s
= (const GLushort
*) src
;
1324 for (i
= 0; i
< n
; i
++) {
1327 dst
[i
][BCOMP
] = (GLfloat
) s
[2*i
+0];
1328 dst
[i
][ACOMP
] = (GLfloat
) s
[2*i
+1];
1333 unpack_LUMINANCE_ALPHA_UINT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1335 const GLuint
*s
= (const GLuint
*) src
;
1337 for (i
= 0; i
< n
; i
++) {
1340 dst
[i
][BCOMP
] = (GLfloat
) s
[2*i
+0];
1341 dst
[i
][ACOMP
] = (GLfloat
) s
[2*i
+1];
1346 unpack_LUMINANCE_ALPHA_INT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1348 const GLbyte
*s
= (const GLbyte
*) src
;
1350 for (i
= 0; i
< n
; i
++) {
1353 dst
[i
][BCOMP
] = (GLfloat
) s
[2*i
+0];
1354 dst
[i
][ACOMP
] = (GLfloat
) s
[2*i
+1];
1359 unpack_LUMINANCE_ALPHA_INT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1361 const GLshort
*s
= (const GLshort
*) src
;
1363 for (i
= 0; i
< n
; i
++) {
1366 dst
[i
][BCOMP
] = (GLfloat
) s
[2*i
+0];
1367 dst
[i
][ACOMP
] = (GLfloat
) s
[2*i
+1];
1372 unpack_LUMINANCE_ALPHA_INT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1374 const GLint
*s
= (const GLint
*) src
;
1376 for (i
= 0; i
< n
; i
++) {
1379 dst
[i
][BCOMP
] = (GLfloat
) s
[2*i
+0];
1380 dst
[i
][ACOMP
] = (GLfloat
) s
[2*i
+1];
1385 unpack_R_INT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1387 const GLbyte
*s
= (const GLbyte
*) src
;
1389 for (i
= 0; i
< n
; i
++) {
1390 dst
[i
][RCOMP
] = (GLfloat
) s
[i
];
1391 dst
[i
][GCOMP
] = 0.0;
1392 dst
[i
][BCOMP
] = 0.0;
1393 dst
[i
][ACOMP
] = 1.0;
1398 unpack_RG_INT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1400 const GLbyte
*s
= (const GLbyte
*) src
;
1402 for (i
= 0; i
< n
; i
++) {
1403 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*2+0];
1404 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*2+1];
1405 dst
[i
][BCOMP
] = 0.0;
1406 dst
[i
][ACOMP
] = 1.0;
1411 unpack_RGB_INT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1413 const GLbyte
*s
= (const GLbyte
*) src
;
1415 for (i
= 0; i
< n
; i
++) {
1416 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*3+0];
1417 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*3+1];
1418 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*3+2];
1419 dst
[i
][ACOMP
] = 1.0;
1424 unpack_RGBA_INT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1426 const GLbyte
*s
= (const GLbyte
*) src
;
1428 for (i
= 0; i
< n
; i
++) {
1429 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1430 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1431 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1432 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1437 unpack_R_INT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1439 const GLshort
*s
= (const GLshort
*) src
;
1441 for (i
= 0; i
< n
; i
++) {
1442 dst
[i
][RCOMP
] = (GLfloat
) s
[i
];
1443 dst
[i
][GCOMP
] = 0.0;
1444 dst
[i
][BCOMP
] = 0.0;
1445 dst
[i
][ACOMP
] = 1.0;
1450 unpack_RG_INT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1452 const GLshort
*s
= (const GLshort
*) src
;
1454 for (i
= 0; i
< n
; i
++) {
1455 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*2+0];
1456 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*2+1];
1457 dst
[i
][BCOMP
] = 0.0;
1458 dst
[i
][ACOMP
] = 1.0;
1463 unpack_RGB_INT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1465 const GLshort
*s
= (const GLshort
*) src
;
1467 for (i
= 0; i
< n
; i
++) {
1468 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*3+0];
1469 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*3+1];
1470 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*3+2];
1471 dst
[i
][ACOMP
] = 1.0;
1476 unpack_RGBA_INT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1478 const GLshort
*s
= (const GLshort
*) src
;
1480 for (i
= 0; i
< n
; i
++) {
1481 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1482 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1483 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1484 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1489 unpack_R_INT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1491 const GLint
*s
= (const GLint
*) src
;
1493 for (i
= 0; i
< n
; i
++) {
1494 dst
[i
][RCOMP
] = (GLfloat
) s
[i
];
1495 dst
[i
][GCOMP
] = 0.0;
1496 dst
[i
][BCOMP
] = 0.0;
1497 dst
[i
][ACOMP
] = 1.0;
1502 unpack_RG_INT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1504 const GLint
*s
= (const GLint
*) src
;
1506 for (i
= 0; i
< n
; i
++) {
1507 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*2+0];
1508 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*2+1];
1509 dst
[i
][BCOMP
] = 0.0;
1510 dst
[i
][ACOMP
] = 1.0;
1515 unpack_RGB_INT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1517 const GLint
*s
= (const GLint
*) src
;
1519 for (i
= 0; i
< n
; i
++) {
1520 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*3+0];
1521 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*3+1];
1522 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*3+2];
1523 dst
[i
][ACOMP
] = 1.0;
1529 unpack_RGBA_INT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1531 const GLint
*s
= (const GLint
*) src
;
1533 for (i
= 0; i
< n
; i
++) {
1534 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1535 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1536 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1537 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1542 unpack_R_UINT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1544 const GLubyte
*s
= (const GLubyte
*) src
;
1546 for (i
= 0; i
< n
; i
++) {
1547 dst
[i
][RCOMP
] = (GLfloat
) s
[i
];
1548 dst
[i
][GCOMP
] = 0.0;
1549 dst
[i
][BCOMP
] = 0.0;
1550 dst
[i
][ACOMP
] = 1.0;
1555 unpack_RG_UINT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1557 const GLubyte
*s
= (const GLubyte
*) src
;
1559 for (i
= 0; i
< n
; i
++) {
1560 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*2+0];
1561 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*2+1];
1562 dst
[i
][BCOMP
] = 0.0;
1563 dst
[i
][ACOMP
] = 1.0;
1568 unpack_RGB_UINT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1570 const GLubyte
*s
= (const GLubyte
*) src
;
1572 for (i
= 0; i
< n
; i
++) {
1573 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*3+0];
1574 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*3+1];
1575 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*3+2];
1576 dst
[i
][ACOMP
] = 1.0;
1581 unpack_RGBA_UINT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1583 const GLubyte
*s
= (const GLubyte
*) src
;
1585 for (i
= 0; i
< n
; i
++) {
1586 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1587 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1588 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1589 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1594 unpack_R_UINT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1596 const GLushort
*s
= (const GLushort
*) src
;
1598 for (i
= 0; i
< n
; i
++) {
1599 dst
[i
][RCOMP
] = (GLfloat
) s
[i
];
1600 dst
[i
][GCOMP
] = 0.0;
1601 dst
[i
][BCOMP
] = 0.0;
1602 dst
[i
][ACOMP
] = 1.0;
1607 unpack_RG_UINT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1609 const GLushort
*s
= (const GLushort
*) src
;
1611 for (i
= 0; i
< n
; i
++) {
1612 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*2+0];
1613 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*2+1];
1614 dst
[i
][BCOMP
] = 0.0;
1615 dst
[i
][ACOMP
] = 1.0;
1620 unpack_RGB_UINT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1622 const GLushort
*s
= (const GLushort
*) src
;
1624 for (i
= 0; i
< n
; i
++) {
1625 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*3+0];
1626 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*3+1];
1627 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*3+2];
1628 dst
[i
][ACOMP
] = 1.0;
1633 unpack_RGBA_UINT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1635 const GLushort
*s
= (const GLushort
*) src
;
1637 for (i
= 0; i
< n
; i
++) {
1638 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1639 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1640 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1641 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1646 unpack_R_UINT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1648 const GLuint
*s
= (const GLuint
*) src
;
1650 for (i
= 0; i
< n
; i
++) {
1651 dst
[i
][RCOMP
] = (GLfloat
) s
[i
];
1652 dst
[i
][GCOMP
] = 0.0;
1653 dst
[i
][BCOMP
] = 0.0;
1654 dst
[i
][ACOMP
] = 1.0;
1659 unpack_RG_UINT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1661 const GLuint
*s
= (const GLuint
*) src
;
1663 for (i
= 0; i
< n
; i
++) {
1664 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*2+0];
1665 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*2+1];
1666 dst
[i
][BCOMP
] = 0.0;
1667 dst
[i
][ACOMP
] = 1.0;
1672 unpack_RGB_UINT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1674 const GLuint
*s
= (const GLuint
*) src
;
1676 for (i
= 0; i
< n
; i
++) {
1677 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*3+0];
1678 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*3+1];
1679 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*3+2];
1680 dst
[i
][ACOMP
] = 1.0;
1685 unpack_RGBA_UINT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1687 const GLuint
*s
= (const GLuint
*) src
;
1689 for (i
= 0; i
< n
; i
++) {
1690 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1691 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1692 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1693 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1698 unpack_DUDV8(const void *src
, GLfloat dst
[][4], GLuint n
)
1700 const GLbyte
*s
= (const GLbyte
*) src
;
1702 for (i
= 0; i
< n
; i
++) {
1703 dst
[i
][RCOMP
] = BYTE_TO_FLOAT(s
[i
*2+0]);
1704 dst
[i
][GCOMP
] = BYTE_TO_FLOAT(s
[i
*2+1]);
1711 unpack_SIGNED_R8(const void *src
, GLfloat dst
[][4], GLuint n
)
1713 const GLbyte
*s
= ((const GLbyte
*) src
);
1715 for (i
= 0; i
< n
; i
++) {
1716 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( s
[i
] );
1717 dst
[i
][GCOMP
] = 0.0F
;
1718 dst
[i
][BCOMP
] = 0.0F
;
1719 dst
[i
][ACOMP
] = 1.0F
;
1724 unpack_SIGNED_RG88_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
1726 const GLushort
*s
= ((const GLushort
*) src
);
1728 for (i
= 0; i
< n
; i
++) {
1729 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] & 0xff) );
1730 dst
[i
][GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
1731 dst
[i
][BCOMP
] = 0.0F
;
1732 dst
[i
][ACOMP
] = 1.0F
;
1737 unpack_SIGNED_RGBX8888(const void *src
, GLfloat dst
[][4], GLuint n
)
1739 const GLuint
*s
= ((const GLuint
*) src
);
1741 for (i
= 0; i
< n
; i
++) {
1742 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 24) );
1743 dst
[i
][GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 16) );
1744 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
1745 dst
[i
][ACOMP
] = 1.0f
;
1750 unpack_SIGNED_RGBA8888(const void *src
, GLfloat dst
[][4], GLuint n
)
1752 const GLuint
*s
= ((const GLuint
*) src
);
1754 for (i
= 0; i
< n
; i
++) {
1755 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 24) );
1756 dst
[i
][GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 16) );
1757 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
1758 dst
[i
][ACOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] ) );
1763 unpack_SIGNED_RGBA8888_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
1765 const GLuint
*s
= ((const GLuint
*) src
);
1767 for (i
= 0; i
< n
; i
++) {
1768 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] ) );
1769 dst
[i
][GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
1770 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 16) );
1771 dst
[i
][ACOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 24) );
1776 unpack_SIGNED_R16(const void *src
, GLfloat dst
[][4], GLuint n
)
1778 const GLshort
*s
= ((const GLshort
*) src
);
1780 for (i
= 0; i
< n
; i
++) {
1781 dst
[i
][RCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
] );
1782 dst
[i
][GCOMP
] = 0.0F
;
1783 dst
[i
][BCOMP
] = 0.0F
;
1784 dst
[i
][ACOMP
] = 1.0F
;
1789 unpack_SIGNED_GR1616(const void *src
, GLfloat dst
[][4], GLuint n
)
1791 const GLuint
*s
= ((const GLuint
*) src
);
1793 for (i
= 0; i
< n
; i
++) {
1794 dst
[i
][RCOMP
] = SHORT_TO_FLOAT_TEX( (GLshort
) (s
[i
] & 0xffff) );
1795 dst
[i
][GCOMP
] = SHORT_TO_FLOAT_TEX( (GLshort
) (s
[i
] >> 16) );
1796 dst
[i
][BCOMP
] = 0.0F
;
1797 dst
[i
][ACOMP
] = 1.0F
;
1802 unpack_SIGNED_RGB_16(const void *src
, GLfloat dst
[][4], GLuint n
)
1804 const GLshort
*s
= (const GLshort
*) src
;
1806 for (i
= 0; i
< n
; i
++) {
1807 dst
[i
][RCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*3+0] );
1808 dst
[i
][GCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*3+1] );
1809 dst
[i
][BCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*3+2] );
1810 dst
[i
][ACOMP
] = 1.0F
;
1815 unpack_SIGNED_RGBA_16(const void *src
, GLfloat dst
[][4], GLuint n
)
1817 const GLshort
*s
= (const GLshort
*) src
;
1819 for (i
= 0; i
< n
; i
++) {
1820 dst
[i
][RCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+0] );
1821 dst
[i
][GCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+1] );
1822 dst
[i
][BCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+2] );
1823 dst
[i
][ACOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+3] );
1828 unpack_RGBA_16(const void *src
, GLfloat dst
[][4], GLuint n
)
1830 const GLushort
*s
= (const GLushort
*) src
;
1832 for (i
= 0; i
< n
; i
++) {
1833 dst
[i
][RCOMP
] = USHORT_TO_FLOAT( s
[i
*4+0] );
1834 dst
[i
][GCOMP
] = USHORT_TO_FLOAT( s
[i
*4+1] );
1835 dst
[i
][BCOMP
] = USHORT_TO_FLOAT( s
[i
*4+2] );
1836 dst
[i
][ACOMP
] = USHORT_TO_FLOAT( s
[i
*4+3] );
1841 unpack_RED_RGTC1(const void *src
, GLfloat dst
[][4], GLuint n
)
1847 unpack_SIGNED_RED_RGTC1(const void *src
, GLfloat dst
[][4], GLuint n
)
1853 unpack_RG_RGTC2(const void *src
, GLfloat dst
[][4], GLuint n
)
1859 unpack_SIGNED_RG_RGTC2(const void *src
, GLfloat dst
[][4], GLuint n
)
1865 unpack_L_LATC1(const void *src
, GLfloat dst
[][4], GLuint n
)
1871 unpack_SIGNED_L_LATC1(const void *src
, GLfloat dst
[][4], GLuint n
)
1877 unpack_LA_LATC2(const void *src
, GLfloat dst
[][4], GLuint n
)
1883 unpack_SIGNED_LA_LATC2(const void *src
, GLfloat dst
[][4], GLuint n
)
1889 unpack_ETC1_RGB8(const void *src
, GLfloat dst
[][4], GLuint n
)
1895 unpack_ETC2_RGB8(const void *src
, GLfloat dst
[][4], GLuint n
)
1901 unpack_ETC2_SRGB8(const void *src
, GLfloat dst
[][4], GLuint n
)
1907 unpack_ETC2_RGBA8_EAC(const void *src
, GLfloat dst
[][4], GLuint n
)
1913 unpack_ETC2_SRGB8_ALPHA8_EAC(const void *src
, GLfloat dst
[][4], GLuint n
)
1919 unpack_ETC2_R11_EAC(const void *src
, GLfloat dst
[][4], GLuint n
)
1925 unpack_ETC2_RG11_EAC(const void *src
, GLfloat dst
[][4], GLuint n
)
1931 unpack_ETC2_SIGNED_R11_EAC(const void *src
, GLfloat dst
[][4], GLuint n
)
1937 unpack_ETC2_SIGNED_RG11_EAC(const void *src
, GLfloat dst
[][4], GLuint n
)
1943 unpack_ETC2_RGB8_PUNCHTHROUGH_ALPHA1(const void *src
, GLfloat dst
[][4],
1950 unpack_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1(const void *src
, GLfloat dst
[][4],
1957 unpack_SIGNED_A8(const void *src
, GLfloat dst
[][4], GLuint n
)
1959 const GLbyte
*s
= ((const GLbyte
*) src
);
1961 for (i
= 0; i
< n
; i
++) {
1962 dst
[i
][RCOMP
] = 0.0F
;
1963 dst
[i
][GCOMP
] = 0.0F
;
1964 dst
[i
][BCOMP
] = 0.0F
;
1965 dst
[i
][ACOMP
] = BYTE_TO_FLOAT_TEX( s
[i
] );
1970 unpack_SIGNED_L8(const void *src
, GLfloat dst
[][4], GLuint n
)
1972 const GLbyte
*s
= ((const GLbyte
*) src
);
1974 for (i
= 0; i
< n
; i
++) {
1977 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( s
[i
] );
1978 dst
[i
][ACOMP
] = 1.0F
;
1983 unpack_SIGNED_AL88(const void *src
, GLfloat dst
[][4], GLuint n
)
1985 const GLshort
*s
= ((const GLshort
*) src
);
1987 for (i
= 0; i
< n
; i
++) {
1990 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] & 0xff) );
1991 dst
[i
][ACOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
1996 unpack_SIGNED_I8(const void *src
, GLfloat dst
[][4], GLuint n
)
1998 const GLbyte
*s
= ((const GLbyte
*) src
);
2000 for (i
= 0; i
< n
; i
++) {
2004 dst
[i
][ACOMP
] = BYTE_TO_FLOAT_TEX( s
[i
] );
2009 unpack_SIGNED_A16(const void *src
, GLfloat dst
[][4], GLuint n
)
2011 const GLshort
*s
= ((const GLshort
*) src
);
2013 for (i
= 0; i
< n
; i
++) {
2014 dst
[i
][RCOMP
] = 0.0F
;
2015 dst
[i
][GCOMP
] = 0.0F
;
2016 dst
[i
][BCOMP
] = 0.0F
;
2017 dst
[i
][ACOMP
] = SHORT_TO_FLOAT_TEX( s
[i
] );
2022 unpack_SIGNED_L16(const void *src
, GLfloat dst
[][4], GLuint n
)
2024 const GLshort
*s
= ((const GLshort
*) src
);
2026 for (i
= 0; i
< n
; i
++) {
2029 dst
[i
][BCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
] );
2030 dst
[i
][ACOMP
] = 1.0F
;
2035 unpack_SIGNED_AL1616(const void *src
, GLfloat dst
[][4], GLuint n
)
2037 const GLshort
*s
= (const GLshort
*) src
;
2039 for (i
= 0; i
< n
; i
++) {
2042 dst
[i
][BCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*2+0] );
2043 dst
[i
][ACOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*2+1] );
2048 unpack_SIGNED_I16(const void *src
, GLfloat dst
[][4], GLuint n
)
2050 const GLshort
*s
= ((const GLshort
*) src
);
2052 for (i
= 0; i
< n
; i
++) {
2056 dst
[i
][ACOMP
] = SHORT_TO_FLOAT_TEX( s
[i
] );
2061 unpack_RGB9_E5_FLOAT(const void *src
, GLfloat dst
[][4], GLuint n
)
2063 const GLuint
*s
= (const GLuint
*) src
;
2065 for (i
= 0; i
< n
; i
++) {
2066 rgb9e5_to_float3(s
[i
], dst
[i
]);
2067 dst
[i
][ACOMP
] = 1.0F
;
2072 unpack_R11_G11_B10_FLOAT(const void *src
, GLfloat dst
[][4], GLuint n
)
2074 const GLuint
*s
= (const GLuint
*) src
;
2076 for (i
= 0; i
< n
; i
++) {
2077 r11g11b10f_to_float3(s
[i
], dst
[i
]);
2078 dst
[i
][ACOMP
] = 1.0F
;
2083 unpack_XRGB4444_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
2085 const GLushort
*s
= ((const GLushort
*) src
);
2087 for (i
= 0; i
< n
; i
++) {
2088 dst
[i
][RCOMP
] = ((s
[i
] >> 8) & 0xf) * (1.0F
/ 15.0F
);
2089 dst
[i
][GCOMP
] = ((s
[i
] >> 4) & 0xf) * (1.0F
/ 15.0F
);
2090 dst
[i
][BCOMP
] = ((s
[i
] ) & 0xf) * (1.0F
/ 15.0F
);
2091 dst
[i
][ACOMP
] = 1.0;
2096 unpack_XRGB1555_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
2098 const GLushort
*s
= ((const GLushort
*) src
);
2100 for (i
= 0; i
< n
; i
++) {
2101 dst
[i
][RCOMP
] = ((s
[i
] >> 10) & 0x1f) * (1.0F
/ 31.0F
);
2102 dst
[i
][GCOMP
] = ((s
[i
] >> 5) & 0x1f) * (1.0F
/ 31.0F
);
2103 dst
[i
][BCOMP
] = ((s
[i
] >> 0) & 0x1f) * (1.0F
/ 31.0F
);
2104 dst
[i
][ACOMP
] = 1.0;
2109 unpack_XBGR8888_SNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
2111 const GLuint
*s
= ((const GLuint
*) src
);
2113 for (i
= 0; i
< n
; i
++) {
2114 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] ) );
2115 dst
[i
][GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
2116 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 16) );
2117 dst
[i
][ACOMP
] = 1.0;
2122 unpack_XBGR8888_SRGB(const void *src
, GLfloat dst
[][4], GLuint n
)
2124 const GLuint
*s
= ((const GLuint
*) src
);
2126 for (i
= 0; i
< n
; i
++) {
2127 dst
[i
][RCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] ) & 0xff );
2128 dst
[i
][GCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] >> 8) & 0xff );
2129 dst
[i
][BCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] >> 16) & 0xff );
2130 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 24 ); /* linear! */
2135 unpack_XBGR8888_UINT(const void *src
, GLfloat dst
[][4], GLuint n
)
2137 const GLbyte
*s
= (const GLbyte
*) src
;
2139 for (i
= 0; i
< n
; i
++) {
2140 dst
[i
][RCOMP
] = s
[i
*4+0];
2141 dst
[i
][GCOMP
] = s
[i
*4+1];
2142 dst
[i
][BCOMP
] = s
[i
*4+2];
2143 dst
[i
][ACOMP
] = 1.0;
2148 unpack_XBGR8888_SINT(const void *src
, GLfloat dst
[][4], GLuint n
)
2150 const GLbyte
*s
= (const GLbyte
*) src
;
2152 for (i
= 0; i
< n
; i
++) {
2153 dst
[i
][RCOMP
] = s
[i
*4+0];
2154 dst
[i
][GCOMP
] = s
[i
*4+1];
2155 dst
[i
][BCOMP
] = s
[i
*4+2];
2156 dst
[i
][ACOMP
] = 1.0;
2161 unpack_XRGB2101010_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
2163 const GLuint
*s
= ((const GLuint
*) src
);
2165 for (i
= 0; i
< n
; i
++) {
2166 dst
[i
][RCOMP
] = ((s
[i
] >> 20) & 0x3ff) * (1.0F
/ 1023.0F
);
2167 dst
[i
][GCOMP
] = ((s
[i
] >> 10) & 0x3ff) * (1.0F
/ 1023.0F
);
2168 dst
[i
][BCOMP
] = ((s
[i
] >> 0) & 0x3ff) * (1.0F
/ 1023.0F
);
2169 dst
[i
][ACOMP
] = 1.0;
2174 unpack_XBGR16161616_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
2176 const GLushort
*s
= (const GLushort
*) src
;
2178 for (i
= 0; i
< n
; i
++) {
2179 dst
[i
][RCOMP
] = USHORT_TO_FLOAT( s
[i
*4+0] );
2180 dst
[i
][GCOMP
] = USHORT_TO_FLOAT( s
[i
*4+1] );
2181 dst
[i
][BCOMP
] = USHORT_TO_FLOAT( s
[i
*4+2] );
2182 dst
[i
][ACOMP
] = 1.0;
2187 unpack_XBGR16161616_SNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
2189 const GLshort
*s
= (const GLshort
*) src
;
2191 for (i
= 0; i
< n
; i
++) {
2192 dst
[i
][RCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+0] );
2193 dst
[i
][GCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+1] );
2194 dst
[i
][BCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+2] );
2195 dst
[i
][ACOMP
] = 1.0;
2200 unpack_XBGR16161616_FLOAT(const void *src
, GLfloat dst
[][4], GLuint n
)
2202 const GLshort
*s
= (const GLshort
*) src
;
2204 for (i
= 0; i
< n
; i
++) {
2205 dst
[i
][RCOMP
] = _mesa_half_to_float(s
[i
*4+0]);
2206 dst
[i
][GCOMP
] = _mesa_half_to_float(s
[i
*4+1]);
2207 dst
[i
][BCOMP
] = _mesa_half_to_float(s
[i
*4+2]);
2208 dst
[i
][ACOMP
] = 1.0;
2213 unpack_XBGR16161616_UINT(const void *src
, GLfloat dst
[][4], GLuint n
)
2215 const GLushort
*s
= (const GLushort
*) src
;
2217 for (i
= 0; i
< n
; i
++) {
2218 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
2219 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
2220 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
2221 dst
[i
][ACOMP
] = 1.0;
2226 unpack_XBGR16161616_SINT(const void *src
, GLfloat dst
[][4], GLuint n
)
2228 const GLshort
*s
= (const GLshort
*) src
;
2230 for (i
= 0; i
< n
; i
++) {
2231 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
2232 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
2233 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
2234 dst
[i
][ACOMP
] = 1.0;
2239 unpack_XBGR32323232_FLOAT(const void *src
, GLfloat dst
[][4], GLuint n
)
2241 const GLfloat
*s
= (const GLfloat
*) src
;
2243 for (i
= 0; i
< n
; i
++) {
2244 dst
[i
][RCOMP
] = s
[i
*4+0];
2245 dst
[i
][GCOMP
] = s
[i
*4+1];
2246 dst
[i
][BCOMP
] = s
[i
*4+2];
2247 dst
[i
][ACOMP
] = 1.0;
2252 unpack_XBGR32323232_UINT(const void *src
, GLfloat dst
[][4], GLuint n
)
2254 const GLuint
*s
= (const GLuint
*) src
;
2256 for (i
= 0; i
< n
; i
++) {
2257 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
2258 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
2259 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
2260 dst
[i
][ACOMP
] = 1.0;
2265 unpack_XBGR32323232_SINT(const void *src
, GLfloat dst
[][4], GLuint n
)
2267 const GLint
*s
= (const GLint
*) src
;
2269 for (i
= 0; i
< n
; i
++) {
2270 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
2271 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
2272 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
2273 dst
[i
][ACOMP
] = 1.0;
2278 unpack_ABGR2101010(const void *src
, GLfloat dst
[][4], GLuint n
)
2280 const GLuint
*s
= ((const GLuint
*) src
);
2282 for (i
= 0; i
< n
; i
++) {
2283 dst
[i
][RCOMP
] = ((s
[i
] >> 0) & 0x3ff) * (1.0F
/ 1023.0F
);
2284 dst
[i
][GCOMP
] = ((s
[i
] >> 10) & 0x3ff) * (1.0F
/ 1023.0F
);
2285 dst
[i
][BCOMP
] = ((s
[i
] >> 20) & 0x3ff) * (1.0F
/ 1023.0F
);
2286 dst
[i
][ACOMP
] = ((s
[i
] >> 30) & 0x03) * (1.0F
/ 3.0F
);
2291 unpack_SIGNED_RG88(const void *src
, GLfloat dst
[][4], GLuint n
)
2293 const GLushort
*s
= ((const GLushort
*) src
);
2295 for (i
= 0; i
< n
; i
++) {
2296 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
2297 dst
[i
][GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] & 0xff) );
2298 dst
[i
][BCOMP
] = 0.0F
;
2299 dst
[i
][ACOMP
] = 1.0F
;
2304 unpack_SIGNED_RG1616(const void *src
, GLfloat dst
[][4], GLuint n
)
2306 const GLuint
*s
= ((const GLuint
*) src
);
2308 for (i
= 0; i
< n
; i
++) {
2309 dst
[i
][RCOMP
] = SHORT_TO_FLOAT_TEX( (GLshort
) (s
[i
] >> 16) );
2310 dst
[i
][GCOMP
] = SHORT_TO_FLOAT_TEX( (GLshort
) (s
[i
] & 0xffff) );
2311 dst
[i
][BCOMP
] = 0.0F
;
2312 dst
[i
][ACOMP
] = 1.0F
;
2317 * Return the unpacker function for the given format.
2319 static unpack_rgba_func
2320 get_unpack_rgba_function(mesa_format format
)
2322 static unpack_rgba_func table
[MESA_FORMAT_COUNT
];
2323 static GLboolean initialized
= GL_FALSE
;
2326 table
[MESA_FORMAT_NONE
] = NULL
;
2328 table
[MESA_FORMAT_A8B8G8R8_UNORM
] = unpack_RGBA8888
;
2329 table
[MESA_FORMAT_R8G8B8A8_UNORM
] = unpack_RGBA8888_REV
;
2330 table
[MESA_FORMAT_B8G8R8A8_UNORM
] = unpack_ARGB8888
;
2331 table
[MESA_FORMAT_A8R8G8B8_UNORM
] = unpack_ARGB8888_REV
;
2332 table
[MESA_FORMAT_X8B8G8R8_UNORM
] = unpack_RGBX8888
;
2333 table
[MESA_FORMAT_R8G8B8X8_UNORM
] = unpack_RGBX8888_REV
;
2334 table
[MESA_FORMAT_B8G8R8X8_UNORM
] = unpack_XRGB8888
;
2335 table
[MESA_FORMAT_X8R8G8B8_UNORM
] = unpack_XRGB8888_REV
;
2336 table
[MESA_FORMAT_BGR_UNORM8
] = unpack_RGB888
;
2337 table
[MESA_FORMAT_RGB_UNORM8
] = unpack_BGR888
;
2338 table
[MESA_FORMAT_B5G6R5_UNORM
] = unpack_RGB565
;
2339 table
[MESA_FORMAT_R5G6B5_UNORM
] = unpack_RGB565_REV
;
2340 table
[MESA_FORMAT_B4G4R4A4_UNORM
] = unpack_ARGB4444
;
2341 table
[MESA_FORMAT_A4R4G4B4_UNORM
] = unpack_ARGB4444_REV
;
2342 table
[MESA_FORMAT_A1B5G5R5_UNORM
] = unpack_RGBA5551
;
2343 table
[MESA_FORMAT_B5G5R5A1_UNORM
] = unpack_ARGB1555
;
2344 table
[MESA_FORMAT_A1R5G5B5_UNORM
] = unpack_ARGB1555_REV
;
2345 table
[MESA_FORMAT_L4A4_UNORM
] = unpack_AL44
;
2346 table
[MESA_FORMAT_L8A8_UNORM
] = unpack_AL88
;
2347 table
[MESA_FORMAT_A8L8_UNORM
] = unpack_AL88_REV
;
2348 table
[MESA_FORMAT_L16A16_UNORM
] = unpack_AL1616
;
2349 table
[MESA_FORMAT_A16L16_UNORM
] = unpack_AL1616_REV
;
2350 table
[MESA_FORMAT_B2G3R3_UNORM
] = unpack_RGB332
;
2351 table
[MESA_FORMAT_A_UNORM8
] = unpack_A8
;
2352 table
[MESA_FORMAT_A_UNORM16
] = unpack_A16
;
2353 table
[MESA_FORMAT_L_UNORM8
] = unpack_L8
;
2354 table
[MESA_FORMAT_L_UNORM16
] = unpack_L16
;
2355 table
[MESA_FORMAT_I_UNORM8
] = unpack_I8
;
2356 table
[MESA_FORMAT_I_UNORM16
] = unpack_I16
;
2357 table
[MESA_FORMAT_YCBCR
] = unpack_YCBCR
;
2358 table
[MESA_FORMAT_YCBCR_REV
] = unpack_YCBCR_REV
;
2359 table
[MESA_FORMAT_R_UNORM8
] = unpack_R8
;
2360 table
[MESA_FORMAT_R8G8_UNORM
] = unpack_GR88
;
2361 table
[MESA_FORMAT_G8R8_UNORM
] = unpack_RG88
;
2362 table
[MESA_FORMAT_R_UNORM16
] = unpack_R16
;
2363 table
[MESA_FORMAT_R16G16_UNORM
] = unpack_GR1616
;
2364 table
[MESA_FORMAT_G16R16_UNORM
] = unpack_RG1616
;
2365 table
[MESA_FORMAT_B10G10R10A2_UNORM
] = unpack_ARGB2101010
;
2366 table
[MESA_FORMAT_B10G10R10A2_UINT
] = unpack_ARGB2101010_UINT
;
2367 table
[MESA_FORMAT_R10G10B10A2_UINT
] = unpack_ABGR2101010_UINT
;
2368 table
[MESA_FORMAT_S8_UINT_Z24_UNORM
] = unpack_Z24_S8
;
2369 table
[MESA_FORMAT_Z24_UNORM_X8_UINT
] = unpack_S8_Z24
;
2370 table
[MESA_FORMAT_Z_UNORM16
] = unpack_Z16
;
2371 table
[MESA_FORMAT_Z24_UNORM_S8_UINT
] = unpack_X8_Z24
;
2372 table
[MESA_FORMAT_X8Z24_UNORM
] = unpack_Z24_X8
;
2373 table
[MESA_FORMAT_Z_UNORM32
] = unpack_Z32
;
2374 table
[MESA_FORMAT_S_UINT8
] = unpack_S8
;
2375 table
[MESA_FORMAT_BGR_SRGB8
] = unpack_SRGB8
;
2376 table
[MESA_FORMAT_A8B8G8R8_SRGB
] = unpack_SRGBA8
;
2377 table
[MESA_FORMAT_B8G8R8A8_SRGB
] = unpack_SARGB8
;
2378 table
[MESA_FORMAT_L_SRGB8
] = unpack_SL8
;
2379 table
[MESA_FORMAT_L8A8_SRGB
] = unpack_SLA8
;
2380 table
[MESA_FORMAT_SRGB_DXT1
] = unpack_SRGB_DXT1
;
2381 table
[MESA_FORMAT_SRGBA_DXT1
] = unpack_SRGBA_DXT1
;
2382 table
[MESA_FORMAT_SRGBA_DXT3
] = unpack_SRGBA_DXT3
;
2383 table
[MESA_FORMAT_SRGBA_DXT5
] = unpack_SRGBA_DXT5
;
2385 table
[MESA_FORMAT_RGB_FXT1
] = unpack_RGB_FXT1
;
2386 table
[MESA_FORMAT_RGBA_FXT1
] = unpack_RGBA_FXT1
;
2387 table
[MESA_FORMAT_RGB_DXT1
] = unpack_RGB_DXT1
;
2388 table
[MESA_FORMAT_RGBA_DXT1
] = unpack_RGBA_DXT1
;
2389 table
[MESA_FORMAT_RGBA_DXT3
] = unpack_RGBA_DXT3
;
2390 table
[MESA_FORMAT_RGBA_DXT5
] = unpack_RGBA_DXT5
;
2392 table
[MESA_FORMAT_RGBA_FLOAT32
] = unpack_RGBA_FLOAT32
;
2393 table
[MESA_FORMAT_RGBA_FLOAT16
] = unpack_RGBA_FLOAT16
;
2394 table
[MESA_FORMAT_RGB_FLOAT32
] = unpack_RGB_FLOAT32
;
2395 table
[MESA_FORMAT_RGB_FLOAT16
] = unpack_RGB_FLOAT16
;
2396 table
[MESA_FORMAT_A_FLOAT32
] = unpack_ALPHA_FLOAT32
;
2397 table
[MESA_FORMAT_A_FLOAT16
] = unpack_ALPHA_FLOAT16
;
2398 table
[MESA_FORMAT_L_FLOAT32
] = unpack_LUMINANCE_FLOAT32
;
2399 table
[MESA_FORMAT_L_FLOAT16
] = unpack_LUMINANCE_FLOAT16
;
2400 table
[MESA_FORMAT_LA_FLOAT32
] = unpack_LUMINANCE_ALPHA_FLOAT32
;
2401 table
[MESA_FORMAT_LA_FLOAT16
] = unpack_LUMINANCE_ALPHA_FLOAT16
;
2402 table
[MESA_FORMAT_I_FLOAT32
] = unpack_INTENSITY_FLOAT32
;
2403 table
[MESA_FORMAT_I_FLOAT16
] = unpack_INTENSITY_FLOAT16
;
2404 table
[MESA_FORMAT_R_FLOAT32
] = unpack_R_FLOAT32
;
2405 table
[MESA_FORMAT_R_FLOAT16
] = unpack_R_FLOAT16
;
2406 table
[MESA_FORMAT_RG_FLOAT32
] = unpack_RG_FLOAT32
;
2407 table
[MESA_FORMAT_RG_FLOAT16
] = unpack_RG_FLOAT16
;
2409 table
[MESA_FORMAT_A_UINT8
] = unpack_ALPHA_UINT8
;
2410 table
[MESA_FORMAT_A_UINT16
] = unpack_ALPHA_UINT16
;
2411 table
[MESA_FORMAT_A_UINT32
] = unpack_ALPHA_UINT32
;
2412 table
[MESA_FORMAT_A_SINT8
] = unpack_ALPHA_INT8
;
2413 table
[MESA_FORMAT_A_SINT16
] = unpack_ALPHA_INT16
;
2414 table
[MESA_FORMAT_A_SINT32
] = unpack_ALPHA_INT32
;
2416 table
[MESA_FORMAT_I_UINT8
] = unpack_INTENSITY_UINT8
;
2417 table
[MESA_FORMAT_I_UINT16
] = unpack_INTENSITY_UINT16
;
2418 table
[MESA_FORMAT_I_UINT32
] = unpack_INTENSITY_UINT32
;
2419 table
[MESA_FORMAT_I_SINT8
] = unpack_INTENSITY_INT8
;
2420 table
[MESA_FORMAT_I_SINT16
] = unpack_INTENSITY_INT16
;
2421 table
[MESA_FORMAT_I_SINT32
] = unpack_INTENSITY_INT32
;
2423 table
[MESA_FORMAT_L_UINT8
] = unpack_LUMINANCE_UINT8
;
2424 table
[MESA_FORMAT_L_UINT16
] = unpack_LUMINANCE_UINT16
;
2425 table
[MESA_FORMAT_L_UINT32
] = unpack_LUMINANCE_UINT32
;
2426 table
[MESA_FORMAT_L_SINT8
] = unpack_LUMINANCE_INT8
;
2427 table
[MESA_FORMAT_L_SINT16
] = unpack_LUMINANCE_INT16
;
2428 table
[MESA_FORMAT_L_SINT32
] = unpack_LUMINANCE_INT32
;
2430 table
[MESA_FORMAT_LA_UINT8
] = unpack_LUMINANCE_ALPHA_UINT8
;
2431 table
[MESA_FORMAT_LA_UINT16
] = unpack_LUMINANCE_ALPHA_UINT16
;
2432 table
[MESA_FORMAT_LA_UINT32
] = unpack_LUMINANCE_ALPHA_UINT32
;
2433 table
[MESA_FORMAT_LA_SINT8
] = unpack_LUMINANCE_ALPHA_INT8
;
2434 table
[MESA_FORMAT_LA_SINT16
] = unpack_LUMINANCE_ALPHA_INT16
;
2435 table
[MESA_FORMAT_LA_SINT32
] = unpack_LUMINANCE_ALPHA_INT32
;
2437 table
[MESA_FORMAT_R_SINT8
] = unpack_R_INT8
;
2438 table
[MESA_FORMAT_RG_SINT8
] = unpack_RG_INT8
;
2439 table
[MESA_FORMAT_RGB_SINT8
] = unpack_RGB_INT8
;
2440 table
[MESA_FORMAT_RGBA_SINT8
] = unpack_RGBA_INT8
;
2441 table
[MESA_FORMAT_R_SINT16
] = unpack_R_INT16
;
2442 table
[MESA_FORMAT_RG_SINT16
] = unpack_RG_INT16
;
2443 table
[MESA_FORMAT_RGB_SINT16
] = unpack_RGB_INT16
;
2444 table
[MESA_FORMAT_RGBA_SINT16
] = unpack_RGBA_INT16
;
2445 table
[MESA_FORMAT_R_SINT32
] = unpack_R_INT32
;
2446 table
[MESA_FORMAT_RG_SINT32
] = unpack_RG_INT32
;
2447 table
[MESA_FORMAT_RGB_SINT32
] = unpack_RGB_INT32
;
2448 table
[MESA_FORMAT_RGBA_SINT32
] = unpack_RGBA_INT32
;
2449 table
[MESA_FORMAT_R_UINT8
] = unpack_R_UINT8
;
2450 table
[MESA_FORMAT_RG_UINT8
] = unpack_RG_UINT8
;
2451 table
[MESA_FORMAT_RGB_UINT8
] = unpack_RGB_UINT8
;
2452 table
[MESA_FORMAT_RGBA_UINT8
] = unpack_RGBA_UINT8
;
2453 table
[MESA_FORMAT_R_UINT16
] = unpack_R_UINT16
;
2454 table
[MESA_FORMAT_RG_UINT16
] = unpack_RG_UINT16
;
2455 table
[MESA_FORMAT_RGB_UINT16
] = unpack_RGB_UINT16
;
2456 table
[MESA_FORMAT_RGBA_UINT16
] = unpack_RGBA_UINT16
;
2457 table
[MESA_FORMAT_R_UINT32
] = unpack_R_UINT32
;
2458 table
[MESA_FORMAT_RG_UINT32
] = unpack_RG_UINT32
;
2459 table
[MESA_FORMAT_RGB_UINT32
] = unpack_RGB_UINT32
;
2460 table
[MESA_FORMAT_RGBA_UINT32
] = unpack_RGBA_UINT32
;
2462 table
[MESA_FORMAT_DUDV8
] = unpack_DUDV8
;
2463 table
[MESA_FORMAT_R_SNORM8
] = unpack_SIGNED_R8
;
2464 table
[MESA_FORMAT_R8G8_SNORM
] = unpack_SIGNED_RG88_REV
;
2465 table
[MESA_FORMAT_X8B8G8R8_SNORM
] = unpack_SIGNED_RGBX8888
;
2466 table
[MESA_FORMAT_A8B8G8R8_SNORM
] = unpack_SIGNED_RGBA8888
;
2467 table
[MESA_FORMAT_R8G8B8A8_SNORM
] = unpack_SIGNED_RGBA8888_REV
;
2468 table
[MESA_FORMAT_R_SNORM16
] = unpack_SIGNED_R16
;
2469 table
[MESA_FORMAT_R16G16_SNORM
] = unpack_SIGNED_GR1616
;
2470 table
[MESA_FORMAT_RGB_SNORM16
] = unpack_SIGNED_RGB_16
;
2471 table
[MESA_FORMAT_RGBA_SNORM16
] = unpack_SIGNED_RGBA_16
;
2472 table
[MESA_FORMAT_RGBA_UNORM16
] = unpack_RGBA_16
;
2474 table
[MESA_FORMAT_R_RGTC1_UNORM
] = unpack_RED_RGTC1
;
2475 table
[MESA_FORMAT_R_RGTC1_SNORM
] = unpack_SIGNED_RED_RGTC1
;
2476 table
[MESA_FORMAT_RG_RGTC2_UNORM
] = unpack_RG_RGTC2
;
2477 table
[MESA_FORMAT_RG_RGTC2_SNORM
] = unpack_SIGNED_RG_RGTC2
;
2479 table
[MESA_FORMAT_L_LATC1_UNORM
] = unpack_L_LATC1
;
2480 table
[MESA_FORMAT_L_LATC1_SNORM
] = unpack_SIGNED_L_LATC1
;
2481 table
[MESA_FORMAT_LA_LATC2_UNORM
] = unpack_LA_LATC2
;
2482 table
[MESA_FORMAT_LA_LATC2_SNORM
] = unpack_SIGNED_LA_LATC2
;
2484 table
[MESA_FORMAT_ETC1_RGB8
] = unpack_ETC1_RGB8
;
2485 table
[MESA_FORMAT_ETC2_RGB8
] = unpack_ETC2_RGB8
;
2486 table
[MESA_FORMAT_ETC2_SRGB8
] = unpack_ETC2_SRGB8
;
2487 table
[MESA_FORMAT_ETC2_RGBA8_EAC
] = unpack_ETC2_RGBA8_EAC
;
2488 table
[MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC
] = unpack_ETC2_SRGB8_ALPHA8_EAC
;
2489 table
[MESA_FORMAT_ETC2_R11_EAC
] = unpack_ETC2_R11_EAC
;
2490 table
[MESA_FORMAT_ETC2_RG11_EAC
] = unpack_ETC2_RG11_EAC
;
2491 table
[MESA_FORMAT_ETC2_SIGNED_R11_EAC
] = unpack_ETC2_SIGNED_R11_EAC
;
2492 table
[MESA_FORMAT_ETC2_SIGNED_RG11_EAC
] = unpack_ETC2_SIGNED_RG11_EAC
;
2493 table
[MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1
] =
2494 unpack_ETC2_RGB8_PUNCHTHROUGH_ALPHA1
;
2495 table
[MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
] =
2496 unpack_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
;
2497 table
[MESA_FORMAT_A_SNORM8
] = unpack_SIGNED_A8
;
2498 table
[MESA_FORMAT_L_SNORM8
] = unpack_SIGNED_L8
;
2499 table
[MESA_FORMAT_L8A8_SNORM
] = unpack_SIGNED_AL88
;
2500 table
[MESA_FORMAT_I_SNORM8
] = unpack_SIGNED_I8
;
2501 table
[MESA_FORMAT_A_SNORM16
] = unpack_SIGNED_A16
;
2502 table
[MESA_FORMAT_L_SNORM16
] = unpack_SIGNED_L16
;
2503 table
[MESA_FORMAT_LA_SNORM16
] = unpack_SIGNED_AL1616
;
2504 table
[MESA_FORMAT_I_SNORM16
] = unpack_SIGNED_I16
;
2506 table
[MESA_FORMAT_R9G9B9E5_FLOAT
] = unpack_RGB9_E5_FLOAT
;
2507 table
[MESA_FORMAT_R11G11B10_FLOAT
] = unpack_R11_G11_B10_FLOAT
;
2509 table
[MESA_FORMAT_Z_FLOAT32
] = unpack_Z32_FLOAT
;
2510 table
[MESA_FORMAT_Z32_FLOAT_S8X24_UINT
] = unpack_Z32_FLOAT_X24S8
;
2512 table
[MESA_FORMAT_B4G4R4X4_UNORM
] = unpack_XRGB4444_UNORM
;
2513 table
[MESA_FORMAT_B5G5R5X1_UNORM
] = unpack_XRGB1555_UNORM
;
2514 table
[MESA_FORMAT_R8G8B8X8_SNORM
] = unpack_XBGR8888_SNORM
;
2515 table
[MESA_FORMAT_R8G8B8X8_SRGB
] = unpack_XBGR8888_SRGB
;
2516 table
[MESA_FORMAT_RGBX_UINT8
] = unpack_XBGR8888_UINT
;
2517 table
[MESA_FORMAT_RGBX_SINT8
] = unpack_XBGR8888_SINT
;
2518 table
[MESA_FORMAT_B10G10R10X2_UNORM
] = unpack_XRGB2101010_UNORM
;
2519 table
[MESA_FORMAT_RGBX_UNORM16
] = unpack_XBGR16161616_UNORM
;
2520 table
[MESA_FORMAT_RGBX_SNORM16
] = unpack_XBGR16161616_SNORM
;
2521 table
[MESA_FORMAT_RGBX_FLOAT16
] = unpack_XBGR16161616_FLOAT
;
2522 table
[MESA_FORMAT_RGBX_UINT16
] = unpack_XBGR16161616_UINT
;
2523 table
[MESA_FORMAT_RGBX_SINT16
] = unpack_XBGR16161616_SINT
;
2524 table
[MESA_FORMAT_RGBX_FLOAT32
] = unpack_XBGR32323232_FLOAT
;
2525 table
[MESA_FORMAT_RGBX_UINT32
] = unpack_XBGR32323232_UINT
;
2526 table
[MESA_FORMAT_RGBX_SINT32
] = unpack_XBGR32323232_SINT
;
2528 table
[MESA_FORMAT_R10G10B10A2_UNORM
] = unpack_ABGR2101010
;
2530 table
[MESA_FORMAT_G8R8_SNORM
] = unpack_SIGNED_RG88
;
2531 table
[MESA_FORMAT_G16R16_SNORM
] = unpack_SIGNED_RG1616
;
2533 initialized
= GL_TRUE
;
2536 if (table
[format
] == NULL
) {
2537 _mesa_problem(NULL
, "unsupported unpack for format %s",
2538 _mesa_get_format_name(format
));
2541 return table
[format
];
2546 * Unpack rgba colors, returning as GLfloat values.
2549 _mesa_unpack_rgba_row(mesa_format format
, GLuint n
,
2550 const void *src
, GLfloat dst
[][4])
2552 unpack_rgba_func unpack
= get_unpack_rgba_function(format
);
2553 unpack(src
, dst
, n
);
2557 /**********************************************************************/
2558 /* Unpack, returning GLubyte colors */
2559 /**********************************************************************/
2563 unpack_ubyte_RGBA8888(const void *src
, GLubyte dst
[][4], GLuint n
)
2565 const GLuint
*s
= ((const GLuint
*) src
);
2567 for (i
= 0; i
< n
; i
++) {
2568 dst
[i
][RCOMP
] = (s
[i
] >> 24);
2569 dst
[i
][GCOMP
] = (s
[i
] >> 16) & 0xff;
2570 dst
[i
][BCOMP
] = (s
[i
] >> 8) & 0xff;
2571 dst
[i
][ACOMP
] = (s
[i
] ) & 0xff;
2576 unpack_ubyte_RGBA8888_REV(const void *src
, GLubyte dst
[][4], GLuint n
)
2578 const GLuint
*s
= ((const GLuint
*) src
);
2580 for (i
= 0; i
< n
; i
++) {
2581 dst
[i
][RCOMP
] = (s
[i
] ) & 0xff;
2582 dst
[i
][GCOMP
] = (s
[i
] >> 8) & 0xff;
2583 dst
[i
][BCOMP
] = (s
[i
] >> 16) & 0xff;
2584 dst
[i
][ACOMP
] = (s
[i
] >> 24);
2589 unpack_ubyte_ARGB8888(const void *src
, GLubyte dst
[][4], GLuint n
)
2591 const GLuint
*s
= ((const GLuint
*) src
);
2593 for (i
= 0; i
< n
; i
++) {
2594 dst
[i
][RCOMP
] = (s
[i
] >> 16) & 0xff;
2595 dst
[i
][GCOMP
] = (s
[i
] >> 8) & 0xff;
2596 dst
[i
][BCOMP
] = (s
[i
] ) & 0xff;
2597 dst
[i
][ACOMP
] = (s
[i
] >> 24);
2602 unpack_ubyte_ARGB8888_REV(const void *src
, GLubyte dst
[][4], GLuint n
)
2604 const GLuint
*s
= ((const GLuint
*) src
);
2606 for (i
= 0; i
< n
; i
++) {
2607 dst
[i
][RCOMP
] = (s
[i
] >> 8) & 0xff;
2608 dst
[i
][GCOMP
] = (s
[i
] >> 16) & 0xff;
2609 dst
[i
][BCOMP
] = (s
[i
] >> 24);
2610 dst
[i
][ACOMP
] = (s
[i
] ) & 0xff;
2615 unpack_ubyte_RGBX8888(const void *src
, GLubyte dst
[][4], GLuint n
)
2617 const GLuint
*s
= ((const GLuint
*) src
);
2619 for (i
= 0; i
< n
; i
++) {
2620 dst
[i
][RCOMP
] = (s
[i
] >> 24);
2621 dst
[i
][GCOMP
] = (s
[i
] >> 16) & 0xff;
2622 dst
[i
][BCOMP
] = (s
[i
] >> 8) & 0xff;
2623 dst
[i
][ACOMP
] = 0xff;
2628 unpack_ubyte_RGBX8888_REV(const void *src
, GLubyte dst
[][4], GLuint n
)
2630 const GLuint
*s
= ((const GLuint
*) src
);
2632 for (i
= 0; i
< n
; i
++) {
2633 dst
[i
][RCOMP
] = (s
[i
] ) & 0xff;
2634 dst
[i
][GCOMP
] = (s
[i
] >> 8) & 0xff;
2635 dst
[i
][BCOMP
] = (s
[i
] >> 16) & 0xff;
2636 dst
[i
][ACOMP
] = 0xff;
2641 unpack_ubyte_XRGB8888(const void *src
, GLubyte dst
[][4], GLuint n
)
2643 const GLuint
*s
= ((const GLuint
*) src
);
2645 for (i
= 0; i
< n
; i
++) {
2646 dst
[i
][RCOMP
] = (s
[i
] >> 16) & 0xff;
2647 dst
[i
][GCOMP
] = (s
[i
] >> 8) & 0xff;
2648 dst
[i
][BCOMP
] = (s
[i
] ) & 0xff;
2649 dst
[i
][ACOMP
] = 0xff;
2654 unpack_ubyte_XRGB8888_REV(const void *src
, GLubyte dst
[][4], GLuint n
)
2656 const GLuint
*s
= ((const GLuint
*) src
);
2658 for (i
= 0; i
< n
; i
++) {
2659 dst
[i
][RCOMP
] = (s
[i
] >> 8) & 0xff;
2660 dst
[i
][GCOMP
] = (s
[i
] >> 16) & 0xff;
2661 dst
[i
][BCOMP
] = (s
[i
] >> 24);
2662 dst
[i
][ACOMP
] = 0xff;
2667 unpack_ubyte_RGB888(const void *src
, GLubyte dst
[][4], GLuint n
)
2669 const GLubyte
*s
= (const GLubyte
*) src
;
2671 for (i
= 0; i
< n
; i
++) {
2672 dst
[i
][RCOMP
] = s
[i
*3+2];
2673 dst
[i
][GCOMP
] = s
[i
*3+1];
2674 dst
[i
][BCOMP
] = s
[i
*3+0];
2675 dst
[i
][ACOMP
] = 0xff;
2680 unpack_ubyte_BGR888(const void *src
, GLubyte dst
[][4], GLuint n
)
2682 const GLubyte
*s
= (const GLubyte
*) src
;
2684 for (i
= 0; i
< n
; i
++) {
2685 dst
[i
][RCOMP
] = s
[i
*3+0];
2686 dst
[i
][GCOMP
] = s
[i
*3+1];
2687 dst
[i
][BCOMP
] = s
[i
*3+2];
2688 dst
[i
][ACOMP
] = 0xff;
2693 unpack_ubyte_RGB565(const void *src
, GLubyte dst
[][4], GLuint n
)
2695 const GLushort
*s
= ((const GLushort
*) src
);
2697 for (i
= 0; i
< n
; i
++) {
2698 dst
[i
][RCOMP
] = EXPAND_5_8((s
[i
] >> 11) & 0x1f);
2699 dst
[i
][GCOMP
] = EXPAND_6_8((s
[i
] >> 5 ) & 0x3f);
2700 dst
[i
][BCOMP
] = EXPAND_5_8( s
[i
] & 0x1f);
2701 dst
[i
][ACOMP
] = 0xff;
2706 unpack_ubyte_RGB565_REV(const void *src
, GLubyte dst
[][4], GLuint n
)
2708 /* Warning: this function does not match the current Mesa definition
2709 * of MESA_FORMAT_R5G6B5_UNORM.
2711 const GLushort
*s
= ((const GLushort
*) src
);
2713 for (i
= 0; i
< n
; i
++) {
2714 GLuint t
= (s
[i
] >> 8) | (s
[i
] << 8); /* byte swap */
2715 dst
[i
][RCOMP
] = EXPAND_5_8((t
>> 11) & 0x1f);
2716 dst
[i
][GCOMP
] = EXPAND_6_8((t
>> 5 ) & 0x3f);
2717 dst
[i
][BCOMP
] = EXPAND_5_8( t
& 0x1f);
2718 dst
[i
][ACOMP
] = 0xff;
2723 unpack_ubyte_ARGB4444(const void *src
, GLubyte dst
[][4], GLuint n
)
2725 const GLushort
*s
= ((const GLushort
*) src
);
2727 for (i
= 0; i
< n
; i
++) {
2728 dst
[i
][RCOMP
] = EXPAND_4_8((s
[i
] >> 8) & 0xf);
2729 dst
[i
][GCOMP
] = EXPAND_4_8((s
[i
] >> 4) & 0xf);
2730 dst
[i
][BCOMP
] = EXPAND_4_8((s
[i
] ) & 0xf);
2731 dst
[i
][ACOMP
] = EXPAND_4_8((s
[i
] >> 12) & 0xf);
2736 unpack_ubyte_ARGB4444_REV(const void *src
, GLubyte dst
[][4], GLuint n
)
2738 const GLushort
*s
= ((const GLushort
*) src
);
2740 for (i
= 0; i
< n
; i
++) {
2741 dst
[i
][RCOMP
] = EXPAND_4_8((s
[i
] ) & 0xf);
2742 dst
[i
][GCOMP
] = EXPAND_4_8((s
[i
] >> 12) & 0xf);
2743 dst
[i
][BCOMP
] = EXPAND_4_8((s
[i
] >> 8) & 0xf);
2744 dst
[i
][ACOMP
] = EXPAND_4_8((s
[i
] >> 4) & 0xf);
2749 unpack_ubyte_RGBA5551(const void *src
, GLubyte dst
[][4], GLuint n
)
2751 const GLushort
*s
= ((const GLushort
*) src
);
2753 for (i
= 0; i
< n
; i
++) {
2754 dst
[i
][RCOMP
] = EXPAND_5_8((s
[i
] >> 11) & 0x1f);
2755 dst
[i
][GCOMP
] = EXPAND_5_8((s
[i
] >> 6) & 0x1f);
2756 dst
[i
][BCOMP
] = EXPAND_5_8((s
[i
] >> 1) & 0x1f);
2757 dst
[i
][ACOMP
] = EXPAND_1_8((s
[i
] ) & 0x01);
2762 unpack_ubyte_ARGB1555(const void *src
, GLubyte dst
[][4], GLuint n
)
2764 const GLushort
*s
= ((const GLushort
*) src
);
2766 for (i
= 0; i
< n
; i
++) {
2767 dst
[i
][RCOMP
] = EXPAND_5_8((s
[i
] >> 10) & 0x1f);
2768 dst
[i
][GCOMP
] = EXPAND_5_8((s
[i
] >> 5) & 0x1f);
2769 dst
[i
][BCOMP
] = EXPAND_5_8((s
[i
] >> 0) & 0x1f);
2770 dst
[i
][ACOMP
] = EXPAND_1_8((s
[i
] >> 15) & 0x01);
2775 unpack_ubyte_ARGB1555_REV(const void *src
, GLubyte dst
[][4], GLuint n
)
2777 /* Warning: this function does not match the current Mesa definition
2778 * of MESA_FORMAT_A1R5G5B5_UNORM.
2780 const GLushort
*s
= ((const GLushort
*) src
);
2782 for (i
= 0; i
< n
; i
++) {
2783 GLushort tmp
= (s
[i
] << 8) | (s
[i
] >> 8); /* byteswap */
2784 dst
[i
][RCOMP
] = EXPAND_5_8((tmp
>> 10) & 0x1f);
2785 dst
[i
][GCOMP
] = EXPAND_5_8((tmp
>> 5) & 0x1f);
2786 dst
[i
][BCOMP
] = EXPAND_5_8((tmp
>> 0) & 0x1f);
2787 dst
[i
][ACOMP
] = EXPAND_1_8((tmp
>> 15) & 0x01);
2792 unpack_ubyte_AL44(const void *src
, GLubyte dst
[][4], GLuint n
)
2794 const GLubyte
*s
= ((const GLubyte
*) src
);
2796 for (i
= 0; i
< n
; i
++) {
2799 dst
[i
][BCOMP
] = EXPAND_4_8(s
[i
] & 0xf);
2800 dst
[i
][ACOMP
] = EXPAND_4_8(s
[i
] >> 4);
2805 unpack_ubyte_AL88(const void *src
, GLubyte dst
[][4], GLuint n
)
2807 const GLushort
*s
= ((const GLushort
*) src
);
2809 for (i
= 0; i
< n
; i
++) {
2812 dst
[i
][BCOMP
] = EXPAND_4_8(s
[i
] & 0xff);
2813 dst
[i
][ACOMP
] = EXPAND_4_8(s
[i
] >> 8);
2818 unpack_ubyte_AL88_REV(const void *src
, GLubyte dst
[][4], GLuint n
)
2820 const GLushort
*s
= ((const GLushort
*) src
);
2822 for (i
= 0; i
< n
; i
++) {
2825 dst
[i
][BCOMP
] = EXPAND_4_8(s
[i
] >> 8);
2826 dst
[i
][ACOMP
] = EXPAND_4_8(s
[i
] & 0xff);
2831 unpack_ubyte_RGB332(const void *src
, GLubyte dst
[][4], GLuint n
)
2833 const GLubyte
*s
= ((const GLubyte
*) src
);
2835 for (i
= 0; i
< n
; i
++) {
2836 dst
[i
][RCOMP
] = EXPAND_3_8((s
[i
] >> 5) & 0x7);
2837 dst
[i
][GCOMP
] = EXPAND_3_8((s
[i
] >> 2) & 0x7);
2838 dst
[i
][BCOMP
] = EXPAND_2_8((s
[i
] ) & 0x3);
2839 dst
[i
][ACOMP
] = 0xff;
2844 unpack_ubyte_A8(const void *src
, GLubyte dst
[][4], GLuint n
)
2846 const GLubyte
*s
= ((const GLubyte
*) src
);
2848 for (i
= 0; i
< n
; i
++) {
2852 dst
[i
][ACOMP
] = s
[i
];
2857 unpack_ubyte_L8(const void *src
, GLubyte dst
[][4], GLuint n
)
2859 const GLubyte
*s
= ((const GLubyte
*) src
);
2861 for (i
= 0; i
< n
; i
++) {
2864 dst
[i
][BCOMP
] = s
[i
];
2865 dst
[i
][ACOMP
] = 0xff;
2871 unpack_ubyte_I8(const void *src
, GLubyte dst
[][4], GLuint n
)
2873 const GLubyte
*s
= ((const GLubyte
*) src
);
2875 for (i
= 0; i
< n
; i
++) {
2879 dst
[i
][ACOMP
] = s
[i
];
2884 unpack_ubyte_R8(const void *src
, GLubyte dst
[][4], GLuint n
)
2886 const GLubyte
*s
= ((const GLubyte
*) src
);
2888 for (i
= 0; i
< n
; i
++) {
2897 unpack_ubyte_GR88(const void *src
, GLubyte dst
[][4], GLuint n
)
2899 const GLushort
*s
= ((const GLushort
*) src
);
2901 for (i
= 0; i
< n
; i
++) {
2902 dst
[i
][RCOMP
] = s
[i
] & 0xff;
2903 dst
[i
][GCOMP
] = s
[i
] >> 8;
2905 dst
[i
][ACOMP
] = 0xff;
2910 unpack_ubyte_RG88(const void *src
, GLubyte dst
[][4], GLuint n
)
2912 const GLushort
*s
= ((const GLushort
*) src
);
2914 for (i
= 0; i
< n
; i
++) {
2915 dst
[i
][RCOMP
] = s
[i
] >> 8;
2916 dst
[i
][GCOMP
] = s
[i
] & 0xff;
2918 dst
[i
][ACOMP
] = 0xff;
2924 * Unpack rgba colors, returning as GLubyte values. This should usually
2925 * only be used for unpacking formats that use 8 bits or less per channel.
2928 _mesa_unpack_ubyte_rgba_row(mesa_format format
, GLuint n
,
2929 const void *src
, GLubyte dst
[][4])
2932 case MESA_FORMAT_A8B8G8R8_UNORM
:
2933 unpack_ubyte_RGBA8888(src
, dst
, n
);
2935 case MESA_FORMAT_R8G8B8A8_UNORM
:
2936 unpack_ubyte_RGBA8888_REV(src
, dst
, n
);
2938 case MESA_FORMAT_B8G8R8A8_UNORM
:
2939 unpack_ubyte_ARGB8888(src
, dst
, n
);
2941 case MESA_FORMAT_A8R8G8B8_UNORM
:
2942 unpack_ubyte_ARGB8888_REV(src
, dst
, n
);
2944 case MESA_FORMAT_X8B8G8R8_UNORM
:
2945 unpack_ubyte_RGBX8888(src
, dst
, n
);
2947 case MESA_FORMAT_R8G8B8X8_UNORM
:
2948 unpack_ubyte_RGBX8888_REV(src
, dst
, n
);
2950 case MESA_FORMAT_B8G8R8X8_UNORM
:
2951 unpack_ubyte_XRGB8888(src
, dst
, n
);
2953 case MESA_FORMAT_X8R8G8B8_UNORM
:
2954 unpack_ubyte_XRGB8888_REV(src
, dst
, n
);
2956 case MESA_FORMAT_BGR_UNORM8
:
2957 unpack_ubyte_RGB888(src
, dst
, n
);
2959 case MESA_FORMAT_RGB_UNORM8
:
2960 unpack_ubyte_BGR888(src
, dst
, n
);
2962 case MESA_FORMAT_B5G6R5_UNORM
:
2963 unpack_ubyte_RGB565(src
, dst
, n
);
2965 case MESA_FORMAT_R5G6B5_UNORM
:
2966 unpack_ubyte_RGB565_REV(src
, dst
, n
);
2968 case MESA_FORMAT_B4G4R4A4_UNORM
:
2969 unpack_ubyte_ARGB4444(src
, dst
, n
);
2971 case MESA_FORMAT_A4R4G4B4_UNORM
:
2972 unpack_ubyte_ARGB4444_REV(src
, dst
, n
);
2974 case MESA_FORMAT_A1B5G5R5_UNORM
:
2975 unpack_ubyte_RGBA5551(src
, dst
, n
);
2977 case MESA_FORMAT_B5G5R5A1_UNORM
:
2978 unpack_ubyte_ARGB1555(src
, dst
, n
);
2980 case MESA_FORMAT_A1R5G5B5_UNORM
:
2981 unpack_ubyte_ARGB1555_REV(src
, dst
, n
);
2983 case MESA_FORMAT_L4A4_UNORM
:
2984 unpack_ubyte_AL44(src
, dst
, n
);
2986 case MESA_FORMAT_L8A8_UNORM
:
2987 unpack_ubyte_AL88(src
, dst
, n
);
2989 case MESA_FORMAT_A8L8_UNORM
:
2990 unpack_ubyte_AL88_REV(src
, dst
, n
);
2992 case MESA_FORMAT_B2G3R3_UNORM
:
2993 unpack_ubyte_RGB332(src
, dst
, n
);
2995 case MESA_FORMAT_A_UNORM8
:
2996 unpack_ubyte_A8(src
, dst
, n
);
2998 case MESA_FORMAT_L_UNORM8
:
2999 unpack_ubyte_L8(src
, dst
, n
);
3001 case MESA_FORMAT_I_UNORM8
:
3002 unpack_ubyte_I8(src
, dst
, n
);
3004 case MESA_FORMAT_R_UNORM8
:
3005 unpack_ubyte_R8(src
, dst
, n
);
3007 case MESA_FORMAT_R8G8_UNORM
:
3008 unpack_ubyte_GR88(src
, dst
, n
);
3010 case MESA_FORMAT_G8R8_UNORM
:
3011 unpack_ubyte_RG88(src
, dst
, n
);
3014 /* get float values, convert to ubyte */
3016 GLfloat
*tmp
= malloc(n
* 4 * sizeof(GLfloat
));
3019 _mesa_unpack_rgba_row(format
, n
, src
, (GLfloat (*)[4]) tmp
);
3020 for (i
= 0; i
< n
; i
++) {
3021 UNCLAMPED_FLOAT_TO_UBYTE(dst
[i
][0], tmp
[i
*4+0]);
3022 UNCLAMPED_FLOAT_TO_UBYTE(dst
[i
][1], tmp
[i
*4+1]);
3023 UNCLAMPED_FLOAT_TO_UBYTE(dst
[i
][2], tmp
[i
*4+2]);
3024 UNCLAMPED_FLOAT_TO_UBYTE(dst
[i
][3], tmp
[i
*4+3]);
3034 /**********************************************************************/
3035 /* Unpack, returning GLuint colors */
3036 /**********************************************************************/
3039 unpack_int_rgba_RGBA_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3041 memcpy(dst
, src
, n
* 4 * sizeof(GLuint
));
3045 unpack_int_rgba_RGBA_UINT16(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
3049 for (i
= 0; i
< n
; i
++) {
3050 dst
[i
][0] = src
[i
* 4 + 0];
3051 dst
[i
][1] = src
[i
* 4 + 1];
3052 dst
[i
][2] = src
[i
* 4 + 2];
3053 dst
[i
][3] = src
[i
* 4 + 3];
3058 unpack_int_rgba_RGBA_INT16(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
3062 for (i
= 0; i
< n
; i
++) {
3063 dst
[i
][0] = src
[i
* 4 + 0];
3064 dst
[i
][1] = src
[i
* 4 + 1];
3065 dst
[i
][2] = src
[i
* 4 + 2];
3066 dst
[i
][3] = src
[i
* 4 + 3];
3071 unpack_int_rgba_RGBA_UINT8(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
3075 for (i
= 0; i
< n
; i
++) {
3076 dst
[i
][0] = src
[i
* 4 + 0];
3077 dst
[i
][1] = src
[i
* 4 + 1];
3078 dst
[i
][2] = src
[i
* 4 + 2];
3079 dst
[i
][3] = src
[i
* 4 + 3];
3084 unpack_int_rgba_RGBA_INT8(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3088 for (i
= 0; i
< n
; i
++) {
3089 dst
[i
][0] = src
[i
* 4 + 0];
3090 dst
[i
][1] = src
[i
* 4 + 1];
3091 dst
[i
][2] = src
[i
* 4 + 2];
3092 dst
[i
][3] = src
[i
* 4 + 3];
3097 unpack_int_rgba_ARGB8888(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3101 for (i
= 0; i
< n
; i
++) {
3102 dst
[i
][RCOMP
] = (GLubyte
) src
[i
* 4 + 2];
3103 dst
[i
][GCOMP
] = (GLubyte
) src
[i
* 4 + 1];
3104 dst
[i
][BCOMP
] = (GLubyte
) src
[i
* 4 + 0];
3105 dst
[i
][ACOMP
] = (GLubyte
) src
[i
* 4 + 3];
3110 unpack_int_rgba_XRGB8888(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3114 for (i
= 0; i
< n
; i
++) {
3115 dst
[i
][RCOMP
] = (GLubyte
) src
[i
* 4 + 2];
3116 dst
[i
][GCOMP
] = (GLubyte
) src
[i
* 4 + 1];
3117 dst
[i
][BCOMP
] = (GLubyte
) src
[i
* 4 + 0];
3118 dst
[i
][ACOMP
] = (GLubyte
) 0xff;
3123 unpack_int_rgba_RGB_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3127 for (i
= 0; i
< n
; i
++) {
3128 dst
[i
][0] = src
[i
* 3 + 0];
3129 dst
[i
][1] = src
[i
* 3 + 1];
3130 dst
[i
][2] = src
[i
* 3 + 2];
3136 unpack_int_rgba_RGB_UINT16(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
3140 for (i
= 0; i
< n
; i
++) {
3141 dst
[i
][0] = src
[i
* 3 + 0];
3142 dst
[i
][1] = src
[i
* 3 + 1];
3143 dst
[i
][2] = src
[i
* 3 + 2];
3149 unpack_int_rgba_RGB_INT16(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
3153 for (i
= 0; i
< n
; i
++) {
3154 dst
[i
][0] = src
[i
* 3 + 0];
3155 dst
[i
][1] = src
[i
* 3 + 1];
3156 dst
[i
][2] = src
[i
* 3 + 2];
3162 unpack_int_rgba_RGB_UINT8(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
3166 for (i
= 0; i
< n
; i
++) {
3167 dst
[i
][0] = src
[i
* 3 + 0];
3168 dst
[i
][1] = src
[i
* 3 + 1];
3169 dst
[i
][2] = src
[i
* 3 + 2];
3175 unpack_int_rgba_RGB_INT8(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3179 for (i
= 0; i
< n
; i
++) {
3180 dst
[i
][0] = src
[i
* 3 + 0];
3181 dst
[i
][1] = src
[i
* 3 + 1];
3182 dst
[i
][2] = src
[i
* 3 + 2];
3188 unpack_int_rgba_RG_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3192 for (i
= 0; i
< n
; i
++) {
3193 dst
[i
][0] = src
[i
* 2 + 0];
3194 dst
[i
][1] = src
[i
* 2 + 1];
3201 unpack_int_rgba_RG_UINT16(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
3205 for (i
= 0; i
< n
; i
++) {
3206 dst
[i
][0] = src
[i
* 2 + 0];
3207 dst
[i
][1] = src
[i
* 2 + 1];
3214 unpack_int_rgba_RG_INT16(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
3218 for (i
= 0; i
< n
; i
++) {
3219 dst
[i
][0] = src
[i
* 2 + 0];
3220 dst
[i
][1] = src
[i
* 2 + 1];
3227 unpack_int_rgba_RG_UINT8(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
3231 for (i
= 0; i
< n
; i
++) {
3232 dst
[i
][0] = src
[i
* 2 + 0];
3233 dst
[i
][1] = src
[i
* 2 + 1];
3240 unpack_int_rgba_RG_INT8(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3244 for (i
= 0; i
< n
; i
++) {
3245 dst
[i
][0] = src
[i
* 2 + 0];
3246 dst
[i
][1] = src
[i
* 2 + 1];
3253 unpack_int_rgba_R_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3257 for (i
= 0; i
< n
; i
++) {
3266 unpack_int_rgba_R_UINT16(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
3270 for (i
= 0; i
< n
; i
++) {
3279 unpack_int_rgba_R_INT16(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
3283 for (i
= 0; i
< n
; i
++) {
3292 unpack_int_rgba_R_UINT8(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
3296 for (i
= 0; i
< n
; i
++) {
3305 unpack_int_rgba_R_INT8(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3309 for (i
= 0; i
< n
; i
++) {
3318 unpack_int_rgba_ALPHA_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3322 for (i
= 0; i
< n
; i
++) {
3323 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = 0;
3329 unpack_int_rgba_ALPHA_UINT16(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
3333 for (i
= 0; i
< n
; i
++) {
3334 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = 0;
3340 unpack_int_rgba_ALPHA_INT16(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
3344 for (i
= 0; i
< n
; i
++) {
3345 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = 0;
3351 unpack_int_rgba_ALPHA_UINT8(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
3355 for (i
= 0; i
< n
; i
++) {
3356 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = 0;
3362 unpack_int_rgba_ALPHA_INT8(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3366 for (i
= 0; i
< n
; i
++) {
3367 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = 0;
3373 unpack_int_rgba_LUMINANCE_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3377 for (i
= 0; i
< n
; i
++) {
3378 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
];
3384 unpack_int_rgba_LUMINANCE_UINT16(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
3388 for (i
= 0; i
< n
; i
++) {
3389 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
];
3395 unpack_int_rgba_LUMINANCE_INT16(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
3399 for (i
= 0; i
< n
; i
++) {
3400 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
];
3406 unpack_int_rgba_LUMINANCE_UINT8(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
3410 for (i
= 0; i
< n
; i
++) {
3411 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
];
3417 unpack_int_rgba_LUMINANCE_INT8(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3421 for (i
= 0; i
< n
; i
++) {
3422 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
];
3429 unpack_int_rgba_LUMINANCE_ALPHA_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3433 for (i
= 0; i
< n
; i
++) {
3434 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
* 2 + 0];
3435 dst
[i
][3] = src
[i
* 2 + 1];
3440 unpack_int_rgba_LUMINANCE_ALPHA_UINT16(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
3444 for (i
= 0; i
< n
; i
++) {
3445 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
* 2 + 0];
3446 dst
[i
][3] = src
[i
* 2 + 1];
3451 unpack_int_rgba_LUMINANCE_ALPHA_INT16(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
3455 for (i
= 0; i
< n
; i
++) {
3456 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
* 2 + 0];
3457 dst
[i
][3] = src
[i
* 2 + 1];
3462 unpack_int_rgba_LUMINANCE_ALPHA_UINT8(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
3466 for (i
= 0; i
< n
; i
++) {
3467 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
* 2 + 0];
3468 dst
[i
][3] = src
[i
* 2 + 1];
3473 unpack_int_rgba_LUMINANCE_ALPHA_INT8(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3477 for (i
= 0; i
< n
; i
++) {
3478 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
* 2 + 0];
3479 dst
[i
][3] = src
[i
* 2 + 1];
3484 unpack_int_rgba_INTENSITY_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3488 for (i
= 0; i
< n
; i
++) {
3489 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = dst
[i
][3] = src
[i
];
3494 unpack_int_rgba_INTENSITY_UINT16(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
3498 for (i
= 0; i
< n
; i
++) {
3499 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = dst
[i
][3] = src
[i
];
3504 unpack_int_rgba_INTENSITY_INT16(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
3508 for (i
= 0; i
< n
; i
++) {
3509 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = dst
[i
][3] = src
[i
];
3514 unpack_int_rgba_INTENSITY_UINT8(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
3518 for (i
= 0; i
< n
; i
++) {
3519 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = dst
[i
][3] = src
[i
];
3524 unpack_int_rgba_INTENSITY_INT8(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3528 for (i
= 0; i
< n
; i
++) {
3529 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = dst
[i
][3] = src
[i
];
3534 unpack_int_rgba_ARGB2101010_UINT(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3538 for (i
= 0; i
< n
; i
++) {
3539 GLuint tmp
= src
[i
];
3540 dst
[i
][0] = (tmp
>> 20) & 0x3ff;
3541 dst
[i
][1] = (tmp
>> 10) & 0x3ff;
3542 dst
[i
][2] = (tmp
>> 0) & 0x3ff;
3543 dst
[i
][3] = (tmp
>> 30) & 0x3;
3548 unpack_int_rgba_ABGR2101010_UINT(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3552 for (i
= 0; i
< n
; i
++) {
3553 GLuint tmp
= src
[i
];
3554 dst
[i
][0] = (tmp
>> 0) & 0x3ff;
3555 dst
[i
][1] = (tmp
>> 10) & 0x3ff;
3556 dst
[i
][2] = (tmp
>> 20) & 0x3ff;
3557 dst
[i
][3] = (tmp
>> 30) & 0x3;
3562 unpack_int_rgba_ARGB2101010(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3566 for (i
= 0; i
< n
; i
++) {
3567 GLuint tmp
= src
[i
];
3568 dst
[i
][0] = (tmp
>> 20) & 0x3ff;
3569 dst
[i
][1] = (tmp
>> 10) & 0x3ff;
3570 dst
[i
][2] = (tmp
>> 0) & 0x3ff;
3571 dst
[i
][3] = (tmp
>> 30) & 0x3;
3576 unpack_int_rgba_XBGR8888_UINT(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
3580 for (i
= 0; i
< n
; i
++) {
3581 dst
[i
][0] = src
[i
* 4 + 0];
3582 dst
[i
][1] = src
[i
* 4 + 1];
3583 dst
[i
][2] = src
[i
* 4 + 2];
3589 unpack_int_rgba_XBGR8888_SINT(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3593 for (i
= 0; i
< n
; i
++) {
3594 dst
[i
][0] = src
[i
* 4 + 0];
3595 dst
[i
][1] = src
[i
* 4 + 1];
3596 dst
[i
][2] = src
[i
* 4 + 2];
3602 unpack_int_rgba_XBGR16161616_UINT(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
3606 for (i
= 0; i
< n
; i
++) {
3607 dst
[i
][0] = src
[i
* 4 + 0];
3608 dst
[i
][1] = src
[i
* 4 + 1];
3609 dst
[i
][2] = src
[i
* 4 + 2];
3615 unpack_int_rgba_XBGR16161616_SINT(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
3619 for (i
= 0; i
< n
; i
++) {
3620 dst
[i
][0] = src
[i
* 4 + 0];
3621 dst
[i
][1] = src
[i
* 4 + 1];
3622 dst
[i
][2] = src
[i
* 4 + 2];
3628 unpack_int_rgba_XBGR32323232_UINT(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3632 for (i
= 0; i
< n
; i
++) {
3633 dst
[i
][0] = src
[i
* 4 + 0];
3634 dst
[i
][1] = src
[i
* 4 + 1];
3635 dst
[i
][2] = src
[i
* 4 + 2];
3641 unpack_int_rgba_ABGR2101010(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3645 for (i
= 0; i
< n
; i
++) {
3646 GLuint tmp
= src
[i
];
3647 dst
[i
][0] = (tmp
>> 0) & 0x3ff;
3648 dst
[i
][1] = (tmp
>> 10) & 0x3ff;
3649 dst
[i
][2] = (tmp
>> 20) & 0x3ff;
3650 dst
[i
][3] = (tmp
>> 30) & 0x3;
3655 _mesa_unpack_uint_rgba_row(mesa_format format
, GLuint n
,
3656 const void *src
, GLuint dst
[][4])
3659 /* Since there won't be any sign extension happening, there's no need to
3660 * make separate paths for 32-bit-to-32-bit integer unpack.
3662 case MESA_FORMAT_RGBA_UINT32
:
3663 case MESA_FORMAT_RGBA_SINT32
:
3664 unpack_int_rgba_RGBA_UINT32(src
, dst
, n
);
3667 case MESA_FORMAT_RGBA_UINT16
:
3668 unpack_int_rgba_RGBA_UINT16(src
, dst
, n
);
3670 case MESA_FORMAT_RGBA_SINT16
:
3671 unpack_int_rgba_RGBA_INT16(src
, dst
, n
);
3674 case MESA_FORMAT_RGBA_UINT8
:
3675 unpack_int_rgba_RGBA_UINT8(src
, dst
, n
);
3677 case MESA_FORMAT_RGBA_SINT8
:
3678 unpack_int_rgba_RGBA_INT8(src
, dst
, n
);
3681 case MESA_FORMAT_B8G8R8A8_UNORM
:
3682 unpack_int_rgba_ARGB8888(src
, dst
, n
);
3685 case MESA_FORMAT_B8G8R8X8_UNORM
:
3686 unpack_int_rgba_XRGB8888(src
, dst
, n
);
3689 case MESA_FORMAT_RGB_UINT32
:
3690 case MESA_FORMAT_RGB_SINT32
:
3691 unpack_int_rgba_RGB_UINT32(src
, dst
, n
);
3694 case MESA_FORMAT_RGB_UINT16
:
3695 unpack_int_rgba_RGB_UINT16(src
, dst
, n
);
3697 case MESA_FORMAT_RGB_SINT16
:
3698 unpack_int_rgba_RGB_INT16(src
, dst
, n
);
3701 case MESA_FORMAT_RGB_UINT8
:
3702 unpack_int_rgba_RGB_UINT8(src
, dst
, n
);
3704 case MESA_FORMAT_RGB_SINT8
:
3705 unpack_int_rgba_RGB_INT8(src
, dst
, n
);
3708 case MESA_FORMAT_RG_UINT32
:
3709 case MESA_FORMAT_RG_SINT32
:
3710 unpack_int_rgba_RG_UINT32(src
, dst
, n
);
3713 case MESA_FORMAT_RG_UINT16
:
3714 unpack_int_rgba_RG_UINT16(src
, dst
, n
);
3716 case MESA_FORMAT_RG_SINT16
:
3717 unpack_int_rgba_RG_INT16(src
, dst
, n
);
3720 case MESA_FORMAT_RG_UINT8
:
3721 unpack_int_rgba_RG_UINT8(src
, dst
, n
);
3723 case MESA_FORMAT_RG_SINT8
:
3724 unpack_int_rgba_RG_INT8(src
, dst
, n
);
3727 case MESA_FORMAT_R_UINT32
:
3728 case MESA_FORMAT_R_SINT32
:
3729 unpack_int_rgba_R_UINT32(src
, dst
, n
);
3732 case MESA_FORMAT_R_UINT16
:
3733 unpack_int_rgba_R_UINT16(src
, dst
, n
);
3735 case MESA_FORMAT_R_SINT16
:
3736 unpack_int_rgba_R_INT16(src
, dst
, n
);
3739 case MESA_FORMAT_R_UINT8
:
3740 unpack_int_rgba_R_UINT8(src
, dst
, n
);
3742 case MESA_FORMAT_R_SINT8
:
3743 unpack_int_rgba_R_INT8(src
, dst
, n
);
3746 case MESA_FORMAT_A_UINT32
:
3747 case MESA_FORMAT_A_SINT32
:
3748 unpack_int_rgba_ALPHA_UINT32(src
, dst
, n
);
3751 case MESA_FORMAT_A_UINT16
:
3752 unpack_int_rgba_ALPHA_UINT16(src
, dst
, n
);
3754 case MESA_FORMAT_A_SINT16
:
3755 unpack_int_rgba_ALPHA_INT16(src
, dst
, n
);
3758 case MESA_FORMAT_A_UINT8
:
3759 unpack_int_rgba_ALPHA_UINT8(src
, dst
, n
);
3761 case MESA_FORMAT_A_SINT8
:
3762 unpack_int_rgba_ALPHA_INT8(src
, dst
, n
);
3765 case MESA_FORMAT_L_UINT32
:
3766 case MESA_FORMAT_L_SINT32
:
3767 unpack_int_rgba_LUMINANCE_UINT32(src
, dst
, n
);
3769 case MESA_FORMAT_L_UINT16
:
3770 unpack_int_rgba_LUMINANCE_UINT16(src
, dst
, n
);
3772 case MESA_FORMAT_L_SINT16
:
3773 unpack_int_rgba_LUMINANCE_INT16(src
, dst
, n
);
3776 case MESA_FORMAT_L_UINT8
:
3777 unpack_int_rgba_LUMINANCE_UINT8(src
, dst
, n
);
3779 case MESA_FORMAT_L_SINT8
:
3780 unpack_int_rgba_LUMINANCE_INT8(src
, dst
, n
);
3783 case MESA_FORMAT_LA_UINT32
:
3784 case MESA_FORMAT_LA_SINT32
:
3785 unpack_int_rgba_LUMINANCE_ALPHA_UINT32(src
, dst
, n
);
3788 case MESA_FORMAT_LA_UINT16
:
3789 unpack_int_rgba_LUMINANCE_ALPHA_UINT16(src
, dst
, n
);
3791 case MESA_FORMAT_LA_SINT16
:
3792 unpack_int_rgba_LUMINANCE_ALPHA_INT16(src
, dst
, n
);
3795 case MESA_FORMAT_LA_UINT8
:
3796 unpack_int_rgba_LUMINANCE_ALPHA_UINT8(src
, dst
, n
);
3798 case MESA_FORMAT_LA_SINT8
:
3799 unpack_int_rgba_LUMINANCE_ALPHA_INT8(src
, dst
, n
);
3802 case MESA_FORMAT_I_UINT32
:
3803 case MESA_FORMAT_I_SINT32
:
3804 unpack_int_rgba_INTENSITY_UINT32(src
, dst
, n
);
3807 case MESA_FORMAT_I_UINT16
:
3808 unpack_int_rgba_INTENSITY_UINT16(src
, dst
, n
);
3810 case MESA_FORMAT_I_SINT16
:
3811 unpack_int_rgba_INTENSITY_INT16(src
, dst
, n
);
3814 case MESA_FORMAT_I_UINT8
:
3815 unpack_int_rgba_INTENSITY_UINT8(src
, dst
, n
);
3817 case MESA_FORMAT_I_SINT8
:
3818 unpack_int_rgba_INTENSITY_INT8(src
, dst
, n
);
3821 case MESA_FORMAT_B10G10R10A2_UINT
:
3822 unpack_int_rgba_ARGB2101010_UINT(src
, dst
, n
);
3825 case MESA_FORMAT_R10G10B10A2_UINT
:
3826 unpack_int_rgba_ABGR2101010_UINT(src
, dst
, n
);
3829 case MESA_FORMAT_B10G10R10A2_UNORM
:
3830 unpack_int_rgba_ARGB2101010(src
, dst
, n
);
3833 case MESA_FORMAT_RGBX_UINT8
:
3834 unpack_int_rgba_XBGR8888_UINT(src
, dst
, n
);
3837 case MESA_FORMAT_RGBX_SINT8
:
3838 unpack_int_rgba_XBGR8888_SINT(src
, dst
, n
);
3841 case MESA_FORMAT_RGBX_UINT16
:
3842 unpack_int_rgba_XBGR16161616_UINT(src
, dst
, n
);
3845 case MESA_FORMAT_RGBX_SINT16
:
3846 unpack_int_rgba_XBGR16161616_SINT(src
, dst
, n
);
3849 case MESA_FORMAT_RGBX_UINT32
:
3850 case MESA_FORMAT_RGBX_SINT32
:
3851 unpack_int_rgba_XBGR32323232_UINT(src
, dst
, n
);
3854 case MESA_FORMAT_R10G10B10A2_UNORM
:
3855 unpack_int_rgba_ABGR2101010(src
, dst
, n
);
3859 _mesa_problem(NULL
, "%s: bad format %s", __FUNCTION__
,
3860 _mesa_get_format_name(format
));
3866 * Unpack a 2D rect of pixels returning float RGBA colors.
3867 * \param format the source image format
3868 * \param src start address of the source image
3869 * \param srcRowStride source image row stride in bytes
3870 * \param dst start address of the dest image
3871 * \param dstRowStride dest image row stride in bytes
3872 * \param x source image start X pos
3873 * \param y source image start Y pos
3874 * \param width width of rect region to convert
3875 * \param height height of rect region to convert
3878 _mesa_unpack_rgba_block(mesa_format format
,
3879 const void *src
, GLint srcRowStride
,
3880 GLfloat dst
[][4], GLint dstRowStride
,
3881 GLuint x
, GLuint y
, GLuint width
, GLuint height
)
3883 unpack_rgba_func unpack
= get_unpack_rgba_function(format
);
3884 const GLuint srcPixStride
= _mesa_get_format_bytes(format
);
3885 const GLuint dstPixStride
= 4 * sizeof(GLfloat
);
3886 const GLubyte
*srcRow
;
3890 /* XXX needs to be fixed for compressed formats */
3892 srcRow
= ((const GLubyte
*) src
) + srcRowStride
* y
+ srcPixStride
* x
;
3893 dstRow
= ((GLubyte
*) dst
) + dstRowStride
* y
+ dstPixStride
* x
;
3895 for (i
= 0; i
< height
; i
++) {
3896 unpack(srcRow
, (GLfloat (*)[4]) dstRow
, width
);
3898 dstRow
+= dstRowStride
;
3899 srcRow
+= srcRowStride
;
3906 typedef void (*unpack_float_z_func
)(GLuint n
, const void *src
, GLfloat
*dst
);
3909 unpack_float_z_Z24_X8(GLuint n
, const void *src
, GLfloat
*dst
)
3911 /* only return Z, not stencil data */
3912 const GLuint
*s
= ((const GLuint
*) src
);
3913 const GLdouble scale
= 1.0 / (GLdouble
) 0xffffff;
3915 for (i
= 0; i
< n
; i
++) {
3916 dst
[i
] = (GLfloat
) ((s
[i
] >> 8) * scale
);
3917 ASSERT(dst
[i
] >= 0.0F
);
3918 ASSERT(dst
[i
] <= 1.0F
);
3923 unpack_float_z_X8_Z24(GLuint n
, const void *src
, GLfloat
*dst
)
3925 /* only return Z, not stencil data */
3926 const GLuint
*s
= ((const GLuint
*) src
);
3927 const GLdouble scale
= 1.0 / (GLdouble
) 0xffffff;
3929 for (i
= 0; i
< n
; i
++) {
3930 dst
[i
] = (GLfloat
) ((s
[i
] & 0x00ffffff) * scale
);
3931 ASSERT(dst
[i
] >= 0.0F
);
3932 ASSERT(dst
[i
] <= 1.0F
);
3937 unpack_float_z_Z16(GLuint n
, const void *src
, GLfloat
*dst
)
3939 const GLushort
*s
= ((const GLushort
*) src
);
3941 for (i
= 0; i
< n
; i
++) {
3942 dst
[i
] = s
[i
] * (1.0F
/ 65535.0F
);
3947 unpack_float_z_Z32(GLuint n
, const void *src
, GLfloat
*dst
)
3949 const GLuint
*s
= ((const GLuint
*) src
);
3951 for (i
= 0; i
< n
; i
++) {
3952 dst
[i
] = s
[i
] * (1.0F
/ 0xffffffff);
3957 unpack_float_z_Z32F(GLuint n
, const void *src
, GLfloat
*dst
)
3959 memcpy(dst
, src
, n
* sizeof(float));
3963 unpack_float_z_Z32X24S8(GLuint n
, const void *src
, GLfloat
*dst
)
3965 const struct z32f_x24s8
*s
= (const struct z32f_x24s8
*) src
;
3967 for (i
= 0; i
< n
; i
++) {
3976 * The returned values will always be in the range [0.0, 1.0].
3979 _mesa_unpack_float_z_row(mesa_format format
, GLuint n
,
3980 const void *src
, GLfloat
*dst
)
3982 unpack_float_z_func unpack
;
3985 case MESA_FORMAT_S8_UINT_Z24_UNORM
:
3986 case MESA_FORMAT_X8Z24_UNORM
:
3987 unpack
= unpack_float_z_Z24_X8
;
3989 case MESA_FORMAT_Z24_UNORM_X8_UINT
:
3990 case MESA_FORMAT_Z24_UNORM_S8_UINT
:
3991 unpack
= unpack_float_z_X8_Z24
;
3993 case MESA_FORMAT_Z_UNORM16
:
3994 unpack
= unpack_float_z_Z16
;
3996 case MESA_FORMAT_Z_UNORM32
:
3997 unpack
= unpack_float_z_Z32
;
3999 case MESA_FORMAT_Z_FLOAT32
:
4000 unpack
= unpack_float_z_Z32F
;
4002 case MESA_FORMAT_Z32_FLOAT_S8X24_UINT
:
4003 unpack
= unpack_float_z_Z32X24S8
;
4006 _mesa_problem(NULL
, "bad format %s in _mesa_unpack_float_z_row",
4007 _mesa_get_format_name(format
));
4011 unpack(n
, src
, dst
);
4016 typedef void (*unpack_uint_z_func
)(const void *src
, GLuint
*dst
, GLuint n
);
4019 unpack_uint_z_Z24_X8(const void *src
, GLuint
*dst
, GLuint n
)
4021 /* only return Z, not stencil data */
4022 const GLuint
*s
= ((const GLuint
*) src
);
4024 for (i
= 0; i
< n
; i
++) {
4025 dst
[i
] = (s
[i
] & 0xffffff00) | (s
[i
] >> 24);
4030 unpack_uint_z_X8_Z24(const void *src
, GLuint
*dst
, GLuint n
)
4032 /* only return Z, not stencil data */
4033 const GLuint
*s
= ((const GLuint
*) src
);
4035 for (i
= 0; i
< n
; i
++) {
4036 dst
[i
] = (s
[i
] << 8) | ((s
[i
] >> 16) & 0xff);
4041 unpack_uint_z_Z16(const void *src
, GLuint
*dst
, GLuint n
)
4043 const GLushort
*s
= ((const GLushort
*)src
);
4045 for (i
= 0; i
< n
; i
++) {
4046 dst
[i
] = (s
[i
] << 16) | s
[i
];
4051 unpack_uint_z_Z32(const void *src
, GLuint
*dst
, GLuint n
)
4053 memcpy(dst
, src
, n
* sizeof(GLuint
));
4057 unpack_uint_z_Z32_FLOAT(const void *src
, GLuint
*dst
, GLuint n
)
4059 const float *s
= (const float *)src
;
4061 for (i
= 0; i
< n
; i
++) {
4062 dst
[i
] = FLOAT_TO_UINT(CLAMP(s
[i
], 0.0F
, 1.0F
));
4067 unpack_uint_z_Z32_FLOAT_X24S8(const void *src
, GLuint
*dst
, GLuint n
)
4069 const struct z32f_x24s8
*s
= (const struct z32f_x24s8
*) src
;
4072 for (i
= 0; i
< n
; i
++) {
4073 dst
[i
] = FLOAT_TO_UINT(CLAMP(s
[i
].z
, 0.0F
, 1.0F
));
4080 * The returned values will always be in the range [0, 0xffffffff].
4083 _mesa_unpack_uint_z_row(mesa_format format
, GLuint n
,
4084 const void *src
, GLuint
*dst
)
4086 unpack_uint_z_func unpack
;
4087 const GLubyte
*srcPtr
= (GLubyte
*) src
;
4090 case MESA_FORMAT_S8_UINT_Z24_UNORM
:
4091 case MESA_FORMAT_X8Z24_UNORM
:
4092 unpack
= unpack_uint_z_Z24_X8
;
4094 case MESA_FORMAT_Z24_UNORM_X8_UINT
:
4095 case MESA_FORMAT_Z24_UNORM_S8_UINT
:
4096 unpack
= unpack_uint_z_X8_Z24
;
4098 case MESA_FORMAT_Z_UNORM16
:
4099 unpack
= unpack_uint_z_Z16
;
4101 case MESA_FORMAT_Z_UNORM32
:
4102 unpack
= unpack_uint_z_Z32
;
4104 case MESA_FORMAT_Z_FLOAT32
:
4105 unpack
= unpack_uint_z_Z32_FLOAT
;
4107 case MESA_FORMAT_Z32_FLOAT_S8X24_UINT
:
4108 unpack
= unpack_uint_z_Z32_FLOAT_X24S8
;
4111 _mesa_problem(NULL
, "bad format %s in _mesa_unpack_uint_z_row",
4112 _mesa_get_format_name(format
));
4116 unpack(srcPtr
, dst
, n
);
4121 unpack_ubyte_s_S8(const void *src
, GLubyte
*dst
, GLuint n
)
4123 memcpy(dst
, src
, n
);
4127 unpack_ubyte_s_Z24_S8(const void *src
, GLubyte
*dst
, GLuint n
)
4130 const GLuint
*src32
= src
;
4132 for (i
= 0; i
< n
; i
++)
4133 dst
[i
] = src32
[i
] & 0xff;
4137 unpack_ubyte_s_S8_Z24(const void *src
, GLubyte
*dst
, GLuint n
)
4140 const GLuint
*src32
= src
;
4142 for (i
= 0; i
< n
; i
++)
4143 dst
[i
] = src32
[i
] >> 24;
4147 unpack_ubyte_s_Z32_FLOAT_X24S8(const void *src
, GLubyte
*dst
, GLuint n
)
4150 const struct z32f_x24s8
*s
= (const struct z32f_x24s8
*) src
;
4152 for (i
= 0; i
< n
; i
++)
4153 dst
[i
] = s
[i
].x24s8
& 0xff;
4157 _mesa_unpack_ubyte_stencil_row(mesa_format format
, GLuint n
,
4158 const void *src
, GLubyte
*dst
)
4161 case MESA_FORMAT_S_UINT8
:
4162 unpack_ubyte_s_S8(src
, dst
, n
);
4164 case MESA_FORMAT_S8_UINT_Z24_UNORM
:
4165 unpack_ubyte_s_Z24_S8(src
, dst
, n
);
4167 case MESA_FORMAT_Z24_UNORM_X8_UINT
:
4168 unpack_ubyte_s_S8_Z24(src
, dst
, n
);
4170 case MESA_FORMAT_Z32_FLOAT_S8X24_UINT
:
4171 unpack_ubyte_s_Z32_FLOAT_X24S8(src
, dst
, n
);
4174 _mesa_problem(NULL
, "bad format %s in _mesa_unpack_ubyte_s_row",
4175 _mesa_get_format_name(format
));
4181 unpack_uint_24_8_depth_stencil_S8_Z24(const GLuint
*src
, GLuint
*dst
, GLuint n
)
4185 for (i
= 0; i
< n
; i
++) {
4186 GLuint val
= src
[i
];
4187 dst
[i
] = val
>> 24 | val
<< 8;
4192 unpack_uint_24_8_depth_stencil_Z24_S8(const GLuint
*src
, GLuint
*dst
, GLuint n
)
4194 memcpy(dst
, src
, n
* 4);
4198 _mesa_unpack_uint_24_8_depth_stencil_row(mesa_format format
, GLuint n
,
4199 const void *src
, GLuint
*dst
)
4202 case MESA_FORMAT_S8_UINT_Z24_UNORM
:
4203 unpack_uint_24_8_depth_stencil_Z24_S8(src
, dst
, n
);
4205 case MESA_FORMAT_Z24_UNORM_X8_UINT
:
4206 unpack_uint_24_8_depth_stencil_S8_Z24(src
, dst
, n
);
4210 "bad format %s in _mesa_unpack_uint_24_8_depth_stencil_row",
4211 _mesa_get_format_name(format
));