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_X24S8 */
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 const GLushort
*s
= ((const GLushort
*) src
);
239 for (i
= 0; i
< n
; i
++) {
240 GLuint t
= (s
[i
] >> 8) | (s
[i
] << 8); /* byte swap */
241 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( ((t
>> 8) & 0xf8) | ((t
>> 13) & 0x7) );
242 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( ((t
>> 3) & 0xfc) | ((t
>> 9) & 0x3) );
243 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( ((t
<< 3) & 0xf8) | ((t
>> 2) & 0x7) );
244 dst
[i
][ACOMP
] = 1.0F
;
249 unpack_ARGB4444(const void *src
, GLfloat dst
[][4], GLuint n
)
251 const GLushort
*s
= ((const GLushort
*) src
);
253 for (i
= 0; i
< n
; i
++) {
254 dst
[i
][RCOMP
] = ((s
[i
] >> 8) & 0xf) * (1.0F
/ 15.0F
);
255 dst
[i
][GCOMP
] = ((s
[i
] >> 4) & 0xf) * (1.0F
/ 15.0F
);
256 dst
[i
][BCOMP
] = ((s
[i
] ) & 0xf) * (1.0F
/ 15.0F
);
257 dst
[i
][ACOMP
] = ((s
[i
] >> 12) & 0xf) * (1.0F
/ 15.0F
);
262 unpack_ARGB4444_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
264 const GLushort
*s
= ((const GLushort
*) src
);
266 for (i
= 0; i
< n
; i
++) {
267 dst
[i
][RCOMP
] = ((s
[i
] ) & 0xf) * (1.0F
/ 15.0F
);
268 dst
[i
][GCOMP
] = ((s
[i
] >> 12) & 0xf) * (1.0F
/ 15.0F
);
269 dst
[i
][BCOMP
] = ((s
[i
] >> 8) & 0xf) * (1.0F
/ 15.0F
);
270 dst
[i
][ACOMP
] = ((s
[i
] >> 4) & 0xf) * (1.0F
/ 15.0F
);
275 unpack_RGBA5551(const void *src
, GLfloat dst
[][4], GLuint n
)
277 const GLushort
*s
= ((const GLushort
*) src
);
279 for (i
= 0; i
< n
; i
++) {
280 dst
[i
][RCOMP
] = ((s
[i
] >> 11) & 0x1f) * (1.0F
/ 31.0F
);
281 dst
[i
][GCOMP
] = ((s
[i
] >> 6) & 0x1f) * (1.0F
/ 31.0F
);
282 dst
[i
][BCOMP
] = ((s
[i
] >> 1) & 0x1f) * (1.0F
/ 31.0F
);
283 dst
[i
][ACOMP
] = ((s
[i
] ) & 0x01) * 1.0F
;
288 unpack_ARGB1555(const void *src
, GLfloat dst
[][4], GLuint n
)
290 const GLushort
*s
= ((const GLushort
*) src
);
292 for (i
= 0; i
< n
; i
++) {
293 dst
[i
][RCOMP
] = ((s
[i
] >> 10) & 0x1f) * (1.0F
/ 31.0F
);
294 dst
[i
][GCOMP
] = ((s
[i
] >> 5) & 0x1f) * (1.0F
/ 31.0F
);
295 dst
[i
][BCOMP
] = ((s
[i
] >> 0) & 0x1f) * (1.0F
/ 31.0F
);
296 dst
[i
][ACOMP
] = ((s
[i
] >> 15) & 0x01) * 1.0F
;
301 unpack_ARGB1555_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
303 const GLushort
*s
= ((const GLushort
*) src
);
305 for (i
= 0; i
< n
; i
++) {
306 GLushort tmp
= (s
[i
] << 8) | (s
[i
] >> 8); /* byteswap */
307 dst
[i
][RCOMP
] = ((tmp
>> 10) & 0x1f) * (1.0F
/ 31.0F
);
308 dst
[i
][GCOMP
] = ((tmp
>> 5) & 0x1f) * (1.0F
/ 31.0F
);
309 dst
[i
][BCOMP
] = ((tmp
>> 0) & 0x1f) * (1.0F
/ 31.0F
);
310 dst
[i
][ACOMP
] = ((tmp
>> 15) & 0x01) * 1.0F
;
315 unpack_AL44(const void *src
, GLfloat dst
[][4], GLuint n
)
317 const GLubyte
*s
= ((const GLubyte
*) src
);
319 for (i
= 0; i
< n
; i
++) {
322 dst
[i
][BCOMP
] = (s
[i
] & 0xf) * (1.0F
/ 15.0F
);
323 dst
[i
][ACOMP
] = ((s
[i
] >> 4) & 0xf) * (1.0F
/ 15.0F
);
328 unpack_AL88(const void *src
, GLfloat dst
[][4], GLuint n
)
330 const GLushort
*s
= ((const GLushort
*) src
);
332 for (i
= 0; i
< n
; i
++) {
335 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( s
[i
] & 0xff );
336 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 8 );
341 unpack_AL88_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
343 const GLushort
*s
= ((const GLushort
*) src
);
345 for (i
= 0; i
< n
; i
++) {
348 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 8 );
349 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( s
[i
] & 0xff );
354 unpack_AL1616(const void *src
, GLfloat dst
[][4], GLuint n
)
356 const GLuint
*s
= ((const GLuint
*) src
);
358 for (i
= 0; i
< n
; i
++) {
361 dst
[i
][BCOMP
] = USHORT_TO_FLOAT( s
[i
] & 0xffff );
362 dst
[i
][ACOMP
] = USHORT_TO_FLOAT( s
[i
] >> 16 );
367 unpack_AL1616_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
369 const GLuint
*s
= ((const GLuint
*) src
);
371 for (i
= 0; i
< n
; i
++) {
374 dst
[i
][BCOMP
] = USHORT_TO_FLOAT( s
[i
] >> 16 );
375 dst
[i
][ACOMP
] = USHORT_TO_FLOAT( s
[i
] & 0xffff );
380 unpack_RGB332(const void *src
, GLfloat dst
[][4], GLuint n
)
382 const GLubyte
*s
= ((const GLubyte
*) src
);
384 for (i
= 0; i
< n
; i
++) {
385 dst
[i
][RCOMP
] = ((s
[i
] >> 5) & 0x7) * (1.0F
/ 7.0F
);
386 dst
[i
][GCOMP
] = ((s
[i
] >> 2) & 0x7) * (1.0F
/ 7.0F
);
387 dst
[i
][BCOMP
] = ((s
[i
] ) & 0x3) * (1.0F
/ 3.0F
);
388 dst
[i
][ACOMP
] = 1.0F
;
394 unpack_A8(const void *src
, GLfloat dst
[][4], GLuint n
)
396 const GLubyte
*s
= ((const GLubyte
*) src
);
398 for (i
= 0; i
< n
; i
++) {
401 dst
[i
][BCOMP
] = 0.0F
;
402 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT(s
[i
]);
407 unpack_A16(const void *src
, GLfloat dst
[][4], GLuint n
)
409 const GLushort
*s
= ((const GLushort
*) src
);
411 for (i
= 0; i
< n
; i
++) {
414 dst
[i
][BCOMP
] = 0.0F
;
415 dst
[i
][ACOMP
] = USHORT_TO_FLOAT(s
[i
]);
420 unpack_L8(const void *src
, GLfloat dst
[][4], GLuint n
)
422 const GLubyte
*s
= ((const GLubyte
*) src
);
424 for (i
= 0; i
< n
; i
++) {
427 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT(s
[i
]);
428 dst
[i
][ACOMP
] = 1.0F
;
433 unpack_L16(const void *src
, GLfloat dst
[][4], GLuint n
)
435 const GLushort
*s
= ((const GLushort
*) src
);
437 for (i
= 0; i
< n
; i
++) {
440 dst
[i
][BCOMP
] = USHORT_TO_FLOAT(s
[i
]);
441 dst
[i
][ACOMP
] = 1.0F
;
446 unpack_I8(const void *src
, GLfloat dst
[][4], GLuint n
)
448 const GLubyte
*s
= ((const GLubyte
*) src
);
450 for (i
= 0; i
< n
; i
++) {
454 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT(s
[i
]);
459 unpack_I16(const void *src
, GLfloat dst
[][4], GLuint n
)
461 const GLushort
*s
= ((const GLushort
*) src
);
463 for (i
= 0; i
< n
; i
++) {
467 dst
[i
][ACOMP
] = USHORT_TO_FLOAT(s
[i
]);
472 unpack_YCBCR(const void *src
, GLfloat dst
[][4], GLuint n
)
475 for (i
= 0; i
< n
; i
++) {
476 const GLushort
*src0
= ((const GLushort
*) src
) + i
* 2; /* even */
477 const GLushort
*src1
= src0
+ 1; /* odd */
478 const GLubyte y0
= (*src0
>> 8) & 0xff; /* luminance */
479 const GLubyte cb
= *src0
& 0xff; /* chroma U */
480 const GLubyte y1
= (*src1
>> 8) & 0xff; /* luminance */
481 const GLubyte cr
= *src1
& 0xff; /* chroma V */
482 const GLubyte y
= (i
& 1) ? y1
: y0
; /* choose even/odd luminance */
483 GLfloat r
= 1.164F
* (y
- 16) + 1.596F
* (cr
- 128);
484 GLfloat g
= 1.164F
* (y
- 16) - 0.813F
* (cr
- 128) - 0.391F
* (cb
- 128);
485 GLfloat b
= 1.164F
* (y
- 16) + 2.018F
* (cb
- 128);
486 r
*= (1.0F
/ 255.0F
);
487 g
*= (1.0F
/ 255.0F
);
488 b
*= (1.0F
/ 255.0F
);
489 dst
[i
][RCOMP
] = CLAMP(r
, 0.0F
, 1.0F
);
490 dst
[i
][GCOMP
] = CLAMP(g
, 0.0F
, 1.0F
);
491 dst
[i
][BCOMP
] = CLAMP(b
, 0.0F
, 1.0F
);
492 dst
[i
][ACOMP
] = 1.0F
;
497 unpack_YCBCR_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
500 for (i
= 0; i
< n
; i
++) {
501 const GLushort
*src0
= ((const GLushort
*) src
) + i
* 2; /* even */
502 const GLushort
*src1
= src0
+ 1; /* odd */
503 const GLubyte y0
= *src0
& 0xff; /* luminance */
504 const GLubyte cr
= (*src0
>> 8) & 0xff; /* chroma V */
505 const GLubyte y1
= *src1
& 0xff; /* luminance */
506 const GLubyte cb
= (*src1
>> 8) & 0xff; /* chroma U */
507 const GLubyte y
= (i
& 1) ? y1
: y0
; /* choose even/odd luminance */
508 GLfloat r
= 1.164F
* (y
- 16) + 1.596F
* (cr
- 128);
509 GLfloat g
= 1.164F
* (y
- 16) - 0.813F
* (cr
- 128) - 0.391F
* (cb
- 128);
510 GLfloat b
= 1.164F
* (y
- 16) + 2.018F
* (cb
- 128);
511 r
*= (1.0F
/ 255.0F
);
512 g
*= (1.0F
/ 255.0F
);
513 b
*= (1.0F
/ 255.0F
);
514 dst
[i
][RCOMP
] = CLAMP(r
, 0.0F
, 1.0F
);
515 dst
[i
][GCOMP
] = CLAMP(g
, 0.0F
, 1.0F
);
516 dst
[i
][BCOMP
] = CLAMP(b
, 0.0F
, 1.0F
);
517 dst
[i
][ACOMP
] = 1.0F
;
522 unpack_R8(const void *src
, GLfloat dst
[][4], GLuint n
)
524 const GLubyte
*s
= ((const GLubyte
*) src
);
526 for (i
= 0; i
< n
; i
++) {
527 dst
[i
][0] = UBYTE_TO_FLOAT(s
[i
]);
535 unpack_GR88(const void *src
, GLfloat dst
[][4], GLuint n
)
537 const GLushort
*s
= ((const GLushort
*) src
);
539 for (i
= 0; i
< n
; i
++) {
540 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( s
[i
] & 0xff );
541 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 8 );
548 unpack_RG88(const void *src
, GLfloat dst
[][4], GLuint n
)
550 const GLushort
*s
= ((const GLushort
*) src
);
552 for (i
= 0; i
< n
; i
++) {
553 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 8 );
554 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( s
[i
] & 0xff );
561 unpack_R16(const void *src
, GLfloat dst
[][4], GLuint n
)
563 const GLushort
*s
= ((const GLushort
*) src
);
565 for (i
= 0; i
< n
; i
++) {
566 dst
[i
][RCOMP
] = USHORT_TO_FLOAT(s
[i
]);
574 unpack_GR1616(const void *src
, GLfloat dst
[][4], GLuint n
)
576 const GLuint
*s
= ((const GLuint
*) src
);
578 for (i
= 0; i
< n
; i
++) {
579 dst
[i
][RCOMP
] = USHORT_TO_FLOAT( s
[i
] & 0xffff );
580 dst
[i
][GCOMP
] = USHORT_TO_FLOAT( s
[i
] >> 16 );
587 unpack_RG1616(const void *src
, GLfloat dst
[][4], GLuint n
)
589 const GLuint
*s
= ((const GLuint
*) src
);
591 for (i
= 0; i
< n
; i
++) {
592 dst
[i
][RCOMP
] = USHORT_TO_FLOAT( s
[i
] >> 16 );
593 dst
[i
][GCOMP
] = USHORT_TO_FLOAT( s
[i
] & 0xffff );
600 unpack_ARGB2101010(const void *src
, GLfloat dst
[][4], GLuint n
)
602 const GLuint
*s
= ((const GLuint
*) src
);
604 for (i
= 0; i
< n
; i
++) {
605 dst
[i
][RCOMP
] = ((s
[i
] >> 20) & 0x3ff) * (1.0F
/ 1023.0F
);
606 dst
[i
][GCOMP
] = ((s
[i
] >> 10) & 0x3ff) * (1.0F
/ 1023.0F
);
607 dst
[i
][BCOMP
] = ((s
[i
] >> 0) & 0x3ff) * (1.0F
/ 1023.0F
);
608 dst
[i
][ACOMP
] = ((s
[i
] >> 30) & 0x03) * (1.0F
/ 3.0F
);
614 unpack_ARGB2101010_UINT(const void *src
, GLfloat dst
[][4], GLuint n
)
616 const GLuint
*s
= (const GLuint
*) src
;
618 for (i
= 0; i
< n
; i
++) {
619 dst
[i
][RCOMP
] = (GLfloat
)((s
[i
] >> 20) & 0x3ff);
620 dst
[i
][GCOMP
] = (GLfloat
)((s
[i
] >> 10) & 0x3ff);
621 dst
[i
][BCOMP
] = (GLfloat
)((s
[i
] >> 0) & 0x3ff);
622 dst
[i
][ACOMP
] = (GLfloat
)((s
[i
] >> 30) & 0x03);
628 unpack_ABGR2101010_UINT(const void *src
, GLfloat dst
[][4], GLuint n
)
630 const GLuint
*s
= ((const GLuint
*) src
);
632 for (i
= 0; i
< n
; i
++) {
633 dst
[i
][RCOMP
] = (GLfloat
)((s
[i
] >> 0) & 0x3ff);
634 dst
[i
][GCOMP
] = (GLfloat
)((s
[i
] >> 10) & 0x3ff);
635 dst
[i
][BCOMP
] = (GLfloat
)((s
[i
] >> 20) & 0x3ff);
636 dst
[i
][ACOMP
] = (GLfloat
)((s
[i
] >> 30) & 0x03);
642 unpack_Z24_S8(const void *src
, GLfloat dst
[][4], GLuint n
)
644 /* only return Z, not stencil data */
645 const GLuint
*s
= ((const GLuint
*) src
);
646 const GLdouble scale
= 1.0 / (GLdouble
) 0xffffff;
648 for (i
= 0; i
< n
; i
++) {
651 dst
[i
][2] = (GLfloat
) ((s
[i
] >> 8) * scale
);
653 ASSERT(dst
[i
][0] >= 0.0F
);
654 ASSERT(dst
[i
][0] <= 1.0F
);
659 unpack_S8_Z24(const void *src
, GLfloat dst
[][4], GLuint n
)
661 /* only return Z, not stencil data */
662 const GLuint
*s
= ((const GLuint
*) src
);
663 const GLdouble scale
= 1.0 / (GLdouble
) 0xffffff;
665 for (i
= 0; i
< n
; i
++) {
668 dst
[i
][2] = (float) ((s
[i
] & 0x00ffffff) * scale
);
670 ASSERT(dst
[i
][0] >= 0.0F
);
671 ASSERT(dst
[i
][0] <= 1.0F
);
676 unpack_Z16(const void *src
, GLfloat dst
[][4], GLuint n
)
678 const GLushort
*s
= ((const GLushort
*) src
);
680 for (i
= 0; i
< n
; i
++) {
683 dst
[i
][2] = s
[i
] * (1.0F
/ 65535.0F
);
689 unpack_X8_Z24(const void *src
, GLfloat dst
[][4], GLuint n
)
691 unpack_S8_Z24(src
, dst
, n
);
695 unpack_Z24_X8(const void *src
, GLfloat dst
[][4], GLuint n
)
697 unpack_Z24_S8(src
, dst
, n
);
701 unpack_Z32(const void *src
, GLfloat dst
[][4], GLuint n
)
703 const GLuint
*s
= ((const GLuint
*) src
);
705 for (i
= 0; i
< n
; i
++) {
708 dst
[i
][2] = s
[i
] * (1.0F
/ 0xffffffff);
714 unpack_Z32_FLOAT(const void *src
, GLfloat dst
[][4], GLuint n
)
716 const GLfloat
*s
= ((const GLfloat
*) src
);
718 for (i
= 0; i
< n
; i
++) {
721 dst
[i
][2] = s
[i
* 2];
727 unpack_Z32_FLOAT_X24S8(const void *src
, GLfloat dst
[][4], GLuint n
)
729 const GLfloat
*s
= ((const GLfloat
*) src
);
731 for (i
= 0; i
< n
; i
++) {
741 unpack_S8(const void *src
, GLfloat dst
[][4], GLuint n
)
743 /* should never be used */
745 for (i
= 0; i
< n
; i
++) {
755 unpack_SRGB8(const void *src
, GLfloat dst
[][4], GLuint n
)
757 const GLubyte
*s
= (const GLubyte
*) src
;
759 for (i
= 0; i
< n
; i
++) {
760 dst
[i
][RCOMP
] = _mesa_nonlinear_to_linear(s
[i
*3+2]);
761 dst
[i
][GCOMP
] = _mesa_nonlinear_to_linear(s
[i
*3+1]);
762 dst
[i
][BCOMP
] = _mesa_nonlinear_to_linear(s
[i
*3+0]);
763 dst
[i
][ACOMP
] = 1.0F
;
768 unpack_SRGBA8(const void *src
, GLfloat dst
[][4], GLuint n
)
770 const GLuint
*s
= ((const GLuint
*) src
);
772 for (i
= 0; i
< n
; i
++) {
773 dst
[i
][RCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] >> 24) );
774 dst
[i
][GCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] >> 16) & 0xff );
775 dst
[i
][BCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] >> 8) & 0xff );
776 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( s
[i
] & 0xff ); /* linear! */
781 unpack_SARGB8(const void *src
, GLfloat dst
[][4], GLuint n
)
783 const GLuint
*s
= ((const GLuint
*) src
);
785 for (i
= 0; i
< n
; i
++) {
786 dst
[i
][RCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] >> 16) & 0xff );
787 dst
[i
][GCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] >> 8) & 0xff );
788 dst
[i
][BCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] ) & 0xff );
789 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 24 ); /* linear! */
794 unpack_SL8(const void *src
, GLfloat dst
[][4], GLuint n
)
796 const GLubyte
*s
= ((const GLubyte
*) src
);
798 for (i
= 0; i
< n
; i
++) {
801 dst
[i
][BCOMP
] = _mesa_nonlinear_to_linear(s
[i
]);
802 dst
[i
][ACOMP
] = 1.0F
;
807 unpack_SLA8(const void *src
, GLfloat dst
[][4], GLuint n
)
809 const GLushort
*s
= (const GLushort
*) src
;
811 for (i
= 0; i
< n
; i
++) {
814 dst
[i
][BCOMP
] = _mesa_nonlinear_to_linear(s
[i
] & 0xff);
815 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT(s
[i
] >> 8); /* linear! */
820 unpack_SRGB_DXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
825 unpack_SRGBA_DXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
830 unpack_SRGBA_DXT3(const void *src
, GLfloat dst
[][4], GLuint n
)
835 unpack_SRGBA_DXT5(const void *src
, GLfloat dst
[][4], GLuint n
)
840 unpack_RGB_FXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
845 unpack_RGBA_FXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
850 unpack_RGB_DXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
855 unpack_RGBA_DXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
860 unpack_RGBA_DXT3(const void *src
, GLfloat dst
[][4], GLuint n
)
865 unpack_RGBA_DXT5(const void *src
, GLfloat dst
[][4], GLuint n
)
871 unpack_RGBA_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
873 const GLfloat
*s
= (const GLfloat
*) src
;
875 for (i
= 0; i
< n
; i
++) {
876 dst
[i
][RCOMP
] = s
[i
*4+0];
877 dst
[i
][GCOMP
] = s
[i
*4+1];
878 dst
[i
][BCOMP
] = s
[i
*4+2];
879 dst
[i
][ACOMP
] = s
[i
*4+3];
884 unpack_RGBA_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
886 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
888 for (i
= 0; i
< n
; i
++) {
889 dst
[i
][RCOMP
] = _mesa_half_to_float(s
[i
*4+0]);
890 dst
[i
][GCOMP
] = _mesa_half_to_float(s
[i
*4+1]);
891 dst
[i
][BCOMP
] = _mesa_half_to_float(s
[i
*4+2]);
892 dst
[i
][ACOMP
] = _mesa_half_to_float(s
[i
*4+3]);
897 unpack_RGB_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
899 const GLfloat
*s
= (const GLfloat
*) src
;
901 for (i
= 0; i
< n
; i
++) {
902 dst
[i
][RCOMP
] = s
[i
*3+0];
903 dst
[i
][GCOMP
] = s
[i
*3+1];
904 dst
[i
][BCOMP
] = s
[i
*3+2];
905 dst
[i
][ACOMP
] = 1.0F
;
910 unpack_RGB_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
912 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
914 for (i
= 0; i
< n
; i
++) {
915 dst
[i
][RCOMP
] = _mesa_half_to_float(s
[i
*3+0]);
916 dst
[i
][GCOMP
] = _mesa_half_to_float(s
[i
*3+1]);
917 dst
[i
][BCOMP
] = _mesa_half_to_float(s
[i
*3+2]);
918 dst
[i
][ACOMP
] = 1.0F
;
923 unpack_ALPHA_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
925 const GLfloat
*s
= (const GLfloat
*) src
;
927 for (i
= 0; i
< n
; i
++) {
930 dst
[i
][BCOMP
] = 0.0F
;
931 dst
[i
][ACOMP
] = s
[i
];
936 unpack_ALPHA_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
938 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
940 for (i
= 0; i
< n
; i
++) {
943 dst
[i
][BCOMP
] = 0.0F
;
944 dst
[i
][ACOMP
] = _mesa_half_to_float(s
[i
]);
949 unpack_LUMINANCE_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
951 const GLfloat
*s
= (const GLfloat
*) src
;
953 for (i
= 0; i
< n
; i
++) {
956 dst
[i
][BCOMP
] = s
[i
];
957 dst
[i
][ACOMP
] = 1.0F
;
962 unpack_LUMINANCE_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
964 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
966 for (i
= 0; i
< n
; i
++) {
969 dst
[i
][BCOMP
] = _mesa_half_to_float(s
[i
]);
970 dst
[i
][ACOMP
] = 1.0F
;
975 unpack_LUMINANCE_ALPHA_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
977 const GLfloat
*s
= (const GLfloat
*) src
;
979 for (i
= 0; i
< n
; i
++) {
982 dst
[i
][BCOMP
] = s
[i
*2+0];
983 dst
[i
][ACOMP
] = s
[i
*2+1];
988 unpack_LUMINANCE_ALPHA_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
990 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
992 for (i
= 0; i
< n
; i
++) {
995 dst
[i
][BCOMP
] = _mesa_half_to_float(s
[i
*2+0]);
996 dst
[i
][ACOMP
] = _mesa_half_to_float(s
[i
*2+1]);
1001 unpack_INTENSITY_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1003 const GLfloat
*s
= (const GLfloat
*) src
;
1005 for (i
= 0; i
< n
; i
++) {
1009 dst
[i
][ACOMP
] = s
[i
];
1014 unpack_INTENSITY_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1016 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
1018 for (i
= 0; i
< n
; i
++) {
1022 dst
[i
][ACOMP
] = _mesa_half_to_float(s
[i
]);
1027 unpack_R_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1029 const GLfloat
*s
= (const GLfloat
*) src
;
1031 for (i
= 0; i
< n
; i
++) {
1032 dst
[i
][RCOMP
] = s
[i
];
1033 dst
[i
][GCOMP
] = 0.0F
;
1034 dst
[i
][BCOMP
] = 0.0F
;
1035 dst
[i
][ACOMP
] = 1.0F
;
1040 unpack_R_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1042 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
1044 for (i
= 0; i
< n
; i
++) {
1045 dst
[i
][RCOMP
] = _mesa_half_to_float(s
[i
]);
1046 dst
[i
][GCOMP
] = 0.0F
;
1047 dst
[i
][BCOMP
] = 0.0F
;
1048 dst
[i
][ACOMP
] = 1.0F
;
1053 unpack_RG_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1055 const GLfloat
*s
= (const GLfloat
*) src
;
1057 for (i
= 0; i
< n
; i
++) {
1058 dst
[i
][RCOMP
] = s
[i
*2+0];
1059 dst
[i
][GCOMP
] = s
[i
*2+1];
1060 dst
[i
][BCOMP
] = 0.0F
;
1061 dst
[i
][ACOMP
] = 1.0F
;
1066 unpack_RG_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1068 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
1070 for (i
= 0; i
< n
; i
++) {
1071 dst
[i
][RCOMP
] = _mesa_half_to_float(s
[i
*2+0]);
1072 dst
[i
][GCOMP
] = _mesa_half_to_float(s
[i
*2+1]);
1073 dst
[i
][BCOMP
] = 0.0F
;
1074 dst
[i
][ACOMP
] = 1.0F
;
1079 unpack_ALPHA_UINT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1081 const GLubyte
*s
= (const GLubyte
*) src
;
1083 for (i
= 0; i
< n
; i
++) {
1086 dst
[i
][BCOMP
] = 0.0;
1087 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1092 unpack_ALPHA_UINT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1094 const GLushort
*s
= (const GLushort
*) src
;
1096 for (i
= 0; i
< n
; i
++) {
1099 dst
[i
][BCOMP
] = 0.0;
1100 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1105 unpack_ALPHA_UINT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1107 const GLuint
*s
= (const GLuint
*) src
;
1109 for (i
= 0; i
< n
; i
++) {
1112 dst
[i
][BCOMP
] = 0.0;
1113 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1118 unpack_ALPHA_INT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1120 const GLbyte
*s
= (const GLbyte
*) src
;
1122 for (i
= 0; i
< n
; i
++) {
1125 dst
[i
][BCOMP
] = 0.0;
1126 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1131 unpack_ALPHA_INT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1133 const GLshort
*s
= (const GLshort
*) src
;
1135 for (i
= 0; i
< n
; i
++) {
1138 dst
[i
][BCOMP
] = 0.0;
1139 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1144 unpack_ALPHA_INT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1146 const GLint
*s
= (const GLint
*) src
;
1148 for (i
= 0; i
< n
; i
++) {
1151 dst
[i
][BCOMP
] = 0.0;
1152 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1157 unpack_INTENSITY_UINT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1159 const GLubyte
*s
= (const GLubyte
*) src
;
1161 for (i
= 0; i
< n
; i
++) {
1165 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1170 unpack_INTENSITY_UINT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1172 const GLushort
*s
= (const GLushort
*) src
;
1174 for (i
= 0; i
< n
; i
++) {
1178 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1183 unpack_INTENSITY_UINT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1185 const GLuint
*s
= (const GLuint
*) src
;
1187 for (i
= 0; i
< n
; i
++) {
1191 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1196 unpack_INTENSITY_INT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1198 const GLbyte
*s
= (const GLbyte
*) src
;
1200 for (i
= 0; i
< n
; i
++) {
1204 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1209 unpack_INTENSITY_INT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1211 const GLshort
*s
= (const GLshort
*) src
;
1213 for (i
= 0; i
< n
; i
++) {
1217 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1222 unpack_INTENSITY_INT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1224 const GLint
*s
= (const GLint
*) src
;
1226 for (i
= 0; i
< n
; i
++) {
1230 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1235 unpack_LUMINANCE_UINT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1237 const GLubyte
*s
= (const GLubyte
*) src
;
1239 for (i
= 0; i
< n
; i
++) {
1240 dst
[i
][RCOMP
] = dst
[i
][GCOMP
] = dst
[i
][BCOMP
] = (GLfloat
) s
[i
];
1241 dst
[i
][ACOMP
] = 1.0;
1246 unpack_LUMINANCE_UINT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1248 const GLushort
*s
= (const GLushort
*) src
;
1250 for (i
= 0; i
< n
; i
++) {
1251 dst
[i
][RCOMP
] = dst
[i
][GCOMP
] = dst
[i
][BCOMP
] = (GLfloat
) s
[i
];
1252 dst
[i
][ACOMP
] = 1.0;
1257 unpack_LUMINANCE_UINT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1259 const GLuint
*s
= (const GLuint
*) src
;
1261 for (i
= 0; i
< n
; i
++) {
1262 dst
[i
][RCOMP
] = dst
[i
][GCOMP
] = dst
[i
][BCOMP
] = (GLfloat
) s
[i
];
1263 dst
[i
][ACOMP
] = 1.0;
1268 unpack_LUMINANCE_INT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1270 const GLbyte
*s
= (const GLbyte
*) src
;
1272 for (i
= 0; i
< n
; i
++) {
1273 dst
[i
][RCOMP
] = dst
[i
][GCOMP
] = dst
[i
][BCOMP
] = (GLfloat
) s
[i
];
1274 dst
[i
][ACOMP
] = 1.0;
1279 unpack_LUMINANCE_INT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1281 const GLshort
*s
= (const GLshort
*) src
;
1283 for (i
= 0; i
< n
; i
++) {
1284 dst
[i
][RCOMP
] = dst
[i
][GCOMP
] = dst
[i
][BCOMP
] = (GLfloat
) s
[i
];
1285 dst
[i
][ACOMP
] = 1.0;
1290 unpack_LUMINANCE_INT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1292 const GLint
*s
= (const GLint
*) src
;
1294 for (i
= 0; i
< n
; i
++) {
1295 dst
[i
][RCOMP
] = dst
[i
][GCOMP
] = dst
[i
][BCOMP
] = (GLfloat
) s
[i
];
1296 dst
[i
][ACOMP
] = 1.0;
1301 unpack_LUMINANCE_ALPHA_UINT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1303 const GLubyte
*s
= (const GLubyte
*) src
;
1305 for (i
= 0; i
< n
; i
++) {
1308 dst
[i
][BCOMP
] = (GLfloat
) s
[2*i
+0];
1309 dst
[i
][ACOMP
] = (GLfloat
) s
[2*i
+1];
1314 unpack_LUMINANCE_ALPHA_UINT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1316 const GLushort
*s
= (const GLushort
*) src
;
1318 for (i
= 0; i
< n
; i
++) {
1321 dst
[i
][BCOMP
] = (GLfloat
) s
[2*i
+0];
1322 dst
[i
][ACOMP
] = (GLfloat
) s
[2*i
+1];
1327 unpack_LUMINANCE_ALPHA_UINT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1329 const GLuint
*s
= (const GLuint
*) src
;
1331 for (i
= 0; i
< n
; i
++) {
1334 dst
[i
][BCOMP
] = (GLfloat
) s
[2*i
+0];
1335 dst
[i
][ACOMP
] = (GLfloat
) s
[2*i
+1];
1340 unpack_LUMINANCE_ALPHA_INT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1342 const GLbyte
*s
= (const GLbyte
*) src
;
1344 for (i
= 0; i
< n
; i
++) {
1347 dst
[i
][BCOMP
] = (GLfloat
) s
[2*i
+0];
1348 dst
[i
][ACOMP
] = (GLfloat
) s
[2*i
+1];
1353 unpack_LUMINANCE_ALPHA_INT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1355 const GLshort
*s
= (const GLshort
*) src
;
1357 for (i
= 0; i
< n
; i
++) {
1360 dst
[i
][BCOMP
] = (GLfloat
) s
[2*i
+0];
1361 dst
[i
][ACOMP
] = (GLfloat
) s
[2*i
+1];
1366 unpack_LUMINANCE_ALPHA_INT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1368 const GLint
*s
= (const GLint
*) src
;
1370 for (i
= 0; i
< n
; i
++) {
1373 dst
[i
][BCOMP
] = (GLfloat
) s
[2*i
+0];
1374 dst
[i
][ACOMP
] = (GLfloat
) s
[2*i
+1];
1379 unpack_R_INT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1381 const GLbyte
*s
= (const GLbyte
*) src
;
1383 for (i
= 0; i
< n
; i
++) {
1384 dst
[i
][RCOMP
] = (GLfloat
) s
[i
];
1385 dst
[i
][GCOMP
] = 0.0;
1386 dst
[i
][BCOMP
] = 0.0;
1387 dst
[i
][ACOMP
] = 1.0;
1392 unpack_RG_INT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1394 const GLbyte
*s
= (const GLbyte
*) src
;
1396 for (i
= 0; i
< n
; i
++) {
1397 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*2+0];
1398 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*2+1];
1399 dst
[i
][BCOMP
] = 0.0;
1400 dst
[i
][ACOMP
] = 1.0;
1405 unpack_RGB_INT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1407 const GLbyte
*s
= (const GLbyte
*) src
;
1409 for (i
= 0; i
< n
; i
++) {
1410 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*3+0];
1411 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*3+1];
1412 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*3+2];
1413 dst
[i
][ACOMP
] = 1.0;
1418 unpack_RGBA_INT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1420 const GLbyte
*s
= (const GLbyte
*) src
;
1422 for (i
= 0; i
< n
; i
++) {
1423 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1424 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1425 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1426 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1431 unpack_R_INT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1433 const GLshort
*s
= (const GLshort
*) src
;
1435 for (i
= 0; i
< n
; i
++) {
1436 dst
[i
][RCOMP
] = (GLfloat
) s
[i
];
1437 dst
[i
][GCOMP
] = 0.0;
1438 dst
[i
][BCOMP
] = 0.0;
1439 dst
[i
][ACOMP
] = 1.0;
1444 unpack_RG_INT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1446 const GLshort
*s
= (const GLshort
*) src
;
1448 for (i
= 0; i
< n
; i
++) {
1449 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*2+0];
1450 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*2+1];
1451 dst
[i
][BCOMP
] = 0.0;
1452 dst
[i
][ACOMP
] = 1.0;
1457 unpack_RGB_INT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1459 const GLshort
*s
= (const GLshort
*) src
;
1461 for (i
= 0; i
< n
; i
++) {
1462 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*3+0];
1463 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*3+1];
1464 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*3+2];
1465 dst
[i
][ACOMP
] = 1.0;
1470 unpack_RGBA_INT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1472 const GLshort
*s
= (const GLshort
*) src
;
1474 for (i
= 0; i
< n
; i
++) {
1475 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1476 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1477 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1478 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1483 unpack_R_INT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1485 const GLint
*s
= (const GLint
*) src
;
1487 for (i
= 0; i
< n
; i
++) {
1488 dst
[i
][RCOMP
] = (GLfloat
) s
[i
];
1489 dst
[i
][GCOMP
] = 0.0;
1490 dst
[i
][BCOMP
] = 0.0;
1491 dst
[i
][ACOMP
] = 1.0;
1496 unpack_RG_INT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1498 const GLint
*s
= (const GLint
*) src
;
1500 for (i
= 0; i
< n
; i
++) {
1501 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*2+0];
1502 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*2+1];
1503 dst
[i
][BCOMP
] = 0.0;
1504 dst
[i
][ACOMP
] = 1.0;
1509 unpack_RGB_INT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1511 const GLint
*s
= (const GLint
*) src
;
1513 for (i
= 0; i
< n
; i
++) {
1514 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*3+0];
1515 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*3+1];
1516 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*3+2];
1517 dst
[i
][ACOMP
] = 1.0;
1523 unpack_RGBA_INT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1525 const GLint
*s
= (const GLint
*) src
;
1527 for (i
= 0; i
< n
; i
++) {
1528 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1529 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1530 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1531 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1536 unpack_R_UINT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1538 const GLubyte
*s
= (const GLubyte
*) src
;
1540 for (i
= 0; i
< n
; i
++) {
1541 dst
[i
][RCOMP
] = (GLfloat
) s
[i
];
1542 dst
[i
][GCOMP
] = 0.0;
1543 dst
[i
][BCOMP
] = 0.0;
1544 dst
[i
][ACOMP
] = 1.0;
1549 unpack_RG_UINT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1551 const GLubyte
*s
= (const GLubyte
*) src
;
1553 for (i
= 0; i
< n
; i
++) {
1554 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*2+0];
1555 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*2+1];
1556 dst
[i
][BCOMP
] = 0.0;
1557 dst
[i
][ACOMP
] = 1.0;
1562 unpack_RGB_UINT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1564 const GLubyte
*s
= (const GLubyte
*) src
;
1566 for (i
= 0; i
< n
; i
++) {
1567 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*3+0];
1568 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*3+1];
1569 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*3+2];
1570 dst
[i
][ACOMP
] = 1.0;
1575 unpack_RGBA_UINT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1577 const GLubyte
*s
= (const GLubyte
*) src
;
1579 for (i
= 0; i
< n
; i
++) {
1580 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1581 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1582 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1583 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1588 unpack_R_UINT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1590 const GLushort
*s
= (const GLushort
*) src
;
1592 for (i
= 0; i
< n
; i
++) {
1593 dst
[i
][RCOMP
] = (GLfloat
) s
[i
];
1594 dst
[i
][GCOMP
] = 0.0;
1595 dst
[i
][BCOMP
] = 0.0;
1596 dst
[i
][ACOMP
] = 1.0;
1601 unpack_RG_UINT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1603 const GLushort
*s
= (const GLushort
*) src
;
1605 for (i
= 0; i
< n
; i
++) {
1606 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*2+0];
1607 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*2+1];
1608 dst
[i
][BCOMP
] = 0.0;
1609 dst
[i
][ACOMP
] = 1.0;
1614 unpack_RGB_UINT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1616 const GLushort
*s
= (const GLushort
*) src
;
1618 for (i
= 0; i
< n
; i
++) {
1619 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*3+0];
1620 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*3+1];
1621 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*3+2];
1622 dst
[i
][ACOMP
] = 1.0;
1627 unpack_RGBA_UINT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1629 const GLushort
*s
= (const GLushort
*) src
;
1631 for (i
= 0; i
< n
; i
++) {
1632 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1633 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1634 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1635 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1640 unpack_R_UINT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1642 const GLuint
*s
= (const GLuint
*) src
;
1644 for (i
= 0; i
< n
; i
++) {
1645 dst
[i
][RCOMP
] = (GLfloat
) s
[i
];
1646 dst
[i
][GCOMP
] = 0.0;
1647 dst
[i
][BCOMP
] = 0.0;
1648 dst
[i
][ACOMP
] = 1.0;
1653 unpack_RG_UINT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1655 const GLuint
*s
= (const GLuint
*) src
;
1657 for (i
= 0; i
< n
; i
++) {
1658 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*2+0];
1659 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*2+1];
1660 dst
[i
][BCOMP
] = 0.0;
1661 dst
[i
][ACOMP
] = 1.0;
1666 unpack_RGB_UINT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1668 const GLuint
*s
= (const GLuint
*) src
;
1670 for (i
= 0; i
< n
; i
++) {
1671 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*3+0];
1672 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*3+1];
1673 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*3+2];
1674 dst
[i
][ACOMP
] = 1.0;
1679 unpack_RGBA_UINT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1681 const GLuint
*s
= (const GLuint
*) src
;
1683 for (i
= 0; i
< n
; i
++) {
1684 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1685 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1686 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1687 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1692 unpack_DUDV8(const void *src
, GLfloat dst
[][4], GLuint n
)
1694 const GLbyte
*s
= (const GLbyte
*) src
;
1696 for (i
= 0; i
< n
; i
++) {
1697 dst
[i
][RCOMP
] = BYTE_TO_FLOAT(s
[i
*2+0]);
1698 dst
[i
][GCOMP
] = BYTE_TO_FLOAT(s
[i
*2+1]);
1705 unpack_SIGNED_R8(const void *src
, GLfloat dst
[][4], GLuint n
)
1707 const GLbyte
*s
= ((const GLbyte
*) src
);
1709 for (i
= 0; i
< n
; i
++) {
1710 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( s
[i
] );
1711 dst
[i
][GCOMP
] = 0.0F
;
1712 dst
[i
][BCOMP
] = 0.0F
;
1713 dst
[i
][ACOMP
] = 1.0F
;
1718 unpack_SIGNED_RG88_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
1720 const GLushort
*s
= ((const GLushort
*) src
);
1722 for (i
= 0; i
< n
; i
++) {
1723 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] & 0xff) );
1724 dst
[i
][GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
1725 dst
[i
][BCOMP
] = 0.0F
;
1726 dst
[i
][ACOMP
] = 1.0F
;
1731 unpack_SIGNED_RGBX8888(const void *src
, GLfloat dst
[][4], GLuint n
)
1733 const GLuint
*s
= ((const GLuint
*) src
);
1735 for (i
= 0; i
< n
; i
++) {
1736 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 24) );
1737 dst
[i
][GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 16) );
1738 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
1739 dst
[i
][ACOMP
] = 1.0f
;
1744 unpack_SIGNED_RGBA8888(const void *src
, GLfloat dst
[][4], GLuint n
)
1746 const GLuint
*s
= ((const GLuint
*) src
);
1748 for (i
= 0; i
< n
; i
++) {
1749 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 24) );
1750 dst
[i
][GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 16) );
1751 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
1752 dst
[i
][ACOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] ) );
1757 unpack_SIGNED_RGBA8888_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
1759 const GLuint
*s
= ((const GLuint
*) src
);
1761 for (i
= 0; i
< n
; i
++) {
1762 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] ) );
1763 dst
[i
][GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
1764 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 16) );
1765 dst
[i
][ACOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 24) );
1770 unpack_SIGNED_R16(const void *src
, GLfloat dst
[][4], GLuint n
)
1772 const GLshort
*s
= ((const GLshort
*) src
);
1774 for (i
= 0; i
< n
; i
++) {
1775 dst
[i
][RCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
] );
1776 dst
[i
][GCOMP
] = 0.0F
;
1777 dst
[i
][BCOMP
] = 0.0F
;
1778 dst
[i
][ACOMP
] = 1.0F
;
1783 unpack_SIGNED_GR1616(const void *src
, GLfloat dst
[][4], GLuint n
)
1785 const GLuint
*s
= ((const GLuint
*) src
);
1787 for (i
= 0; i
< n
; i
++) {
1788 dst
[i
][RCOMP
] = SHORT_TO_FLOAT_TEX( (GLshort
) (s
[i
] & 0xffff) );
1789 dst
[i
][GCOMP
] = SHORT_TO_FLOAT_TEX( (GLshort
) (s
[i
] >> 16) );
1790 dst
[i
][BCOMP
] = 0.0F
;
1791 dst
[i
][ACOMP
] = 1.0F
;
1796 unpack_SIGNED_RGB_16(const void *src
, GLfloat dst
[][4], GLuint n
)
1798 const GLshort
*s
= (const GLshort
*) src
;
1800 for (i
= 0; i
< n
; i
++) {
1801 dst
[i
][RCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*3+0] );
1802 dst
[i
][GCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*3+1] );
1803 dst
[i
][BCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*3+2] );
1804 dst
[i
][ACOMP
] = 1.0F
;
1809 unpack_SIGNED_RGBA_16(const void *src
, GLfloat dst
[][4], GLuint n
)
1811 const GLshort
*s
= (const GLshort
*) src
;
1813 for (i
= 0; i
< n
; i
++) {
1814 dst
[i
][RCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+0] );
1815 dst
[i
][GCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+1] );
1816 dst
[i
][BCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+2] );
1817 dst
[i
][ACOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+3] );
1822 unpack_RGBA_16(const void *src
, GLfloat dst
[][4], GLuint n
)
1824 const GLushort
*s
= (const GLushort
*) src
;
1826 for (i
= 0; i
< n
; i
++) {
1827 dst
[i
][RCOMP
] = USHORT_TO_FLOAT( s
[i
*4+0] );
1828 dst
[i
][GCOMP
] = USHORT_TO_FLOAT( s
[i
*4+1] );
1829 dst
[i
][BCOMP
] = USHORT_TO_FLOAT( s
[i
*4+2] );
1830 dst
[i
][ACOMP
] = USHORT_TO_FLOAT( s
[i
*4+3] );
1835 unpack_RED_RGTC1(const void *src
, GLfloat dst
[][4], GLuint n
)
1841 unpack_SIGNED_RED_RGTC1(const void *src
, GLfloat dst
[][4], GLuint n
)
1847 unpack_RG_RGTC2(const void *src
, GLfloat dst
[][4], GLuint n
)
1853 unpack_SIGNED_RG_RGTC2(const void *src
, GLfloat dst
[][4], GLuint n
)
1859 unpack_L_LATC1(const void *src
, GLfloat dst
[][4], GLuint n
)
1865 unpack_SIGNED_L_LATC1(const void *src
, GLfloat dst
[][4], GLuint n
)
1871 unpack_LA_LATC2(const void *src
, GLfloat dst
[][4], GLuint n
)
1877 unpack_SIGNED_LA_LATC2(const void *src
, GLfloat dst
[][4], GLuint n
)
1883 unpack_ETC1_RGB8(const void *src
, GLfloat dst
[][4], GLuint n
)
1889 unpack_ETC2_RGB8(const void *src
, GLfloat dst
[][4], GLuint n
)
1895 unpack_ETC2_SRGB8(const void *src
, GLfloat dst
[][4], GLuint n
)
1901 unpack_ETC2_RGBA8_EAC(const void *src
, GLfloat dst
[][4], GLuint n
)
1907 unpack_ETC2_SRGB8_ALPHA8_EAC(const void *src
, GLfloat dst
[][4], GLuint n
)
1913 unpack_ETC2_R11_EAC(const void *src
, GLfloat dst
[][4], GLuint n
)
1919 unpack_ETC2_RG11_EAC(const void *src
, GLfloat dst
[][4], GLuint n
)
1925 unpack_ETC2_SIGNED_R11_EAC(const void *src
, GLfloat dst
[][4], GLuint n
)
1931 unpack_ETC2_SIGNED_RG11_EAC(const void *src
, GLfloat dst
[][4], GLuint n
)
1937 unpack_ETC2_RGB8_PUNCHTHROUGH_ALPHA1(const void *src
, GLfloat dst
[][4],
1944 unpack_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1(const void *src
, GLfloat dst
[][4],
1951 unpack_SIGNED_A8(const void *src
, GLfloat dst
[][4], GLuint n
)
1953 const GLbyte
*s
= ((const GLbyte
*) src
);
1955 for (i
= 0; i
< n
; i
++) {
1956 dst
[i
][RCOMP
] = 0.0F
;
1957 dst
[i
][GCOMP
] = 0.0F
;
1958 dst
[i
][BCOMP
] = 0.0F
;
1959 dst
[i
][ACOMP
] = BYTE_TO_FLOAT_TEX( s
[i
] );
1964 unpack_SIGNED_L8(const void *src
, GLfloat dst
[][4], GLuint n
)
1966 const GLbyte
*s
= ((const GLbyte
*) src
);
1968 for (i
= 0; i
< n
; i
++) {
1971 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( s
[i
] );
1972 dst
[i
][ACOMP
] = 1.0F
;
1977 unpack_SIGNED_AL88(const void *src
, GLfloat dst
[][4], GLuint n
)
1979 const GLshort
*s
= ((const GLshort
*) src
);
1981 for (i
= 0; i
< n
; i
++) {
1984 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] & 0xff) );
1985 dst
[i
][ACOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
1990 unpack_SIGNED_I8(const void *src
, GLfloat dst
[][4], GLuint n
)
1992 const GLbyte
*s
= ((const GLbyte
*) src
);
1994 for (i
= 0; i
< n
; i
++) {
1998 dst
[i
][ACOMP
] = BYTE_TO_FLOAT_TEX( s
[i
] );
2003 unpack_SIGNED_A16(const void *src
, GLfloat dst
[][4], GLuint n
)
2005 const GLshort
*s
= ((const GLshort
*) src
);
2007 for (i
= 0; i
< n
; i
++) {
2008 dst
[i
][RCOMP
] = 0.0F
;
2009 dst
[i
][GCOMP
] = 0.0F
;
2010 dst
[i
][BCOMP
] = 0.0F
;
2011 dst
[i
][ACOMP
] = SHORT_TO_FLOAT_TEX( s
[i
] );
2016 unpack_SIGNED_L16(const void *src
, GLfloat dst
[][4], GLuint n
)
2018 const GLshort
*s
= ((const GLshort
*) src
);
2020 for (i
= 0; i
< n
; i
++) {
2023 dst
[i
][BCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
] );
2024 dst
[i
][ACOMP
] = 1.0F
;
2029 unpack_SIGNED_AL1616(const void *src
, GLfloat dst
[][4], GLuint n
)
2031 const GLshort
*s
= (const GLshort
*) src
;
2033 for (i
= 0; i
< n
; i
++) {
2036 dst
[i
][BCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*2+0] );
2037 dst
[i
][ACOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*2+1] );
2042 unpack_SIGNED_I16(const void *src
, GLfloat dst
[][4], GLuint n
)
2044 const GLshort
*s
= ((const GLshort
*) src
);
2046 for (i
= 0; i
< n
; i
++) {
2050 dst
[i
][ACOMP
] = SHORT_TO_FLOAT_TEX( s
[i
] );
2055 unpack_RGB9_E5_FLOAT(const void *src
, GLfloat dst
[][4], GLuint n
)
2057 const GLuint
*s
= (const GLuint
*) src
;
2059 for (i
= 0; i
< n
; i
++) {
2060 rgb9e5_to_float3(s
[i
], dst
[i
]);
2061 dst
[i
][ACOMP
] = 1.0F
;
2066 unpack_R11_G11_B10_FLOAT(const void *src
, GLfloat dst
[][4], GLuint n
)
2068 const GLuint
*s
= (const GLuint
*) src
;
2070 for (i
= 0; i
< n
; i
++) {
2071 r11g11b10f_to_float3(s
[i
], dst
[i
]);
2072 dst
[i
][ACOMP
] = 1.0F
;
2077 unpack_XRGB4444_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
2079 const GLushort
*s
= ((const GLushort
*) src
);
2081 for (i
= 0; i
< n
; i
++) {
2082 dst
[i
][RCOMP
] = ((s
[i
] >> 8) & 0xf) * (1.0F
/ 15.0F
);
2083 dst
[i
][GCOMP
] = ((s
[i
] >> 4) & 0xf) * (1.0F
/ 15.0F
);
2084 dst
[i
][BCOMP
] = ((s
[i
] ) & 0xf) * (1.0F
/ 15.0F
);
2085 dst
[i
][ACOMP
] = 1.0;
2090 unpack_XRGB1555_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
2092 const GLushort
*s
= ((const GLushort
*) src
);
2094 for (i
= 0; i
< n
; i
++) {
2095 dst
[i
][RCOMP
] = ((s
[i
] >> 10) & 0x1f) * (1.0F
/ 31.0F
);
2096 dst
[i
][GCOMP
] = ((s
[i
] >> 5) & 0x1f) * (1.0F
/ 31.0F
);
2097 dst
[i
][BCOMP
] = ((s
[i
] >> 0) & 0x1f) * (1.0F
/ 31.0F
);
2098 dst
[i
][ACOMP
] = 1.0;
2103 unpack_XBGR8888_SNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
2105 const GLuint
*s
= ((const GLuint
*) src
);
2107 for (i
= 0; i
< n
; i
++) {
2108 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] ) );
2109 dst
[i
][GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
2110 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 16) );
2111 dst
[i
][ACOMP
] = 1.0;
2116 unpack_XBGR8888_SRGB(const void *src
, GLfloat dst
[][4], GLuint n
)
2118 const GLuint
*s
= ((const GLuint
*) src
);
2120 for (i
= 0; i
< n
; i
++) {
2121 dst
[i
][RCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] ) & 0xff );
2122 dst
[i
][GCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] >> 8) & 0xff );
2123 dst
[i
][BCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] >> 16) & 0xff );
2124 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 24 ); /* linear! */
2129 unpack_XBGR8888_UINT(const void *src
, GLfloat dst
[][4], GLuint n
)
2131 const GLbyte
*s
= (const GLbyte
*) src
;
2133 for (i
= 0; i
< n
; i
++) {
2134 dst
[i
][RCOMP
] = s
[i
*4+0];
2135 dst
[i
][GCOMP
] = s
[i
*4+1];
2136 dst
[i
][BCOMP
] = s
[i
*4+2];
2137 dst
[i
][ACOMP
] = 1.0;
2142 unpack_XBGR8888_SINT(const void *src
, GLfloat dst
[][4], GLuint n
)
2144 const GLbyte
*s
= (const GLbyte
*) src
;
2146 for (i
= 0; i
< n
; i
++) {
2147 dst
[i
][RCOMP
] = s
[i
*4+0];
2148 dst
[i
][GCOMP
] = s
[i
*4+1];
2149 dst
[i
][BCOMP
] = s
[i
*4+2];
2150 dst
[i
][ACOMP
] = 1.0;
2155 unpack_XRGB2101010_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
2157 const GLuint
*s
= ((const GLuint
*) src
);
2159 for (i
= 0; i
< n
; i
++) {
2160 dst
[i
][RCOMP
] = ((s
[i
] >> 20) & 0x3ff) * (1.0F
/ 1023.0F
);
2161 dst
[i
][GCOMP
] = ((s
[i
] >> 10) & 0x3ff) * (1.0F
/ 1023.0F
);
2162 dst
[i
][BCOMP
] = ((s
[i
] >> 0) & 0x3ff) * (1.0F
/ 1023.0F
);
2163 dst
[i
][ACOMP
] = 1.0;
2168 unpack_XBGR16161616_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
2170 const GLushort
*s
= (const GLushort
*) src
;
2172 for (i
= 0; i
< n
; i
++) {
2173 dst
[i
][RCOMP
] = USHORT_TO_FLOAT( s
[i
*4+0] );
2174 dst
[i
][GCOMP
] = USHORT_TO_FLOAT( s
[i
*4+1] );
2175 dst
[i
][BCOMP
] = USHORT_TO_FLOAT( s
[i
*4+2] );
2176 dst
[i
][ACOMP
] = 1.0;
2181 unpack_XBGR16161616_SNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
2183 const GLshort
*s
= (const GLshort
*) src
;
2185 for (i
= 0; i
< n
; i
++) {
2186 dst
[i
][RCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+0] );
2187 dst
[i
][GCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+1] );
2188 dst
[i
][BCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+2] );
2189 dst
[i
][ACOMP
] = 1.0;
2194 unpack_XBGR16161616_FLOAT(const void *src
, GLfloat dst
[][4], GLuint n
)
2196 const GLshort
*s
= (const GLshort
*) src
;
2198 for (i
= 0; i
< n
; i
++) {
2199 dst
[i
][RCOMP
] = _mesa_half_to_float(s
[i
*4+0]);
2200 dst
[i
][GCOMP
] = _mesa_half_to_float(s
[i
*4+1]);
2201 dst
[i
][BCOMP
] = _mesa_half_to_float(s
[i
*4+2]);
2202 dst
[i
][ACOMP
] = 1.0;
2207 unpack_XBGR16161616_UINT(const void *src
, GLfloat dst
[][4], GLuint n
)
2209 const GLushort
*s
= (const GLushort
*) src
;
2211 for (i
= 0; i
< n
; i
++) {
2212 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
2213 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
2214 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
2215 dst
[i
][ACOMP
] = 1.0;
2220 unpack_XBGR16161616_SINT(const void *src
, GLfloat dst
[][4], GLuint n
)
2222 const GLshort
*s
= (const GLshort
*) src
;
2224 for (i
= 0; i
< n
; i
++) {
2225 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
2226 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
2227 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
2228 dst
[i
][ACOMP
] = 1.0;
2233 unpack_XBGR32323232_FLOAT(const void *src
, GLfloat dst
[][4], GLuint n
)
2235 const GLfloat
*s
= (const GLfloat
*) src
;
2237 for (i
= 0; i
< n
; i
++) {
2238 dst
[i
][RCOMP
] = s
[i
*4+0];
2239 dst
[i
][GCOMP
] = s
[i
*4+1];
2240 dst
[i
][BCOMP
] = s
[i
*4+2];
2241 dst
[i
][ACOMP
] = 1.0;
2246 unpack_XBGR32323232_UINT(const void *src
, GLfloat dst
[][4], GLuint n
)
2248 const GLuint
*s
= (const GLuint
*) src
;
2250 for (i
= 0; i
< n
; i
++) {
2251 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
2252 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
2253 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
2254 dst
[i
][ACOMP
] = 1.0;
2259 unpack_XBGR32323232_SINT(const void *src
, GLfloat dst
[][4], GLuint n
)
2261 const GLint
*s
= (const GLint
*) src
;
2263 for (i
= 0; i
< n
; i
++) {
2264 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
2265 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
2266 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
2267 dst
[i
][ACOMP
] = 1.0;
2272 unpack_ABGR2101010(const void *src
, GLfloat dst
[][4], GLuint n
)
2274 const GLuint
*s
= ((const GLuint
*) src
);
2276 for (i
= 0; i
< n
; i
++) {
2277 dst
[i
][RCOMP
] = ((s
[i
] >> 0) & 0x3ff) * (1.0F
/ 1023.0F
);
2278 dst
[i
][GCOMP
] = ((s
[i
] >> 10) & 0x3ff) * (1.0F
/ 1023.0F
);
2279 dst
[i
][BCOMP
] = ((s
[i
] >> 20) & 0x3ff) * (1.0F
/ 1023.0F
);
2280 dst
[i
][ACOMP
] = ((s
[i
] >> 30) & 0x03) * (1.0F
/ 3.0F
);
2285 unpack_SIGNED_RG88(const void *src
, GLfloat dst
[][4], GLuint n
)
2287 const GLushort
*s
= ((const GLushort
*) src
);
2289 for (i
= 0; i
< n
; i
++) {
2290 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
2291 dst
[i
][GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] & 0xff) );
2292 dst
[i
][BCOMP
] = 0.0F
;
2293 dst
[i
][ACOMP
] = 1.0F
;
2298 unpack_SIGNED_RG1616(const void *src
, GLfloat dst
[][4], GLuint n
)
2300 const GLuint
*s
= ((const GLuint
*) src
);
2302 for (i
= 0; i
< n
; i
++) {
2303 dst
[i
][RCOMP
] = SHORT_TO_FLOAT_TEX( (GLshort
) (s
[i
] >> 16) );
2304 dst
[i
][GCOMP
] = SHORT_TO_FLOAT_TEX( (GLshort
) (s
[i
] & 0xffff) );
2305 dst
[i
][BCOMP
] = 0.0F
;
2306 dst
[i
][ACOMP
] = 1.0F
;
2311 * Return the unpacker function for the given format.
2313 static unpack_rgba_func
2314 get_unpack_rgba_function(gl_format format
)
2316 static unpack_rgba_func table
[MESA_FORMAT_COUNT
];
2317 static GLboolean initialized
= GL_FALSE
;
2320 table
[MESA_FORMAT_NONE
] = NULL
;
2322 table
[MESA_FORMAT_RGBA8888
] = unpack_RGBA8888
;
2323 table
[MESA_FORMAT_RGBA8888_REV
] = unpack_RGBA8888_REV
;
2324 table
[MESA_FORMAT_ARGB8888
] = unpack_ARGB8888
;
2325 table
[MESA_FORMAT_ARGB8888_REV
] = unpack_ARGB8888_REV
;
2326 table
[MESA_FORMAT_RGBX8888
] = unpack_RGBX8888
;
2327 table
[MESA_FORMAT_RGBX8888_REV
] = unpack_RGBX8888_REV
;
2328 table
[MESA_FORMAT_XRGB8888
] = unpack_XRGB8888
;
2329 table
[MESA_FORMAT_XRGB8888_REV
] = unpack_XRGB8888_REV
;
2330 table
[MESA_FORMAT_RGB888
] = unpack_RGB888
;
2331 table
[MESA_FORMAT_BGR888
] = unpack_BGR888
;
2332 table
[MESA_FORMAT_RGB565
] = unpack_RGB565
;
2333 table
[MESA_FORMAT_RGB565_REV
] = unpack_RGB565_REV
;
2334 table
[MESA_FORMAT_ARGB4444
] = unpack_ARGB4444
;
2335 table
[MESA_FORMAT_ARGB4444_REV
] = unpack_ARGB4444_REV
;
2336 table
[MESA_FORMAT_RGBA5551
] = unpack_RGBA5551
;
2337 table
[MESA_FORMAT_ARGB1555
] = unpack_ARGB1555
;
2338 table
[MESA_FORMAT_ARGB1555_REV
] = unpack_ARGB1555_REV
;
2339 table
[MESA_FORMAT_AL44
] = unpack_AL44
;
2340 table
[MESA_FORMAT_AL88
] = unpack_AL88
;
2341 table
[MESA_FORMAT_AL88_REV
] = unpack_AL88_REV
;
2342 table
[MESA_FORMAT_AL1616
] = unpack_AL1616
;
2343 table
[MESA_FORMAT_AL1616_REV
] = unpack_AL1616_REV
;
2344 table
[MESA_FORMAT_RGB332
] = unpack_RGB332
;
2345 table
[MESA_FORMAT_A8
] = unpack_A8
;
2346 table
[MESA_FORMAT_A16
] = unpack_A16
;
2347 table
[MESA_FORMAT_L8
] = unpack_L8
;
2348 table
[MESA_FORMAT_L16
] = unpack_L16
;
2349 table
[MESA_FORMAT_I8
] = unpack_I8
;
2350 table
[MESA_FORMAT_I16
] = unpack_I16
;
2351 table
[MESA_FORMAT_YCBCR
] = unpack_YCBCR
;
2352 table
[MESA_FORMAT_YCBCR_REV
] = unpack_YCBCR_REV
;
2353 table
[MESA_FORMAT_R8
] = unpack_R8
;
2354 table
[MESA_FORMAT_GR88
] = unpack_GR88
;
2355 table
[MESA_FORMAT_RG88
] = unpack_RG88
;
2356 table
[MESA_FORMAT_R16
] = unpack_R16
;
2357 table
[MESA_FORMAT_GR1616
] = unpack_GR1616
;
2358 table
[MESA_FORMAT_RG1616
] = unpack_RG1616
;
2359 table
[MESA_FORMAT_ARGB2101010
] = unpack_ARGB2101010
;
2360 table
[MESA_FORMAT_ARGB2101010_UINT
] = unpack_ARGB2101010_UINT
;
2361 table
[MESA_FORMAT_ABGR2101010_UINT
] = unpack_ABGR2101010_UINT
;
2362 table
[MESA_FORMAT_Z24_S8
] = unpack_Z24_S8
;
2363 table
[MESA_FORMAT_S8_Z24
] = unpack_S8_Z24
;
2364 table
[MESA_FORMAT_Z16
] = unpack_Z16
;
2365 table
[MESA_FORMAT_X8_Z24
] = unpack_X8_Z24
;
2366 table
[MESA_FORMAT_Z24_X8
] = unpack_Z24_X8
;
2367 table
[MESA_FORMAT_Z32
] = unpack_Z32
;
2368 table
[MESA_FORMAT_S8
] = unpack_S8
;
2369 table
[MESA_FORMAT_SRGB8
] = unpack_SRGB8
;
2370 table
[MESA_FORMAT_SRGBA8
] = unpack_SRGBA8
;
2371 table
[MESA_FORMAT_SARGB8
] = unpack_SARGB8
;
2372 table
[MESA_FORMAT_SL8
] = unpack_SL8
;
2373 table
[MESA_FORMAT_SLA8
] = unpack_SLA8
;
2374 table
[MESA_FORMAT_SRGB_DXT1
] = unpack_SRGB_DXT1
;
2375 table
[MESA_FORMAT_SRGBA_DXT1
] = unpack_SRGBA_DXT1
;
2376 table
[MESA_FORMAT_SRGBA_DXT3
] = unpack_SRGBA_DXT3
;
2377 table
[MESA_FORMAT_SRGBA_DXT5
] = unpack_SRGBA_DXT5
;
2379 table
[MESA_FORMAT_RGB_FXT1
] = unpack_RGB_FXT1
;
2380 table
[MESA_FORMAT_RGBA_FXT1
] = unpack_RGBA_FXT1
;
2381 table
[MESA_FORMAT_RGB_DXT1
] = unpack_RGB_DXT1
;
2382 table
[MESA_FORMAT_RGBA_DXT1
] = unpack_RGBA_DXT1
;
2383 table
[MESA_FORMAT_RGBA_DXT3
] = unpack_RGBA_DXT3
;
2384 table
[MESA_FORMAT_RGBA_DXT5
] = unpack_RGBA_DXT5
;
2386 table
[MESA_FORMAT_RGBA_FLOAT32
] = unpack_RGBA_FLOAT32
;
2387 table
[MESA_FORMAT_RGBA_FLOAT16
] = unpack_RGBA_FLOAT16
;
2388 table
[MESA_FORMAT_RGB_FLOAT32
] = unpack_RGB_FLOAT32
;
2389 table
[MESA_FORMAT_RGB_FLOAT16
] = unpack_RGB_FLOAT16
;
2390 table
[MESA_FORMAT_ALPHA_FLOAT32
] = unpack_ALPHA_FLOAT32
;
2391 table
[MESA_FORMAT_ALPHA_FLOAT16
] = unpack_ALPHA_FLOAT16
;
2392 table
[MESA_FORMAT_LUMINANCE_FLOAT32
] = unpack_LUMINANCE_FLOAT32
;
2393 table
[MESA_FORMAT_LUMINANCE_FLOAT16
] = unpack_LUMINANCE_FLOAT16
;
2394 table
[MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32
] = unpack_LUMINANCE_ALPHA_FLOAT32
;
2395 table
[MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16
] = unpack_LUMINANCE_ALPHA_FLOAT16
;
2396 table
[MESA_FORMAT_INTENSITY_FLOAT32
] = unpack_INTENSITY_FLOAT32
;
2397 table
[MESA_FORMAT_INTENSITY_FLOAT16
] = unpack_INTENSITY_FLOAT16
;
2398 table
[MESA_FORMAT_R_FLOAT32
] = unpack_R_FLOAT32
;
2399 table
[MESA_FORMAT_R_FLOAT16
] = unpack_R_FLOAT16
;
2400 table
[MESA_FORMAT_RG_FLOAT32
] = unpack_RG_FLOAT32
;
2401 table
[MESA_FORMAT_RG_FLOAT16
] = unpack_RG_FLOAT16
;
2403 table
[MESA_FORMAT_ALPHA_UINT8
] = unpack_ALPHA_UINT8
;
2404 table
[MESA_FORMAT_ALPHA_UINT16
] = unpack_ALPHA_UINT16
;
2405 table
[MESA_FORMAT_ALPHA_UINT32
] = unpack_ALPHA_UINT32
;
2406 table
[MESA_FORMAT_ALPHA_INT8
] = unpack_ALPHA_INT8
;
2407 table
[MESA_FORMAT_ALPHA_INT16
] = unpack_ALPHA_INT16
;
2408 table
[MESA_FORMAT_ALPHA_INT32
] = unpack_ALPHA_INT32
;
2410 table
[MESA_FORMAT_INTENSITY_UINT8
] = unpack_INTENSITY_UINT8
;
2411 table
[MESA_FORMAT_INTENSITY_UINT16
] = unpack_INTENSITY_UINT16
;
2412 table
[MESA_FORMAT_INTENSITY_UINT32
] = unpack_INTENSITY_UINT32
;
2413 table
[MESA_FORMAT_INTENSITY_INT8
] = unpack_INTENSITY_INT8
;
2414 table
[MESA_FORMAT_INTENSITY_INT16
] = unpack_INTENSITY_INT16
;
2415 table
[MESA_FORMAT_INTENSITY_INT32
] = unpack_INTENSITY_INT32
;
2417 table
[MESA_FORMAT_LUMINANCE_UINT8
] = unpack_LUMINANCE_UINT8
;
2418 table
[MESA_FORMAT_LUMINANCE_UINT16
] = unpack_LUMINANCE_UINT16
;
2419 table
[MESA_FORMAT_LUMINANCE_UINT32
] = unpack_LUMINANCE_UINT32
;
2420 table
[MESA_FORMAT_LUMINANCE_INT8
] = unpack_LUMINANCE_INT8
;
2421 table
[MESA_FORMAT_LUMINANCE_INT16
] = unpack_LUMINANCE_INT16
;
2422 table
[MESA_FORMAT_LUMINANCE_INT32
] = unpack_LUMINANCE_INT32
;
2424 table
[MESA_FORMAT_LUMINANCE_ALPHA_UINT8
] = unpack_LUMINANCE_ALPHA_UINT8
;
2425 table
[MESA_FORMAT_LUMINANCE_ALPHA_UINT16
] = unpack_LUMINANCE_ALPHA_UINT16
;
2426 table
[MESA_FORMAT_LUMINANCE_ALPHA_UINT32
] = unpack_LUMINANCE_ALPHA_UINT32
;
2427 table
[MESA_FORMAT_LUMINANCE_ALPHA_INT8
] = unpack_LUMINANCE_ALPHA_INT8
;
2428 table
[MESA_FORMAT_LUMINANCE_ALPHA_INT16
] = unpack_LUMINANCE_ALPHA_INT16
;
2429 table
[MESA_FORMAT_LUMINANCE_ALPHA_INT32
] = unpack_LUMINANCE_ALPHA_INT32
;
2431 table
[MESA_FORMAT_R_INT8
] = unpack_R_INT8
;
2432 table
[MESA_FORMAT_RG_INT8
] = unpack_RG_INT8
;
2433 table
[MESA_FORMAT_RGB_INT8
] = unpack_RGB_INT8
;
2434 table
[MESA_FORMAT_RGBA_INT8
] = unpack_RGBA_INT8
;
2435 table
[MESA_FORMAT_R_INT16
] = unpack_R_INT16
;
2436 table
[MESA_FORMAT_RG_INT16
] = unpack_RG_INT16
;
2437 table
[MESA_FORMAT_RGB_INT16
] = unpack_RGB_INT16
;
2438 table
[MESA_FORMAT_RGBA_INT16
] = unpack_RGBA_INT16
;
2439 table
[MESA_FORMAT_R_INT32
] = unpack_R_INT32
;
2440 table
[MESA_FORMAT_RG_INT32
] = unpack_RG_INT32
;
2441 table
[MESA_FORMAT_RGB_INT32
] = unpack_RGB_INT32
;
2442 table
[MESA_FORMAT_RGBA_INT32
] = unpack_RGBA_INT32
;
2443 table
[MESA_FORMAT_R_UINT8
] = unpack_R_UINT8
;
2444 table
[MESA_FORMAT_RG_UINT8
] = unpack_RG_UINT8
;
2445 table
[MESA_FORMAT_RGB_UINT8
] = unpack_RGB_UINT8
;
2446 table
[MESA_FORMAT_RGBA_UINT8
] = unpack_RGBA_UINT8
;
2447 table
[MESA_FORMAT_R_UINT16
] = unpack_R_UINT16
;
2448 table
[MESA_FORMAT_RG_UINT16
] = unpack_RG_UINT16
;
2449 table
[MESA_FORMAT_RGB_UINT16
] = unpack_RGB_UINT16
;
2450 table
[MESA_FORMAT_RGBA_UINT16
] = unpack_RGBA_UINT16
;
2451 table
[MESA_FORMAT_R_UINT32
] = unpack_R_UINT32
;
2452 table
[MESA_FORMAT_RG_UINT32
] = unpack_RG_UINT32
;
2453 table
[MESA_FORMAT_RGB_UINT32
] = unpack_RGB_UINT32
;
2454 table
[MESA_FORMAT_RGBA_UINT32
] = unpack_RGBA_UINT32
;
2456 table
[MESA_FORMAT_DUDV8
] = unpack_DUDV8
;
2457 table
[MESA_FORMAT_SIGNED_R8
] = unpack_SIGNED_R8
;
2458 table
[MESA_FORMAT_SIGNED_RG88_REV
] = unpack_SIGNED_RG88_REV
;
2459 table
[MESA_FORMAT_SIGNED_RGBX8888
] = unpack_SIGNED_RGBX8888
;
2460 table
[MESA_FORMAT_SIGNED_RGBA8888
] = unpack_SIGNED_RGBA8888
;
2461 table
[MESA_FORMAT_SIGNED_RGBA8888_REV
] = unpack_SIGNED_RGBA8888_REV
;
2462 table
[MESA_FORMAT_SIGNED_R16
] = unpack_SIGNED_R16
;
2463 table
[MESA_FORMAT_SIGNED_GR1616
] = unpack_SIGNED_GR1616
;
2464 table
[MESA_FORMAT_SIGNED_RGB_16
] = unpack_SIGNED_RGB_16
;
2465 table
[MESA_FORMAT_SIGNED_RGBA_16
] = unpack_SIGNED_RGBA_16
;
2466 table
[MESA_FORMAT_RGBA_16
] = unpack_RGBA_16
;
2468 table
[MESA_FORMAT_RED_RGTC1
] = unpack_RED_RGTC1
;
2469 table
[MESA_FORMAT_SIGNED_RED_RGTC1
] = unpack_SIGNED_RED_RGTC1
;
2470 table
[MESA_FORMAT_RG_RGTC2
] = unpack_RG_RGTC2
;
2471 table
[MESA_FORMAT_SIGNED_RG_RGTC2
] = unpack_SIGNED_RG_RGTC2
;
2473 table
[MESA_FORMAT_L_LATC1
] = unpack_L_LATC1
;
2474 table
[MESA_FORMAT_SIGNED_L_LATC1
] = unpack_SIGNED_L_LATC1
;
2475 table
[MESA_FORMAT_LA_LATC2
] = unpack_LA_LATC2
;
2476 table
[MESA_FORMAT_SIGNED_LA_LATC2
] = unpack_SIGNED_LA_LATC2
;
2478 table
[MESA_FORMAT_ETC1_RGB8
] = unpack_ETC1_RGB8
;
2479 table
[MESA_FORMAT_ETC2_RGB8
] = unpack_ETC2_RGB8
;
2480 table
[MESA_FORMAT_ETC2_SRGB8
] = unpack_ETC2_SRGB8
;
2481 table
[MESA_FORMAT_ETC2_RGBA8_EAC
] = unpack_ETC2_RGBA8_EAC
;
2482 table
[MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC
] = unpack_ETC2_SRGB8_ALPHA8_EAC
;
2483 table
[MESA_FORMAT_ETC2_R11_EAC
] = unpack_ETC2_R11_EAC
;
2484 table
[MESA_FORMAT_ETC2_RG11_EAC
] = unpack_ETC2_RG11_EAC
;
2485 table
[MESA_FORMAT_ETC2_SIGNED_R11_EAC
] = unpack_ETC2_SIGNED_R11_EAC
;
2486 table
[MESA_FORMAT_ETC2_SIGNED_RG11_EAC
] = unpack_ETC2_SIGNED_RG11_EAC
;
2487 table
[MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1
] =
2488 unpack_ETC2_RGB8_PUNCHTHROUGH_ALPHA1
;
2489 table
[MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
] =
2490 unpack_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
;
2491 table
[MESA_FORMAT_SIGNED_A8
] = unpack_SIGNED_A8
;
2492 table
[MESA_FORMAT_SIGNED_L8
] = unpack_SIGNED_L8
;
2493 table
[MESA_FORMAT_SIGNED_AL88
] = unpack_SIGNED_AL88
;
2494 table
[MESA_FORMAT_SIGNED_I8
] = unpack_SIGNED_I8
;
2495 table
[MESA_FORMAT_SIGNED_A16
] = unpack_SIGNED_A16
;
2496 table
[MESA_FORMAT_SIGNED_L16
] = unpack_SIGNED_L16
;
2497 table
[MESA_FORMAT_SIGNED_AL1616
] = unpack_SIGNED_AL1616
;
2498 table
[MESA_FORMAT_SIGNED_I16
] = unpack_SIGNED_I16
;
2500 table
[MESA_FORMAT_RGB9_E5_FLOAT
] = unpack_RGB9_E5_FLOAT
;
2501 table
[MESA_FORMAT_R11_G11_B10_FLOAT
] = unpack_R11_G11_B10_FLOAT
;
2503 table
[MESA_FORMAT_Z32_FLOAT
] = unpack_Z32_FLOAT
;
2504 table
[MESA_FORMAT_Z32_FLOAT_X24S8
] = unpack_Z32_FLOAT_X24S8
;
2506 table
[MESA_FORMAT_XRGB4444_UNORM
] = unpack_XRGB4444_UNORM
;
2507 table
[MESA_FORMAT_XRGB1555_UNORM
] = unpack_XRGB1555_UNORM
;
2508 table
[MESA_FORMAT_XBGR8888_SNORM
] = unpack_XBGR8888_SNORM
;
2509 table
[MESA_FORMAT_XBGR8888_SRGB
] = unpack_XBGR8888_SRGB
;
2510 table
[MESA_FORMAT_XBGR8888_UINT
] = unpack_XBGR8888_UINT
;
2511 table
[MESA_FORMAT_XBGR8888_SINT
] = unpack_XBGR8888_SINT
;
2512 table
[MESA_FORMAT_XRGB2101010_UNORM
] = unpack_XRGB2101010_UNORM
;
2513 table
[MESA_FORMAT_XBGR16161616_UNORM
] = unpack_XBGR16161616_UNORM
;
2514 table
[MESA_FORMAT_XBGR16161616_SNORM
] = unpack_XBGR16161616_SNORM
;
2515 table
[MESA_FORMAT_XBGR16161616_FLOAT
] = unpack_XBGR16161616_FLOAT
;
2516 table
[MESA_FORMAT_XBGR16161616_UINT
] = unpack_XBGR16161616_UINT
;
2517 table
[MESA_FORMAT_XBGR16161616_SINT
] = unpack_XBGR16161616_SINT
;
2518 table
[MESA_FORMAT_XBGR32323232_FLOAT
] = unpack_XBGR32323232_FLOAT
;
2519 table
[MESA_FORMAT_XBGR32323232_UINT
] = unpack_XBGR32323232_UINT
;
2520 table
[MESA_FORMAT_XBGR32323232_SINT
] = unpack_XBGR32323232_SINT
;
2522 table
[MESA_FORMAT_ABGR2101010
] = unpack_ABGR2101010
;
2524 table
[MESA_FORMAT_SIGNED_RG88
] = unpack_SIGNED_RG88
;
2525 table
[MESA_FORMAT_SIGNED_RG1616
] = unpack_SIGNED_RG1616
;
2527 initialized
= GL_TRUE
;
2530 if (table
[format
] == NULL
) {
2531 _mesa_problem(NULL
, "unsupported unpack for format %s",
2532 _mesa_get_format_name(format
));
2535 return table
[format
];
2540 * Unpack rgba colors, returning as GLfloat values.
2543 _mesa_unpack_rgba_row(gl_format format
, GLuint n
,
2544 const void *src
, GLfloat dst
[][4])
2546 unpack_rgba_func unpack
= get_unpack_rgba_function(format
);
2547 unpack(src
, dst
, n
);
2551 /**********************************************************************/
2552 /* Unpack, returning GLubyte colors */
2553 /**********************************************************************/
2557 unpack_ubyte_RGBA8888(const void *src
, GLubyte dst
[][4], GLuint n
)
2559 const GLuint
*s
= ((const GLuint
*) src
);
2561 for (i
= 0; i
< n
; i
++) {
2562 dst
[i
][RCOMP
] = (s
[i
] >> 24);
2563 dst
[i
][GCOMP
] = (s
[i
] >> 16) & 0xff;
2564 dst
[i
][BCOMP
] = (s
[i
] >> 8) & 0xff;
2565 dst
[i
][ACOMP
] = (s
[i
] ) & 0xff;
2570 unpack_ubyte_RGBA8888_REV(const void *src
, GLubyte dst
[][4], GLuint n
)
2572 const GLuint
*s
= ((const GLuint
*) src
);
2574 for (i
= 0; i
< n
; i
++) {
2575 dst
[i
][RCOMP
] = (s
[i
] ) & 0xff;
2576 dst
[i
][GCOMP
] = (s
[i
] >> 8) & 0xff;
2577 dst
[i
][BCOMP
] = (s
[i
] >> 16) & 0xff;
2578 dst
[i
][ACOMP
] = (s
[i
] >> 24);
2583 unpack_ubyte_ARGB8888(const void *src
, GLubyte dst
[][4], GLuint n
)
2585 const GLuint
*s
= ((const GLuint
*) src
);
2587 for (i
= 0; i
< n
; i
++) {
2588 dst
[i
][RCOMP
] = (s
[i
] >> 16) & 0xff;
2589 dst
[i
][GCOMP
] = (s
[i
] >> 8) & 0xff;
2590 dst
[i
][BCOMP
] = (s
[i
] ) & 0xff;
2591 dst
[i
][ACOMP
] = (s
[i
] >> 24);
2596 unpack_ubyte_ARGB8888_REV(const void *src
, GLubyte dst
[][4], GLuint n
)
2598 const GLuint
*s
= ((const GLuint
*) src
);
2600 for (i
= 0; i
< n
; i
++) {
2601 dst
[i
][RCOMP
] = (s
[i
] >> 8) & 0xff;
2602 dst
[i
][GCOMP
] = (s
[i
] >> 16) & 0xff;
2603 dst
[i
][BCOMP
] = (s
[i
] >> 24);
2604 dst
[i
][ACOMP
] = (s
[i
] ) & 0xff;
2609 unpack_ubyte_RGBX8888(const void *src
, GLubyte dst
[][4], GLuint n
)
2611 const GLuint
*s
= ((const GLuint
*) src
);
2613 for (i
= 0; i
< n
; i
++) {
2614 dst
[i
][RCOMP
] = (s
[i
] >> 24);
2615 dst
[i
][GCOMP
] = (s
[i
] >> 16) & 0xff;
2616 dst
[i
][BCOMP
] = (s
[i
] >> 8) & 0xff;
2617 dst
[i
][ACOMP
] = 0xff;
2622 unpack_ubyte_RGBX8888_REV(const void *src
, GLubyte dst
[][4], GLuint n
)
2624 const GLuint
*s
= ((const GLuint
*) src
);
2626 for (i
= 0; i
< n
; i
++) {
2627 dst
[i
][RCOMP
] = (s
[i
] ) & 0xff;
2628 dst
[i
][GCOMP
] = (s
[i
] >> 8) & 0xff;
2629 dst
[i
][BCOMP
] = (s
[i
] >> 16) & 0xff;
2630 dst
[i
][ACOMP
] = 0xff;
2635 unpack_ubyte_XRGB8888(const void *src
, GLubyte dst
[][4], GLuint n
)
2637 const GLuint
*s
= ((const GLuint
*) src
);
2639 for (i
= 0; i
< n
; i
++) {
2640 dst
[i
][RCOMP
] = (s
[i
] >> 16) & 0xff;
2641 dst
[i
][GCOMP
] = (s
[i
] >> 8) & 0xff;
2642 dst
[i
][BCOMP
] = (s
[i
] ) & 0xff;
2643 dst
[i
][ACOMP
] = 0xff;
2648 unpack_ubyte_XRGB8888_REV(const void *src
, GLubyte dst
[][4], GLuint n
)
2650 const GLuint
*s
= ((const GLuint
*) src
);
2652 for (i
= 0; i
< n
; i
++) {
2653 dst
[i
][RCOMP
] = (s
[i
] >> 8) & 0xff;
2654 dst
[i
][GCOMP
] = (s
[i
] >> 16) & 0xff;
2655 dst
[i
][BCOMP
] = (s
[i
] >> 24);
2656 dst
[i
][ACOMP
] = 0xff;
2661 unpack_ubyte_RGB888(const void *src
, GLubyte dst
[][4], GLuint n
)
2663 const GLubyte
*s
= (const GLubyte
*) src
;
2665 for (i
= 0; i
< n
; i
++) {
2666 dst
[i
][RCOMP
] = s
[i
*3+2];
2667 dst
[i
][GCOMP
] = s
[i
*3+1];
2668 dst
[i
][BCOMP
] = s
[i
*3+0];
2669 dst
[i
][ACOMP
] = 0xff;
2674 unpack_ubyte_BGR888(const void *src
, GLubyte dst
[][4], GLuint n
)
2676 const GLubyte
*s
= (const GLubyte
*) src
;
2678 for (i
= 0; i
< n
; i
++) {
2679 dst
[i
][RCOMP
] = s
[i
*3+0];
2680 dst
[i
][GCOMP
] = s
[i
*3+1];
2681 dst
[i
][BCOMP
] = s
[i
*3+2];
2682 dst
[i
][ACOMP
] = 0xff;
2687 unpack_ubyte_RGB565(const void *src
, GLubyte dst
[][4], GLuint n
)
2689 const GLushort
*s
= ((const GLushort
*) src
);
2691 for (i
= 0; i
< n
; i
++) {
2692 dst
[i
][RCOMP
] = EXPAND_5_8((s
[i
] >> 11) & 0x1f);
2693 dst
[i
][GCOMP
] = EXPAND_6_8((s
[i
] >> 5 ) & 0x3f);
2694 dst
[i
][BCOMP
] = EXPAND_5_8( s
[i
] & 0x1f);
2695 dst
[i
][ACOMP
] = 0xff;
2700 unpack_ubyte_RGB565_REV(const void *src
, GLubyte dst
[][4], GLuint n
)
2702 const GLushort
*s
= ((const GLushort
*) src
);
2704 for (i
= 0; i
< n
; i
++) {
2705 GLuint t
= (s
[i
] >> 8) | (s
[i
] << 8); /* byte swap */
2706 dst
[i
][RCOMP
] = EXPAND_5_8((t
>> 11) & 0x1f);
2707 dst
[i
][GCOMP
] = EXPAND_6_8((t
>> 5 ) & 0x3f);
2708 dst
[i
][BCOMP
] = EXPAND_5_8( t
& 0x1f);
2709 dst
[i
][ACOMP
] = 0xff;
2714 unpack_ubyte_ARGB4444(const void *src
, GLubyte dst
[][4], GLuint n
)
2716 const GLushort
*s
= ((const GLushort
*) src
);
2718 for (i
= 0; i
< n
; i
++) {
2719 dst
[i
][RCOMP
] = EXPAND_4_8((s
[i
] >> 8) & 0xf);
2720 dst
[i
][GCOMP
] = EXPAND_4_8((s
[i
] >> 4) & 0xf);
2721 dst
[i
][BCOMP
] = EXPAND_4_8((s
[i
] ) & 0xf);
2722 dst
[i
][ACOMP
] = EXPAND_4_8((s
[i
] >> 12) & 0xf);
2727 unpack_ubyte_ARGB4444_REV(const void *src
, GLubyte dst
[][4], GLuint n
)
2729 const GLushort
*s
= ((const GLushort
*) src
);
2731 for (i
= 0; i
< n
; i
++) {
2732 dst
[i
][RCOMP
] = EXPAND_4_8((s
[i
] ) & 0xf);
2733 dst
[i
][GCOMP
] = EXPAND_4_8((s
[i
] >> 12) & 0xf);
2734 dst
[i
][BCOMP
] = EXPAND_4_8((s
[i
] >> 8) & 0xf);
2735 dst
[i
][ACOMP
] = EXPAND_4_8((s
[i
] >> 4) & 0xf);
2740 unpack_ubyte_RGBA5551(const void *src
, GLubyte dst
[][4], GLuint n
)
2742 const GLushort
*s
= ((const GLushort
*) src
);
2744 for (i
= 0; i
< n
; i
++) {
2745 dst
[i
][RCOMP
] = EXPAND_5_8((s
[i
] >> 11) & 0x1f);
2746 dst
[i
][GCOMP
] = EXPAND_5_8((s
[i
] >> 6) & 0x1f);
2747 dst
[i
][BCOMP
] = EXPAND_5_8((s
[i
] >> 1) & 0x1f);
2748 dst
[i
][ACOMP
] = EXPAND_1_8((s
[i
] ) & 0x01);
2753 unpack_ubyte_ARGB1555(const void *src
, GLubyte dst
[][4], GLuint n
)
2755 const GLushort
*s
= ((const GLushort
*) src
);
2757 for (i
= 0; i
< n
; i
++) {
2758 dst
[i
][RCOMP
] = EXPAND_5_8((s
[i
] >> 10) & 0x1f);
2759 dst
[i
][GCOMP
] = EXPAND_5_8((s
[i
] >> 5) & 0x1f);
2760 dst
[i
][BCOMP
] = EXPAND_5_8((s
[i
] >> 0) & 0x1f);
2761 dst
[i
][ACOMP
] = EXPAND_1_8((s
[i
] >> 15) & 0x01);
2766 unpack_ubyte_ARGB1555_REV(const void *src
, GLubyte dst
[][4], GLuint n
)
2768 const GLushort
*s
= ((const GLushort
*) src
);
2770 for (i
= 0; i
< n
; i
++) {
2771 GLushort tmp
= (s
[i
] << 8) | (s
[i
] >> 8); /* byteswap */
2772 dst
[i
][RCOMP
] = EXPAND_5_8((tmp
>> 10) & 0x1f);
2773 dst
[i
][GCOMP
] = EXPAND_5_8((tmp
>> 5) & 0x1f);
2774 dst
[i
][BCOMP
] = EXPAND_5_8((tmp
>> 0) & 0x1f);
2775 dst
[i
][ACOMP
] = EXPAND_1_8((tmp
>> 15) & 0x01);
2780 unpack_ubyte_AL44(const void *src
, GLubyte dst
[][4], GLuint n
)
2782 const GLubyte
*s
= ((const GLubyte
*) src
);
2784 for (i
= 0; i
< n
; i
++) {
2787 dst
[i
][BCOMP
] = EXPAND_4_8(s
[i
] & 0xf);
2788 dst
[i
][ACOMP
] = EXPAND_4_8(s
[i
] >> 4);
2793 unpack_ubyte_AL88(const void *src
, GLubyte dst
[][4], GLuint n
)
2795 const GLushort
*s
= ((const GLushort
*) src
);
2797 for (i
= 0; i
< n
; i
++) {
2800 dst
[i
][BCOMP
] = EXPAND_4_8(s
[i
] & 0xff);
2801 dst
[i
][ACOMP
] = EXPAND_4_8(s
[i
] >> 8);
2806 unpack_ubyte_AL88_REV(const void *src
, GLubyte dst
[][4], GLuint n
)
2808 const GLushort
*s
= ((const GLushort
*) src
);
2810 for (i
= 0; i
< n
; i
++) {
2813 dst
[i
][BCOMP
] = EXPAND_4_8(s
[i
] >> 8);
2814 dst
[i
][ACOMP
] = EXPAND_4_8(s
[i
] & 0xff);
2819 unpack_ubyte_RGB332(const void *src
, GLubyte dst
[][4], GLuint n
)
2821 const GLubyte
*s
= ((const GLubyte
*) src
);
2823 for (i
= 0; i
< n
; i
++) {
2824 dst
[i
][RCOMP
] = EXPAND_3_8((s
[i
] >> 5) & 0x7);
2825 dst
[i
][GCOMP
] = EXPAND_3_8((s
[i
] >> 2) & 0x7);
2826 dst
[i
][BCOMP
] = EXPAND_2_8((s
[i
] ) & 0x3);
2827 dst
[i
][ACOMP
] = 0xff;
2832 unpack_ubyte_A8(const void *src
, GLubyte dst
[][4], GLuint n
)
2834 const GLubyte
*s
= ((const GLubyte
*) src
);
2836 for (i
= 0; i
< n
; i
++) {
2840 dst
[i
][ACOMP
] = s
[i
];
2845 unpack_ubyte_L8(const void *src
, GLubyte dst
[][4], GLuint n
)
2847 const GLubyte
*s
= ((const GLubyte
*) src
);
2849 for (i
= 0; i
< n
; i
++) {
2852 dst
[i
][BCOMP
] = s
[i
];
2853 dst
[i
][ACOMP
] = 0xff;
2859 unpack_ubyte_I8(const void *src
, GLubyte dst
[][4], GLuint n
)
2861 const GLubyte
*s
= ((const GLubyte
*) src
);
2863 for (i
= 0; i
< n
; i
++) {
2867 dst
[i
][ACOMP
] = s
[i
];
2872 unpack_ubyte_R8(const void *src
, GLubyte dst
[][4], GLuint n
)
2874 const GLubyte
*s
= ((const GLubyte
*) src
);
2876 for (i
= 0; i
< n
; i
++) {
2885 unpack_ubyte_GR88(const void *src
, GLubyte dst
[][4], GLuint n
)
2887 const GLushort
*s
= ((const GLushort
*) src
);
2889 for (i
= 0; i
< n
; i
++) {
2890 dst
[i
][RCOMP
] = s
[i
] & 0xff;
2891 dst
[i
][GCOMP
] = s
[i
] >> 8;
2893 dst
[i
][ACOMP
] = 0xff;
2898 unpack_ubyte_RG88(const void *src
, GLubyte dst
[][4], GLuint n
)
2900 const GLushort
*s
= ((const GLushort
*) src
);
2902 for (i
= 0; i
< n
; i
++) {
2903 dst
[i
][RCOMP
] = s
[i
] >> 8;
2904 dst
[i
][GCOMP
] = s
[i
] & 0xff;
2906 dst
[i
][ACOMP
] = 0xff;
2912 * Unpack rgba colors, returning as GLubyte values. This should usually
2913 * only be used for unpacking formats that use 8 bits or less per channel.
2916 _mesa_unpack_ubyte_rgba_row(gl_format format
, GLuint n
,
2917 const void *src
, GLubyte dst
[][4])
2920 case MESA_FORMAT_RGBA8888
:
2921 unpack_ubyte_RGBA8888(src
, dst
, n
);
2923 case MESA_FORMAT_RGBA8888_REV
:
2924 unpack_ubyte_RGBA8888_REV(src
, dst
, n
);
2926 case MESA_FORMAT_ARGB8888
:
2927 unpack_ubyte_ARGB8888(src
, dst
, n
);
2929 case MESA_FORMAT_ARGB8888_REV
:
2930 unpack_ubyte_ARGB8888_REV(src
, dst
, n
);
2932 case MESA_FORMAT_RGBX8888
:
2933 unpack_ubyte_RGBX8888(src
, dst
, n
);
2935 case MESA_FORMAT_RGBX8888_REV
:
2936 unpack_ubyte_RGBX8888_REV(src
, dst
, n
);
2938 case MESA_FORMAT_XRGB8888
:
2939 unpack_ubyte_XRGB8888(src
, dst
, n
);
2941 case MESA_FORMAT_XRGB8888_REV
:
2942 unpack_ubyte_XRGB8888_REV(src
, dst
, n
);
2944 case MESA_FORMAT_RGB888
:
2945 unpack_ubyte_RGB888(src
, dst
, n
);
2947 case MESA_FORMAT_BGR888
:
2948 unpack_ubyte_BGR888(src
, dst
, n
);
2950 case MESA_FORMAT_RGB565
:
2951 unpack_ubyte_RGB565(src
, dst
, n
);
2953 case MESA_FORMAT_RGB565_REV
:
2954 unpack_ubyte_RGB565_REV(src
, dst
, n
);
2956 case MESA_FORMAT_ARGB4444
:
2957 unpack_ubyte_ARGB4444(src
, dst
, n
);
2959 case MESA_FORMAT_ARGB4444_REV
:
2960 unpack_ubyte_ARGB4444_REV(src
, dst
, n
);
2962 case MESA_FORMAT_RGBA5551
:
2963 unpack_ubyte_RGBA5551(src
, dst
, n
);
2965 case MESA_FORMAT_ARGB1555
:
2966 unpack_ubyte_ARGB1555(src
, dst
, n
);
2968 case MESA_FORMAT_ARGB1555_REV
:
2969 unpack_ubyte_ARGB1555_REV(src
, dst
, n
);
2971 case MESA_FORMAT_AL44
:
2972 unpack_ubyte_AL44(src
, dst
, n
);
2974 case MESA_FORMAT_AL88
:
2975 unpack_ubyte_AL88(src
, dst
, n
);
2977 case MESA_FORMAT_AL88_REV
:
2978 unpack_ubyte_AL88_REV(src
, dst
, n
);
2980 case MESA_FORMAT_RGB332
:
2981 unpack_ubyte_RGB332(src
, dst
, n
);
2983 case MESA_FORMAT_A8
:
2984 unpack_ubyte_A8(src
, dst
, n
);
2986 case MESA_FORMAT_L8
:
2987 unpack_ubyte_L8(src
, dst
, n
);
2989 case MESA_FORMAT_I8
:
2990 unpack_ubyte_I8(src
, dst
, n
);
2992 case MESA_FORMAT_R8
:
2993 unpack_ubyte_R8(src
, dst
, n
);
2995 case MESA_FORMAT_GR88
:
2996 unpack_ubyte_GR88(src
, dst
, n
);
2998 case MESA_FORMAT_RG88
:
2999 unpack_ubyte_RG88(src
, dst
, n
);
3002 /* get float values, convert to ubyte */
3004 GLfloat
*tmp
= malloc(n
* 4 * sizeof(GLfloat
));
3007 _mesa_unpack_rgba_row(format
, n
, src
, (GLfloat (*)[4]) tmp
);
3008 for (i
= 0; i
< n
; i
++) {
3009 UNCLAMPED_FLOAT_TO_UBYTE(dst
[i
][0], tmp
[i
*4+0]);
3010 UNCLAMPED_FLOAT_TO_UBYTE(dst
[i
][1], tmp
[i
*4+1]);
3011 UNCLAMPED_FLOAT_TO_UBYTE(dst
[i
][2], tmp
[i
*4+2]);
3012 UNCLAMPED_FLOAT_TO_UBYTE(dst
[i
][3], tmp
[i
*4+3]);
3022 /**********************************************************************/
3023 /* Unpack, returning GLuint colors */
3024 /**********************************************************************/
3027 unpack_int_rgba_RGBA_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3029 memcpy(dst
, src
, n
* 4 * sizeof(GLuint
));
3033 unpack_int_rgba_RGBA_UINT16(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
3037 for (i
= 0; i
< n
; i
++) {
3038 dst
[i
][0] = src
[i
* 4 + 0];
3039 dst
[i
][1] = src
[i
* 4 + 1];
3040 dst
[i
][2] = src
[i
* 4 + 2];
3041 dst
[i
][3] = src
[i
* 4 + 3];
3046 unpack_int_rgba_RGBA_INT16(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
3050 for (i
= 0; i
< n
; i
++) {
3051 dst
[i
][0] = src
[i
* 4 + 0];
3052 dst
[i
][1] = src
[i
* 4 + 1];
3053 dst
[i
][2] = src
[i
* 4 + 2];
3054 dst
[i
][3] = src
[i
* 4 + 3];
3059 unpack_int_rgba_RGBA_UINT8(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
3063 for (i
= 0; i
< n
; i
++) {
3064 dst
[i
][0] = src
[i
* 4 + 0];
3065 dst
[i
][1] = src
[i
* 4 + 1];
3066 dst
[i
][2] = src
[i
* 4 + 2];
3067 dst
[i
][3] = src
[i
* 4 + 3];
3072 unpack_int_rgba_RGBA_INT8(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3076 for (i
= 0; i
< n
; i
++) {
3077 dst
[i
][0] = src
[i
* 4 + 0];
3078 dst
[i
][1] = src
[i
* 4 + 1];
3079 dst
[i
][2] = src
[i
* 4 + 2];
3080 dst
[i
][3] = src
[i
* 4 + 3];
3085 unpack_int_rgba_ARGB8888(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3089 for (i
= 0; i
< n
; i
++) {
3090 dst
[i
][RCOMP
] = (GLubyte
) src
[i
* 4 + 2];
3091 dst
[i
][GCOMP
] = (GLubyte
) src
[i
* 4 + 1];
3092 dst
[i
][BCOMP
] = (GLubyte
) src
[i
* 4 + 0];
3093 dst
[i
][ACOMP
] = (GLubyte
) src
[i
* 4 + 3];
3098 unpack_int_rgba_XRGB8888(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3102 for (i
= 0; i
< n
; i
++) {
3103 dst
[i
][RCOMP
] = (GLubyte
) src
[i
* 4 + 2];
3104 dst
[i
][GCOMP
] = (GLubyte
) src
[i
* 4 + 1];
3105 dst
[i
][BCOMP
] = (GLubyte
) src
[i
* 4 + 0];
3106 dst
[i
][ACOMP
] = (GLubyte
) 0xff;
3111 unpack_int_rgba_RGB_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3115 for (i
= 0; i
< n
; i
++) {
3116 dst
[i
][0] = src
[i
* 3 + 0];
3117 dst
[i
][1] = src
[i
* 3 + 1];
3118 dst
[i
][2] = src
[i
* 3 + 2];
3124 unpack_int_rgba_RGB_UINT16(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
3128 for (i
= 0; i
< n
; i
++) {
3129 dst
[i
][0] = src
[i
* 3 + 0];
3130 dst
[i
][1] = src
[i
* 3 + 1];
3131 dst
[i
][2] = src
[i
* 3 + 2];
3137 unpack_int_rgba_RGB_INT16(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
3141 for (i
= 0; i
< n
; i
++) {
3142 dst
[i
][0] = src
[i
* 3 + 0];
3143 dst
[i
][1] = src
[i
* 3 + 1];
3144 dst
[i
][2] = src
[i
* 3 + 2];
3150 unpack_int_rgba_RGB_UINT8(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
3154 for (i
= 0; i
< n
; i
++) {
3155 dst
[i
][0] = src
[i
* 3 + 0];
3156 dst
[i
][1] = src
[i
* 3 + 1];
3157 dst
[i
][2] = src
[i
* 3 + 2];
3163 unpack_int_rgba_RGB_INT8(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3167 for (i
= 0; i
< n
; i
++) {
3168 dst
[i
][0] = src
[i
* 3 + 0];
3169 dst
[i
][1] = src
[i
* 3 + 1];
3170 dst
[i
][2] = src
[i
* 3 + 2];
3176 unpack_int_rgba_RG_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3180 for (i
= 0; i
< n
; i
++) {
3181 dst
[i
][0] = src
[i
* 2 + 0];
3182 dst
[i
][1] = src
[i
* 2 + 1];
3189 unpack_int_rgba_RG_UINT16(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
3193 for (i
= 0; i
< n
; i
++) {
3194 dst
[i
][0] = src
[i
* 2 + 0];
3195 dst
[i
][1] = src
[i
* 2 + 1];
3202 unpack_int_rgba_RG_INT16(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
3206 for (i
= 0; i
< n
; i
++) {
3207 dst
[i
][0] = src
[i
* 2 + 0];
3208 dst
[i
][1] = src
[i
* 2 + 1];
3215 unpack_int_rgba_RG_UINT8(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
3219 for (i
= 0; i
< n
; i
++) {
3220 dst
[i
][0] = src
[i
* 2 + 0];
3221 dst
[i
][1] = src
[i
* 2 + 1];
3228 unpack_int_rgba_RG_INT8(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3232 for (i
= 0; i
< n
; i
++) {
3233 dst
[i
][0] = src
[i
* 2 + 0];
3234 dst
[i
][1] = src
[i
* 2 + 1];
3241 unpack_int_rgba_R_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3245 for (i
= 0; i
< n
; i
++) {
3254 unpack_int_rgba_R_UINT16(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
3258 for (i
= 0; i
< n
; i
++) {
3267 unpack_int_rgba_R_INT16(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
3271 for (i
= 0; i
< n
; i
++) {
3280 unpack_int_rgba_R_UINT8(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
3284 for (i
= 0; i
< n
; i
++) {
3293 unpack_int_rgba_R_INT8(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3297 for (i
= 0; i
< n
; i
++) {
3306 unpack_int_rgba_ALPHA_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3310 for (i
= 0; i
< n
; i
++) {
3311 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = 0;
3317 unpack_int_rgba_ALPHA_UINT16(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
3321 for (i
= 0; i
< n
; i
++) {
3322 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = 0;
3328 unpack_int_rgba_ALPHA_INT16(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
3332 for (i
= 0; i
< n
; i
++) {
3333 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = 0;
3339 unpack_int_rgba_ALPHA_UINT8(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
3343 for (i
= 0; i
< n
; i
++) {
3344 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = 0;
3350 unpack_int_rgba_ALPHA_INT8(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3354 for (i
= 0; i
< n
; i
++) {
3355 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = 0;
3361 unpack_int_rgba_LUMINANCE_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3365 for (i
= 0; i
< n
; i
++) {
3366 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
];
3372 unpack_int_rgba_LUMINANCE_UINT16(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
3376 for (i
= 0; i
< n
; i
++) {
3377 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
];
3383 unpack_int_rgba_LUMINANCE_INT16(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
3387 for (i
= 0; i
< n
; i
++) {
3388 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
];
3394 unpack_int_rgba_LUMINANCE_UINT8(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
3398 for (i
= 0; i
< n
; i
++) {
3399 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
];
3405 unpack_int_rgba_LUMINANCE_INT8(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3409 for (i
= 0; i
< n
; i
++) {
3410 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
];
3417 unpack_int_rgba_LUMINANCE_ALPHA_UINT32(const GLuint
*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
* 2 + 0];
3423 dst
[i
][3] = src
[i
* 2 + 1];
3428 unpack_int_rgba_LUMINANCE_ALPHA_UINT16(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
3432 for (i
= 0; i
< n
; i
++) {
3433 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
* 2 + 0];
3434 dst
[i
][3] = src
[i
* 2 + 1];
3439 unpack_int_rgba_LUMINANCE_ALPHA_INT16(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
3443 for (i
= 0; i
< n
; i
++) {
3444 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
* 2 + 0];
3445 dst
[i
][3] = src
[i
* 2 + 1];
3450 unpack_int_rgba_LUMINANCE_ALPHA_UINT8(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
3454 for (i
= 0; i
< n
; i
++) {
3455 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
* 2 + 0];
3456 dst
[i
][3] = src
[i
* 2 + 1];
3461 unpack_int_rgba_LUMINANCE_ALPHA_INT8(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3465 for (i
= 0; i
< n
; i
++) {
3466 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
* 2 + 0];
3467 dst
[i
][3] = src
[i
* 2 + 1];
3472 unpack_int_rgba_INTENSITY_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3476 for (i
= 0; i
< n
; i
++) {
3477 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = dst
[i
][3] = src
[i
];
3482 unpack_int_rgba_INTENSITY_UINT16(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
3486 for (i
= 0; i
< n
; i
++) {
3487 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = dst
[i
][3] = src
[i
];
3492 unpack_int_rgba_INTENSITY_INT16(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
3496 for (i
= 0; i
< n
; i
++) {
3497 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = dst
[i
][3] = src
[i
];
3502 unpack_int_rgba_INTENSITY_UINT8(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
3506 for (i
= 0; i
< n
; i
++) {
3507 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = dst
[i
][3] = src
[i
];
3512 unpack_int_rgba_INTENSITY_INT8(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3516 for (i
= 0; i
< n
; i
++) {
3517 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = dst
[i
][3] = src
[i
];
3522 unpack_int_rgba_ARGB2101010_UINT(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3526 for (i
= 0; i
< n
; i
++) {
3527 GLuint tmp
= src
[i
];
3528 dst
[i
][0] = (tmp
>> 20) & 0x3ff;
3529 dst
[i
][1] = (tmp
>> 10) & 0x3ff;
3530 dst
[i
][2] = (tmp
>> 0) & 0x3ff;
3531 dst
[i
][3] = (tmp
>> 30) & 0x3;
3536 unpack_int_rgba_ABGR2101010_UINT(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3540 for (i
= 0; i
< n
; i
++) {
3541 GLuint tmp
= src
[i
];
3542 dst
[i
][0] = (tmp
>> 0) & 0x3ff;
3543 dst
[i
][1] = (tmp
>> 10) & 0x3ff;
3544 dst
[i
][2] = (tmp
>> 20) & 0x3ff;
3545 dst
[i
][3] = (tmp
>> 30) & 0x3;
3550 unpack_int_rgba_ARGB2101010(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3554 for (i
= 0; i
< n
; i
++) {
3555 GLuint tmp
= src
[i
];
3556 dst
[i
][0] = (tmp
>> 20) & 0x3ff;
3557 dst
[i
][1] = (tmp
>> 10) & 0x3ff;
3558 dst
[i
][2] = (tmp
>> 0) & 0x3ff;
3559 dst
[i
][3] = (tmp
>> 30) & 0x3;
3564 unpack_int_rgba_XBGR8888_UINT(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
3568 for (i
= 0; i
< n
; i
++) {
3569 dst
[i
][0] = src
[i
* 4 + 0];
3570 dst
[i
][1] = src
[i
* 4 + 1];
3571 dst
[i
][2] = src
[i
* 4 + 2];
3577 unpack_int_rgba_XBGR8888_SINT(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3581 for (i
= 0; i
< n
; i
++) {
3582 dst
[i
][0] = src
[i
* 4 + 0];
3583 dst
[i
][1] = src
[i
* 4 + 1];
3584 dst
[i
][2] = src
[i
* 4 + 2];
3590 unpack_int_rgba_XBGR16161616_UINT(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
3594 for (i
= 0; i
< n
; i
++) {
3595 dst
[i
][0] = src
[i
* 4 + 0];
3596 dst
[i
][1] = src
[i
* 4 + 1];
3597 dst
[i
][2] = src
[i
* 4 + 2];
3603 unpack_int_rgba_XBGR16161616_SINT(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
3607 for (i
= 0; i
< n
; i
++) {
3608 dst
[i
][0] = src
[i
* 4 + 0];
3609 dst
[i
][1] = src
[i
* 4 + 1];
3610 dst
[i
][2] = src
[i
* 4 + 2];
3616 unpack_int_rgba_XBGR32323232_UINT(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3620 for (i
= 0; i
< n
; i
++) {
3621 dst
[i
][0] = src
[i
* 4 + 0];
3622 dst
[i
][1] = src
[i
* 4 + 1];
3623 dst
[i
][2] = src
[i
* 4 + 2];
3629 unpack_int_rgba_ABGR2101010(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3633 for (i
= 0; i
< n
; i
++) {
3634 GLuint tmp
= src
[i
];
3635 dst
[i
][0] = (tmp
>> 0) & 0x3ff;
3636 dst
[i
][1] = (tmp
>> 10) & 0x3ff;
3637 dst
[i
][2] = (tmp
>> 20) & 0x3ff;
3638 dst
[i
][3] = (tmp
>> 30) & 0x3;
3643 _mesa_unpack_uint_rgba_row(gl_format format
, GLuint n
,
3644 const void *src
, GLuint dst
[][4])
3647 /* Since there won't be any sign extension happening, there's no need to
3648 * make separate paths for 32-bit-to-32-bit integer unpack.
3650 case MESA_FORMAT_RGBA_UINT32
:
3651 case MESA_FORMAT_RGBA_INT32
:
3652 unpack_int_rgba_RGBA_UINT32(src
, dst
, n
);
3655 case MESA_FORMAT_RGBA_UINT16
:
3656 unpack_int_rgba_RGBA_UINT16(src
, dst
, n
);
3658 case MESA_FORMAT_RGBA_INT16
:
3659 unpack_int_rgba_RGBA_INT16(src
, dst
, n
);
3662 case MESA_FORMAT_RGBA_UINT8
:
3663 unpack_int_rgba_RGBA_UINT8(src
, dst
, n
);
3665 case MESA_FORMAT_RGBA_INT8
:
3666 unpack_int_rgba_RGBA_INT8(src
, dst
, n
);
3669 case MESA_FORMAT_ARGB8888
:
3670 unpack_int_rgba_ARGB8888(src
, dst
, n
);
3673 case MESA_FORMAT_XRGB8888
:
3674 unpack_int_rgba_XRGB8888(src
, dst
, n
);
3677 case MESA_FORMAT_RGB_UINT32
:
3678 case MESA_FORMAT_RGB_INT32
:
3679 unpack_int_rgba_RGB_UINT32(src
, dst
, n
);
3682 case MESA_FORMAT_RGB_UINT16
:
3683 unpack_int_rgba_RGB_UINT16(src
, dst
, n
);
3685 case MESA_FORMAT_RGB_INT16
:
3686 unpack_int_rgba_RGB_INT16(src
, dst
, n
);
3689 case MESA_FORMAT_RGB_UINT8
:
3690 unpack_int_rgba_RGB_UINT8(src
, dst
, n
);
3692 case MESA_FORMAT_RGB_INT8
:
3693 unpack_int_rgba_RGB_INT8(src
, dst
, n
);
3696 case MESA_FORMAT_RG_UINT32
:
3697 case MESA_FORMAT_RG_INT32
:
3698 unpack_int_rgba_RG_UINT32(src
, dst
, n
);
3701 case MESA_FORMAT_RG_UINT16
:
3702 unpack_int_rgba_RG_UINT16(src
, dst
, n
);
3704 case MESA_FORMAT_RG_INT16
:
3705 unpack_int_rgba_RG_INT16(src
, dst
, n
);
3708 case MESA_FORMAT_RG_UINT8
:
3709 unpack_int_rgba_RG_UINT8(src
, dst
, n
);
3711 case MESA_FORMAT_RG_INT8
:
3712 unpack_int_rgba_RG_INT8(src
, dst
, n
);
3715 case MESA_FORMAT_R_UINT32
:
3716 case MESA_FORMAT_R_INT32
:
3717 unpack_int_rgba_R_UINT32(src
, dst
, n
);
3720 case MESA_FORMAT_R_UINT16
:
3721 unpack_int_rgba_R_UINT16(src
, dst
, n
);
3723 case MESA_FORMAT_R_INT16
:
3724 unpack_int_rgba_R_INT16(src
, dst
, n
);
3727 case MESA_FORMAT_R_UINT8
:
3728 unpack_int_rgba_R_UINT8(src
, dst
, n
);
3730 case MESA_FORMAT_R_INT8
:
3731 unpack_int_rgba_R_INT8(src
, dst
, n
);
3734 case MESA_FORMAT_ALPHA_UINT32
:
3735 case MESA_FORMAT_ALPHA_INT32
:
3736 unpack_int_rgba_ALPHA_UINT32(src
, dst
, n
);
3739 case MESA_FORMAT_ALPHA_UINT16
:
3740 unpack_int_rgba_ALPHA_UINT16(src
, dst
, n
);
3742 case MESA_FORMAT_ALPHA_INT16
:
3743 unpack_int_rgba_ALPHA_INT16(src
, dst
, n
);
3746 case MESA_FORMAT_ALPHA_UINT8
:
3747 unpack_int_rgba_ALPHA_UINT8(src
, dst
, n
);
3749 case MESA_FORMAT_ALPHA_INT8
:
3750 unpack_int_rgba_ALPHA_INT8(src
, dst
, n
);
3753 case MESA_FORMAT_LUMINANCE_UINT32
:
3754 case MESA_FORMAT_LUMINANCE_INT32
:
3755 unpack_int_rgba_LUMINANCE_UINT32(src
, dst
, n
);
3757 case MESA_FORMAT_LUMINANCE_UINT16
:
3758 unpack_int_rgba_LUMINANCE_UINT16(src
, dst
, n
);
3760 case MESA_FORMAT_LUMINANCE_INT16
:
3761 unpack_int_rgba_LUMINANCE_INT16(src
, dst
, n
);
3764 case MESA_FORMAT_LUMINANCE_UINT8
:
3765 unpack_int_rgba_LUMINANCE_UINT8(src
, dst
, n
);
3767 case MESA_FORMAT_LUMINANCE_INT8
:
3768 unpack_int_rgba_LUMINANCE_INT8(src
, dst
, n
);
3771 case MESA_FORMAT_LUMINANCE_ALPHA_UINT32
:
3772 case MESA_FORMAT_LUMINANCE_ALPHA_INT32
:
3773 unpack_int_rgba_LUMINANCE_ALPHA_UINT32(src
, dst
, n
);
3776 case MESA_FORMAT_LUMINANCE_ALPHA_UINT16
:
3777 unpack_int_rgba_LUMINANCE_ALPHA_UINT16(src
, dst
, n
);
3779 case MESA_FORMAT_LUMINANCE_ALPHA_INT16
:
3780 unpack_int_rgba_LUMINANCE_ALPHA_INT16(src
, dst
, n
);
3783 case MESA_FORMAT_LUMINANCE_ALPHA_UINT8
:
3784 unpack_int_rgba_LUMINANCE_ALPHA_UINT8(src
, dst
, n
);
3786 case MESA_FORMAT_LUMINANCE_ALPHA_INT8
:
3787 unpack_int_rgba_LUMINANCE_ALPHA_INT8(src
, dst
, n
);
3790 case MESA_FORMAT_INTENSITY_UINT32
:
3791 case MESA_FORMAT_INTENSITY_INT32
:
3792 unpack_int_rgba_INTENSITY_UINT32(src
, dst
, n
);
3795 case MESA_FORMAT_INTENSITY_UINT16
:
3796 unpack_int_rgba_INTENSITY_UINT16(src
, dst
, n
);
3798 case MESA_FORMAT_INTENSITY_INT16
:
3799 unpack_int_rgba_INTENSITY_INT16(src
, dst
, n
);
3802 case MESA_FORMAT_INTENSITY_UINT8
:
3803 unpack_int_rgba_INTENSITY_UINT8(src
, dst
, n
);
3805 case MESA_FORMAT_INTENSITY_INT8
:
3806 unpack_int_rgba_INTENSITY_INT8(src
, dst
, n
);
3809 case MESA_FORMAT_ARGB2101010_UINT
:
3810 unpack_int_rgba_ARGB2101010_UINT(src
, dst
, n
);
3813 case MESA_FORMAT_ABGR2101010_UINT
:
3814 unpack_int_rgba_ABGR2101010_UINT(src
, dst
, n
);
3817 case MESA_FORMAT_ARGB2101010
:
3818 unpack_int_rgba_ARGB2101010(src
, dst
, n
);
3821 case MESA_FORMAT_XBGR8888_UINT
:
3822 unpack_int_rgba_XBGR8888_UINT(src
, dst
, n
);
3825 case MESA_FORMAT_XBGR8888_SINT
:
3826 unpack_int_rgba_XBGR8888_SINT(src
, dst
, n
);
3829 case MESA_FORMAT_XBGR16161616_UINT
:
3830 unpack_int_rgba_XBGR16161616_UINT(src
, dst
, n
);
3833 case MESA_FORMAT_XBGR16161616_SINT
:
3834 unpack_int_rgba_XBGR16161616_SINT(src
, dst
, n
);
3837 case MESA_FORMAT_XBGR32323232_UINT
:
3838 case MESA_FORMAT_XBGR32323232_SINT
:
3839 unpack_int_rgba_XBGR32323232_UINT(src
, dst
, n
);
3842 case MESA_FORMAT_ABGR2101010
:
3843 unpack_int_rgba_ABGR2101010(src
, dst
, n
);
3847 _mesa_problem(NULL
, "%s: bad format %s", __FUNCTION__
,
3848 _mesa_get_format_name(format
));
3854 * Unpack a 2D rect of pixels returning float RGBA colors.
3855 * \param format the source image format
3856 * \param src start address of the source image
3857 * \param srcRowStride source image row stride in bytes
3858 * \param dst start address of the dest image
3859 * \param dstRowStride dest image row stride in bytes
3860 * \param x source image start X pos
3861 * \param y source image start Y pos
3862 * \param width width of rect region to convert
3863 * \param height height of rect region to convert
3866 _mesa_unpack_rgba_block(gl_format format
,
3867 const void *src
, GLint srcRowStride
,
3868 GLfloat dst
[][4], GLint dstRowStride
,
3869 GLuint x
, GLuint y
, GLuint width
, GLuint height
)
3871 unpack_rgba_func unpack
= get_unpack_rgba_function(format
);
3872 const GLuint srcPixStride
= _mesa_get_format_bytes(format
);
3873 const GLuint dstPixStride
= 4 * sizeof(GLfloat
);
3874 const GLubyte
*srcRow
;
3878 /* XXX needs to be fixed for compressed formats */
3880 srcRow
= ((const GLubyte
*) src
) + srcRowStride
* y
+ srcPixStride
* x
;
3881 dstRow
= ((GLubyte
*) dst
) + dstRowStride
* y
+ dstPixStride
* x
;
3883 for (i
= 0; i
< height
; i
++) {
3884 unpack(srcRow
, (GLfloat (*)[4]) dstRow
, width
);
3886 dstRow
+= dstRowStride
;
3887 srcRow
+= srcRowStride
;
3894 typedef void (*unpack_float_z_func
)(GLuint n
, const void *src
, GLfloat
*dst
);
3897 unpack_float_z_Z24_X8(GLuint n
, const void *src
, GLfloat
*dst
)
3899 /* only return Z, not stencil data */
3900 const GLuint
*s
= ((const GLuint
*) src
);
3901 const GLdouble scale
= 1.0 / (GLdouble
) 0xffffff;
3903 for (i
= 0; i
< n
; i
++) {
3904 dst
[i
] = (GLfloat
) ((s
[i
] >> 8) * scale
);
3905 ASSERT(dst
[i
] >= 0.0F
);
3906 ASSERT(dst
[i
] <= 1.0F
);
3911 unpack_float_z_X8_Z24(GLuint n
, const void *src
, GLfloat
*dst
)
3913 /* only return Z, not stencil data */
3914 const GLuint
*s
= ((const GLuint
*) src
);
3915 const GLdouble scale
= 1.0 / (GLdouble
) 0xffffff;
3917 for (i
= 0; i
< n
; i
++) {
3918 dst
[i
] = (GLfloat
) ((s
[i
] & 0x00ffffff) * scale
);
3919 ASSERT(dst
[i
] >= 0.0F
);
3920 ASSERT(dst
[i
] <= 1.0F
);
3925 unpack_float_z_Z16(GLuint n
, const void *src
, GLfloat
*dst
)
3927 const GLushort
*s
= ((const GLushort
*) src
);
3929 for (i
= 0; i
< n
; i
++) {
3930 dst
[i
] = s
[i
] * (1.0F
/ 65535.0F
);
3935 unpack_float_z_Z32(GLuint n
, const void *src
, GLfloat
*dst
)
3937 const GLuint
*s
= ((const GLuint
*) src
);
3939 for (i
= 0; i
< n
; i
++) {
3940 dst
[i
] = s
[i
] * (1.0F
/ 0xffffffff);
3945 unpack_float_z_Z32F(GLuint n
, const void *src
, GLfloat
*dst
)
3947 memcpy(dst
, src
, n
* sizeof(float));
3951 unpack_float_z_Z32X24S8(GLuint n
, const void *src
, GLfloat
*dst
)
3953 const struct z32f_x24s8
*s
= (const struct z32f_x24s8
*) src
;
3955 for (i
= 0; i
< n
; i
++) {
3964 * The returned values will always be in the range [0.0, 1.0].
3967 _mesa_unpack_float_z_row(gl_format format
, GLuint n
,
3968 const void *src
, GLfloat
*dst
)
3970 unpack_float_z_func unpack
;
3973 case MESA_FORMAT_Z24_S8
:
3974 case MESA_FORMAT_Z24_X8
:
3975 unpack
= unpack_float_z_Z24_X8
;
3977 case MESA_FORMAT_S8_Z24
:
3978 case MESA_FORMAT_X8_Z24
:
3979 unpack
= unpack_float_z_X8_Z24
;
3981 case MESA_FORMAT_Z16
:
3982 unpack
= unpack_float_z_Z16
;
3984 case MESA_FORMAT_Z32
:
3985 unpack
= unpack_float_z_Z32
;
3987 case MESA_FORMAT_Z32_FLOAT
:
3988 unpack
= unpack_float_z_Z32F
;
3990 case MESA_FORMAT_Z32_FLOAT_X24S8
:
3991 unpack
= unpack_float_z_Z32X24S8
;
3994 _mesa_problem(NULL
, "bad format %s in _mesa_unpack_float_z_row",
3995 _mesa_get_format_name(format
));
3999 unpack(n
, src
, dst
);
4004 typedef void (*unpack_uint_z_func
)(const void *src
, GLuint
*dst
, GLuint n
);
4007 unpack_uint_z_Z24_X8(const void *src
, GLuint
*dst
, GLuint n
)
4009 /* only return Z, not stencil data */
4010 const GLuint
*s
= ((const GLuint
*) src
);
4012 for (i
= 0; i
< n
; i
++) {
4013 dst
[i
] = (s
[i
] & 0xffffff00) | (s
[i
] >> 24);
4018 unpack_uint_z_X8_Z24(const void *src
, GLuint
*dst
, GLuint n
)
4020 /* only return Z, not stencil data */
4021 const GLuint
*s
= ((const GLuint
*) src
);
4023 for (i
= 0; i
< n
; i
++) {
4024 dst
[i
] = (s
[i
] << 8) | ((s
[i
] >> 16) & 0xff);
4029 unpack_uint_z_Z16(const void *src
, GLuint
*dst
, GLuint n
)
4031 const GLushort
*s
= ((const GLushort
*)src
);
4033 for (i
= 0; i
< n
; i
++) {
4034 dst
[i
] = (s
[i
] << 16) | s
[i
];
4039 unpack_uint_z_Z32(const void *src
, GLuint
*dst
, GLuint n
)
4041 memcpy(dst
, src
, n
* sizeof(GLuint
));
4045 unpack_uint_z_Z32_FLOAT(const void *src
, GLuint
*dst
, GLuint n
)
4047 const float *s
= (const float *)src
;
4049 for (i
= 0; i
< n
; i
++) {
4050 dst
[i
] = FLOAT_TO_UINT(CLAMP(s
[i
], 0.0F
, 1.0F
));
4055 unpack_uint_z_Z32_FLOAT_X24S8(const void *src
, GLuint
*dst
, GLuint n
)
4057 const struct z32f_x24s8
*s
= (const struct z32f_x24s8
*) src
;
4060 for (i
= 0; i
< n
; i
++) {
4061 dst
[i
] = FLOAT_TO_UINT(CLAMP(s
[i
].z
, 0.0F
, 1.0F
));
4068 * The returned values will always be in the range [0, 0xffffffff].
4071 _mesa_unpack_uint_z_row(gl_format format
, GLuint n
,
4072 const void *src
, GLuint
*dst
)
4074 unpack_uint_z_func unpack
;
4075 const GLubyte
*srcPtr
= (GLubyte
*) src
;
4078 case MESA_FORMAT_Z24_S8
:
4079 case MESA_FORMAT_Z24_X8
:
4080 unpack
= unpack_uint_z_Z24_X8
;
4082 case MESA_FORMAT_S8_Z24
:
4083 case MESA_FORMAT_X8_Z24
:
4084 unpack
= unpack_uint_z_X8_Z24
;
4086 case MESA_FORMAT_Z16
:
4087 unpack
= unpack_uint_z_Z16
;
4089 case MESA_FORMAT_Z32
:
4090 unpack
= unpack_uint_z_Z32
;
4092 case MESA_FORMAT_Z32_FLOAT
:
4093 unpack
= unpack_uint_z_Z32_FLOAT
;
4095 case MESA_FORMAT_Z32_FLOAT_X24S8
:
4096 unpack
= unpack_uint_z_Z32_FLOAT_X24S8
;
4099 _mesa_problem(NULL
, "bad format %s in _mesa_unpack_uint_z_row",
4100 _mesa_get_format_name(format
));
4104 unpack(srcPtr
, dst
, n
);
4109 unpack_ubyte_s_S8(const void *src
, GLubyte
*dst
, GLuint n
)
4111 memcpy(dst
, src
, n
);
4115 unpack_ubyte_s_Z24_S8(const void *src
, GLubyte
*dst
, GLuint n
)
4118 const GLuint
*src32
= src
;
4120 for (i
= 0; i
< n
; i
++)
4121 dst
[i
] = src32
[i
] & 0xff;
4125 unpack_ubyte_s_S8_Z24(const void *src
, GLubyte
*dst
, GLuint n
)
4128 const GLuint
*src32
= src
;
4130 for (i
= 0; i
< n
; i
++)
4131 dst
[i
] = src32
[i
] >> 24;
4135 unpack_ubyte_s_Z32_FLOAT_X24S8(const void *src
, GLubyte
*dst
, GLuint n
)
4138 const struct z32f_x24s8
*s
= (const struct z32f_x24s8
*) src
;
4140 for (i
= 0; i
< n
; i
++)
4141 dst
[i
] = s
[i
].x24s8
& 0xff;
4145 _mesa_unpack_ubyte_stencil_row(gl_format format
, GLuint n
,
4146 const void *src
, GLubyte
*dst
)
4149 case MESA_FORMAT_S8
:
4150 unpack_ubyte_s_S8(src
, dst
, n
);
4152 case MESA_FORMAT_Z24_S8
:
4153 unpack_ubyte_s_Z24_S8(src
, dst
, n
);
4155 case MESA_FORMAT_S8_Z24
:
4156 unpack_ubyte_s_S8_Z24(src
, dst
, n
);
4158 case MESA_FORMAT_Z32_FLOAT_X24S8
:
4159 unpack_ubyte_s_Z32_FLOAT_X24S8(src
, dst
, n
);
4162 _mesa_problem(NULL
, "bad format %s in _mesa_unpack_ubyte_s_row",
4163 _mesa_get_format_name(format
));
4169 unpack_uint_24_8_depth_stencil_S8_Z24(const GLuint
*src
, GLuint
*dst
, GLuint n
)
4173 for (i
= 0; i
< n
; i
++) {
4174 GLuint val
= src
[i
];
4175 dst
[i
] = val
>> 24 | val
<< 8;
4180 unpack_uint_24_8_depth_stencil_Z24_S8(const GLuint
*src
, GLuint
*dst
, GLuint n
)
4182 memcpy(dst
, src
, n
* 4);
4186 _mesa_unpack_uint_24_8_depth_stencil_row(gl_format format
, GLuint n
,
4187 const void *src
, GLuint
*dst
)
4190 case MESA_FORMAT_Z24_S8
:
4191 unpack_uint_24_8_depth_stencil_Z24_S8(src
, dst
, n
);
4193 case MESA_FORMAT_S8_Z24
:
4194 unpack_uint_24_8_depth_stencil_S8_Z24(src
, dst
, n
);
4198 "bad format %s in _mesa_unpack_uint_24_8_depth_stencil_row",
4199 _mesa_get_format_name(format
));