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 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 #include "format_unpack.h"
28 #include "../../gallium/auxiliary/util/u_format_rgb9e5.h"
29 #include "../../gallium/auxiliary/util/u_format_r11g11b10f.h"
33 * Convert an 8-bit sRGB value from non-linear space to a
34 * linear RGB value in [0, 1].
35 * Implemented with a 256-entry lookup table.
38 nonlinear_to_linear(GLubyte cs8
)
40 static GLfloat table
[256];
41 static GLboolean tableReady
= GL_FALSE
;
43 /* compute lookup table now */
45 for (i
= 0; i
< 256; i
++) {
46 const GLfloat cs
= UBYTE_TO_FLOAT(i
);
48 table
[i
] = cs
/ 12.92f
;
51 table
[i
] = (GLfloat
) pow((cs
+ 0.055) / 1.055, 2.4);
60 typedef void (*unpack_rgba_func
)(const void *src
, GLfloat dst
[][4], GLuint n
);
64 unpack_RGBA8888(const void *src
, GLfloat dst
[][4], GLuint n
)
66 const GLuint
*s
= ((const GLuint
*) src
);
68 for (i
= 0; i
< n
; i
++) {
69 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 24) );
70 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 16) & 0xff );
71 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 8) & 0xff );
72 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( (s
[i
] ) & 0xff );
77 unpack_RGBA8888_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
79 const GLuint
*s
= ((const GLuint
*) src
);
81 for (i
= 0; i
< n
; i
++) {
82 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( (s
[i
] ) & 0xff );
83 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 8) & 0xff );
84 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 16) & 0xff );
85 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 24) );
90 unpack_ARGB8888(const void *src
, GLfloat dst
[][4], GLuint n
)
92 const GLuint
*s
= ((const GLuint
*) src
);
94 for (i
= 0; i
< n
; i
++) {
95 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 16) & 0xff );
96 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 8) & 0xff );
97 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( (s
[i
] ) & 0xff );
98 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 24) );
103 unpack_ARGB8888_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
105 const GLuint
*s
= ((const GLuint
*) src
);
107 for (i
= 0; i
< n
; i
++) {
108 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 8) & 0xff );
109 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 16) & 0xff );
110 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 24) );
111 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( (s
[i
] ) & 0xff );
116 unpack_XRGB8888(const void *src
, GLfloat dst
[][4], GLuint n
)
118 const GLuint
*s
= ((const GLuint
*) src
);
120 for (i
= 0; i
< n
; i
++) {
121 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 16) & 0xff );
122 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 8) & 0xff );
123 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( (s
[i
] ) & 0xff );
124 dst
[i
][ACOMP
] = 1.0f
;
129 unpack_XRGB8888_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
131 const GLuint
*s
= ((const GLuint
*) src
);
133 for (i
= 0; i
< n
; i
++) {
134 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 8) & 0xff );
135 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 16) & 0xff );
136 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 24) );
137 dst
[i
][ACOMP
] = 1.0f
;
142 unpack_RGB888(const void *src
, GLfloat dst
[][4], GLuint n
)
144 const GLubyte
*s
= (const GLubyte
*) src
;
146 for (i
= 0; i
< n
; i
++) {
147 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( s
[i
*3+2] );
148 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( s
[i
*3+1] );
149 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( s
[i
*3+0] );
150 dst
[i
][ACOMP
] = 1.0F
;
155 unpack_BGR888(const void *src
, GLfloat dst
[][4], GLuint n
)
157 const GLubyte
*s
= (const GLubyte
*) src
;
159 for (i
= 0; i
< n
; i
++) {
160 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( s
[i
*3+0] );
161 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( s
[i
*3+1] );
162 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( s
[i
*3+2] );
163 dst
[i
][ACOMP
] = 1.0F
;
168 unpack_RGB565(const void *src
, GLfloat dst
[][4], GLuint n
)
170 const GLushort
*s
= ((const GLushort
*) src
);
172 for (i
= 0; i
< n
; i
++) {
173 dst
[i
][RCOMP
] = ((s
[i
] >> 11) & 0x1f) * (1.0F
/ 31.0F
);
174 dst
[i
][GCOMP
] = ((s
[i
] >> 5 ) & 0x3f) * (1.0F
/ 63.0F
);
175 dst
[i
][BCOMP
] = ((s
[i
] ) & 0x1f) * (1.0F
/ 31.0F
);
176 dst
[i
][ACOMP
] = 1.0F
;
181 unpack_RGB565_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
183 const GLushort
*s
= ((const GLushort
*) src
);
185 for (i
= 0; i
< n
; i
++) {
186 GLuint t
= (s
[i
] >> 8) | (s
[i
] << 8); /* byte swap */
187 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( ((t
>> 8) & 0xf8) | ((t
>> 13) & 0x7) );
188 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( ((t
>> 3) & 0xfc) | ((t
>> 9) & 0x3) );
189 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( ((t
<< 3) & 0xf8) | ((t
>> 2) & 0x7) );
190 dst
[i
][ACOMP
] = 1.0F
;
195 unpack_ARGB4444(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
] >> 8) & 0xf) * (1.0F
/ 15.0F
);
201 dst
[i
][GCOMP
] = ((s
[i
] >> 4) & 0xf) * (1.0F
/ 15.0F
);
202 dst
[i
][BCOMP
] = ((s
[i
] ) & 0xf) * (1.0F
/ 15.0F
);
203 dst
[i
][ACOMP
] = ((s
[i
] >> 12) & 0xf) * (1.0F
/ 15.0F
);
208 unpack_ARGB4444_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
210 const GLushort
*s
= ((const GLushort
*) src
);
212 for (i
= 0; i
< n
; i
++) {
213 dst
[i
][RCOMP
] = ((s
[i
] ) & 0xf) * (1.0F
/ 15.0F
);
214 dst
[i
][GCOMP
] = ((s
[i
] >> 12) & 0xf) * (1.0F
/ 15.0F
);
215 dst
[i
][BCOMP
] = ((s
[i
] >> 8) & 0xf) * (1.0F
/ 15.0F
);
216 dst
[i
][ACOMP
] = ((s
[i
] >> 4) & 0xf) * (1.0F
/ 15.0F
);
221 unpack_RGBA5551(const void *src
, GLfloat dst
[][4], GLuint n
)
223 const GLushort
*s
= ((const GLushort
*) src
);
225 for (i
= 0; i
< n
; i
++) {
226 dst
[i
][RCOMP
] = ((s
[i
] >> 11) & 0x1f) * (1.0F
/ 31.0F
);
227 dst
[i
][GCOMP
] = ((s
[i
] >> 6) & 0x1f) * (1.0F
/ 31.0F
);
228 dst
[i
][BCOMP
] = ((s
[i
] >> 1) & 0x1f) * (1.0F
/ 31.0F
);
229 dst
[i
][ACOMP
] = ((s
[i
] ) & 0x01) * 1.0F
;
234 unpack_ARGB1555(const void *src
, GLfloat dst
[][4], GLuint n
)
236 const GLushort
*s
= ((const GLushort
*) src
);
238 for (i
= 0; i
< n
; i
++) {
239 dst
[i
][RCOMP
] = ((s
[i
] >> 10) & 0x1f) * (1.0F
/ 31.0F
);
240 dst
[i
][GCOMP
] = ((s
[i
] >> 5) & 0x1f) * (1.0F
/ 31.0F
);
241 dst
[i
][BCOMP
] = ((s
[i
] >> 0) & 0x1f) * (1.0F
/ 31.0F
);
242 dst
[i
][ACOMP
] = ((s
[i
] >> 15) & 0x01) * 1.0F
;
247 unpack_ARGB1555_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
249 const GLushort
*s
= ((const GLushort
*) src
);
251 for (i
= 0; i
< n
; i
++) {
252 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( ((s
[i
] >> 7) & 0xf8) | ((s
[i
] >> 12) & 0x7) );
253 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( ((s
[i
] >> 2) & 0xf8) | ((s
[i
] >> 7) & 0x7) );
254 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( ((s
[i
] << 3) & 0xf8) | ((s
[i
] >> 2) & 0x7) );
255 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( ((s
[i
] >> 15) & 0x01) * 255 );
260 unpack_AL44(const void *src
, GLfloat dst
[][4], GLuint n
)
262 const GLubyte
*s
= ((const GLubyte
*) src
);
264 for (i
= 0; i
< n
; i
++) {
267 dst
[i
][BCOMP
] = (s
[i
] & 0xf) * (1.0F
/ 15.0F
);
268 dst
[i
][ACOMP
] = ((s
[i
] >> 4) & 0xf) * (1.0F
/ 15.0F
);
273 unpack_AL88(const void *src
, GLfloat dst
[][4], GLuint n
)
275 const GLushort
*s
= ((const GLushort
*) src
);
277 for (i
= 0; i
< n
; i
++) {
280 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( s
[i
] & 0xff );
281 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 8 );
286 unpack_AL88_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
288 const GLushort
*s
= ((const GLushort
*) src
);
290 for (i
= 0; i
< n
; i
++) {
293 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 8 );
294 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( s
[i
] & 0xff );
299 unpack_AL1616(const void *src
, GLfloat dst
[][4], GLuint n
)
301 const GLuint
*s
= ((const GLuint
*) src
);
303 for (i
= 0; i
< n
; i
++) {
306 dst
[i
][BCOMP
] = USHORT_TO_FLOAT( s
[i
] & 0xffff );
307 dst
[i
][ACOMP
] = USHORT_TO_FLOAT( s
[i
] >> 16 );
312 unpack_AL1616_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
314 const GLuint
*s
= ((const GLuint
*) src
);
316 for (i
= 0; i
< n
; i
++) {
319 dst
[i
][BCOMP
] = USHORT_TO_FLOAT( s
[i
] >> 16 );
320 dst
[i
][ACOMP
] = USHORT_TO_FLOAT( s
[i
] & 0xffff );
325 unpack_RGB332(const void *src
, GLfloat dst
[][4], GLuint n
)
327 const GLubyte
*s
= ((const GLubyte
*) src
);
329 for (i
= 0; i
< n
; i
++) {
330 dst
[i
][RCOMP
] = ((s
[i
] >> 5) & 0x7) * (1.0F
/ 7.0F
);
331 dst
[i
][GCOMP
] = ((s
[i
] >> 2) & 0x7) * (1.0F
/ 7.0F
);
332 dst
[i
][BCOMP
] = ((s
[i
] ) & 0x3) * (1.0F
/ 3.0F
);
333 dst
[i
][ACOMP
] = 1.0F
;
339 unpack_A8(const void *src
, GLfloat dst
[][4], GLuint n
)
341 const GLubyte
*s
= ((const GLubyte
*) src
);
343 for (i
= 0; i
< n
; i
++) {
346 dst
[i
][BCOMP
] = 0.0F
;
347 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT(s
[i
]);
352 unpack_A16(const void *src
, GLfloat dst
[][4], GLuint n
)
354 const GLushort
*s
= ((const GLushort
*) src
);
356 for (i
= 0; i
< n
; i
++) {
359 dst
[i
][BCOMP
] = 0.0F
;
360 dst
[i
][ACOMP
] = USHORT_TO_FLOAT(s
[i
]);
365 unpack_L8(const void *src
, GLfloat dst
[][4], GLuint n
)
367 const GLubyte
*s
= ((const GLubyte
*) src
);
369 for (i
= 0; i
< n
; i
++) {
372 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT(s
[i
]);
373 dst
[i
][ACOMP
] = 1.0F
;
378 unpack_L16(const void *src
, GLfloat dst
[][4], GLuint n
)
380 const GLushort
*s
= ((const GLushort
*) src
);
382 for (i
= 0; i
< n
; i
++) {
385 dst
[i
][BCOMP
] = USHORT_TO_FLOAT(s
[i
]);
386 dst
[i
][ACOMP
] = 1.0F
;
391 unpack_I8(const void *src
, GLfloat dst
[][4], GLuint n
)
393 const GLubyte
*s
= ((const GLubyte
*) src
);
395 for (i
= 0; i
< n
; i
++) {
399 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT(s
[i
]);
404 unpack_I16(const void *src
, GLfloat dst
[][4], GLuint n
)
406 const GLushort
*s
= ((const GLushort
*) src
);
408 for (i
= 0; i
< n
; i
++) {
412 dst
[i
][ACOMP
] = USHORT_TO_FLOAT(s
[i
]);
417 unpack_YCBCR(const void *src
, GLfloat dst
[][4], GLuint n
)
420 for (i
= 0; i
< n
; i
++) {
421 const GLushort
*src0
= ((const GLushort
*) src
) + i
* 2; /* even */
422 const GLushort
*src1
= src0
+ 1; /* odd */
423 const GLubyte y0
= (*src0
>> 8) & 0xff; /* luminance */
424 const GLubyte cb
= *src0
& 0xff; /* chroma U */
425 const GLubyte y1
= (*src1
>> 8) & 0xff; /* luminance */
426 const GLubyte cr
= *src1
& 0xff; /* chroma V */
427 const GLubyte y
= (i
& 1) ? y1
: y0
; /* choose even/odd luminance */
428 GLfloat r
= 1.164F
* (y
- 16) + 1.596F
* (cr
- 128);
429 GLfloat g
= 1.164F
* (y
- 16) - 0.813F
* (cr
- 128) - 0.391F
* (cb
- 128);
430 GLfloat b
= 1.164F
* (y
- 16) + 2.018F
* (cb
- 128);
431 r
*= (1.0F
/ 255.0F
);
432 g
*= (1.0F
/ 255.0F
);
433 b
*= (1.0F
/ 255.0F
);
434 dst
[i
][RCOMP
] = CLAMP(r
, 0.0F
, 1.0F
);
435 dst
[i
][GCOMP
] = CLAMP(g
, 0.0F
, 1.0F
);
436 dst
[i
][BCOMP
] = CLAMP(b
, 0.0F
, 1.0F
);
437 dst
[i
][ACOMP
] = 1.0F
;
442 unpack_YCBCR_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
445 for (i
= 0; i
< n
; i
++) {
446 const GLushort
*src0
= ((const GLushort
*) src
) + i
* 2; /* even */
447 const GLushort
*src1
= src0
+ 1; /* odd */
448 const GLubyte y0
= *src0
& 0xff; /* luminance */
449 const GLubyte cr
= (*src0
>> 8) & 0xff; /* chroma V */
450 const GLubyte y1
= *src1
& 0xff; /* luminance */
451 const GLubyte cb
= (*src1
>> 8) & 0xff; /* chroma U */
452 const GLubyte y
= (i
& 1) ? y1
: y0
; /* choose even/odd luminance */
453 GLfloat r
= 1.164F
* (y
- 16) + 1.596F
* (cr
- 128);
454 GLfloat g
= 1.164F
* (y
- 16) - 0.813F
* (cr
- 128) - 0.391F
* (cb
- 128);
455 GLfloat b
= 1.164F
* (y
- 16) + 2.018F
* (cb
- 128);
456 r
*= (1.0F
/ 255.0F
);
457 g
*= (1.0F
/ 255.0F
);
458 b
*= (1.0F
/ 255.0F
);
459 dst
[i
][RCOMP
] = CLAMP(r
, 0.0F
, 1.0F
);
460 dst
[i
][GCOMP
] = CLAMP(g
, 0.0F
, 1.0F
);
461 dst
[i
][BCOMP
] = CLAMP(b
, 0.0F
, 1.0F
);
462 dst
[i
][ACOMP
] = 1.0F
;
467 unpack_R8(const void *src
, GLfloat dst
[][4], GLuint n
)
469 const GLubyte
*s
= ((const GLubyte
*) src
);
471 for (i
= 0; i
< n
; i
++) {
472 dst
[i
][0] = UBYTE_TO_FLOAT(s
[i
]);
480 unpack_RG88(const void *src
, GLfloat dst
[][4], GLuint n
)
482 const GLushort
*s
= ((const GLushort
*) src
);
484 for (i
= 0; i
< n
; i
++) {
485 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( s
[i
] & 0xff );
486 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 8 );
493 unpack_RG88_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
495 const GLushort
*s
= ((const GLushort
*) src
);
497 for (i
= 0; i
< n
; i
++) {
498 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( s
[i
] & 0xff );
499 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 8 );
506 unpack_R16(const void *src
, GLfloat dst
[][4], GLuint n
)
508 const GLushort
*s
= ((const GLushort
*) src
);
510 for (i
= 0; i
< n
; i
++) {
511 dst
[i
][RCOMP
] = USHORT_TO_FLOAT(s
[i
]);
519 unpack_RG1616(const void *src
, GLfloat dst
[][4], GLuint n
)
521 const GLuint
*s
= ((const GLuint
*) src
);
523 for (i
= 0; i
< n
; i
++) {
524 dst
[i
][RCOMP
] = USHORT_TO_FLOAT( s
[i
] & 0xffff );
525 dst
[i
][GCOMP
] = USHORT_TO_FLOAT( s
[i
] >> 16 );
532 unpack_RG1616_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
534 const GLuint
*s
= ((const GLuint
*) src
);
536 for (i
= 0; i
< n
; i
++) {
537 dst
[i
][RCOMP
] = USHORT_TO_FLOAT( s
[i
] >> 16 );
538 dst
[i
][GCOMP
] = USHORT_TO_FLOAT( s
[i
] & 0xffff );
545 unpack_ARGB2101010(const void *src
, GLfloat dst
[][4], GLuint n
)
547 const GLuint
*s
= ((const GLuint
*) src
);
549 for (i
= 0; i
< n
; i
++) {
550 dst
[i
][RCOMP
] = ((s
[i
] >> 20) & 0x3ff) * (1.0F
/ 1023.0F
);
551 dst
[i
][GCOMP
] = ((s
[i
] >> 10) & 0x3ff) * (1.0F
/ 1023.0F
);
552 dst
[i
][BCOMP
] = ((s
[i
] >> 0) & 0x3ff) * (1.0F
/ 1023.0F
);
553 dst
[i
][ACOMP
] = ((s
[i
] >> 30) & 0x03) * (1.0F
/ 3.0F
);
559 unpack_Z24_S8(const void *src
, GLfloat dst
[][4], GLuint n
)
561 /* only return Z, not stencil data */
562 const GLuint
*s
= ((const GLuint
*) src
);
563 const GLfloat scale
= 1.0F
/ (GLfloat
) 0xffffff;
565 for (i
= 0; i
< n
; i
++) {
568 dst
[i
][2] = (s
[i
] >> 8) * scale
;
570 ASSERT(dst
[i
][0] >= 0.0F
);
571 ASSERT(dst
[i
][0] <= 1.0F
);
576 unpack_S8_Z24(const void *src
, GLfloat dst
[][4], GLuint n
)
578 /* only return Z, not stencil data */
579 const GLuint
*s
= ((const GLuint
*) src
);
580 const GLfloat scale
= 1.0F
/ (GLfloat
) 0xffffff;
582 for (i
= 0; i
< n
; i
++) {
585 dst
[i
][2] = (s
[i
] & 0x00ffffff) * scale
;
587 ASSERT(dst
[i
][0] >= 0.0F
);
588 ASSERT(dst
[i
][0] <= 1.0F
);
593 unpack_Z16(const void *src
, GLfloat dst
[][4], GLuint n
)
595 const GLushort
*s
= ((const GLushort
*) src
);
597 for (i
= 0; i
< n
; i
++) {
600 dst
[i
][2] = s
[i
] * (1.0F
/ 65535.0F
);
606 unpack_X8_Z24(const void *src
, GLfloat dst
[][4], GLuint n
)
608 unpack_S8_Z24(src
, dst
, n
);
612 unpack_Z24_X8(const void *src
, GLfloat dst
[][4], GLuint n
)
614 unpack_Z24_S8(src
, dst
, n
);
618 unpack_Z32(const void *src
, GLfloat dst
[][4], GLuint n
)
620 const GLuint
*s
= ((const GLuint
*) src
);
622 for (i
= 0; i
< n
; i
++) {
625 dst
[i
][2] = s
[i
] * (1.0F
/ 0xffffffff);
631 unpack_Z32_FLOAT(const void *src
, GLfloat dst
[][4], GLuint n
)
633 const GLfloat
*s
= ((const GLfloat
*) src
);
635 for (i
= 0; i
< n
; i
++) {
644 unpack_Z32_FLOAT_X24S8(const void *src
, GLfloat dst
[][4], GLuint n
)
646 const GLfloat
*s
= ((const GLfloat
*) src
);
648 for (i
= 0; i
< n
; i
++) {
658 unpack_S8(const void *src
, GLfloat dst
[][4], GLuint n
)
660 /* should never be used */
662 for (i
= 0; i
< n
; i
++) {
672 unpack_SRGB8(const void *src
, GLfloat dst
[][4], GLuint n
)
674 const GLubyte
*s
= (const GLubyte
*) src
;
676 for (i
= 0; i
< n
; i
++) {
677 dst
[i
][RCOMP
] = nonlinear_to_linear(s
[i
*3+2]);
678 dst
[i
][GCOMP
] = nonlinear_to_linear(s
[i
*3+1]);
679 dst
[i
][BCOMP
] = nonlinear_to_linear(s
[i
*3+0]);
680 dst
[i
][ACOMP
] = 1.0F
;
685 unpack_SRGBA8(const void *src
, GLfloat dst
[][4], GLuint n
)
687 const GLuint
*s
= ((const GLuint
*) src
);
689 for (i
= 0; i
< n
; i
++) {
690 dst
[i
][RCOMP
] = nonlinear_to_linear( (s
[i
] >> 24) );
691 dst
[i
][GCOMP
] = nonlinear_to_linear( (s
[i
] >> 16) & 0xff );
692 dst
[i
][BCOMP
] = nonlinear_to_linear( (s
[i
] >> 8) & 0xff );
693 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( s
[i
] & 0xff ); /* linear! */
698 unpack_SARGB8(const void *src
, GLfloat dst
[][4], GLuint n
)
700 const GLuint
*s
= ((const GLuint
*) src
);
702 for (i
= 0; i
< n
; i
++) {
703 dst
[i
][RCOMP
] = nonlinear_to_linear( (s
[i
] >> 16) & 0xff );
704 dst
[i
][GCOMP
] = nonlinear_to_linear( (s
[i
] >> 8) & 0xff );
705 dst
[i
][BCOMP
] = nonlinear_to_linear( (s
[i
] ) & 0xff );
706 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 24 ); /* linear! */
711 unpack_SL8(const void *src
, GLfloat dst
[][4], GLuint n
)
713 const GLubyte
*s
= ((const GLubyte
*) src
);
715 for (i
= 0; i
< n
; i
++) {
718 dst
[i
][BCOMP
] = nonlinear_to_linear(s
[i
]);
719 dst
[i
][ACOMP
] = 1.0F
;
724 unpack_SLA8(const void *src
, GLfloat dst
[][4], GLuint n
)
726 const GLubyte
*s
= (const GLubyte
*) src
;
728 for (i
= 0; i
< n
; i
++) {
731 dst
[i
][BCOMP
] = nonlinear_to_linear(s
[i
*2+0]);
732 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT(s
[i
*2+1]); /* linear! */
737 unpack_SRGB_DXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
742 unpack_SRGBA_DXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
747 unpack_SRGBA_DXT3(const void *src
, GLfloat dst
[][4], GLuint n
)
752 unpack_SRGBA_DXT5(const void *src
, GLfloat dst
[][4], GLuint n
)
757 unpack_RGB_FXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
762 unpack_RGBA_FXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
767 unpack_RGB_DXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
772 unpack_RGBA_DXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
777 unpack_RGBA_DXT3(const void *src
, GLfloat dst
[][4], GLuint n
)
782 unpack_RGBA_DXT5(const void *src
, GLfloat dst
[][4], GLuint n
)
788 unpack_RGBA_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
790 const GLfloat
*s
= (const GLfloat
*) src
;
792 for (i
= 0; i
< n
; i
++) {
793 dst
[i
][RCOMP
] = s
[i
*4+0];
794 dst
[i
][GCOMP
] = s
[i
*4+1];
795 dst
[i
][BCOMP
] = s
[i
*4+2];
796 dst
[i
][ACOMP
] = s
[i
*4+3];
801 unpack_RGBA_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
803 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
805 for (i
= 0; i
< n
; i
++) {
806 dst
[i
][RCOMP
] = _mesa_half_to_float(s
[i
*4+0]);
807 dst
[i
][GCOMP
] = _mesa_half_to_float(s
[i
*4+1]);
808 dst
[i
][BCOMP
] = _mesa_half_to_float(s
[i
*4+2]);
809 dst
[i
][ACOMP
] = _mesa_half_to_float(s
[i
*4+3]);
814 unpack_RGB_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
816 const GLfloat
*s
= (const GLfloat
*) src
;
818 for (i
= 0; i
< n
; i
++) {
819 dst
[i
][RCOMP
] = s
[i
*3+0];
820 dst
[i
][GCOMP
] = s
[i
*3+1];
821 dst
[i
][BCOMP
] = s
[i
*3+2];
822 dst
[i
][ACOMP
] = 1.0F
;
827 unpack_RGB_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
829 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
831 for (i
= 0; i
< n
; i
++) {
832 dst
[i
][RCOMP
] = _mesa_half_to_float(s
[i
*3+0]);
833 dst
[i
][GCOMP
] = _mesa_half_to_float(s
[i
*3+1]);
834 dst
[i
][BCOMP
] = _mesa_half_to_float(s
[i
*3+2]);
835 dst
[i
][ACOMP
] = 1.0F
;
840 unpack_ALPHA_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
842 const GLfloat
*s
= (const GLfloat
*) src
;
844 for (i
= 0; i
< n
; i
++) {
847 dst
[i
][BCOMP
] = 0.0F
;
848 dst
[i
][ACOMP
] = s
[i
];
853 unpack_ALPHA_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
855 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
857 for (i
= 0; i
< n
; i
++) {
860 dst
[i
][BCOMP
] = 0.0F
;
861 dst
[i
][ACOMP
] = _mesa_half_to_float(s
[i
]);
866 unpack_LUMINANCE_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
868 const GLfloat
*s
= (const GLfloat
*) src
;
870 for (i
= 0; i
< n
; i
++) {
873 dst
[i
][BCOMP
] = s
[i
];
874 dst
[i
][ACOMP
] = 1.0F
;
879 unpack_LUMINANCE_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
881 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
883 for (i
= 0; i
< n
; i
++) {
886 dst
[i
][BCOMP
] = _mesa_half_to_float(s
[i
]);
887 dst
[i
][ACOMP
] = 1.0F
;
892 unpack_LUMINANCE_ALPHA_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
894 const GLfloat
*s
= (const GLfloat
*) src
;
896 for (i
= 0; i
< n
; i
++) {
899 dst
[i
][BCOMP
] = s
[i
*2+0];
900 dst
[i
][ACOMP
] = s
[i
*2+1];
905 unpack_LUMINANCE_ALPHA_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
907 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
909 for (i
= 0; i
< n
; i
++) {
912 dst
[i
][BCOMP
] = _mesa_half_to_float(s
[i
*2+0]);
913 dst
[i
][ACOMP
] = _mesa_half_to_float(s
[i
*2+1]);
918 unpack_INTENSITY_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
920 const GLfloat
*s
= (const GLfloat
*) src
;
922 for (i
= 0; i
< n
; i
++) {
926 dst
[i
][ACOMP
] = s
[i
];
931 unpack_INTENSITY_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
933 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
935 for (i
= 0; i
< n
; i
++) {
939 dst
[i
][ACOMP
] = _mesa_half_to_float(s
[i
]);
944 unpack_R_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
946 const GLfloat
*s
= (const GLfloat
*) src
;
948 for (i
= 0; i
< n
; i
++) {
949 dst
[i
][RCOMP
] = s
[i
];
950 dst
[i
][GCOMP
] = 0.0F
;
951 dst
[i
][BCOMP
] = 0.0F
;
952 dst
[i
][ACOMP
] = 1.0F
;
957 unpack_R_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
959 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
961 for (i
= 0; i
< n
; i
++) {
962 dst
[i
][RCOMP
] = _mesa_half_to_float(s
[i
]);
963 dst
[i
][GCOMP
] = 0.0F
;
964 dst
[i
][BCOMP
] = 0.0F
;
965 dst
[i
][ACOMP
] = 1.0F
;
970 unpack_RG_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
972 const GLfloat
*s
= (const GLfloat
*) src
;
974 for (i
= 0; i
< n
; i
++) {
975 dst
[i
][RCOMP
] = s
[i
*2+0];
976 dst
[i
][GCOMP
] = s
[i
*2+1];
977 dst
[i
][BCOMP
] = 0.0F
;
978 dst
[i
][ACOMP
] = 1.0F
;
983 unpack_RG_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
985 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
987 for (i
= 0; i
< n
; i
++) {
988 dst
[i
][RCOMP
] = _mesa_half_to_float(s
[i
*2+0]);
989 dst
[i
][GCOMP
] = _mesa_half_to_float(s
[i
*2+1]);
990 dst
[i
][BCOMP
] = 0.0F
;
991 dst
[i
][ACOMP
] = 1.0F
;
997 unpack_RGBA_INT8(const void *src
, GLfloat dst
[][4], GLuint n
)
999 const GLbyte
*s
= (const GLbyte
*) src
;
1001 for (i
= 0; i
< n
; i
++) {
1002 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1003 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1004 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1005 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1010 unpack_RGBA_INT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1012 const GLshort
*s
= (const GLshort
*) src
;
1014 for (i
= 0; i
< n
; i
++) {
1015 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1016 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1017 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1018 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1023 unpack_RGBA_INT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1025 const GLint
*s
= (const GLint
*) src
;
1027 for (i
= 0; i
< n
; i
++) {
1028 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1029 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1030 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1031 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1036 unpack_RGBA_UINT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1038 const GLubyte
*s
= (const GLubyte
*) src
;
1040 for (i
= 0; i
< n
; i
++) {
1041 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1042 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1043 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1044 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1049 unpack_RGBA_UINT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1051 const GLushort
*s
= (const GLushort
*) src
;
1053 for (i
= 0; i
< n
; i
++) {
1054 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1055 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1056 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1057 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1062 unpack_RGBA_UINT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1064 const GLuint
*s
= (const GLuint
*) src
;
1066 for (i
= 0; i
< n
; i
++) {
1067 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1068 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1069 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1070 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1075 unpack_DUDV8(const void *src
, GLfloat dst
[][4], GLuint n
)
1077 const GLbyte
*s
= (const GLbyte
*) src
;
1079 for (i
= 0; i
< n
; i
++) {
1080 dst
[i
][RCOMP
] = BYTE_TO_FLOAT(s
[i
*2+0]);
1081 dst
[i
][GCOMP
] = BYTE_TO_FLOAT(s
[i
*2+1]);
1088 unpack_SIGNED_R8(const void *src
, GLfloat dst
[][4], GLuint n
)
1090 const GLbyte
*s
= ((const GLbyte
*) src
);
1092 for (i
= 0; i
< n
; i
++) {
1093 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( s
[i
] );
1094 dst
[i
][GCOMP
] = 0.0F
;
1095 dst
[i
][BCOMP
] = 0.0F
;
1096 dst
[i
][ACOMP
] = 1.0F
;
1101 unpack_SIGNED_RG88_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
1103 const GLushort
*s
= ((const GLushort
*) src
);
1105 for (i
= 0; i
< n
; i
++) {
1106 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] & 0xff) );
1107 dst
[i
][GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
1108 dst
[i
][BCOMP
] = 0.0F
;
1109 dst
[i
][ACOMP
] = 1.0F
;
1114 unpack_SIGNED_RGBX8888(const void *src
, GLfloat dst
[][4], GLuint n
)
1116 const GLuint
*s
= ((const GLuint
*) src
);
1118 for (i
= 0; i
< n
; i
++) {
1119 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 24) );
1120 dst
[i
][GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 16) );
1121 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
1122 dst
[i
][ACOMP
] = 1.0f
;
1127 unpack_SIGNED_RGBA8888(const void *src
, GLfloat dst
[][4], GLuint n
)
1129 const GLuint
*s
= ((const GLuint
*) src
);
1131 for (i
= 0; i
< n
; i
++) {
1132 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 24) );
1133 dst
[i
][GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 16) );
1134 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
1135 dst
[i
][ACOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] ) );
1140 unpack_SIGNED_RGBA8888_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
1142 const GLuint
*s
= ((const GLuint
*) src
);
1144 for (i
= 0; i
< n
; i
++) {
1145 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] ) );
1146 dst
[i
][GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
1147 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 16) );
1148 dst
[i
][ACOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 24) );
1153 unpack_SIGNED_R16(const void *src
, GLfloat dst
[][4], GLuint n
)
1155 const GLshort
*s
= ((const GLshort
*) src
);
1157 for (i
= 0; i
< n
; i
++) {
1158 dst
[i
][RCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
] );
1159 dst
[i
][GCOMP
] = 0.0F
;
1160 dst
[i
][BCOMP
] = 0.0F
;
1161 dst
[i
][ACOMP
] = 1.0F
;
1166 unpack_SIGNED_GR1616(const void *src
, GLfloat dst
[][4], GLuint n
)
1168 const GLuint
*s
= ((const GLuint
*) src
);
1170 for (i
= 0; i
< n
; i
++) {
1171 dst
[i
][RCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
] & 0xffff );
1172 dst
[i
][GCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
] >> 16 );
1173 dst
[i
][BCOMP
] = 0.0F
;
1174 dst
[i
][ACOMP
] = 1.0F
;
1179 unpack_SIGNED_RGB_16(const void *src
, GLfloat dst
[][4], GLuint n
)
1181 const GLshort
*s
= (const GLshort
*) src
;
1183 for (i
= 0; i
< n
; i
++) {
1184 dst
[i
][RCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*3+0] );
1185 dst
[i
][GCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*3+1] );
1186 dst
[i
][BCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*3+2] );
1187 dst
[i
][ACOMP
] = 1.0F
;
1192 unpack_SIGNED_RGBA_16(const void *src
, GLfloat dst
[][4], GLuint n
)
1194 const GLshort
*s
= (const GLshort
*) src
;
1196 for (i
= 0; i
< n
; i
++) {
1197 dst
[i
][RCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+0] );
1198 dst
[i
][GCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+1] );
1199 dst
[i
][BCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+2] );
1200 dst
[i
][ACOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+3] );
1205 unpack_RGBA_16(const void *src
, GLfloat dst
[][4], GLuint n
)
1207 const GLushort
*s
= (const GLushort
*) src
;
1209 for (i
= 0; i
< n
; i
++) {
1210 dst
[i
][RCOMP
] = USHORT_TO_FLOAT( s
[i
*4+0] );
1211 dst
[i
][GCOMP
] = USHORT_TO_FLOAT( s
[i
*4+1] );
1212 dst
[i
][BCOMP
] = USHORT_TO_FLOAT( s
[i
*4+2] );
1213 dst
[i
][ACOMP
] = USHORT_TO_FLOAT( s
[i
*4+3] );
1218 unpack_RED_RGTC1(const void *src
, GLfloat dst
[][4], GLuint n
)
1224 unpack_SIGNED_RED_RGTC1(const void *src
, GLfloat dst
[][4], GLuint n
)
1230 unpack_RG_RGTC2(const void *src
, GLfloat dst
[][4], GLuint n
)
1236 unpack_SIGNED_RG_RGTC2(const void *src
, GLfloat dst
[][4], GLuint n
)
1242 unpack_L_LATC1(const void *src
, GLfloat dst
[][4], GLuint n
)
1248 unpack_SIGNED_L_LATC1(const void *src
, GLfloat dst
[][4], GLuint n
)
1254 unpack_LA_LATC2(const void *src
, GLfloat dst
[][4], GLuint n
)
1260 unpack_SIGNED_LA_LATC2(const void *src
, GLfloat dst
[][4], GLuint n
)
1266 unpack_SIGNED_A8(const void *src
, GLfloat dst
[][4], GLuint n
)
1268 const GLbyte
*s
= ((const GLbyte
*) src
);
1270 for (i
= 0; i
< n
; i
++) {
1271 dst
[i
][RCOMP
] = 0.0F
;
1272 dst
[i
][GCOMP
] = 0.0F
;
1273 dst
[i
][BCOMP
] = 0.0F
;
1274 dst
[i
][ACOMP
] = BYTE_TO_FLOAT_TEX( s
[i
] );
1279 unpack_SIGNED_L8(const void *src
, GLfloat dst
[][4], GLuint n
)
1281 const GLbyte
*s
= ((const GLbyte
*) src
);
1283 for (i
= 0; i
< n
; i
++) {
1286 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( s
[i
] );
1287 dst
[i
][ACOMP
] = 1.0F
;
1292 unpack_SIGNED_AL88(const void *src
, GLfloat dst
[][4], GLuint n
)
1294 const GLshort
*s
= ((const GLshort
*) src
);
1296 for (i
= 0; i
< n
; i
++) {
1299 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] & 0xff) );
1300 dst
[i
][ACOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
1305 unpack_SIGNED_I8(const void *src
, GLfloat dst
[][4], GLuint n
)
1307 const GLbyte
*s
= ((const GLbyte
*) src
);
1309 for (i
= 0; i
< n
; i
++) {
1313 dst
[i
][ACOMP
] = BYTE_TO_FLOAT_TEX( s
[i
] );
1318 unpack_SIGNED_A16(const void *src
, GLfloat dst
[][4], GLuint n
)
1320 const GLshort
*s
= ((const GLshort
*) src
);
1322 for (i
= 0; i
< n
; i
++) {
1323 dst
[i
][RCOMP
] = 0.0F
;
1324 dst
[i
][GCOMP
] = 0.0F
;
1325 dst
[i
][BCOMP
] = 0.0F
;
1326 dst
[i
][ACOMP
] = SHORT_TO_FLOAT_TEX( s
[i
] );
1331 unpack_SIGNED_L16(const void *src
, GLfloat dst
[][4], GLuint n
)
1333 const GLshort
*s
= ((const GLshort
*) src
);
1335 for (i
= 0; i
< n
; i
++) {
1338 dst
[i
][BCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
] );
1339 dst
[i
][ACOMP
] = 1.0F
;
1344 unpack_SIGNED_AL1616(const void *src
, GLfloat dst
[][4], GLuint n
)
1346 const GLshort
*s
= (const GLshort
*) src
;
1348 for (i
= 0; i
< n
; i
++) {
1351 dst
[i
][BCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*2+0] );
1352 dst
[i
][ACOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*2+1] );
1357 unpack_SIGNED_I16(const void *src
, GLfloat dst
[][4], GLuint n
)
1359 const GLshort
*s
= ((const GLshort
*) src
);
1361 for (i
= 0; i
< n
; i
++) {
1365 dst
[i
][ACOMP
] = SHORT_TO_FLOAT_TEX( s
[i
] );
1370 unpack_RGB9_E5_FLOAT(const void *src
, GLfloat dst
[][4], GLuint n
)
1372 const GLuint
*s
= (const GLuint
*) src
;
1374 for (i
= 0; i
< n
; i
++) {
1375 rgb9e5_to_float3(s
[i
], dst
[i
]);
1376 dst
[i
][ACOMP
] = 1.0F
;
1381 unpack_R11_G11_B10_FLOAT(const void *src
, GLfloat dst
[][4], GLuint n
)
1383 const GLuint
*s
= (const GLuint
*) src
;
1385 for (i
= 0; i
< n
; i
++) {
1386 r11g11b10f_to_float3(s
[i
], dst
[i
]);
1387 dst
[i
][ACOMP
] = 1.0F
;
1393 * Return the unpacker function for the given format.
1395 static unpack_rgba_func
1396 get_unpack_rgba_function(gl_format format
)
1398 static unpack_rgba_func table
[MESA_FORMAT_COUNT
];
1399 static GLboolean initialized
= GL_FALSE
;
1402 table
[MESA_FORMAT_NONE
] = NULL
;
1404 table
[MESA_FORMAT_RGBA8888
] = unpack_RGBA8888
;
1405 table
[MESA_FORMAT_RGBA8888_REV
] = unpack_RGBA8888_REV
;
1406 table
[MESA_FORMAT_ARGB8888
] = unpack_ARGB8888
;
1407 table
[MESA_FORMAT_ARGB8888_REV
] = unpack_ARGB8888_REV
;
1408 table
[MESA_FORMAT_XRGB8888
] = unpack_XRGB8888
;
1409 table
[MESA_FORMAT_XRGB8888_REV
] = unpack_XRGB8888_REV
;
1410 table
[MESA_FORMAT_RGB888
] = unpack_RGB888
;
1411 table
[MESA_FORMAT_BGR888
] = unpack_BGR888
;
1412 table
[MESA_FORMAT_RGB565
] = unpack_RGB565
;
1413 table
[MESA_FORMAT_RGB565_REV
] = unpack_RGB565_REV
;
1414 table
[MESA_FORMAT_ARGB4444
] = unpack_ARGB4444
;
1415 table
[MESA_FORMAT_ARGB4444_REV
] = unpack_ARGB4444_REV
;
1416 table
[MESA_FORMAT_RGBA5551
] = unpack_RGBA5551
;
1417 table
[MESA_FORMAT_ARGB1555
] = unpack_ARGB1555
;
1418 table
[MESA_FORMAT_ARGB1555_REV
] = unpack_ARGB1555_REV
;
1419 table
[MESA_FORMAT_AL44
] = unpack_AL44
;
1420 table
[MESA_FORMAT_AL88
] = unpack_AL88
;
1421 table
[MESA_FORMAT_AL88_REV
] = unpack_AL88_REV
;
1422 table
[MESA_FORMAT_AL1616
] = unpack_AL1616
;
1423 table
[MESA_FORMAT_AL1616_REV
] = unpack_AL1616_REV
;
1424 table
[MESA_FORMAT_RGB332
] = unpack_RGB332
;
1425 table
[MESA_FORMAT_A8
] = unpack_A8
;
1426 table
[MESA_FORMAT_A16
] = unpack_A16
;
1427 table
[MESA_FORMAT_L8
] = unpack_L8
;
1428 table
[MESA_FORMAT_L16
] = unpack_L16
;
1429 table
[MESA_FORMAT_I8
] = unpack_I8
;
1430 table
[MESA_FORMAT_I16
] = unpack_I16
;
1431 table
[MESA_FORMAT_YCBCR
] = unpack_YCBCR
;
1432 table
[MESA_FORMAT_YCBCR_REV
] = unpack_YCBCR_REV
;
1433 table
[MESA_FORMAT_R8
] = unpack_R8
;
1434 table
[MESA_FORMAT_RG88
] = unpack_RG88
;
1435 table
[MESA_FORMAT_RG88_REV
] = unpack_RG88_REV
;
1436 table
[MESA_FORMAT_R16
] = unpack_R16
;
1437 table
[MESA_FORMAT_RG1616
] = unpack_RG1616
;
1438 table
[MESA_FORMAT_RG1616_REV
] = unpack_RG1616_REV
;
1439 table
[MESA_FORMAT_ARGB2101010
] = unpack_ARGB2101010
;
1440 table
[MESA_FORMAT_Z24_S8
] = unpack_Z24_S8
;
1441 table
[MESA_FORMAT_S8_Z24
] = unpack_S8_Z24
;
1442 table
[MESA_FORMAT_Z16
] = unpack_Z16
;
1443 table
[MESA_FORMAT_X8_Z24
] = unpack_X8_Z24
;
1444 table
[MESA_FORMAT_Z24_X8
] = unpack_Z24_X8
;
1445 table
[MESA_FORMAT_Z32
] = unpack_Z32
;
1446 table
[MESA_FORMAT_S8
] = unpack_S8
;
1447 table
[MESA_FORMAT_SRGB8
] = unpack_SRGB8
;
1448 table
[MESA_FORMAT_SRGBA8
] = unpack_SRGBA8
;
1449 table
[MESA_FORMAT_SARGB8
] = unpack_SARGB8
;
1450 table
[MESA_FORMAT_SL8
] = unpack_SL8
;
1451 table
[MESA_FORMAT_SLA8
] = unpack_SLA8
;
1452 table
[MESA_FORMAT_SRGB_DXT1
] = unpack_SRGB_DXT1
;
1453 table
[MESA_FORMAT_SRGBA_DXT1
] = unpack_SRGBA_DXT1
;
1454 table
[MESA_FORMAT_SRGBA_DXT3
] = unpack_SRGBA_DXT3
;
1455 table
[MESA_FORMAT_SRGBA_DXT5
] = unpack_SRGBA_DXT5
;
1457 table
[MESA_FORMAT_RGB_FXT1
] = unpack_RGB_FXT1
;
1458 table
[MESA_FORMAT_RGBA_FXT1
] = unpack_RGBA_FXT1
;
1459 table
[MESA_FORMAT_RGB_DXT1
] = unpack_RGB_DXT1
;
1460 table
[MESA_FORMAT_RGBA_DXT1
] = unpack_RGBA_DXT1
;
1461 table
[MESA_FORMAT_RGBA_DXT3
] = unpack_RGBA_DXT3
;
1462 table
[MESA_FORMAT_RGBA_DXT5
] = unpack_RGBA_DXT5
;
1464 table
[MESA_FORMAT_RGBA_FLOAT32
] = unpack_RGBA_FLOAT32
;
1465 table
[MESA_FORMAT_RGBA_FLOAT16
] = unpack_RGBA_FLOAT16
;
1466 table
[MESA_FORMAT_RGB_FLOAT32
] = unpack_RGB_FLOAT32
;
1467 table
[MESA_FORMAT_RGB_FLOAT16
] = unpack_RGB_FLOAT16
;
1468 table
[MESA_FORMAT_ALPHA_FLOAT32
] = unpack_ALPHA_FLOAT32
;
1469 table
[MESA_FORMAT_ALPHA_FLOAT16
] = unpack_ALPHA_FLOAT16
;
1470 table
[MESA_FORMAT_LUMINANCE_FLOAT32
] = unpack_LUMINANCE_FLOAT32
;
1471 table
[MESA_FORMAT_LUMINANCE_FLOAT16
] = unpack_LUMINANCE_FLOAT16
;
1472 table
[MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32
] = unpack_LUMINANCE_ALPHA_FLOAT32
;
1473 table
[MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16
] = unpack_LUMINANCE_ALPHA_FLOAT16
;
1474 table
[MESA_FORMAT_INTENSITY_FLOAT32
] = unpack_INTENSITY_FLOAT32
;
1475 table
[MESA_FORMAT_INTENSITY_FLOAT16
] = unpack_INTENSITY_FLOAT16
;
1476 table
[MESA_FORMAT_R_FLOAT32
] = unpack_R_FLOAT32
;
1477 table
[MESA_FORMAT_R_FLOAT16
] = unpack_R_FLOAT16
;
1478 table
[MESA_FORMAT_RG_FLOAT32
] = unpack_RG_FLOAT32
;
1479 table
[MESA_FORMAT_RG_FLOAT16
] = unpack_RG_FLOAT16
;
1481 table
[MESA_FORMAT_RGBA_INT8
] = unpack_RGBA_INT8
;
1482 table
[MESA_FORMAT_RGBA_INT16
] = unpack_RGBA_INT16
;
1483 table
[MESA_FORMAT_RGBA_INT32
] = unpack_RGBA_INT32
;
1484 table
[MESA_FORMAT_RGBA_UINT8
] = unpack_RGBA_UINT8
;
1485 table
[MESA_FORMAT_RGBA_UINT16
] = unpack_RGBA_UINT16
;
1486 table
[MESA_FORMAT_RGBA_UINT32
] = unpack_RGBA_UINT32
;
1488 table
[MESA_FORMAT_DUDV8
] = unpack_DUDV8
;
1489 table
[MESA_FORMAT_SIGNED_R8
] = unpack_SIGNED_R8
;
1490 table
[MESA_FORMAT_SIGNED_RG88_REV
] = unpack_SIGNED_RG88_REV
;
1491 table
[MESA_FORMAT_SIGNED_RGBX8888
] = unpack_SIGNED_RGBX8888
;
1492 table
[MESA_FORMAT_SIGNED_RGBA8888
] = unpack_SIGNED_RGBA8888
;
1493 table
[MESA_FORMAT_SIGNED_RGBA8888_REV
] = unpack_SIGNED_RGBA8888_REV
;
1494 table
[MESA_FORMAT_SIGNED_R16
] = unpack_SIGNED_R16
;
1495 table
[MESA_FORMAT_SIGNED_GR1616
] = unpack_SIGNED_GR1616
;
1496 table
[MESA_FORMAT_SIGNED_RGB_16
] = unpack_SIGNED_RGB_16
;
1497 table
[MESA_FORMAT_SIGNED_RGBA_16
] = unpack_SIGNED_RGBA_16
;
1498 table
[MESA_FORMAT_RGBA_16
] = unpack_RGBA_16
;
1500 table
[MESA_FORMAT_RED_RGTC1
] = unpack_RED_RGTC1
;
1501 table
[MESA_FORMAT_SIGNED_RED_RGTC1
] = unpack_SIGNED_RED_RGTC1
;
1502 table
[MESA_FORMAT_RG_RGTC2
] = unpack_RG_RGTC2
;
1503 table
[MESA_FORMAT_SIGNED_RG_RGTC2
] = unpack_SIGNED_RG_RGTC2
;
1505 table
[MESA_FORMAT_L_LATC1
] = unpack_L_LATC1
;
1506 table
[MESA_FORMAT_SIGNED_L_LATC1
] = unpack_SIGNED_L_LATC1
;
1507 table
[MESA_FORMAT_LA_LATC2
] = unpack_LA_LATC2
;
1508 table
[MESA_FORMAT_SIGNED_LA_LATC2
] = unpack_SIGNED_LA_LATC2
;
1510 table
[MESA_FORMAT_SIGNED_A8
] = unpack_SIGNED_A8
;
1511 table
[MESA_FORMAT_SIGNED_L8
] = unpack_SIGNED_L8
;
1512 table
[MESA_FORMAT_SIGNED_AL88
] = unpack_SIGNED_AL88
;
1513 table
[MESA_FORMAT_SIGNED_I8
] = unpack_SIGNED_I8
;
1514 table
[MESA_FORMAT_SIGNED_A16
] = unpack_SIGNED_A16
;
1515 table
[MESA_FORMAT_SIGNED_L16
] = unpack_SIGNED_L16
;
1516 table
[MESA_FORMAT_SIGNED_AL1616
] = unpack_SIGNED_AL1616
;
1517 table
[MESA_FORMAT_SIGNED_I16
] = unpack_SIGNED_I16
;
1519 table
[MESA_FORMAT_RGB9_E5_FLOAT
] = unpack_RGB9_E5_FLOAT
;
1520 table
[MESA_FORMAT_R11_G11_B10_FLOAT
] = unpack_R11_G11_B10_FLOAT
;
1522 table
[MESA_FORMAT_Z32_FLOAT
] = unpack_Z32_FLOAT
;
1523 table
[MESA_FORMAT_Z32_FLOAT_X24S8
] = unpack_Z32_FLOAT_X24S8
;
1525 initialized
= GL_TRUE
;
1528 return table
[format
];
1533 _mesa_unpack_rgba_row(gl_format format
, GLuint n
,
1534 const void *src
, GLfloat dst
[][4])
1536 unpack_rgba_func unpack
= get_unpack_rgba_function(format
);
1537 unpack(src
, dst
, n
);
1541 unpack_int_rgba_RGBA_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
1543 memcpy(dst
, src
, n
* 4 * sizeof(GLuint
));
1547 unpack_int_rgba_RGB_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
1551 for (i
= 0; i
< n
; i
++) {
1552 dst
[i
][0] = src
[i
* 3 + 0];
1553 dst
[i
][1] = src
[i
* 3 + 1];
1554 dst
[i
][2] = src
[i
* 3 + 2];
1560 unpack_int_rgba_RG_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
1564 for (i
= 0; i
< n
; i
++) {
1565 dst
[i
][0] = src
[i
* 2 + 0];
1566 dst
[i
][1] = src
[i
* 2 + 1];
1573 unpack_int_rgba_R_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
1577 for (i
= 0; i
< n
; i
++) {
1586 unpack_int_rgba_LUMINANCE_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
1590 for (i
= 0; i
< n
; i
++) {
1591 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
];
1597 unpack_int_rgba_LUMINANCE_ALPHA_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
1601 for (i
= 0; i
< n
; i
++) {
1602 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
* 2 + 0];
1603 dst
[i
][3] = src
[i
* 2 + 1];
1608 unpack_int_rgba_INTENSITY_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
1612 for (i
= 0; i
< n
; i
++) {
1613 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = dst
[i
][3] = src
[i
];
1618 _mesa_unpack_int_rgba_row(gl_format format
, GLuint n
,
1619 const void *src
, GLuint dst
[][4])
1622 /* Since there won't be any sign extension happening, there's no need to
1623 * make separate paths for 32-bit-to-32-bit integer unpack.
1625 case MESA_FORMAT_RGBA_UINT32
:
1626 case MESA_FORMAT_RGBA_INT32
:
1627 unpack_int_rgba_RGBA_UINT32(src
, dst
, n
);
1629 case MESA_FORMAT_RGB_UINT32
:
1630 case MESA_FORMAT_RGB_INT32
:
1631 unpack_int_rgba_RGB_UINT32(src
, dst
, n
);
1633 case MESA_FORMAT_RG_UINT32
:
1634 case MESA_FORMAT_RG_INT32
:
1635 unpack_int_rgba_RG_UINT32(src
, dst
, n
);
1637 case MESA_FORMAT_R_UINT32
:
1638 case MESA_FORMAT_R_INT32
:
1639 unpack_int_rgba_R_UINT32(src
, dst
, n
);
1642 case MESA_FORMAT_LUMINANCE_UINT32
:
1643 case MESA_FORMAT_LUMINANCE_INT32
:
1644 unpack_int_rgba_LUMINANCE_UINT32(src
, dst
, n
);
1646 case MESA_FORMAT_LUMINANCE_ALPHA_UINT32
:
1647 case MESA_FORMAT_LUMINANCE_ALPHA_INT32
:
1648 unpack_int_rgba_LUMINANCE_ALPHA_UINT32(src
, dst
, n
);
1650 case MESA_FORMAT_INTENSITY_UINT32
:
1651 case MESA_FORMAT_INTENSITY_INT32
:
1652 unpack_int_rgba_INTENSITY_UINT32(src
, dst
, n
);
1656 _mesa_problem(NULL
, "%s: bad format %s", __FUNCTION__
,
1657 _mesa_get_format_name(format
));
1663 * Unpack a 2D rect of pixels returning float RGBA colors.
1664 * \param format the source image format
1665 * \param src start address of the source image
1666 * \param srcRowStride source image row stride in bytes
1667 * \param dst start address of the dest image
1668 * \param dstRowStride dest image row stride in bytes
1669 * \param x source image start X pos
1670 * \param y source image start Y pos
1671 * \param width width of rect region to convert
1672 * \param height height of rect region to convert
1675 _mesa_unpack_rgba_block(gl_format format
,
1676 const void *src
, GLint srcRowStride
,
1677 GLfloat dst
[][4], GLint dstRowStride
,
1678 GLuint x
, GLuint y
, GLuint width
, GLuint height
)
1680 unpack_rgba_func unpack
= get_unpack_rgba_function(format
);
1681 const GLuint srcPixStride
= _mesa_get_format_bytes(format
);
1682 const GLuint dstPixStride
= 4 * sizeof(GLfloat
);
1683 const GLubyte
*srcRow
;
1687 /* XXX needs to be fixed for compressed formats */
1689 srcRow
= ((const GLubyte
*) src
) + srcRowStride
* y
+ srcPixStride
* x
;
1690 dstRow
= ((GLubyte
*) dst
) + dstRowStride
* y
+ dstPixStride
* x
;
1692 for (i
= 0; i
< height
; i
++) {
1693 unpack(srcRow
, (GLfloat (*)[4]) dstRow
, width
);
1695 dstRow
+= dstRowStride
;
1696 srcRow
+= srcRowStride
;
1703 typedef void (*unpack_float_z_func
)(GLuint n
, const void *src
, GLfloat
*dst
);
1706 unpack_float_z_Z24_X8(GLuint n
, const void *src
, GLfloat
*dst
)
1708 /* only return Z, not stencil data */
1709 const GLuint
*s
= ((const GLuint
*) src
);
1710 const GLfloat scale
= 1.0F
/ (GLfloat
) 0xffffff;
1712 for (i
= 0; i
< n
; i
++) {
1713 dst
[i
] = (s
[i
] >> 8) * scale
;
1714 ASSERT(dst
[i
] >= 0.0F
);
1715 ASSERT(dst
[i
] <= 1.0F
);
1720 unpack_float_z_X8_Z24(GLuint n
, const void *src
, GLfloat
*dst
)
1722 /* only return Z, not stencil data */
1723 const GLuint
*s
= ((const GLuint
*) src
);
1724 const GLfloat scale
= 1.0F
/ (GLfloat
) 0xffffff;
1726 for (i
= 0; i
< n
; i
++) {
1727 dst
[i
] = (s
[i
] & 0x00ffffff) * scale
;
1728 ASSERT(dst
[i
] >= 0.0F
);
1729 ASSERT(dst
[i
] <= 1.0F
);
1734 unpack_float_z_Z16(GLuint n
, const void *src
, GLfloat
*dst
)
1736 const GLushort
*s
= ((const GLushort
*) src
);
1738 for (i
= 0; i
< n
; i
++) {
1739 dst
[i
] = s
[i
] * (1.0F
/ 65535.0F
);
1744 unpack_float_z_Z32(GLuint n
, const void *src
, GLfloat
*dst
)
1746 const GLuint
*s
= ((const GLuint
*) src
);
1748 for (i
= 0; i
< n
; i
++) {
1749 dst
[i
] = s
[i
] * (1.0F
/ 0xffffffff);
1754 unpack_float_z_Z32X24S8(GLuint n
, const void *src
, GLfloat
*dst
)
1756 const GLfloat
*s
= ((const GLfloat
*) src
);
1758 for (i
= 0; i
< n
; i
++) {
1766 _mesa_unpack_float_z_row(gl_format format
, GLuint n
,
1767 const void *src
, GLfloat
*dst
)
1769 unpack_float_z_func unpack
;
1772 case MESA_FORMAT_Z24_S8
:
1773 case MESA_FORMAT_Z24_X8
:
1774 unpack
= unpack_float_z_Z24_X8
;
1776 case MESA_FORMAT_S8_Z24
:
1777 case MESA_FORMAT_X8_Z24
:
1778 unpack
= unpack_float_z_X8_Z24
;
1780 case MESA_FORMAT_Z16
:
1781 unpack
= unpack_float_z_Z16
;
1783 case MESA_FORMAT_Z32
:
1784 unpack
= unpack_float_z_Z32
;
1786 case MESA_FORMAT_Z32_FLOAT_X24S8
:
1787 unpack
= unpack_float_z_Z32X24S8
;
1790 _mesa_problem(NULL
, "bad format %s in _mesa_unpack_float_z_row",
1791 _mesa_get_format_name(format
));
1795 unpack(n
, src
, dst
);
1800 typedef void (*unpack_uint_z_func
)(const void *src
, GLuint
*dst
, GLuint n
);
1803 unpack_uint_z_Z24_X8(const void *src
, GLuint
*dst
, GLuint n
)
1805 /* only return Z, not stencil data */
1806 const GLuint
*s
= ((const GLuint
*) src
);
1808 for (i
= 0; i
< n
; i
++) {
1809 dst
[i
] = (s
[i
] & 0xffffff00) | (s
[i
] >> 24);
1814 unpack_uint_z_X8_Z24(const void *src
, GLuint
*dst
, GLuint n
)
1816 /* only return Z, not stencil data */
1817 const GLuint
*s
= ((const GLuint
*) src
);
1819 for (i
= 0; i
< n
; i
++) {
1820 dst
[i
] = (s
[i
] << 8) | ((s
[i
] >> 16) & 0xff);
1825 unpack_uint_z_Z16(const void *src
, GLuint
*dst
, GLuint n
)
1827 const GLushort
*s
= ((const GLushort
*)src
);
1829 for (i
= 0; i
< n
; i
++) {
1830 dst
[i
] = (s
[i
] << 16) | s
[i
];
1835 unpack_uint_z_Z32(const void *src
, GLuint
*dst
, GLuint n
)
1837 memcpy(dst
, src
, n
* sizeof(GLuint
));
1842 _mesa_unpack_uint_z_row(gl_format format
, GLuint n
,
1843 const void *src
, GLuint
*dst
)
1845 unpack_uint_z_func unpack
;
1846 const GLubyte
*srcPtr
= (GLubyte
*) src
;
1849 case MESA_FORMAT_Z24_S8
:
1850 case MESA_FORMAT_Z24_X8
:
1851 unpack
= unpack_uint_z_Z24_X8
;
1853 case MESA_FORMAT_S8_Z24
:
1854 case MESA_FORMAT_X8_Z24
:
1855 unpack
= unpack_uint_z_X8_Z24
;
1857 case MESA_FORMAT_Z16
:
1858 unpack
= unpack_uint_z_Z16
;
1860 case MESA_FORMAT_Z32
:
1861 unpack
= unpack_uint_z_Z32
;
1864 _mesa_problem(NULL
, "bad format %s in _mesa_unpack_uint_z_row",
1865 _mesa_get_format_name(format
));
1869 unpack(srcPtr
, dst
, n
);
1874 unpack_ubyte_s_S8(const void *src
, GLubyte
*dst
, GLuint n
)
1876 memcpy(dst
, src
, n
);
1880 unpack_ubyte_s_Z24_S8(const void *src
, GLubyte
*dst
, GLuint n
)
1883 const GLuint
*src32
= src
;
1885 for (i
= 0; i
< n
; i
++)
1886 dst
[i
] = src32
[i
] & 0xff;
1890 unpack_ubyte_s_S8_Z24(const void *src
, GLubyte
*dst
, GLuint n
)
1893 const GLuint
*src32
= src
;
1895 for (i
= 0; i
< n
; i
++)
1896 dst
[i
] = src32
[i
] >> 24;
1900 unpack_ubyte_s_Z32_FLOAT_X24S8(const void *src
, GLubyte
*dst
, GLuint n
)
1903 const GLuint
*src32
= src
;
1905 for (i
= 0; i
< n
; i
++)
1906 dst
[i
] = src32
[i
* 2 + 1] & 0xff;
1910 _mesa_unpack_ubyte_stencil_row(gl_format format
, GLuint n
,
1911 const void *src
, GLubyte
*dst
)
1914 case MESA_FORMAT_S8
:
1915 unpack_ubyte_s_S8(src
, dst
, n
);
1917 case MESA_FORMAT_Z24_S8
:
1918 unpack_ubyte_s_Z24_S8(src
, dst
, n
);
1920 case MESA_FORMAT_S8_Z24
:
1921 unpack_ubyte_s_S8_Z24(src
, dst
, n
);
1923 case MESA_FORMAT_Z32_FLOAT_X24S8
:
1924 unpack_ubyte_s_Z32_FLOAT_X24S8(src
, dst
, n
);
1927 _mesa_problem(NULL
, "bad format %s in _mesa_unpack_ubyte_s_row",
1928 _mesa_get_format_name(format
));
1934 unpack_uint_24_8_depth_stencil_S8_Z24(const GLuint
*src
, GLuint
*dst
, GLuint n
)
1938 for (i
= 0; i
< n
; i
++) {
1939 GLuint val
= src
[i
];
1940 dst
[i
] = val
>> 24 | val
<< 8;
1945 unpack_uint_24_8_depth_stencil_Z24_S8(const GLuint
*src
, GLuint
*dst
, GLuint n
)
1947 memcpy(dst
, src
, n
* 4);
1951 _mesa_unpack_uint_24_8_depth_stencil_row(gl_format format
, GLuint n
,
1952 const void *src
, GLuint
*dst
)
1955 case MESA_FORMAT_Z24_S8
:
1956 unpack_uint_24_8_depth_stencil_Z24_S8(src
, dst
, n
);
1958 case MESA_FORMAT_S8_Z24
:
1959 unpack_uint_24_8_depth_stencil_S8_Z24(src
, dst
, n
);
1962 _mesa_problem(NULL
, "bad format %s in _mesa_unpack_ubyte_s_row",
1963 _mesa_get_format_name(format
));