2 * Mesa 3-D graphics library
4 * Copyright (c) 2011 VMware, Inc.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
27 #include "format_unpack.h"
29 #include "../../gallium/auxiliary/util/u_format_rgb9e5.h"
30 #include "../../gallium/auxiliary/util/u_format_r11g11b10f.h"
33 /** Helper struct for MESA_FORMAT_Z32_FLOAT_S8X24_UINT */
41 /* Expand 1, 2, 3, 4, 5, 6-bit values to fill 8 bits */
43 #define EXPAND_1_8(X) ( (X) ? 0xff : 0x0 )
45 #define EXPAND_2_8(X) ( ((X) << 6) | ((X) << 4) | ((X) << 2) | (X) )
47 #define EXPAND_3_8(X) ( ((X) << 5) | ((X) << 2) | ((X) >> 1) )
49 #define EXPAND_4_8(X) ( ((X) << 4) | (X) )
51 #define EXPAND_5_8(X) ( ((X) << 3) | ((X) >> 2) )
53 #define EXPAND_6_8(X) ( ((X) << 2) | ((X) >> 4) )
57 * Convert an 8-bit sRGB value from non-linear space to a
58 * linear RGB value in [0, 1].
59 * Implemented with a 256-entry lookup table.
62 _mesa_nonlinear_to_linear(GLubyte cs8
)
64 static GLfloat table
[256];
65 static GLboolean tableReady
= GL_FALSE
;
67 /* compute lookup table now */
69 for (i
= 0; i
< 256; i
++) {
70 const GLfloat cs
= UBYTE_TO_FLOAT(i
);
72 table
[i
] = cs
/ 12.92f
;
75 table
[i
] = (GLfloat
) pow((cs
+ 0.055) / 1.055, 2.4);
84 /**********************************************************************/
85 /* Unpack, returning GLfloat colors */
86 /**********************************************************************/
88 typedef void (*unpack_rgba_func
)(const void *src
, GLfloat dst
[][4], GLuint n
);
92 unpack_A8B8G8R8_UNORM(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_R8G8B8A8_UNORM(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_B8G8R8A8_UNORM(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_A8R8G8B8_UNORM(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_B8G8R8X8_UNORM(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_X8R8G8B8_UNORM(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_BGR_UNORM8(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_RGB_UNORM8(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_B5G6R5_UNORM(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_R5G6B5_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
237 /* Warning: this function does not match the current Mesa definition
238 * of MESA_FORMAT_R5G6B5_UNORM.
240 const GLushort
*s
= ((const GLushort
*) src
);
242 for (i
= 0; i
< n
; i
++) {
243 GLuint t
= (s
[i
] >> 8) | (s
[i
] << 8); /* byte swap */
244 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( ((t
>> 8) & 0xf8) | ((t
>> 13) & 0x7) );
245 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( ((t
>> 3) & 0xfc) | ((t
>> 9) & 0x3) );
246 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( ((t
<< 3) & 0xf8) | ((t
>> 2) & 0x7) );
247 dst
[i
][ACOMP
] = 1.0F
;
252 unpack_B4G4R4A4_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
254 const GLushort
*s
= ((const GLushort
*) src
);
256 for (i
= 0; i
< n
; i
++) {
257 dst
[i
][RCOMP
] = ((s
[i
] >> 8) & 0xf) * (1.0F
/ 15.0F
);
258 dst
[i
][GCOMP
] = ((s
[i
] >> 4) & 0xf) * (1.0F
/ 15.0F
);
259 dst
[i
][BCOMP
] = ((s
[i
] ) & 0xf) * (1.0F
/ 15.0F
);
260 dst
[i
][ACOMP
] = ((s
[i
] >> 12) & 0xf) * (1.0F
/ 15.0F
);
265 unpack_A4R4G4B4_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
267 const GLushort
*s
= ((const GLushort
*) src
);
269 for (i
= 0; i
< n
; i
++) {
270 dst
[i
][RCOMP
] = ((s
[i
] >> 4) & 0xf) * (1.0F
/ 15.0F
);
271 dst
[i
][GCOMP
] = ((s
[i
] >> 8) & 0xf) * (1.0F
/ 15.0F
);
272 dst
[i
][BCOMP
] = ((s
[i
] >> 12) & 0xf) * (1.0F
/ 15.0F
);
273 dst
[i
][ACOMP
] = ((s
[i
] ) & 0xf) * (1.0F
/ 15.0F
);
278 unpack_A1B5G5R5_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
280 const GLushort
*s
= ((const GLushort
*) src
);
282 for (i
= 0; i
< n
; i
++) {
283 dst
[i
][RCOMP
] = ((s
[i
] >> 11) & 0x1f) * (1.0F
/ 31.0F
);
284 dst
[i
][GCOMP
] = ((s
[i
] >> 6) & 0x1f) * (1.0F
/ 31.0F
);
285 dst
[i
][BCOMP
] = ((s
[i
] >> 1) & 0x1f) * (1.0F
/ 31.0F
);
286 dst
[i
][ACOMP
] = ((s
[i
] ) & 0x01) * 1.0F
;
291 unpack_B5G5R5A1_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
293 const GLushort
*s
= ((const GLushort
*) src
);
295 for (i
= 0; i
< n
; i
++) {
296 dst
[i
][RCOMP
] = ((s
[i
] >> 10) & 0x1f) * (1.0F
/ 31.0F
);
297 dst
[i
][GCOMP
] = ((s
[i
] >> 5) & 0x1f) * (1.0F
/ 31.0F
);
298 dst
[i
][BCOMP
] = ((s
[i
] >> 0) & 0x1f) * (1.0F
/ 31.0F
);
299 dst
[i
][ACOMP
] = ((s
[i
] >> 15) & 0x01) * 1.0F
;
304 unpack_A1R5G5B5_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
306 /* Warning: this function does not match the current Mesa definition
307 * of MESA_FORMAT_A1R5G5B5_UNORM.
309 const GLushort
*s
= ((const GLushort
*) src
);
311 for (i
= 0; i
< n
; i
++) {
312 GLushort tmp
= (s
[i
] << 8) | (s
[i
] >> 8); /* byteswap */
313 dst
[i
][RCOMP
] = ((tmp
>> 10) & 0x1f) * (1.0F
/ 31.0F
);
314 dst
[i
][GCOMP
] = ((tmp
>> 5) & 0x1f) * (1.0F
/ 31.0F
);
315 dst
[i
][BCOMP
] = ((tmp
>> 0) & 0x1f) * (1.0F
/ 31.0F
);
316 dst
[i
][ACOMP
] = ((tmp
>> 15) & 0x01) * 1.0F
;
321 unpack_L4A4_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
323 const GLubyte
*s
= ((const GLubyte
*) src
);
325 for (i
= 0; i
< n
; i
++) {
328 dst
[i
][BCOMP
] = (s
[i
] & 0xf) * (1.0F
/ 15.0F
);
329 dst
[i
][ACOMP
] = ((s
[i
] >> 4) & 0xf) * (1.0F
/ 15.0F
);
334 unpack_L8A8_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
336 const GLushort
*s
= ((const GLushort
*) src
);
338 for (i
= 0; i
< n
; i
++) {
341 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( s
[i
] & 0xff );
342 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 8 );
347 unpack_A8L8_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
349 const GLushort
*s
= ((const GLushort
*) src
);
351 for (i
= 0; i
< n
; i
++) {
354 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 8 );
355 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( s
[i
] & 0xff );
360 unpack_L16A16_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
362 const GLuint
*s
= ((const GLuint
*) src
);
364 for (i
= 0; i
< n
; i
++) {
367 dst
[i
][BCOMP
] = USHORT_TO_FLOAT( s
[i
] & 0xffff );
368 dst
[i
][ACOMP
] = USHORT_TO_FLOAT( s
[i
] >> 16 );
373 unpack_A16L16_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
375 const GLuint
*s
= ((const GLuint
*) src
);
377 for (i
= 0; i
< n
; i
++) {
380 dst
[i
][BCOMP
] = USHORT_TO_FLOAT( s
[i
] >> 16 );
381 dst
[i
][ACOMP
] = USHORT_TO_FLOAT( s
[i
] & 0xffff );
386 unpack_B2G3R3_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
388 const GLubyte
*s
= ((const GLubyte
*) src
);
390 for (i
= 0; i
< n
; i
++) {
391 dst
[i
][RCOMP
] = ((s
[i
] >> 5) & 0x7) * (1.0F
/ 7.0F
);
392 dst
[i
][GCOMP
] = ((s
[i
] >> 2) & 0x7) * (1.0F
/ 7.0F
);
393 dst
[i
][BCOMP
] = ((s
[i
] ) & 0x3) * (1.0F
/ 3.0F
);
394 dst
[i
][ACOMP
] = 1.0F
;
400 unpack_A_UNORM8(const void *src
, GLfloat dst
[][4], GLuint n
)
402 const GLubyte
*s
= ((const GLubyte
*) src
);
404 for (i
= 0; i
< n
; i
++) {
407 dst
[i
][BCOMP
] = 0.0F
;
408 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT(s
[i
]);
413 unpack_A_UNORM16(const void *src
, GLfloat dst
[][4], GLuint n
)
415 const GLushort
*s
= ((const GLushort
*) src
);
417 for (i
= 0; i
< n
; i
++) {
420 dst
[i
][BCOMP
] = 0.0F
;
421 dst
[i
][ACOMP
] = USHORT_TO_FLOAT(s
[i
]);
426 unpack_L_UNORM8(const void *src
, GLfloat dst
[][4], GLuint n
)
428 const GLubyte
*s
= ((const GLubyte
*) src
);
430 for (i
= 0; i
< n
; i
++) {
433 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT(s
[i
]);
434 dst
[i
][ACOMP
] = 1.0F
;
439 unpack_L_UNORM16(const void *src
, GLfloat dst
[][4], GLuint n
)
441 const GLushort
*s
= ((const GLushort
*) src
);
443 for (i
= 0; i
< n
; i
++) {
446 dst
[i
][BCOMP
] = USHORT_TO_FLOAT(s
[i
]);
447 dst
[i
][ACOMP
] = 1.0F
;
452 unpack_I_UNORM8(const void *src
, GLfloat dst
[][4], GLuint n
)
454 const GLubyte
*s
= ((const GLubyte
*) src
);
456 for (i
= 0; i
< n
; i
++) {
460 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT(s
[i
]);
465 unpack_I_UNORM16(const void *src
, GLfloat dst
[][4], GLuint n
)
467 const GLushort
*s
= ((const GLushort
*) src
);
469 for (i
= 0; i
< n
; i
++) {
473 dst
[i
][ACOMP
] = USHORT_TO_FLOAT(s
[i
]);
478 unpack_YCBCR(const void *src
, GLfloat dst
[][4], GLuint n
)
481 for (i
= 0; i
< n
; i
++) {
482 const GLushort
*src0
= ((const GLushort
*) src
) + i
* 2; /* even */
483 const GLushort
*src1
= src0
+ 1; /* odd */
484 const GLubyte y0
= (*src0
>> 8) & 0xff; /* luminance */
485 const GLubyte cb
= *src0
& 0xff; /* chroma U */
486 const GLubyte y1
= (*src1
>> 8) & 0xff; /* luminance */
487 const GLubyte cr
= *src1
& 0xff; /* chroma V */
488 const GLubyte y
= (i
& 1) ? y1
: y0
; /* choose even/odd luminance */
489 GLfloat r
= 1.164F
* (y
- 16) + 1.596F
* (cr
- 128);
490 GLfloat g
= 1.164F
* (y
- 16) - 0.813F
* (cr
- 128) - 0.391F
* (cb
- 128);
491 GLfloat b
= 1.164F
* (y
- 16) + 2.018F
* (cb
- 128);
492 r
*= (1.0F
/ 255.0F
);
493 g
*= (1.0F
/ 255.0F
);
494 b
*= (1.0F
/ 255.0F
);
495 dst
[i
][RCOMP
] = CLAMP(r
, 0.0F
, 1.0F
);
496 dst
[i
][GCOMP
] = CLAMP(g
, 0.0F
, 1.0F
);
497 dst
[i
][BCOMP
] = CLAMP(b
, 0.0F
, 1.0F
);
498 dst
[i
][ACOMP
] = 1.0F
;
503 unpack_YCBCR_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
506 for (i
= 0; i
< n
; i
++) {
507 const GLushort
*src0
= ((const GLushort
*) src
) + i
* 2; /* even */
508 const GLushort
*src1
= src0
+ 1; /* odd */
509 const GLubyte y0
= *src0
& 0xff; /* luminance */
510 const GLubyte cr
= (*src0
>> 8) & 0xff; /* chroma V */
511 const GLubyte y1
= *src1
& 0xff; /* luminance */
512 const GLubyte cb
= (*src1
>> 8) & 0xff; /* chroma U */
513 const GLubyte y
= (i
& 1) ? y1
: y0
; /* choose even/odd luminance */
514 GLfloat r
= 1.164F
* (y
- 16) + 1.596F
* (cr
- 128);
515 GLfloat g
= 1.164F
* (y
- 16) - 0.813F
* (cr
- 128) - 0.391F
* (cb
- 128);
516 GLfloat b
= 1.164F
* (y
- 16) + 2.018F
* (cb
- 128);
517 r
*= (1.0F
/ 255.0F
);
518 g
*= (1.0F
/ 255.0F
);
519 b
*= (1.0F
/ 255.0F
);
520 dst
[i
][RCOMP
] = CLAMP(r
, 0.0F
, 1.0F
);
521 dst
[i
][GCOMP
] = CLAMP(g
, 0.0F
, 1.0F
);
522 dst
[i
][BCOMP
] = CLAMP(b
, 0.0F
, 1.0F
);
523 dst
[i
][ACOMP
] = 1.0F
;
528 unpack_R_UNORM8(const void *src
, GLfloat dst
[][4], GLuint n
)
530 const GLubyte
*s
= ((const GLubyte
*) src
);
532 for (i
= 0; i
< n
; i
++) {
533 dst
[i
][0] = UBYTE_TO_FLOAT(s
[i
]);
541 unpack_R8G8_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
543 const GLushort
*s
= ((const GLushort
*) src
);
545 for (i
= 0; i
< n
; i
++) {
546 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( s
[i
] & 0xff );
547 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 8 );
554 unpack_G8R8_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
556 const GLushort
*s
= ((const GLushort
*) src
);
558 for (i
= 0; i
< n
; i
++) {
559 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 8 );
560 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( s
[i
] & 0xff );
567 unpack_R_UNORM16(const void *src
, GLfloat dst
[][4], GLuint n
)
569 const GLushort
*s
= ((const GLushort
*) src
);
571 for (i
= 0; i
< n
; i
++) {
572 dst
[i
][RCOMP
] = USHORT_TO_FLOAT(s
[i
]);
580 unpack_R16G16_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
582 const GLuint
*s
= ((const GLuint
*) src
);
584 for (i
= 0; i
< n
; i
++) {
585 dst
[i
][RCOMP
] = USHORT_TO_FLOAT( s
[i
] & 0xffff );
586 dst
[i
][GCOMP
] = USHORT_TO_FLOAT( s
[i
] >> 16 );
593 unpack_G16R16_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
595 const GLuint
*s
= ((const GLuint
*) src
);
597 for (i
= 0; i
< n
; i
++) {
598 dst
[i
][RCOMP
] = USHORT_TO_FLOAT( s
[i
] >> 16 );
599 dst
[i
][GCOMP
] = USHORT_TO_FLOAT( s
[i
] & 0xffff );
606 unpack_B10G10R10A2_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
608 const GLuint
*s
= ((const GLuint
*) src
);
610 for (i
= 0; i
< n
; i
++) {
611 dst
[i
][RCOMP
] = ((s
[i
] >> 20) & 0x3ff) * (1.0F
/ 1023.0F
);
612 dst
[i
][GCOMP
] = ((s
[i
] >> 10) & 0x3ff) * (1.0F
/ 1023.0F
);
613 dst
[i
][BCOMP
] = ((s
[i
] >> 0) & 0x3ff) * (1.0F
/ 1023.0F
);
614 dst
[i
][ACOMP
] = ((s
[i
] >> 30) & 0x03) * (1.0F
/ 3.0F
);
620 unpack_ARGB2101010_UINT(const void *src
, GLfloat dst
[][4], GLuint n
)
622 const GLuint
*s
= (const GLuint
*) src
;
624 for (i
= 0; i
< n
; i
++) {
625 dst
[i
][RCOMP
] = (GLfloat
)((s
[i
] >> 20) & 0x3ff);
626 dst
[i
][GCOMP
] = (GLfloat
)((s
[i
] >> 10) & 0x3ff);
627 dst
[i
][BCOMP
] = (GLfloat
)((s
[i
] >> 0) & 0x3ff);
628 dst
[i
][ACOMP
] = (GLfloat
)((s
[i
] >> 30) & 0x03);
634 unpack_ABGR2101010_UINT(const void *src
, GLfloat dst
[][4], GLuint n
)
636 const GLuint
*s
= ((const GLuint
*) src
);
638 for (i
= 0; i
< n
; i
++) {
639 dst
[i
][RCOMP
] = (GLfloat
)((s
[i
] >> 0) & 0x3ff);
640 dst
[i
][GCOMP
] = (GLfloat
)((s
[i
] >> 10) & 0x3ff);
641 dst
[i
][BCOMP
] = (GLfloat
)((s
[i
] >> 20) & 0x3ff);
642 dst
[i
][ACOMP
] = (GLfloat
)((s
[i
] >> 30) & 0x03);
648 unpack_Z24_S8(const void *src
, GLfloat dst
[][4], GLuint n
)
650 /* only return Z, not stencil data */
651 const GLuint
*s
= ((const GLuint
*) src
);
652 const GLdouble scale
= 1.0 / (GLdouble
) 0xffffff;
654 for (i
= 0; i
< n
; i
++) {
657 dst
[i
][2] = (GLfloat
) ((s
[i
] >> 8) * scale
);
659 ASSERT(dst
[i
][0] >= 0.0F
);
660 ASSERT(dst
[i
][0] <= 1.0F
);
665 unpack_S8_Z24(const void *src
, GLfloat dst
[][4], GLuint n
)
667 /* only return Z, not stencil data */
668 const GLuint
*s
= ((const GLuint
*) src
);
669 const GLdouble scale
= 1.0 / (GLdouble
) 0xffffff;
671 for (i
= 0; i
< n
; i
++) {
674 dst
[i
][2] = (float) ((s
[i
] & 0x00ffffff) * scale
);
676 ASSERT(dst
[i
][0] >= 0.0F
);
677 ASSERT(dst
[i
][0] <= 1.0F
);
682 unpack_Z16(const void *src
, GLfloat dst
[][4], GLuint n
)
684 const GLushort
*s
= ((const GLushort
*) src
);
686 for (i
= 0; i
< n
; i
++) {
689 dst
[i
][2] = s
[i
] * (1.0F
/ 65535.0F
);
695 unpack_X8_Z24(const void *src
, GLfloat dst
[][4], GLuint n
)
697 unpack_S8_Z24(src
, dst
, n
);
701 unpack_Z24_X8(const void *src
, GLfloat dst
[][4], GLuint n
)
703 unpack_Z24_S8(src
, dst
, n
);
707 unpack_Z32(const void *src
, GLfloat dst
[][4], GLuint n
)
709 const GLuint
*s
= ((const GLuint
*) src
);
711 for (i
= 0; i
< n
; i
++) {
714 dst
[i
][2] = s
[i
] * (1.0F
/ 0xffffffff);
720 unpack_Z32_FLOAT(const void *src
, GLfloat dst
[][4], GLuint n
)
722 const GLfloat
*s
= ((const GLfloat
*) src
);
724 for (i
= 0; i
< n
; i
++) {
727 dst
[i
][2] = s
[i
* 2];
733 unpack_Z32_FLOAT_X24S8(const void *src
, GLfloat dst
[][4], GLuint n
)
735 const GLfloat
*s
= ((const GLfloat
*) src
);
737 for (i
= 0; i
< n
; i
++) {
747 unpack_S8(const void *src
, GLfloat dst
[][4], GLuint n
)
749 /* should never be used */
751 for (i
= 0; i
< n
; i
++) {
761 unpack_BGR_SRGB8(const void *src
, GLfloat dst
[][4], GLuint n
)
763 const GLubyte
*s
= (const GLubyte
*) src
;
765 for (i
= 0; i
< n
; i
++) {
766 dst
[i
][RCOMP
] = _mesa_nonlinear_to_linear(s
[i
*3+2]);
767 dst
[i
][GCOMP
] = _mesa_nonlinear_to_linear(s
[i
*3+1]);
768 dst
[i
][BCOMP
] = _mesa_nonlinear_to_linear(s
[i
*3+0]);
769 dst
[i
][ACOMP
] = 1.0F
;
774 unpack_A8B8G8R8_SRGB(const void *src
, GLfloat dst
[][4], GLuint n
)
776 const GLuint
*s
= ((const GLuint
*) src
);
778 for (i
= 0; i
< n
; i
++) {
779 dst
[i
][RCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] >> 24) );
780 dst
[i
][GCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] >> 16) & 0xff );
781 dst
[i
][BCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] >> 8) & 0xff );
782 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( s
[i
] & 0xff ); /* linear! */
787 unpack_B8G8R8A8_SRGB(const void *src
, GLfloat dst
[][4], GLuint n
)
789 const GLuint
*s
= ((const GLuint
*) src
);
791 for (i
= 0; i
< n
; i
++) {
792 dst
[i
][RCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] >> 16) & 0xff );
793 dst
[i
][GCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] >> 8) & 0xff );
794 dst
[i
][BCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] ) & 0xff );
795 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 24 ); /* linear! */
800 unpack_R8G8B8A8_SRGB(const void *src
, GLfloat dst
[][4], GLuint n
)
802 const GLuint
*s
= ((const GLuint
*) src
);
804 for (i
= 0; i
< n
; i
++) {
805 dst
[i
][RCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] ) & 0xff );
806 dst
[i
][GCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] >> 8) & 0xff );
807 dst
[i
][BCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] >> 16) & 0xff );
808 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 24 ); /* linear! */
813 unpack_L_SRGB8(const void *src
, GLfloat dst
[][4], GLuint n
)
815 const GLubyte
*s
= ((const GLubyte
*) src
);
817 for (i
= 0; i
< n
; i
++) {
820 dst
[i
][BCOMP
] = _mesa_nonlinear_to_linear(s
[i
]);
821 dst
[i
][ACOMP
] = 1.0F
;
826 unpack_L8A8_SRGB(const void *src
, GLfloat dst
[][4], GLuint n
)
828 const GLushort
*s
= (const GLushort
*) src
;
830 for (i
= 0; i
< n
; i
++) {
833 dst
[i
][BCOMP
] = _mesa_nonlinear_to_linear(s
[i
] & 0xff);
834 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT(s
[i
] >> 8); /* linear! */
839 unpack_SRGB_DXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
844 unpack_SRGBA_DXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
849 unpack_SRGBA_DXT3(const void *src
, GLfloat dst
[][4], GLuint n
)
854 unpack_SRGBA_DXT5(const void *src
, GLfloat dst
[][4], GLuint n
)
859 unpack_RGB_FXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
864 unpack_RGBA_FXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
869 unpack_RGB_DXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
874 unpack_RGBA_DXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
879 unpack_RGBA_DXT3(const void *src
, GLfloat dst
[][4], GLuint n
)
884 unpack_RGBA_DXT5(const void *src
, GLfloat dst
[][4], GLuint n
)
890 unpack_RGBA_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
892 const GLfloat
*s
= (const GLfloat
*) src
;
894 for (i
= 0; i
< n
; i
++) {
895 dst
[i
][RCOMP
] = s
[i
*4+0];
896 dst
[i
][GCOMP
] = s
[i
*4+1];
897 dst
[i
][BCOMP
] = s
[i
*4+2];
898 dst
[i
][ACOMP
] = s
[i
*4+3];
903 unpack_RGBA_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
905 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
907 for (i
= 0; i
< n
; i
++) {
908 dst
[i
][RCOMP
] = _mesa_half_to_float(s
[i
*4+0]);
909 dst
[i
][GCOMP
] = _mesa_half_to_float(s
[i
*4+1]);
910 dst
[i
][BCOMP
] = _mesa_half_to_float(s
[i
*4+2]);
911 dst
[i
][ACOMP
] = _mesa_half_to_float(s
[i
*4+3]);
916 unpack_RGB_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
918 const GLfloat
*s
= (const GLfloat
*) src
;
920 for (i
= 0; i
< n
; i
++) {
921 dst
[i
][RCOMP
] = s
[i
*3+0];
922 dst
[i
][GCOMP
] = s
[i
*3+1];
923 dst
[i
][BCOMP
] = s
[i
*3+2];
924 dst
[i
][ACOMP
] = 1.0F
;
929 unpack_RGB_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
931 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
933 for (i
= 0; i
< n
; i
++) {
934 dst
[i
][RCOMP
] = _mesa_half_to_float(s
[i
*3+0]);
935 dst
[i
][GCOMP
] = _mesa_half_to_float(s
[i
*3+1]);
936 dst
[i
][BCOMP
] = _mesa_half_to_float(s
[i
*3+2]);
937 dst
[i
][ACOMP
] = 1.0F
;
942 unpack_A_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
944 const GLfloat
*s
= (const GLfloat
*) src
;
946 for (i
= 0; i
< n
; i
++) {
949 dst
[i
][BCOMP
] = 0.0F
;
950 dst
[i
][ACOMP
] = s
[i
];
955 unpack_A_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
957 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
959 for (i
= 0; i
< n
; i
++) {
962 dst
[i
][BCOMP
] = 0.0F
;
963 dst
[i
][ACOMP
] = _mesa_half_to_float(s
[i
]);
968 unpack_L_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
970 const GLfloat
*s
= (const GLfloat
*) src
;
972 for (i
= 0; i
< n
; i
++) {
975 dst
[i
][BCOMP
] = s
[i
];
976 dst
[i
][ACOMP
] = 1.0F
;
981 unpack_L_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
983 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
985 for (i
= 0; i
< n
; i
++) {
988 dst
[i
][BCOMP
] = _mesa_half_to_float(s
[i
]);
989 dst
[i
][ACOMP
] = 1.0F
;
994 unpack_LA_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
996 const GLfloat
*s
= (const GLfloat
*) src
;
998 for (i
= 0; i
< n
; i
++) {
1001 dst
[i
][BCOMP
] = s
[i
*2+0];
1002 dst
[i
][ACOMP
] = s
[i
*2+1];
1007 unpack_LA_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1009 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
1011 for (i
= 0; i
< n
; i
++) {
1014 dst
[i
][BCOMP
] = _mesa_half_to_float(s
[i
*2+0]);
1015 dst
[i
][ACOMP
] = _mesa_half_to_float(s
[i
*2+1]);
1020 unpack_I_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1022 const GLfloat
*s
= (const GLfloat
*) src
;
1024 for (i
= 0; i
< n
; i
++) {
1028 dst
[i
][ACOMP
] = s
[i
];
1033 unpack_I_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1035 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
1037 for (i
= 0; i
< n
; i
++) {
1041 dst
[i
][ACOMP
] = _mesa_half_to_float(s
[i
]);
1046 unpack_R_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1048 const GLfloat
*s
= (const GLfloat
*) src
;
1050 for (i
= 0; i
< n
; i
++) {
1051 dst
[i
][RCOMP
] = s
[i
];
1052 dst
[i
][GCOMP
] = 0.0F
;
1053 dst
[i
][BCOMP
] = 0.0F
;
1054 dst
[i
][ACOMP
] = 1.0F
;
1059 unpack_R_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1061 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
1063 for (i
= 0; i
< n
; i
++) {
1064 dst
[i
][RCOMP
] = _mesa_half_to_float(s
[i
]);
1065 dst
[i
][GCOMP
] = 0.0F
;
1066 dst
[i
][BCOMP
] = 0.0F
;
1067 dst
[i
][ACOMP
] = 1.0F
;
1072 unpack_RG_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1074 const GLfloat
*s
= (const GLfloat
*) src
;
1076 for (i
= 0; i
< n
; i
++) {
1077 dst
[i
][RCOMP
] = s
[i
*2+0];
1078 dst
[i
][GCOMP
] = s
[i
*2+1];
1079 dst
[i
][BCOMP
] = 0.0F
;
1080 dst
[i
][ACOMP
] = 1.0F
;
1085 unpack_RG_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1087 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
1089 for (i
= 0; i
< n
; i
++) {
1090 dst
[i
][RCOMP
] = _mesa_half_to_float(s
[i
*2+0]);
1091 dst
[i
][GCOMP
] = _mesa_half_to_float(s
[i
*2+1]);
1092 dst
[i
][BCOMP
] = 0.0F
;
1093 dst
[i
][ACOMP
] = 1.0F
;
1098 unpack_ALPHA_UINT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1100 const GLubyte
*s
= (const GLubyte
*) src
;
1102 for (i
= 0; i
< n
; i
++) {
1105 dst
[i
][BCOMP
] = 0.0;
1106 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1111 unpack_ALPHA_UINT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1113 const GLushort
*s
= (const GLushort
*) src
;
1115 for (i
= 0; i
< n
; i
++) {
1118 dst
[i
][BCOMP
] = 0.0;
1119 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1124 unpack_ALPHA_UINT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1126 const GLuint
*s
= (const GLuint
*) src
;
1128 for (i
= 0; i
< n
; i
++) {
1131 dst
[i
][BCOMP
] = 0.0;
1132 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1137 unpack_ALPHA_INT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1139 const GLbyte
*s
= (const GLbyte
*) src
;
1141 for (i
= 0; i
< n
; i
++) {
1144 dst
[i
][BCOMP
] = 0.0;
1145 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1150 unpack_ALPHA_INT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1152 const GLshort
*s
= (const GLshort
*) src
;
1154 for (i
= 0; i
< n
; i
++) {
1157 dst
[i
][BCOMP
] = 0.0;
1158 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1163 unpack_ALPHA_INT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1165 const GLint
*s
= (const GLint
*) src
;
1167 for (i
= 0; i
< n
; i
++) {
1170 dst
[i
][BCOMP
] = 0.0;
1171 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1176 unpack_INTENSITY_UINT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1178 const GLubyte
*s
= (const GLubyte
*) src
;
1180 for (i
= 0; i
< n
; i
++) {
1184 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1189 unpack_INTENSITY_UINT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1191 const GLushort
*s
= (const GLushort
*) src
;
1193 for (i
= 0; i
< n
; i
++) {
1197 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1202 unpack_INTENSITY_UINT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1204 const GLuint
*s
= (const GLuint
*) src
;
1206 for (i
= 0; i
< n
; i
++) {
1210 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1215 unpack_INTENSITY_INT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1217 const GLbyte
*s
= (const GLbyte
*) src
;
1219 for (i
= 0; i
< n
; i
++) {
1223 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1228 unpack_INTENSITY_INT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1230 const GLshort
*s
= (const GLshort
*) src
;
1232 for (i
= 0; i
< n
; i
++) {
1236 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1241 unpack_INTENSITY_INT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1243 const GLint
*s
= (const GLint
*) src
;
1245 for (i
= 0; i
< n
; i
++) {
1249 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1254 unpack_LUMINANCE_UINT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1256 const GLubyte
*s
= (const GLubyte
*) src
;
1258 for (i
= 0; i
< n
; i
++) {
1259 dst
[i
][RCOMP
] = dst
[i
][GCOMP
] = dst
[i
][BCOMP
] = (GLfloat
) s
[i
];
1260 dst
[i
][ACOMP
] = 1.0;
1265 unpack_LUMINANCE_UINT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1267 const GLushort
*s
= (const GLushort
*) src
;
1269 for (i
= 0; i
< n
; i
++) {
1270 dst
[i
][RCOMP
] = dst
[i
][GCOMP
] = dst
[i
][BCOMP
] = (GLfloat
) s
[i
];
1271 dst
[i
][ACOMP
] = 1.0;
1276 unpack_LUMINANCE_UINT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1278 const GLuint
*s
= (const GLuint
*) src
;
1280 for (i
= 0; i
< n
; i
++) {
1281 dst
[i
][RCOMP
] = dst
[i
][GCOMP
] = dst
[i
][BCOMP
] = (GLfloat
) s
[i
];
1282 dst
[i
][ACOMP
] = 1.0;
1287 unpack_LUMINANCE_INT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1289 const GLbyte
*s
= (const GLbyte
*) src
;
1291 for (i
= 0; i
< n
; i
++) {
1292 dst
[i
][RCOMP
] = dst
[i
][GCOMP
] = dst
[i
][BCOMP
] = (GLfloat
) s
[i
];
1293 dst
[i
][ACOMP
] = 1.0;
1298 unpack_LUMINANCE_INT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1300 const GLshort
*s
= (const GLshort
*) src
;
1302 for (i
= 0; i
< n
; i
++) {
1303 dst
[i
][RCOMP
] = dst
[i
][GCOMP
] = dst
[i
][BCOMP
] = (GLfloat
) s
[i
];
1304 dst
[i
][ACOMP
] = 1.0;
1309 unpack_LUMINANCE_INT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1311 const GLint
*s
= (const GLint
*) src
;
1313 for (i
= 0; i
< n
; i
++) {
1314 dst
[i
][RCOMP
] = dst
[i
][GCOMP
] = dst
[i
][BCOMP
] = (GLfloat
) s
[i
];
1315 dst
[i
][ACOMP
] = 1.0;
1320 unpack_LUMINANCE_ALPHA_UINT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1322 const GLubyte
*s
= (const GLubyte
*) src
;
1324 for (i
= 0; i
< n
; i
++) {
1327 dst
[i
][BCOMP
] = (GLfloat
) s
[2*i
+0];
1328 dst
[i
][ACOMP
] = (GLfloat
) s
[2*i
+1];
1333 unpack_LUMINANCE_ALPHA_UINT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1335 const GLushort
*s
= (const GLushort
*) src
;
1337 for (i
= 0; i
< n
; i
++) {
1340 dst
[i
][BCOMP
] = (GLfloat
) s
[2*i
+0];
1341 dst
[i
][ACOMP
] = (GLfloat
) s
[2*i
+1];
1346 unpack_LUMINANCE_ALPHA_UINT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1348 const GLuint
*s
= (const GLuint
*) src
;
1350 for (i
= 0; i
< n
; i
++) {
1353 dst
[i
][BCOMP
] = (GLfloat
) s
[2*i
+0];
1354 dst
[i
][ACOMP
] = (GLfloat
) s
[2*i
+1];
1359 unpack_LUMINANCE_ALPHA_INT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1361 const GLbyte
*s
= (const GLbyte
*) src
;
1363 for (i
= 0; i
< n
; i
++) {
1366 dst
[i
][BCOMP
] = (GLfloat
) s
[2*i
+0];
1367 dst
[i
][ACOMP
] = (GLfloat
) s
[2*i
+1];
1372 unpack_LUMINANCE_ALPHA_INT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1374 const GLshort
*s
= (const GLshort
*) src
;
1376 for (i
= 0; i
< n
; i
++) {
1379 dst
[i
][BCOMP
] = (GLfloat
) s
[2*i
+0];
1380 dst
[i
][ACOMP
] = (GLfloat
) s
[2*i
+1];
1385 unpack_LUMINANCE_ALPHA_INT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1387 const GLint
*s
= (const GLint
*) src
;
1389 for (i
= 0; i
< n
; i
++) {
1392 dst
[i
][BCOMP
] = (GLfloat
) s
[2*i
+0];
1393 dst
[i
][ACOMP
] = (GLfloat
) s
[2*i
+1];
1398 unpack_R_INT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1400 const GLbyte
*s
= (const GLbyte
*) src
;
1402 for (i
= 0; i
< n
; i
++) {
1403 dst
[i
][RCOMP
] = (GLfloat
) s
[i
];
1404 dst
[i
][GCOMP
] = 0.0;
1405 dst
[i
][BCOMP
] = 0.0;
1406 dst
[i
][ACOMP
] = 1.0;
1411 unpack_RG_INT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1413 const GLbyte
*s
= (const GLbyte
*) src
;
1415 for (i
= 0; i
< n
; i
++) {
1416 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*2+0];
1417 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*2+1];
1418 dst
[i
][BCOMP
] = 0.0;
1419 dst
[i
][ACOMP
] = 1.0;
1424 unpack_RGB_INT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1426 const GLbyte
*s
= (const GLbyte
*) src
;
1428 for (i
= 0; i
< n
; i
++) {
1429 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*3+0];
1430 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*3+1];
1431 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*3+2];
1432 dst
[i
][ACOMP
] = 1.0;
1437 unpack_RGBA_INT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1439 const GLbyte
*s
= (const GLbyte
*) src
;
1441 for (i
= 0; i
< n
; i
++) {
1442 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1443 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1444 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1445 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1450 unpack_R_INT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1452 const GLshort
*s
= (const GLshort
*) src
;
1454 for (i
= 0; i
< n
; i
++) {
1455 dst
[i
][RCOMP
] = (GLfloat
) s
[i
];
1456 dst
[i
][GCOMP
] = 0.0;
1457 dst
[i
][BCOMP
] = 0.0;
1458 dst
[i
][ACOMP
] = 1.0;
1463 unpack_RG_INT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1465 const GLshort
*s
= (const GLshort
*) src
;
1467 for (i
= 0; i
< n
; i
++) {
1468 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*2+0];
1469 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*2+1];
1470 dst
[i
][BCOMP
] = 0.0;
1471 dst
[i
][ACOMP
] = 1.0;
1476 unpack_RGB_INT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1478 const GLshort
*s
= (const GLshort
*) src
;
1480 for (i
= 0; i
< n
; i
++) {
1481 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*3+0];
1482 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*3+1];
1483 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*3+2];
1484 dst
[i
][ACOMP
] = 1.0;
1489 unpack_RGBA_INT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1491 const GLshort
*s
= (const GLshort
*) src
;
1493 for (i
= 0; i
< n
; i
++) {
1494 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1495 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1496 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1497 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1502 unpack_R_INT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1504 const GLint
*s
= (const GLint
*) src
;
1506 for (i
= 0; i
< n
; i
++) {
1507 dst
[i
][RCOMP
] = (GLfloat
) s
[i
];
1508 dst
[i
][GCOMP
] = 0.0;
1509 dst
[i
][BCOMP
] = 0.0;
1510 dst
[i
][ACOMP
] = 1.0;
1515 unpack_RG_INT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1517 const GLint
*s
= (const GLint
*) src
;
1519 for (i
= 0; i
< n
; i
++) {
1520 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*2+0];
1521 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*2+1];
1522 dst
[i
][BCOMP
] = 0.0;
1523 dst
[i
][ACOMP
] = 1.0;
1528 unpack_RGB_INT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1530 const GLint
*s
= (const GLint
*) src
;
1532 for (i
= 0; i
< n
; i
++) {
1533 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*3+0];
1534 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*3+1];
1535 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*3+2];
1536 dst
[i
][ACOMP
] = 1.0;
1542 unpack_RGBA_INT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1544 const GLint
*s
= (const GLint
*) src
;
1546 for (i
= 0; i
< n
; i
++) {
1547 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1548 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1549 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1550 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1555 unpack_R_UINT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1557 const GLubyte
*s
= (const GLubyte
*) src
;
1559 for (i
= 0; i
< n
; i
++) {
1560 dst
[i
][RCOMP
] = (GLfloat
) s
[i
];
1561 dst
[i
][GCOMP
] = 0.0;
1562 dst
[i
][BCOMP
] = 0.0;
1563 dst
[i
][ACOMP
] = 1.0;
1568 unpack_RG_UINT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1570 const GLubyte
*s
= (const GLubyte
*) src
;
1572 for (i
= 0; i
< n
; i
++) {
1573 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*2+0];
1574 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*2+1];
1575 dst
[i
][BCOMP
] = 0.0;
1576 dst
[i
][ACOMP
] = 1.0;
1581 unpack_RGB_UINT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1583 const GLubyte
*s
= (const GLubyte
*) src
;
1585 for (i
= 0; i
< n
; i
++) {
1586 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*3+0];
1587 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*3+1];
1588 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*3+2];
1589 dst
[i
][ACOMP
] = 1.0;
1594 unpack_RGBA_UINT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1596 const GLubyte
*s
= (const GLubyte
*) src
;
1598 for (i
= 0; i
< n
; i
++) {
1599 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1600 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1601 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1602 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1607 unpack_R_UINT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1609 const GLushort
*s
= (const GLushort
*) src
;
1611 for (i
= 0; i
< n
; i
++) {
1612 dst
[i
][RCOMP
] = (GLfloat
) s
[i
];
1613 dst
[i
][GCOMP
] = 0.0;
1614 dst
[i
][BCOMP
] = 0.0;
1615 dst
[i
][ACOMP
] = 1.0;
1620 unpack_RG_UINT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1622 const GLushort
*s
= (const GLushort
*) src
;
1624 for (i
= 0; i
< n
; i
++) {
1625 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*2+0];
1626 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*2+1];
1627 dst
[i
][BCOMP
] = 0.0;
1628 dst
[i
][ACOMP
] = 1.0;
1633 unpack_RGB_UINT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1635 const GLushort
*s
= (const GLushort
*) src
;
1637 for (i
= 0; i
< n
; i
++) {
1638 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*3+0];
1639 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*3+1];
1640 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*3+2];
1641 dst
[i
][ACOMP
] = 1.0;
1646 unpack_RGBA_UINT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1648 const GLushort
*s
= (const GLushort
*) src
;
1650 for (i
= 0; i
< n
; i
++) {
1651 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1652 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1653 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1654 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1659 unpack_R_UINT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1661 const GLuint
*s
= (const GLuint
*) src
;
1663 for (i
= 0; i
< n
; i
++) {
1664 dst
[i
][RCOMP
] = (GLfloat
) s
[i
];
1665 dst
[i
][GCOMP
] = 0.0;
1666 dst
[i
][BCOMP
] = 0.0;
1667 dst
[i
][ACOMP
] = 1.0;
1672 unpack_RG_UINT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1674 const GLuint
*s
= (const GLuint
*) src
;
1676 for (i
= 0; i
< n
; i
++) {
1677 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*2+0];
1678 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*2+1];
1679 dst
[i
][BCOMP
] = 0.0;
1680 dst
[i
][ACOMP
] = 1.0;
1685 unpack_RGB_UINT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1687 const GLuint
*s
= (const GLuint
*) src
;
1689 for (i
= 0; i
< n
; i
++) {
1690 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*3+0];
1691 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*3+1];
1692 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*3+2];
1693 dst
[i
][ACOMP
] = 1.0;
1698 unpack_RGBA_UINT32(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
] = (GLfloat
) s
[i
*4+3];
1711 unpack_DUDV8(const void *src
, GLfloat dst
[][4], GLuint n
)
1713 const GLbyte
*s
= (const GLbyte
*) src
;
1715 for (i
= 0; i
< n
; i
++) {
1716 dst
[i
][RCOMP
] = BYTE_TO_FLOAT(s
[i
*2+0]);
1717 dst
[i
][GCOMP
] = BYTE_TO_FLOAT(s
[i
*2+1]);
1724 unpack_SIGNED_R_UNORM8(const void *src
, GLfloat dst
[][4], GLuint n
)
1726 const GLbyte
*s
= ((const GLbyte
*) src
);
1728 for (i
= 0; i
< n
; i
++) {
1729 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( s
[i
] );
1730 dst
[i
][GCOMP
] = 0.0F
;
1731 dst
[i
][BCOMP
] = 0.0F
;
1732 dst
[i
][ACOMP
] = 1.0F
;
1737 unpack_SIGNED_RG88_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
1739 const GLushort
*s
= ((const GLushort
*) src
);
1741 for (i
= 0; i
< n
; i
++) {
1742 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] & 0xff) );
1743 dst
[i
][GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
1744 dst
[i
][BCOMP
] = 0.0F
;
1745 dst
[i
][ACOMP
] = 1.0F
;
1750 unpack_SIGNED_RGBX8888(const void *src
, GLfloat dst
[][4], GLuint n
)
1752 const GLuint
*s
= ((const GLuint
*) src
);
1754 for (i
= 0; i
< n
; i
++) {
1755 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 24) );
1756 dst
[i
][GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 16) );
1757 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
1758 dst
[i
][ACOMP
] = 1.0f
;
1763 unpack_SIGNED_A8B8G8R8_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
1765 const GLuint
*s
= ((const GLuint
*) src
);
1767 for (i
= 0; i
< n
; i
++) {
1768 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 24) );
1769 dst
[i
][GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 16) );
1770 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
1771 dst
[i
][ACOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] ) );
1776 unpack_SIGNED_R8G8B8A8_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
1778 const GLuint
*s
= ((const GLuint
*) src
);
1780 for (i
= 0; i
< n
; i
++) {
1781 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] ) );
1782 dst
[i
][GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
1783 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 16) );
1784 dst
[i
][ACOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 24) );
1789 unpack_SIGNED_R_UNORM16(const void *src
, GLfloat dst
[][4], GLuint n
)
1791 const GLshort
*s
= ((const GLshort
*) src
);
1793 for (i
= 0; i
< n
; i
++) {
1794 dst
[i
][RCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
] );
1795 dst
[i
][GCOMP
] = 0.0F
;
1796 dst
[i
][BCOMP
] = 0.0F
;
1797 dst
[i
][ACOMP
] = 1.0F
;
1802 unpack_SIGNED_R16G16_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
1804 const GLuint
*s
= ((const GLuint
*) src
);
1806 for (i
= 0; i
< n
; i
++) {
1807 dst
[i
][RCOMP
] = SHORT_TO_FLOAT_TEX( (GLshort
) (s
[i
] & 0xffff) );
1808 dst
[i
][GCOMP
] = SHORT_TO_FLOAT_TEX( (GLshort
) (s
[i
] >> 16) );
1809 dst
[i
][BCOMP
] = 0.0F
;
1810 dst
[i
][ACOMP
] = 1.0F
;
1815 unpack_SIGNED_RGB_16(const void *src
, GLfloat dst
[][4], GLuint n
)
1817 const GLshort
*s
= (const GLshort
*) src
;
1819 for (i
= 0; i
< n
; i
++) {
1820 dst
[i
][RCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*3+0] );
1821 dst
[i
][GCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*3+1] );
1822 dst
[i
][BCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*3+2] );
1823 dst
[i
][ACOMP
] = 1.0F
;
1828 unpack_SIGNED_RGBA_16(const void *src
, GLfloat dst
[][4], GLuint n
)
1830 const GLshort
*s
= (const GLshort
*) src
;
1832 for (i
= 0; i
< n
; i
++) {
1833 dst
[i
][RCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+0] );
1834 dst
[i
][GCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+1] );
1835 dst
[i
][BCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+2] );
1836 dst
[i
][ACOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+3] );
1841 unpack_RGBA_16(const void *src
, GLfloat dst
[][4], GLuint n
)
1843 const GLushort
*s
= (const GLushort
*) src
;
1845 for (i
= 0; i
< n
; i
++) {
1846 dst
[i
][RCOMP
] = USHORT_TO_FLOAT( s
[i
*4+0] );
1847 dst
[i
][GCOMP
] = USHORT_TO_FLOAT( s
[i
*4+1] );
1848 dst
[i
][BCOMP
] = USHORT_TO_FLOAT( s
[i
*4+2] );
1849 dst
[i
][ACOMP
] = USHORT_TO_FLOAT( s
[i
*4+3] );
1854 unpack_RED_RGTC1(const void *src
, GLfloat dst
[][4], GLuint n
)
1860 unpack_SIGNED_RED_RGTC1(const void *src
, GLfloat dst
[][4], GLuint n
)
1866 unpack_RG_RGTC2(const void *src
, GLfloat dst
[][4], GLuint n
)
1872 unpack_SIGNED_RG_RGTC2(const void *src
, GLfloat dst
[][4], GLuint n
)
1878 unpack_L_LATC1(const void *src
, GLfloat dst
[][4], GLuint n
)
1884 unpack_SIGNED_L_LATC1(const void *src
, GLfloat dst
[][4], GLuint n
)
1890 unpack_LA_LATC2(const void *src
, GLfloat dst
[][4], GLuint n
)
1896 unpack_SIGNED_LA_LATC2(const void *src
, GLfloat dst
[][4], GLuint n
)
1902 unpack_ETC1_RGB8(const void *src
, GLfloat dst
[][4], GLuint n
)
1908 unpack_ETC2_RGB8(const void *src
, GLfloat dst
[][4], GLuint n
)
1914 unpack_ETC2_SRGB8(const void *src
, GLfloat dst
[][4], GLuint n
)
1920 unpack_ETC2_RGBA8_EAC(const void *src
, GLfloat dst
[][4], GLuint n
)
1926 unpack_ETC2_SRGB8_ALPHA8_EAC(const void *src
, GLfloat dst
[][4], GLuint n
)
1932 unpack_ETC2_R11_EAC(const void *src
, GLfloat dst
[][4], GLuint n
)
1938 unpack_ETC2_RG11_EAC(const void *src
, GLfloat dst
[][4], GLuint n
)
1944 unpack_ETC2_SIGNED_R11_EAC(const void *src
, GLfloat dst
[][4], GLuint n
)
1950 unpack_ETC2_SIGNED_RG11_EAC(const void *src
, GLfloat dst
[][4], GLuint n
)
1956 unpack_ETC2_RGB8_PUNCHTHROUGH_ALPHA1(const void *src
, GLfloat dst
[][4],
1963 unpack_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1(const void *src
, GLfloat dst
[][4],
1970 unpack_SIGNED_A_UNORM8(const void *src
, GLfloat dst
[][4], GLuint n
)
1972 const GLbyte
*s
= ((const GLbyte
*) src
);
1974 for (i
= 0; i
< n
; i
++) {
1975 dst
[i
][RCOMP
] = 0.0F
;
1976 dst
[i
][GCOMP
] = 0.0F
;
1977 dst
[i
][BCOMP
] = 0.0F
;
1978 dst
[i
][ACOMP
] = BYTE_TO_FLOAT_TEX( s
[i
] );
1983 unpack_SIGNED_L_UNORM8(const void *src
, GLfloat dst
[][4], GLuint n
)
1985 const GLbyte
*s
= ((const GLbyte
*) src
);
1987 for (i
= 0; i
< n
; i
++) {
1990 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( s
[i
] );
1991 dst
[i
][ACOMP
] = 1.0F
;
1996 unpack_SIGNED_L8A8_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
1998 const GLshort
*s
= ((const GLshort
*) src
);
2000 for (i
= 0; i
< n
; i
++) {
2003 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] & 0xff) );
2004 dst
[i
][ACOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
2009 unpack_SIGNED_I_UNORM8(const void *src
, GLfloat dst
[][4], GLuint n
)
2011 const GLbyte
*s
= ((const GLbyte
*) src
);
2013 for (i
= 0; i
< n
; i
++) {
2017 dst
[i
][ACOMP
] = BYTE_TO_FLOAT_TEX( s
[i
] );
2022 unpack_SIGNED_A_UNORM16(const void *src
, GLfloat dst
[][4], GLuint n
)
2024 const GLshort
*s
= ((const GLshort
*) src
);
2026 for (i
= 0; i
< n
; i
++) {
2027 dst
[i
][RCOMP
] = 0.0F
;
2028 dst
[i
][GCOMP
] = 0.0F
;
2029 dst
[i
][BCOMP
] = 0.0F
;
2030 dst
[i
][ACOMP
] = SHORT_TO_FLOAT_TEX( s
[i
] );
2035 unpack_SIGNED_L_UNORM16(const void *src
, GLfloat dst
[][4], GLuint n
)
2037 const GLshort
*s
= ((const GLshort
*) src
);
2039 for (i
= 0; i
< n
; i
++) {
2042 dst
[i
][BCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
] );
2043 dst
[i
][ACOMP
] = 1.0F
;
2048 unpack_SIGNED_L16A16_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
2050 const GLshort
*s
= (const GLshort
*) src
;
2052 for (i
= 0; i
< n
; i
++) {
2055 dst
[i
][BCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*2+0] );
2056 dst
[i
][ACOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*2+1] );
2061 unpack_SIGNED_I_UNORM16(const void *src
, GLfloat dst
[][4], GLuint n
)
2063 const GLshort
*s
= ((const GLshort
*) src
);
2065 for (i
= 0; i
< n
; i
++) {
2069 dst
[i
][ACOMP
] = SHORT_TO_FLOAT_TEX( s
[i
] );
2074 unpack_R9G9B9E5_FLOAT(const void *src
, GLfloat dst
[][4], GLuint n
)
2076 const GLuint
*s
= (const GLuint
*) src
;
2078 for (i
= 0; i
< n
; i
++) {
2079 rgb9e5_to_float3(s
[i
], dst
[i
]);
2080 dst
[i
][ACOMP
] = 1.0F
;
2085 unpack_R11G11B10_FLOAT(const void *src
, GLfloat dst
[][4], GLuint n
)
2087 const GLuint
*s
= (const GLuint
*) src
;
2089 for (i
= 0; i
< n
; i
++) {
2090 r11g11b10f_to_float3(s
[i
], dst
[i
]);
2091 dst
[i
][ACOMP
] = 1.0F
;
2096 unpack_XRGB4444_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
2098 const GLushort
*s
= ((const GLushort
*) src
);
2100 for (i
= 0; i
< n
; i
++) {
2101 dst
[i
][RCOMP
] = ((s
[i
] >> 8) & 0xf) * (1.0F
/ 15.0F
);
2102 dst
[i
][GCOMP
] = ((s
[i
] >> 4) & 0xf) * (1.0F
/ 15.0F
);
2103 dst
[i
][BCOMP
] = ((s
[i
] ) & 0xf) * (1.0F
/ 15.0F
);
2104 dst
[i
][ACOMP
] = 1.0;
2109 unpack_XRGB1555_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
2111 const GLushort
*s
= ((const GLushort
*) src
);
2113 for (i
= 0; i
< n
; i
++) {
2114 dst
[i
][RCOMP
] = ((s
[i
] >> 10) & 0x1f) * (1.0F
/ 31.0F
);
2115 dst
[i
][GCOMP
] = ((s
[i
] >> 5) & 0x1f) * (1.0F
/ 31.0F
);
2116 dst
[i
][BCOMP
] = ((s
[i
] >> 0) & 0x1f) * (1.0F
/ 31.0F
);
2117 dst
[i
][ACOMP
] = 1.0;
2122 unpack_XBGR8888_SNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
2124 const GLuint
*s
= ((const GLuint
*) src
);
2126 for (i
= 0; i
< n
; i
++) {
2127 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] ) );
2128 dst
[i
][GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
2129 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 16) );
2130 dst
[i
][ACOMP
] = 1.0;
2135 unpack_R8G8B8X8_SRGB(const void *src
, GLfloat dst
[][4], GLuint n
)
2137 const GLuint
*s
= ((const GLuint
*) src
);
2139 for (i
= 0; i
< n
; i
++) {
2140 dst
[i
][RCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] ) & 0xff );
2141 dst
[i
][GCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] >> 8) & 0xff );
2142 dst
[i
][BCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] >> 16) & 0xff );
2143 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 24 ); /* linear! */
2148 unpack_XBGR8888_UINT(const void *src
, GLfloat dst
[][4], GLuint n
)
2150 const GLbyte
*s
= (const GLbyte
*) src
;
2152 for (i
= 0; i
< n
; i
++) {
2153 dst
[i
][RCOMP
] = s
[i
*4+0];
2154 dst
[i
][GCOMP
] = s
[i
*4+1];
2155 dst
[i
][BCOMP
] = s
[i
*4+2];
2156 dst
[i
][ACOMP
] = 1.0;
2161 unpack_XBGR8888_SINT(const void *src
, GLfloat dst
[][4], GLuint n
)
2163 const GLbyte
*s
= (const GLbyte
*) src
;
2165 for (i
= 0; i
< n
; i
++) {
2166 dst
[i
][RCOMP
] = s
[i
*4+0];
2167 dst
[i
][GCOMP
] = s
[i
*4+1];
2168 dst
[i
][BCOMP
] = s
[i
*4+2];
2169 dst
[i
][ACOMP
] = 1.0;
2174 unpack_B10G10R10X2_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
2176 const GLuint
*s
= ((const GLuint
*) src
);
2178 for (i
= 0; i
< n
; i
++) {
2179 dst
[i
][RCOMP
] = ((s
[i
] >> 20) & 0x3ff) * (1.0F
/ 1023.0F
);
2180 dst
[i
][GCOMP
] = ((s
[i
] >> 10) & 0x3ff) * (1.0F
/ 1023.0F
);
2181 dst
[i
][BCOMP
] = ((s
[i
] >> 0) & 0x3ff) * (1.0F
/ 1023.0F
);
2182 dst
[i
][ACOMP
] = 1.0;
2187 unpack_RGBX_UNORM16(const void *src
, GLfloat dst
[][4], GLuint n
)
2189 const GLushort
*s
= (const GLushort
*) src
;
2191 for (i
= 0; i
< n
; i
++) {
2192 dst
[i
][RCOMP
] = USHORT_TO_FLOAT( s
[i
*4+0] );
2193 dst
[i
][GCOMP
] = USHORT_TO_FLOAT( s
[i
*4+1] );
2194 dst
[i
][BCOMP
] = USHORT_TO_FLOAT( s
[i
*4+2] );
2195 dst
[i
][ACOMP
] = 1.0;
2200 unpack_XBGR16161616_SNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
2202 const GLshort
*s
= (const GLshort
*) src
;
2204 for (i
= 0; i
< n
; i
++) {
2205 dst
[i
][RCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+0] );
2206 dst
[i
][GCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+1] );
2207 dst
[i
][BCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+2] );
2208 dst
[i
][ACOMP
] = 1.0;
2213 unpack_XBGR16161616_FLOAT(const void *src
, GLfloat dst
[][4], GLuint n
)
2215 const GLshort
*s
= (const GLshort
*) src
;
2217 for (i
= 0; i
< n
; i
++) {
2218 dst
[i
][RCOMP
] = _mesa_half_to_float(s
[i
*4+0]);
2219 dst
[i
][GCOMP
] = _mesa_half_to_float(s
[i
*4+1]);
2220 dst
[i
][BCOMP
] = _mesa_half_to_float(s
[i
*4+2]);
2221 dst
[i
][ACOMP
] = 1.0;
2226 unpack_XBGR16161616_UINT(const void *src
, GLfloat dst
[][4], GLuint n
)
2228 const GLushort
*s
= (const GLushort
*) src
;
2230 for (i
= 0; i
< n
; i
++) {
2231 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
2232 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
2233 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
2234 dst
[i
][ACOMP
] = 1.0;
2239 unpack_XBGR16161616_SINT(const void *src
, GLfloat dst
[][4], GLuint n
)
2241 const GLshort
*s
= (const GLshort
*) src
;
2243 for (i
= 0; i
< n
; i
++) {
2244 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
2245 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
2246 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
2247 dst
[i
][ACOMP
] = 1.0;
2252 unpack_RGBX_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
2254 const GLfloat
*s
= (const GLfloat
*) src
;
2256 for (i
= 0; i
< n
; i
++) {
2257 dst
[i
][RCOMP
] = s
[i
*4+0];
2258 dst
[i
][GCOMP
] = s
[i
*4+1];
2259 dst
[i
][BCOMP
] = s
[i
*4+2];
2260 dst
[i
][ACOMP
] = 1.0;
2265 unpack_XBGR32323232_UINT(const void *src
, GLfloat dst
[][4], GLuint n
)
2267 const GLuint
*s
= (const GLuint
*) src
;
2269 for (i
= 0; i
< n
; i
++) {
2270 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
2271 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
2272 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
2273 dst
[i
][ACOMP
] = 1.0;
2278 unpack_XBGR32323232_SINT(const void *src
, GLfloat dst
[][4], GLuint n
)
2280 const GLint
*s
= (const GLint
*) src
;
2282 for (i
= 0; i
< n
; i
++) {
2283 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
2284 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
2285 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
2286 dst
[i
][ACOMP
] = 1.0;
2291 unpack_R10G10B10A2_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
2293 const GLuint
*s
= ((const GLuint
*) src
);
2295 for (i
= 0; i
< n
; i
++) {
2296 dst
[i
][RCOMP
] = ((s
[i
] >> 0) & 0x3ff) * (1.0F
/ 1023.0F
);
2297 dst
[i
][GCOMP
] = ((s
[i
] >> 10) & 0x3ff) * (1.0F
/ 1023.0F
);
2298 dst
[i
][BCOMP
] = ((s
[i
] >> 20) & 0x3ff) * (1.0F
/ 1023.0F
);
2299 dst
[i
][ACOMP
] = ((s
[i
] >> 30) & 0x03) * (1.0F
/ 3.0F
);
2304 unpack_SIGNED_G8R8_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
2306 const GLushort
*s
= ((const GLushort
*) src
);
2308 for (i
= 0; i
< n
; i
++) {
2309 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
2310 dst
[i
][GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] & 0xff) );
2311 dst
[i
][BCOMP
] = 0.0F
;
2312 dst
[i
][ACOMP
] = 1.0F
;
2317 unpack_SIGNED_G16R16_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
2319 const GLuint
*s
= ((const GLuint
*) src
);
2321 for (i
= 0; i
< n
; i
++) {
2322 dst
[i
][RCOMP
] = SHORT_TO_FLOAT_TEX( (GLshort
) (s
[i
] >> 16) );
2323 dst
[i
][GCOMP
] = SHORT_TO_FLOAT_TEX( (GLshort
) (s
[i
] & 0xffff) );
2324 dst
[i
][BCOMP
] = 0.0F
;
2325 dst
[i
][ACOMP
] = 1.0F
;
2330 unpack_B8G8R8X8_SRGB(const void *src
, GLfloat dst
[][4], GLuint n
)
2332 const GLuint
*s
= ((const GLuint
*) src
);
2334 for (i
= 0; i
< n
; i
++) {
2335 dst
[i
][RCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] >> 16) & 0xff );
2336 dst
[i
][GCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] >> 8) & 0xff );
2337 dst
[i
][BCOMP
] = _mesa_nonlinear_to_linear( (s
[i
] ) & 0xff );
2338 dst
[i
][ACOMP
] = 1.0F
;
2343 * Return the unpacker function for the given format.
2345 static unpack_rgba_func
2346 get_unpack_rgba_function(mesa_format format
)
2348 static unpack_rgba_func table
[MESA_FORMAT_COUNT
];
2349 static GLboolean initialized
= GL_FALSE
;
2352 table
[MESA_FORMAT_NONE
] = NULL
;
2354 table
[MESA_FORMAT_A8B8G8R8_UNORM
] = unpack_A8B8G8R8_UNORM
;
2355 table
[MESA_FORMAT_R8G8B8A8_UNORM
] = unpack_R8G8B8A8_UNORM
;
2356 table
[MESA_FORMAT_B8G8R8A8_UNORM
] = unpack_B8G8R8A8_UNORM
;
2357 table
[MESA_FORMAT_A8R8G8B8_UNORM
] = unpack_A8R8G8B8_UNORM
;
2358 table
[MESA_FORMAT_X8B8G8R8_UNORM
] = unpack_RGBX8888
;
2359 table
[MESA_FORMAT_R8G8B8X8_UNORM
] = unpack_RGBX8888_REV
;
2360 table
[MESA_FORMAT_B8G8R8X8_UNORM
] = unpack_B8G8R8X8_UNORM
;
2361 table
[MESA_FORMAT_X8R8G8B8_UNORM
] = unpack_X8R8G8B8_UNORM
;
2362 table
[MESA_FORMAT_BGR_UNORM8
] = unpack_BGR_UNORM8
;
2363 table
[MESA_FORMAT_RGB_UNORM8
] = unpack_RGB_UNORM8
;
2364 table
[MESA_FORMAT_B5G6R5_UNORM
] = unpack_B5G6R5_UNORM
;
2365 table
[MESA_FORMAT_R5G6B5_UNORM
] = unpack_R5G6B5_UNORM
;
2366 table
[MESA_FORMAT_B4G4R4A4_UNORM
] = unpack_B4G4R4A4_UNORM
;
2367 table
[MESA_FORMAT_A4R4G4B4_UNORM
] = unpack_A4R4G4B4_UNORM
;
2368 table
[MESA_FORMAT_A1B5G5R5_UNORM
] = unpack_A1B5G5R5_UNORM
;
2369 table
[MESA_FORMAT_B5G5R5A1_UNORM
] = unpack_B5G5R5A1_UNORM
;
2370 table
[MESA_FORMAT_A1R5G5B5_UNORM
] = unpack_A1R5G5B5_UNORM
;
2371 table
[MESA_FORMAT_L4A4_UNORM
] = unpack_L4A4_UNORM
;
2372 table
[MESA_FORMAT_L8A8_UNORM
] = unpack_L8A8_UNORM
;
2373 table
[MESA_FORMAT_A8L8_UNORM
] = unpack_A8L8_UNORM
;
2374 table
[MESA_FORMAT_L16A16_UNORM
] = unpack_L16A16_UNORM
;
2375 table
[MESA_FORMAT_A16L16_UNORM
] = unpack_A16L16_UNORM
;
2376 table
[MESA_FORMAT_B2G3R3_UNORM
] = unpack_B2G3R3_UNORM
;
2377 table
[MESA_FORMAT_A_UNORM8
] = unpack_A_UNORM8
;
2378 table
[MESA_FORMAT_A_UNORM16
] = unpack_A_UNORM16
;
2379 table
[MESA_FORMAT_L_UNORM8
] = unpack_L_UNORM8
;
2380 table
[MESA_FORMAT_L_UNORM16
] = unpack_L_UNORM16
;
2381 table
[MESA_FORMAT_I_UNORM8
] = unpack_I_UNORM8
;
2382 table
[MESA_FORMAT_I_UNORM16
] = unpack_I_UNORM16
;
2383 table
[MESA_FORMAT_YCBCR
] = unpack_YCBCR
;
2384 table
[MESA_FORMAT_YCBCR_REV
] = unpack_YCBCR_REV
;
2385 table
[MESA_FORMAT_R_UNORM8
] = unpack_R_UNORM8
;
2386 table
[MESA_FORMAT_R8G8_UNORM
] = unpack_R8G8_UNORM
;
2387 table
[MESA_FORMAT_G8R8_UNORM
] = unpack_G8R8_UNORM
;
2388 table
[MESA_FORMAT_R_UNORM16
] = unpack_R_UNORM16
;
2389 table
[MESA_FORMAT_R16G16_UNORM
] = unpack_R16G16_UNORM
;
2390 table
[MESA_FORMAT_G16R16_UNORM
] = unpack_G16R16_UNORM
;
2391 table
[MESA_FORMAT_B10G10R10A2_UNORM
] = unpack_B10G10R10A2_UNORM
;
2392 table
[MESA_FORMAT_B10G10R10A2_UINT
] = unpack_ARGB2101010_UINT
;
2393 table
[MESA_FORMAT_R10G10B10A2_UINT
] = unpack_ABGR2101010_UINT
;
2394 table
[MESA_FORMAT_S8_UINT_Z24_UNORM
] = unpack_Z24_S8
;
2395 table
[MESA_FORMAT_Z24_UNORM_S8_UINT
] = unpack_S8_Z24
;
2396 table
[MESA_FORMAT_Z_UNORM16
] = unpack_Z16
;
2397 table
[MESA_FORMAT_Z24_UNORM_X8_UINT
] = unpack_X8_Z24
;
2398 table
[MESA_FORMAT_X8_UINT_Z24_UNORM
] = unpack_Z24_X8
;
2399 table
[MESA_FORMAT_Z_UNORM32
] = unpack_Z32
;
2400 table
[MESA_FORMAT_S_UINT8
] = unpack_S8
;
2401 table
[MESA_FORMAT_BGR_SRGB8
] = unpack_BGR_SRGB8
;
2402 table
[MESA_FORMAT_A8B8G8R8_SRGB
] = unpack_A8B8G8R8_SRGB
;
2403 table
[MESA_FORMAT_B8G8R8A8_SRGB
] = unpack_B8G8R8A8_SRGB
;
2404 table
[MESA_FORMAT_R8G8B8A8_SRGB
] = unpack_R8G8B8A8_SRGB
;
2405 table
[MESA_FORMAT_L_SRGB8
] = unpack_L_SRGB8
;
2406 table
[MESA_FORMAT_L8A8_SRGB
] = unpack_L8A8_SRGB
;
2407 table
[MESA_FORMAT_SRGB_DXT1
] = unpack_SRGB_DXT1
;
2408 table
[MESA_FORMAT_SRGBA_DXT1
] = unpack_SRGBA_DXT1
;
2409 table
[MESA_FORMAT_SRGBA_DXT3
] = unpack_SRGBA_DXT3
;
2410 table
[MESA_FORMAT_SRGBA_DXT5
] = unpack_SRGBA_DXT5
;
2412 table
[MESA_FORMAT_RGB_FXT1
] = unpack_RGB_FXT1
;
2413 table
[MESA_FORMAT_RGBA_FXT1
] = unpack_RGBA_FXT1
;
2414 table
[MESA_FORMAT_RGB_DXT1
] = unpack_RGB_DXT1
;
2415 table
[MESA_FORMAT_RGBA_DXT1
] = unpack_RGBA_DXT1
;
2416 table
[MESA_FORMAT_RGBA_DXT3
] = unpack_RGBA_DXT3
;
2417 table
[MESA_FORMAT_RGBA_DXT5
] = unpack_RGBA_DXT5
;
2419 table
[MESA_FORMAT_RGBA_FLOAT32
] = unpack_RGBA_FLOAT32
;
2420 table
[MESA_FORMAT_RGBA_FLOAT16
] = unpack_RGBA_FLOAT16
;
2421 table
[MESA_FORMAT_RGB_FLOAT32
] = unpack_RGB_FLOAT32
;
2422 table
[MESA_FORMAT_RGB_FLOAT16
] = unpack_RGB_FLOAT16
;
2423 table
[MESA_FORMAT_A_FLOAT32
] = unpack_A_FLOAT32
;
2424 table
[MESA_FORMAT_A_FLOAT16
] = unpack_A_FLOAT16
;
2425 table
[MESA_FORMAT_L_FLOAT32
] = unpack_L_FLOAT32
;
2426 table
[MESA_FORMAT_L_FLOAT16
] = unpack_L_FLOAT16
;
2427 table
[MESA_FORMAT_LA_FLOAT32
] = unpack_LA_FLOAT32
;
2428 table
[MESA_FORMAT_LA_FLOAT16
] = unpack_LA_FLOAT16
;
2429 table
[MESA_FORMAT_I_FLOAT32
] = unpack_I_FLOAT32
;
2430 table
[MESA_FORMAT_I_FLOAT16
] = unpack_I_FLOAT16
;
2431 table
[MESA_FORMAT_R_FLOAT32
] = unpack_R_FLOAT32
;
2432 table
[MESA_FORMAT_R_FLOAT16
] = unpack_R_FLOAT16
;
2433 table
[MESA_FORMAT_RG_FLOAT32
] = unpack_RG_FLOAT32
;
2434 table
[MESA_FORMAT_RG_FLOAT16
] = unpack_RG_FLOAT16
;
2436 table
[MESA_FORMAT_A_UINT8
] = unpack_ALPHA_UINT8
;
2437 table
[MESA_FORMAT_A_UINT16
] = unpack_ALPHA_UINT16
;
2438 table
[MESA_FORMAT_A_UINT32
] = unpack_ALPHA_UINT32
;
2439 table
[MESA_FORMAT_A_SINT8
] = unpack_ALPHA_INT8
;
2440 table
[MESA_FORMAT_A_SINT16
] = unpack_ALPHA_INT16
;
2441 table
[MESA_FORMAT_A_SINT32
] = unpack_ALPHA_INT32
;
2443 table
[MESA_FORMAT_I_UINT8
] = unpack_INTENSITY_UINT8
;
2444 table
[MESA_FORMAT_I_UINT16
] = unpack_INTENSITY_UINT16
;
2445 table
[MESA_FORMAT_I_UINT32
] = unpack_INTENSITY_UINT32
;
2446 table
[MESA_FORMAT_I_SINT8
] = unpack_INTENSITY_INT8
;
2447 table
[MESA_FORMAT_I_SINT16
] = unpack_INTENSITY_INT16
;
2448 table
[MESA_FORMAT_I_SINT32
] = unpack_INTENSITY_INT32
;
2450 table
[MESA_FORMAT_L_UINT8
] = unpack_LUMINANCE_UINT8
;
2451 table
[MESA_FORMAT_L_UINT16
] = unpack_LUMINANCE_UINT16
;
2452 table
[MESA_FORMAT_L_UINT32
] = unpack_LUMINANCE_UINT32
;
2453 table
[MESA_FORMAT_L_SINT8
] = unpack_LUMINANCE_INT8
;
2454 table
[MESA_FORMAT_L_SINT16
] = unpack_LUMINANCE_INT16
;
2455 table
[MESA_FORMAT_L_SINT32
] = unpack_LUMINANCE_INT32
;
2457 table
[MESA_FORMAT_LA_UINT8
] = unpack_LUMINANCE_ALPHA_UINT8
;
2458 table
[MESA_FORMAT_LA_UINT16
] = unpack_LUMINANCE_ALPHA_UINT16
;
2459 table
[MESA_FORMAT_LA_UINT32
] = unpack_LUMINANCE_ALPHA_UINT32
;
2460 table
[MESA_FORMAT_LA_SINT8
] = unpack_LUMINANCE_ALPHA_INT8
;
2461 table
[MESA_FORMAT_LA_SINT16
] = unpack_LUMINANCE_ALPHA_INT16
;
2462 table
[MESA_FORMAT_LA_SINT32
] = unpack_LUMINANCE_ALPHA_INT32
;
2464 table
[MESA_FORMAT_R_SINT8
] = unpack_R_INT8
;
2465 table
[MESA_FORMAT_RG_SINT8
] = unpack_RG_INT8
;
2466 table
[MESA_FORMAT_RGB_SINT8
] = unpack_RGB_INT8
;
2467 table
[MESA_FORMAT_RGBA_SINT8
] = unpack_RGBA_INT8
;
2468 table
[MESA_FORMAT_R_SINT16
] = unpack_R_INT16
;
2469 table
[MESA_FORMAT_RG_SINT16
] = unpack_RG_INT16
;
2470 table
[MESA_FORMAT_RGB_SINT16
] = unpack_RGB_INT16
;
2471 table
[MESA_FORMAT_RGBA_SINT16
] = unpack_RGBA_INT16
;
2472 table
[MESA_FORMAT_R_SINT32
] = unpack_R_INT32
;
2473 table
[MESA_FORMAT_RG_SINT32
] = unpack_RG_INT32
;
2474 table
[MESA_FORMAT_RGB_SINT32
] = unpack_RGB_INT32
;
2475 table
[MESA_FORMAT_RGBA_SINT32
] = unpack_RGBA_INT32
;
2476 table
[MESA_FORMAT_R_UINT8
] = unpack_R_UINT8
;
2477 table
[MESA_FORMAT_RG_UINT8
] = unpack_RG_UINT8
;
2478 table
[MESA_FORMAT_RGB_UINT8
] = unpack_RGB_UINT8
;
2479 table
[MESA_FORMAT_RGBA_UINT8
] = unpack_RGBA_UINT8
;
2480 table
[MESA_FORMAT_R_UINT16
] = unpack_R_UINT16
;
2481 table
[MESA_FORMAT_RG_UINT16
] = unpack_RG_UINT16
;
2482 table
[MESA_FORMAT_RGB_UINT16
] = unpack_RGB_UINT16
;
2483 table
[MESA_FORMAT_RGBA_UINT16
] = unpack_RGBA_UINT16
;
2484 table
[MESA_FORMAT_R_UINT32
] = unpack_R_UINT32
;
2485 table
[MESA_FORMAT_RG_UINT32
] = unpack_RG_UINT32
;
2486 table
[MESA_FORMAT_RGB_UINT32
] = unpack_RGB_UINT32
;
2487 table
[MESA_FORMAT_RGBA_UINT32
] = unpack_RGBA_UINT32
;
2489 table
[MESA_FORMAT_DUDV8
] = unpack_DUDV8
;
2490 table
[MESA_FORMAT_R_SNORM8
] = unpack_SIGNED_R_UNORM8
;
2491 table
[MESA_FORMAT_R8G8_SNORM
] = unpack_SIGNED_RG88_REV
;
2492 table
[MESA_FORMAT_X8B8G8R8_SNORM
] = unpack_SIGNED_RGBX8888
;
2493 table
[MESA_FORMAT_A8B8G8R8_SNORM
] = unpack_SIGNED_A8B8G8R8_UNORM
;
2494 table
[MESA_FORMAT_R8G8B8A8_SNORM
] = unpack_SIGNED_R8G8B8A8_UNORM
;
2495 table
[MESA_FORMAT_R_SNORM16
] = unpack_SIGNED_R_UNORM16
;
2496 table
[MESA_FORMAT_R16G16_SNORM
] = unpack_SIGNED_R16G16_UNORM
;
2497 table
[MESA_FORMAT_RGB_SNORM16
] = unpack_SIGNED_RGB_16
;
2498 table
[MESA_FORMAT_RGBA_SNORM16
] = unpack_SIGNED_RGBA_16
;
2499 table
[MESA_FORMAT_RGBA_UNORM16
] = unpack_RGBA_16
;
2501 table
[MESA_FORMAT_R_RGTC1_UNORM
] = unpack_RED_RGTC1
;
2502 table
[MESA_FORMAT_R_RGTC1_SNORM
] = unpack_SIGNED_RED_RGTC1
;
2503 table
[MESA_FORMAT_RG_RGTC2_UNORM
] = unpack_RG_RGTC2
;
2504 table
[MESA_FORMAT_RG_RGTC2_SNORM
] = unpack_SIGNED_RG_RGTC2
;
2506 table
[MESA_FORMAT_L_LATC1_UNORM
] = unpack_L_LATC1
;
2507 table
[MESA_FORMAT_L_LATC1_SNORM
] = unpack_SIGNED_L_LATC1
;
2508 table
[MESA_FORMAT_LA_LATC2_UNORM
] = unpack_LA_LATC2
;
2509 table
[MESA_FORMAT_LA_LATC2_SNORM
] = unpack_SIGNED_LA_LATC2
;
2511 table
[MESA_FORMAT_ETC1_RGB8
] = unpack_ETC1_RGB8
;
2512 table
[MESA_FORMAT_ETC2_RGB8
] = unpack_ETC2_RGB8
;
2513 table
[MESA_FORMAT_ETC2_SRGB8
] = unpack_ETC2_SRGB8
;
2514 table
[MESA_FORMAT_ETC2_RGBA8_EAC
] = unpack_ETC2_RGBA8_EAC
;
2515 table
[MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC
] = unpack_ETC2_SRGB8_ALPHA8_EAC
;
2516 table
[MESA_FORMAT_ETC2_R11_EAC
] = unpack_ETC2_R11_EAC
;
2517 table
[MESA_FORMAT_ETC2_RG11_EAC
] = unpack_ETC2_RG11_EAC
;
2518 table
[MESA_FORMAT_ETC2_SIGNED_R11_EAC
] = unpack_ETC2_SIGNED_R11_EAC
;
2519 table
[MESA_FORMAT_ETC2_SIGNED_RG11_EAC
] = unpack_ETC2_SIGNED_RG11_EAC
;
2520 table
[MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1
] =
2521 unpack_ETC2_RGB8_PUNCHTHROUGH_ALPHA1
;
2522 table
[MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
] =
2523 unpack_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
;
2524 table
[MESA_FORMAT_A_SNORM8
] = unpack_A_SNORM8
;
2525 table
[MESA_FORMAT_L_SNORM8
] = unpack_L_SNORM8
;
2526 table
[MESA_FORMAT_L8A8_SNORM
] = unpack_L8A8_SNORM
;
2527 table
[MESA_FORMAT_I_SNORM8
] = unpack_SIGNED_I_UNORM8
;
2528 table
[MESA_FORMAT_A_SNORM16
] = unpack_A_SNORM16
;
2529 table
[MESA_FORMAT_L_SNORM16
] = unpack_L_SNORM16
;
2530 table
[MESA_FORMAT_LA_SNORM16
] = unpack_LA_SNORM16
;
2531 table
[MESA_FORMAT_I_SNORM16
] = unpack_SIGNED_I_UNORM16
;
2533 table
[MESA_FORMAT_R9G9B9E5_FLOAT
] = unpack_R9G9B9E5_FLOAT
;
2534 table
[MESA_FORMAT_R11G11B10_FLOAT
] = unpack_R11G11B10_FLOAT
;
2536 table
[MESA_FORMAT_Z_FLOAT32
] = unpack_Z32_FLOAT
;
2537 table
[MESA_FORMAT_Z32_FLOAT_S8X24_UINT
] = unpack_Z32_FLOAT_X24S8
;
2539 table
[MESA_FORMAT_B4G4R4X4_UNORM
] = unpack_XRGB4444_UNORM
;
2540 table
[MESA_FORMAT_B5G5R5X1_UNORM
] = unpack_XRGB1555_UNORM
;
2541 table
[MESA_FORMAT_R8G8B8X8_SNORM
] = unpack_XBGR8888_SNORM
;
2542 table
[MESA_FORMAT_R8G8B8X8_SRGB
] = unpack_R8G8B8X8_SRGB
;
2543 table
[MESA_FORMAT_RGBX_UINT8
] = unpack_XBGR8888_UINT
;
2544 table
[MESA_FORMAT_RGBX_SINT8
] = unpack_XBGR8888_SINT
;
2545 table
[MESA_FORMAT_B10G10R10X2_UNORM
] = unpack_B10G10R10X2_UNORM
;
2546 table
[MESA_FORMAT_RGBX_UNORM16
] = unpack_RGBX_UNORM16
;
2547 table
[MESA_FORMAT_RGBX_SNORM16
] = unpack_XBGR16161616_SNORM
;
2548 table
[MESA_FORMAT_RGBX_FLOAT16
] = unpack_XBGR16161616_FLOAT
;
2549 table
[MESA_FORMAT_RGBX_UINT16
] = unpack_XBGR16161616_UINT
;
2550 table
[MESA_FORMAT_RGBX_SINT16
] = unpack_XBGR16161616_SINT
;
2551 table
[MESA_FORMAT_RGBX_FLOAT32
] = unpack_RGBX_FLOAT32
;
2552 table
[MESA_FORMAT_RGBX_UINT32
] = unpack_XBGR32323232_UINT
;
2553 table
[MESA_FORMAT_RGBX_SINT32
] = unpack_XBGR32323232_SINT
;
2555 table
[MESA_FORMAT_R10G10B10A2_UNORM
] = unpack_R10G10B10A2_UNORM
;
2557 table
[MESA_FORMAT_G8R8_SNORM
] = unpack_SIGNED_G8R8_UNORM
;
2558 table
[MESA_FORMAT_G16R16_SNORM
] = unpack_SIGNED_G16R16_UNORM
;
2560 table
[MESA_FORMAT_B8G8R8X8_SRGB
] = unpack_B8G8R8X8_SRGB
;
2562 initialized
= GL_TRUE
;
2565 if (table
[format
] == NULL
) {
2566 _mesa_problem(NULL
, "unsupported unpack for format %s",
2567 _mesa_get_format_name(format
));
2570 return table
[format
];
2575 * Unpack rgba colors, returning as GLfloat values.
2578 _mesa_unpack_rgba_row(mesa_format format
, GLuint n
,
2579 const void *src
, GLfloat dst
[][4])
2581 unpack_rgba_func unpack
= get_unpack_rgba_function(format
);
2582 unpack(src
, dst
, n
);
2586 /**********************************************************************/
2587 /* Unpack, returning GLubyte colors */
2588 /**********************************************************************/
2592 unpack_ubyte_A8B8G8R8_UNORM(const void *src
, GLubyte dst
[][4], GLuint n
)
2594 const GLuint
*s
= ((const GLuint
*) src
);
2596 for (i
= 0; i
< n
; i
++) {
2597 dst
[i
][RCOMP
] = (s
[i
] >> 24);
2598 dst
[i
][GCOMP
] = (s
[i
] >> 16) & 0xff;
2599 dst
[i
][BCOMP
] = (s
[i
] >> 8) & 0xff;
2600 dst
[i
][ACOMP
] = (s
[i
] ) & 0xff;
2605 unpack_ubyte_R8G8B8A8_UNORM(const void *src
, GLubyte dst
[][4], GLuint n
)
2607 const GLuint
*s
= ((const GLuint
*) src
);
2609 for (i
= 0; i
< n
; i
++) {
2610 dst
[i
][RCOMP
] = (s
[i
] ) & 0xff;
2611 dst
[i
][GCOMP
] = (s
[i
] >> 8) & 0xff;
2612 dst
[i
][BCOMP
] = (s
[i
] >> 16) & 0xff;
2613 dst
[i
][ACOMP
] = (s
[i
] >> 24);
2618 unpack_ubyte_B8G8R8A8_UNORM(const void *src
, GLubyte dst
[][4], GLuint n
)
2620 const GLuint
*s
= ((const GLuint
*) src
);
2622 for (i
= 0; i
< n
; i
++) {
2623 dst
[i
][RCOMP
] = (s
[i
] >> 16) & 0xff;
2624 dst
[i
][GCOMP
] = (s
[i
] >> 8) & 0xff;
2625 dst
[i
][BCOMP
] = (s
[i
] ) & 0xff;
2626 dst
[i
][ACOMP
] = (s
[i
] >> 24);
2631 unpack_ubyte_A8R8G8B8_UNORM(const void *src
, GLubyte dst
[][4], GLuint n
)
2633 const GLuint
*s
= ((const GLuint
*) src
);
2635 for (i
= 0; i
< n
; i
++) {
2636 dst
[i
][RCOMP
] = (s
[i
] >> 8) & 0xff;
2637 dst
[i
][GCOMP
] = (s
[i
] >> 16) & 0xff;
2638 dst
[i
][BCOMP
] = (s
[i
] >> 24);
2639 dst
[i
][ACOMP
] = (s
[i
] ) & 0xff;
2644 unpack_ubyte_RGBX8888(const void *src
, GLubyte dst
[][4], GLuint n
)
2646 const GLuint
*s
= ((const GLuint
*) src
);
2648 for (i
= 0; i
< n
; i
++) {
2649 dst
[i
][RCOMP
] = (s
[i
] >> 24);
2650 dst
[i
][GCOMP
] = (s
[i
] >> 16) & 0xff;
2651 dst
[i
][BCOMP
] = (s
[i
] >> 8) & 0xff;
2652 dst
[i
][ACOMP
] = 0xff;
2657 unpack_ubyte_RGBX8888_REV(const void *src
, GLubyte dst
[][4], GLuint n
)
2659 const GLuint
*s
= ((const GLuint
*) src
);
2661 for (i
= 0; i
< n
; i
++) {
2662 dst
[i
][RCOMP
] = (s
[i
] ) & 0xff;
2663 dst
[i
][GCOMP
] = (s
[i
] >> 8) & 0xff;
2664 dst
[i
][BCOMP
] = (s
[i
] >> 16) & 0xff;
2665 dst
[i
][ACOMP
] = 0xff;
2670 unpack_ubyte_B8G8R8X8_UNORM(const void *src
, GLubyte dst
[][4], GLuint n
)
2672 const GLuint
*s
= ((const GLuint
*) src
);
2674 for (i
= 0; i
< n
; i
++) {
2675 dst
[i
][RCOMP
] = (s
[i
] >> 16) & 0xff;
2676 dst
[i
][GCOMP
] = (s
[i
] >> 8) & 0xff;
2677 dst
[i
][BCOMP
] = (s
[i
] ) & 0xff;
2678 dst
[i
][ACOMP
] = 0xff;
2683 unpack_ubyte_X8R8G8B8_UNORM(const void *src
, GLubyte dst
[][4], GLuint n
)
2685 const GLuint
*s
= ((const GLuint
*) src
);
2687 for (i
= 0; i
< n
; i
++) {
2688 dst
[i
][RCOMP
] = (s
[i
] >> 8) & 0xff;
2689 dst
[i
][GCOMP
] = (s
[i
] >> 16) & 0xff;
2690 dst
[i
][BCOMP
] = (s
[i
] >> 24);
2691 dst
[i
][ACOMP
] = 0xff;
2696 unpack_ubyte_BGR_UNORM8(const void *src
, GLubyte dst
[][4], GLuint n
)
2698 const GLubyte
*s
= (const GLubyte
*) src
;
2700 for (i
= 0; i
< n
; i
++) {
2701 dst
[i
][RCOMP
] = s
[i
*3+2];
2702 dst
[i
][GCOMP
] = s
[i
*3+1];
2703 dst
[i
][BCOMP
] = s
[i
*3+0];
2704 dst
[i
][ACOMP
] = 0xff;
2709 unpack_ubyte_RGB_UNORM8(const void *src
, GLubyte dst
[][4], GLuint n
)
2711 const GLubyte
*s
= (const GLubyte
*) src
;
2713 for (i
= 0; i
< n
; i
++) {
2714 dst
[i
][RCOMP
] = s
[i
*3+0];
2715 dst
[i
][GCOMP
] = s
[i
*3+1];
2716 dst
[i
][BCOMP
] = s
[i
*3+2];
2717 dst
[i
][ACOMP
] = 0xff;
2722 unpack_ubyte_B5G6R5_UNORM(const void *src
, GLubyte dst
[][4], GLuint n
)
2724 const GLushort
*s
= ((const GLushort
*) src
);
2726 for (i
= 0; i
< n
; i
++) {
2727 dst
[i
][RCOMP
] = EXPAND_5_8((s
[i
] >> 11) & 0x1f);
2728 dst
[i
][GCOMP
] = EXPAND_6_8((s
[i
] >> 5 ) & 0x3f);
2729 dst
[i
][BCOMP
] = EXPAND_5_8( s
[i
] & 0x1f);
2730 dst
[i
][ACOMP
] = 0xff;
2735 unpack_ubyte_R5G6B5_UNORM(const void *src
, GLubyte dst
[][4], GLuint n
)
2737 /* Warning: this function does not match the current Mesa definition
2738 * of MESA_FORMAT_R5G6B5_UNORM.
2740 const GLushort
*s
= ((const GLushort
*) src
);
2742 for (i
= 0; i
< n
; i
++) {
2743 GLuint t
= (s
[i
] >> 8) | (s
[i
] << 8); /* byte swap */
2744 dst
[i
][RCOMP
] = EXPAND_5_8((t
>> 11) & 0x1f);
2745 dst
[i
][GCOMP
] = EXPAND_6_8((t
>> 5 ) & 0x3f);
2746 dst
[i
][BCOMP
] = EXPAND_5_8( t
& 0x1f);
2747 dst
[i
][ACOMP
] = 0xff;
2752 unpack_ubyte_B4G4R4A4_UNORM(const void *src
, GLubyte dst
[][4], GLuint n
)
2754 const GLushort
*s
= ((const GLushort
*) src
);
2756 for (i
= 0; i
< n
; i
++) {
2757 dst
[i
][RCOMP
] = EXPAND_4_8((s
[i
] >> 8) & 0xf);
2758 dst
[i
][GCOMP
] = EXPAND_4_8((s
[i
] >> 4) & 0xf);
2759 dst
[i
][BCOMP
] = EXPAND_4_8((s
[i
] ) & 0xf);
2760 dst
[i
][ACOMP
] = EXPAND_4_8((s
[i
] >> 12) & 0xf);
2765 unpack_ubyte_A4R4G4B4_UNORM(const void *src
, GLubyte dst
[][4], GLuint n
)
2767 const GLushort
*s
= ((const GLushort
*) src
);
2769 for (i
= 0; i
< n
; i
++) {
2770 dst
[i
][RCOMP
] = EXPAND_4_8((s
[i
] >> 4) & 0xf);
2771 dst
[i
][GCOMP
] = EXPAND_4_8((s
[i
] >> 8) & 0xf);
2772 dst
[i
][BCOMP
] = EXPAND_4_8((s
[i
] >> 12) & 0xf);
2773 dst
[i
][ACOMP
] = EXPAND_4_8((s
[i
] ) & 0xf);
2778 unpack_ubyte_A1B5G5R5_UNORM(const void *src
, GLubyte dst
[][4], GLuint n
)
2780 const GLushort
*s
= ((const GLushort
*) src
);
2782 for (i
= 0; i
< n
; i
++) {
2783 dst
[i
][RCOMP
] = EXPAND_5_8((s
[i
] >> 11) & 0x1f);
2784 dst
[i
][GCOMP
] = EXPAND_5_8((s
[i
] >> 6) & 0x1f);
2785 dst
[i
][BCOMP
] = EXPAND_5_8((s
[i
] >> 1) & 0x1f);
2786 dst
[i
][ACOMP
] = EXPAND_1_8((s
[i
] ) & 0x01);
2791 unpack_ubyte_B5G5R5A1_UNORM(const void *src
, GLubyte dst
[][4], GLuint n
)
2793 const GLushort
*s
= ((const GLushort
*) src
);
2795 for (i
= 0; i
< n
; i
++) {
2796 dst
[i
][RCOMP
] = EXPAND_5_8((s
[i
] >> 10) & 0x1f);
2797 dst
[i
][GCOMP
] = EXPAND_5_8((s
[i
] >> 5) & 0x1f);
2798 dst
[i
][BCOMP
] = EXPAND_5_8((s
[i
] >> 0) & 0x1f);
2799 dst
[i
][ACOMP
] = EXPAND_1_8((s
[i
] >> 15) & 0x01);
2804 unpack_ubyte_A1R5G5B5_UNORM(const void *src
, GLubyte dst
[][4], GLuint n
)
2806 /* Warning: this function does not match the current Mesa definition
2807 * of MESA_FORMAT_A1R5G5B5_UNORM.
2809 const GLushort
*s
= ((const GLushort
*) src
);
2811 for (i
= 0; i
< n
; i
++) {
2812 GLushort tmp
= (s
[i
] << 8) | (s
[i
] >> 8); /* byteswap */
2813 dst
[i
][RCOMP
] = EXPAND_5_8((tmp
>> 10) & 0x1f);
2814 dst
[i
][GCOMP
] = EXPAND_5_8((tmp
>> 5) & 0x1f);
2815 dst
[i
][BCOMP
] = EXPAND_5_8((tmp
>> 0) & 0x1f);
2816 dst
[i
][ACOMP
] = EXPAND_1_8((tmp
>> 15) & 0x01);
2821 unpack_ubyte_L4A4_UNORM(const void *src
, GLubyte dst
[][4], GLuint n
)
2823 const GLubyte
*s
= ((const GLubyte
*) src
);
2825 for (i
= 0; i
< n
; i
++) {
2828 dst
[i
][BCOMP
] = EXPAND_4_8(s
[i
] & 0xf);
2829 dst
[i
][ACOMP
] = EXPAND_4_8(s
[i
] >> 4);
2834 unpack_ubyte_L8A8_UNORM(const void *src
, GLubyte dst
[][4], GLuint n
)
2836 const GLushort
*s
= ((const GLushort
*) src
);
2838 for (i
= 0; i
< n
; i
++) {
2841 dst
[i
][BCOMP
] = EXPAND_4_8(s
[i
] & 0xff);
2842 dst
[i
][ACOMP
] = EXPAND_4_8(s
[i
] >> 8);
2847 unpack_ubyte_A8L8_UNORM(const void *src
, GLubyte dst
[][4], GLuint n
)
2849 const GLushort
*s
= ((const GLushort
*) src
);
2851 for (i
= 0; i
< n
; i
++) {
2854 dst
[i
][BCOMP
] = EXPAND_4_8(s
[i
] >> 8);
2855 dst
[i
][ACOMP
] = EXPAND_4_8(s
[i
] & 0xff);
2860 unpack_ubyte_B2G3R3_UNORM(const void *src
, GLubyte dst
[][4], GLuint n
)
2862 const GLubyte
*s
= ((const GLubyte
*) src
);
2864 for (i
= 0; i
< n
; i
++) {
2865 dst
[i
][RCOMP
] = EXPAND_3_8((s
[i
] >> 5) & 0x7);
2866 dst
[i
][GCOMP
] = EXPAND_3_8((s
[i
] >> 2) & 0x7);
2867 dst
[i
][BCOMP
] = EXPAND_2_8((s
[i
] ) & 0x3);
2868 dst
[i
][ACOMP
] = 0xff;
2873 unpack_ubyte_A_UNORM8(const void *src
, GLubyte dst
[][4], GLuint n
)
2875 const GLubyte
*s
= ((const GLubyte
*) src
);
2877 for (i
= 0; i
< n
; i
++) {
2881 dst
[i
][ACOMP
] = s
[i
];
2886 unpack_ubyte_L_UNORM8(const void *src
, GLubyte dst
[][4], GLuint n
)
2888 const GLubyte
*s
= ((const GLubyte
*) src
);
2890 for (i
= 0; i
< n
; i
++) {
2893 dst
[i
][BCOMP
] = s
[i
];
2894 dst
[i
][ACOMP
] = 0xff;
2900 unpack_ubyte_I_UNORM8(const void *src
, GLubyte dst
[][4], GLuint n
)
2902 const GLubyte
*s
= ((const GLubyte
*) src
);
2904 for (i
= 0; i
< n
; i
++) {
2908 dst
[i
][ACOMP
] = s
[i
];
2913 unpack_ubyte_R_UNORM8(const void *src
, GLubyte dst
[][4], GLuint n
)
2915 const GLubyte
*s
= ((const GLubyte
*) src
);
2917 for (i
= 0; i
< n
; i
++) {
2926 unpack_ubyte_R8G8_UNORM(const void *src
, GLubyte dst
[][4], GLuint n
)
2928 const GLushort
*s
= ((const GLushort
*) src
);
2930 for (i
= 0; i
< n
; i
++) {
2931 dst
[i
][RCOMP
] = s
[i
] & 0xff;
2932 dst
[i
][GCOMP
] = s
[i
] >> 8;
2934 dst
[i
][ACOMP
] = 0xff;
2939 unpack_ubyte_G8R8_UNORM(const void *src
, GLubyte dst
[][4], GLuint n
)
2941 const GLushort
*s
= ((const GLushort
*) src
);
2943 for (i
= 0; i
< n
; i
++) {
2944 dst
[i
][RCOMP
] = s
[i
] >> 8;
2945 dst
[i
][GCOMP
] = s
[i
] & 0xff;
2947 dst
[i
][ACOMP
] = 0xff;
2953 * Unpack rgba colors, returning as GLubyte values. This should usually
2954 * only be used for unpacking formats that use 8 bits or less per channel.
2957 _mesa_unpack_ubyte_rgba_row(mesa_format format
, GLuint n
,
2958 const void *src
, GLubyte dst
[][4])
2961 case MESA_FORMAT_A8B8G8R8_UNORM
:
2962 unpack_ubyte_A8B8G8R8_UNORM(src
, dst
, n
);
2964 case MESA_FORMAT_R8G8B8A8_UNORM
:
2965 unpack_ubyte_R8G8B8A8_UNORM(src
, dst
, n
);
2967 case MESA_FORMAT_B8G8R8A8_UNORM
:
2968 unpack_ubyte_B8G8R8A8_UNORM(src
, dst
, n
);
2970 case MESA_FORMAT_A8R8G8B8_UNORM
:
2971 unpack_ubyte_A8R8G8B8_UNORM(src
, dst
, n
);
2973 case MESA_FORMAT_X8B8G8R8_UNORM
:
2974 unpack_ubyte_RGBX8888(src
, dst
, n
);
2976 case MESA_FORMAT_R8G8B8X8_UNORM
:
2977 unpack_ubyte_RGBX8888_REV(src
, dst
, n
);
2979 case MESA_FORMAT_B8G8R8X8_UNORM
:
2980 unpack_ubyte_B8G8R8X8_UNORM(src
, dst
, n
);
2982 case MESA_FORMAT_X8R8G8B8_UNORM
:
2983 unpack_ubyte_X8R8G8B8_UNORM(src
, dst
, n
);
2985 case MESA_FORMAT_BGR_UNORM8
:
2986 unpack_ubyte_BGR_UNORM8(src
, dst
, n
);
2988 case MESA_FORMAT_RGB_UNORM8
:
2989 unpack_ubyte_RGB_UNORM8(src
, dst
, n
);
2991 case MESA_FORMAT_B5G6R5_UNORM
:
2992 unpack_ubyte_B5G6R5_UNORM(src
, dst
, n
);
2994 case MESA_FORMAT_R5G6B5_UNORM
:
2995 unpack_ubyte_R5G6B5_UNORM(src
, dst
, n
);
2997 case MESA_FORMAT_B4G4R4A4_UNORM
:
2998 unpack_ubyte_B4G4R4A4_UNORM(src
, dst
, n
);
3000 case MESA_FORMAT_A4R4G4B4_UNORM
:
3001 unpack_ubyte_A4R4G4B4_UNORM(src
, dst
, n
);
3003 case MESA_FORMAT_A1B5G5R5_UNORM
:
3004 unpack_ubyte_A1B5G5R5_UNORM(src
, dst
, n
);
3006 case MESA_FORMAT_B5G5R5A1_UNORM
:
3007 unpack_ubyte_B5G5R5A1_UNORM(src
, dst
, n
);
3009 case MESA_FORMAT_A1R5G5B5_UNORM
:
3010 unpack_ubyte_A1R5G5B5_UNORM(src
, dst
, n
);
3012 case MESA_FORMAT_L4A4_UNORM
:
3013 unpack_ubyte_L4A4_UNORM(src
, dst
, n
);
3015 case MESA_FORMAT_L8A8_UNORM
:
3016 unpack_ubyte_L8A8_UNORM(src
, dst
, n
);
3018 case MESA_FORMAT_A8L8_UNORM
:
3019 unpack_ubyte_A8L8_UNORM(src
, dst
, n
);
3021 case MESA_FORMAT_B2G3R3_UNORM
:
3022 unpack_ubyte_B2G3R3_UNORM(src
, dst
, n
);
3024 case MESA_FORMAT_A_UNORM8
:
3025 unpack_ubyte_A_UNORM8(src
, dst
, n
);
3027 case MESA_FORMAT_L_UNORM8
:
3028 unpack_ubyte_L_UNORM8(src
, dst
, n
);
3030 case MESA_FORMAT_I_UNORM8
:
3031 unpack_ubyte_I_UNORM8(src
, dst
, n
);
3033 case MESA_FORMAT_R_UNORM8
:
3034 unpack_ubyte_R_UNORM8(src
, dst
, n
);
3036 case MESA_FORMAT_R8G8_UNORM
:
3037 unpack_ubyte_R8G8_UNORM(src
, dst
, n
);
3039 case MESA_FORMAT_G8R8_UNORM
:
3040 unpack_ubyte_G8R8_UNORM(src
, dst
, n
);
3043 /* get float values, convert to ubyte */
3045 GLfloat
*tmp
= malloc(n
* 4 * sizeof(GLfloat
));
3048 _mesa_unpack_rgba_row(format
, n
, src
, (GLfloat (*)[4]) tmp
);
3049 for (i
= 0; i
< n
; i
++) {
3050 UNCLAMPED_FLOAT_TO_UBYTE(dst
[i
][0], tmp
[i
*4+0]);
3051 UNCLAMPED_FLOAT_TO_UBYTE(dst
[i
][1], tmp
[i
*4+1]);
3052 UNCLAMPED_FLOAT_TO_UBYTE(dst
[i
][2], tmp
[i
*4+2]);
3053 UNCLAMPED_FLOAT_TO_UBYTE(dst
[i
][3], tmp
[i
*4+3]);
3063 /**********************************************************************/
3064 /* Unpack, returning GLuint colors */
3065 /**********************************************************************/
3068 unpack_int_rgba_RGBA_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3070 memcpy(dst
, src
, n
* 4 * sizeof(GLuint
));
3074 unpack_int_rgba_RGBA_UINT16(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
3078 for (i
= 0; i
< n
; i
++) {
3079 dst
[i
][0] = src
[i
* 4 + 0];
3080 dst
[i
][1] = src
[i
* 4 + 1];
3081 dst
[i
][2] = src
[i
* 4 + 2];
3082 dst
[i
][3] = src
[i
* 4 + 3];
3087 unpack_int_rgba_RGBA_INT16(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
3091 for (i
= 0; i
< n
; i
++) {
3092 dst
[i
][0] = src
[i
* 4 + 0];
3093 dst
[i
][1] = src
[i
* 4 + 1];
3094 dst
[i
][2] = src
[i
* 4 + 2];
3095 dst
[i
][3] = src
[i
* 4 + 3];
3100 unpack_int_rgba_RGBA_UINT8(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
3104 for (i
= 0; i
< n
; i
++) {
3105 dst
[i
][0] = src
[i
* 4 + 0];
3106 dst
[i
][1] = src
[i
* 4 + 1];
3107 dst
[i
][2] = src
[i
* 4 + 2];
3108 dst
[i
][3] = src
[i
* 4 + 3];
3113 unpack_int_rgba_RGBA_INT8(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3117 for (i
= 0; i
< n
; i
++) {
3118 dst
[i
][0] = src
[i
* 4 + 0];
3119 dst
[i
][1] = src
[i
* 4 + 1];
3120 dst
[i
][2] = src
[i
* 4 + 2];
3121 dst
[i
][3] = src
[i
* 4 + 3];
3126 unpack_int_rgba_B8G8R8A8_UNORM(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3130 for (i
= 0; i
< n
; i
++) {
3131 dst
[i
][RCOMP
] = (GLubyte
) src
[i
* 4 + 2];
3132 dst
[i
][GCOMP
] = (GLubyte
) src
[i
* 4 + 1];
3133 dst
[i
][BCOMP
] = (GLubyte
) src
[i
* 4 + 0];
3134 dst
[i
][ACOMP
] = (GLubyte
) src
[i
* 4 + 3];
3139 unpack_int_rgba_B8G8R8X8_UNORM(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3143 for (i
= 0; i
< n
; i
++) {
3144 dst
[i
][RCOMP
] = (GLubyte
) src
[i
* 4 + 2];
3145 dst
[i
][GCOMP
] = (GLubyte
) src
[i
* 4 + 1];
3146 dst
[i
][BCOMP
] = (GLubyte
) src
[i
* 4 + 0];
3147 dst
[i
][ACOMP
] = (GLubyte
) 0xff;
3152 unpack_int_rgba_RGB_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3156 for (i
= 0; i
< n
; i
++) {
3157 dst
[i
][0] = src
[i
* 3 + 0];
3158 dst
[i
][1] = src
[i
* 3 + 1];
3159 dst
[i
][2] = src
[i
* 3 + 2];
3165 unpack_int_rgba_RGB_UINT16(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
3169 for (i
= 0; i
< n
; i
++) {
3170 dst
[i
][0] = src
[i
* 3 + 0];
3171 dst
[i
][1] = src
[i
* 3 + 1];
3172 dst
[i
][2] = src
[i
* 3 + 2];
3178 unpack_int_rgba_RGB_INT16(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
3182 for (i
= 0; i
< n
; i
++) {
3183 dst
[i
][0] = src
[i
* 3 + 0];
3184 dst
[i
][1] = src
[i
* 3 + 1];
3185 dst
[i
][2] = src
[i
* 3 + 2];
3191 unpack_int_rgba_RGB_UINT8(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
3195 for (i
= 0; i
< n
; i
++) {
3196 dst
[i
][0] = src
[i
* 3 + 0];
3197 dst
[i
][1] = src
[i
* 3 + 1];
3198 dst
[i
][2] = src
[i
* 3 + 2];
3204 unpack_int_rgba_RGB_INT8(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3208 for (i
= 0; i
< n
; i
++) {
3209 dst
[i
][0] = src
[i
* 3 + 0];
3210 dst
[i
][1] = src
[i
* 3 + 1];
3211 dst
[i
][2] = src
[i
* 3 + 2];
3217 unpack_int_rgba_RG_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3221 for (i
= 0; i
< n
; i
++) {
3222 dst
[i
][0] = src
[i
* 2 + 0];
3223 dst
[i
][1] = src
[i
* 2 + 1];
3230 unpack_int_rgba_RG_UINT16(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
3234 for (i
= 0; i
< n
; i
++) {
3235 dst
[i
][0] = src
[i
* 2 + 0];
3236 dst
[i
][1] = src
[i
* 2 + 1];
3243 unpack_int_rgba_RG_INT16(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
3247 for (i
= 0; i
< n
; i
++) {
3248 dst
[i
][0] = src
[i
* 2 + 0];
3249 dst
[i
][1] = src
[i
* 2 + 1];
3256 unpack_int_rgba_RG_UINT8(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
3260 for (i
= 0; i
< n
; i
++) {
3261 dst
[i
][0] = src
[i
* 2 + 0];
3262 dst
[i
][1] = src
[i
* 2 + 1];
3269 unpack_int_rgba_RG_INT8(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3273 for (i
= 0; i
< n
; i
++) {
3274 dst
[i
][0] = src
[i
* 2 + 0];
3275 dst
[i
][1] = src
[i
* 2 + 1];
3282 unpack_int_rgba_R_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3286 for (i
= 0; i
< n
; i
++) {
3295 unpack_int_rgba_R_UINT16(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
3299 for (i
= 0; i
< n
; i
++) {
3308 unpack_int_rgba_R_INT16(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
3312 for (i
= 0; i
< n
; i
++) {
3321 unpack_int_rgba_R_UINT8(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
3325 for (i
= 0; i
< n
; i
++) {
3334 unpack_int_rgba_R_INT8(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3338 for (i
= 0; i
< n
; i
++) {
3347 unpack_int_rgba_ALPHA_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3351 for (i
= 0; i
< n
; i
++) {
3352 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = 0;
3358 unpack_int_rgba_ALPHA_UINT16(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
3362 for (i
= 0; i
< n
; i
++) {
3363 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = 0;
3369 unpack_int_rgba_ALPHA_INT16(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
3373 for (i
= 0; i
< n
; i
++) {
3374 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = 0;
3380 unpack_int_rgba_ALPHA_UINT8(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
3384 for (i
= 0; i
< n
; i
++) {
3385 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = 0;
3391 unpack_int_rgba_ALPHA_INT8(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3395 for (i
= 0; i
< n
; i
++) {
3396 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = 0;
3402 unpack_int_rgba_LUMINANCE_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3406 for (i
= 0; i
< n
; i
++) {
3407 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
];
3413 unpack_int_rgba_LUMINANCE_UINT16(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
3417 for (i
= 0; i
< n
; i
++) {
3418 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
];
3424 unpack_int_rgba_LUMINANCE_INT16(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
3428 for (i
= 0; i
< n
; i
++) {
3429 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
];
3435 unpack_int_rgba_LUMINANCE_UINT8(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
3439 for (i
= 0; i
< n
; i
++) {
3440 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
];
3446 unpack_int_rgba_LUMINANCE_INT8(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3450 for (i
= 0; i
< n
; i
++) {
3451 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
];
3458 unpack_int_rgba_LUMINANCE_ALPHA_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3462 for (i
= 0; i
< n
; i
++) {
3463 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
* 2 + 0];
3464 dst
[i
][3] = src
[i
* 2 + 1];
3469 unpack_int_rgba_LUMINANCE_ALPHA_UINT16(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
3473 for (i
= 0; i
< n
; i
++) {
3474 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
* 2 + 0];
3475 dst
[i
][3] = src
[i
* 2 + 1];
3480 unpack_int_rgba_LUMINANCE_ALPHA_INT16(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
3484 for (i
= 0; i
< n
; i
++) {
3485 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
* 2 + 0];
3486 dst
[i
][3] = src
[i
* 2 + 1];
3491 unpack_int_rgba_LUMINANCE_ALPHA_UINT8(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
3495 for (i
= 0; i
< n
; i
++) {
3496 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
* 2 + 0];
3497 dst
[i
][3] = src
[i
* 2 + 1];
3502 unpack_int_rgba_LUMINANCE_ALPHA_INT8(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3506 for (i
= 0; i
< n
; i
++) {
3507 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
* 2 + 0];
3508 dst
[i
][3] = src
[i
* 2 + 1];
3513 unpack_int_rgba_INTENSITY_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3517 for (i
= 0; i
< n
; i
++) {
3518 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = dst
[i
][3] = src
[i
];
3523 unpack_int_rgba_INTENSITY_UINT16(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
3527 for (i
= 0; i
< n
; i
++) {
3528 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = dst
[i
][3] = src
[i
];
3533 unpack_int_rgba_INTENSITY_INT16(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
3537 for (i
= 0; i
< n
; i
++) {
3538 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = dst
[i
][3] = src
[i
];
3543 unpack_int_rgba_INTENSITY_UINT8(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
3547 for (i
= 0; i
< n
; i
++) {
3548 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = dst
[i
][3] = src
[i
];
3553 unpack_int_rgba_INTENSITY_INT8(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3557 for (i
= 0; i
< n
; i
++) {
3558 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = dst
[i
][3] = src
[i
];
3563 unpack_int_rgba_ARGB2101010_UINT(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3567 for (i
= 0; i
< n
; i
++) {
3568 GLuint tmp
= src
[i
];
3569 dst
[i
][0] = (tmp
>> 20) & 0x3ff;
3570 dst
[i
][1] = (tmp
>> 10) & 0x3ff;
3571 dst
[i
][2] = (tmp
>> 0) & 0x3ff;
3572 dst
[i
][3] = (tmp
>> 30) & 0x3;
3577 unpack_int_rgba_ABGR2101010_UINT(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3581 for (i
= 0; i
< n
; i
++) {
3582 GLuint tmp
= src
[i
];
3583 dst
[i
][0] = (tmp
>> 0) & 0x3ff;
3584 dst
[i
][1] = (tmp
>> 10) & 0x3ff;
3585 dst
[i
][2] = (tmp
>> 20) & 0x3ff;
3586 dst
[i
][3] = (tmp
>> 30) & 0x3;
3591 unpack_int_rgba_B10G10R10A2_UNORM(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3595 for (i
= 0; i
< n
; i
++) {
3596 GLuint tmp
= src
[i
];
3597 dst
[i
][0] = (tmp
>> 20) & 0x3ff;
3598 dst
[i
][1] = (tmp
>> 10) & 0x3ff;
3599 dst
[i
][2] = (tmp
>> 0) & 0x3ff;
3600 dst
[i
][3] = (tmp
>> 30) & 0x3;
3605 unpack_int_rgba_XBGR8888_UINT(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
3609 for (i
= 0; i
< n
; i
++) {
3610 dst
[i
][0] = src
[i
* 4 + 0];
3611 dst
[i
][1] = src
[i
* 4 + 1];
3612 dst
[i
][2] = src
[i
* 4 + 2];
3618 unpack_int_rgba_XBGR8888_SINT(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3622 for (i
= 0; i
< n
; i
++) {
3623 dst
[i
][0] = src
[i
* 4 + 0];
3624 dst
[i
][1] = src
[i
* 4 + 1];
3625 dst
[i
][2] = src
[i
* 4 + 2];
3631 unpack_int_rgba_XBGR16161616_UINT(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
3635 for (i
= 0; i
< n
; i
++) {
3636 dst
[i
][0] = src
[i
* 4 + 0];
3637 dst
[i
][1] = src
[i
* 4 + 1];
3638 dst
[i
][2] = src
[i
* 4 + 2];
3644 unpack_int_rgba_XBGR16161616_SINT(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
3648 for (i
= 0; i
< n
; i
++) {
3649 dst
[i
][0] = src
[i
* 4 + 0];
3650 dst
[i
][1] = src
[i
* 4 + 1];
3651 dst
[i
][2] = src
[i
* 4 + 2];
3657 unpack_int_rgba_XBGR32323232_UINT(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3661 for (i
= 0; i
< n
; i
++) {
3662 dst
[i
][0] = src
[i
* 4 + 0];
3663 dst
[i
][1] = src
[i
* 4 + 1];
3664 dst
[i
][2] = src
[i
* 4 + 2];
3670 unpack_int_rgba_R10G10B10A2_UNORM(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3674 for (i
= 0; i
< n
; i
++) {
3675 GLuint tmp
= src
[i
];
3676 dst
[i
][0] = (tmp
>> 0) & 0x3ff;
3677 dst
[i
][1] = (tmp
>> 10) & 0x3ff;
3678 dst
[i
][2] = (tmp
>> 20) & 0x3ff;
3679 dst
[i
][3] = (tmp
>> 30) & 0x3;
3684 _mesa_unpack_uint_rgba_row(mesa_format format
, GLuint n
,
3685 const void *src
, GLuint dst
[][4])
3688 /* Since there won't be any sign extension happening, there's no need to
3689 * make separate paths for 32-bit-to-32-bit integer unpack.
3691 case MESA_FORMAT_RGBA_UINT32
:
3692 case MESA_FORMAT_RGBA_SINT32
:
3693 unpack_int_rgba_RGBA_UINT32(src
, dst
, n
);
3696 case MESA_FORMAT_RGBA_UINT16
:
3697 unpack_int_rgba_RGBA_UINT16(src
, dst
, n
);
3699 case MESA_FORMAT_RGBA_SINT16
:
3700 unpack_int_rgba_RGBA_INT16(src
, dst
, n
);
3703 case MESA_FORMAT_RGBA_UINT8
:
3704 unpack_int_rgba_RGBA_UINT8(src
, dst
, n
);
3706 case MESA_FORMAT_RGBA_SINT8
:
3707 unpack_int_rgba_RGBA_INT8(src
, dst
, n
);
3710 case MESA_FORMAT_B8G8R8A8_UNORM
:
3711 unpack_int_rgba_B8G8R8A8_UNORM(src
, dst
, n
);
3714 case MESA_FORMAT_B8G8R8X8_UNORM
:
3715 unpack_int_rgba_B8G8R8X8_UNORM(src
, dst
, n
);
3718 case MESA_FORMAT_RGB_UINT32
:
3719 case MESA_FORMAT_RGB_SINT32
:
3720 unpack_int_rgba_RGB_UINT32(src
, dst
, n
);
3723 case MESA_FORMAT_RGB_UINT16
:
3724 unpack_int_rgba_RGB_UINT16(src
, dst
, n
);
3726 case MESA_FORMAT_RGB_SINT16
:
3727 unpack_int_rgba_RGB_INT16(src
, dst
, n
);
3730 case MESA_FORMAT_RGB_UINT8
:
3731 unpack_int_rgba_RGB_UINT8(src
, dst
, n
);
3733 case MESA_FORMAT_RGB_SINT8
:
3734 unpack_int_rgba_RGB_INT8(src
, dst
, n
);
3737 case MESA_FORMAT_RG_UINT32
:
3738 case MESA_FORMAT_RG_SINT32
:
3739 unpack_int_rgba_RG_UINT32(src
, dst
, n
);
3742 case MESA_FORMAT_RG_UINT16
:
3743 unpack_int_rgba_RG_UINT16(src
, dst
, n
);
3745 case MESA_FORMAT_RG_SINT16
:
3746 unpack_int_rgba_RG_INT16(src
, dst
, n
);
3749 case MESA_FORMAT_RG_UINT8
:
3750 unpack_int_rgba_RG_UINT8(src
, dst
, n
);
3752 case MESA_FORMAT_RG_SINT8
:
3753 unpack_int_rgba_RG_INT8(src
, dst
, n
);
3756 case MESA_FORMAT_R_UINT32
:
3757 case MESA_FORMAT_R_SINT32
:
3758 unpack_int_rgba_R_UINT32(src
, dst
, n
);
3761 case MESA_FORMAT_R_UINT16
:
3762 unpack_int_rgba_R_UINT16(src
, dst
, n
);
3764 case MESA_FORMAT_R_SINT16
:
3765 unpack_int_rgba_R_INT16(src
, dst
, n
);
3768 case MESA_FORMAT_R_UINT8
:
3769 unpack_int_rgba_R_UINT8(src
, dst
, n
);
3771 case MESA_FORMAT_R_SINT8
:
3772 unpack_int_rgba_R_INT8(src
, dst
, n
);
3775 case MESA_FORMAT_A_UINT32
:
3776 case MESA_FORMAT_A_SINT32
:
3777 unpack_int_rgba_ALPHA_UINT32(src
, dst
, n
);
3780 case MESA_FORMAT_A_UINT16
:
3781 unpack_int_rgba_ALPHA_UINT16(src
, dst
, n
);
3783 case MESA_FORMAT_A_SINT16
:
3784 unpack_int_rgba_ALPHA_INT16(src
, dst
, n
);
3787 case MESA_FORMAT_A_UINT8
:
3788 unpack_int_rgba_ALPHA_UINT8(src
, dst
, n
);
3790 case MESA_FORMAT_A_SINT8
:
3791 unpack_int_rgba_ALPHA_INT8(src
, dst
, n
);
3794 case MESA_FORMAT_L_UINT32
:
3795 case MESA_FORMAT_L_SINT32
:
3796 unpack_int_rgba_LUMINANCE_UINT32(src
, dst
, n
);
3798 case MESA_FORMAT_L_UINT16
:
3799 unpack_int_rgba_LUMINANCE_UINT16(src
, dst
, n
);
3801 case MESA_FORMAT_L_SINT16
:
3802 unpack_int_rgba_LUMINANCE_INT16(src
, dst
, n
);
3805 case MESA_FORMAT_L_UINT8
:
3806 unpack_int_rgba_LUMINANCE_UINT8(src
, dst
, n
);
3808 case MESA_FORMAT_L_SINT8
:
3809 unpack_int_rgba_LUMINANCE_INT8(src
, dst
, n
);
3812 case MESA_FORMAT_LA_UINT32
:
3813 case MESA_FORMAT_LA_SINT32
:
3814 unpack_int_rgba_LUMINANCE_ALPHA_UINT32(src
, dst
, n
);
3817 case MESA_FORMAT_LA_UINT16
:
3818 unpack_int_rgba_LUMINANCE_ALPHA_UINT16(src
, dst
, n
);
3820 case MESA_FORMAT_LA_SINT16
:
3821 unpack_int_rgba_LUMINANCE_ALPHA_INT16(src
, dst
, n
);
3824 case MESA_FORMAT_LA_UINT8
:
3825 unpack_int_rgba_LUMINANCE_ALPHA_UINT8(src
, dst
, n
);
3827 case MESA_FORMAT_LA_SINT8
:
3828 unpack_int_rgba_LUMINANCE_ALPHA_INT8(src
, dst
, n
);
3831 case MESA_FORMAT_I_UINT32
:
3832 case MESA_FORMAT_I_SINT32
:
3833 unpack_int_rgba_INTENSITY_UINT32(src
, dst
, n
);
3836 case MESA_FORMAT_I_UINT16
:
3837 unpack_int_rgba_INTENSITY_UINT16(src
, dst
, n
);
3839 case MESA_FORMAT_I_SINT16
:
3840 unpack_int_rgba_INTENSITY_INT16(src
, dst
, n
);
3843 case MESA_FORMAT_I_UINT8
:
3844 unpack_int_rgba_INTENSITY_UINT8(src
, dst
, n
);
3846 case MESA_FORMAT_I_SINT8
:
3847 unpack_int_rgba_INTENSITY_INT8(src
, dst
, n
);
3850 case MESA_FORMAT_B10G10R10A2_UINT
:
3851 unpack_int_rgba_ARGB2101010_UINT(src
, dst
, n
);
3854 case MESA_FORMAT_R10G10B10A2_UINT
:
3855 unpack_int_rgba_ABGR2101010_UINT(src
, dst
, n
);
3858 case MESA_FORMAT_B10G10R10A2_UNORM
:
3859 unpack_int_rgba_B10G10R10A2_UNORM(src
, dst
, n
);
3862 case MESA_FORMAT_RGBX_UINT8
:
3863 unpack_int_rgba_XBGR8888_UINT(src
, dst
, n
);
3866 case MESA_FORMAT_RGBX_SINT8
:
3867 unpack_int_rgba_XBGR8888_SINT(src
, dst
, n
);
3870 case MESA_FORMAT_RGBX_UINT16
:
3871 unpack_int_rgba_XBGR16161616_UINT(src
, dst
, n
);
3874 case MESA_FORMAT_RGBX_SINT16
:
3875 unpack_int_rgba_XBGR16161616_SINT(src
, dst
, n
);
3878 case MESA_FORMAT_RGBX_UINT32
:
3879 case MESA_FORMAT_RGBX_SINT32
:
3880 unpack_int_rgba_XBGR32323232_UINT(src
, dst
, n
);
3883 case MESA_FORMAT_R10G10B10A2_UNORM
:
3884 unpack_int_rgba_R10G10B10A2_UNORM(src
, dst
, n
);
3888 _mesa_problem(NULL
, "%s: bad format %s", __FUNCTION__
,
3889 _mesa_get_format_name(format
));
3895 * Unpack a 2D rect of pixels returning float RGBA colors.
3896 * \param format the source image format
3897 * \param src start address of the source image
3898 * \param srcRowStride source image row stride in bytes
3899 * \param dst start address of the dest image
3900 * \param dstRowStride dest image row stride in bytes
3901 * \param x source image start X pos
3902 * \param y source image start Y pos
3903 * \param width width of rect region to convert
3904 * \param height height of rect region to convert
3907 _mesa_unpack_rgba_block(mesa_format format
,
3908 const void *src
, GLint srcRowStride
,
3909 GLfloat dst
[][4], GLint dstRowStride
,
3910 GLuint x
, GLuint y
, GLuint width
, GLuint height
)
3912 unpack_rgba_func unpack
= get_unpack_rgba_function(format
);
3913 const GLuint srcPixStride
= _mesa_get_format_bytes(format
);
3914 const GLuint dstPixStride
= 4 * sizeof(GLfloat
);
3915 const GLubyte
*srcRow
;
3919 /* XXX needs to be fixed for compressed formats */
3921 srcRow
= ((const GLubyte
*) src
) + srcRowStride
* y
+ srcPixStride
* x
;
3922 dstRow
= ((GLubyte
*) dst
) + dstRowStride
* y
+ dstPixStride
* x
;
3924 for (i
= 0; i
< height
; i
++) {
3925 unpack(srcRow
, (GLfloat (*)[4]) dstRow
, width
);
3927 dstRow
+= dstRowStride
;
3928 srcRow
+= srcRowStride
;
3935 typedef void (*unpack_float_z_func
)(GLuint n
, const void *src
, GLfloat
*dst
);
3938 unpack_float_z_Z24_X8(GLuint n
, const void *src
, GLfloat
*dst
)
3940 /* only return Z, not stencil data */
3941 const GLuint
*s
= ((const GLuint
*) src
);
3942 const GLdouble scale
= 1.0 / (GLdouble
) 0xffffff;
3944 for (i
= 0; i
< n
; i
++) {
3945 dst
[i
] = (GLfloat
) ((s
[i
] >> 8) * scale
);
3946 ASSERT(dst
[i
] >= 0.0F
);
3947 ASSERT(dst
[i
] <= 1.0F
);
3952 unpack_float_z_X8_Z24(GLuint n
, const void *src
, GLfloat
*dst
)
3954 /* only return Z, not stencil data */
3955 const GLuint
*s
= ((const GLuint
*) src
);
3956 const GLdouble scale
= 1.0 / (GLdouble
) 0xffffff;
3958 for (i
= 0; i
< n
; i
++) {
3959 dst
[i
] = (GLfloat
) ((s
[i
] & 0x00ffffff) * scale
);
3960 ASSERT(dst
[i
] >= 0.0F
);
3961 ASSERT(dst
[i
] <= 1.0F
);
3966 unpack_float_z_Z16(GLuint n
, const void *src
, GLfloat
*dst
)
3968 const GLushort
*s
= ((const GLushort
*) src
);
3970 for (i
= 0; i
< n
; i
++) {
3971 dst
[i
] = s
[i
] * (1.0F
/ 65535.0F
);
3976 unpack_float_z_Z32(GLuint n
, const void *src
, GLfloat
*dst
)
3978 const GLuint
*s
= ((const GLuint
*) src
);
3980 for (i
= 0; i
< n
; i
++) {
3981 dst
[i
] = s
[i
] * (1.0F
/ 0xffffffff);
3986 unpack_float_z_Z32F(GLuint n
, const void *src
, GLfloat
*dst
)
3988 memcpy(dst
, src
, n
* sizeof(float));
3992 unpack_float_z_Z32X24S8(GLuint n
, const void *src
, GLfloat
*dst
)
3994 const struct z32f_x24s8
*s
= (const struct z32f_x24s8
*) src
;
3996 for (i
= 0; i
< n
; i
++) {
4005 * The returned values will always be in the range [0.0, 1.0].
4008 _mesa_unpack_float_z_row(mesa_format format
, GLuint n
,
4009 const void *src
, GLfloat
*dst
)
4011 unpack_float_z_func unpack
;
4014 case MESA_FORMAT_S8_UINT_Z24_UNORM
:
4015 case MESA_FORMAT_X8_UINT_Z24_UNORM
:
4016 unpack
= unpack_float_z_Z24_X8
;
4018 case MESA_FORMAT_Z24_UNORM_S8_UINT
:
4019 case MESA_FORMAT_Z24_UNORM_X8_UINT
:
4020 unpack
= unpack_float_z_X8_Z24
;
4022 case MESA_FORMAT_Z_UNORM16
:
4023 unpack
= unpack_float_z_Z16
;
4025 case MESA_FORMAT_Z_UNORM32
:
4026 unpack
= unpack_float_z_Z32
;
4028 case MESA_FORMAT_Z_FLOAT32
:
4029 unpack
= unpack_float_z_Z32F
;
4031 case MESA_FORMAT_Z32_FLOAT_S8X24_UINT
:
4032 unpack
= unpack_float_z_Z32X24S8
;
4035 _mesa_problem(NULL
, "bad format %s in _mesa_unpack_float_z_row",
4036 _mesa_get_format_name(format
));
4040 unpack(n
, src
, dst
);
4045 typedef void (*unpack_uint_z_func
)(const void *src
, GLuint
*dst
, GLuint n
);
4048 unpack_uint_z_Z24_X8(const void *src
, GLuint
*dst
, GLuint n
)
4050 /* only return Z, not stencil data */
4051 const GLuint
*s
= ((const GLuint
*) src
);
4053 for (i
= 0; i
< n
; i
++) {
4054 dst
[i
] = (s
[i
] & 0xffffff00) | (s
[i
] >> 24);
4059 unpack_uint_z_X8_Z24(const void *src
, GLuint
*dst
, GLuint n
)
4061 /* only return Z, not stencil data */
4062 const GLuint
*s
= ((const GLuint
*) src
);
4064 for (i
= 0; i
< n
; i
++) {
4065 dst
[i
] = (s
[i
] << 8) | ((s
[i
] >> 16) & 0xff);
4070 unpack_uint_z_Z16(const void *src
, GLuint
*dst
, GLuint n
)
4072 const GLushort
*s
= ((const GLushort
*)src
);
4074 for (i
= 0; i
< n
; i
++) {
4075 dst
[i
] = (s
[i
] << 16) | s
[i
];
4080 unpack_uint_z_Z32(const void *src
, GLuint
*dst
, GLuint n
)
4082 memcpy(dst
, src
, n
* sizeof(GLuint
));
4086 unpack_uint_z_Z32_FLOAT(const void *src
, GLuint
*dst
, GLuint n
)
4088 const float *s
= (const float *)src
;
4090 for (i
= 0; i
< n
; i
++) {
4091 dst
[i
] = FLOAT_TO_UINT(CLAMP(s
[i
], 0.0F
, 1.0F
));
4096 unpack_uint_z_Z32_FLOAT_X24S8(const void *src
, GLuint
*dst
, GLuint n
)
4098 const struct z32f_x24s8
*s
= (const struct z32f_x24s8
*) src
;
4101 for (i
= 0; i
< n
; i
++) {
4102 dst
[i
] = FLOAT_TO_UINT(CLAMP(s
[i
].z
, 0.0F
, 1.0F
));
4109 * The returned values will always be in the range [0, 0xffffffff].
4112 _mesa_unpack_uint_z_row(mesa_format format
, GLuint n
,
4113 const void *src
, GLuint
*dst
)
4115 unpack_uint_z_func unpack
;
4116 const GLubyte
*srcPtr
= (GLubyte
*) src
;
4119 case MESA_FORMAT_S8_UINT_Z24_UNORM
:
4120 case MESA_FORMAT_X8_UINT_Z24_UNORM
:
4121 unpack
= unpack_uint_z_Z24_X8
;
4123 case MESA_FORMAT_Z24_UNORM_S8_UINT
:
4124 case MESA_FORMAT_Z24_UNORM_X8_UINT
:
4125 unpack
= unpack_uint_z_X8_Z24
;
4127 case MESA_FORMAT_Z_UNORM16
:
4128 unpack
= unpack_uint_z_Z16
;
4130 case MESA_FORMAT_Z_UNORM32
:
4131 unpack
= unpack_uint_z_Z32
;
4133 case MESA_FORMAT_Z_FLOAT32
:
4134 unpack
= unpack_uint_z_Z32_FLOAT
;
4136 case MESA_FORMAT_Z32_FLOAT_S8X24_UINT
:
4137 unpack
= unpack_uint_z_Z32_FLOAT_X24S8
;
4140 _mesa_problem(NULL
, "bad format %s in _mesa_unpack_uint_z_row",
4141 _mesa_get_format_name(format
));
4145 unpack(srcPtr
, dst
, n
);
4150 unpack_ubyte_s_S8(const void *src
, GLubyte
*dst
, GLuint n
)
4152 memcpy(dst
, src
, n
);
4156 unpack_ubyte_s_Z24_S8(const void *src
, GLubyte
*dst
, GLuint n
)
4159 const GLuint
*src32
= src
;
4161 for (i
= 0; i
< n
; i
++)
4162 dst
[i
] = src32
[i
] & 0xff;
4166 unpack_ubyte_s_S8_Z24(const void *src
, GLubyte
*dst
, GLuint n
)
4169 const GLuint
*src32
= src
;
4171 for (i
= 0; i
< n
; i
++)
4172 dst
[i
] = src32
[i
] >> 24;
4176 unpack_ubyte_s_Z32_FLOAT_X24S8(const void *src
, GLubyte
*dst
, GLuint n
)
4179 const struct z32f_x24s8
*s
= (const struct z32f_x24s8
*) src
;
4181 for (i
= 0; i
< n
; i
++)
4182 dst
[i
] = s
[i
].x24s8
& 0xff;
4186 _mesa_unpack_ubyte_stencil_row(mesa_format format
, GLuint n
,
4187 const void *src
, GLubyte
*dst
)
4190 case MESA_FORMAT_S_UINT8
:
4191 unpack_ubyte_s_S8(src
, dst
, n
);
4193 case MESA_FORMAT_S8_UINT_Z24_UNORM
:
4194 unpack_ubyte_s_Z24_S8(src
, dst
, n
);
4196 case MESA_FORMAT_Z24_UNORM_S8_UINT
:
4197 unpack_ubyte_s_S8_Z24(src
, dst
, n
);
4199 case MESA_FORMAT_Z32_FLOAT_S8X24_UINT
:
4200 unpack_ubyte_s_Z32_FLOAT_X24S8(src
, dst
, n
);
4203 _mesa_problem(NULL
, "bad format %s in _mesa_unpack_ubyte_s_row",
4204 _mesa_get_format_name(format
));
4210 unpack_uint_24_8_depth_stencil_S8_Z24(const GLuint
*src
, GLuint
*dst
, GLuint n
)
4214 for (i
= 0; i
< n
; i
++) {
4215 GLuint val
= src
[i
];
4216 dst
[i
] = val
>> 24 | val
<< 8;
4221 unpack_uint_24_8_depth_stencil_Z32_S8X24(const GLuint
*src
,
4222 GLuint
*dst
, GLuint n
)
4226 for (i
= 0; i
< n
; i
++) {
4227 /* 8 bytes per pixel (float + uint32) */
4228 GLfloat zf
= ((GLfloat
*) src
)[i
* 2 + 0];
4229 GLuint z24
= (GLuint
) (zf
* (GLfloat
) 0xffffff);
4230 GLuint s
= src
[i
* 2 + 1] & 0xff;
4231 dst
[i
] = (z24
<< 8) | s
;
4236 unpack_uint_24_8_depth_stencil_Z24_S8(const GLuint
*src
, GLuint
*dst
, GLuint n
)
4238 memcpy(dst
, src
, n
* 4);
4242 * Unpack depth/stencil returning as GL_UNSIGNED_INT_24_8.
4243 * \param format the source data format
4246 _mesa_unpack_uint_24_8_depth_stencil_row(mesa_format format
, GLuint n
,
4247 const void *src
, GLuint
*dst
)
4250 case MESA_FORMAT_S8_UINT_Z24_UNORM
:
4251 unpack_uint_24_8_depth_stencil_Z24_S8(src
, dst
, n
);
4253 case MESA_FORMAT_Z24_UNORM_S8_UINT
:
4254 unpack_uint_24_8_depth_stencil_S8_Z24(src
, dst
, n
);
4256 case MESA_FORMAT_Z32_FLOAT_S8X24_UINT
:
4257 unpack_uint_24_8_depth_stencil_Z32_S8X24(src
, dst
, n
);
4261 "bad format %s in _mesa_unpack_uint_24_8_depth_stencil_row",
4262 _mesa_get_format_name(format
));