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_ABGR2101010_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
] >> 0) & 0x3ff);
620 dst
[i
][GCOMP
] = (GLfloat
)((s
[i
] >> 10) & 0x3ff);
621 dst
[i
][BCOMP
] = (GLfloat
)((s
[i
] >> 20) & 0x3ff);
622 dst
[i
][ACOMP
] = (GLfloat
)((s
[i
] >> 30) & 0x03);
628 unpack_Z24_S8(const void *src
, GLfloat dst
[][4], GLuint n
)
630 /* only return Z, not stencil data */
631 const GLuint
*s
= ((const GLuint
*) src
);
632 const GLdouble scale
= 1.0 / (GLdouble
) 0xffffff;
634 for (i
= 0; i
< n
; i
++) {
637 dst
[i
][2] = (GLfloat
) ((s
[i
] >> 8) * scale
);
639 ASSERT(dst
[i
][0] >= 0.0F
);
640 ASSERT(dst
[i
][0] <= 1.0F
);
645 unpack_S8_Z24(const void *src
, GLfloat dst
[][4], GLuint n
)
647 /* only return Z, not stencil data */
648 const GLuint
*s
= ((const GLuint
*) src
);
649 const GLdouble scale
= 1.0 / (GLdouble
) 0xffffff;
651 for (i
= 0; i
< n
; i
++) {
654 dst
[i
][2] = (float) ((s
[i
] & 0x00ffffff) * scale
);
656 ASSERT(dst
[i
][0] >= 0.0F
);
657 ASSERT(dst
[i
][0] <= 1.0F
);
662 unpack_Z16(const void *src
, GLfloat dst
[][4], GLuint n
)
664 const GLushort
*s
= ((const GLushort
*) src
);
666 for (i
= 0; i
< n
; i
++) {
669 dst
[i
][2] = s
[i
] * (1.0F
/ 65535.0F
);
675 unpack_X8_Z24(const void *src
, GLfloat dst
[][4], GLuint n
)
677 unpack_S8_Z24(src
, dst
, n
);
681 unpack_Z24_X8(const void *src
, GLfloat dst
[][4], GLuint n
)
683 unpack_Z24_S8(src
, dst
, n
);
687 unpack_Z32(const void *src
, GLfloat dst
[][4], GLuint n
)
689 const GLuint
*s
= ((const GLuint
*) src
);
691 for (i
= 0; i
< n
; i
++) {
694 dst
[i
][2] = s
[i
] * (1.0F
/ 0xffffffff);
700 unpack_Z32_FLOAT(const void *src
, GLfloat dst
[][4], GLuint n
)
702 const GLfloat
*s
= ((const GLfloat
*) src
);
704 for (i
= 0; i
< n
; i
++) {
707 dst
[i
][2] = s
[i
* 2];
713 unpack_Z32_FLOAT_X24S8(const void *src
, GLfloat dst
[][4], GLuint n
)
715 const GLfloat
*s
= ((const GLfloat
*) src
);
717 for (i
= 0; i
< n
; i
++) {
727 unpack_S8(const void *src
, GLfloat dst
[][4], GLuint n
)
729 /* should never be used */
731 for (i
= 0; i
< n
; i
++) {
741 unpack_SRGB8(const void *src
, GLfloat dst
[][4], GLuint n
)
743 const GLubyte
*s
= (const GLubyte
*) src
;
745 for (i
= 0; i
< n
; i
++) {
746 dst
[i
][RCOMP
] = _mesa_nonlinear_to_linear(s
[i
*3+2]);
747 dst
[i
][GCOMP
] = _mesa_nonlinear_to_linear(s
[i
*3+1]);
748 dst
[i
][BCOMP
] = _mesa_nonlinear_to_linear(s
[i
*3+0]);
749 dst
[i
][ACOMP
] = 1.0F
;
754 unpack_SRGBA8(const void *src
, GLfloat dst
[][4], GLuint n
)
756 const GLuint
*s
= ((const GLuint
*) src
);
758 for (i
= 0; i
< n
; i
++) {
759 dst
[i
][RCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] >> 24) );
760 dst
[i
][GCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] >> 16) & 0xff );
761 dst
[i
][BCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] >> 8) & 0xff );
762 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( s
[i
] & 0xff ); /* linear! */
767 unpack_SARGB8(const void *src
, GLfloat dst
[][4], GLuint n
)
769 const GLuint
*s
= ((const GLuint
*) src
);
771 for (i
= 0; i
< n
; i
++) {
772 dst
[i
][RCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] >> 16) & 0xff );
773 dst
[i
][GCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] >> 8) & 0xff );
774 dst
[i
][BCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] ) & 0xff );
775 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 24 ); /* linear! */
780 unpack_SL8(const void *src
, GLfloat dst
[][4], GLuint n
)
782 const GLubyte
*s
= ((const GLubyte
*) src
);
784 for (i
= 0; i
< n
; i
++) {
787 dst
[i
][BCOMP
] = _mesa_nonlinear_to_linear(s
[i
]);
788 dst
[i
][ACOMP
] = 1.0F
;
793 unpack_SLA8(const void *src
, GLfloat dst
[][4], GLuint n
)
795 const GLushort
*s
= (const GLushort
*) src
;
797 for (i
= 0; i
< n
; i
++) {
800 dst
[i
][BCOMP
] = _mesa_nonlinear_to_linear(s
[i
] & 0xff);
801 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT(s
[i
] >> 8); /* linear! */
806 unpack_SRGB_DXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
811 unpack_SRGBA_DXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
816 unpack_SRGBA_DXT3(const void *src
, GLfloat dst
[][4], GLuint n
)
821 unpack_SRGBA_DXT5(const void *src
, GLfloat dst
[][4], GLuint n
)
826 unpack_RGB_FXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
831 unpack_RGBA_FXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
836 unpack_RGB_DXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
841 unpack_RGBA_DXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
846 unpack_RGBA_DXT3(const void *src
, GLfloat dst
[][4], GLuint n
)
851 unpack_RGBA_DXT5(const void *src
, GLfloat dst
[][4], GLuint n
)
857 unpack_RGBA_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
859 const GLfloat
*s
= (const GLfloat
*) src
;
861 for (i
= 0; i
< n
; i
++) {
862 dst
[i
][RCOMP
] = s
[i
*4+0];
863 dst
[i
][GCOMP
] = s
[i
*4+1];
864 dst
[i
][BCOMP
] = s
[i
*4+2];
865 dst
[i
][ACOMP
] = s
[i
*4+3];
870 unpack_RGBA_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
872 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
874 for (i
= 0; i
< n
; i
++) {
875 dst
[i
][RCOMP
] = _mesa_half_to_float(s
[i
*4+0]);
876 dst
[i
][GCOMP
] = _mesa_half_to_float(s
[i
*4+1]);
877 dst
[i
][BCOMP
] = _mesa_half_to_float(s
[i
*4+2]);
878 dst
[i
][ACOMP
] = _mesa_half_to_float(s
[i
*4+3]);
883 unpack_RGB_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
885 const GLfloat
*s
= (const GLfloat
*) src
;
887 for (i
= 0; i
< n
; i
++) {
888 dst
[i
][RCOMP
] = s
[i
*3+0];
889 dst
[i
][GCOMP
] = s
[i
*3+1];
890 dst
[i
][BCOMP
] = s
[i
*3+2];
891 dst
[i
][ACOMP
] = 1.0F
;
896 unpack_RGB_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
898 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
900 for (i
= 0; i
< n
; i
++) {
901 dst
[i
][RCOMP
] = _mesa_half_to_float(s
[i
*3+0]);
902 dst
[i
][GCOMP
] = _mesa_half_to_float(s
[i
*3+1]);
903 dst
[i
][BCOMP
] = _mesa_half_to_float(s
[i
*3+2]);
904 dst
[i
][ACOMP
] = 1.0F
;
909 unpack_ALPHA_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
911 const GLfloat
*s
= (const GLfloat
*) src
;
913 for (i
= 0; i
< n
; i
++) {
916 dst
[i
][BCOMP
] = 0.0F
;
917 dst
[i
][ACOMP
] = s
[i
];
922 unpack_ALPHA_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
924 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
926 for (i
= 0; i
< n
; i
++) {
929 dst
[i
][BCOMP
] = 0.0F
;
930 dst
[i
][ACOMP
] = _mesa_half_to_float(s
[i
]);
935 unpack_LUMINANCE_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
937 const GLfloat
*s
= (const GLfloat
*) src
;
939 for (i
= 0; i
< n
; i
++) {
942 dst
[i
][BCOMP
] = s
[i
];
943 dst
[i
][ACOMP
] = 1.0F
;
948 unpack_LUMINANCE_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
950 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
952 for (i
= 0; i
< n
; i
++) {
955 dst
[i
][BCOMP
] = _mesa_half_to_float(s
[i
]);
956 dst
[i
][ACOMP
] = 1.0F
;
961 unpack_LUMINANCE_ALPHA_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
963 const GLfloat
*s
= (const GLfloat
*) src
;
965 for (i
= 0; i
< n
; i
++) {
968 dst
[i
][BCOMP
] = s
[i
*2+0];
969 dst
[i
][ACOMP
] = s
[i
*2+1];
974 unpack_LUMINANCE_ALPHA_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
976 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
978 for (i
= 0; i
< n
; i
++) {
981 dst
[i
][BCOMP
] = _mesa_half_to_float(s
[i
*2+0]);
982 dst
[i
][ACOMP
] = _mesa_half_to_float(s
[i
*2+1]);
987 unpack_INTENSITY_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
989 const GLfloat
*s
= (const GLfloat
*) src
;
991 for (i
= 0; i
< n
; i
++) {
995 dst
[i
][ACOMP
] = s
[i
];
1000 unpack_INTENSITY_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1002 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
1004 for (i
= 0; i
< n
; i
++) {
1008 dst
[i
][ACOMP
] = _mesa_half_to_float(s
[i
]);
1013 unpack_R_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1015 const GLfloat
*s
= (const GLfloat
*) src
;
1017 for (i
= 0; i
< n
; i
++) {
1018 dst
[i
][RCOMP
] = s
[i
];
1019 dst
[i
][GCOMP
] = 0.0F
;
1020 dst
[i
][BCOMP
] = 0.0F
;
1021 dst
[i
][ACOMP
] = 1.0F
;
1026 unpack_R_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1028 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
1030 for (i
= 0; i
< n
; i
++) {
1031 dst
[i
][RCOMP
] = _mesa_half_to_float(s
[i
]);
1032 dst
[i
][GCOMP
] = 0.0F
;
1033 dst
[i
][BCOMP
] = 0.0F
;
1034 dst
[i
][ACOMP
] = 1.0F
;
1039 unpack_RG_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1041 const GLfloat
*s
= (const GLfloat
*) src
;
1043 for (i
= 0; i
< n
; i
++) {
1044 dst
[i
][RCOMP
] = s
[i
*2+0];
1045 dst
[i
][GCOMP
] = s
[i
*2+1];
1046 dst
[i
][BCOMP
] = 0.0F
;
1047 dst
[i
][ACOMP
] = 1.0F
;
1052 unpack_RG_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1054 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
1056 for (i
= 0; i
< n
; i
++) {
1057 dst
[i
][RCOMP
] = _mesa_half_to_float(s
[i
*2+0]);
1058 dst
[i
][GCOMP
] = _mesa_half_to_float(s
[i
*2+1]);
1059 dst
[i
][BCOMP
] = 0.0F
;
1060 dst
[i
][ACOMP
] = 1.0F
;
1066 unpack_RGBA_INT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1068 const GLbyte
*s
= (const GLbyte
*) src
;
1070 for (i
= 0; i
< n
; i
++) {
1071 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1072 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1073 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1074 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1079 unpack_RGBA_INT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1081 const GLshort
*s
= (const GLshort
*) src
;
1083 for (i
= 0; i
< n
; i
++) {
1084 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1085 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1086 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1087 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1092 unpack_RGBA_INT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1094 const GLint
*s
= (const GLint
*) src
;
1096 for (i
= 0; i
< n
; i
++) {
1097 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1098 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1099 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1100 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1105 unpack_RGBA_UINT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1107 const GLubyte
*s
= (const GLubyte
*) src
;
1109 for (i
= 0; i
< n
; i
++) {
1110 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1111 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1112 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1113 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1118 unpack_RGBA_UINT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1120 const GLushort
*s
= (const GLushort
*) src
;
1122 for (i
= 0; i
< n
; i
++) {
1123 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1124 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1125 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1126 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1131 unpack_RGBA_UINT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1133 const GLuint
*s
= (const GLuint
*) src
;
1135 for (i
= 0; i
< n
; i
++) {
1136 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1137 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1138 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1139 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1144 unpack_DUDV8(const void *src
, GLfloat dst
[][4], GLuint n
)
1146 const GLbyte
*s
= (const GLbyte
*) src
;
1148 for (i
= 0; i
< n
; i
++) {
1149 dst
[i
][RCOMP
] = BYTE_TO_FLOAT(s
[i
*2+0]);
1150 dst
[i
][GCOMP
] = BYTE_TO_FLOAT(s
[i
*2+1]);
1157 unpack_SIGNED_R8(const void *src
, GLfloat dst
[][4], GLuint n
)
1159 const GLbyte
*s
= ((const GLbyte
*) src
);
1161 for (i
= 0; i
< n
; i
++) {
1162 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( s
[i
] );
1163 dst
[i
][GCOMP
] = 0.0F
;
1164 dst
[i
][BCOMP
] = 0.0F
;
1165 dst
[i
][ACOMP
] = 1.0F
;
1170 unpack_SIGNED_RG88_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
1172 const GLushort
*s
= ((const GLushort
*) src
);
1174 for (i
= 0; i
< n
; i
++) {
1175 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] & 0xff) );
1176 dst
[i
][GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
1177 dst
[i
][BCOMP
] = 0.0F
;
1178 dst
[i
][ACOMP
] = 1.0F
;
1183 unpack_SIGNED_RGBX8888(const void *src
, GLfloat dst
[][4], GLuint n
)
1185 const GLuint
*s
= ((const GLuint
*) src
);
1187 for (i
= 0; i
< n
; i
++) {
1188 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 24) );
1189 dst
[i
][GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 16) );
1190 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
1191 dst
[i
][ACOMP
] = 1.0f
;
1196 unpack_SIGNED_RGBA8888(const void *src
, GLfloat dst
[][4], GLuint n
)
1198 const GLuint
*s
= ((const GLuint
*) src
);
1200 for (i
= 0; i
< n
; i
++) {
1201 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 24) );
1202 dst
[i
][GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 16) );
1203 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
1204 dst
[i
][ACOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] ) );
1209 unpack_SIGNED_RGBA8888_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
1211 const GLuint
*s
= ((const GLuint
*) src
);
1213 for (i
= 0; i
< n
; i
++) {
1214 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] ) );
1215 dst
[i
][GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
1216 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 16) );
1217 dst
[i
][ACOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 24) );
1222 unpack_SIGNED_R16(const void *src
, GLfloat dst
[][4], GLuint n
)
1224 const GLshort
*s
= ((const GLshort
*) src
);
1226 for (i
= 0; i
< n
; i
++) {
1227 dst
[i
][RCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
] );
1228 dst
[i
][GCOMP
] = 0.0F
;
1229 dst
[i
][BCOMP
] = 0.0F
;
1230 dst
[i
][ACOMP
] = 1.0F
;
1235 unpack_SIGNED_GR1616(const void *src
, GLfloat dst
[][4], GLuint n
)
1237 const GLuint
*s
= ((const GLuint
*) src
);
1239 for (i
= 0; i
< n
; i
++) {
1240 dst
[i
][RCOMP
] = SHORT_TO_FLOAT_TEX( (GLshort
) (s
[i
] & 0xffff) );
1241 dst
[i
][GCOMP
] = SHORT_TO_FLOAT_TEX( (GLshort
) (s
[i
] >> 16) );
1242 dst
[i
][BCOMP
] = 0.0F
;
1243 dst
[i
][ACOMP
] = 1.0F
;
1248 unpack_SIGNED_RGB_16(const void *src
, GLfloat dst
[][4], GLuint n
)
1250 const GLshort
*s
= (const GLshort
*) src
;
1252 for (i
= 0; i
< n
; i
++) {
1253 dst
[i
][RCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*3+0] );
1254 dst
[i
][GCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*3+1] );
1255 dst
[i
][BCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*3+2] );
1256 dst
[i
][ACOMP
] = 1.0F
;
1261 unpack_SIGNED_RGBA_16(const void *src
, GLfloat dst
[][4], GLuint n
)
1263 const GLshort
*s
= (const GLshort
*) src
;
1265 for (i
= 0; i
< n
; i
++) {
1266 dst
[i
][RCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+0] );
1267 dst
[i
][GCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+1] );
1268 dst
[i
][BCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+2] );
1269 dst
[i
][ACOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+3] );
1274 unpack_RGBA_16(const void *src
, GLfloat dst
[][4], GLuint n
)
1276 const GLushort
*s
= (const GLushort
*) src
;
1278 for (i
= 0; i
< n
; i
++) {
1279 dst
[i
][RCOMP
] = USHORT_TO_FLOAT( s
[i
*4+0] );
1280 dst
[i
][GCOMP
] = USHORT_TO_FLOAT( s
[i
*4+1] );
1281 dst
[i
][BCOMP
] = USHORT_TO_FLOAT( s
[i
*4+2] );
1282 dst
[i
][ACOMP
] = USHORT_TO_FLOAT( s
[i
*4+3] );
1287 unpack_RED_RGTC1(const void *src
, GLfloat dst
[][4], GLuint n
)
1293 unpack_SIGNED_RED_RGTC1(const void *src
, GLfloat dst
[][4], GLuint n
)
1299 unpack_RG_RGTC2(const void *src
, GLfloat dst
[][4], GLuint n
)
1305 unpack_SIGNED_RG_RGTC2(const void *src
, GLfloat dst
[][4], GLuint n
)
1311 unpack_L_LATC1(const void *src
, GLfloat dst
[][4], GLuint n
)
1317 unpack_SIGNED_L_LATC1(const void *src
, GLfloat dst
[][4], GLuint n
)
1323 unpack_LA_LATC2(const void *src
, GLfloat dst
[][4], GLuint n
)
1329 unpack_SIGNED_LA_LATC2(const void *src
, GLfloat dst
[][4], GLuint n
)
1335 unpack_ETC1_RGB8(const void *src
, GLfloat dst
[][4], GLuint n
)
1341 unpack_ETC2_RGB8(const void *src
, GLfloat dst
[][4], GLuint n
)
1347 unpack_ETC2_SRGB8(const void *src
, GLfloat dst
[][4], GLuint n
)
1353 unpack_ETC2_RGBA8_EAC(const void *src
, GLfloat dst
[][4], GLuint n
)
1359 unpack_ETC2_SRGB8_ALPHA8_EAC(const void *src
, GLfloat dst
[][4], GLuint n
)
1365 unpack_ETC2_R11_EAC(const void *src
, GLfloat dst
[][4], GLuint n
)
1371 unpack_ETC2_RG11_EAC(const void *src
, GLfloat dst
[][4], GLuint n
)
1377 unpack_ETC2_SIGNED_R11_EAC(const void *src
, GLfloat dst
[][4], GLuint n
)
1383 unpack_ETC2_SIGNED_RG11_EAC(const void *src
, GLfloat dst
[][4], GLuint n
)
1389 unpack_ETC2_RGB8_PUNCHTHROUGH_ALPHA1(const void *src
, GLfloat dst
[][4],
1396 unpack_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1(const void *src
, GLfloat dst
[][4],
1403 unpack_SIGNED_A8(const void *src
, GLfloat dst
[][4], GLuint n
)
1405 const GLbyte
*s
= ((const GLbyte
*) src
);
1407 for (i
= 0; i
< n
; i
++) {
1408 dst
[i
][RCOMP
] = 0.0F
;
1409 dst
[i
][GCOMP
] = 0.0F
;
1410 dst
[i
][BCOMP
] = 0.0F
;
1411 dst
[i
][ACOMP
] = BYTE_TO_FLOAT_TEX( s
[i
] );
1416 unpack_SIGNED_L8(const void *src
, GLfloat dst
[][4], GLuint n
)
1418 const GLbyte
*s
= ((const GLbyte
*) src
);
1420 for (i
= 0; i
< n
; i
++) {
1423 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( s
[i
] );
1424 dst
[i
][ACOMP
] = 1.0F
;
1429 unpack_SIGNED_AL88(const void *src
, GLfloat dst
[][4], GLuint n
)
1431 const GLshort
*s
= ((const GLshort
*) src
);
1433 for (i
= 0; i
< n
; i
++) {
1436 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] & 0xff) );
1437 dst
[i
][ACOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
1442 unpack_SIGNED_I8(const void *src
, GLfloat dst
[][4], GLuint n
)
1444 const GLbyte
*s
= ((const GLbyte
*) src
);
1446 for (i
= 0; i
< n
; i
++) {
1450 dst
[i
][ACOMP
] = BYTE_TO_FLOAT_TEX( s
[i
] );
1455 unpack_SIGNED_A16(const void *src
, GLfloat dst
[][4], GLuint n
)
1457 const GLshort
*s
= ((const GLshort
*) src
);
1459 for (i
= 0; i
< n
; i
++) {
1460 dst
[i
][RCOMP
] = 0.0F
;
1461 dst
[i
][GCOMP
] = 0.0F
;
1462 dst
[i
][BCOMP
] = 0.0F
;
1463 dst
[i
][ACOMP
] = SHORT_TO_FLOAT_TEX( s
[i
] );
1468 unpack_SIGNED_L16(const void *src
, GLfloat dst
[][4], GLuint n
)
1470 const GLshort
*s
= ((const GLshort
*) src
);
1472 for (i
= 0; i
< n
; i
++) {
1475 dst
[i
][BCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
] );
1476 dst
[i
][ACOMP
] = 1.0F
;
1481 unpack_SIGNED_AL1616(const void *src
, GLfloat dst
[][4], GLuint n
)
1483 const GLshort
*s
= (const GLshort
*) src
;
1485 for (i
= 0; i
< n
; i
++) {
1488 dst
[i
][BCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*2+0] );
1489 dst
[i
][ACOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*2+1] );
1494 unpack_SIGNED_I16(const void *src
, GLfloat dst
[][4], GLuint n
)
1496 const GLshort
*s
= ((const GLshort
*) src
);
1498 for (i
= 0; i
< n
; i
++) {
1502 dst
[i
][ACOMP
] = SHORT_TO_FLOAT_TEX( s
[i
] );
1507 unpack_RGB9_E5_FLOAT(const void *src
, GLfloat dst
[][4], GLuint n
)
1509 const GLuint
*s
= (const GLuint
*) src
;
1511 for (i
= 0; i
< n
; i
++) {
1512 rgb9e5_to_float3(s
[i
], dst
[i
]);
1513 dst
[i
][ACOMP
] = 1.0F
;
1518 unpack_R11_G11_B10_FLOAT(const void *src
, GLfloat dst
[][4], GLuint n
)
1520 const GLuint
*s
= (const GLuint
*) src
;
1522 for (i
= 0; i
< n
; i
++) {
1523 r11g11b10f_to_float3(s
[i
], dst
[i
]);
1524 dst
[i
][ACOMP
] = 1.0F
;
1529 unpack_XRGB4444_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
1531 const GLushort
*s
= ((const GLushort
*) src
);
1533 for (i
= 0; i
< n
; i
++) {
1534 dst
[i
][RCOMP
] = ((s
[i
] >> 8) & 0xf) * (1.0F
/ 15.0F
);
1535 dst
[i
][GCOMP
] = ((s
[i
] >> 4) & 0xf) * (1.0F
/ 15.0F
);
1536 dst
[i
][BCOMP
] = ((s
[i
] ) & 0xf) * (1.0F
/ 15.0F
);
1537 dst
[i
][ACOMP
] = 1.0;
1542 unpack_XRGB1555_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
1544 const GLushort
*s
= ((const GLushort
*) src
);
1546 for (i
= 0; i
< n
; i
++) {
1547 dst
[i
][RCOMP
] = ((s
[i
] >> 10) & 0x1f) * (1.0F
/ 31.0F
);
1548 dst
[i
][GCOMP
] = ((s
[i
] >> 5) & 0x1f) * (1.0F
/ 31.0F
);
1549 dst
[i
][BCOMP
] = ((s
[i
] >> 0) & 0x1f) * (1.0F
/ 31.0F
);
1550 dst
[i
][ACOMP
] = 1.0;
1555 unpack_XBGR8888_SNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
1557 const GLuint
*s
= ((const GLuint
*) src
);
1559 for (i
= 0; i
< n
; i
++) {
1560 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] ) );
1561 dst
[i
][GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
1562 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 16) );
1563 dst
[i
][ACOMP
] = 1.0;
1568 unpack_XBGR8888_SRGB(const void *src
, GLfloat dst
[][4], GLuint n
)
1570 const GLuint
*s
= ((const GLuint
*) src
);
1572 for (i
= 0; i
< n
; i
++) {
1573 dst
[i
][RCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] ) & 0xff );
1574 dst
[i
][GCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] >> 8) & 0xff );
1575 dst
[i
][BCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] >> 16) & 0xff );
1576 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 24 ); /* linear! */
1581 unpack_XBGR8888_UINT(const void *src
, GLfloat dst
[][4], GLuint n
)
1583 const GLbyte
*s
= (const GLbyte
*) src
;
1585 for (i
= 0; i
< n
; i
++) {
1586 dst
[i
][RCOMP
] = s
[i
*4+0];
1587 dst
[i
][GCOMP
] = s
[i
*4+1];
1588 dst
[i
][BCOMP
] = s
[i
*4+2];
1589 dst
[i
][ACOMP
] = 1.0;
1594 unpack_XBGR8888_SINT(const void *src
, GLfloat dst
[][4], GLuint n
)
1596 const GLbyte
*s
= (const GLbyte
*) src
;
1598 for (i
= 0; i
< n
; i
++) {
1599 dst
[i
][RCOMP
] = s
[i
*4+0];
1600 dst
[i
][GCOMP
] = s
[i
*4+1];
1601 dst
[i
][BCOMP
] = s
[i
*4+2];
1602 dst
[i
][ACOMP
] = 1.0;
1607 unpack_XRGB2101010_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
1609 const GLuint
*s
= ((const GLuint
*) src
);
1611 for (i
= 0; i
< n
; i
++) {
1612 dst
[i
][RCOMP
] = ((s
[i
] >> 20) & 0x3ff) * (1.0F
/ 1023.0F
);
1613 dst
[i
][GCOMP
] = ((s
[i
] >> 10) & 0x3ff) * (1.0F
/ 1023.0F
);
1614 dst
[i
][BCOMP
] = ((s
[i
] >> 0) & 0x3ff) * (1.0F
/ 1023.0F
);
1615 dst
[i
][ACOMP
] = 1.0;
1620 unpack_XBGR16161616_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
1622 const GLushort
*s
= (const GLushort
*) src
;
1624 for (i
= 0; i
< n
; i
++) {
1625 dst
[i
][RCOMP
] = USHORT_TO_FLOAT( s
[i
*4+0] );
1626 dst
[i
][GCOMP
] = USHORT_TO_FLOAT( s
[i
*4+1] );
1627 dst
[i
][BCOMP
] = USHORT_TO_FLOAT( s
[i
*4+2] );
1628 dst
[i
][ACOMP
] = 1.0;
1633 unpack_XBGR16161616_SNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
1635 const GLshort
*s
= (const GLshort
*) src
;
1637 for (i
= 0; i
< n
; i
++) {
1638 dst
[i
][RCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+0] );
1639 dst
[i
][GCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+1] );
1640 dst
[i
][BCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+2] );
1641 dst
[i
][ACOMP
] = 1.0;
1646 unpack_XBGR16161616_FLOAT(const void *src
, GLfloat dst
[][4], GLuint n
)
1648 const GLshort
*s
= (const GLshort
*) src
;
1650 for (i
= 0; i
< n
; i
++) {
1651 dst
[i
][RCOMP
] = _mesa_half_to_float(s
[i
*4+0]);
1652 dst
[i
][GCOMP
] = _mesa_half_to_float(s
[i
*4+1]);
1653 dst
[i
][BCOMP
] = _mesa_half_to_float(s
[i
*4+2]);
1654 dst
[i
][ACOMP
] = 1.0;
1659 unpack_XBGR16161616_UINT(const void *src
, GLfloat dst
[][4], GLuint n
)
1661 const GLushort
*s
= (const GLushort
*) src
;
1663 for (i
= 0; i
< n
; i
++) {
1664 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1665 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1666 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1667 dst
[i
][ACOMP
] = 1.0;
1672 unpack_XBGR16161616_SINT(const void *src
, GLfloat dst
[][4], GLuint n
)
1674 const GLshort
*s
= (const GLshort
*) src
;
1676 for (i
= 0; i
< n
; i
++) {
1677 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1678 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1679 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1680 dst
[i
][ACOMP
] = 1.0;
1685 unpack_XBGR32323232_FLOAT(const void *src
, GLfloat dst
[][4], GLuint n
)
1687 const GLfloat
*s
= (const GLfloat
*) src
;
1689 for (i
= 0; i
< n
; i
++) {
1690 dst
[i
][RCOMP
] = s
[i
*4+0];
1691 dst
[i
][GCOMP
] = s
[i
*4+1];
1692 dst
[i
][BCOMP
] = s
[i
*4+2];
1693 dst
[i
][ACOMP
] = 1.0;
1698 unpack_XBGR32323232_UINT(const void *src
, GLfloat dst
[][4], GLuint n
)
1700 const GLuint
*s
= (const GLuint
*) src
;
1702 for (i
= 0; i
< n
; i
++) {
1703 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1704 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1705 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1706 dst
[i
][ACOMP
] = 1.0;
1711 unpack_XBGR32323232_SINT(const void *src
, GLfloat dst
[][4], GLuint n
)
1713 const GLint
*s
= (const GLint
*) src
;
1715 for (i
= 0; i
< n
; i
++) {
1716 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1717 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1718 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1719 dst
[i
][ACOMP
] = 1.0;
1725 * Return the unpacker function for the given format.
1727 static unpack_rgba_func
1728 get_unpack_rgba_function(gl_format format
)
1730 static unpack_rgba_func table
[MESA_FORMAT_COUNT
];
1731 static GLboolean initialized
= GL_FALSE
;
1734 table
[MESA_FORMAT_NONE
] = NULL
;
1736 table
[MESA_FORMAT_RGBA8888
] = unpack_RGBA8888
;
1737 table
[MESA_FORMAT_RGBA8888_REV
] = unpack_RGBA8888_REV
;
1738 table
[MESA_FORMAT_ARGB8888
] = unpack_ARGB8888
;
1739 table
[MESA_FORMAT_ARGB8888_REV
] = unpack_ARGB8888_REV
;
1740 table
[MESA_FORMAT_RGBX8888
] = unpack_RGBX8888
;
1741 table
[MESA_FORMAT_RGBX8888_REV
] = unpack_RGBX8888_REV
;
1742 table
[MESA_FORMAT_XRGB8888
] = unpack_XRGB8888
;
1743 table
[MESA_FORMAT_XRGB8888_REV
] = unpack_XRGB8888_REV
;
1744 table
[MESA_FORMAT_RGB888
] = unpack_RGB888
;
1745 table
[MESA_FORMAT_BGR888
] = unpack_BGR888
;
1746 table
[MESA_FORMAT_RGB565
] = unpack_RGB565
;
1747 table
[MESA_FORMAT_RGB565_REV
] = unpack_RGB565_REV
;
1748 table
[MESA_FORMAT_ARGB4444
] = unpack_ARGB4444
;
1749 table
[MESA_FORMAT_ARGB4444_REV
] = unpack_ARGB4444_REV
;
1750 table
[MESA_FORMAT_RGBA5551
] = unpack_RGBA5551
;
1751 table
[MESA_FORMAT_ARGB1555
] = unpack_ARGB1555
;
1752 table
[MESA_FORMAT_ARGB1555_REV
] = unpack_ARGB1555_REV
;
1753 table
[MESA_FORMAT_AL44
] = unpack_AL44
;
1754 table
[MESA_FORMAT_AL88
] = unpack_AL88
;
1755 table
[MESA_FORMAT_AL88_REV
] = unpack_AL88_REV
;
1756 table
[MESA_FORMAT_AL1616
] = unpack_AL1616
;
1757 table
[MESA_FORMAT_AL1616_REV
] = unpack_AL1616_REV
;
1758 table
[MESA_FORMAT_RGB332
] = unpack_RGB332
;
1759 table
[MESA_FORMAT_A8
] = unpack_A8
;
1760 table
[MESA_FORMAT_A16
] = unpack_A16
;
1761 table
[MESA_FORMAT_L8
] = unpack_L8
;
1762 table
[MESA_FORMAT_L16
] = unpack_L16
;
1763 table
[MESA_FORMAT_I8
] = unpack_I8
;
1764 table
[MESA_FORMAT_I16
] = unpack_I16
;
1765 table
[MESA_FORMAT_YCBCR
] = unpack_YCBCR
;
1766 table
[MESA_FORMAT_YCBCR_REV
] = unpack_YCBCR_REV
;
1767 table
[MESA_FORMAT_R8
] = unpack_R8
;
1768 table
[MESA_FORMAT_GR88
] = unpack_GR88
;
1769 table
[MESA_FORMAT_RG88
] = unpack_RG88
;
1770 table
[MESA_FORMAT_R16
] = unpack_R16
;
1771 table
[MESA_FORMAT_GR1616
] = unpack_GR1616
;
1772 table
[MESA_FORMAT_RG1616
] = unpack_RG1616
;
1773 table
[MESA_FORMAT_ARGB2101010
] = unpack_ARGB2101010
;
1774 table
[MESA_FORMAT_ABGR2101010_UINT
] = unpack_ABGR2101010_UINT
;
1775 table
[MESA_FORMAT_Z24_S8
] = unpack_Z24_S8
;
1776 table
[MESA_FORMAT_S8_Z24
] = unpack_S8_Z24
;
1777 table
[MESA_FORMAT_Z16
] = unpack_Z16
;
1778 table
[MESA_FORMAT_X8_Z24
] = unpack_X8_Z24
;
1779 table
[MESA_FORMAT_Z24_X8
] = unpack_Z24_X8
;
1780 table
[MESA_FORMAT_Z32
] = unpack_Z32
;
1781 table
[MESA_FORMAT_S8
] = unpack_S8
;
1782 table
[MESA_FORMAT_SRGB8
] = unpack_SRGB8
;
1783 table
[MESA_FORMAT_SRGBA8
] = unpack_SRGBA8
;
1784 table
[MESA_FORMAT_SARGB8
] = unpack_SARGB8
;
1785 table
[MESA_FORMAT_SL8
] = unpack_SL8
;
1786 table
[MESA_FORMAT_SLA8
] = unpack_SLA8
;
1787 table
[MESA_FORMAT_SRGB_DXT1
] = unpack_SRGB_DXT1
;
1788 table
[MESA_FORMAT_SRGBA_DXT1
] = unpack_SRGBA_DXT1
;
1789 table
[MESA_FORMAT_SRGBA_DXT3
] = unpack_SRGBA_DXT3
;
1790 table
[MESA_FORMAT_SRGBA_DXT5
] = unpack_SRGBA_DXT5
;
1792 table
[MESA_FORMAT_RGB_FXT1
] = unpack_RGB_FXT1
;
1793 table
[MESA_FORMAT_RGBA_FXT1
] = unpack_RGBA_FXT1
;
1794 table
[MESA_FORMAT_RGB_DXT1
] = unpack_RGB_DXT1
;
1795 table
[MESA_FORMAT_RGBA_DXT1
] = unpack_RGBA_DXT1
;
1796 table
[MESA_FORMAT_RGBA_DXT3
] = unpack_RGBA_DXT3
;
1797 table
[MESA_FORMAT_RGBA_DXT5
] = unpack_RGBA_DXT5
;
1799 table
[MESA_FORMAT_RGBA_FLOAT32
] = unpack_RGBA_FLOAT32
;
1800 table
[MESA_FORMAT_RGBA_FLOAT16
] = unpack_RGBA_FLOAT16
;
1801 table
[MESA_FORMAT_RGB_FLOAT32
] = unpack_RGB_FLOAT32
;
1802 table
[MESA_FORMAT_RGB_FLOAT16
] = unpack_RGB_FLOAT16
;
1803 table
[MESA_FORMAT_ALPHA_FLOAT32
] = unpack_ALPHA_FLOAT32
;
1804 table
[MESA_FORMAT_ALPHA_FLOAT16
] = unpack_ALPHA_FLOAT16
;
1805 table
[MESA_FORMAT_LUMINANCE_FLOAT32
] = unpack_LUMINANCE_FLOAT32
;
1806 table
[MESA_FORMAT_LUMINANCE_FLOAT16
] = unpack_LUMINANCE_FLOAT16
;
1807 table
[MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32
] = unpack_LUMINANCE_ALPHA_FLOAT32
;
1808 table
[MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16
] = unpack_LUMINANCE_ALPHA_FLOAT16
;
1809 table
[MESA_FORMAT_INTENSITY_FLOAT32
] = unpack_INTENSITY_FLOAT32
;
1810 table
[MESA_FORMAT_INTENSITY_FLOAT16
] = unpack_INTENSITY_FLOAT16
;
1811 table
[MESA_FORMAT_R_FLOAT32
] = unpack_R_FLOAT32
;
1812 table
[MESA_FORMAT_R_FLOAT16
] = unpack_R_FLOAT16
;
1813 table
[MESA_FORMAT_RG_FLOAT32
] = unpack_RG_FLOAT32
;
1814 table
[MESA_FORMAT_RG_FLOAT16
] = unpack_RG_FLOAT16
;
1816 table
[MESA_FORMAT_RGBA_INT8
] = unpack_RGBA_INT8
;
1817 table
[MESA_FORMAT_RGBA_INT16
] = unpack_RGBA_INT16
;
1818 table
[MESA_FORMAT_RGBA_INT32
] = unpack_RGBA_INT32
;
1819 table
[MESA_FORMAT_RGBA_UINT8
] = unpack_RGBA_UINT8
;
1820 table
[MESA_FORMAT_RGBA_UINT16
] = unpack_RGBA_UINT16
;
1821 table
[MESA_FORMAT_RGBA_UINT32
] = unpack_RGBA_UINT32
;
1823 table
[MESA_FORMAT_DUDV8
] = unpack_DUDV8
;
1824 table
[MESA_FORMAT_SIGNED_R8
] = unpack_SIGNED_R8
;
1825 table
[MESA_FORMAT_SIGNED_RG88_REV
] = unpack_SIGNED_RG88_REV
;
1826 table
[MESA_FORMAT_SIGNED_RGBX8888
] = unpack_SIGNED_RGBX8888
;
1827 table
[MESA_FORMAT_SIGNED_RGBA8888
] = unpack_SIGNED_RGBA8888
;
1828 table
[MESA_FORMAT_SIGNED_RGBA8888_REV
] = unpack_SIGNED_RGBA8888_REV
;
1829 table
[MESA_FORMAT_SIGNED_R16
] = unpack_SIGNED_R16
;
1830 table
[MESA_FORMAT_SIGNED_GR1616
] = unpack_SIGNED_GR1616
;
1831 table
[MESA_FORMAT_SIGNED_RGB_16
] = unpack_SIGNED_RGB_16
;
1832 table
[MESA_FORMAT_SIGNED_RGBA_16
] = unpack_SIGNED_RGBA_16
;
1833 table
[MESA_FORMAT_RGBA_16
] = unpack_RGBA_16
;
1835 table
[MESA_FORMAT_RED_RGTC1
] = unpack_RED_RGTC1
;
1836 table
[MESA_FORMAT_SIGNED_RED_RGTC1
] = unpack_SIGNED_RED_RGTC1
;
1837 table
[MESA_FORMAT_RG_RGTC2
] = unpack_RG_RGTC2
;
1838 table
[MESA_FORMAT_SIGNED_RG_RGTC2
] = unpack_SIGNED_RG_RGTC2
;
1840 table
[MESA_FORMAT_L_LATC1
] = unpack_L_LATC1
;
1841 table
[MESA_FORMAT_SIGNED_L_LATC1
] = unpack_SIGNED_L_LATC1
;
1842 table
[MESA_FORMAT_LA_LATC2
] = unpack_LA_LATC2
;
1843 table
[MESA_FORMAT_SIGNED_LA_LATC2
] = unpack_SIGNED_LA_LATC2
;
1845 table
[MESA_FORMAT_ETC1_RGB8
] = unpack_ETC1_RGB8
;
1846 table
[MESA_FORMAT_ETC2_RGB8
] = unpack_ETC2_RGB8
;
1847 table
[MESA_FORMAT_ETC2_SRGB8
] = unpack_ETC2_SRGB8
;
1848 table
[MESA_FORMAT_ETC2_RGBA8_EAC
] = unpack_ETC2_RGBA8_EAC
;
1849 table
[MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC
] = unpack_ETC2_SRGB8_ALPHA8_EAC
;
1850 table
[MESA_FORMAT_ETC2_R11_EAC
] = unpack_ETC2_R11_EAC
;
1851 table
[MESA_FORMAT_ETC2_RG11_EAC
] = unpack_ETC2_RG11_EAC
;
1852 table
[MESA_FORMAT_ETC2_SIGNED_R11_EAC
] = unpack_ETC2_SIGNED_R11_EAC
;
1853 table
[MESA_FORMAT_ETC2_SIGNED_RG11_EAC
] = unpack_ETC2_SIGNED_RG11_EAC
;
1854 table
[MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1
] =
1855 unpack_ETC2_RGB8_PUNCHTHROUGH_ALPHA1
;
1856 table
[MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
] =
1857 unpack_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
;
1858 table
[MESA_FORMAT_SIGNED_A8
] = unpack_SIGNED_A8
;
1859 table
[MESA_FORMAT_SIGNED_L8
] = unpack_SIGNED_L8
;
1860 table
[MESA_FORMAT_SIGNED_AL88
] = unpack_SIGNED_AL88
;
1861 table
[MESA_FORMAT_SIGNED_I8
] = unpack_SIGNED_I8
;
1862 table
[MESA_FORMAT_SIGNED_A16
] = unpack_SIGNED_A16
;
1863 table
[MESA_FORMAT_SIGNED_L16
] = unpack_SIGNED_L16
;
1864 table
[MESA_FORMAT_SIGNED_AL1616
] = unpack_SIGNED_AL1616
;
1865 table
[MESA_FORMAT_SIGNED_I16
] = unpack_SIGNED_I16
;
1867 table
[MESA_FORMAT_RGB9_E5_FLOAT
] = unpack_RGB9_E5_FLOAT
;
1868 table
[MESA_FORMAT_R11_G11_B10_FLOAT
] = unpack_R11_G11_B10_FLOAT
;
1870 table
[MESA_FORMAT_Z32_FLOAT
] = unpack_Z32_FLOAT
;
1871 table
[MESA_FORMAT_Z32_FLOAT_X24S8
] = unpack_Z32_FLOAT_X24S8
;
1873 table
[MESA_FORMAT_XRGB4444_UNORM
] = unpack_XRGB4444_UNORM
;
1874 table
[MESA_FORMAT_XRGB1555_UNORM
] = unpack_XRGB1555_UNORM
;
1875 table
[MESA_FORMAT_XBGR8888_SNORM
] = unpack_XBGR8888_SNORM
;
1876 table
[MESA_FORMAT_XBGR8888_SRGB
] = unpack_XBGR8888_SRGB
;
1877 table
[MESA_FORMAT_XBGR8888_UINT
] = unpack_XBGR8888_UINT
;
1878 table
[MESA_FORMAT_XBGR8888_SINT
] = unpack_XBGR8888_SINT
;
1879 table
[MESA_FORMAT_XRGB2101010_UNORM
] = unpack_XRGB2101010_UNORM
;
1880 table
[MESA_FORMAT_XBGR16161616_UNORM
] = unpack_XBGR16161616_UNORM
;
1881 table
[MESA_FORMAT_XBGR16161616_SNORM
] = unpack_XBGR16161616_SNORM
;
1882 table
[MESA_FORMAT_XBGR16161616_FLOAT
] = unpack_XBGR16161616_FLOAT
;
1883 table
[MESA_FORMAT_XBGR16161616_UINT
] = unpack_XBGR16161616_UINT
;
1884 table
[MESA_FORMAT_XBGR16161616_SINT
] = unpack_XBGR16161616_SINT
;
1885 table
[MESA_FORMAT_XBGR32323232_FLOAT
] = unpack_XBGR32323232_FLOAT
;
1886 table
[MESA_FORMAT_XBGR32323232_UINT
] = unpack_XBGR32323232_UINT
;
1887 table
[MESA_FORMAT_XBGR32323232_SINT
] = unpack_XBGR32323232_SINT
;
1889 initialized
= GL_TRUE
;
1892 if (table
[format
] == NULL
) {
1893 _mesa_problem(NULL
, "unsupported unpack for format %s",
1894 _mesa_get_format_name(format
));
1897 return table
[format
];
1902 * Unpack rgba colors, returning as GLfloat values.
1905 _mesa_unpack_rgba_row(gl_format format
, GLuint n
,
1906 const void *src
, GLfloat dst
[][4])
1908 unpack_rgba_func unpack
= get_unpack_rgba_function(format
);
1909 unpack(src
, dst
, n
);
1913 /**********************************************************************/
1914 /* Unpack, returning GLubyte colors */
1915 /**********************************************************************/
1919 unpack_ubyte_RGBA8888(const void *src
, GLubyte dst
[][4], GLuint n
)
1921 const GLuint
*s
= ((const GLuint
*) src
);
1923 for (i
= 0; i
< n
; i
++) {
1924 dst
[i
][RCOMP
] = (s
[i
] >> 24);
1925 dst
[i
][GCOMP
] = (s
[i
] >> 16) & 0xff;
1926 dst
[i
][BCOMP
] = (s
[i
] >> 8) & 0xff;
1927 dst
[i
][ACOMP
] = (s
[i
] ) & 0xff;
1932 unpack_ubyte_RGBA8888_REV(const void *src
, GLubyte dst
[][4], GLuint n
)
1934 const GLuint
*s
= ((const GLuint
*) src
);
1936 for (i
= 0; i
< n
; i
++) {
1937 dst
[i
][RCOMP
] = (s
[i
] ) & 0xff;
1938 dst
[i
][GCOMP
] = (s
[i
] >> 8) & 0xff;
1939 dst
[i
][BCOMP
] = (s
[i
] >> 16) & 0xff;
1940 dst
[i
][ACOMP
] = (s
[i
] >> 24);
1945 unpack_ubyte_ARGB8888(const void *src
, GLubyte dst
[][4], GLuint n
)
1947 const GLuint
*s
= ((const GLuint
*) src
);
1949 for (i
= 0; i
< n
; i
++) {
1950 dst
[i
][RCOMP
] = (s
[i
] >> 16) & 0xff;
1951 dst
[i
][GCOMP
] = (s
[i
] >> 8) & 0xff;
1952 dst
[i
][BCOMP
] = (s
[i
] ) & 0xff;
1953 dst
[i
][ACOMP
] = (s
[i
] >> 24);
1958 unpack_ubyte_ARGB8888_REV(const void *src
, GLubyte dst
[][4], GLuint n
)
1960 const GLuint
*s
= ((const GLuint
*) src
);
1962 for (i
= 0; i
< n
; i
++) {
1963 dst
[i
][RCOMP
] = (s
[i
] >> 8) & 0xff;
1964 dst
[i
][GCOMP
] = (s
[i
] >> 16) & 0xff;
1965 dst
[i
][BCOMP
] = (s
[i
] >> 24);
1966 dst
[i
][ACOMP
] = (s
[i
] ) & 0xff;
1971 unpack_ubyte_RGBX8888(const void *src
, GLubyte dst
[][4], GLuint n
)
1973 const GLuint
*s
= ((const GLuint
*) src
);
1975 for (i
= 0; i
< n
; i
++) {
1976 dst
[i
][RCOMP
] = (s
[i
] >> 24);
1977 dst
[i
][GCOMP
] = (s
[i
] >> 16) & 0xff;
1978 dst
[i
][BCOMP
] = (s
[i
] >> 8) & 0xff;
1979 dst
[i
][ACOMP
] = 0xff;
1984 unpack_ubyte_RGBX8888_REV(const void *src
, GLubyte dst
[][4], GLuint n
)
1986 const GLuint
*s
= ((const GLuint
*) src
);
1988 for (i
= 0; i
< n
; i
++) {
1989 dst
[i
][RCOMP
] = (s
[i
] ) & 0xff;
1990 dst
[i
][GCOMP
] = (s
[i
] >> 8) & 0xff;
1991 dst
[i
][BCOMP
] = (s
[i
] >> 16) & 0xff;
1992 dst
[i
][ACOMP
] = 0xff;
1997 unpack_ubyte_XRGB8888(const void *src
, GLubyte dst
[][4], GLuint n
)
1999 const GLuint
*s
= ((const GLuint
*) src
);
2001 for (i
= 0; i
< n
; i
++) {
2002 dst
[i
][RCOMP
] = (s
[i
] >> 16) & 0xff;
2003 dst
[i
][GCOMP
] = (s
[i
] >> 8) & 0xff;
2004 dst
[i
][BCOMP
] = (s
[i
] ) & 0xff;
2005 dst
[i
][ACOMP
] = 0xff;
2010 unpack_ubyte_XRGB8888_REV(const void *src
, GLubyte dst
[][4], GLuint n
)
2012 const GLuint
*s
= ((const GLuint
*) src
);
2014 for (i
= 0; i
< n
; i
++) {
2015 dst
[i
][RCOMP
] = (s
[i
] >> 8) & 0xff;
2016 dst
[i
][GCOMP
] = (s
[i
] >> 16) & 0xff;
2017 dst
[i
][BCOMP
] = (s
[i
] >> 24);
2018 dst
[i
][ACOMP
] = 0xff;
2023 unpack_ubyte_RGB888(const void *src
, GLubyte dst
[][4], GLuint n
)
2025 const GLubyte
*s
= (const GLubyte
*) src
;
2027 for (i
= 0; i
< n
; i
++) {
2028 dst
[i
][RCOMP
] = s
[i
*3+2];
2029 dst
[i
][GCOMP
] = s
[i
*3+1];
2030 dst
[i
][BCOMP
] = s
[i
*3+0];
2031 dst
[i
][ACOMP
] = 0xff;
2036 unpack_ubyte_BGR888(const void *src
, GLubyte dst
[][4], GLuint n
)
2038 const GLubyte
*s
= (const GLubyte
*) src
;
2040 for (i
= 0; i
< n
; i
++) {
2041 dst
[i
][RCOMP
] = s
[i
*3+0];
2042 dst
[i
][GCOMP
] = s
[i
*3+1];
2043 dst
[i
][BCOMP
] = s
[i
*3+2];
2044 dst
[i
][ACOMP
] = 0xff;
2049 unpack_ubyte_RGB565(const void *src
, GLubyte dst
[][4], GLuint n
)
2051 const GLushort
*s
= ((const GLushort
*) src
);
2053 for (i
= 0; i
< n
; i
++) {
2054 dst
[i
][RCOMP
] = EXPAND_5_8((s
[i
] >> 11) & 0x1f);
2055 dst
[i
][GCOMP
] = EXPAND_6_8((s
[i
] >> 5 ) & 0x3f);
2056 dst
[i
][BCOMP
] = EXPAND_5_8( s
[i
] & 0x1f);
2057 dst
[i
][ACOMP
] = 0xff;
2062 unpack_ubyte_RGB565_REV(const void *src
, GLubyte dst
[][4], GLuint n
)
2064 const GLushort
*s
= ((const GLushort
*) src
);
2066 for (i
= 0; i
< n
; i
++) {
2067 GLuint t
= (s
[i
] >> 8) | (s
[i
] << 8); /* byte swap */
2068 dst
[i
][RCOMP
] = EXPAND_5_8((t
>> 11) & 0x1f);
2069 dst
[i
][GCOMP
] = EXPAND_6_8((t
>> 5 ) & 0x3f);
2070 dst
[i
][BCOMP
] = EXPAND_5_8( t
& 0x1f);
2071 dst
[i
][ACOMP
] = 0xff;
2076 unpack_ubyte_ARGB4444(const void *src
, GLubyte dst
[][4], GLuint n
)
2078 const GLushort
*s
= ((const GLushort
*) src
);
2080 for (i
= 0; i
< n
; i
++) {
2081 dst
[i
][RCOMP
] = EXPAND_4_8((s
[i
] >> 8) & 0xf);
2082 dst
[i
][GCOMP
] = EXPAND_4_8((s
[i
] >> 4) & 0xf);
2083 dst
[i
][BCOMP
] = EXPAND_4_8((s
[i
] ) & 0xf);
2084 dst
[i
][ACOMP
] = EXPAND_4_8((s
[i
] >> 12) & 0xf);
2089 unpack_ubyte_ARGB4444_REV(const void *src
, GLubyte dst
[][4], GLuint n
)
2091 const GLushort
*s
= ((const GLushort
*) src
);
2093 for (i
= 0; i
< n
; i
++) {
2094 dst
[i
][RCOMP
] = EXPAND_4_8((s
[i
] ) & 0xf);
2095 dst
[i
][GCOMP
] = EXPAND_4_8((s
[i
] >> 12) & 0xf);
2096 dst
[i
][BCOMP
] = EXPAND_4_8((s
[i
] >> 8) & 0xf);
2097 dst
[i
][ACOMP
] = EXPAND_4_8((s
[i
] >> 4) & 0xf);
2102 unpack_ubyte_RGBA5551(const void *src
, GLubyte dst
[][4], GLuint n
)
2104 const GLushort
*s
= ((const GLushort
*) src
);
2106 for (i
= 0; i
< n
; i
++) {
2107 dst
[i
][RCOMP
] = EXPAND_5_8((s
[i
] >> 11) & 0x1f);
2108 dst
[i
][GCOMP
] = EXPAND_5_8((s
[i
] >> 6) & 0x1f);
2109 dst
[i
][BCOMP
] = EXPAND_5_8((s
[i
] >> 1) & 0x1f);
2110 dst
[i
][ACOMP
] = EXPAND_1_8((s
[i
] ) & 0x01);
2115 unpack_ubyte_ARGB1555(const void *src
, GLubyte dst
[][4], GLuint n
)
2117 const GLushort
*s
= ((const GLushort
*) src
);
2119 for (i
= 0; i
< n
; i
++) {
2120 dst
[i
][RCOMP
] = EXPAND_5_8((s
[i
] >> 10) & 0x1f);
2121 dst
[i
][GCOMP
] = EXPAND_5_8((s
[i
] >> 5) & 0x1f);
2122 dst
[i
][BCOMP
] = EXPAND_5_8((s
[i
] >> 0) & 0x1f);
2123 dst
[i
][ACOMP
] = EXPAND_1_8((s
[i
] >> 15) & 0x01);
2128 unpack_ubyte_ARGB1555_REV(const void *src
, GLubyte dst
[][4], GLuint n
)
2130 const GLushort
*s
= ((const GLushort
*) src
);
2132 for (i
= 0; i
< n
; i
++) {
2133 GLushort tmp
= (s
[i
] << 8) | (s
[i
] >> 8); /* byteswap */
2134 dst
[i
][RCOMP
] = EXPAND_5_8((tmp
>> 10) & 0x1f);
2135 dst
[i
][GCOMP
] = EXPAND_5_8((tmp
>> 5) & 0x1f);
2136 dst
[i
][BCOMP
] = EXPAND_5_8((tmp
>> 0) & 0x1f);
2137 dst
[i
][ACOMP
] = EXPAND_1_8((tmp
>> 15) & 0x01);
2142 unpack_ubyte_AL44(const void *src
, GLubyte dst
[][4], GLuint n
)
2144 const GLubyte
*s
= ((const GLubyte
*) src
);
2146 for (i
= 0; i
< n
; i
++) {
2149 dst
[i
][BCOMP
] = EXPAND_4_8(s
[i
] & 0xf);
2150 dst
[i
][ACOMP
] = EXPAND_4_8(s
[i
] >> 4);
2155 unpack_ubyte_AL88(const void *src
, GLubyte dst
[][4], GLuint n
)
2157 const GLushort
*s
= ((const GLushort
*) src
);
2159 for (i
= 0; i
< n
; i
++) {
2162 dst
[i
][BCOMP
] = EXPAND_4_8(s
[i
] & 0xff);
2163 dst
[i
][ACOMP
] = EXPAND_4_8(s
[i
] >> 8);
2168 unpack_ubyte_AL88_REV(const void *src
, GLubyte dst
[][4], GLuint n
)
2170 const GLushort
*s
= ((const GLushort
*) src
);
2172 for (i
= 0; i
< n
; i
++) {
2175 dst
[i
][BCOMP
] = EXPAND_4_8(s
[i
] >> 8);
2176 dst
[i
][ACOMP
] = EXPAND_4_8(s
[i
] & 0xff);
2181 unpack_ubyte_RGB332(const void *src
, GLubyte dst
[][4], GLuint n
)
2183 const GLubyte
*s
= ((const GLubyte
*) src
);
2185 for (i
= 0; i
< n
; i
++) {
2186 dst
[i
][RCOMP
] = EXPAND_3_8((s
[i
] >> 5) & 0x7);
2187 dst
[i
][GCOMP
] = EXPAND_3_8((s
[i
] >> 2) & 0x7);
2188 dst
[i
][BCOMP
] = EXPAND_2_8((s
[i
] ) & 0x3);
2189 dst
[i
][ACOMP
] = 0xff;
2194 unpack_ubyte_A8(const void *src
, GLubyte dst
[][4], GLuint n
)
2196 const GLubyte
*s
= ((const GLubyte
*) src
);
2198 for (i
= 0; i
< n
; i
++) {
2202 dst
[i
][ACOMP
] = s
[i
];
2207 unpack_ubyte_L8(const void *src
, GLubyte dst
[][4], GLuint n
)
2209 const GLubyte
*s
= ((const GLubyte
*) src
);
2211 for (i
= 0; i
< n
; i
++) {
2214 dst
[i
][BCOMP
] = s
[i
];
2215 dst
[i
][ACOMP
] = 0xff;
2221 unpack_ubyte_I8(const void *src
, GLubyte dst
[][4], GLuint n
)
2223 const GLubyte
*s
= ((const GLubyte
*) src
);
2225 for (i
= 0; i
< n
; i
++) {
2229 dst
[i
][ACOMP
] = s
[i
];
2234 unpack_ubyte_R8(const void *src
, GLubyte dst
[][4], GLuint n
)
2236 const GLubyte
*s
= ((const GLubyte
*) src
);
2238 for (i
= 0; i
< n
; i
++) {
2247 unpack_ubyte_GR88(const void *src
, GLubyte dst
[][4], GLuint n
)
2249 const GLushort
*s
= ((const GLushort
*) src
);
2251 for (i
= 0; i
< n
; i
++) {
2252 dst
[i
][RCOMP
] = s
[i
] & 0xff;
2253 dst
[i
][GCOMP
] = s
[i
] >> 8;
2255 dst
[i
][ACOMP
] = 0xff;
2260 unpack_ubyte_RG88(const void *src
, GLubyte dst
[][4], GLuint n
)
2262 const GLushort
*s
= ((const GLushort
*) src
);
2264 for (i
= 0; i
< n
; i
++) {
2265 dst
[i
][RCOMP
] = s
[i
] >> 8;
2266 dst
[i
][GCOMP
] = s
[i
] & 0xff;
2268 dst
[i
][ACOMP
] = 0xff;
2274 * Unpack rgba colors, returning as GLubyte values. This should usually
2275 * only be used for unpacking formats that use 8 bits or less per channel.
2278 _mesa_unpack_ubyte_rgba_row(gl_format format
, GLuint n
,
2279 const void *src
, GLubyte dst
[][4])
2282 case MESA_FORMAT_RGBA8888
:
2283 unpack_ubyte_RGBA8888(src
, dst
, n
);
2285 case MESA_FORMAT_RGBA8888_REV
:
2286 unpack_ubyte_RGBA8888_REV(src
, dst
, n
);
2288 case MESA_FORMAT_ARGB8888
:
2289 unpack_ubyte_ARGB8888(src
, dst
, n
);
2291 case MESA_FORMAT_ARGB8888_REV
:
2292 unpack_ubyte_ARGB8888_REV(src
, dst
, n
);
2294 case MESA_FORMAT_RGBX8888
:
2295 unpack_ubyte_RGBX8888(src
, dst
, n
);
2297 case MESA_FORMAT_RGBX8888_REV
:
2298 unpack_ubyte_RGBX8888_REV(src
, dst
, n
);
2300 case MESA_FORMAT_XRGB8888
:
2301 unpack_ubyte_XRGB8888(src
, dst
, n
);
2303 case MESA_FORMAT_XRGB8888_REV
:
2304 unpack_ubyte_XRGB8888_REV(src
, dst
, n
);
2306 case MESA_FORMAT_RGB888
:
2307 unpack_ubyte_RGB888(src
, dst
, n
);
2309 case MESA_FORMAT_BGR888
:
2310 unpack_ubyte_BGR888(src
, dst
, n
);
2312 case MESA_FORMAT_RGB565
:
2313 unpack_ubyte_RGB565(src
, dst
, n
);
2315 case MESA_FORMAT_RGB565_REV
:
2316 unpack_ubyte_RGB565_REV(src
, dst
, n
);
2318 case MESA_FORMAT_ARGB4444
:
2319 unpack_ubyte_ARGB4444(src
, dst
, n
);
2321 case MESA_FORMAT_ARGB4444_REV
:
2322 unpack_ubyte_ARGB4444_REV(src
, dst
, n
);
2324 case MESA_FORMAT_RGBA5551
:
2325 unpack_ubyte_RGBA5551(src
, dst
, n
);
2327 case MESA_FORMAT_ARGB1555
:
2328 unpack_ubyte_ARGB1555(src
, dst
, n
);
2330 case MESA_FORMAT_ARGB1555_REV
:
2331 unpack_ubyte_ARGB1555_REV(src
, dst
, n
);
2333 case MESA_FORMAT_AL44
:
2334 unpack_ubyte_AL44(src
, dst
, n
);
2336 case MESA_FORMAT_AL88
:
2337 unpack_ubyte_AL88(src
, dst
, n
);
2339 case MESA_FORMAT_AL88_REV
:
2340 unpack_ubyte_AL88_REV(src
, dst
, n
);
2342 case MESA_FORMAT_RGB332
:
2343 unpack_ubyte_RGB332(src
, dst
, n
);
2345 case MESA_FORMAT_A8
:
2346 unpack_ubyte_A8(src
, dst
, n
);
2348 case MESA_FORMAT_L8
:
2349 unpack_ubyte_L8(src
, dst
, n
);
2351 case MESA_FORMAT_I8
:
2352 unpack_ubyte_I8(src
, dst
, n
);
2354 case MESA_FORMAT_R8
:
2355 unpack_ubyte_R8(src
, dst
, n
);
2357 case MESA_FORMAT_GR88
:
2358 unpack_ubyte_GR88(src
, dst
, n
);
2360 case MESA_FORMAT_RG88
:
2361 unpack_ubyte_RG88(src
, dst
, n
);
2364 /* get float values, convert to ubyte */
2366 GLfloat
*tmp
= malloc(n
* 4 * sizeof(GLfloat
));
2369 _mesa_unpack_rgba_row(format
, n
, src
, (GLfloat (*)[4]) tmp
);
2370 for (i
= 0; i
< n
; i
++) {
2371 UNCLAMPED_FLOAT_TO_UBYTE(dst
[i
][0], tmp
[i
*4+0]);
2372 UNCLAMPED_FLOAT_TO_UBYTE(dst
[i
][1], tmp
[i
*4+1]);
2373 UNCLAMPED_FLOAT_TO_UBYTE(dst
[i
][2], tmp
[i
*4+2]);
2374 UNCLAMPED_FLOAT_TO_UBYTE(dst
[i
][3], tmp
[i
*4+3]);
2384 /**********************************************************************/
2385 /* Unpack, returning GLuint colors */
2386 /**********************************************************************/
2389 unpack_int_rgba_RGBA_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
2391 memcpy(dst
, src
, n
* 4 * sizeof(GLuint
));
2395 unpack_int_rgba_RGBA_UINT16(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
2399 for (i
= 0; i
< n
; i
++) {
2400 dst
[i
][0] = src
[i
* 4 + 0];
2401 dst
[i
][1] = src
[i
* 4 + 1];
2402 dst
[i
][2] = src
[i
* 4 + 2];
2403 dst
[i
][3] = src
[i
* 4 + 3];
2408 unpack_int_rgba_RGBA_INT16(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
2412 for (i
= 0; i
< n
; i
++) {
2413 dst
[i
][0] = src
[i
* 4 + 0];
2414 dst
[i
][1] = src
[i
* 4 + 1];
2415 dst
[i
][2] = src
[i
* 4 + 2];
2416 dst
[i
][3] = src
[i
* 4 + 3];
2421 unpack_int_rgba_RGBA_UINT8(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
2425 for (i
= 0; i
< n
; i
++) {
2426 dst
[i
][0] = src
[i
* 4 + 0];
2427 dst
[i
][1] = src
[i
* 4 + 1];
2428 dst
[i
][2] = src
[i
* 4 + 2];
2429 dst
[i
][3] = src
[i
* 4 + 3];
2434 unpack_int_rgba_RGBA_INT8(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
2438 for (i
= 0; i
< n
; i
++) {
2439 dst
[i
][0] = src
[i
* 4 + 0];
2440 dst
[i
][1] = src
[i
* 4 + 1];
2441 dst
[i
][2] = src
[i
* 4 + 2];
2442 dst
[i
][3] = src
[i
* 4 + 3];
2447 unpack_int_rgba_ARGB8888(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
2451 for (i
= 0; i
< n
; i
++) {
2452 dst
[i
][RCOMP
] = (GLubyte
) src
[i
* 4 + 2];
2453 dst
[i
][GCOMP
] = (GLubyte
) src
[i
* 4 + 1];
2454 dst
[i
][BCOMP
] = (GLubyte
) src
[i
* 4 + 0];
2455 dst
[i
][ACOMP
] = (GLubyte
) src
[i
* 4 + 3];
2460 unpack_int_rgba_XRGB8888(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
2464 for (i
= 0; i
< n
; i
++) {
2465 dst
[i
][RCOMP
] = (GLubyte
) src
[i
* 4 + 2];
2466 dst
[i
][GCOMP
] = (GLubyte
) src
[i
* 4 + 1];
2467 dst
[i
][BCOMP
] = (GLubyte
) src
[i
* 4 + 0];
2468 dst
[i
][ACOMP
] = (GLubyte
) 0xff;
2473 unpack_int_rgba_RGB_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
2477 for (i
= 0; i
< n
; i
++) {
2478 dst
[i
][0] = src
[i
* 3 + 0];
2479 dst
[i
][1] = src
[i
* 3 + 1];
2480 dst
[i
][2] = src
[i
* 3 + 2];
2486 unpack_int_rgba_RGB_UINT16(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
2490 for (i
= 0; i
< n
; i
++) {
2491 dst
[i
][0] = src
[i
* 3 + 0];
2492 dst
[i
][1] = src
[i
* 3 + 1];
2493 dst
[i
][2] = src
[i
* 3 + 2];
2499 unpack_int_rgba_RGB_INT16(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
2503 for (i
= 0; i
< n
; i
++) {
2504 dst
[i
][0] = src
[i
* 3 + 0];
2505 dst
[i
][1] = src
[i
* 3 + 1];
2506 dst
[i
][2] = src
[i
* 3 + 2];
2512 unpack_int_rgba_RGB_UINT8(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
2516 for (i
= 0; i
< n
; i
++) {
2517 dst
[i
][0] = src
[i
* 3 + 0];
2518 dst
[i
][1] = src
[i
* 3 + 1];
2519 dst
[i
][2] = src
[i
* 3 + 2];
2525 unpack_int_rgba_RGB_INT8(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
2529 for (i
= 0; i
< n
; i
++) {
2530 dst
[i
][0] = src
[i
* 3 + 0];
2531 dst
[i
][1] = src
[i
* 3 + 1];
2532 dst
[i
][2] = src
[i
* 3 + 2];
2538 unpack_int_rgba_RG_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
2542 for (i
= 0; i
< n
; i
++) {
2543 dst
[i
][0] = src
[i
* 2 + 0];
2544 dst
[i
][1] = src
[i
* 2 + 1];
2551 unpack_int_rgba_RG_UINT16(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
2555 for (i
= 0; i
< n
; i
++) {
2556 dst
[i
][0] = src
[i
* 2 + 0];
2557 dst
[i
][1] = src
[i
* 2 + 1];
2564 unpack_int_rgba_RG_INT16(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
2568 for (i
= 0; i
< n
; i
++) {
2569 dst
[i
][0] = src
[i
* 2 + 0];
2570 dst
[i
][1] = src
[i
* 2 + 1];
2577 unpack_int_rgba_RG_UINT8(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
2581 for (i
= 0; i
< n
; i
++) {
2582 dst
[i
][0] = src
[i
* 2 + 0];
2583 dst
[i
][1] = src
[i
* 2 + 1];
2590 unpack_int_rgba_RG_INT8(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
2594 for (i
= 0; i
< n
; i
++) {
2595 dst
[i
][0] = src
[i
* 2 + 0];
2596 dst
[i
][1] = src
[i
* 2 + 1];
2603 unpack_int_rgba_R_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
2607 for (i
= 0; i
< n
; i
++) {
2616 unpack_int_rgba_R_UINT16(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
2620 for (i
= 0; i
< n
; i
++) {
2629 unpack_int_rgba_R_INT16(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
2633 for (i
= 0; i
< n
; i
++) {
2642 unpack_int_rgba_R_UINT8(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
2646 for (i
= 0; i
< n
; i
++) {
2655 unpack_int_rgba_R_INT8(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
2659 for (i
= 0; i
< n
; i
++) {
2668 unpack_int_rgba_ALPHA_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
2672 for (i
= 0; i
< n
; i
++) {
2673 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = 0;
2679 unpack_int_rgba_ALPHA_UINT16(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
2683 for (i
= 0; i
< n
; i
++) {
2684 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = 0;
2690 unpack_int_rgba_ALPHA_INT16(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
2694 for (i
= 0; i
< n
; i
++) {
2695 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = 0;
2701 unpack_int_rgba_ALPHA_UINT8(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
2705 for (i
= 0; i
< n
; i
++) {
2706 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = 0;
2712 unpack_int_rgba_ALPHA_INT8(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
2716 for (i
= 0; i
< n
; i
++) {
2717 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = 0;
2723 unpack_int_rgba_LUMINANCE_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
2727 for (i
= 0; i
< n
; i
++) {
2728 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
];
2734 unpack_int_rgba_LUMINANCE_UINT16(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
2738 for (i
= 0; i
< n
; i
++) {
2739 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
];
2745 unpack_int_rgba_LUMINANCE_INT16(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
2749 for (i
= 0; i
< n
; i
++) {
2750 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
];
2756 unpack_int_rgba_LUMINANCE_UINT8(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
2760 for (i
= 0; i
< n
; i
++) {
2761 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
];
2767 unpack_int_rgba_LUMINANCE_INT8(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
2771 for (i
= 0; i
< n
; i
++) {
2772 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
];
2779 unpack_int_rgba_LUMINANCE_ALPHA_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
2783 for (i
= 0; i
< n
; i
++) {
2784 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
* 2 + 0];
2785 dst
[i
][3] = src
[i
* 2 + 1];
2790 unpack_int_rgba_LUMINANCE_ALPHA_UINT16(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
2794 for (i
= 0; i
< n
; i
++) {
2795 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
* 2 + 0];
2796 dst
[i
][3] = src
[i
* 2 + 1];
2801 unpack_int_rgba_LUMINANCE_ALPHA_INT16(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
2805 for (i
= 0; i
< n
; i
++) {
2806 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
* 2 + 0];
2807 dst
[i
][3] = src
[i
* 2 + 1];
2812 unpack_int_rgba_LUMINANCE_ALPHA_UINT8(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
2816 for (i
= 0; i
< n
; i
++) {
2817 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
* 2 + 0];
2818 dst
[i
][3] = src
[i
* 2 + 1];
2823 unpack_int_rgba_LUMINANCE_ALPHA_INT8(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
2827 for (i
= 0; i
< n
; i
++) {
2828 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
* 2 + 0];
2829 dst
[i
][3] = src
[i
* 2 + 1];
2834 unpack_int_rgba_INTENSITY_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
2838 for (i
= 0; i
< n
; i
++) {
2839 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = dst
[i
][3] = src
[i
];
2844 unpack_int_rgba_INTENSITY_UINT16(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
2848 for (i
= 0; i
< n
; i
++) {
2849 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = dst
[i
][3] = src
[i
];
2854 unpack_int_rgba_INTENSITY_INT16(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
2858 for (i
= 0; i
< n
; i
++) {
2859 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = dst
[i
][3] = src
[i
];
2864 unpack_int_rgba_INTENSITY_UINT8(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
2868 for (i
= 0; i
< n
; i
++) {
2869 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = dst
[i
][3] = src
[i
];
2874 unpack_int_rgba_INTENSITY_INT8(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
2878 for (i
= 0; i
< n
; i
++) {
2879 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = dst
[i
][3] = src
[i
];
2884 unpack_int_rgba_ARGB2101010_UINT(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
2888 for (i
= 0; i
< n
; i
++) {
2889 GLuint tmp
= src
[i
];
2890 dst
[i
][0] = (tmp
>> 20) & 0x3ff;
2891 dst
[i
][1] = (tmp
>> 10) & 0x3ff;
2892 dst
[i
][2] = (tmp
>> 0) & 0x3ff;
2893 dst
[i
][3] = (tmp
>> 30) & 0x3;
2898 unpack_int_rgba_ABGR2101010_UINT(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
2902 for (i
= 0; i
< n
; i
++) {
2903 GLuint tmp
= src
[i
];
2904 dst
[i
][0] = (tmp
>> 0) & 0x3ff;
2905 dst
[i
][1] = (tmp
>> 10) & 0x3ff;
2906 dst
[i
][2] = (tmp
>> 20) & 0x3ff;
2907 dst
[i
][3] = (tmp
>> 30) & 0x3;
2912 unpack_int_rgba_ARGB2101010(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
2916 for (i
= 0; i
< n
; i
++) {
2917 GLuint tmp
= src
[i
];
2918 dst
[i
][0] = (tmp
>> 20) & 0x3ff;
2919 dst
[i
][1] = (tmp
>> 10) & 0x3ff;
2920 dst
[i
][2] = (tmp
>> 0) & 0x3ff;
2921 dst
[i
][3] = (tmp
>> 30) & 0x3;
2926 unpack_int_rgba_XBGR8888_UINT(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
2930 for (i
= 0; i
< n
; i
++) {
2931 dst
[i
][0] = src
[i
* 4 + 0];
2932 dst
[i
][1] = src
[i
* 4 + 1];
2933 dst
[i
][2] = src
[i
* 4 + 2];
2939 unpack_int_rgba_XBGR8888_SINT(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
2943 for (i
= 0; i
< n
; i
++) {
2944 dst
[i
][0] = src
[i
* 4 + 0];
2945 dst
[i
][1] = src
[i
* 4 + 1];
2946 dst
[i
][2] = src
[i
* 4 + 2];
2952 unpack_int_rgba_XBGR16161616_UINT(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
2956 for (i
= 0; i
< n
; i
++) {
2957 dst
[i
][0] = src
[i
* 4 + 0];
2958 dst
[i
][1] = src
[i
* 4 + 1];
2959 dst
[i
][2] = src
[i
* 4 + 2];
2965 unpack_int_rgba_XBGR16161616_SINT(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
2969 for (i
= 0; i
< n
; i
++) {
2970 dst
[i
][0] = src
[i
* 4 + 0];
2971 dst
[i
][1] = src
[i
* 4 + 1];
2972 dst
[i
][2] = src
[i
* 4 + 2];
2978 unpack_int_rgba_XBGR32323232_UINT(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
2982 for (i
= 0; i
< n
; i
++) {
2983 dst
[i
][0] = src
[i
* 4 + 0];
2984 dst
[i
][1] = src
[i
* 4 + 1];
2985 dst
[i
][2] = src
[i
* 4 + 2];
2991 _mesa_unpack_uint_rgba_row(gl_format format
, GLuint n
,
2992 const void *src
, GLuint dst
[][4])
2995 /* Since there won't be any sign extension happening, there's no need to
2996 * make separate paths for 32-bit-to-32-bit integer unpack.
2998 case MESA_FORMAT_RGBA_UINT32
:
2999 case MESA_FORMAT_RGBA_INT32
:
3000 unpack_int_rgba_RGBA_UINT32(src
, dst
, n
);
3003 case MESA_FORMAT_RGBA_UINT16
:
3004 unpack_int_rgba_RGBA_UINT16(src
, dst
, n
);
3006 case MESA_FORMAT_RGBA_INT16
:
3007 unpack_int_rgba_RGBA_INT16(src
, dst
, n
);
3010 case MESA_FORMAT_RGBA_UINT8
:
3011 unpack_int_rgba_RGBA_UINT8(src
, dst
, n
);
3013 case MESA_FORMAT_RGBA_INT8
:
3014 unpack_int_rgba_RGBA_INT8(src
, dst
, n
);
3017 case MESA_FORMAT_ARGB8888
:
3018 unpack_int_rgba_ARGB8888(src
, dst
, n
);
3021 case MESA_FORMAT_XRGB8888
:
3022 unpack_int_rgba_XRGB8888(src
, dst
, n
);
3025 case MESA_FORMAT_RGB_UINT32
:
3026 case MESA_FORMAT_RGB_INT32
:
3027 unpack_int_rgba_RGB_UINT32(src
, dst
, n
);
3030 case MESA_FORMAT_RGB_UINT16
:
3031 unpack_int_rgba_RGB_UINT16(src
, dst
, n
);
3033 case MESA_FORMAT_RGB_INT16
:
3034 unpack_int_rgba_RGB_INT16(src
, dst
, n
);
3037 case MESA_FORMAT_RGB_UINT8
:
3038 unpack_int_rgba_RGB_UINT8(src
, dst
, n
);
3040 case MESA_FORMAT_RGB_INT8
:
3041 unpack_int_rgba_RGB_INT8(src
, dst
, n
);
3044 case MESA_FORMAT_RG_UINT32
:
3045 case MESA_FORMAT_RG_INT32
:
3046 unpack_int_rgba_RG_UINT32(src
, dst
, n
);
3049 case MESA_FORMAT_RG_UINT16
:
3050 unpack_int_rgba_RG_UINT16(src
, dst
, n
);
3052 case MESA_FORMAT_RG_INT16
:
3053 unpack_int_rgba_RG_INT16(src
, dst
, n
);
3056 case MESA_FORMAT_RG_UINT8
:
3057 unpack_int_rgba_RG_UINT8(src
, dst
, n
);
3059 case MESA_FORMAT_RG_INT8
:
3060 unpack_int_rgba_RG_INT8(src
, dst
, n
);
3063 case MESA_FORMAT_R_UINT32
:
3064 case MESA_FORMAT_R_INT32
:
3065 unpack_int_rgba_R_UINT32(src
, dst
, n
);
3068 case MESA_FORMAT_R_UINT16
:
3069 unpack_int_rgba_R_UINT16(src
, dst
, n
);
3071 case MESA_FORMAT_R_INT16
:
3072 unpack_int_rgba_R_INT16(src
, dst
, n
);
3075 case MESA_FORMAT_R_UINT8
:
3076 unpack_int_rgba_R_UINT8(src
, dst
, n
);
3078 case MESA_FORMAT_R_INT8
:
3079 unpack_int_rgba_R_INT8(src
, dst
, n
);
3082 case MESA_FORMAT_ALPHA_UINT32
:
3083 case MESA_FORMAT_ALPHA_INT32
:
3084 unpack_int_rgba_ALPHA_UINT32(src
, dst
, n
);
3087 case MESA_FORMAT_ALPHA_UINT16
:
3088 unpack_int_rgba_ALPHA_UINT16(src
, dst
, n
);
3090 case MESA_FORMAT_ALPHA_INT16
:
3091 unpack_int_rgba_ALPHA_INT16(src
, dst
, n
);
3094 case MESA_FORMAT_ALPHA_UINT8
:
3095 unpack_int_rgba_ALPHA_UINT8(src
, dst
, n
);
3097 case MESA_FORMAT_ALPHA_INT8
:
3098 unpack_int_rgba_ALPHA_INT8(src
, dst
, n
);
3101 case MESA_FORMAT_LUMINANCE_UINT32
:
3102 case MESA_FORMAT_LUMINANCE_INT32
:
3103 unpack_int_rgba_LUMINANCE_UINT32(src
, dst
, n
);
3105 case MESA_FORMAT_LUMINANCE_UINT16
:
3106 unpack_int_rgba_LUMINANCE_UINT16(src
, dst
, n
);
3108 case MESA_FORMAT_LUMINANCE_INT16
:
3109 unpack_int_rgba_LUMINANCE_INT16(src
, dst
, n
);
3112 case MESA_FORMAT_LUMINANCE_UINT8
:
3113 unpack_int_rgba_LUMINANCE_UINT8(src
, dst
, n
);
3115 case MESA_FORMAT_LUMINANCE_INT8
:
3116 unpack_int_rgba_LUMINANCE_INT8(src
, dst
, n
);
3119 case MESA_FORMAT_LUMINANCE_ALPHA_UINT32
:
3120 case MESA_FORMAT_LUMINANCE_ALPHA_INT32
:
3121 unpack_int_rgba_LUMINANCE_ALPHA_UINT32(src
, dst
, n
);
3124 case MESA_FORMAT_LUMINANCE_ALPHA_UINT16
:
3125 unpack_int_rgba_LUMINANCE_ALPHA_UINT16(src
, dst
, n
);
3127 case MESA_FORMAT_LUMINANCE_ALPHA_INT16
:
3128 unpack_int_rgba_LUMINANCE_ALPHA_INT16(src
, dst
, n
);
3131 case MESA_FORMAT_LUMINANCE_ALPHA_UINT8
:
3132 unpack_int_rgba_LUMINANCE_ALPHA_UINT8(src
, dst
, n
);
3134 case MESA_FORMAT_LUMINANCE_ALPHA_INT8
:
3135 unpack_int_rgba_LUMINANCE_ALPHA_INT8(src
, dst
, n
);
3138 case MESA_FORMAT_INTENSITY_UINT32
:
3139 case MESA_FORMAT_INTENSITY_INT32
:
3140 unpack_int_rgba_INTENSITY_UINT32(src
, dst
, n
);
3143 case MESA_FORMAT_INTENSITY_UINT16
:
3144 unpack_int_rgba_INTENSITY_UINT16(src
, dst
, n
);
3146 case MESA_FORMAT_INTENSITY_INT16
:
3147 unpack_int_rgba_INTENSITY_INT16(src
, dst
, n
);
3150 case MESA_FORMAT_INTENSITY_UINT8
:
3151 unpack_int_rgba_INTENSITY_UINT8(src
, dst
, n
);
3153 case MESA_FORMAT_INTENSITY_INT8
:
3154 unpack_int_rgba_INTENSITY_INT8(src
, dst
, n
);
3157 case MESA_FORMAT_ARGB2101010_UINT
:
3158 unpack_int_rgba_ARGB2101010_UINT(src
, dst
, n
);
3161 case MESA_FORMAT_ABGR2101010_UINT
:
3162 unpack_int_rgba_ABGR2101010_UINT(src
, dst
, n
);
3165 case MESA_FORMAT_ARGB2101010
:
3166 unpack_int_rgba_ARGB2101010(src
, dst
, n
);
3169 case MESA_FORMAT_XBGR8888_UINT
:
3170 unpack_int_rgba_XBGR8888_UINT(src
, dst
, n
);
3173 case MESA_FORMAT_XBGR8888_SINT
:
3174 unpack_int_rgba_XBGR8888_SINT(src
, dst
, n
);
3177 case MESA_FORMAT_XBGR16161616_UINT
:
3178 unpack_int_rgba_XBGR16161616_UINT(src
, dst
, n
);
3181 case MESA_FORMAT_XBGR16161616_SINT
:
3182 unpack_int_rgba_XBGR16161616_SINT(src
, dst
, n
);
3185 case MESA_FORMAT_XBGR32323232_UINT
:
3186 case MESA_FORMAT_XBGR32323232_SINT
:
3187 unpack_int_rgba_XBGR32323232_UINT(src
, dst
, n
);
3191 _mesa_problem(NULL
, "%s: bad format %s", __FUNCTION__
,
3192 _mesa_get_format_name(format
));
3198 * Unpack a 2D rect of pixels returning float RGBA colors.
3199 * \param format the source image format
3200 * \param src start address of the source image
3201 * \param srcRowStride source image row stride in bytes
3202 * \param dst start address of the dest image
3203 * \param dstRowStride dest image row stride in bytes
3204 * \param x source image start X pos
3205 * \param y source image start Y pos
3206 * \param width width of rect region to convert
3207 * \param height height of rect region to convert
3210 _mesa_unpack_rgba_block(gl_format format
,
3211 const void *src
, GLint srcRowStride
,
3212 GLfloat dst
[][4], GLint dstRowStride
,
3213 GLuint x
, GLuint y
, GLuint width
, GLuint height
)
3215 unpack_rgba_func unpack
= get_unpack_rgba_function(format
);
3216 const GLuint srcPixStride
= _mesa_get_format_bytes(format
);
3217 const GLuint dstPixStride
= 4 * sizeof(GLfloat
);
3218 const GLubyte
*srcRow
;
3222 /* XXX needs to be fixed for compressed formats */
3224 srcRow
= ((const GLubyte
*) src
) + srcRowStride
* y
+ srcPixStride
* x
;
3225 dstRow
= ((GLubyte
*) dst
) + dstRowStride
* y
+ dstPixStride
* x
;
3227 for (i
= 0; i
< height
; i
++) {
3228 unpack(srcRow
, (GLfloat (*)[4]) dstRow
, width
);
3230 dstRow
+= dstRowStride
;
3231 srcRow
+= srcRowStride
;
3238 typedef void (*unpack_float_z_func
)(GLuint n
, const void *src
, GLfloat
*dst
);
3241 unpack_float_z_Z24_X8(GLuint n
, const void *src
, GLfloat
*dst
)
3243 /* only return Z, not stencil data */
3244 const GLuint
*s
= ((const GLuint
*) src
);
3245 const GLdouble scale
= 1.0 / (GLdouble
) 0xffffff;
3247 for (i
= 0; i
< n
; i
++) {
3248 dst
[i
] = (GLfloat
) ((s
[i
] >> 8) * scale
);
3249 ASSERT(dst
[i
] >= 0.0F
);
3250 ASSERT(dst
[i
] <= 1.0F
);
3255 unpack_float_z_X8_Z24(GLuint n
, const void *src
, GLfloat
*dst
)
3257 /* only return Z, not stencil data */
3258 const GLuint
*s
= ((const GLuint
*) src
);
3259 const GLdouble scale
= 1.0 / (GLdouble
) 0xffffff;
3261 for (i
= 0; i
< n
; i
++) {
3262 dst
[i
] = (GLfloat
) ((s
[i
] & 0x00ffffff) * scale
);
3263 ASSERT(dst
[i
] >= 0.0F
);
3264 ASSERT(dst
[i
] <= 1.0F
);
3269 unpack_float_z_Z16(GLuint n
, const void *src
, GLfloat
*dst
)
3271 const GLushort
*s
= ((const GLushort
*) src
);
3273 for (i
= 0; i
< n
; i
++) {
3274 dst
[i
] = s
[i
] * (1.0F
/ 65535.0F
);
3279 unpack_float_z_Z32(GLuint n
, const void *src
, GLfloat
*dst
)
3281 const GLuint
*s
= ((const GLuint
*) src
);
3283 for (i
= 0; i
< n
; i
++) {
3284 dst
[i
] = s
[i
] * (1.0F
/ 0xffffffff);
3289 unpack_float_z_Z32F(GLuint n
, const void *src
, GLfloat
*dst
)
3291 memcpy(dst
, src
, n
* sizeof(float));
3295 unpack_float_z_Z32X24S8(GLuint n
, const void *src
, GLfloat
*dst
)
3297 const struct z32f_x24s8
*s
= (const struct z32f_x24s8
*) src
;
3299 for (i
= 0; i
< n
; i
++) {
3308 * The returned values will always be in the range [0.0, 1.0].
3311 _mesa_unpack_float_z_row(gl_format format
, GLuint n
,
3312 const void *src
, GLfloat
*dst
)
3314 unpack_float_z_func unpack
;
3317 case MESA_FORMAT_Z24_S8
:
3318 case MESA_FORMAT_Z24_X8
:
3319 unpack
= unpack_float_z_Z24_X8
;
3321 case MESA_FORMAT_S8_Z24
:
3322 case MESA_FORMAT_X8_Z24
:
3323 unpack
= unpack_float_z_X8_Z24
;
3325 case MESA_FORMAT_Z16
:
3326 unpack
= unpack_float_z_Z16
;
3328 case MESA_FORMAT_Z32
:
3329 unpack
= unpack_float_z_Z32
;
3331 case MESA_FORMAT_Z32_FLOAT
:
3332 unpack
= unpack_float_z_Z32F
;
3334 case MESA_FORMAT_Z32_FLOAT_X24S8
:
3335 unpack
= unpack_float_z_Z32X24S8
;
3338 _mesa_problem(NULL
, "bad format %s in _mesa_unpack_float_z_row",
3339 _mesa_get_format_name(format
));
3343 unpack(n
, src
, dst
);
3348 typedef void (*unpack_uint_z_func
)(const void *src
, GLuint
*dst
, GLuint n
);
3351 unpack_uint_z_Z24_X8(const void *src
, GLuint
*dst
, GLuint n
)
3353 /* only return Z, not stencil data */
3354 const GLuint
*s
= ((const GLuint
*) src
);
3356 for (i
= 0; i
< n
; i
++) {
3357 dst
[i
] = (s
[i
] & 0xffffff00) | (s
[i
] >> 24);
3362 unpack_uint_z_X8_Z24(const void *src
, GLuint
*dst
, GLuint n
)
3364 /* only return Z, not stencil data */
3365 const GLuint
*s
= ((const GLuint
*) src
);
3367 for (i
= 0; i
< n
; i
++) {
3368 dst
[i
] = (s
[i
] << 8) | ((s
[i
] >> 16) & 0xff);
3373 unpack_uint_z_Z16(const void *src
, GLuint
*dst
, GLuint n
)
3375 const GLushort
*s
= ((const GLushort
*)src
);
3377 for (i
= 0; i
< n
; i
++) {
3378 dst
[i
] = (s
[i
] << 16) | s
[i
];
3383 unpack_uint_z_Z32(const void *src
, GLuint
*dst
, GLuint n
)
3385 memcpy(dst
, src
, n
* sizeof(GLuint
));
3389 unpack_uint_z_Z32_FLOAT(const void *src
, GLuint
*dst
, GLuint n
)
3391 const float *s
= (const float *)src
;
3393 for (i
= 0; i
< n
; i
++) {
3394 dst
[i
] = FLOAT_TO_UINT(CLAMP(s
[i
], 0.0F
, 1.0F
));
3399 unpack_uint_z_Z32_FLOAT_X24S8(const void *src
, GLuint
*dst
, GLuint n
)
3401 const struct z32f_x24s8
*s
= (const struct z32f_x24s8
*) src
;
3404 for (i
= 0; i
< n
; i
++) {
3405 dst
[i
] = FLOAT_TO_UINT(CLAMP(s
[i
].z
, 0.0F
, 1.0F
));
3412 * The returned values will always be in the range [0, 0xffffffff].
3415 _mesa_unpack_uint_z_row(gl_format format
, GLuint n
,
3416 const void *src
, GLuint
*dst
)
3418 unpack_uint_z_func unpack
;
3419 const GLubyte
*srcPtr
= (GLubyte
*) src
;
3422 case MESA_FORMAT_Z24_S8
:
3423 case MESA_FORMAT_Z24_X8
:
3424 unpack
= unpack_uint_z_Z24_X8
;
3426 case MESA_FORMAT_S8_Z24
:
3427 case MESA_FORMAT_X8_Z24
:
3428 unpack
= unpack_uint_z_X8_Z24
;
3430 case MESA_FORMAT_Z16
:
3431 unpack
= unpack_uint_z_Z16
;
3433 case MESA_FORMAT_Z32
:
3434 unpack
= unpack_uint_z_Z32
;
3436 case MESA_FORMAT_Z32_FLOAT
:
3437 unpack
= unpack_uint_z_Z32_FLOAT
;
3439 case MESA_FORMAT_Z32_FLOAT_X24S8
:
3440 unpack
= unpack_uint_z_Z32_FLOAT_X24S8
;
3443 _mesa_problem(NULL
, "bad format %s in _mesa_unpack_uint_z_row",
3444 _mesa_get_format_name(format
));
3448 unpack(srcPtr
, dst
, n
);
3453 unpack_ubyte_s_S8(const void *src
, GLubyte
*dst
, GLuint n
)
3455 memcpy(dst
, src
, n
);
3459 unpack_ubyte_s_Z24_S8(const void *src
, GLubyte
*dst
, GLuint n
)
3462 const GLuint
*src32
= src
;
3464 for (i
= 0; i
< n
; i
++)
3465 dst
[i
] = src32
[i
] & 0xff;
3469 unpack_ubyte_s_S8_Z24(const void *src
, GLubyte
*dst
, GLuint n
)
3472 const GLuint
*src32
= src
;
3474 for (i
= 0; i
< n
; i
++)
3475 dst
[i
] = src32
[i
] >> 24;
3479 unpack_ubyte_s_Z32_FLOAT_X24S8(const void *src
, GLubyte
*dst
, GLuint n
)
3482 const struct z32f_x24s8
*s
= (const struct z32f_x24s8
*) src
;
3484 for (i
= 0; i
< n
; i
++)
3485 dst
[i
] = s
[i
].x24s8
& 0xff;
3489 _mesa_unpack_ubyte_stencil_row(gl_format format
, GLuint n
,
3490 const void *src
, GLubyte
*dst
)
3493 case MESA_FORMAT_S8
:
3494 unpack_ubyte_s_S8(src
, dst
, n
);
3496 case MESA_FORMAT_Z24_S8
:
3497 unpack_ubyte_s_Z24_S8(src
, dst
, n
);
3499 case MESA_FORMAT_S8_Z24
:
3500 unpack_ubyte_s_S8_Z24(src
, dst
, n
);
3502 case MESA_FORMAT_Z32_FLOAT_X24S8
:
3503 unpack_ubyte_s_Z32_FLOAT_X24S8(src
, dst
, n
);
3506 _mesa_problem(NULL
, "bad format %s in _mesa_unpack_ubyte_s_row",
3507 _mesa_get_format_name(format
));
3513 unpack_uint_24_8_depth_stencil_S8_Z24(const GLuint
*src
, GLuint
*dst
, GLuint n
)
3517 for (i
= 0; i
< n
; i
++) {
3518 GLuint val
= src
[i
];
3519 dst
[i
] = val
>> 24 | val
<< 8;
3524 unpack_uint_24_8_depth_stencil_Z24_S8(const GLuint
*src
, GLuint
*dst
, GLuint n
)
3526 memcpy(dst
, src
, n
* 4);
3530 _mesa_unpack_uint_24_8_depth_stencil_row(gl_format format
, GLuint n
,
3531 const void *src
, GLuint
*dst
)
3534 case MESA_FORMAT_Z24_S8
:
3535 unpack_uint_24_8_depth_stencil_Z24_S8(src
, dst
, n
);
3537 case MESA_FORMAT_S8_Z24
:
3538 unpack_uint_24_8_depth_stencil_S8_Z24(src
, dst
, n
);
3542 "bad format %s in _mesa_unpack_uint_24_8_depth_stencil_row",
3543 _mesa_get_format_name(format
));