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"
31 #include "util/format_srgb.h"
34 /** Helper struct for MESA_FORMAT_Z32_FLOAT_S8X24_UINT */
42 /* Expand 1, 2, 3, 4, 5, 6-bit values to fill 8 bits */
44 #define EXPAND_1_8(X) ( (X) ? 0xff : 0x0 )
46 #define EXPAND_2_8(X) ( ((X) << 6) | ((X) << 4) | ((X) << 2) | (X) )
48 #define EXPAND_3_8(X) ( ((X) << 5) | ((X) << 2) | ((X) >> 1) )
50 #define EXPAND_4_8(X) ( ((X) << 4) | (X) )
52 #define EXPAND_5_8(X) ( ((X) << 3) | ((X) >> 2) )
54 #define EXPAND_6_8(X) ( ((X) << 2) | ((X) >> 4) )
57 /**********************************************************************/
58 /* Unpack, returning GLfloat colors */
59 /**********************************************************************/
61 typedef void (*unpack_rgba_func
)(const void *src
, GLfloat dst
[][4], GLuint n
);
65 unpack_A8B8G8R8_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
67 const GLuint
*s
= ((const GLuint
*) src
);
69 for (i
= 0; i
< n
; i
++) {
70 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 24) );
71 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 16) & 0xff );
72 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 8) & 0xff );
73 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( (s
[i
] ) & 0xff );
78 unpack_R8G8B8A8_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
80 const GLuint
*s
= ((const GLuint
*) src
);
82 for (i
= 0; i
< n
; i
++) {
83 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( (s
[i
] ) & 0xff );
84 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 8) & 0xff );
85 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 16) & 0xff );
86 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 24) );
91 unpack_B8G8R8A8_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
93 const GLuint
*s
= ((const GLuint
*) src
);
95 for (i
= 0; i
< n
; i
++) {
96 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 16) & 0xff );
97 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 8) & 0xff );
98 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( (s
[i
] ) & 0xff );
99 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 24) );
104 unpack_A8R8G8B8_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
106 const GLuint
*s
= ((const GLuint
*) src
);
108 for (i
= 0; i
< n
; i
++) {
109 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 8) & 0xff );
110 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 16) & 0xff );
111 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 24) );
112 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( (s
[i
] ) & 0xff );
117 unpack_RGBX8888(const void *src
, GLfloat dst
[][4], GLuint n
)
119 const GLuint
*s
= ((const GLuint
*) src
);
121 for (i
= 0; i
< n
; i
++) {
122 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 24) );
123 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 16) & 0xff );
124 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 8) & 0xff );
125 dst
[i
][ACOMP
] = 1.0f
;
130 unpack_RGBX8888_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
132 const GLuint
*s
= ((const GLuint
*) src
);
134 for (i
= 0; i
< n
; i
++) {
135 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( (s
[i
] ) & 0xff );
136 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 8) & 0xff );
137 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 16) & 0xff );
138 dst
[i
][ACOMP
] = 1.0f
;
143 unpack_B8G8R8X8_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
145 const GLuint
*s
= ((const GLuint
*) src
);
147 for (i
= 0; i
< n
; i
++) {
148 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 16) & 0xff );
149 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 8) & 0xff );
150 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( (s
[i
] ) & 0xff );
151 dst
[i
][ACOMP
] = 1.0f
;
156 unpack_X8R8G8B8_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
158 const GLuint
*s
= ((const GLuint
*) src
);
160 for (i
= 0; i
< n
; i
++) {
161 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 8) & 0xff );
162 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 16) & 0xff );
163 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 24) );
164 dst
[i
][ACOMP
] = 1.0f
;
169 unpack_BGR_UNORM8(const void *src
, GLfloat dst
[][4], GLuint n
)
171 const GLubyte
*s
= (const GLubyte
*) src
;
173 for (i
= 0; i
< n
; i
++) {
174 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( s
[i
*3+2] );
175 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( s
[i
*3+1] );
176 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( s
[i
*3+0] );
177 dst
[i
][ACOMP
] = 1.0F
;
182 unpack_RGB_UNORM8(const void *src
, GLfloat dst
[][4], GLuint n
)
184 const GLubyte
*s
= (const GLubyte
*) src
;
186 for (i
= 0; i
< n
; i
++) {
187 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( s
[i
*3+0] );
188 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( s
[i
*3+1] );
189 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( s
[i
*3+2] );
190 dst
[i
][ACOMP
] = 1.0F
;
195 unpack_B5G6R5_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
197 const GLushort
*s
= ((const GLushort
*) src
);
199 for (i
= 0; i
< n
; i
++) {
200 dst
[i
][RCOMP
] = ((s
[i
] >> 11) & 0x1f) * (1.0F
/ 31.0F
);
201 dst
[i
][GCOMP
] = ((s
[i
] >> 5 ) & 0x3f) * (1.0F
/ 63.0F
);
202 dst
[i
][BCOMP
] = ((s
[i
] ) & 0x1f) * (1.0F
/ 31.0F
);
203 dst
[i
][ACOMP
] = 1.0F
;
208 unpack_R5G6B5_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
210 /* Warning: this function does not match the current Mesa definition
211 * of MESA_FORMAT_R5G6B5_UNORM.
213 const GLushort
*s
= ((const GLushort
*) src
);
215 for (i
= 0; i
< n
; i
++) {
216 GLuint t
= (s
[i
] >> 8) | (s
[i
] << 8); /* byte swap */
217 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( ((t
>> 8) & 0xf8) | ((t
>> 13) & 0x7) );
218 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( ((t
>> 3) & 0xfc) | ((t
>> 9) & 0x3) );
219 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( ((t
<< 3) & 0xf8) | ((t
>> 2) & 0x7) );
220 dst
[i
][ACOMP
] = 1.0F
;
225 unpack_B4G4R4A4_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
227 const GLushort
*s
= ((const GLushort
*) src
);
229 for (i
= 0; i
< n
; i
++) {
230 dst
[i
][RCOMP
] = ((s
[i
] >> 8) & 0xf) * (1.0F
/ 15.0F
);
231 dst
[i
][GCOMP
] = ((s
[i
] >> 4) & 0xf) * (1.0F
/ 15.0F
);
232 dst
[i
][BCOMP
] = ((s
[i
] ) & 0xf) * (1.0F
/ 15.0F
);
233 dst
[i
][ACOMP
] = ((s
[i
] >> 12) & 0xf) * (1.0F
/ 15.0F
);
238 unpack_A4R4G4B4_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
240 const GLushort
*s
= ((const GLushort
*) src
);
242 for (i
= 0; i
< n
; i
++) {
243 dst
[i
][RCOMP
] = ((s
[i
] >> 4) & 0xf) * (1.0F
/ 15.0F
);
244 dst
[i
][GCOMP
] = ((s
[i
] >> 8) & 0xf) * (1.0F
/ 15.0F
);
245 dst
[i
][BCOMP
] = ((s
[i
] >> 12) & 0xf) * (1.0F
/ 15.0F
);
246 dst
[i
][ACOMP
] = ((s
[i
] ) & 0xf) * (1.0F
/ 15.0F
);
251 unpack_A1B5G5R5_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
253 const GLushort
*s
= ((const GLushort
*) src
);
255 for (i
= 0; i
< n
; i
++) {
256 dst
[i
][RCOMP
] = ((s
[i
] >> 11) & 0x1f) * (1.0F
/ 31.0F
);
257 dst
[i
][GCOMP
] = ((s
[i
] >> 6) & 0x1f) * (1.0F
/ 31.0F
);
258 dst
[i
][BCOMP
] = ((s
[i
] >> 1) & 0x1f) * (1.0F
/ 31.0F
);
259 dst
[i
][ACOMP
] = ((s
[i
] ) & 0x01) * 1.0F
;
264 unpack_B5G5R5A1_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
266 const GLushort
*s
= ((const GLushort
*) src
);
268 for (i
= 0; i
< n
; i
++) {
269 dst
[i
][RCOMP
] = ((s
[i
] >> 10) & 0x1f) * (1.0F
/ 31.0F
);
270 dst
[i
][GCOMP
] = ((s
[i
] >> 5) & 0x1f) * (1.0F
/ 31.0F
);
271 dst
[i
][BCOMP
] = ((s
[i
] >> 0) & 0x1f) * (1.0F
/ 31.0F
);
272 dst
[i
][ACOMP
] = ((s
[i
] >> 15) & 0x01) * 1.0F
;
277 unpack_A1R5G5B5_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
279 /* Warning: this function does not match the current Mesa definition
280 * of MESA_FORMAT_A1R5G5B5_UNORM.
282 const GLushort
*s
= ((const GLushort
*) src
);
284 for (i
= 0; i
< n
; i
++) {
285 GLushort tmp
= (s
[i
] << 8) | (s
[i
] >> 8); /* byteswap */
286 dst
[i
][RCOMP
] = ((tmp
>> 10) & 0x1f) * (1.0F
/ 31.0F
);
287 dst
[i
][GCOMP
] = ((tmp
>> 5) & 0x1f) * (1.0F
/ 31.0F
);
288 dst
[i
][BCOMP
] = ((tmp
>> 0) & 0x1f) * (1.0F
/ 31.0F
);
289 dst
[i
][ACOMP
] = ((tmp
>> 15) & 0x01) * 1.0F
;
294 unpack_L4A4_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
296 const GLubyte
*s
= ((const GLubyte
*) src
);
298 for (i
= 0; i
< n
; i
++) {
301 dst
[i
][BCOMP
] = (s
[i
] & 0xf) * (1.0F
/ 15.0F
);
302 dst
[i
][ACOMP
] = ((s
[i
] >> 4) & 0xf) * (1.0F
/ 15.0F
);
307 unpack_L8A8_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
309 const GLushort
*s
= ((const GLushort
*) src
);
311 for (i
= 0; i
< n
; i
++) {
314 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( s
[i
] & 0xff );
315 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 8 );
320 unpack_A8L8_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
322 const GLushort
*s
= ((const GLushort
*) src
);
324 for (i
= 0; i
< n
; i
++) {
327 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 8 );
328 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( s
[i
] & 0xff );
333 unpack_L16A16_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
335 const GLuint
*s
= ((const GLuint
*) src
);
337 for (i
= 0; i
< n
; i
++) {
340 dst
[i
][BCOMP
] = USHORT_TO_FLOAT( s
[i
] & 0xffff );
341 dst
[i
][ACOMP
] = USHORT_TO_FLOAT( s
[i
] >> 16 );
346 unpack_A16L16_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
348 const GLuint
*s
= ((const GLuint
*) src
);
350 for (i
= 0; i
< n
; i
++) {
353 dst
[i
][BCOMP
] = USHORT_TO_FLOAT( s
[i
] >> 16 );
354 dst
[i
][ACOMP
] = USHORT_TO_FLOAT( s
[i
] & 0xffff );
359 unpack_B2G3R3_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
361 const GLubyte
*s
= ((const GLubyte
*) src
);
363 for (i
= 0; i
< n
; i
++) {
364 dst
[i
][RCOMP
] = ((s
[i
] >> 5) & 0x7) * (1.0F
/ 7.0F
);
365 dst
[i
][GCOMP
] = ((s
[i
] >> 2) & 0x7) * (1.0F
/ 7.0F
);
366 dst
[i
][BCOMP
] = ((s
[i
] ) & 0x3) * (1.0F
/ 3.0F
);
367 dst
[i
][ACOMP
] = 1.0F
;
373 unpack_A_UNORM8(const void *src
, GLfloat dst
[][4], GLuint n
)
375 const GLubyte
*s
= ((const GLubyte
*) src
);
377 for (i
= 0; i
< n
; i
++) {
380 dst
[i
][BCOMP
] = 0.0F
;
381 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT(s
[i
]);
386 unpack_A_UNORM16(const void *src
, GLfloat dst
[][4], GLuint n
)
388 const GLushort
*s
= ((const GLushort
*) src
);
390 for (i
= 0; i
< n
; i
++) {
393 dst
[i
][BCOMP
] = 0.0F
;
394 dst
[i
][ACOMP
] = USHORT_TO_FLOAT(s
[i
]);
399 unpack_L_UNORM8(const void *src
, GLfloat dst
[][4], GLuint n
)
401 const GLubyte
*s
= ((const GLubyte
*) src
);
403 for (i
= 0; i
< n
; i
++) {
406 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT(s
[i
]);
407 dst
[i
][ACOMP
] = 1.0F
;
412 unpack_L_UNORM16(const void *src
, GLfloat dst
[][4], GLuint n
)
414 const GLushort
*s
= ((const GLushort
*) src
);
416 for (i
= 0; i
< n
; i
++) {
419 dst
[i
][BCOMP
] = USHORT_TO_FLOAT(s
[i
]);
420 dst
[i
][ACOMP
] = 1.0F
;
425 unpack_I_UNORM8(const void *src
, GLfloat dst
[][4], GLuint n
)
427 const GLubyte
*s
= ((const GLubyte
*) src
);
429 for (i
= 0; i
< n
; i
++) {
433 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT(s
[i
]);
438 unpack_I_UNORM16(const void *src
, GLfloat dst
[][4], GLuint n
)
440 const GLushort
*s
= ((const GLushort
*) src
);
442 for (i
= 0; i
< n
; i
++) {
446 dst
[i
][ACOMP
] = USHORT_TO_FLOAT(s
[i
]);
451 unpack_YCBCR(const void *src
, GLfloat dst
[][4], GLuint n
)
454 for (i
= 0; i
< n
; i
++) {
455 const GLushort
*src0
= ((const GLushort
*) src
) + i
* 2; /* even */
456 const GLushort
*src1
= src0
+ 1; /* odd */
457 const GLubyte y0
= (*src0
>> 8) & 0xff; /* luminance */
458 const GLubyte cb
= *src0
& 0xff; /* chroma U */
459 const GLubyte y1
= (*src1
>> 8) & 0xff; /* luminance */
460 const GLubyte cr
= *src1
& 0xff; /* chroma V */
461 const GLubyte y
= (i
& 1) ? y1
: y0
; /* choose even/odd luminance */
462 GLfloat r
= 1.164F
* (y
- 16) + 1.596F
* (cr
- 128);
463 GLfloat g
= 1.164F
* (y
- 16) - 0.813F
* (cr
- 128) - 0.391F
* (cb
- 128);
464 GLfloat b
= 1.164F
* (y
- 16) + 2.018F
* (cb
- 128);
465 r
*= (1.0F
/ 255.0F
);
466 g
*= (1.0F
/ 255.0F
);
467 b
*= (1.0F
/ 255.0F
);
468 dst
[i
][RCOMP
] = CLAMP(r
, 0.0F
, 1.0F
);
469 dst
[i
][GCOMP
] = CLAMP(g
, 0.0F
, 1.0F
);
470 dst
[i
][BCOMP
] = CLAMP(b
, 0.0F
, 1.0F
);
471 dst
[i
][ACOMP
] = 1.0F
;
476 unpack_YCBCR_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
479 for (i
= 0; i
< n
; i
++) {
480 const GLushort
*src0
= ((const GLushort
*) src
) + i
* 2; /* even */
481 const GLushort
*src1
= src0
+ 1; /* odd */
482 const GLubyte y0
= *src0
& 0xff; /* luminance */
483 const GLubyte cr
= (*src0
>> 8) & 0xff; /* chroma V */
484 const GLubyte y1
= *src1
& 0xff; /* luminance */
485 const GLubyte cb
= (*src1
>> 8) & 0xff; /* chroma U */
486 const GLubyte y
= (i
& 1) ? y1
: y0
; /* choose even/odd luminance */
487 GLfloat r
= 1.164F
* (y
- 16) + 1.596F
* (cr
- 128);
488 GLfloat g
= 1.164F
* (y
- 16) - 0.813F
* (cr
- 128) - 0.391F
* (cb
- 128);
489 GLfloat b
= 1.164F
* (y
- 16) + 2.018F
* (cb
- 128);
490 r
*= (1.0F
/ 255.0F
);
491 g
*= (1.0F
/ 255.0F
);
492 b
*= (1.0F
/ 255.0F
);
493 dst
[i
][RCOMP
] = CLAMP(r
, 0.0F
, 1.0F
);
494 dst
[i
][GCOMP
] = CLAMP(g
, 0.0F
, 1.0F
);
495 dst
[i
][BCOMP
] = CLAMP(b
, 0.0F
, 1.0F
);
496 dst
[i
][ACOMP
] = 1.0F
;
501 unpack_R_UNORM8(const void *src
, GLfloat dst
[][4], GLuint n
)
503 const GLubyte
*s
= ((const GLubyte
*) src
);
505 for (i
= 0; i
< n
; i
++) {
506 dst
[i
][0] = UBYTE_TO_FLOAT(s
[i
]);
514 unpack_R8G8_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
516 const GLushort
*s
= ((const GLushort
*) src
);
518 for (i
= 0; i
< n
; i
++) {
519 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( s
[i
] & 0xff );
520 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 8 );
527 unpack_G8R8_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
529 const GLushort
*s
= ((const GLushort
*) src
);
531 for (i
= 0; i
< n
; i
++) {
532 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 8 );
533 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( s
[i
] & 0xff );
540 unpack_R_UNORM16(const void *src
, GLfloat dst
[][4], GLuint n
)
542 const GLushort
*s
= ((const GLushort
*) src
);
544 for (i
= 0; i
< n
; i
++) {
545 dst
[i
][RCOMP
] = USHORT_TO_FLOAT(s
[i
]);
553 unpack_R16G16_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
555 const GLuint
*s
= ((const GLuint
*) src
);
557 for (i
= 0; i
< n
; i
++) {
558 dst
[i
][RCOMP
] = USHORT_TO_FLOAT( s
[i
] & 0xffff );
559 dst
[i
][GCOMP
] = USHORT_TO_FLOAT( s
[i
] >> 16 );
566 unpack_G16R16_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
568 const GLuint
*s
= ((const GLuint
*) src
);
570 for (i
= 0; i
< n
; i
++) {
571 dst
[i
][RCOMP
] = USHORT_TO_FLOAT( s
[i
] >> 16 );
572 dst
[i
][GCOMP
] = USHORT_TO_FLOAT( s
[i
] & 0xffff );
579 unpack_B10G10R10A2_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
581 const GLuint
*s
= ((const GLuint
*) src
);
583 for (i
= 0; i
< n
; i
++) {
584 dst
[i
][RCOMP
] = ((s
[i
] >> 20) & 0x3ff) * (1.0F
/ 1023.0F
);
585 dst
[i
][GCOMP
] = ((s
[i
] >> 10) & 0x3ff) * (1.0F
/ 1023.0F
);
586 dst
[i
][BCOMP
] = ((s
[i
] >> 0) & 0x3ff) * (1.0F
/ 1023.0F
);
587 dst
[i
][ACOMP
] = ((s
[i
] >> 30) & 0x03) * (1.0F
/ 3.0F
);
593 unpack_B10G10R10A2_UINT(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
] = (GLfloat
)((s
[i
] >> 20) & 0x3ff);
599 dst
[i
][GCOMP
] = (GLfloat
)((s
[i
] >> 10) & 0x3ff);
600 dst
[i
][BCOMP
] = (GLfloat
)((s
[i
] >> 0) & 0x3ff);
601 dst
[i
][ACOMP
] = (GLfloat
)((s
[i
] >> 30) & 0x03);
607 unpack_R10G10B10A2_UINT(const void *src
, GLfloat dst
[][4], GLuint n
)
609 const GLuint
*s
= ((const GLuint
*) src
);
611 for (i
= 0; i
< n
; i
++) {
612 dst
[i
][RCOMP
] = (GLfloat
)((s
[i
] >> 0) & 0x3ff);
613 dst
[i
][GCOMP
] = (GLfloat
)((s
[i
] >> 10) & 0x3ff);
614 dst
[i
][BCOMP
] = (GLfloat
)((s
[i
] >> 20) & 0x3ff);
615 dst
[i
][ACOMP
] = (GLfloat
)((s
[i
] >> 30) & 0x03);
621 unpack_S8_UINT_Z24_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
623 /* only return Z, not stencil data */
624 const GLuint
*s
= ((const GLuint
*) src
);
625 const GLdouble scale
= 1.0 / (GLdouble
) 0xffffff;
627 for (i
= 0; i
< n
; i
++) {
630 dst
[i
][2] = (GLfloat
) ((s
[i
] >> 8) * scale
);
632 ASSERT(dst
[i
][0] >= 0.0F
);
633 ASSERT(dst
[i
][0] <= 1.0F
);
638 unpack_Z24_UNORM_S8_UINT(const void *src
, GLfloat dst
[][4], GLuint n
)
640 /* only return Z, not stencil data */
641 const GLuint
*s
= ((const GLuint
*) src
);
642 const GLdouble scale
= 1.0 / (GLdouble
) 0xffffff;
644 for (i
= 0; i
< n
; i
++) {
647 dst
[i
][2] = (float) ((s
[i
] & 0x00ffffff) * scale
);
649 ASSERT(dst
[i
][0] >= 0.0F
);
650 ASSERT(dst
[i
][0] <= 1.0F
);
655 unpack_Z_UNORM16(const void *src
, GLfloat dst
[][4], GLuint n
)
657 const GLushort
*s
= ((const GLushort
*) src
);
659 for (i
= 0; i
< n
; i
++) {
662 dst
[i
][2] = s
[i
] * (1.0F
/ 65535.0F
);
668 unpack_Z24_UNORM_X8_UINT(const void *src
, GLfloat dst
[][4], GLuint n
)
670 unpack_Z24_UNORM_S8_UINT(src
, dst
, n
);
674 unpack_X8_UINT_Z24_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
676 unpack_S8_UINT_Z24_UNORM(src
, dst
, n
);
680 unpack_Z_UNORM32(const void *src
, GLfloat dst
[][4], GLuint n
)
682 const GLuint
*s
= ((const GLuint
*) src
);
684 for (i
= 0; i
< n
; i
++) {
687 dst
[i
][2] = s
[i
] * (1.0F
/ 0xffffffff);
693 unpack_Z32_FLOAT_S8X24_UINT(const void *src
, GLfloat dst
[][4], GLuint n
)
695 const struct z32f_x24s8
*s
= (const struct z32f_x24s8
*) src
;
697 for (i
= 0; i
< n
; i
++) {
706 unpack_Z_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
708 const GLfloat
*s
= ((const GLfloat
*) src
);
710 for (i
= 0; i
< n
; i
++) {
720 unpack_S8(const void *src
, GLfloat dst
[][4], GLuint n
)
722 /* should never be used */
724 for (i
= 0; i
< n
; i
++) {
734 unpack_BGR_SRGB8(const void *src
, GLfloat dst
[][4], GLuint n
)
736 const GLubyte
*s
= (const GLubyte
*) src
;
738 for (i
= 0; i
< n
; i
++) {
739 dst
[i
][RCOMP
] = util_format_srgb_8unorm_to_linear_float(s
[i
*3+2]);
740 dst
[i
][GCOMP
] = util_format_srgb_8unorm_to_linear_float(s
[i
*3+1]);
741 dst
[i
][BCOMP
] = util_format_srgb_8unorm_to_linear_float(s
[i
*3+0]);
742 dst
[i
][ACOMP
] = 1.0F
;
747 unpack_A8B8G8R8_SRGB(const void *src
, GLfloat dst
[][4], GLuint n
)
749 const GLuint
*s
= ((const GLuint
*) src
);
751 for (i
= 0; i
< n
; i
++) {
752 dst
[i
][RCOMP
] = util_format_srgb_8unorm_to_linear_float( (s
[i
] >> 24) );
753 dst
[i
][GCOMP
] = util_format_srgb_8unorm_to_linear_float( (s
[i
] >> 16) & 0xff );
754 dst
[i
][BCOMP
] = util_format_srgb_8unorm_to_linear_float( (s
[i
] >> 8) & 0xff );
755 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( s
[i
] & 0xff ); /* linear! */
760 unpack_B8G8R8A8_SRGB(const void *src
, GLfloat dst
[][4], GLuint n
)
762 const GLuint
*s
= ((const GLuint
*) src
);
764 for (i
= 0; i
< n
; i
++) {
765 dst
[i
][RCOMP
] = util_format_srgb_8unorm_to_linear_float( (s
[i
] >> 16) & 0xff );
766 dst
[i
][GCOMP
] = util_format_srgb_8unorm_to_linear_float( (s
[i
] >> 8) & 0xff );
767 dst
[i
][BCOMP
] = util_format_srgb_8unorm_to_linear_float( (s
[i
] ) & 0xff );
768 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 24 ); /* linear! */
773 unpack_A8R8G8B8_SRGB(const void *src
, GLfloat dst
[][4], GLuint n
)
775 const GLuint
*s
= ((const GLuint
*) src
);
777 for (i
= 0; i
< n
; i
++) {
778 dst
[i
][RCOMP
] = util_format_srgb_8unorm_to_linear_float( (s
[i
] >> 8) & 0xff );
779 dst
[i
][GCOMP
] = util_format_srgb_8unorm_to_linear_float( (s
[i
] >> 16) & 0xff );
780 dst
[i
][BCOMP
] = util_format_srgb_8unorm_to_linear_float( (s
[i
] >> 24) );
781 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( s
[i
] & 0xff ); /* linear! */
786 unpack_R8G8B8A8_SRGB(const void *src
, GLfloat dst
[][4], GLuint n
)
788 const GLuint
*s
= ((const GLuint
*) src
);
790 for (i
= 0; i
< n
; i
++) {
791 dst
[i
][RCOMP
] = util_format_srgb_8unorm_to_linear_float( (s
[i
] ) & 0xff );
792 dst
[i
][GCOMP
] = util_format_srgb_8unorm_to_linear_float( (s
[i
] >> 8) & 0xff );
793 dst
[i
][BCOMP
] = util_format_srgb_8unorm_to_linear_float( (s
[i
] >> 16) & 0xff );
794 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 24 ); /* linear! */
799 unpack_L_SRGB8(const void *src
, GLfloat dst
[][4], GLuint n
)
801 const GLubyte
*s
= ((const GLubyte
*) src
);
803 for (i
= 0; i
< n
; i
++) {
806 dst
[i
][BCOMP
] = util_format_srgb_8unorm_to_linear_float(s
[i
]);
807 dst
[i
][ACOMP
] = 1.0F
;
812 unpack_L8A8_SRGB(const void *src
, GLfloat dst
[][4], GLuint n
)
814 const GLushort
*s
= (const GLushort
*) src
;
816 for (i
= 0; i
< n
; i
++) {
819 dst
[i
][BCOMP
] = util_format_srgb_8unorm_to_linear_float(s
[i
] & 0xff);
820 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT(s
[i
] >> 8); /* linear! */
825 unpack_A8L8_SRGB(const void *src
, GLfloat dst
[][4], GLuint n
)
827 const GLushort
*s
= (const GLushort
*) src
;
829 for (i
= 0; i
< n
; i
++) {
832 dst
[i
][BCOMP
] = util_format_srgb_8unorm_to_linear_float(s
[i
] >> 8);
833 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT(s
[i
] & 0xff); /* linear! */
838 unpack_SRGB_DXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
843 unpack_SRGBA_DXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
848 unpack_SRGBA_DXT3(const void *src
, GLfloat dst
[][4], GLuint n
)
853 unpack_SRGBA_DXT5(const void *src
, GLfloat dst
[][4], GLuint n
)
858 unpack_RGB_FXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
863 unpack_RGBA_FXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
868 unpack_RGB_DXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
873 unpack_RGBA_DXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
878 unpack_RGBA_DXT3(const void *src
, GLfloat dst
[][4], GLuint n
)
883 unpack_RGBA_DXT5(const void *src
, GLfloat dst
[][4], GLuint n
)
889 unpack_RGBA_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
891 const GLfloat
*s
= (const GLfloat
*) src
;
893 for (i
= 0; i
< n
; i
++) {
894 dst
[i
][RCOMP
] = s
[i
*4+0];
895 dst
[i
][GCOMP
] = s
[i
*4+1];
896 dst
[i
][BCOMP
] = s
[i
*4+2];
897 dst
[i
][ACOMP
] = s
[i
*4+3];
902 unpack_RGBA_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
904 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
906 for (i
= 0; i
< n
; i
++) {
907 dst
[i
][RCOMP
] = _mesa_half_to_float(s
[i
*4+0]);
908 dst
[i
][GCOMP
] = _mesa_half_to_float(s
[i
*4+1]);
909 dst
[i
][BCOMP
] = _mesa_half_to_float(s
[i
*4+2]);
910 dst
[i
][ACOMP
] = _mesa_half_to_float(s
[i
*4+3]);
915 unpack_RGB_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
917 const GLfloat
*s
= (const GLfloat
*) src
;
919 for (i
= 0; i
< n
; i
++) {
920 dst
[i
][RCOMP
] = s
[i
*3+0];
921 dst
[i
][GCOMP
] = s
[i
*3+1];
922 dst
[i
][BCOMP
] = s
[i
*3+2];
923 dst
[i
][ACOMP
] = 1.0F
;
928 unpack_RGB_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
930 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
932 for (i
= 0; i
< n
; i
++) {
933 dst
[i
][RCOMP
] = _mesa_half_to_float(s
[i
*3+0]);
934 dst
[i
][GCOMP
] = _mesa_half_to_float(s
[i
*3+1]);
935 dst
[i
][BCOMP
] = _mesa_half_to_float(s
[i
*3+2]);
936 dst
[i
][ACOMP
] = 1.0F
;
941 unpack_A_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
943 const GLfloat
*s
= (const GLfloat
*) src
;
945 for (i
= 0; i
< n
; i
++) {
948 dst
[i
][BCOMP
] = 0.0F
;
949 dst
[i
][ACOMP
] = s
[i
];
954 unpack_A_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
956 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
958 for (i
= 0; i
< n
; i
++) {
961 dst
[i
][BCOMP
] = 0.0F
;
962 dst
[i
][ACOMP
] = _mesa_half_to_float(s
[i
]);
967 unpack_L_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
969 const GLfloat
*s
= (const GLfloat
*) src
;
971 for (i
= 0; i
< n
; i
++) {
974 dst
[i
][BCOMP
] = s
[i
];
975 dst
[i
][ACOMP
] = 1.0F
;
980 unpack_L_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
982 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
984 for (i
= 0; i
< n
; i
++) {
987 dst
[i
][BCOMP
] = _mesa_half_to_float(s
[i
]);
988 dst
[i
][ACOMP
] = 1.0F
;
993 unpack_LA_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
995 const GLfloat
*s
= (const GLfloat
*) src
;
997 for (i
= 0; i
< n
; i
++) {
1000 dst
[i
][BCOMP
] = s
[i
*2+0];
1001 dst
[i
][ACOMP
] = s
[i
*2+1];
1006 unpack_LA_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1008 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
1010 for (i
= 0; i
< n
; i
++) {
1013 dst
[i
][BCOMP
] = _mesa_half_to_float(s
[i
*2+0]);
1014 dst
[i
][ACOMP
] = _mesa_half_to_float(s
[i
*2+1]);
1019 unpack_I_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1021 const GLfloat
*s
= (const GLfloat
*) src
;
1023 for (i
= 0; i
< n
; i
++) {
1027 dst
[i
][ACOMP
] = s
[i
];
1032 unpack_I_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1034 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
1036 for (i
= 0; i
< n
; i
++) {
1040 dst
[i
][ACOMP
] = _mesa_half_to_float(s
[i
]);
1045 unpack_R_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1047 const GLfloat
*s
= (const GLfloat
*) src
;
1049 for (i
= 0; i
< n
; i
++) {
1050 dst
[i
][RCOMP
] = s
[i
];
1051 dst
[i
][GCOMP
] = 0.0F
;
1052 dst
[i
][BCOMP
] = 0.0F
;
1053 dst
[i
][ACOMP
] = 1.0F
;
1058 unpack_R_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1060 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
1062 for (i
= 0; i
< n
; i
++) {
1063 dst
[i
][RCOMP
] = _mesa_half_to_float(s
[i
]);
1064 dst
[i
][GCOMP
] = 0.0F
;
1065 dst
[i
][BCOMP
] = 0.0F
;
1066 dst
[i
][ACOMP
] = 1.0F
;
1071 unpack_RG_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1073 const GLfloat
*s
= (const GLfloat
*) src
;
1075 for (i
= 0; i
< n
; i
++) {
1076 dst
[i
][RCOMP
] = s
[i
*2+0];
1077 dst
[i
][GCOMP
] = s
[i
*2+1];
1078 dst
[i
][BCOMP
] = 0.0F
;
1079 dst
[i
][ACOMP
] = 1.0F
;
1084 unpack_RG_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1086 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
1088 for (i
= 0; i
< n
; i
++) {
1089 dst
[i
][RCOMP
] = _mesa_half_to_float(s
[i
*2+0]);
1090 dst
[i
][GCOMP
] = _mesa_half_to_float(s
[i
*2+1]);
1091 dst
[i
][BCOMP
] = 0.0F
;
1092 dst
[i
][ACOMP
] = 1.0F
;
1097 unpack_ALPHA_UINT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1099 const GLubyte
*s
= (const GLubyte
*) src
;
1101 for (i
= 0; i
< n
; i
++) {
1104 dst
[i
][BCOMP
] = 0.0;
1105 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1110 unpack_ALPHA_UINT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1112 const GLushort
*s
= (const GLushort
*) src
;
1114 for (i
= 0; i
< n
; i
++) {
1117 dst
[i
][BCOMP
] = 0.0;
1118 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1123 unpack_ALPHA_UINT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1125 const GLuint
*s
= (const GLuint
*) src
;
1127 for (i
= 0; i
< n
; i
++) {
1130 dst
[i
][BCOMP
] = 0.0;
1131 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1136 unpack_ALPHA_INT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1138 const GLbyte
*s
= (const GLbyte
*) src
;
1140 for (i
= 0; i
< n
; i
++) {
1143 dst
[i
][BCOMP
] = 0.0;
1144 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1149 unpack_ALPHA_INT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1151 const GLshort
*s
= (const GLshort
*) src
;
1153 for (i
= 0; i
< n
; i
++) {
1156 dst
[i
][BCOMP
] = 0.0;
1157 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1162 unpack_ALPHA_INT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1164 const GLint
*s
= (const GLint
*) src
;
1166 for (i
= 0; i
< n
; i
++) {
1169 dst
[i
][BCOMP
] = 0.0;
1170 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1175 unpack_INTENSITY_UINT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1177 const GLubyte
*s
= (const GLubyte
*) src
;
1179 for (i
= 0; i
< n
; i
++) {
1183 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1188 unpack_INTENSITY_UINT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1190 const GLushort
*s
= (const GLushort
*) src
;
1192 for (i
= 0; i
< n
; i
++) {
1196 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1201 unpack_INTENSITY_UINT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1203 const GLuint
*s
= (const GLuint
*) src
;
1205 for (i
= 0; i
< n
; i
++) {
1209 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1214 unpack_INTENSITY_INT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1216 const GLbyte
*s
= (const GLbyte
*) src
;
1218 for (i
= 0; i
< n
; i
++) {
1222 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1227 unpack_INTENSITY_INT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1229 const GLshort
*s
= (const GLshort
*) src
;
1231 for (i
= 0; i
< n
; i
++) {
1235 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1240 unpack_INTENSITY_INT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1242 const GLint
*s
= (const GLint
*) src
;
1244 for (i
= 0; i
< n
; i
++) {
1248 dst
[i
][ACOMP
] = (GLfloat
) s
[i
];
1253 unpack_LUMINANCE_UINT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1255 const GLubyte
*s
= (const GLubyte
*) src
;
1257 for (i
= 0; i
< n
; i
++) {
1258 dst
[i
][RCOMP
] = dst
[i
][GCOMP
] = dst
[i
][BCOMP
] = (GLfloat
) s
[i
];
1259 dst
[i
][ACOMP
] = 1.0;
1264 unpack_LUMINANCE_UINT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1266 const GLushort
*s
= (const GLushort
*) src
;
1268 for (i
= 0; i
< n
; i
++) {
1269 dst
[i
][RCOMP
] = dst
[i
][GCOMP
] = dst
[i
][BCOMP
] = (GLfloat
) s
[i
];
1270 dst
[i
][ACOMP
] = 1.0;
1275 unpack_LUMINANCE_UINT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1277 const GLuint
*s
= (const GLuint
*) src
;
1279 for (i
= 0; i
< n
; i
++) {
1280 dst
[i
][RCOMP
] = dst
[i
][GCOMP
] = dst
[i
][BCOMP
] = (GLfloat
) s
[i
];
1281 dst
[i
][ACOMP
] = 1.0;
1286 unpack_LUMINANCE_INT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1288 const GLbyte
*s
= (const GLbyte
*) src
;
1290 for (i
= 0; i
< n
; i
++) {
1291 dst
[i
][RCOMP
] = dst
[i
][GCOMP
] = dst
[i
][BCOMP
] = (GLfloat
) s
[i
];
1292 dst
[i
][ACOMP
] = 1.0;
1297 unpack_LUMINANCE_INT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1299 const GLshort
*s
= (const GLshort
*) src
;
1301 for (i
= 0; i
< n
; i
++) {
1302 dst
[i
][RCOMP
] = dst
[i
][GCOMP
] = dst
[i
][BCOMP
] = (GLfloat
) s
[i
];
1303 dst
[i
][ACOMP
] = 1.0;
1308 unpack_LUMINANCE_INT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1310 const GLint
*s
= (const GLint
*) src
;
1312 for (i
= 0; i
< n
; i
++) {
1313 dst
[i
][RCOMP
] = dst
[i
][GCOMP
] = dst
[i
][BCOMP
] = (GLfloat
) s
[i
];
1314 dst
[i
][ACOMP
] = 1.0;
1319 unpack_LUMINANCE_ALPHA_UINT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1321 const GLubyte
*s
= (const GLubyte
*) src
;
1323 for (i
= 0; i
< n
; i
++) {
1326 dst
[i
][BCOMP
] = (GLfloat
) s
[2*i
+0];
1327 dst
[i
][ACOMP
] = (GLfloat
) s
[2*i
+1];
1332 unpack_LUMINANCE_ALPHA_UINT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1334 const GLushort
*s
= (const GLushort
*) src
;
1336 for (i
= 0; i
< n
; i
++) {
1339 dst
[i
][BCOMP
] = (GLfloat
) s
[2*i
+0];
1340 dst
[i
][ACOMP
] = (GLfloat
) s
[2*i
+1];
1345 unpack_LUMINANCE_ALPHA_UINT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1347 const GLuint
*s
= (const GLuint
*) src
;
1349 for (i
= 0; i
< n
; i
++) {
1352 dst
[i
][BCOMP
] = (GLfloat
) s
[2*i
+0];
1353 dst
[i
][ACOMP
] = (GLfloat
) s
[2*i
+1];
1358 unpack_LUMINANCE_ALPHA_INT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1360 const GLbyte
*s
= (const GLbyte
*) src
;
1362 for (i
= 0; i
< n
; i
++) {
1365 dst
[i
][BCOMP
] = (GLfloat
) s
[2*i
+0];
1366 dst
[i
][ACOMP
] = (GLfloat
) s
[2*i
+1];
1371 unpack_LUMINANCE_ALPHA_INT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1373 const GLshort
*s
= (const GLshort
*) src
;
1375 for (i
= 0; i
< n
; i
++) {
1378 dst
[i
][BCOMP
] = (GLfloat
) s
[2*i
+0];
1379 dst
[i
][ACOMP
] = (GLfloat
) s
[2*i
+1];
1384 unpack_LUMINANCE_ALPHA_INT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1386 const GLint
*s
= (const GLint
*) src
;
1388 for (i
= 0; i
< n
; i
++) {
1391 dst
[i
][BCOMP
] = (GLfloat
) s
[2*i
+0];
1392 dst
[i
][ACOMP
] = (GLfloat
) s
[2*i
+1];
1397 unpack_R_INT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1399 const GLbyte
*s
= (const GLbyte
*) src
;
1401 for (i
= 0; i
< n
; i
++) {
1402 dst
[i
][RCOMP
] = (GLfloat
) s
[i
];
1403 dst
[i
][GCOMP
] = 0.0;
1404 dst
[i
][BCOMP
] = 0.0;
1405 dst
[i
][ACOMP
] = 1.0;
1410 unpack_RG_INT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1412 const GLbyte
*s
= (const GLbyte
*) src
;
1414 for (i
= 0; i
< n
; i
++) {
1415 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*2+0];
1416 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*2+1];
1417 dst
[i
][BCOMP
] = 0.0;
1418 dst
[i
][ACOMP
] = 1.0;
1423 unpack_RGB_INT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1425 const GLbyte
*s
= (const GLbyte
*) src
;
1427 for (i
= 0; i
< n
; i
++) {
1428 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*3+0];
1429 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*3+1];
1430 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*3+2];
1431 dst
[i
][ACOMP
] = 1.0;
1436 unpack_RGBA_INT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1438 const GLbyte
*s
= (const GLbyte
*) src
;
1440 for (i
= 0; i
< n
; i
++) {
1441 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1442 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1443 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1444 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1449 unpack_R_INT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1451 const GLshort
*s
= (const GLshort
*) src
;
1453 for (i
= 0; i
< n
; i
++) {
1454 dst
[i
][RCOMP
] = (GLfloat
) s
[i
];
1455 dst
[i
][GCOMP
] = 0.0;
1456 dst
[i
][BCOMP
] = 0.0;
1457 dst
[i
][ACOMP
] = 1.0;
1462 unpack_RG_INT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1464 const GLshort
*s
= (const GLshort
*) src
;
1466 for (i
= 0; i
< n
; i
++) {
1467 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*2+0];
1468 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*2+1];
1469 dst
[i
][BCOMP
] = 0.0;
1470 dst
[i
][ACOMP
] = 1.0;
1475 unpack_RGB_INT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1477 const GLshort
*s
= (const GLshort
*) src
;
1479 for (i
= 0; i
< n
; i
++) {
1480 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*3+0];
1481 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*3+1];
1482 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*3+2];
1483 dst
[i
][ACOMP
] = 1.0;
1488 unpack_RGBA_INT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1490 const GLshort
*s
= (const GLshort
*) src
;
1492 for (i
= 0; i
< n
; i
++) {
1493 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1494 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1495 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1496 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1501 unpack_R_INT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1503 const GLint
*s
= (const GLint
*) src
;
1505 for (i
= 0; i
< n
; i
++) {
1506 dst
[i
][RCOMP
] = (GLfloat
) s
[i
];
1507 dst
[i
][GCOMP
] = 0.0;
1508 dst
[i
][BCOMP
] = 0.0;
1509 dst
[i
][ACOMP
] = 1.0;
1514 unpack_RG_INT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1516 const GLint
*s
= (const GLint
*) src
;
1518 for (i
= 0; i
< n
; i
++) {
1519 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*2+0];
1520 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*2+1];
1521 dst
[i
][BCOMP
] = 0.0;
1522 dst
[i
][ACOMP
] = 1.0;
1527 unpack_RGB_INT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1529 const GLint
*s
= (const GLint
*) src
;
1531 for (i
= 0; i
< n
; i
++) {
1532 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*3+0];
1533 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*3+1];
1534 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*3+2];
1535 dst
[i
][ACOMP
] = 1.0;
1541 unpack_RGBA_INT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1543 const GLint
*s
= (const GLint
*) src
;
1545 for (i
= 0; i
< n
; i
++) {
1546 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1547 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1548 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1549 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1554 unpack_R_UINT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1556 const GLubyte
*s
= (const GLubyte
*) src
;
1558 for (i
= 0; i
< n
; i
++) {
1559 dst
[i
][RCOMP
] = (GLfloat
) s
[i
];
1560 dst
[i
][GCOMP
] = 0.0;
1561 dst
[i
][BCOMP
] = 0.0;
1562 dst
[i
][ACOMP
] = 1.0;
1567 unpack_RG_UINT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1569 const GLubyte
*s
= (const GLubyte
*) src
;
1571 for (i
= 0; i
< n
; i
++) {
1572 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*2+0];
1573 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*2+1];
1574 dst
[i
][BCOMP
] = 0.0;
1575 dst
[i
][ACOMP
] = 1.0;
1580 unpack_RGB_UINT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1582 const GLubyte
*s
= (const GLubyte
*) src
;
1584 for (i
= 0; i
< n
; i
++) {
1585 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*3+0];
1586 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*3+1];
1587 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*3+2];
1588 dst
[i
][ACOMP
] = 1.0;
1593 unpack_RGBA_UINT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1595 const GLubyte
*s
= (const GLubyte
*) src
;
1597 for (i
= 0; i
< n
; i
++) {
1598 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1599 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1600 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1601 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1606 unpack_R_UINT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1608 const GLushort
*s
= (const GLushort
*) src
;
1610 for (i
= 0; i
< n
; i
++) {
1611 dst
[i
][RCOMP
] = (GLfloat
) s
[i
];
1612 dst
[i
][GCOMP
] = 0.0;
1613 dst
[i
][BCOMP
] = 0.0;
1614 dst
[i
][ACOMP
] = 1.0;
1619 unpack_RG_UINT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1621 const GLushort
*s
= (const GLushort
*) src
;
1623 for (i
= 0; i
< n
; i
++) {
1624 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*2+0];
1625 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*2+1];
1626 dst
[i
][BCOMP
] = 0.0;
1627 dst
[i
][ACOMP
] = 1.0;
1632 unpack_RGB_UINT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1634 const GLushort
*s
= (const GLushort
*) src
;
1636 for (i
= 0; i
< n
; i
++) {
1637 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*3+0];
1638 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*3+1];
1639 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*3+2];
1640 dst
[i
][ACOMP
] = 1.0;
1645 unpack_RGBA_UINT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1647 const GLushort
*s
= (const GLushort
*) src
;
1649 for (i
= 0; i
< n
; i
++) {
1650 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1651 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1652 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1653 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1658 unpack_R_UINT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1660 const GLuint
*s
= (const GLuint
*) src
;
1662 for (i
= 0; i
< n
; i
++) {
1663 dst
[i
][RCOMP
] = (GLfloat
) s
[i
];
1664 dst
[i
][GCOMP
] = 0.0;
1665 dst
[i
][BCOMP
] = 0.0;
1666 dst
[i
][ACOMP
] = 1.0;
1671 unpack_RG_UINT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1673 const GLuint
*s
= (const GLuint
*) src
;
1675 for (i
= 0; i
< n
; i
++) {
1676 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*2+0];
1677 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*2+1];
1678 dst
[i
][BCOMP
] = 0.0;
1679 dst
[i
][ACOMP
] = 1.0;
1684 unpack_RGB_UINT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1686 const GLuint
*s
= (const GLuint
*) src
;
1688 for (i
= 0; i
< n
; i
++) {
1689 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*3+0];
1690 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*3+1];
1691 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*3+2];
1692 dst
[i
][ACOMP
] = 1.0;
1697 unpack_RGBA_UINT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1699 const GLuint
*s
= (const GLuint
*) src
;
1701 for (i
= 0; i
< n
; i
++) {
1702 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1703 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1704 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1705 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1710 unpack_R_SNORM8(const void *src
, GLfloat dst
[][4], GLuint n
)
1712 const GLbyte
*s
= ((const GLbyte
*) src
);
1714 for (i
= 0; i
< n
; i
++) {
1715 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( s
[i
] );
1716 dst
[i
][GCOMP
] = 0.0F
;
1717 dst
[i
][BCOMP
] = 0.0F
;
1718 dst
[i
][ACOMP
] = 1.0F
;
1723 unpack_R8G8_SNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
1725 const GLushort
*s
= ((const GLushort
*) src
);
1727 for (i
= 0; i
< n
; i
++) {
1728 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] & 0xff) );
1729 dst
[i
][GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
1730 dst
[i
][BCOMP
] = 0.0F
;
1731 dst
[i
][ACOMP
] = 1.0F
;
1736 unpack_X8B8G8R8_SNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
1738 const GLuint
*s
= ((const GLuint
*) src
);
1740 for (i
= 0; i
< n
; i
++) {
1741 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 24) );
1742 dst
[i
][GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 16) );
1743 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
1744 dst
[i
][ACOMP
] = 1.0f
;
1749 unpack_A8B8G8R8_SNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
1751 const GLuint
*s
= ((const GLuint
*) src
);
1753 for (i
= 0; i
< n
; i
++) {
1754 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 24) );
1755 dst
[i
][GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 16) );
1756 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
1757 dst
[i
][ACOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] ) );
1762 unpack_R8G8B8A8_SNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
1764 const GLuint
*s
= ((const GLuint
*) src
);
1766 for (i
= 0; i
< n
; i
++) {
1767 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] ) );
1768 dst
[i
][GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
1769 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 16) );
1770 dst
[i
][ACOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 24) );
1775 unpack_R_SNORM16(const void *src
, GLfloat dst
[][4], GLuint n
)
1777 const GLshort
*s
= ((const GLshort
*) src
);
1779 for (i
= 0; i
< n
; i
++) {
1780 dst
[i
][RCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
] );
1781 dst
[i
][GCOMP
] = 0.0F
;
1782 dst
[i
][BCOMP
] = 0.0F
;
1783 dst
[i
][ACOMP
] = 1.0F
;
1788 unpack_R16G16_SNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
1790 const GLuint
*s
= ((const GLuint
*) src
);
1792 for (i
= 0; i
< n
; i
++) {
1793 dst
[i
][RCOMP
] = SHORT_TO_FLOAT_TEX( (GLshort
) (s
[i
] & 0xffff) );
1794 dst
[i
][GCOMP
] = SHORT_TO_FLOAT_TEX( (GLshort
) (s
[i
] >> 16) );
1795 dst
[i
][BCOMP
] = 0.0F
;
1796 dst
[i
][ACOMP
] = 1.0F
;
1801 unpack_RGB_SNORM16(const void *src
, GLfloat dst
[][4], GLuint n
)
1803 const GLshort
*s
= (const GLshort
*) src
;
1805 for (i
= 0; i
< n
; i
++) {
1806 dst
[i
][RCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*3+0] );
1807 dst
[i
][GCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*3+1] );
1808 dst
[i
][BCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*3+2] );
1809 dst
[i
][ACOMP
] = 1.0F
;
1814 unpack_RGBA_SNORM16(const void *src
, GLfloat dst
[][4], GLuint n
)
1816 const GLshort
*s
= (const GLshort
*) src
;
1818 for (i
= 0; i
< n
; i
++) {
1819 dst
[i
][RCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+0] );
1820 dst
[i
][GCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+1] );
1821 dst
[i
][BCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+2] );
1822 dst
[i
][ACOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+3] );
1827 unpack_RGBA_16(const void *src
, GLfloat dst
[][4], GLuint n
)
1829 const GLushort
*s
= (const GLushort
*) src
;
1831 for (i
= 0; i
< n
; i
++) {
1832 dst
[i
][RCOMP
] = USHORT_TO_FLOAT( s
[i
*4+0] );
1833 dst
[i
][GCOMP
] = USHORT_TO_FLOAT( s
[i
*4+1] );
1834 dst
[i
][BCOMP
] = USHORT_TO_FLOAT( s
[i
*4+2] );
1835 dst
[i
][ACOMP
] = USHORT_TO_FLOAT( s
[i
*4+3] );
1840 unpack_RED_RGTC1(const void *src
, GLfloat dst
[][4], GLuint n
)
1846 unpack_SIGNED_RED_RGTC1(const void *src
, GLfloat dst
[][4], GLuint n
)
1852 unpack_RG_RGTC2(const void *src
, GLfloat dst
[][4], GLuint n
)
1858 unpack_SIGNED_RG_RGTC2(const void *src
, GLfloat dst
[][4], GLuint n
)
1864 unpack_L_LATC1(const void *src
, GLfloat dst
[][4], GLuint n
)
1870 unpack_SIGNED_L_LATC1(const void *src
, GLfloat dst
[][4], GLuint n
)
1876 unpack_LA_LATC2(const void *src
, GLfloat dst
[][4], GLuint n
)
1882 unpack_SIGNED_LA_LATC2(const void *src
, GLfloat dst
[][4], GLuint n
)
1888 unpack_ETC1_RGB8(const void *src
, GLfloat dst
[][4], GLuint n
)
1894 unpack_ETC2_RGB8(const void *src
, GLfloat dst
[][4], GLuint n
)
1900 unpack_ETC2_SRGB8(const void *src
, GLfloat dst
[][4], GLuint n
)
1906 unpack_ETC2_RGBA8_EAC(const void *src
, GLfloat dst
[][4], GLuint n
)
1912 unpack_ETC2_SRGB8_ALPHA8_EAC(const void *src
, GLfloat dst
[][4], GLuint n
)
1918 unpack_ETC2_R11_EAC(const void *src
, GLfloat dst
[][4], GLuint n
)
1924 unpack_ETC2_RG11_EAC(const void *src
, GLfloat dst
[][4], GLuint n
)
1930 unpack_ETC2_SIGNED_R11_EAC(const void *src
, GLfloat dst
[][4], GLuint n
)
1936 unpack_ETC2_SIGNED_RG11_EAC(const void *src
, GLfloat dst
[][4], GLuint n
)
1942 unpack_ETC2_RGB8_PUNCHTHROUGH_ALPHA1(const void *src
, GLfloat dst
[][4],
1949 unpack_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1(const void *src
, GLfloat dst
[][4],
1956 unpack_A_SNORM8(const void *src
, GLfloat dst
[][4], GLuint n
)
1958 const GLbyte
*s
= ((const GLbyte
*) src
);
1960 for (i
= 0; i
< n
; i
++) {
1961 dst
[i
][RCOMP
] = 0.0F
;
1962 dst
[i
][GCOMP
] = 0.0F
;
1963 dst
[i
][BCOMP
] = 0.0F
;
1964 dst
[i
][ACOMP
] = BYTE_TO_FLOAT_TEX( s
[i
] );
1969 unpack_L_SNORM8(const void *src
, GLfloat dst
[][4], GLuint n
)
1971 const GLbyte
*s
= ((const GLbyte
*) src
);
1973 for (i
= 0; i
< n
; i
++) {
1976 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( s
[i
] );
1977 dst
[i
][ACOMP
] = 1.0F
;
1982 unpack_L8A8_SNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
1984 const GLshort
*s
= ((const GLshort
*) src
);
1986 for (i
= 0; i
< n
; i
++) {
1989 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] & 0xff) );
1990 dst
[i
][ACOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
1996 unpack_A8L8_SNORM(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
] >> 8) );
2004 dst
[i
][ACOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] & 0xff) );
2009 unpack_I_SNORM8(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_A_SNORM16(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_L_SNORM16(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_LA_SNORM16(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_I_SNORM16(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_R8G8B8X8_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
] = util_format_srgb_8unorm_to_linear_float( (s
[i
] ) & 0xff );
2141 dst
[i
][GCOMP
] = util_format_srgb_8unorm_to_linear_float( (s
[i
] >> 8) & 0xff );
2142 dst
[i
][BCOMP
] = util_format_srgb_8unorm_to_linear_float( (s
[i
] >> 16) & 0xff );
2143 dst
[i
][ACOMP
] = 1.0f
;
2148 unpack_X8B8G8R8_SRGB(const void *src
, GLfloat dst
[][4], GLuint n
)
2150 const GLuint
*s
= ((const GLuint
*) src
);
2152 for (i
= 0; i
< n
; i
++) {
2153 dst
[i
][RCOMP
] = util_format_srgb_8unorm_to_linear_float( (s
[i
] >> 24) );
2154 dst
[i
][GCOMP
] = util_format_srgb_8unorm_to_linear_float( (s
[i
] >> 16) & 0xff );
2155 dst
[i
][BCOMP
] = util_format_srgb_8unorm_to_linear_float( (s
[i
] >> 8) & 0xff );
2156 dst
[i
][ACOMP
] = 1.0f
;
2161 unpack_XBGR8888_UINT(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_XBGR8888_SINT(const void *src
, GLfloat dst
[][4], GLuint n
)
2176 const GLbyte
*s
= (const GLbyte
*) src
;
2178 for (i
= 0; i
< n
; i
++) {
2179 dst
[i
][RCOMP
] = s
[i
*4+0];
2180 dst
[i
][GCOMP
] = s
[i
*4+1];
2181 dst
[i
][BCOMP
] = s
[i
*4+2];
2182 dst
[i
][ACOMP
] = 1.0;
2187 unpack_B10G10R10X2_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
2189 const GLuint
*s
= ((const GLuint
*) src
);
2191 for (i
= 0; i
< n
; i
++) {
2192 dst
[i
][RCOMP
] = ((s
[i
] >> 20) & 0x3ff) * (1.0F
/ 1023.0F
);
2193 dst
[i
][GCOMP
] = ((s
[i
] >> 10) & 0x3ff) * (1.0F
/ 1023.0F
);
2194 dst
[i
][BCOMP
] = ((s
[i
] >> 0) & 0x3ff) * (1.0F
/ 1023.0F
);
2195 dst
[i
][ACOMP
] = 1.0;
2200 unpack_RGBX_UNORM16(const void *src
, GLfloat dst
[][4], GLuint n
)
2202 const GLushort
*s
= (const GLushort
*) src
;
2204 for (i
= 0; i
< n
; i
++) {
2205 dst
[i
][RCOMP
] = USHORT_TO_FLOAT( s
[i
*4+0] );
2206 dst
[i
][GCOMP
] = USHORT_TO_FLOAT( s
[i
*4+1] );
2207 dst
[i
][BCOMP
] = USHORT_TO_FLOAT( s
[i
*4+2] );
2208 dst
[i
][ACOMP
] = 1.0;
2213 unpack_RGBX_SNORM16(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
] = SHORT_TO_FLOAT_TEX( s
[i
*4+0] );
2219 dst
[i
][GCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+1] );
2220 dst
[i
][BCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+2] );
2221 dst
[i
][ACOMP
] = 1.0;
2226 unpack_XBGR16161616_FLOAT(const void *src
, GLfloat dst
[][4], GLuint n
)
2228 const GLshort
*s
= (const GLshort
*) src
;
2230 for (i
= 0; i
< n
; i
++) {
2231 dst
[i
][RCOMP
] = _mesa_half_to_float(s
[i
*4+0]);
2232 dst
[i
][GCOMP
] = _mesa_half_to_float(s
[i
*4+1]);
2233 dst
[i
][BCOMP
] = _mesa_half_to_float(s
[i
*4+2]);
2234 dst
[i
][ACOMP
] = 1.0;
2239 unpack_XBGR16161616_UINT(const void *src
, GLfloat dst
[][4], GLuint n
)
2241 const GLushort
*s
= (const GLushort
*) 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_XBGR16161616_SINT(const void *src
, GLfloat dst
[][4], GLuint n
)
2254 const GLshort
*s
= (const GLshort
*) src
;
2256 for (i
= 0; i
< n
; i
++) {
2257 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
2258 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
2259 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
2260 dst
[i
][ACOMP
] = 1.0;
2265 unpack_RGBX_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
2267 const GLfloat
*s
= (const GLfloat
*) src
;
2269 for (i
= 0; i
< n
; i
++) {
2270 dst
[i
][RCOMP
] = s
[i
*4+0];
2271 dst
[i
][GCOMP
] = s
[i
*4+1];
2272 dst
[i
][BCOMP
] = s
[i
*4+2];
2273 dst
[i
][ACOMP
] = 1.0;
2278 unpack_XBGR32323232_UINT(const void *src
, GLfloat dst
[][4], GLuint n
)
2280 const GLuint
*s
= (const GLuint
*) src
;
2282 for (i
= 0; i
< n
; i
++) {
2283 dst
[i
][RCOMP
] = (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_XBGR32323232_SINT(const void *src
, GLfloat dst
[][4], GLuint n
)
2293 const GLint
*s
= (const GLint
*) src
;
2295 for (i
= 0; i
< n
; i
++) {
2296 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
2297 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
2298 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
2299 dst
[i
][ACOMP
] = 1.0;
2304 unpack_R10G10B10A2_UNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
2306 const GLuint
*s
= ((const GLuint
*) src
);
2308 for (i
= 0; i
< n
; i
++) {
2309 dst
[i
][RCOMP
] = ((s
[i
] >> 0) & 0x3ff) * (1.0F
/ 1023.0F
);
2310 dst
[i
][GCOMP
] = ((s
[i
] >> 10) & 0x3ff) * (1.0F
/ 1023.0F
);
2311 dst
[i
][BCOMP
] = ((s
[i
] >> 20) & 0x3ff) * (1.0F
/ 1023.0F
);
2312 dst
[i
][ACOMP
] = ((s
[i
] >> 30) & 0x03) * (1.0F
/ 3.0F
);
2317 unpack_G8R8_SNORM(const void *src
, GLfloat dst
[][4], GLuint n
)
2319 const GLushort
*s
= ((const GLushort
*) src
);
2321 for (i
= 0; i
< n
; i
++) {
2322 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
2323 dst
[i
][GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] & 0xff) );
2324 dst
[i
][BCOMP
] = 0.0F
;
2325 dst
[i
][ACOMP
] = 1.0F
;
2330 unpack_G16R16_SNORM(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
] = SHORT_TO_FLOAT_TEX( (GLshort
) (s
[i
] >> 16) );
2336 dst
[i
][GCOMP
] = SHORT_TO_FLOAT_TEX( (GLshort
) (s
[i
] & 0xffff) );
2337 dst
[i
][BCOMP
] = 0.0F
;
2338 dst
[i
][ACOMP
] = 1.0F
;
2343 unpack_B8G8R8X8_SRGB(const void *src
, GLfloat dst
[][4], GLuint n
)
2345 const GLuint
*s
= ((const GLuint
*) src
);
2347 for (i
= 0; i
< n
; i
++) {
2348 dst
[i
][RCOMP
] = util_format_srgb_8unorm_to_linear_float( (s
[i
] >> 16) & 0xff );
2349 dst
[i
][GCOMP
] = util_format_srgb_8unorm_to_linear_float( (s
[i
] >> 8) & 0xff );
2350 dst
[i
][BCOMP
] = util_format_srgb_8unorm_to_linear_float( (s
[i
] ) & 0xff );
2351 dst
[i
][ACOMP
] = 1.0F
;
2356 unpack_X8R8G8B8_SRGB(const void *src
, GLfloat dst
[][4], GLuint n
)
2358 const GLuint
*s
= ((const GLuint
*) src
);
2360 for (i
= 0; i
< n
; i
++) {
2361 dst
[i
][RCOMP
] = util_format_srgb_8unorm_to_linear_float( (s
[i
] >> 8) & 0xff );
2362 dst
[i
][GCOMP
] = util_format_srgb_8unorm_to_linear_float( (s
[i
] >> 16) & 0xff );
2363 dst
[i
][BCOMP
] = util_format_srgb_8unorm_to_linear_float( (s
[i
] >> 24) );
2364 dst
[i
][ACOMP
] = 1.0F
;
2369 * Return the unpacker function for the given format.
2371 static unpack_rgba_func
2372 get_unpack_rgba_function(mesa_format format
)
2374 static unpack_rgba_func table
[MESA_FORMAT_COUNT
];
2375 static GLboolean initialized
= GL_FALSE
;
2378 table
[MESA_FORMAT_NONE
] = NULL
;
2380 table
[MESA_FORMAT_A8B8G8R8_UNORM
] = unpack_A8B8G8R8_UNORM
;
2381 table
[MESA_FORMAT_R8G8B8A8_UNORM
] = unpack_R8G8B8A8_UNORM
;
2382 table
[MESA_FORMAT_B8G8R8A8_UNORM
] = unpack_B8G8R8A8_UNORM
;
2383 table
[MESA_FORMAT_A8R8G8B8_UNORM
] = unpack_A8R8G8B8_UNORM
;
2384 table
[MESA_FORMAT_X8B8G8R8_UNORM
] = unpack_RGBX8888
;
2385 table
[MESA_FORMAT_R8G8B8X8_UNORM
] = unpack_RGBX8888_REV
;
2386 table
[MESA_FORMAT_B8G8R8X8_UNORM
] = unpack_B8G8R8X8_UNORM
;
2387 table
[MESA_FORMAT_X8R8G8B8_UNORM
] = unpack_X8R8G8B8_UNORM
;
2388 table
[MESA_FORMAT_BGR_UNORM8
] = unpack_BGR_UNORM8
;
2389 table
[MESA_FORMAT_RGB_UNORM8
] = unpack_RGB_UNORM8
;
2390 table
[MESA_FORMAT_B5G6R5_UNORM
] = unpack_B5G6R5_UNORM
;
2391 table
[MESA_FORMAT_R5G6B5_UNORM
] = unpack_R5G6B5_UNORM
;
2392 table
[MESA_FORMAT_B4G4R4A4_UNORM
] = unpack_B4G4R4A4_UNORM
;
2393 table
[MESA_FORMAT_A4R4G4B4_UNORM
] = unpack_A4R4G4B4_UNORM
;
2394 table
[MESA_FORMAT_A1B5G5R5_UNORM
] = unpack_A1B5G5R5_UNORM
;
2395 table
[MESA_FORMAT_B5G5R5A1_UNORM
] = unpack_B5G5R5A1_UNORM
;
2396 table
[MESA_FORMAT_A1R5G5B5_UNORM
] = unpack_A1R5G5B5_UNORM
;
2397 table
[MESA_FORMAT_L4A4_UNORM
] = unpack_L4A4_UNORM
;
2398 table
[MESA_FORMAT_L8A8_UNORM
] = unpack_L8A8_UNORM
;
2399 table
[MESA_FORMAT_A8L8_UNORM
] = unpack_A8L8_UNORM
;
2400 table
[MESA_FORMAT_L16A16_UNORM
] = unpack_L16A16_UNORM
;
2401 table
[MESA_FORMAT_A16L16_UNORM
] = unpack_A16L16_UNORM
;
2402 table
[MESA_FORMAT_B2G3R3_UNORM
] = unpack_B2G3R3_UNORM
;
2403 table
[MESA_FORMAT_A_UNORM8
] = unpack_A_UNORM8
;
2404 table
[MESA_FORMAT_A_UNORM16
] = unpack_A_UNORM16
;
2405 table
[MESA_FORMAT_L_UNORM8
] = unpack_L_UNORM8
;
2406 table
[MESA_FORMAT_L_UNORM16
] = unpack_L_UNORM16
;
2407 table
[MESA_FORMAT_I_UNORM8
] = unpack_I_UNORM8
;
2408 table
[MESA_FORMAT_I_UNORM16
] = unpack_I_UNORM16
;
2409 table
[MESA_FORMAT_YCBCR
] = unpack_YCBCR
;
2410 table
[MESA_FORMAT_YCBCR_REV
] = unpack_YCBCR_REV
;
2411 table
[MESA_FORMAT_R_UNORM8
] = unpack_R_UNORM8
;
2412 table
[MESA_FORMAT_R8G8_UNORM
] = unpack_R8G8_UNORM
;
2413 table
[MESA_FORMAT_G8R8_UNORM
] = unpack_G8R8_UNORM
;
2414 table
[MESA_FORMAT_R_UNORM16
] = unpack_R_UNORM16
;
2415 table
[MESA_FORMAT_R16G16_UNORM
] = unpack_R16G16_UNORM
;
2416 table
[MESA_FORMAT_G16R16_UNORM
] = unpack_G16R16_UNORM
;
2417 table
[MESA_FORMAT_B10G10R10A2_UNORM
] = unpack_B10G10R10A2_UNORM
;
2418 table
[MESA_FORMAT_B10G10R10A2_UINT
] = unpack_B10G10R10A2_UINT
;
2419 table
[MESA_FORMAT_R10G10B10A2_UINT
] = unpack_R10G10B10A2_UINT
;
2420 table
[MESA_FORMAT_S8_UINT_Z24_UNORM
] = unpack_S8_UINT_Z24_UNORM
;
2421 table
[MESA_FORMAT_Z24_UNORM_S8_UINT
] = unpack_Z24_UNORM_S8_UINT
;
2422 table
[MESA_FORMAT_Z_UNORM16
] = unpack_Z_UNORM16
;
2423 table
[MESA_FORMAT_Z24_UNORM_X8_UINT
] = unpack_Z24_UNORM_X8_UINT
;
2424 table
[MESA_FORMAT_X8_UINT_Z24_UNORM
] = unpack_X8_UINT_Z24_UNORM
;
2425 table
[MESA_FORMAT_Z_UNORM32
] = unpack_Z_UNORM32
;
2426 table
[MESA_FORMAT_S_UINT8
] = unpack_S8
;
2427 table
[MESA_FORMAT_BGR_SRGB8
] = unpack_BGR_SRGB8
;
2428 table
[MESA_FORMAT_A8B8G8R8_SRGB
] = unpack_A8B8G8R8_SRGB
;
2429 table
[MESA_FORMAT_B8G8R8A8_SRGB
] = unpack_B8G8R8A8_SRGB
;
2430 table
[MESA_FORMAT_A8R8G8B8_SRGB
] = unpack_A8R8G8B8_SRGB
;
2431 table
[MESA_FORMAT_R8G8B8A8_SRGB
] = unpack_R8G8B8A8_SRGB
;
2432 table
[MESA_FORMAT_L_SRGB8
] = unpack_L_SRGB8
;
2433 table
[MESA_FORMAT_L8A8_SRGB
] = unpack_L8A8_SRGB
;
2434 table
[MESA_FORMAT_A8L8_SRGB
] = unpack_A8L8_SRGB
;
2435 table
[MESA_FORMAT_SRGB_DXT1
] = unpack_SRGB_DXT1
;
2436 table
[MESA_FORMAT_SRGBA_DXT1
] = unpack_SRGBA_DXT1
;
2437 table
[MESA_FORMAT_SRGBA_DXT3
] = unpack_SRGBA_DXT3
;
2438 table
[MESA_FORMAT_SRGBA_DXT5
] = unpack_SRGBA_DXT5
;
2440 table
[MESA_FORMAT_RGB_FXT1
] = unpack_RGB_FXT1
;
2441 table
[MESA_FORMAT_RGBA_FXT1
] = unpack_RGBA_FXT1
;
2442 table
[MESA_FORMAT_RGB_DXT1
] = unpack_RGB_DXT1
;
2443 table
[MESA_FORMAT_RGBA_DXT1
] = unpack_RGBA_DXT1
;
2444 table
[MESA_FORMAT_RGBA_DXT3
] = unpack_RGBA_DXT3
;
2445 table
[MESA_FORMAT_RGBA_DXT5
] = unpack_RGBA_DXT5
;
2447 table
[MESA_FORMAT_RGBA_FLOAT32
] = unpack_RGBA_FLOAT32
;
2448 table
[MESA_FORMAT_RGBA_FLOAT16
] = unpack_RGBA_FLOAT16
;
2449 table
[MESA_FORMAT_RGB_FLOAT32
] = unpack_RGB_FLOAT32
;
2450 table
[MESA_FORMAT_RGB_FLOAT16
] = unpack_RGB_FLOAT16
;
2451 table
[MESA_FORMAT_A_FLOAT32
] = unpack_A_FLOAT32
;
2452 table
[MESA_FORMAT_A_FLOAT16
] = unpack_A_FLOAT16
;
2453 table
[MESA_FORMAT_L_FLOAT32
] = unpack_L_FLOAT32
;
2454 table
[MESA_FORMAT_L_FLOAT16
] = unpack_L_FLOAT16
;
2455 table
[MESA_FORMAT_LA_FLOAT32
] = unpack_LA_FLOAT32
;
2456 table
[MESA_FORMAT_LA_FLOAT16
] = unpack_LA_FLOAT16
;
2457 table
[MESA_FORMAT_I_FLOAT32
] = unpack_I_FLOAT32
;
2458 table
[MESA_FORMAT_I_FLOAT16
] = unpack_I_FLOAT16
;
2459 table
[MESA_FORMAT_R_FLOAT32
] = unpack_R_FLOAT32
;
2460 table
[MESA_FORMAT_R_FLOAT16
] = unpack_R_FLOAT16
;
2461 table
[MESA_FORMAT_RG_FLOAT32
] = unpack_RG_FLOAT32
;
2462 table
[MESA_FORMAT_RG_FLOAT16
] = unpack_RG_FLOAT16
;
2464 table
[MESA_FORMAT_A_UINT8
] = unpack_ALPHA_UINT8
;
2465 table
[MESA_FORMAT_A_UINT16
] = unpack_ALPHA_UINT16
;
2466 table
[MESA_FORMAT_A_UINT32
] = unpack_ALPHA_UINT32
;
2467 table
[MESA_FORMAT_A_SINT8
] = unpack_ALPHA_INT8
;
2468 table
[MESA_FORMAT_A_SINT16
] = unpack_ALPHA_INT16
;
2469 table
[MESA_FORMAT_A_SINT32
] = unpack_ALPHA_INT32
;
2471 table
[MESA_FORMAT_I_UINT8
] = unpack_INTENSITY_UINT8
;
2472 table
[MESA_FORMAT_I_UINT16
] = unpack_INTENSITY_UINT16
;
2473 table
[MESA_FORMAT_I_UINT32
] = unpack_INTENSITY_UINT32
;
2474 table
[MESA_FORMAT_I_SINT8
] = unpack_INTENSITY_INT8
;
2475 table
[MESA_FORMAT_I_SINT16
] = unpack_INTENSITY_INT16
;
2476 table
[MESA_FORMAT_I_SINT32
] = unpack_INTENSITY_INT32
;
2478 table
[MESA_FORMAT_L_UINT8
] = unpack_LUMINANCE_UINT8
;
2479 table
[MESA_FORMAT_L_UINT16
] = unpack_LUMINANCE_UINT16
;
2480 table
[MESA_FORMAT_L_UINT32
] = unpack_LUMINANCE_UINT32
;
2481 table
[MESA_FORMAT_L_SINT8
] = unpack_LUMINANCE_INT8
;
2482 table
[MESA_FORMAT_L_SINT16
] = unpack_LUMINANCE_INT16
;
2483 table
[MESA_FORMAT_L_SINT32
] = unpack_LUMINANCE_INT32
;
2485 table
[MESA_FORMAT_LA_UINT8
] = unpack_LUMINANCE_ALPHA_UINT8
;
2486 table
[MESA_FORMAT_LA_UINT16
] = unpack_LUMINANCE_ALPHA_UINT16
;
2487 table
[MESA_FORMAT_LA_UINT32
] = unpack_LUMINANCE_ALPHA_UINT32
;
2488 table
[MESA_FORMAT_LA_SINT8
] = unpack_LUMINANCE_ALPHA_INT8
;
2489 table
[MESA_FORMAT_LA_SINT16
] = unpack_LUMINANCE_ALPHA_INT16
;
2490 table
[MESA_FORMAT_LA_SINT32
] = unpack_LUMINANCE_ALPHA_INT32
;
2492 table
[MESA_FORMAT_R_SINT8
] = unpack_R_INT8
;
2493 table
[MESA_FORMAT_RG_SINT8
] = unpack_RG_INT8
;
2494 table
[MESA_FORMAT_RGB_SINT8
] = unpack_RGB_INT8
;
2495 table
[MESA_FORMAT_RGBA_SINT8
] = unpack_RGBA_INT8
;
2496 table
[MESA_FORMAT_R_SINT16
] = unpack_R_INT16
;
2497 table
[MESA_FORMAT_RG_SINT16
] = unpack_RG_INT16
;
2498 table
[MESA_FORMAT_RGB_SINT16
] = unpack_RGB_INT16
;
2499 table
[MESA_FORMAT_RGBA_SINT16
] = unpack_RGBA_INT16
;
2500 table
[MESA_FORMAT_R_SINT32
] = unpack_R_INT32
;
2501 table
[MESA_FORMAT_RG_SINT32
] = unpack_RG_INT32
;
2502 table
[MESA_FORMAT_RGB_SINT32
] = unpack_RGB_INT32
;
2503 table
[MESA_FORMAT_RGBA_SINT32
] = unpack_RGBA_INT32
;
2504 table
[MESA_FORMAT_R_UINT8
] = unpack_R_UINT8
;
2505 table
[MESA_FORMAT_RG_UINT8
] = unpack_RG_UINT8
;
2506 table
[MESA_FORMAT_RGB_UINT8
] = unpack_RGB_UINT8
;
2507 table
[MESA_FORMAT_RGBA_UINT8
] = unpack_RGBA_UINT8
;
2508 table
[MESA_FORMAT_R_UINT16
] = unpack_R_UINT16
;
2509 table
[MESA_FORMAT_RG_UINT16
] = unpack_RG_UINT16
;
2510 table
[MESA_FORMAT_RGB_UINT16
] = unpack_RGB_UINT16
;
2511 table
[MESA_FORMAT_RGBA_UINT16
] = unpack_RGBA_UINT16
;
2512 table
[MESA_FORMAT_R_UINT32
] = unpack_R_UINT32
;
2513 table
[MESA_FORMAT_RG_UINT32
] = unpack_RG_UINT32
;
2514 table
[MESA_FORMAT_RGB_UINT32
] = unpack_RGB_UINT32
;
2515 table
[MESA_FORMAT_RGBA_UINT32
] = unpack_RGBA_UINT32
;
2517 table
[MESA_FORMAT_R_SNORM8
] = unpack_R_SNORM8
;
2518 table
[MESA_FORMAT_R8G8_SNORM
] = unpack_R8G8_SNORM
;
2519 table
[MESA_FORMAT_X8B8G8R8_SNORM
] = unpack_X8B8G8R8_SNORM
;
2520 table
[MESA_FORMAT_A8B8G8R8_SNORM
] = unpack_A8B8G8R8_SNORM
;
2521 table
[MESA_FORMAT_R8G8B8A8_SNORM
] = unpack_R8G8B8A8_SNORM
;
2522 table
[MESA_FORMAT_R_SNORM16
] = unpack_R_SNORM16
;
2523 table
[MESA_FORMAT_R16G16_SNORM
] = unpack_R16G16_SNORM
;
2524 table
[MESA_FORMAT_RGB_SNORM16
] = unpack_RGB_SNORM16
;
2525 table
[MESA_FORMAT_RGBA_SNORM16
] = unpack_RGBA_SNORM16
;
2526 table
[MESA_FORMAT_RGBA_UNORM16
] = unpack_RGBA_16
;
2528 table
[MESA_FORMAT_R_RGTC1_UNORM
] = unpack_RED_RGTC1
;
2529 table
[MESA_FORMAT_R_RGTC1_SNORM
] = unpack_SIGNED_RED_RGTC1
;
2530 table
[MESA_FORMAT_RG_RGTC2_UNORM
] = unpack_RG_RGTC2
;
2531 table
[MESA_FORMAT_RG_RGTC2_SNORM
] = unpack_SIGNED_RG_RGTC2
;
2533 table
[MESA_FORMAT_L_LATC1_UNORM
] = unpack_L_LATC1
;
2534 table
[MESA_FORMAT_L_LATC1_SNORM
] = unpack_SIGNED_L_LATC1
;
2535 table
[MESA_FORMAT_LA_LATC2_UNORM
] = unpack_LA_LATC2
;
2536 table
[MESA_FORMAT_LA_LATC2_SNORM
] = unpack_SIGNED_LA_LATC2
;
2538 table
[MESA_FORMAT_ETC1_RGB8
] = unpack_ETC1_RGB8
;
2539 table
[MESA_FORMAT_ETC2_RGB8
] = unpack_ETC2_RGB8
;
2540 table
[MESA_FORMAT_ETC2_SRGB8
] = unpack_ETC2_SRGB8
;
2541 table
[MESA_FORMAT_ETC2_RGBA8_EAC
] = unpack_ETC2_RGBA8_EAC
;
2542 table
[MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC
] = unpack_ETC2_SRGB8_ALPHA8_EAC
;
2543 table
[MESA_FORMAT_ETC2_R11_EAC
] = unpack_ETC2_R11_EAC
;
2544 table
[MESA_FORMAT_ETC2_RG11_EAC
] = unpack_ETC2_RG11_EAC
;
2545 table
[MESA_FORMAT_ETC2_SIGNED_R11_EAC
] = unpack_ETC2_SIGNED_R11_EAC
;
2546 table
[MESA_FORMAT_ETC2_SIGNED_RG11_EAC
] = unpack_ETC2_SIGNED_RG11_EAC
;
2547 table
[MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1
] =
2548 unpack_ETC2_RGB8_PUNCHTHROUGH_ALPHA1
;
2549 table
[MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
] =
2550 unpack_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
;
2551 table
[MESA_FORMAT_A_SNORM8
] = unpack_A_SNORM8
;
2552 table
[MESA_FORMAT_L_SNORM8
] = unpack_L_SNORM8
;
2553 table
[MESA_FORMAT_L8A8_SNORM
] = unpack_L8A8_SNORM
;
2554 table
[MESA_FORMAT_A8L8_SNORM
] = unpack_A8L8_SNORM
;
2555 table
[MESA_FORMAT_I_SNORM8
] = unpack_I_SNORM8
;
2556 table
[MESA_FORMAT_A_SNORM16
] = unpack_A_SNORM16
;
2557 table
[MESA_FORMAT_L_SNORM16
] = unpack_L_SNORM16
;
2558 table
[MESA_FORMAT_LA_SNORM16
] = unpack_LA_SNORM16
;
2559 table
[MESA_FORMAT_I_SNORM16
] = unpack_I_SNORM16
;
2561 table
[MESA_FORMAT_R9G9B9E5_FLOAT
] = unpack_R9G9B9E5_FLOAT
;
2562 table
[MESA_FORMAT_R11G11B10_FLOAT
] = unpack_R11G11B10_FLOAT
;
2564 table
[MESA_FORMAT_Z_FLOAT32
] = unpack_Z_FLOAT32
;
2565 table
[MESA_FORMAT_Z32_FLOAT_S8X24_UINT
] = unpack_Z32_FLOAT_S8X24_UINT
;
2567 table
[MESA_FORMAT_B4G4R4X4_UNORM
] = unpack_XRGB4444_UNORM
;
2568 table
[MESA_FORMAT_B5G5R5X1_UNORM
] = unpack_XRGB1555_UNORM
;
2569 table
[MESA_FORMAT_R8G8B8X8_SNORM
] = unpack_R8G8B8X8_SNORM
;
2570 table
[MESA_FORMAT_R8G8B8X8_SRGB
] = unpack_R8G8B8X8_SRGB
;
2571 table
[MESA_FORMAT_X8B8G8R8_SRGB
] = unpack_X8B8G8R8_SRGB
;
2572 table
[MESA_FORMAT_RGBX_UINT8
] = unpack_XBGR8888_UINT
;
2573 table
[MESA_FORMAT_RGBX_SINT8
] = unpack_XBGR8888_SINT
;
2574 table
[MESA_FORMAT_B10G10R10X2_UNORM
] = unpack_B10G10R10X2_UNORM
;
2575 table
[MESA_FORMAT_RGBX_UNORM16
] = unpack_RGBX_UNORM16
;
2576 table
[MESA_FORMAT_RGBX_SNORM16
] = unpack_RGBX_SNORM16
;
2577 table
[MESA_FORMAT_RGBX_FLOAT16
] = unpack_XBGR16161616_FLOAT
;
2578 table
[MESA_FORMAT_RGBX_UINT16
] = unpack_XBGR16161616_UINT
;
2579 table
[MESA_FORMAT_RGBX_SINT16
] = unpack_XBGR16161616_SINT
;
2580 table
[MESA_FORMAT_RGBX_FLOAT32
] = unpack_RGBX_FLOAT32
;
2581 table
[MESA_FORMAT_RGBX_UINT32
] = unpack_XBGR32323232_UINT
;
2582 table
[MESA_FORMAT_RGBX_SINT32
] = unpack_XBGR32323232_SINT
;
2584 table
[MESA_FORMAT_R10G10B10A2_UNORM
] = unpack_R10G10B10A2_UNORM
;
2586 table
[MESA_FORMAT_G8R8_SNORM
] = unpack_G8R8_SNORM
;
2587 table
[MESA_FORMAT_G16R16_SNORM
] = unpack_G16R16_SNORM
;
2589 table
[MESA_FORMAT_B8G8R8X8_SRGB
] = unpack_B8G8R8X8_SRGB
;
2590 table
[MESA_FORMAT_X8R8G8B8_SRGB
] = unpack_X8R8G8B8_SRGB
;
2592 initialized
= GL_TRUE
;
2595 if (table
[format
] == NULL
) {
2596 _mesa_problem(NULL
, "unsupported unpack for format %s",
2597 _mesa_get_format_name(format
));
2600 return table
[format
];
2605 * Unpack rgba colors, returning as GLfloat values.
2608 _mesa_unpack_rgba_row(mesa_format format
, GLuint n
,
2609 const void *src
, GLfloat dst
[][4])
2611 unpack_rgba_func unpack
= get_unpack_rgba_function(format
);
2612 unpack(src
, dst
, n
);
2616 /**********************************************************************/
2617 /* Unpack, returning GLubyte colors */
2618 /**********************************************************************/
2622 unpack_ubyte_A8B8G8R8_UNORM(const void *src
, GLubyte dst
[][4], GLuint n
)
2624 const GLuint
*s
= ((const GLuint
*) src
);
2626 for (i
= 0; i
< n
; i
++) {
2627 dst
[i
][RCOMP
] = (s
[i
] >> 24);
2628 dst
[i
][GCOMP
] = (s
[i
] >> 16) & 0xff;
2629 dst
[i
][BCOMP
] = (s
[i
] >> 8) & 0xff;
2630 dst
[i
][ACOMP
] = (s
[i
] ) & 0xff;
2635 unpack_ubyte_R8G8B8A8_UNORM(const void *src
, GLubyte dst
[][4], GLuint n
)
2637 const GLuint
*s
= ((const GLuint
*) src
);
2639 for (i
= 0; i
< n
; i
++) {
2640 dst
[i
][RCOMP
] = (s
[i
] ) & 0xff;
2641 dst
[i
][GCOMP
] = (s
[i
] >> 8) & 0xff;
2642 dst
[i
][BCOMP
] = (s
[i
] >> 16) & 0xff;
2643 dst
[i
][ACOMP
] = (s
[i
] >> 24);
2648 unpack_ubyte_B8G8R8A8_UNORM(const void *src
, GLubyte dst
[][4], GLuint n
)
2650 const GLuint
*s
= ((const GLuint
*) src
);
2652 for (i
= 0; i
< n
; i
++) {
2653 dst
[i
][RCOMP
] = (s
[i
] >> 16) & 0xff;
2654 dst
[i
][GCOMP
] = (s
[i
] >> 8) & 0xff;
2655 dst
[i
][BCOMP
] = (s
[i
] ) & 0xff;
2656 dst
[i
][ACOMP
] = (s
[i
] >> 24);
2661 unpack_ubyte_A8R8G8B8_UNORM(const void *src
, GLubyte dst
[][4], GLuint n
)
2663 const GLuint
*s
= ((const GLuint
*) src
);
2665 for (i
= 0; i
< n
; i
++) {
2666 dst
[i
][RCOMP
] = (s
[i
] >> 8) & 0xff;
2667 dst
[i
][GCOMP
] = (s
[i
] >> 16) & 0xff;
2668 dst
[i
][BCOMP
] = (s
[i
] >> 24);
2669 dst
[i
][ACOMP
] = (s
[i
] ) & 0xff;
2674 unpack_ubyte_RGBX8888(const void *src
, GLubyte dst
[][4], GLuint n
)
2676 const GLuint
*s
= ((const GLuint
*) src
);
2678 for (i
= 0; i
< n
; i
++) {
2679 dst
[i
][RCOMP
] = (s
[i
] >> 24);
2680 dst
[i
][GCOMP
] = (s
[i
] >> 16) & 0xff;
2681 dst
[i
][BCOMP
] = (s
[i
] >> 8) & 0xff;
2682 dst
[i
][ACOMP
] = 0xff;
2687 unpack_ubyte_RGBX8888_REV(const void *src
, GLubyte dst
[][4], GLuint n
)
2689 const GLuint
*s
= ((const GLuint
*) src
);
2691 for (i
= 0; i
< n
; i
++) {
2692 dst
[i
][RCOMP
] = (s
[i
] ) & 0xff;
2693 dst
[i
][GCOMP
] = (s
[i
] >> 8) & 0xff;
2694 dst
[i
][BCOMP
] = (s
[i
] >> 16) & 0xff;
2695 dst
[i
][ACOMP
] = 0xff;
2700 unpack_ubyte_B8G8R8X8_UNORM(const void *src
, GLubyte dst
[][4], GLuint n
)
2702 const GLuint
*s
= ((const GLuint
*) src
);
2704 for (i
= 0; i
< n
; i
++) {
2705 dst
[i
][RCOMP
] = (s
[i
] >> 16) & 0xff;
2706 dst
[i
][GCOMP
] = (s
[i
] >> 8) & 0xff;
2707 dst
[i
][BCOMP
] = (s
[i
] ) & 0xff;
2708 dst
[i
][ACOMP
] = 0xff;
2713 unpack_ubyte_X8R8G8B8_UNORM(const void *src
, GLubyte dst
[][4], GLuint n
)
2715 const GLuint
*s
= ((const GLuint
*) src
);
2717 for (i
= 0; i
< n
; i
++) {
2718 dst
[i
][RCOMP
] = (s
[i
] >> 8) & 0xff;
2719 dst
[i
][GCOMP
] = (s
[i
] >> 16) & 0xff;
2720 dst
[i
][BCOMP
] = (s
[i
] >> 24);
2721 dst
[i
][ACOMP
] = 0xff;
2726 unpack_ubyte_BGR_UNORM8(const void *src
, GLubyte dst
[][4], GLuint n
)
2728 const GLubyte
*s
= (const GLubyte
*) src
;
2730 for (i
= 0; i
< n
; i
++) {
2731 dst
[i
][RCOMP
] = s
[i
*3+2];
2732 dst
[i
][GCOMP
] = s
[i
*3+1];
2733 dst
[i
][BCOMP
] = s
[i
*3+0];
2734 dst
[i
][ACOMP
] = 0xff;
2739 unpack_ubyte_RGB_UNORM8(const void *src
, GLubyte dst
[][4], GLuint n
)
2741 const GLubyte
*s
= (const GLubyte
*) src
;
2743 for (i
= 0; i
< n
; i
++) {
2744 dst
[i
][RCOMP
] = s
[i
*3+0];
2745 dst
[i
][GCOMP
] = s
[i
*3+1];
2746 dst
[i
][BCOMP
] = s
[i
*3+2];
2747 dst
[i
][ACOMP
] = 0xff;
2752 unpack_ubyte_B5G6R5_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_5_8((s
[i
] >> 11) & 0x1f);
2758 dst
[i
][GCOMP
] = EXPAND_6_8((s
[i
] >> 5 ) & 0x3f);
2759 dst
[i
][BCOMP
] = EXPAND_5_8( s
[i
] & 0x1f);
2760 dst
[i
][ACOMP
] = 0xff;
2765 unpack_ubyte_R5G6B5_UNORM(const void *src
, GLubyte dst
[][4], GLuint n
)
2767 const GLushort
*s
= ((const GLushort
*) src
);
2769 for (i
= 0; i
< n
; i
++) {
2770 GLuint t
= (s
[i
] >> 8) | (s
[i
] << 8); /* byte swap */
2771 dst
[i
][RCOMP
] = EXPAND_5_8( t
& 0x1f);
2772 dst
[i
][GCOMP
] = EXPAND_6_8((t
>> 5 ) & 0x3f);
2773 dst
[i
][BCOMP
] = EXPAND_5_8((t
>> 11) & 0x1f);
2774 dst
[i
][ACOMP
] = 0xff;
2779 unpack_ubyte_B4G4R4A4_UNORM(const void *src
, GLubyte dst
[][4], GLuint n
)
2781 const GLushort
*s
= ((const GLushort
*) src
);
2783 for (i
= 0; i
< n
; i
++) {
2784 dst
[i
][RCOMP
] = EXPAND_4_8((s
[i
] >> 8) & 0xf);
2785 dst
[i
][GCOMP
] = EXPAND_4_8((s
[i
] >> 4) & 0xf);
2786 dst
[i
][BCOMP
] = EXPAND_4_8((s
[i
] ) & 0xf);
2787 dst
[i
][ACOMP
] = EXPAND_4_8((s
[i
] >> 12) & 0xf);
2792 unpack_ubyte_A4R4G4B4_UNORM(const void *src
, GLubyte dst
[][4], GLuint n
)
2794 const GLushort
*s
= ((const GLushort
*) src
);
2796 for (i
= 0; i
< n
; i
++) {
2797 dst
[i
][RCOMP
] = EXPAND_4_8((s
[i
] >> 4) & 0xf);
2798 dst
[i
][GCOMP
] = EXPAND_4_8((s
[i
] >> 8) & 0xf);
2799 dst
[i
][BCOMP
] = EXPAND_4_8((s
[i
] >> 12) & 0xf);
2800 dst
[i
][ACOMP
] = EXPAND_4_8((s
[i
] ) & 0xf);
2805 unpack_ubyte_A1B5G5R5_UNORM(const void *src
, GLubyte dst
[][4], GLuint n
)
2807 const GLushort
*s
= ((const GLushort
*) src
);
2809 for (i
= 0; i
< n
; i
++) {
2810 dst
[i
][RCOMP
] = EXPAND_5_8((s
[i
] >> 11) & 0x1f);
2811 dst
[i
][GCOMP
] = EXPAND_5_8((s
[i
] >> 6) & 0x1f);
2812 dst
[i
][BCOMP
] = EXPAND_5_8((s
[i
] >> 1) & 0x1f);
2813 dst
[i
][ACOMP
] = EXPAND_1_8((s
[i
] ) & 0x01);
2818 unpack_ubyte_B5G5R5A1_UNORM(const void *src
, GLubyte dst
[][4], GLuint n
)
2820 const GLushort
*s
= ((const GLushort
*) src
);
2822 for (i
= 0; i
< n
; i
++) {
2823 dst
[i
][RCOMP
] = EXPAND_5_8((s
[i
] >> 10) & 0x1f);
2824 dst
[i
][GCOMP
] = EXPAND_5_8((s
[i
] >> 5) & 0x1f);
2825 dst
[i
][BCOMP
] = EXPAND_5_8((s
[i
] >> 0) & 0x1f);
2826 dst
[i
][ACOMP
] = EXPAND_1_8((s
[i
] >> 15) & 0x01);
2831 unpack_ubyte_A1R5G5B5_UNORM(const void *src
, GLubyte dst
[][4], GLuint n
)
2833 /* Warning: this function does not match the current Mesa definition
2834 * of MESA_FORMAT_A1R5G5B5_UNORM.
2836 const GLushort
*s
= ((const GLushort
*) src
);
2838 for (i
= 0; i
< n
; i
++) {
2839 GLushort tmp
= (s
[i
] << 8) | (s
[i
] >> 8); /* byteswap */
2840 dst
[i
][RCOMP
] = EXPAND_5_8((tmp
>> 10) & 0x1f);
2841 dst
[i
][GCOMP
] = EXPAND_5_8((tmp
>> 5) & 0x1f);
2842 dst
[i
][BCOMP
] = EXPAND_5_8((tmp
>> 0) & 0x1f);
2843 dst
[i
][ACOMP
] = EXPAND_1_8((tmp
>> 15) & 0x01);
2848 unpack_ubyte_L4A4_UNORM(const void *src
, GLubyte dst
[][4], GLuint n
)
2850 const GLubyte
*s
= ((const GLubyte
*) src
);
2852 for (i
= 0; i
< n
; i
++) {
2855 dst
[i
][BCOMP
] = EXPAND_4_8(s
[i
] & 0xf);
2856 dst
[i
][ACOMP
] = EXPAND_4_8(s
[i
] >> 4);
2861 unpack_ubyte_L8A8_UNORM(const void *src
, GLubyte dst
[][4], GLuint n
)
2863 const GLushort
*s
= ((const GLushort
*) src
);
2865 for (i
= 0; i
< n
; i
++) {
2868 dst
[i
][BCOMP
] = EXPAND_4_8(s
[i
] & 0xff);
2869 dst
[i
][ACOMP
] = EXPAND_4_8(s
[i
] >> 8);
2874 unpack_ubyte_A8L8_UNORM(const void *src
, GLubyte dst
[][4], GLuint n
)
2876 const GLushort
*s
= ((const GLushort
*) src
);
2878 for (i
= 0; i
< n
; i
++) {
2881 dst
[i
][BCOMP
] = EXPAND_4_8(s
[i
] >> 8);
2882 dst
[i
][ACOMP
] = EXPAND_4_8(s
[i
] & 0xff);
2887 unpack_ubyte_B2G3R3_UNORM(const void *src
, GLubyte dst
[][4], GLuint n
)
2889 const GLubyte
*s
= ((const GLubyte
*) src
);
2891 for (i
= 0; i
< n
; i
++) {
2892 dst
[i
][RCOMP
] = EXPAND_3_8((s
[i
] >> 5) & 0x7);
2893 dst
[i
][GCOMP
] = EXPAND_3_8((s
[i
] >> 2) & 0x7);
2894 dst
[i
][BCOMP
] = EXPAND_2_8((s
[i
] ) & 0x3);
2895 dst
[i
][ACOMP
] = 0xff;
2900 unpack_ubyte_A_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_L_UNORM8(const void *src
, GLubyte dst
[][4], GLuint n
)
2915 const GLubyte
*s
= ((const GLubyte
*) src
);
2917 for (i
= 0; i
< n
; i
++) {
2920 dst
[i
][BCOMP
] = s
[i
];
2921 dst
[i
][ACOMP
] = 0xff;
2927 unpack_ubyte_I_UNORM8(const void *src
, GLubyte dst
[][4], GLuint n
)
2929 const GLubyte
*s
= ((const GLubyte
*) src
);
2931 for (i
= 0; i
< n
; i
++) {
2935 dst
[i
][ACOMP
] = s
[i
];
2940 unpack_ubyte_R_UNORM8(const void *src
, GLubyte dst
[][4], GLuint n
)
2942 const GLubyte
*s
= ((const GLubyte
*) src
);
2944 for (i
= 0; i
< n
; i
++) {
2953 unpack_ubyte_R8G8_UNORM(const void *src
, GLubyte dst
[][4], GLuint n
)
2955 const GLushort
*s
= ((const GLushort
*) src
);
2957 for (i
= 0; i
< n
; i
++) {
2958 dst
[i
][RCOMP
] = s
[i
] & 0xff;
2959 dst
[i
][GCOMP
] = s
[i
] >> 8;
2961 dst
[i
][ACOMP
] = 0xff;
2966 unpack_ubyte_G8R8_UNORM(const void *src
, GLubyte dst
[][4], GLuint n
)
2968 const GLushort
*s
= ((const GLushort
*) src
);
2970 for (i
= 0; i
< n
; i
++) {
2971 dst
[i
][RCOMP
] = s
[i
] >> 8;
2972 dst
[i
][GCOMP
] = s
[i
] & 0xff;
2974 dst
[i
][ACOMP
] = 0xff;
2980 * Unpack rgba colors, returning as GLubyte values. This should usually
2981 * only be used for unpacking formats that use 8 bits or less per channel.
2984 _mesa_unpack_ubyte_rgba_row(mesa_format format
, GLuint n
,
2985 const void *src
, GLubyte dst
[][4])
2988 case MESA_FORMAT_A8B8G8R8_UNORM
:
2989 unpack_ubyte_A8B8G8R8_UNORM(src
, dst
, n
);
2991 case MESA_FORMAT_R8G8B8A8_UNORM
:
2992 unpack_ubyte_R8G8B8A8_UNORM(src
, dst
, n
);
2994 case MESA_FORMAT_B8G8R8A8_UNORM
:
2995 unpack_ubyte_B8G8R8A8_UNORM(src
, dst
, n
);
2997 case MESA_FORMAT_A8R8G8B8_UNORM
:
2998 unpack_ubyte_A8R8G8B8_UNORM(src
, dst
, n
);
3000 case MESA_FORMAT_X8B8G8R8_UNORM
:
3001 unpack_ubyte_RGBX8888(src
, dst
, n
);
3003 case MESA_FORMAT_R8G8B8X8_UNORM
:
3004 unpack_ubyte_RGBX8888_REV(src
, dst
, n
);
3006 case MESA_FORMAT_B8G8R8X8_UNORM
:
3007 unpack_ubyte_B8G8R8X8_UNORM(src
, dst
, n
);
3009 case MESA_FORMAT_X8R8G8B8_UNORM
:
3010 unpack_ubyte_X8R8G8B8_UNORM(src
, dst
, n
);
3012 case MESA_FORMAT_BGR_UNORM8
:
3013 unpack_ubyte_BGR_UNORM8(src
, dst
, n
);
3015 case MESA_FORMAT_RGB_UNORM8
:
3016 unpack_ubyte_RGB_UNORM8(src
, dst
, n
);
3018 case MESA_FORMAT_B5G6R5_UNORM
:
3019 unpack_ubyte_B5G6R5_UNORM(src
, dst
, n
);
3021 case MESA_FORMAT_R5G6B5_UNORM
:
3022 unpack_ubyte_R5G6B5_UNORM(src
, dst
, n
);
3024 case MESA_FORMAT_B4G4R4A4_UNORM
:
3025 unpack_ubyte_B4G4R4A4_UNORM(src
, dst
, n
);
3027 case MESA_FORMAT_A4R4G4B4_UNORM
:
3028 unpack_ubyte_A4R4G4B4_UNORM(src
, dst
, n
);
3030 case MESA_FORMAT_A1B5G5R5_UNORM
:
3031 unpack_ubyte_A1B5G5R5_UNORM(src
, dst
, n
);
3033 case MESA_FORMAT_B5G5R5A1_UNORM
:
3034 unpack_ubyte_B5G5R5A1_UNORM(src
, dst
, n
);
3036 case MESA_FORMAT_A1R5G5B5_UNORM
:
3037 unpack_ubyte_A1R5G5B5_UNORM(src
, dst
, n
);
3039 case MESA_FORMAT_L4A4_UNORM
:
3040 unpack_ubyte_L4A4_UNORM(src
, dst
, n
);
3042 case MESA_FORMAT_L8A8_UNORM
:
3043 unpack_ubyte_L8A8_UNORM(src
, dst
, n
);
3045 case MESA_FORMAT_A8L8_UNORM
:
3046 unpack_ubyte_A8L8_UNORM(src
, dst
, n
);
3048 case MESA_FORMAT_B2G3R3_UNORM
:
3049 unpack_ubyte_B2G3R3_UNORM(src
, dst
, n
);
3051 case MESA_FORMAT_A_UNORM8
:
3052 unpack_ubyte_A_UNORM8(src
, dst
, n
);
3054 case MESA_FORMAT_L_UNORM8
:
3055 unpack_ubyte_L_UNORM8(src
, dst
, n
);
3057 case MESA_FORMAT_I_UNORM8
:
3058 unpack_ubyte_I_UNORM8(src
, dst
, n
);
3060 case MESA_FORMAT_R_UNORM8
:
3061 unpack_ubyte_R_UNORM8(src
, dst
, n
);
3063 case MESA_FORMAT_R8G8_UNORM
:
3064 unpack_ubyte_R8G8_UNORM(src
, dst
, n
);
3066 case MESA_FORMAT_G8R8_UNORM
:
3067 unpack_ubyte_G8R8_UNORM(src
, dst
, n
);
3070 /* get float values, convert to ubyte */
3072 GLfloat
*tmp
= malloc(n
* 4 * sizeof(GLfloat
));
3075 _mesa_unpack_rgba_row(format
, n
, src
, (GLfloat (*)[4]) tmp
);
3076 for (i
= 0; i
< n
; i
++) {
3077 UNCLAMPED_FLOAT_TO_UBYTE(dst
[i
][0], tmp
[i
*4+0]);
3078 UNCLAMPED_FLOAT_TO_UBYTE(dst
[i
][1], tmp
[i
*4+1]);
3079 UNCLAMPED_FLOAT_TO_UBYTE(dst
[i
][2], tmp
[i
*4+2]);
3080 UNCLAMPED_FLOAT_TO_UBYTE(dst
[i
][3], tmp
[i
*4+3]);
3090 /**********************************************************************/
3091 /* Unpack, returning GLuint colors */
3092 /**********************************************************************/
3095 unpack_int_rgba_RGBA_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3097 memcpy(dst
, src
, n
* 4 * sizeof(GLuint
));
3101 unpack_int_rgba_RGBA_UINT16(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
3105 for (i
= 0; i
< n
; i
++) {
3106 dst
[i
][0] = src
[i
* 4 + 0];
3107 dst
[i
][1] = src
[i
* 4 + 1];
3108 dst
[i
][2] = src
[i
* 4 + 2];
3109 dst
[i
][3] = src
[i
* 4 + 3];
3114 unpack_int_rgba_RGBA_INT16(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
3118 for (i
= 0; i
< n
; i
++) {
3119 dst
[i
][0] = src
[i
* 4 + 0];
3120 dst
[i
][1] = src
[i
* 4 + 1];
3121 dst
[i
][2] = src
[i
* 4 + 2];
3122 dst
[i
][3] = src
[i
* 4 + 3];
3127 unpack_int_rgba_RGBA_UINT8(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
3131 for (i
= 0; i
< n
; i
++) {
3132 dst
[i
][0] = src
[i
* 4 + 0];
3133 dst
[i
][1] = src
[i
* 4 + 1];
3134 dst
[i
][2] = src
[i
* 4 + 2];
3135 dst
[i
][3] = src
[i
* 4 + 3];
3140 unpack_int_rgba_RGBA_INT8(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3144 for (i
= 0; i
< n
; i
++) {
3145 dst
[i
][0] = src
[i
* 4 + 0];
3146 dst
[i
][1] = src
[i
* 4 + 1];
3147 dst
[i
][2] = src
[i
* 4 + 2];
3148 dst
[i
][3] = src
[i
* 4 + 3];
3153 unpack_int_rgba_B8G8R8A8_UNORM(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3157 for (i
= 0; i
< n
; i
++) {
3158 dst
[i
][RCOMP
] = (GLubyte
) src
[i
* 4 + 2];
3159 dst
[i
][GCOMP
] = (GLubyte
) src
[i
* 4 + 1];
3160 dst
[i
][BCOMP
] = (GLubyte
) src
[i
* 4 + 0];
3161 dst
[i
][ACOMP
] = (GLubyte
) src
[i
* 4 + 3];
3166 unpack_int_rgba_B8G8R8X8_UNORM(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3170 for (i
= 0; i
< n
; i
++) {
3171 dst
[i
][RCOMP
] = (GLubyte
) src
[i
* 4 + 2];
3172 dst
[i
][GCOMP
] = (GLubyte
) src
[i
* 4 + 1];
3173 dst
[i
][BCOMP
] = (GLubyte
) src
[i
* 4 + 0];
3174 dst
[i
][ACOMP
] = (GLubyte
) 0xff;
3179 unpack_int_rgba_RGB_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3183 for (i
= 0; i
< n
; i
++) {
3184 dst
[i
][0] = src
[i
* 3 + 0];
3185 dst
[i
][1] = src
[i
* 3 + 1];
3186 dst
[i
][2] = src
[i
* 3 + 2];
3192 unpack_int_rgba_RGB_UINT16(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
3196 for (i
= 0; i
< n
; i
++) {
3197 dst
[i
][0] = src
[i
* 3 + 0];
3198 dst
[i
][1] = src
[i
* 3 + 1];
3199 dst
[i
][2] = src
[i
* 3 + 2];
3205 unpack_int_rgba_RGB_INT16(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
3209 for (i
= 0; i
< n
; i
++) {
3210 dst
[i
][0] = src
[i
* 3 + 0];
3211 dst
[i
][1] = src
[i
* 3 + 1];
3212 dst
[i
][2] = src
[i
* 3 + 2];
3218 unpack_int_rgba_RGB_UINT8(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
3222 for (i
= 0; i
< n
; i
++) {
3223 dst
[i
][0] = src
[i
* 3 + 0];
3224 dst
[i
][1] = src
[i
* 3 + 1];
3225 dst
[i
][2] = src
[i
* 3 + 2];
3231 unpack_int_rgba_RGB_INT8(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3235 for (i
= 0; i
< n
; i
++) {
3236 dst
[i
][0] = src
[i
* 3 + 0];
3237 dst
[i
][1] = src
[i
* 3 + 1];
3238 dst
[i
][2] = src
[i
* 3 + 2];
3244 unpack_int_rgba_RG_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3248 for (i
= 0; i
< n
; i
++) {
3249 dst
[i
][0] = src
[i
* 2 + 0];
3250 dst
[i
][1] = src
[i
* 2 + 1];
3257 unpack_int_rgba_RG_UINT16(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
3261 for (i
= 0; i
< n
; i
++) {
3262 dst
[i
][0] = src
[i
* 2 + 0];
3263 dst
[i
][1] = src
[i
* 2 + 1];
3270 unpack_int_rgba_RG_INT16(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
3274 for (i
= 0; i
< n
; i
++) {
3275 dst
[i
][0] = src
[i
* 2 + 0];
3276 dst
[i
][1] = src
[i
* 2 + 1];
3283 unpack_int_rgba_RG_UINT8(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
3287 for (i
= 0; i
< n
; i
++) {
3288 dst
[i
][0] = src
[i
* 2 + 0];
3289 dst
[i
][1] = src
[i
* 2 + 1];
3296 unpack_int_rgba_RG_INT8(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3300 for (i
= 0; i
< n
; i
++) {
3301 dst
[i
][0] = src
[i
* 2 + 0];
3302 dst
[i
][1] = src
[i
* 2 + 1];
3309 unpack_int_rgba_R_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3313 for (i
= 0; i
< n
; i
++) {
3322 unpack_int_rgba_R_UINT16(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
3326 for (i
= 0; i
< n
; i
++) {
3335 unpack_int_rgba_R_INT16(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
3339 for (i
= 0; i
< n
; i
++) {
3348 unpack_int_rgba_R_UINT8(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
3352 for (i
= 0; i
< n
; i
++) {
3361 unpack_int_rgba_R_INT8(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3365 for (i
= 0; i
< n
; i
++) {
3374 unpack_int_rgba_ALPHA_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3378 for (i
= 0; i
< n
; i
++) {
3379 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = 0;
3385 unpack_int_rgba_ALPHA_UINT16(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
3389 for (i
= 0; i
< n
; i
++) {
3390 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = 0;
3396 unpack_int_rgba_ALPHA_INT16(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
3400 for (i
= 0; i
< n
; i
++) {
3401 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = 0;
3407 unpack_int_rgba_ALPHA_UINT8(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
3411 for (i
= 0; i
< n
; i
++) {
3412 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = 0;
3418 unpack_int_rgba_ALPHA_INT8(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3422 for (i
= 0; i
< n
; i
++) {
3423 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = 0;
3429 unpack_int_rgba_LUMINANCE_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3433 for (i
= 0; i
< n
; i
++) {
3434 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
];
3440 unpack_int_rgba_LUMINANCE_UINT16(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
3444 for (i
= 0; i
< n
; i
++) {
3445 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
];
3451 unpack_int_rgba_LUMINANCE_INT16(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
3455 for (i
= 0; i
< n
; i
++) {
3456 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
];
3462 unpack_int_rgba_LUMINANCE_UINT8(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
3466 for (i
= 0; i
< n
; i
++) {
3467 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
];
3473 unpack_int_rgba_LUMINANCE_INT8(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3477 for (i
= 0; i
< n
; i
++) {
3478 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
];
3485 unpack_int_rgba_LUMINANCE_ALPHA_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3489 for (i
= 0; i
< n
; i
++) {
3490 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
* 2 + 0];
3491 dst
[i
][3] = src
[i
* 2 + 1];
3496 unpack_int_rgba_LUMINANCE_ALPHA_UINT16(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
3500 for (i
= 0; i
< n
; i
++) {
3501 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
* 2 + 0];
3502 dst
[i
][3] = src
[i
* 2 + 1];
3507 unpack_int_rgba_LUMINANCE_ALPHA_INT16(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
3511 for (i
= 0; i
< n
; i
++) {
3512 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
* 2 + 0];
3513 dst
[i
][3] = src
[i
* 2 + 1];
3518 unpack_int_rgba_LUMINANCE_ALPHA_UINT8(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
3522 for (i
= 0; i
< n
; i
++) {
3523 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
* 2 + 0];
3524 dst
[i
][3] = src
[i
* 2 + 1];
3529 unpack_int_rgba_LUMINANCE_ALPHA_INT8(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3533 for (i
= 0; i
< n
; i
++) {
3534 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
* 2 + 0];
3535 dst
[i
][3] = src
[i
* 2 + 1];
3540 unpack_int_rgba_INTENSITY_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3544 for (i
= 0; i
< n
; i
++) {
3545 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = dst
[i
][3] = src
[i
];
3550 unpack_int_rgba_INTENSITY_UINT16(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
3554 for (i
= 0; i
< n
; i
++) {
3555 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = dst
[i
][3] = src
[i
];
3560 unpack_int_rgba_INTENSITY_INT16(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
3564 for (i
= 0; i
< n
; i
++) {
3565 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = dst
[i
][3] = src
[i
];
3570 unpack_int_rgba_INTENSITY_UINT8(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
3574 for (i
= 0; i
< n
; i
++) {
3575 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = dst
[i
][3] = src
[i
];
3580 unpack_int_rgba_INTENSITY_INT8(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3584 for (i
= 0; i
< n
; i
++) {
3585 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = dst
[i
][3] = src
[i
];
3590 unpack_int_rgba_B10G10R10A2_UINT(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3594 for (i
= 0; i
< n
; i
++) {
3595 GLuint tmp
= src
[i
];
3596 dst
[i
][0] = (tmp
>> 20) & 0x3ff;
3597 dst
[i
][1] = (tmp
>> 10) & 0x3ff;
3598 dst
[i
][2] = (tmp
>> 0) & 0x3ff;
3599 dst
[i
][3] = (tmp
>> 30) & 0x3;
3604 unpack_int_rgba_R10G10B10A2_UINT(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3608 for (i
= 0; i
< n
; i
++) {
3609 GLuint tmp
= src
[i
];
3610 dst
[i
][0] = (tmp
>> 0) & 0x3ff;
3611 dst
[i
][1] = (tmp
>> 10) & 0x3ff;
3612 dst
[i
][2] = (tmp
>> 20) & 0x3ff;
3613 dst
[i
][3] = (tmp
>> 30) & 0x3;
3618 unpack_int_rgba_B10G10R10A2_UNORM(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3622 for (i
= 0; i
< n
; i
++) {
3623 GLuint tmp
= src
[i
];
3624 dst
[i
][0] = (tmp
>> 20) & 0x3ff;
3625 dst
[i
][1] = (tmp
>> 10) & 0x3ff;
3626 dst
[i
][2] = (tmp
>> 0) & 0x3ff;
3627 dst
[i
][3] = (tmp
>> 30) & 0x3;
3632 unpack_int_rgba_XBGR8888_UINT(const GLubyte
*src
, GLuint dst
[][4], GLuint n
)
3636 for (i
= 0; i
< n
; i
++) {
3637 dst
[i
][0] = src
[i
* 4 + 0];
3638 dst
[i
][1] = src
[i
* 4 + 1];
3639 dst
[i
][2] = src
[i
* 4 + 2];
3645 unpack_int_rgba_XBGR8888_SINT(const GLbyte
*src
, GLuint dst
[][4], GLuint n
)
3649 for (i
= 0; i
< n
; i
++) {
3650 dst
[i
][0] = src
[i
* 4 + 0];
3651 dst
[i
][1] = src
[i
* 4 + 1];
3652 dst
[i
][2] = src
[i
* 4 + 2];
3658 unpack_int_rgba_XBGR16161616_UINT(const GLushort
*src
, GLuint dst
[][4], GLuint n
)
3662 for (i
= 0; i
< n
; i
++) {
3663 dst
[i
][0] = src
[i
* 4 + 0];
3664 dst
[i
][1] = src
[i
* 4 + 1];
3665 dst
[i
][2] = src
[i
* 4 + 2];
3671 unpack_int_rgba_XBGR16161616_SINT(const GLshort
*src
, GLuint dst
[][4], GLuint n
)
3675 for (i
= 0; i
< n
; i
++) {
3676 dst
[i
][0] = src
[i
* 4 + 0];
3677 dst
[i
][1] = src
[i
* 4 + 1];
3678 dst
[i
][2] = src
[i
* 4 + 2];
3684 unpack_int_rgba_XBGR32323232_UINT(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3688 for (i
= 0; i
< n
; i
++) {
3689 dst
[i
][0] = src
[i
* 4 + 0];
3690 dst
[i
][1] = src
[i
* 4 + 1];
3691 dst
[i
][2] = src
[i
* 4 + 2];
3697 unpack_int_rgba_R10G10B10A2_UNORM(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
3701 for (i
= 0; i
< n
; i
++) {
3702 GLuint tmp
= src
[i
];
3703 dst
[i
][0] = (tmp
>> 0) & 0x3ff;
3704 dst
[i
][1] = (tmp
>> 10) & 0x3ff;
3705 dst
[i
][2] = (tmp
>> 20) & 0x3ff;
3706 dst
[i
][3] = (tmp
>> 30) & 0x3;
3711 _mesa_unpack_uint_rgba_row(mesa_format format
, GLuint n
,
3712 const void *src
, GLuint dst
[][4])
3715 /* Since there won't be any sign extension happening, there's no need to
3716 * make separate paths for 32-bit-to-32-bit integer unpack.
3718 case MESA_FORMAT_RGBA_UINT32
:
3719 case MESA_FORMAT_RGBA_SINT32
:
3720 unpack_int_rgba_RGBA_UINT32(src
, dst
, n
);
3723 case MESA_FORMAT_RGBA_UINT16
:
3724 unpack_int_rgba_RGBA_UINT16(src
, dst
, n
);
3726 case MESA_FORMAT_RGBA_SINT16
:
3727 unpack_int_rgba_RGBA_INT16(src
, dst
, n
);
3730 case MESA_FORMAT_RGBA_UINT8
:
3731 unpack_int_rgba_RGBA_UINT8(src
, dst
, n
);
3733 case MESA_FORMAT_RGBA_SINT8
:
3734 unpack_int_rgba_RGBA_INT8(src
, dst
, n
);
3737 case MESA_FORMAT_B8G8R8A8_UNORM
:
3738 unpack_int_rgba_B8G8R8A8_UNORM(src
, dst
, n
);
3741 case MESA_FORMAT_B8G8R8X8_UNORM
:
3742 unpack_int_rgba_B8G8R8X8_UNORM(src
, dst
, n
);
3745 case MESA_FORMAT_RGB_UINT32
:
3746 case MESA_FORMAT_RGB_SINT32
:
3747 unpack_int_rgba_RGB_UINT32(src
, dst
, n
);
3750 case MESA_FORMAT_RGB_UINT16
:
3751 unpack_int_rgba_RGB_UINT16(src
, dst
, n
);
3753 case MESA_FORMAT_RGB_SINT16
:
3754 unpack_int_rgba_RGB_INT16(src
, dst
, n
);
3757 case MESA_FORMAT_RGB_UINT8
:
3758 unpack_int_rgba_RGB_UINT8(src
, dst
, n
);
3760 case MESA_FORMAT_RGB_SINT8
:
3761 unpack_int_rgba_RGB_INT8(src
, dst
, n
);
3764 case MESA_FORMAT_RG_UINT32
:
3765 case MESA_FORMAT_RG_SINT32
:
3766 unpack_int_rgba_RG_UINT32(src
, dst
, n
);
3769 case MESA_FORMAT_RG_UINT16
:
3770 unpack_int_rgba_RG_UINT16(src
, dst
, n
);
3772 case MESA_FORMAT_RG_SINT16
:
3773 unpack_int_rgba_RG_INT16(src
, dst
, n
);
3776 case MESA_FORMAT_RG_UINT8
:
3777 unpack_int_rgba_RG_UINT8(src
, dst
, n
);
3779 case MESA_FORMAT_RG_SINT8
:
3780 unpack_int_rgba_RG_INT8(src
, dst
, n
);
3783 case MESA_FORMAT_R_UINT32
:
3784 case MESA_FORMAT_R_SINT32
:
3785 unpack_int_rgba_R_UINT32(src
, dst
, n
);
3788 case MESA_FORMAT_R_UINT16
:
3789 unpack_int_rgba_R_UINT16(src
, dst
, n
);
3791 case MESA_FORMAT_R_SINT16
:
3792 unpack_int_rgba_R_INT16(src
, dst
, n
);
3795 case MESA_FORMAT_R_UINT8
:
3796 unpack_int_rgba_R_UINT8(src
, dst
, n
);
3798 case MESA_FORMAT_R_SINT8
:
3799 unpack_int_rgba_R_INT8(src
, dst
, n
);
3802 case MESA_FORMAT_A_UINT32
:
3803 case MESA_FORMAT_A_SINT32
:
3804 unpack_int_rgba_ALPHA_UINT32(src
, dst
, n
);
3807 case MESA_FORMAT_A_UINT16
:
3808 unpack_int_rgba_ALPHA_UINT16(src
, dst
, n
);
3810 case MESA_FORMAT_A_SINT16
:
3811 unpack_int_rgba_ALPHA_INT16(src
, dst
, n
);
3814 case MESA_FORMAT_A_UINT8
:
3815 unpack_int_rgba_ALPHA_UINT8(src
, dst
, n
);
3817 case MESA_FORMAT_A_SINT8
:
3818 unpack_int_rgba_ALPHA_INT8(src
, dst
, n
);
3821 case MESA_FORMAT_L_UINT32
:
3822 case MESA_FORMAT_L_SINT32
:
3823 unpack_int_rgba_LUMINANCE_UINT32(src
, dst
, n
);
3825 case MESA_FORMAT_L_UINT16
:
3826 unpack_int_rgba_LUMINANCE_UINT16(src
, dst
, n
);
3828 case MESA_FORMAT_L_SINT16
:
3829 unpack_int_rgba_LUMINANCE_INT16(src
, dst
, n
);
3832 case MESA_FORMAT_L_UINT8
:
3833 unpack_int_rgba_LUMINANCE_UINT8(src
, dst
, n
);
3835 case MESA_FORMAT_L_SINT8
:
3836 unpack_int_rgba_LUMINANCE_INT8(src
, dst
, n
);
3839 case MESA_FORMAT_LA_UINT32
:
3840 case MESA_FORMAT_LA_SINT32
:
3841 unpack_int_rgba_LUMINANCE_ALPHA_UINT32(src
, dst
, n
);
3844 case MESA_FORMAT_LA_UINT16
:
3845 unpack_int_rgba_LUMINANCE_ALPHA_UINT16(src
, dst
, n
);
3847 case MESA_FORMAT_LA_SINT16
:
3848 unpack_int_rgba_LUMINANCE_ALPHA_INT16(src
, dst
, n
);
3851 case MESA_FORMAT_LA_UINT8
:
3852 unpack_int_rgba_LUMINANCE_ALPHA_UINT8(src
, dst
, n
);
3854 case MESA_FORMAT_LA_SINT8
:
3855 unpack_int_rgba_LUMINANCE_ALPHA_INT8(src
, dst
, n
);
3858 case MESA_FORMAT_I_UINT32
:
3859 case MESA_FORMAT_I_SINT32
:
3860 unpack_int_rgba_INTENSITY_UINT32(src
, dst
, n
);
3863 case MESA_FORMAT_I_UINT16
:
3864 unpack_int_rgba_INTENSITY_UINT16(src
, dst
, n
);
3866 case MESA_FORMAT_I_SINT16
:
3867 unpack_int_rgba_INTENSITY_INT16(src
, dst
, n
);
3870 case MESA_FORMAT_I_UINT8
:
3871 unpack_int_rgba_INTENSITY_UINT8(src
, dst
, n
);
3873 case MESA_FORMAT_I_SINT8
:
3874 unpack_int_rgba_INTENSITY_INT8(src
, dst
, n
);
3877 case MESA_FORMAT_B10G10R10A2_UINT
:
3878 unpack_int_rgba_B10G10R10A2_UINT(src
, dst
, n
);
3881 case MESA_FORMAT_R10G10B10A2_UINT
:
3882 unpack_int_rgba_R10G10B10A2_UINT(src
, dst
, n
);
3885 case MESA_FORMAT_B10G10R10A2_UNORM
:
3886 unpack_int_rgba_B10G10R10A2_UNORM(src
, dst
, n
);
3889 case MESA_FORMAT_RGBX_UINT8
:
3890 unpack_int_rgba_XBGR8888_UINT(src
, dst
, n
);
3893 case MESA_FORMAT_RGBX_SINT8
:
3894 unpack_int_rgba_XBGR8888_SINT(src
, dst
, n
);
3897 case MESA_FORMAT_RGBX_UINT16
:
3898 unpack_int_rgba_XBGR16161616_UINT(src
, dst
, n
);
3901 case MESA_FORMAT_RGBX_SINT16
:
3902 unpack_int_rgba_XBGR16161616_SINT(src
, dst
, n
);
3905 case MESA_FORMAT_RGBX_UINT32
:
3906 case MESA_FORMAT_RGBX_SINT32
:
3907 unpack_int_rgba_XBGR32323232_UINT(src
, dst
, n
);
3910 case MESA_FORMAT_R10G10B10A2_UNORM
:
3911 unpack_int_rgba_R10G10B10A2_UNORM(src
, dst
, n
);
3915 _mesa_problem(NULL
, "%s: bad format %s", __FUNCTION__
,
3916 _mesa_get_format_name(format
));
3922 * Unpack a 2D rect of pixels returning float RGBA colors.
3923 * \param format the source image format
3924 * \param src start address of the source image
3925 * \param srcRowStride source image row stride in bytes
3926 * \param dst start address of the dest image
3927 * \param dstRowStride dest image row stride in bytes
3928 * \param x source image start X pos
3929 * \param y source image start Y pos
3930 * \param width width of rect region to convert
3931 * \param height height of rect region to convert
3934 _mesa_unpack_rgba_block(mesa_format format
,
3935 const void *src
, GLint srcRowStride
,
3936 GLfloat dst
[][4], GLint dstRowStride
,
3937 GLuint x
, GLuint y
, GLuint width
, GLuint height
)
3939 unpack_rgba_func unpack
= get_unpack_rgba_function(format
);
3940 const GLuint srcPixStride
= _mesa_get_format_bytes(format
);
3941 const GLuint dstPixStride
= 4 * sizeof(GLfloat
);
3942 const GLubyte
*srcRow
;
3946 /* XXX needs to be fixed for compressed formats */
3948 srcRow
= ((const GLubyte
*) src
) + srcRowStride
* y
+ srcPixStride
* x
;
3949 dstRow
= ((GLubyte
*) dst
) + dstRowStride
* y
+ dstPixStride
* x
;
3951 for (i
= 0; i
< height
; i
++) {
3952 unpack(srcRow
, (GLfloat (*)[4]) dstRow
, width
);
3954 dstRow
+= dstRowStride
;
3955 srcRow
+= srcRowStride
;
3962 typedef void (*unpack_float_z_func
)(GLuint n
, const void *src
, GLfloat
*dst
);
3965 unpack_float_z_X8_UINT_Z24_UNORM(GLuint n
, const void *src
, GLfloat
*dst
)
3967 /* only return Z, not stencil data */
3968 const GLuint
*s
= ((const GLuint
*) src
);
3969 const GLdouble scale
= 1.0 / (GLdouble
) 0xffffff;
3971 for (i
= 0; i
< n
; i
++) {
3972 dst
[i
] = (GLfloat
) ((s
[i
] >> 8) * scale
);
3973 ASSERT(dst
[i
] >= 0.0F
);
3974 ASSERT(dst
[i
] <= 1.0F
);
3979 unpack_float_z_Z24_UNORM_X8_UINT(GLuint n
, const void *src
, GLfloat
*dst
)
3981 /* only return Z, not stencil data */
3982 const GLuint
*s
= ((const GLuint
*) src
);
3983 const GLdouble scale
= 1.0 / (GLdouble
) 0xffffff;
3985 for (i
= 0; i
< n
; i
++) {
3986 dst
[i
] = (GLfloat
) ((s
[i
] & 0x00ffffff) * scale
);
3987 ASSERT(dst
[i
] >= 0.0F
);
3988 ASSERT(dst
[i
] <= 1.0F
);
3993 unpack_float_Z_UNORM16(GLuint n
, const void *src
, GLfloat
*dst
)
3995 const GLushort
*s
= ((const GLushort
*) src
);
3997 for (i
= 0; i
< n
; i
++) {
3998 dst
[i
] = s
[i
] * (1.0F
/ 65535.0F
);
4003 unpack_float_Z_UNORM32(GLuint n
, const void *src
, GLfloat
*dst
)
4005 const GLuint
*s
= ((const GLuint
*) src
);
4007 for (i
= 0; i
< n
; i
++) {
4008 dst
[i
] = s
[i
] * (1.0F
/ 0xffffffff);
4013 unpack_float_Z_FLOAT32(GLuint n
, const void *src
, GLfloat
*dst
)
4015 memcpy(dst
, src
, n
* sizeof(float));
4019 unpack_float_z_Z32X24S8(GLuint n
, const void *src
, GLfloat
*dst
)
4021 const struct z32f_x24s8
*s
= (const struct z32f_x24s8
*) src
;
4023 for (i
= 0; i
< n
; i
++) {
4032 * The returned values will always be in the range [0.0, 1.0].
4035 _mesa_unpack_float_z_row(mesa_format format
, GLuint n
,
4036 const void *src
, GLfloat
*dst
)
4038 unpack_float_z_func unpack
;
4041 case MESA_FORMAT_S8_UINT_Z24_UNORM
:
4042 case MESA_FORMAT_X8_UINT_Z24_UNORM
:
4043 unpack
= unpack_float_z_X8_UINT_Z24_UNORM
;
4045 case MESA_FORMAT_Z24_UNORM_S8_UINT
:
4046 case MESA_FORMAT_Z24_UNORM_X8_UINT
:
4047 unpack
= unpack_float_z_Z24_UNORM_X8_UINT
;
4049 case MESA_FORMAT_Z_UNORM16
:
4050 unpack
= unpack_float_Z_UNORM16
;
4052 case MESA_FORMAT_Z_UNORM32
:
4053 unpack
= unpack_float_Z_UNORM32
;
4055 case MESA_FORMAT_Z_FLOAT32
:
4056 unpack
= unpack_float_Z_FLOAT32
;
4058 case MESA_FORMAT_Z32_FLOAT_S8X24_UINT
:
4059 unpack
= unpack_float_z_Z32X24S8
;
4062 _mesa_problem(NULL
, "bad format %s in _mesa_unpack_float_z_row",
4063 _mesa_get_format_name(format
));
4067 unpack(n
, src
, dst
);
4072 typedef void (*unpack_uint_z_func
)(const void *src
, GLuint
*dst
, GLuint n
);
4075 unpack_uint_z_X8_UINT_Z24_UNORM(const void *src
, GLuint
*dst
, GLuint n
)
4077 /* only return Z, not stencil data */
4078 const GLuint
*s
= ((const GLuint
*) src
);
4080 for (i
= 0; i
< n
; i
++) {
4081 dst
[i
] = (s
[i
] & 0xffffff00) | (s
[i
] >> 24);
4086 unpack_uint_z_Z24_UNORM_X8_UINT(const void *src
, GLuint
*dst
, GLuint n
)
4088 /* only return Z, not stencil data */
4089 const GLuint
*s
= ((const GLuint
*) src
);
4091 for (i
= 0; i
< n
; i
++) {
4092 dst
[i
] = (s
[i
] << 8) | ((s
[i
] >> 16) & 0xff);
4097 unpack_uint_Z_UNORM16(const void *src
, GLuint
*dst
, GLuint n
)
4099 const GLushort
*s
= ((const GLushort
*)src
);
4101 for (i
= 0; i
< n
; i
++) {
4102 dst
[i
] = (s
[i
] << 16) | s
[i
];
4107 unpack_uint_Z_UNORM32(const void *src
, GLuint
*dst
, GLuint n
)
4109 memcpy(dst
, src
, n
* sizeof(GLuint
));
4113 unpack_uint_Z_FLOAT32(const void *src
, GLuint
*dst
, GLuint n
)
4115 const float *s
= (const float *)src
;
4117 for (i
= 0; i
< n
; i
++) {
4118 dst
[i
] = FLOAT_TO_UINT(CLAMP(s
[i
], 0.0F
, 1.0F
));
4123 unpack_uint_Z_FLOAT32_X24S8(const void *src
, GLuint
*dst
, GLuint n
)
4125 const struct z32f_x24s8
*s
= (const struct z32f_x24s8
*) src
;
4128 for (i
= 0; i
< n
; i
++) {
4129 dst
[i
] = FLOAT_TO_UINT(CLAMP(s
[i
].z
, 0.0F
, 1.0F
));
4136 * The returned values will always be in the range [0, 0xffffffff].
4139 _mesa_unpack_uint_z_row(mesa_format format
, GLuint n
,
4140 const void *src
, GLuint
*dst
)
4142 unpack_uint_z_func unpack
;
4143 const GLubyte
*srcPtr
= (GLubyte
*) src
;
4146 case MESA_FORMAT_S8_UINT_Z24_UNORM
:
4147 case MESA_FORMAT_X8_UINT_Z24_UNORM
:
4148 unpack
= unpack_uint_z_X8_UINT_Z24_UNORM
;
4150 case MESA_FORMAT_Z24_UNORM_S8_UINT
:
4151 case MESA_FORMAT_Z24_UNORM_X8_UINT
:
4152 unpack
= unpack_uint_z_Z24_UNORM_X8_UINT
;
4154 case MESA_FORMAT_Z_UNORM16
:
4155 unpack
= unpack_uint_Z_UNORM16
;
4157 case MESA_FORMAT_Z_UNORM32
:
4158 unpack
= unpack_uint_Z_UNORM32
;
4160 case MESA_FORMAT_Z_FLOAT32
:
4161 unpack
= unpack_uint_Z_FLOAT32
;
4163 case MESA_FORMAT_Z32_FLOAT_S8X24_UINT
:
4164 unpack
= unpack_uint_Z_FLOAT32_X24S8
;
4167 _mesa_problem(NULL
, "bad format %s in _mesa_unpack_uint_z_row",
4168 _mesa_get_format_name(format
));
4172 unpack(srcPtr
, dst
, n
);
4177 unpack_ubyte_s_S_UINT8(const void *src
, GLubyte
*dst
, GLuint n
)
4179 memcpy(dst
, src
, n
);
4183 unpack_ubyte_s_S8_UINT_Z24_UNORM(const void *src
, GLubyte
*dst
, GLuint n
)
4186 const GLuint
*src32
= src
;
4188 for (i
= 0; i
< n
; i
++)
4189 dst
[i
] = src32
[i
] & 0xff;
4193 unpack_ubyte_s_Z24_UNORM_S8_UINT(const void *src
, GLubyte
*dst
, GLuint n
)
4196 const GLuint
*src32
= src
;
4198 for (i
= 0; i
< n
; i
++)
4199 dst
[i
] = src32
[i
] >> 24;
4203 unpack_ubyte_s_Z32_FLOAT_S8X24_UINT(const void *src
, GLubyte
*dst
, GLuint n
)
4206 const struct z32f_x24s8
*s
= (const struct z32f_x24s8
*) src
;
4208 for (i
= 0; i
< n
; i
++)
4209 dst
[i
] = s
[i
].x24s8
& 0xff;
4213 _mesa_unpack_ubyte_stencil_row(mesa_format format
, GLuint n
,
4214 const void *src
, GLubyte
*dst
)
4217 case MESA_FORMAT_S_UINT8
:
4218 unpack_ubyte_s_S_UINT8(src
, dst
, n
);
4220 case MESA_FORMAT_S8_UINT_Z24_UNORM
:
4221 unpack_ubyte_s_S8_UINT_Z24_UNORM(src
, dst
, n
);
4223 case MESA_FORMAT_Z24_UNORM_S8_UINT
:
4224 unpack_ubyte_s_Z24_UNORM_S8_UINT(src
, dst
, n
);
4226 case MESA_FORMAT_Z32_FLOAT_S8X24_UINT
:
4227 unpack_ubyte_s_Z32_FLOAT_S8X24_UINT(src
, dst
, n
);
4230 _mesa_problem(NULL
, "bad format %s in _mesa_unpack_ubyte_s_row",
4231 _mesa_get_format_name(format
));
4237 unpack_uint_24_8_depth_stencil_Z24_UNORM_S8_UINT(const GLuint
*src
, GLuint
*dst
, GLuint n
)
4241 for (i
= 0; i
< n
; i
++) {
4242 GLuint val
= src
[i
];
4243 dst
[i
] = val
>> 24 | val
<< 8;
4248 unpack_uint_24_8_depth_stencil_Z32_S8X24(const GLuint
*src
,
4249 GLuint
*dst
, GLuint n
)
4253 for (i
= 0; i
< n
; i
++) {
4254 /* 8 bytes per pixel (float + uint32) */
4255 GLfloat zf
= ((GLfloat
*) src
)[i
* 2 + 0];
4256 GLuint z24
= (GLuint
) (zf
* (GLfloat
) 0xffffff);
4257 GLuint s
= src
[i
* 2 + 1] & 0xff;
4258 dst
[i
] = (z24
<< 8) | s
;
4263 unpack_uint_24_8_depth_stencil_S8_UINT_Z24_UNORM(const GLuint
*src
, GLuint
*dst
, GLuint n
)
4265 memcpy(dst
, src
, n
* 4);
4269 * Unpack depth/stencil returning as GL_UNSIGNED_INT_24_8.
4270 * \param format the source data format
4273 _mesa_unpack_uint_24_8_depth_stencil_row(mesa_format format
, GLuint n
,
4274 const void *src
, GLuint
*dst
)
4277 case MESA_FORMAT_S8_UINT_Z24_UNORM
:
4278 unpack_uint_24_8_depth_stencil_S8_UINT_Z24_UNORM(src
, dst
, n
);
4280 case MESA_FORMAT_Z24_UNORM_S8_UINT
:
4281 unpack_uint_24_8_depth_stencil_Z24_UNORM_S8_UINT(src
, dst
, n
);
4283 case MESA_FORMAT_Z32_FLOAT_S8X24_UINT
:
4284 unpack_uint_24_8_depth_stencil_Z32_S8X24(src
, dst
, n
);
4288 "bad format %s in _mesa_unpack_uint_24_8_depth_stencil_row",
4289 _mesa_get_format_name(format
));
4295 unpack_float_32_uint_24_8_Z24_UNORM_S8_UINT(const GLuint
*src
,
4296 GLuint
*dst
, GLuint n
)
4299 struct z32f_x24s8
*d
= (struct z32f_x24s8
*) dst
;
4300 const GLdouble scale
= 1.0 / (GLdouble
) 0xffffff;
4302 for (i
= 0; i
< n
; i
++) {
4303 const GLuint z24
= src
[i
] & 0xffffff;
4304 d
[i
].z
= z24
* scale
;
4305 d
[i
].x24s8
= src
[i
] >> 24;
4306 assert(d
[i
].z
>= 0.0f
);
4307 assert(d
[i
].z
<= 1.0f
);
4312 unpack_float_32_uint_24_8_Z32_FLOAT_S8X24_UINT(const GLuint
*src
,
4313 GLuint
*dst
, GLuint n
)
4315 memcpy(dst
, src
, n
* sizeof(struct z32f_x24s8
));
4319 unpack_float_32_uint_24_8_S8_UINT_Z24_UNORM(const GLuint
*src
,
4320 GLuint
*dst
, GLuint n
)
4323 struct z32f_x24s8
*d
= (struct z32f_x24s8
*) dst
;
4324 const GLdouble scale
= 1.0 / (GLdouble
) 0xffffff;
4326 for (i
= 0; i
< n
; i
++) {
4327 const GLuint z24
= src
[i
] >> 8;
4328 d
[i
].z
= z24
* scale
;
4329 d
[i
].x24s8
= src
[i
] & 0xff;
4330 assert(d
[i
].z
>= 0.0f
);
4331 assert(d
[i
].z
<= 1.0f
);
4336 * Unpack depth/stencil returning as GL_FLOAT_32_UNSIGNED_INT_24_8_REV.
4337 * \param format the source data format
4339 * In GL_FLOAT_32_UNSIGNED_INT_24_8_REV lower 4 bytes contain float
4340 * component and higher 4 bytes contain packed 24-bit and 8-bit
4343 * 31 30 29 28 ... 4 3 2 1 0 31 30 29 ... 9 8 7 6 5 ... 2 1 0
4344 * +-------------------------+ +--------------------------------+
4345 * | Float Component | | Unused | 8 bit stencil |
4346 * +-------------------------+ +--------------------------------+
4347 * lower 4 bytes higher 4 bytes
4350 _mesa_unpack_float_32_uint_24_8_depth_stencil_row(mesa_format format
, GLuint n
,
4351 const void *src
, GLuint
*dst
)
4354 case MESA_FORMAT_S8_UINT_Z24_UNORM
:
4355 unpack_float_32_uint_24_8_S8_UINT_Z24_UNORM(src
, dst
, n
);
4357 case MESA_FORMAT_Z24_UNORM_S8_UINT
:
4358 unpack_float_32_uint_24_8_Z24_UNORM_S8_UINT(src
, dst
, n
);
4360 case MESA_FORMAT_Z32_FLOAT_S8X24_UINT
:
4361 unpack_float_32_uint_24_8_Z32_FLOAT_S8X24_UINT(src
, dst
, n
);
4365 "bad format %s in _mesa_unpack_uint_24_8_depth_stencil_row",
4366 _mesa_get_format_name(format
));
4372 * Unpack depth/stencil
4373 * \param format the source data format
4374 * \param type the destination data type
4377 _mesa_unpack_depth_stencil_row(mesa_format format
, GLuint n
,
4378 const void *src
, GLenum type
,
4381 assert(type
== GL_UNSIGNED_INT_24_8
||
4382 type
== GL_FLOAT_32_UNSIGNED_INT_24_8_REV
);
4385 case GL_UNSIGNED_INT_24_8
:
4386 _mesa_unpack_uint_24_8_depth_stencil_row(format
, n
, src
, dst
);
4388 case GL_FLOAT_32_UNSIGNED_INT_24_8_REV
:
4389 _mesa_unpack_float_32_uint_24_8_depth_stencil_row(format
, n
, src
, dst
);
4393 "bad type 0x%x in _mesa_unpack_depth_stencil_row",