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_RGBX8888(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
] >> 24) );
122 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 16) & 0xff );
123 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 8) & 0xff );
124 dst
[i
][ACOMP
] = 1.0f
;
129 unpack_RGBX8888_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
] ) & 0xff );
135 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 8) & 0xff );
136 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 16) & 0xff );
137 dst
[i
][ACOMP
] = 1.0f
;
142 unpack_XRGB8888(const void *src
, GLfloat dst
[][4], GLuint n
)
144 const GLuint
*s
= ((const GLuint
*) src
);
146 for (i
= 0; i
< n
; i
++) {
147 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 16) & 0xff );
148 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 8) & 0xff );
149 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( (s
[i
] ) & 0xff );
150 dst
[i
][ACOMP
] = 1.0f
;
155 unpack_XRGB8888_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
157 const GLuint
*s
= ((const GLuint
*) src
);
159 for (i
= 0; i
< n
; i
++) {
160 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 8) & 0xff );
161 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 16) & 0xff );
162 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( (s
[i
] >> 24) );
163 dst
[i
][ACOMP
] = 1.0f
;
168 unpack_RGB888(const void *src
, GLfloat dst
[][4], GLuint n
)
170 const GLubyte
*s
= (const GLubyte
*) src
;
172 for (i
= 0; i
< n
; i
++) {
173 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( s
[i
*3+2] );
174 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( s
[i
*3+1] );
175 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( s
[i
*3+0] );
176 dst
[i
][ACOMP
] = 1.0F
;
181 unpack_BGR888(const void *src
, GLfloat dst
[][4], GLuint n
)
183 const GLubyte
*s
= (const GLubyte
*) src
;
185 for (i
= 0; i
< n
; i
++) {
186 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( s
[i
*3+0] );
187 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( s
[i
*3+1] );
188 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( s
[i
*3+2] );
189 dst
[i
][ACOMP
] = 1.0F
;
194 unpack_RGB565(const void *src
, GLfloat dst
[][4], GLuint n
)
196 const GLushort
*s
= ((const GLushort
*) src
);
198 for (i
= 0; i
< n
; i
++) {
199 dst
[i
][RCOMP
] = ((s
[i
] >> 11) & 0x1f) * (1.0F
/ 31.0F
);
200 dst
[i
][GCOMP
] = ((s
[i
] >> 5 ) & 0x3f) * (1.0F
/ 63.0F
);
201 dst
[i
][BCOMP
] = ((s
[i
] ) & 0x1f) * (1.0F
/ 31.0F
);
202 dst
[i
][ACOMP
] = 1.0F
;
207 unpack_RGB565_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
209 const GLushort
*s
= ((const GLushort
*) src
);
211 for (i
= 0; i
< n
; i
++) {
212 GLuint t
= (s
[i
] >> 8) | (s
[i
] << 8); /* byte swap */
213 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( ((t
>> 8) & 0xf8) | ((t
>> 13) & 0x7) );
214 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( ((t
>> 3) & 0xfc) | ((t
>> 9) & 0x3) );
215 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( ((t
<< 3) & 0xf8) | ((t
>> 2) & 0x7) );
216 dst
[i
][ACOMP
] = 1.0F
;
221 unpack_ARGB4444(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
] >> 8) & 0xf) * (1.0F
/ 15.0F
);
227 dst
[i
][GCOMP
] = ((s
[i
] >> 4) & 0xf) * (1.0F
/ 15.0F
);
228 dst
[i
][BCOMP
] = ((s
[i
] ) & 0xf) * (1.0F
/ 15.0F
);
229 dst
[i
][ACOMP
] = ((s
[i
] >> 12) & 0xf) * (1.0F
/ 15.0F
);
234 unpack_ARGB4444_REV(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
] ) & 0xf) * (1.0F
/ 15.0F
);
240 dst
[i
][GCOMP
] = ((s
[i
] >> 12) & 0xf) * (1.0F
/ 15.0F
);
241 dst
[i
][BCOMP
] = ((s
[i
] >> 8) & 0xf) * (1.0F
/ 15.0F
);
242 dst
[i
][ACOMP
] = ((s
[i
] >> 4) & 0xf) * (1.0F
/ 15.0F
);
247 unpack_RGBA5551(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
] = ((s
[i
] >> 11) & 0x1f) * (1.0F
/ 31.0F
);
253 dst
[i
][GCOMP
] = ((s
[i
] >> 6) & 0x1f) * (1.0F
/ 31.0F
);
254 dst
[i
][BCOMP
] = ((s
[i
] >> 1) & 0x1f) * (1.0F
/ 31.0F
);
255 dst
[i
][ACOMP
] = ((s
[i
] ) & 0x01) * 1.0F
;
260 unpack_ARGB1555(const void *src
, GLfloat dst
[][4], GLuint n
)
262 const GLushort
*s
= ((const GLushort
*) src
);
264 for (i
= 0; i
< n
; i
++) {
265 dst
[i
][RCOMP
] = ((s
[i
] >> 10) & 0x1f) * (1.0F
/ 31.0F
);
266 dst
[i
][GCOMP
] = ((s
[i
] >> 5) & 0x1f) * (1.0F
/ 31.0F
);
267 dst
[i
][BCOMP
] = ((s
[i
] >> 0) & 0x1f) * (1.0F
/ 31.0F
);
268 dst
[i
][ACOMP
] = ((s
[i
] >> 15) & 0x01) * 1.0F
;
273 unpack_ARGB1555_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
275 const GLushort
*s
= ((const GLushort
*) src
);
277 for (i
= 0; i
< n
; i
++) {
278 GLushort tmp
= (s
[i
] << 8) | (s
[i
] >> 8); /* byteswap */
279 dst
[i
][RCOMP
] = ((tmp
>> 10) & 0x1f) * (1.0F
/ 31.0F
);
280 dst
[i
][GCOMP
] = ((tmp
>> 5) & 0x1f) * (1.0F
/ 31.0F
);
281 dst
[i
][BCOMP
] = ((tmp
>> 0) & 0x1f) * (1.0F
/ 31.0F
);
282 dst
[i
][ACOMP
] = ((tmp
>> 15) & 0x01) * 1.0F
;
287 unpack_AL44(const void *src
, GLfloat dst
[][4], GLuint n
)
289 const GLubyte
*s
= ((const GLubyte
*) src
);
291 for (i
= 0; i
< n
; i
++) {
294 dst
[i
][BCOMP
] = (s
[i
] & 0xf) * (1.0F
/ 15.0F
);
295 dst
[i
][ACOMP
] = ((s
[i
] >> 4) & 0xf) * (1.0F
/ 15.0F
);
300 unpack_AL88(const void *src
, GLfloat dst
[][4], GLuint n
)
302 const GLushort
*s
= ((const GLushort
*) src
);
304 for (i
= 0; i
< n
; i
++) {
307 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( s
[i
] & 0xff );
308 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 8 );
313 unpack_AL88_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
315 const GLushort
*s
= ((const GLushort
*) src
);
317 for (i
= 0; i
< n
; i
++) {
320 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 8 );
321 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( s
[i
] & 0xff );
326 unpack_AL1616(const void *src
, GLfloat dst
[][4], GLuint n
)
328 const GLuint
*s
= ((const GLuint
*) src
);
330 for (i
= 0; i
< n
; i
++) {
333 dst
[i
][BCOMP
] = USHORT_TO_FLOAT( s
[i
] & 0xffff );
334 dst
[i
][ACOMP
] = USHORT_TO_FLOAT( s
[i
] >> 16 );
339 unpack_AL1616_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
341 const GLuint
*s
= ((const GLuint
*) src
);
343 for (i
= 0; i
< n
; i
++) {
346 dst
[i
][BCOMP
] = USHORT_TO_FLOAT( s
[i
] >> 16 );
347 dst
[i
][ACOMP
] = USHORT_TO_FLOAT( s
[i
] & 0xffff );
352 unpack_RGB332(const void *src
, GLfloat dst
[][4], GLuint n
)
354 const GLubyte
*s
= ((const GLubyte
*) src
);
356 for (i
= 0; i
< n
; i
++) {
357 dst
[i
][RCOMP
] = ((s
[i
] >> 5) & 0x7) * (1.0F
/ 7.0F
);
358 dst
[i
][GCOMP
] = ((s
[i
] >> 2) & 0x7) * (1.0F
/ 7.0F
);
359 dst
[i
][BCOMP
] = ((s
[i
] ) & 0x3) * (1.0F
/ 3.0F
);
360 dst
[i
][ACOMP
] = 1.0F
;
366 unpack_A8(const void *src
, GLfloat dst
[][4], GLuint n
)
368 const GLubyte
*s
= ((const GLubyte
*) src
);
370 for (i
= 0; i
< n
; i
++) {
373 dst
[i
][BCOMP
] = 0.0F
;
374 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT(s
[i
]);
379 unpack_A16(const void *src
, GLfloat dst
[][4], GLuint n
)
381 const GLushort
*s
= ((const GLushort
*) src
);
383 for (i
= 0; i
< n
; i
++) {
386 dst
[i
][BCOMP
] = 0.0F
;
387 dst
[i
][ACOMP
] = USHORT_TO_FLOAT(s
[i
]);
392 unpack_L8(const void *src
, GLfloat dst
[][4], GLuint n
)
394 const GLubyte
*s
= ((const GLubyte
*) src
);
396 for (i
= 0; i
< n
; i
++) {
399 dst
[i
][BCOMP
] = UBYTE_TO_FLOAT(s
[i
]);
400 dst
[i
][ACOMP
] = 1.0F
;
405 unpack_L16(const void *src
, GLfloat dst
[][4], GLuint n
)
407 const GLushort
*s
= ((const GLushort
*) src
);
409 for (i
= 0; i
< n
; i
++) {
412 dst
[i
][BCOMP
] = USHORT_TO_FLOAT(s
[i
]);
413 dst
[i
][ACOMP
] = 1.0F
;
418 unpack_I8(const void *src
, GLfloat dst
[][4], GLuint n
)
420 const GLubyte
*s
= ((const GLubyte
*) src
);
422 for (i
= 0; i
< n
; i
++) {
426 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT(s
[i
]);
431 unpack_I16(const void *src
, GLfloat dst
[][4], GLuint n
)
433 const GLushort
*s
= ((const GLushort
*) src
);
435 for (i
= 0; i
< n
; i
++) {
439 dst
[i
][ACOMP
] = USHORT_TO_FLOAT(s
[i
]);
444 unpack_YCBCR(const void *src
, GLfloat dst
[][4], GLuint n
)
447 for (i
= 0; i
< n
; i
++) {
448 const GLushort
*src0
= ((const GLushort
*) src
) + i
* 2; /* even */
449 const GLushort
*src1
= src0
+ 1; /* odd */
450 const GLubyte y0
= (*src0
>> 8) & 0xff; /* luminance */
451 const GLubyte cb
= *src0
& 0xff; /* chroma U */
452 const GLubyte y1
= (*src1
>> 8) & 0xff; /* luminance */
453 const GLubyte cr
= *src1
& 0xff; /* chroma V */
454 const GLubyte y
= (i
& 1) ? y1
: y0
; /* choose even/odd luminance */
455 GLfloat r
= 1.164F
* (y
- 16) + 1.596F
* (cr
- 128);
456 GLfloat g
= 1.164F
* (y
- 16) - 0.813F
* (cr
- 128) - 0.391F
* (cb
- 128);
457 GLfloat b
= 1.164F
* (y
- 16) + 2.018F
* (cb
- 128);
458 r
*= (1.0F
/ 255.0F
);
459 g
*= (1.0F
/ 255.0F
);
460 b
*= (1.0F
/ 255.0F
);
461 dst
[i
][RCOMP
] = CLAMP(r
, 0.0F
, 1.0F
);
462 dst
[i
][GCOMP
] = CLAMP(g
, 0.0F
, 1.0F
);
463 dst
[i
][BCOMP
] = CLAMP(b
, 0.0F
, 1.0F
);
464 dst
[i
][ACOMP
] = 1.0F
;
469 unpack_YCBCR_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
472 for (i
= 0; i
< n
; i
++) {
473 const GLushort
*src0
= ((const GLushort
*) src
) + i
* 2; /* even */
474 const GLushort
*src1
= src0
+ 1; /* odd */
475 const GLubyte y0
= *src0
& 0xff; /* luminance */
476 const GLubyte cr
= (*src0
>> 8) & 0xff; /* chroma V */
477 const GLubyte y1
= *src1
& 0xff; /* luminance */
478 const GLubyte cb
= (*src1
>> 8) & 0xff; /* chroma U */
479 const GLubyte y
= (i
& 1) ? y1
: y0
; /* choose even/odd luminance */
480 GLfloat r
= 1.164F
* (y
- 16) + 1.596F
* (cr
- 128);
481 GLfloat g
= 1.164F
* (y
- 16) - 0.813F
* (cr
- 128) - 0.391F
* (cb
- 128);
482 GLfloat b
= 1.164F
* (y
- 16) + 2.018F
* (cb
- 128);
483 r
*= (1.0F
/ 255.0F
);
484 g
*= (1.0F
/ 255.0F
);
485 b
*= (1.0F
/ 255.0F
);
486 dst
[i
][RCOMP
] = CLAMP(r
, 0.0F
, 1.0F
);
487 dst
[i
][GCOMP
] = CLAMP(g
, 0.0F
, 1.0F
);
488 dst
[i
][BCOMP
] = CLAMP(b
, 0.0F
, 1.0F
);
489 dst
[i
][ACOMP
] = 1.0F
;
494 unpack_R8(const void *src
, GLfloat dst
[][4], GLuint n
)
496 const GLubyte
*s
= ((const GLubyte
*) src
);
498 for (i
= 0; i
< n
; i
++) {
499 dst
[i
][0] = UBYTE_TO_FLOAT(s
[i
]);
507 unpack_RG88(const void *src
, GLfloat dst
[][4], GLuint n
)
509 const GLushort
*s
= ((const GLushort
*) src
);
511 for (i
= 0; i
< n
; i
++) {
512 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( s
[i
] & 0xff );
513 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 8 );
520 unpack_RG88_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
522 const GLushort
*s
= ((const GLushort
*) src
);
524 for (i
= 0; i
< n
; i
++) {
525 dst
[i
][RCOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 8 );
526 dst
[i
][GCOMP
] = UBYTE_TO_FLOAT( s
[i
] & 0xff );
533 unpack_R16(const void *src
, GLfloat dst
[][4], GLuint n
)
535 const GLushort
*s
= ((const GLushort
*) src
);
537 for (i
= 0; i
< n
; i
++) {
538 dst
[i
][RCOMP
] = USHORT_TO_FLOAT(s
[i
]);
546 unpack_RG1616(const void *src
, GLfloat dst
[][4], GLuint n
)
548 const GLuint
*s
= ((const GLuint
*) src
);
550 for (i
= 0; i
< n
; i
++) {
551 dst
[i
][RCOMP
] = USHORT_TO_FLOAT( s
[i
] & 0xffff );
552 dst
[i
][GCOMP
] = USHORT_TO_FLOAT( s
[i
] >> 16 );
559 unpack_RG1616_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
561 const GLuint
*s
= ((const GLuint
*) src
);
563 for (i
= 0; i
< n
; i
++) {
564 dst
[i
][RCOMP
] = USHORT_TO_FLOAT( s
[i
] >> 16 );
565 dst
[i
][GCOMP
] = USHORT_TO_FLOAT( s
[i
] & 0xffff );
572 unpack_ARGB2101010(const void *src
, GLfloat dst
[][4], GLuint n
)
574 const GLuint
*s
= ((const GLuint
*) src
);
576 for (i
= 0; i
< n
; i
++) {
577 dst
[i
][RCOMP
] = ((s
[i
] >> 20) & 0x3ff) * (1.0F
/ 1023.0F
);
578 dst
[i
][GCOMP
] = ((s
[i
] >> 10) & 0x3ff) * (1.0F
/ 1023.0F
);
579 dst
[i
][BCOMP
] = ((s
[i
] >> 0) & 0x3ff) * (1.0F
/ 1023.0F
);
580 dst
[i
][ACOMP
] = ((s
[i
] >> 30) & 0x03) * (1.0F
/ 3.0F
);
586 unpack_Z24_S8(const void *src
, GLfloat dst
[][4], GLuint n
)
588 /* only return Z, not stencil data */
589 const GLuint
*s
= ((const GLuint
*) src
);
590 const GLfloat scale
= 1.0F
/ (GLfloat
) 0xffffff;
592 for (i
= 0; i
< n
; i
++) {
595 dst
[i
][2] = (s
[i
] >> 8) * scale
;
597 ASSERT(dst
[i
][0] >= 0.0F
);
598 ASSERT(dst
[i
][0] <= 1.0F
);
603 unpack_S8_Z24(const void *src
, GLfloat dst
[][4], GLuint n
)
605 /* only return Z, not stencil data */
606 const GLuint
*s
= ((const GLuint
*) src
);
607 const GLfloat scale
= 1.0F
/ (GLfloat
) 0xffffff;
609 for (i
= 0; i
< n
; i
++) {
612 dst
[i
][2] = (s
[i
] & 0x00ffffff) * scale
;
614 ASSERT(dst
[i
][0] >= 0.0F
);
615 ASSERT(dst
[i
][0] <= 1.0F
);
620 unpack_Z16(const void *src
, GLfloat dst
[][4], GLuint n
)
622 const GLushort
*s
= ((const GLushort
*) src
);
624 for (i
= 0; i
< n
; i
++) {
627 dst
[i
][2] = s
[i
] * (1.0F
/ 65535.0F
);
633 unpack_X8_Z24(const void *src
, GLfloat dst
[][4], GLuint n
)
635 unpack_S8_Z24(src
, dst
, n
);
639 unpack_Z24_X8(const void *src
, GLfloat dst
[][4], GLuint n
)
641 unpack_Z24_S8(src
, dst
, n
);
645 unpack_Z32(const void *src
, GLfloat dst
[][4], GLuint n
)
647 const GLuint
*s
= ((const GLuint
*) src
);
649 for (i
= 0; i
< n
; i
++) {
652 dst
[i
][2] = s
[i
] * (1.0F
/ 0xffffffff);
658 unpack_Z32_FLOAT(const void *src
, GLfloat dst
[][4], GLuint n
)
660 const GLfloat
*s
= ((const GLfloat
*) src
);
662 for (i
= 0; i
< n
; i
++) {
665 dst
[i
][2] = s
[i
* 2];
671 unpack_Z32_FLOAT_X24S8(const void *src
, GLfloat dst
[][4], GLuint n
)
673 const GLfloat
*s
= ((const GLfloat
*) src
);
675 for (i
= 0; i
< n
; i
++) {
685 unpack_S8(const void *src
, GLfloat dst
[][4], GLuint n
)
687 /* should never be used */
689 for (i
= 0; i
< n
; i
++) {
699 unpack_SRGB8(const void *src
, GLfloat dst
[][4], GLuint n
)
701 const GLubyte
*s
= (const GLubyte
*) src
;
703 for (i
= 0; i
< n
; i
++) {
704 dst
[i
][RCOMP
] = nonlinear_to_linear(s
[i
*3+2]);
705 dst
[i
][GCOMP
] = nonlinear_to_linear(s
[i
*3+1]);
706 dst
[i
][BCOMP
] = nonlinear_to_linear(s
[i
*3+0]);
707 dst
[i
][ACOMP
] = 1.0F
;
712 unpack_SRGBA8(const void *src
, GLfloat dst
[][4], GLuint n
)
714 const GLuint
*s
= ((const GLuint
*) src
);
716 for (i
= 0; i
< n
; i
++) {
717 dst
[i
][RCOMP
] = nonlinear_to_linear( (s
[i
] >> 24) );
718 dst
[i
][GCOMP
] = nonlinear_to_linear( (s
[i
] >> 16) & 0xff );
719 dst
[i
][BCOMP
] = nonlinear_to_linear( (s
[i
] >> 8) & 0xff );
720 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( s
[i
] & 0xff ); /* linear! */
725 unpack_SARGB8(const void *src
, GLfloat dst
[][4], GLuint n
)
727 const GLuint
*s
= ((const GLuint
*) src
);
729 for (i
= 0; i
< n
; i
++) {
730 dst
[i
][RCOMP
] = nonlinear_to_linear( (s
[i
] >> 16) & 0xff );
731 dst
[i
][GCOMP
] = nonlinear_to_linear( (s
[i
] >> 8) & 0xff );
732 dst
[i
][BCOMP
] = nonlinear_to_linear( (s
[i
] ) & 0xff );
733 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT( s
[i
] >> 24 ); /* linear! */
738 unpack_SL8(const void *src
, GLfloat dst
[][4], GLuint n
)
740 const GLubyte
*s
= ((const GLubyte
*) src
);
742 for (i
= 0; i
< n
; i
++) {
745 dst
[i
][BCOMP
] = nonlinear_to_linear(s
[i
]);
746 dst
[i
][ACOMP
] = 1.0F
;
751 unpack_SLA8(const void *src
, GLfloat dst
[][4], GLuint n
)
753 const GLushort
*s
= (const GLushort
*) src
;
755 for (i
= 0; i
< n
; i
++) {
758 dst
[i
][BCOMP
] = nonlinear_to_linear(s
[i
] & 0xff);
759 dst
[i
][ACOMP
] = UBYTE_TO_FLOAT(s
[i
] >> 8); /* linear! */
764 unpack_SRGB_DXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
769 unpack_SRGBA_DXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
774 unpack_SRGBA_DXT3(const void *src
, GLfloat dst
[][4], GLuint n
)
779 unpack_SRGBA_DXT5(const void *src
, GLfloat dst
[][4], GLuint n
)
784 unpack_RGB_FXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
789 unpack_RGBA_FXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
794 unpack_RGB_DXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
799 unpack_RGBA_DXT1(const void *src
, GLfloat dst
[][4], GLuint n
)
804 unpack_RGBA_DXT3(const void *src
, GLfloat dst
[][4], GLuint n
)
809 unpack_RGBA_DXT5(const void *src
, GLfloat dst
[][4], GLuint n
)
815 unpack_RGBA_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
817 const GLfloat
*s
= (const GLfloat
*) src
;
819 for (i
= 0; i
< n
; i
++) {
820 dst
[i
][RCOMP
] = s
[i
*4+0];
821 dst
[i
][GCOMP
] = s
[i
*4+1];
822 dst
[i
][BCOMP
] = s
[i
*4+2];
823 dst
[i
][ACOMP
] = s
[i
*4+3];
828 unpack_RGBA_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
830 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
832 for (i
= 0; i
< n
; i
++) {
833 dst
[i
][RCOMP
] = _mesa_half_to_float(s
[i
*4+0]);
834 dst
[i
][GCOMP
] = _mesa_half_to_float(s
[i
*4+1]);
835 dst
[i
][BCOMP
] = _mesa_half_to_float(s
[i
*4+2]);
836 dst
[i
][ACOMP
] = _mesa_half_to_float(s
[i
*4+3]);
841 unpack_RGB_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
843 const GLfloat
*s
= (const GLfloat
*) src
;
845 for (i
= 0; i
< n
; i
++) {
846 dst
[i
][RCOMP
] = s
[i
*3+0];
847 dst
[i
][GCOMP
] = s
[i
*3+1];
848 dst
[i
][BCOMP
] = s
[i
*3+2];
849 dst
[i
][ACOMP
] = 1.0F
;
854 unpack_RGB_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
856 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
858 for (i
= 0; i
< n
; i
++) {
859 dst
[i
][RCOMP
] = _mesa_half_to_float(s
[i
*3+0]);
860 dst
[i
][GCOMP
] = _mesa_half_to_float(s
[i
*3+1]);
861 dst
[i
][BCOMP
] = _mesa_half_to_float(s
[i
*3+2]);
862 dst
[i
][ACOMP
] = 1.0F
;
867 unpack_ALPHA_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
869 const GLfloat
*s
= (const GLfloat
*) src
;
871 for (i
= 0; i
< n
; i
++) {
874 dst
[i
][BCOMP
] = 0.0F
;
875 dst
[i
][ACOMP
] = s
[i
];
880 unpack_ALPHA_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
882 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
884 for (i
= 0; i
< n
; i
++) {
887 dst
[i
][BCOMP
] = 0.0F
;
888 dst
[i
][ACOMP
] = _mesa_half_to_float(s
[i
]);
893 unpack_LUMINANCE_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
895 const GLfloat
*s
= (const GLfloat
*) src
;
897 for (i
= 0; i
< n
; i
++) {
900 dst
[i
][BCOMP
] = s
[i
];
901 dst
[i
][ACOMP
] = 1.0F
;
906 unpack_LUMINANCE_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
908 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
910 for (i
= 0; i
< n
; i
++) {
913 dst
[i
][BCOMP
] = _mesa_half_to_float(s
[i
]);
914 dst
[i
][ACOMP
] = 1.0F
;
919 unpack_LUMINANCE_ALPHA_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
921 const GLfloat
*s
= (const GLfloat
*) src
;
923 for (i
= 0; i
< n
; i
++) {
926 dst
[i
][BCOMP
] = s
[i
*2+0];
927 dst
[i
][ACOMP
] = s
[i
*2+1];
932 unpack_LUMINANCE_ALPHA_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
934 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
936 for (i
= 0; i
< n
; i
++) {
939 dst
[i
][BCOMP
] = _mesa_half_to_float(s
[i
*2+0]);
940 dst
[i
][ACOMP
] = _mesa_half_to_float(s
[i
*2+1]);
945 unpack_INTENSITY_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
947 const GLfloat
*s
= (const GLfloat
*) src
;
949 for (i
= 0; i
< n
; i
++) {
953 dst
[i
][ACOMP
] = s
[i
];
958 unpack_INTENSITY_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
960 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
962 for (i
= 0; i
< n
; i
++) {
966 dst
[i
][ACOMP
] = _mesa_half_to_float(s
[i
]);
971 unpack_R_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
973 const GLfloat
*s
= (const GLfloat
*) src
;
975 for (i
= 0; i
< n
; i
++) {
976 dst
[i
][RCOMP
] = s
[i
];
977 dst
[i
][GCOMP
] = 0.0F
;
978 dst
[i
][BCOMP
] = 0.0F
;
979 dst
[i
][ACOMP
] = 1.0F
;
984 unpack_R_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
986 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
988 for (i
= 0; i
< n
; i
++) {
989 dst
[i
][RCOMP
] = _mesa_half_to_float(s
[i
]);
990 dst
[i
][GCOMP
] = 0.0F
;
991 dst
[i
][BCOMP
] = 0.0F
;
992 dst
[i
][ACOMP
] = 1.0F
;
997 unpack_RG_FLOAT32(const void *src
, GLfloat dst
[][4], GLuint n
)
999 const GLfloat
*s
= (const GLfloat
*) src
;
1001 for (i
= 0; i
< n
; i
++) {
1002 dst
[i
][RCOMP
] = s
[i
*2+0];
1003 dst
[i
][GCOMP
] = s
[i
*2+1];
1004 dst
[i
][BCOMP
] = 0.0F
;
1005 dst
[i
][ACOMP
] = 1.0F
;
1010 unpack_RG_FLOAT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1012 const GLhalfARB
*s
= (const GLhalfARB
*) src
;
1014 for (i
= 0; i
< n
; i
++) {
1015 dst
[i
][RCOMP
] = _mesa_half_to_float(s
[i
*2+0]);
1016 dst
[i
][GCOMP
] = _mesa_half_to_float(s
[i
*2+1]);
1017 dst
[i
][BCOMP
] = 0.0F
;
1018 dst
[i
][ACOMP
] = 1.0F
;
1024 unpack_RGBA_INT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1026 const GLbyte
*s
= (const GLbyte
*) src
;
1028 for (i
= 0; i
< n
; i
++) {
1029 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1030 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1031 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1032 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1037 unpack_RGBA_INT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1039 const GLshort
*s
= (const GLshort
*) src
;
1041 for (i
= 0; i
< n
; i
++) {
1042 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1043 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1044 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1045 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1050 unpack_RGBA_INT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1052 const GLint
*s
= (const GLint
*) src
;
1054 for (i
= 0; i
< n
; i
++) {
1055 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1056 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1057 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1058 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1063 unpack_RGBA_UINT8(const void *src
, GLfloat dst
[][4], GLuint n
)
1065 const GLubyte
*s
= (const GLubyte
*) src
;
1067 for (i
= 0; i
< n
; i
++) {
1068 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1069 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1070 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1071 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1076 unpack_RGBA_UINT16(const void *src
, GLfloat dst
[][4], GLuint n
)
1078 const GLushort
*s
= (const GLushort
*) src
;
1080 for (i
= 0; i
< n
; i
++) {
1081 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1082 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1083 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1084 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1089 unpack_RGBA_UINT32(const void *src
, GLfloat dst
[][4], GLuint n
)
1091 const GLuint
*s
= (const GLuint
*) src
;
1093 for (i
= 0; i
< n
; i
++) {
1094 dst
[i
][RCOMP
] = (GLfloat
) s
[i
*4+0];
1095 dst
[i
][GCOMP
] = (GLfloat
) s
[i
*4+1];
1096 dst
[i
][BCOMP
] = (GLfloat
) s
[i
*4+2];
1097 dst
[i
][ACOMP
] = (GLfloat
) s
[i
*4+3];
1102 unpack_DUDV8(const void *src
, GLfloat dst
[][4], GLuint n
)
1104 const GLbyte
*s
= (const GLbyte
*) src
;
1106 for (i
= 0; i
< n
; i
++) {
1107 dst
[i
][RCOMP
] = BYTE_TO_FLOAT(s
[i
*2+0]);
1108 dst
[i
][GCOMP
] = BYTE_TO_FLOAT(s
[i
*2+1]);
1115 unpack_SIGNED_R8(const void *src
, GLfloat dst
[][4], GLuint n
)
1117 const GLbyte
*s
= ((const GLbyte
*) src
);
1119 for (i
= 0; i
< n
; i
++) {
1120 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( s
[i
] );
1121 dst
[i
][GCOMP
] = 0.0F
;
1122 dst
[i
][BCOMP
] = 0.0F
;
1123 dst
[i
][ACOMP
] = 1.0F
;
1128 unpack_SIGNED_RG88_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
1130 const GLushort
*s
= ((const GLushort
*) src
);
1132 for (i
= 0; i
< n
; i
++) {
1133 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] & 0xff) );
1134 dst
[i
][GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
1135 dst
[i
][BCOMP
] = 0.0F
;
1136 dst
[i
][ACOMP
] = 1.0F
;
1141 unpack_SIGNED_RGBX8888(const void *src
, GLfloat dst
[][4], GLuint n
)
1143 const GLuint
*s
= ((const GLuint
*) src
);
1145 for (i
= 0; i
< n
; i
++) {
1146 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 24) );
1147 dst
[i
][GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 16) );
1148 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
1149 dst
[i
][ACOMP
] = 1.0f
;
1154 unpack_SIGNED_RGBA8888(const void *src
, GLfloat dst
[][4], GLuint n
)
1156 const GLuint
*s
= ((const GLuint
*) src
);
1158 for (i
= 0; i
< n
; i
++) {
1159 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 24) );
1160 dst
[i
][GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 16) );
1161 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
1162 dst
[i
][ACOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] ) );
1167 unpack_SIGNED_RGBA8888_REV(const void *src
, GLfloat dst
[][4], GLuint n
)
1169 const GLuint
*s
= ((const GLuint
*) src
);
1171 for (i
= 0; i
< n
; i
++) {
1172 dst
[i
][RCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] ) );
1173 dst
[i
][GCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
1174 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 16) );
1175 dst
[i
][ACOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 24) );
1180 unpack_SIGNED_R16(const void *src
, GLfloat dst
[][4], GLuint n
)
1182 const GLshort
*s
= ((const GLshort
*) src
);
1184 for (i
= 0; i
< n
; i
++) {
1185 dst
[i
][RCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
] );
1186 dst
[i
][GCOMP
] = 0.0F
;
1187 dst
[i
][BCOMP
] = 0.0F
;
1188 dst
[i
][ACOMP
] = 1.0F
;
1193 unpack_SIGNED_GR1616(const void *src
, GLfloat dst
[][4], GLuint n
)
1195 const GLuint
*s
= ((const GLuint
*) src
);
1197 for (i
= 0; i
< n
; i
++) {
1198 dst
[i
][RCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
] & 0xffff );
1199 dst
[i
][GCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
] >> 16 );
1200 dst
[i
][BCOMP
] = 0.0F
;
1201 dst
[i
][ACOMP
] = 1.0F
;
1206 unpack_SIGNED_RGB_16(const void *src
, GLfloat dst
[][4], GLuint n
)
1208 const GLshort
*s
= (const GLshort
*) src
;
1210 for (i
= 0; i
< n
; i
++) {
1211 dst
[i
][RCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*3+0] );
1212 dst
[i
][GCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*3+1] );
1213 dst
[i
][BCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*3+2] );
1214 dst
[i
][ACOMP
] = 1.0F
;
1219 unpack_SIGNED_RGBA_16(const void *src
, GLfloat dst
[][4], GLuint n
)
1221 const GLshort
*s
= (const GLshort
*) src
;
1223 for (i
= 0; i
< n
; i
++) {
1224 dst
[i
][RCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+0] );
1225 dst
[i
][GCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+1] );
1226 dst
[i
][BCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+2] );
1227 dst
[i
][ACOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*4+3] );
1232 unpack_RGBA_16(const void *src
, GLfloat dst
[][4], GLuint n
)
1234 const GLushort
*s
= (const GLushort
*) src
;
1236 for (i
= 0; i
< n
; i
++) {
1237 dst
[i
][RCOMP
] = USHORT_TO_FLOAT( s
[i
*4+0] );
1238 dst
[i
][GCOMP
] = USHORT_TO_FLOAT( s
[i
*4+1] );
1239 dst
[i
][BCOMP
] = USHORT_TO_FLOAT( s
[i
*4+2] );
1240 dst
[i
][ACOMP
] = USHORT_TO_FLOAT( s
[i
*4+3] );
1245 unpack_RED_RGTC1(const void *src
, GLfloat dst
[][4], GLuint n
)
1251 unpack_SIGNED_RED_RGTC1(const void *src
, GLfloat dst
[][4], GLuint n
)
1257 unpack_RG_RGTC2(const void *src
, GLfloat dst
[][4], GLuint n
)
1263 unpack_SIGNED_RG_RGTC2(const void *src
, GLfloat dst
[][4], GLuint n
)
1269 unpack_L_LATC1(const void *src
, GLfloat dst
[][4], GLuint n
)
1275 unpack_SIGNED_L_LATC1(const void *src
, GLfloat dst
[][4], GLuint n
)
1281 unpack_LA_LATC2(const void *src
, GLfloat dst
[][4], GLuint n
)
1287 unpack_SIGNED_LA_LATC2(const void *src
, GLfloat dst
[][4], GLuint n
)
1293 unpack_ETC1_RGB8(const void *src
, GLfloat dst
[][4], GLuint n
)
1299 unpack_SIGNED_A8(const void *src
, GLfloat dst
[][4], GLuint n
)
1301 const GLbyte
*s
= ((const GLbyte
*) src
);
1303 for (i
= 0; i
< n
; i
++) {
1304 dst
[i
][RCOMP
] = 0.0F
;
1305 dst
[i
][GCOMP
] = 0.0F
;
1306 dst
[i
][BCOMP
] = 0.0F
;
1307 dst
[i
][ACOMP
] = BYTE_TO_FLOAT_TEX( s
[i
] );
1312 unpack_SIGNED_L8(const void *src
, GLfloat dst
[][4], GLuint n
)
1314 const GLbyte
*s
= ((const GLbyte
*) src
);
1316 for (i
= 0; i
< n
; i
++) {
1319 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( s
[i
] );
1320 dst
[i
][ACOMP
] = 1.0F
;
1325 unpack_SIGNED_AL88(const void *src
, GLfloat dst
[][4], GLuint n
)
1327 const GLshort
*s
= ((const GLshort
*) src
);
1329 for (i
= 0; i
< n
; i
++) {
1332 dst
[i
][BCOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] & 0xff) );
1333 dst
[i
][ACOMP
] = BYTE_TO_FLOAT_TEX( (GLbyte
) (s
[i
] >> 8) );
1338 unpack_SIGNED_I8(const void *src
, GLfloat dst
[][4], GLuint n
)
1340 const GLbyte
*s
= ((const GLbyte
*) src
);
1342 for (i
= 0; i
< n
; i
++) {
1346 dst
[i
][ACOMP
] = BYTE_TO_FLOAT_TEX( s
[i
] );
1351 unpack_SIGNED_A16(const void *src
, GLfloat dst
[][4], GLuint n
)
1353 const GLshort
*s
= ((const GLshort
*) src
);
1355 for (i
= 0; i
< n
; i
++) {
1356 dst
[i
][RCOMP
] = 0.0F
;
1357 dst
[i
][GCOMP
] = 0.0F
;
1358 dst
[i
][BCOMP
] = 0.0F
;
1359 dst
[i
][ACOMP
] = SHORT_TO_FLOAT_TEX( s
[i
] );
1364 unpack_SIGNED_L16(const void *src
, GLfloat dst
[][4], GLuint n
)
1366 const GLshort
*s
= ((const GLshort
*) src
);
1368 for (i
= 0; i
< n
; i
++) {
1371 dst
[i
][BCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
] );
1372 dst
[i
][ACOMP
] = 1.0F
;
1377 unpack_SIGNED_AL1616(const void *src
, GLfloat dst
[][4], GLuint n
)
1379 const GLshort
*s
= (const GLshort
*) src
;
1381 for (i
= 0; i
< n
; i
++) {
1384 dst
[i
][BCOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*2+0] );
1385 dst
[i
][ACOMP
] = SHORT_TO_FLOAT_TEX( s
[i
*2+1] );
1390 unpack_SIGNED_I16(const void *src
, GLfloat dst
[][4], GLuint n
)
1392 const GLshort
*s
= ((const GLshort
*) src
);
1394 for (i
= 0; i
< n
; i
++) {
1398 dst
[i
][ACOMP
] = SHORT_TO_FLOAT_TEX( s
[i
] );
1403 unpack_RGB9_E5_FLOAT(const void *src
, GLfloat dst
[][4], GLuint n
)
1405 const GLuint
*s
= (const GLuint
*) src
;
1407 for (i
= 0; i
< n
; i
++) {
1408 rgb9e5_to_float3(s
[i
], dst
[i
]);
1409 dst
[i
][ACOMP
] = 1.0F
;
1414 unpack_R11_G11_B10_FLOAT(const void *src
, GLfloat dst
[][4], GLuint n
)
1416 const GLuint
*s
= (const GLuint
*) src
;
1418 for (i
= 0; i
< n
; i
++) {
1419 r11g11b10f_to_float3(s
[i
], dst
[i
]);
1420 dst
[i
][ACOMP
] = 1.0F
;
1426 * Return the unpacker function for the given format.
1428 static unpack_rgba_func
1429 get_unpack_rgba_function(gl_format format
)
1431 static unpack_rgba_func table
[MESA_FORMAT_COUNT
];
1432 static GLboolean initialized
= GL_FALSE
;
1435 table
[MESA_FORMAT_NONE
] = NULL
;
1437 table
[MESA_FORMAT_RGBA8888
] = unpack_RGBA8888
;
1438 table
[MESA_FORMAT_RGBA8888_REV
] = unpack_RGBA8888_REV
;
1439 table
[MESA_FORMAT_ARGB8888
] = unpack_ARGB8888
;
1440 table
[MESA_FORMAT_ARGB8888_REV
] = unpack_ARGB8888_REV
;
1441 table
[MESA_FORMAT_RGBX8888
] = unpack_RGBX8888
;
1442 table
[MESA_FORMAT_RGBX8888_REV
] = unpack_RGBX8888_REV
;
1443 table
[MESA_FORMAT_XRGB8888
] = unpack_XRGB8888
;
1444 table
[MESA_FORMAT_XRGB8888_REV
] = unpack_XRGB8888_REV
;
1445 table
[MESA_FORMAT_RGB888
] = unpack_RGB888
;
1446 table
[MESA_FORMAT_BGR888
] = unpack_BGR888
;
1447 table
[MESA_FORMAT_RGB565
] = unpack_RGB565
;
1448 table
[MESA_FORMAT_RGB565_REV
] = unpack_RGB565_REV
;
1449 table
[MESA_FORMAT_ARGB4444
] = unpack_ARGB4444
;
1450 table
[MESA_FORMAT_ARGB4444_REV
] = unpack_ARGB4444_REV
;
1451 table
[MESA_FORMAT_RGBA5551
] = unpack_RGBA5551
;
1452 table
[MESA_FORMAT_ARGB1555
] = unpack_ARGB1555
;
1453 table
[MESA_FORMAT_ARGB1555_REV
] = unpack_ARGB1555_REV
;
1454 table
[MESA_FORMAT_AL44
] = unpack_AL44
;
1455 table
[MESA_FORMAT_AL88
] = unpack_AL88
;
1456 table
[MESA_FORMAT_AL88_REV
] = unpack_AL88_REV
;
1457 table
[MESA_FORMAT_AL1616
] = unpack_AL1616
;
1458 table
[MESA_FORMAT_AL1616_REV
] = unpack_AL1616_REV
;
1459 table
[MESA_FORMAT_RGB332
] = unpack_RGB332
;
1460 table
[MESA_FORMAT_A8
] = unpack_A8
;
1461 table
[MESA_FORMAT_A16
] = unpack_A16
;
1462 table
[MESA_FORMAT_L8
] = unpack_L8
;
1463 table
[MESA_FORMAT_L16
] = unpack_L16
;
1464 table
[MESA_FORMAT_I8
] = unpack_I8
;
1465 table
[MESA_FORMAT_I16
] = unpack_I16
;
1466 table
[MESA_FORMAT_YCBCR
] = unpack_YCBCR
;
1467 table
[MESA_FORMAT_YCBCR_REV
] = unpack_YCBCR_REV
;
1468 table
[MESA_FORMAT_R8
] = unpack_R8
;
1469 table
[MESA_FORMAT_RG88
] = unpack_RG88
;
1470 table
[MESA_FORMAT_RG88_REV
] = unpack_RG88_REV
;
1471 table
[MESA_FORMAT_R16
] = unpack_R16
;
1472 table
[MESA_FORMAT_RG1616
] = unpack_RG1616
;
1473 table
[MESA_FORMAT_RG1616_REV
] = unpack_RG1616_REV
;
1474 table
[MESA_FORMAT_ARGB2101010
] = unpack_ARGB2101010
;
1475 table
[MESA_FORMAT_Z24_S8
] = unpack_Z24_S8
;
1476 table
[MESA_FORMAT_S8_Z24
] = unpack_S8_Z24
;
1477 table
[MESA_FORMAT_Z16
] = unpack_Z16
;
1478 table
[MESA_FORMAT_X8_Z24
] = unpack_X8_Z24
;
1479 table
[MESA_FORMAT_Z24_X8
] = unpack_Z24_X8
;
1480 table
[MESA_FORMAT_Z32
] = unpack_Z32
;
1481 table
[MESA_FORMAT_S8
] = unpack_S8
;
1482 table
[MESA_FORMAT_SRGB8
] = unpack_SRGB8
;
1483 table
[MESA_FORMAT_SRGBA8
] = unpack_SRGBA8
;
1484 table
[MESA_FORMAT_SARGB8
] = unpack_SARGB8
;
1485 table
[MESA_FORMAT_SL8
] = unpack_SL8
;
1486 table
[MESA_FORMAT_SLA8
] = unpack_SLA8
;
1487 table
[MESA_FORMAT_SRGB_DXT1
] = unpack_SRGB_DXT1
;
1488 table
[MESA_FORMAT_SRGBA_DXT1
] = unpack_SRGBA_DXT1
;
1489 table
[MESA_FORMAT_SRGBA_DXT3
] = unpack_SRGBA_DXT3
;
1490 table
[MESA_FORMAT_SRGBA_DXT5
] = unpack_SRGBA_DXT5
;
1492 table
[MESA_FORMAT_RGB_FXT1
] = unpack_RGB_FXT1
;
1493 table
[MESA_FORMAT_RGBA_FXT1
] = unpack_RGBA_FXT1
;
1494 table
[MESA_FORMAT_RGB_DXT1
] = unpack_RGB_DXT1
;
1495 table
[MESA_FORMAT_RGBA_DXT1
] = unpack_RGBA_DXT1
;
1496 table
[MESA_FORMAT_RGBA_DXT3
] = unpack_RGBA_DXT3
;
1497 table
[MESA_FORMAT_RGBA_DXT5
] = unpack_RGBA_DXT5
;
1499 table
[MESA_FORMAT_RGBA_FLOAT32
] = unpack_RGBA_FLOAT32
;
1500 table
[MESA_FORMAT_RGBA_FLOAT16
] = unpack_RGBA_FLOAT16
;
1501 table
[MESA_FORMAT_RGB_FLOAT32
] = unpack_RGB_FLOAT32
;
1502 table
[MESA_FORMAT_RGB_FLOAT16
] = unpack_RGB_FLOAT16
;
1503 table
[MESA_FORMAT_ALPHA_FLOAT32
] = unpack_ALPHA_FLOAT32
;
1504 table
[MESA_FORMAT_ALPHA_FLOAT16
] = unpack_ALPHA_FLOAT16
;
1505 table
[MESA_FORMAT_LUMINANCE_FLOAT32
] = unpack_LUMINANCE_FLOAT32
;
1506 table
[MESA_FORMAT_LUMINANCE_FLOAT16
] = unpack_LUMINANCE_FLOAT16
;
1507 table
[MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32
] = unpack_LUMINANCE_ALPHA_FLOAT32
;
1508 table
[MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16
] = unpack_LUMINANCE_ALPHA_FLOAT16
;
1509 table
[MESA_FORMAT_INTENSITY_FLOAT32
] = unpack_INTENSITY_FLOAT32
;
1510 table
[MESA_FORMAT_INTENSITY_FLOAT16
] = unpack_INTENSITY_FLOAT16
;
1511 table
[MESA_FORMAT_R_FLOAT32
] = unpack_R_FLOAT32
;
1512 table
[MESA_FORMAT_R_FLOAT16
] = unpack_R_FLOAT16
;
1513 table
[MESA_FORMAT_RG_FLOAT32
] = unpack_RG_FLOAT32
;
1514 table
[MESA_FORMAT_RG_FLOAT16
] = unpack_RG_FLOAT16
;
1516 table
[MESA_FORMAT_RGBA_INT8
] = unpack_RGBA_INT8
;
1517 table
[MESA_FORMAT_RGBA_INT16
] = unpack_RGBA_INT16
;
1518 table
[MESA_FORMAT_RGBA_INT32
] = unpack_RGBA_INT32
;
1519 table
[MESA_FORMAT_RGBA_UINT8
] = unpack_RGBA_UINT8
;
1520 table
[MESA_FORMAT_RGBA_UINT16
] = unpack_RGBA_UINT16
;
1521 table
[MESA_FORMAT_RGBA_UINT32
] = unpack_RGBA_UINT32
;
1523 table
[MESA_FORMAT_DUDV8
] = unpack_DUDV8
;
1524 table
[MESA_FORMAT_SIGNED_R8
] = unpack_SIGNED_R8
;
1525 table
[MESA_FORMAT_SIGNED_RG88_REV
] = unpack_SIGNED_RG88_REV
;
1526 table
[MESA_FORMAT_SIGNED_RGBX8888
] = unpack_SIGNED_RGBX8888
;
1527 table
[MESA_FORMAT_SIGNED_RGBA8888
] = unpack_SIGNED_RGBA8888
;
1528 table
[MESA_FORMAT_SIGNED_RGBA8888_REV
] = unpack_SIGNED_RGBA8888_REV
;
1529 table
[MESA_FORMAT_SIGNED_R16
] = unpack_SIGNED_R16
;
1530 table
[MESA_FORMAT_SIGNED_GR1616
] = unpack_SIGNED_GR1616
;
1531 table
[MESA_FORMAT_SIGNED_RGB_16
] = unpack_SIGNED_RGB_16
;
1532 table
[MESA_FORMAT_SIGNED_RGBA_16
] = unpack_SIGNED_RGBA_16
;
1533 table
[MESA_FORMAT_RGBA_16
] = unpack_RGBA_16
;
1535 table
[MESA_FORMAT_RED_RGTC1
] = unpack_RED_RGTC1
;
1536 table
[MESA_FORMAT_SIGNED_RED_RGTC1
] = unpack_SIGNED_RED_RGTC1
;
1537 table
[MESA_FORMAT_RG_RGTC2
] = unpack_RG_RGTC2
;
1538 table
[MESA_FORMAT_SIGNED_RG_RGTC2
] = unpack_SIGNED_RG_RGTC2
;
1540 table
[MESA_FORMAT_L_LATC1
] = unpack_L_LATC1
;
1541 table
[MESA_FORMAT_SIGNED_L_LATC1
] = unpack_SIGNED_L_LATC1
;
1542 table
[MESA_FORMAT_LA_LATC2
] = unpack_LA_LATC2
;
1543 table
[MESA_FORMAT_SIGNED_LA_LATC2
] = unpack_SIGNED_LA_LATC2
;
1545 table
[MESA_FORMAT_ETC1_RGB8
] = unpack_ETC1_RGB8
;
1547 table
[MESA_FORMAT_SIGNED_A8
] = unpack_SIGNED_A8
;
1548 table
[MESA_FORMAT_SIGNED_L8
] = unpack_SIGNED_L8
;
1549 table
[MESA_FORMAT_SIGNED_AL88
] = unpack_SIGNED_AL88
;
1550 table
[MESA_FORMAT_SIGNED_I8
] = unpack_SIGNED_I8
;
1551 table
[MESA_FORMAT_SIGNED_A16
] = unpack_SIGNED_A16
;
1552 table
[MESA_FORMAT_SIGNED_L16
] = unpack_SIGNED_L16
;
1553 table
[MESA_FORMAT_SIGNED_AL1616
] = unpack_SIGNED_AL1616
;
1554 table
[MESA_FORMAT_SIGNED_I16
] = unpack_SIGNED_I16
;
1556 table
[MESA_FORMAT_RGB9_E5_FLOAT
] = unpack_RGB9_E5_FLOAT
;
1557 table
[MESA_FORMAT_R11_G11_B10_FLOAT
] = unpack_R11_G11_B10_FLOAT
;
1559 table
[MESA_FORMAT_Z32_FLOAT
] = unpack_Z32_FLOAT
;
1560 table
[MESA_FORMAT_Z32_FLOAT_X24S8
] = unpack_Z32_FLOAT_X24S8
;
1562 initialized
= GL_TRUE
;
1565 return table
[format
];
1570 _mesa_unpack_rgba_row(gl_format format
, GLuint n
,
1571 const void *src
, GLfloat dst
[][4])
1573 unpack_rgba_func unpack
= get_unpack_rgba_function(format
);
1574 unpack(src
, dst
, n
);
1578 unpack_int_rgba_RGBA_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
1580 memcpy(dst
, src
, n
* 4 * sizeof(GLuint
));
1584 unpack_int_rgba_RGB_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
1588 for (i
= 0; i
< n
; i
++) {
1589 dst
[i
][0] = src
[i
* 3 + 0];
1590 dst
[i
][1] = src
[i
* 3 + 1];
1591 dst
[i
][2] = src
[i
* 3 + 2];
1597 unpack_int_rgba_RG_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
1601 for (i
= 0; i
< n
; i
++) {
1602 dst
[i
][0] = src
[i
* 2 + 0];
1603 dst
[i
][1] = src
[i
* 2 + 1];
1610 unpack_int_rgba_R_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
1614 for (i
= 0; i
< n
; i
++) {
1623 unpack_int_rgba_LUMINANCE_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
1627 for (i
= 0; i
< n
; i
++) {
1628 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
];
1634 unpack_int_rgba_LUMINANCE_ALPHA_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
1638 for (i
= 0; i
< n
; i
++) {
1639 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = src
[i
* 2 + 0];
1640 dst
[i
][3] = src
[i
* 2 + 1];
1645 unpack_int_rgba_INTENSITY_UINT32(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
1649 for (i
= 0; i
< n
; i
++) {
1650 dst
[i
][0] = dst
[i
][1] = dst
[i
][2] = dst
[i
][3] = src
[i
];
1655 unpack_int_rgba_ARGB2101010_UINT(const GLuint
*src
, GLuint dst
[][4], GLuint n
)
1659 for (i
= 0; i
< n
; i
++) {
1660 GLuint tmp
= src
[i
];
1661 dst
[i
][0] = (tmp
>> 20) & 0x3ff;
1662 dst
[i
][1] = (tmp
>> 10) & 0x3ff;
1663 dst
[i
][2] = (tmp
>> 0) & 0x3ff;
1664 dst
[i
][3] = (tmp
>> 30) & 0x3;
1669 _mesa_unpack_int_rgba_row(gl_format format
, GLuint n
,
1670 const void *src
, GLuint dst
[][4])
1673 /* Since there won't be any sign extension happening, there's no need to
1674 * make separate paths for 32-bit-to-32-bit integer unpack.
1676 case MESA_FORMAT_RGBA_UINT32
:
1677 case MESA_FORMAT_RGBA_INT32
:
1678 unpack_int_rgba_RGBA_UINT32(src
, dst
, n
);
1680 case MESA_FORMAT_RGB_UINT32
:
1681 case MESA_FORMAT_RGB_INT32
:
1682 unpack_int_rgba_RGB_UINT32(src
, dst
, n
);
1684 case MESA_FORMAT_RG_UINT32
:
1685 case MESA_FORMAT_RG_INT32
:
1686 unpack_int_rgba_RG_UINT32(src
, dst
, n
);
1688 case MESA_FORMAT_R_UINT32
:
1689 case MESA_FORMAT_R_INT32
:
1690 unpack_int_rgba_R_UINT32(src
, dst
, n
);
1693 case MESA_FORMAT_LUMINANCE_UINT32
:
1694 case MESA_FORMAT_LUMINANCE_INT32
:
1695 unpack_int_rgba_LUMINANCE_UINT32(src
, dst
, n
);
1697 case MESA_FORMAT_LUMINANCE_ALPHA_UINT32
:
1698 case MESA_FORMAT_LUMINANCE_ALPHA_INT32
:
1699 unpack_int_rgba_LUMINANCE_ALPHA_UINT32(src
, dst
, n
);
1701 case MESA_FORMAT_INTENSITY_UINT32
:
1702 case MESA_FORMAT_INTENSITY_INT32
:
1703 unpack_int_rgba_INTENSITY_UINT32(src
, dst
, n
);
1706 case MESA_FORMAT_ARGB2101010_UINT
:
1707 unpack_int_rgba_ARGB2101010_UINT(src
, dst
, n
);
1710 _mesa_problem(NULL
, "%s: bad format %s", __FUNCTION__
,
1711 _mesa_get_format_name(format
));
1717 * Unpack a 2D rect of pixels returning float RGBA colors.
1718 * \param format the source image format
1719 * \param src start address of the source image
1720 * \param srcRowStride source image row stride in bytes
1721 * \param dst start address of the dest image
1722 * \param dstRowStride dest image row stride in bytes
1723 * \param x source image start X pos
1724 * \param y source image start Y pos
1725 * \param width width of rect region to convert
1726 * \param height height of rect region to convert
1729 _mesa_unpack_rgba_block(gl_format format
,
1730 const void *src
, GLint srcRowStride
,
1731 GLfloat dst
[][4], GLint dstRowStride
,
1732 GLuint x
, GLuint y
, GLuint width
, GLuint height
)
1734 unpack_rgba_func unpack
= get_unpack_rgba_function(format
);
1735 const GLuint srcPixStride
= _mesa_get_format_bytes(format
);
1736 const GLuint dstPixStride
= 4 * sizeof(GLfloat
);
1737 const GLubyte
*srcRow
;
1741 /* XXX needs to be fixed for compressed formats */
1743 srcRow
= ((const GLubyte
*) src
) + srcRowStride
* y
+ srcPixStride
* x
;
1744 dstRow
= ((GLubyte
*) dst
) + dstRowStride
* y
+ dstPixStride
* x
;
1746 for (i
= 0; i
< height
; i
++) {
1747 unpack(srcRow
, (GLfloat (*)[4]) dstRow
, width
);
1749 dstRow
+= dstRowStride
;
1750 srcRow
+= srcRowStride
;
1757 typedef void (*unpack_float_z_func
)(GLuint n
, const void *src
, GLfloat
*dst
);
1760 unpack_float_z_Z24_X8(GLuint n
, const void *src
, GLfloat
*dst
)
1762 /* only return Z, not stencil data */
1763 const GLuint
*s
= ((const GLuint
*) src
);
1764 const GLfloat scale
= 1.0F
/ (GLfloat
) 0xffffff;
1766 for (i
= 0; i
< n
; i
++) {
1767 dst
[i
] = (s
[i
] >> 8) * scale
;
1768 ASSERT(dst
[i
] >= 0.0F
);
1769 ASSERT(dst
[i
] <= 1.0F
);
1774 unpack_float_z_X8_Z24(GLuint n
, const void *src
, GLfloat
*dst
)
1776 /* only return Z, not stencil data */
1777 const GLuint
*s
= ((const GLuint
*) src
);
1778 const GLfloat scale
= 1.0F
/ (GLfloat
) 0xffffff;
1780 for (i
= 0; i
< n
; i
++) {
1781 dst
[i
] = (s
[i
] & 0x00ffffff) * scale
;
1782 ASSERT(dst
[i
] >= 0.0F
);
1783 ASSERT(dst
[i
] <= 1.0F
);
1788 unpack_float_z_Z16(GLuint n
, const void *src
, GLfloat
*dst
)
1790 const GLushort
*s
= ((const GLushort
*) src
);
1792 for (i
= 0; i
< n
; i
++) {
1793 dst
[i
] = s
[i
] * (1.0F
/ 65535.0F
);
1798 unpack_float_z_Z32(GLuint n
, const void *src
, GLfloat
*dst
)
1800 const GLuint
*s
= ((const GLuint
*) src
);
1802 for (i
= 0; i
< n
; i
++) {
1803 dst
[i
] = s
[i
] * (1.0F
/ 0xffffffff);
1808 unpack_float_z_Z32F(GLuint n
, const void *src
, GLfloat
*dst
)
1810 memcpy(dst
, src
, n
* sizeof(float));
1814 unpack_float_z_Z32X24S8(GLuint n
, const void *src
, GLfloat
*dst
)
1816 const GLfloat
*s
= ((const GLfloat
*) src
);
1818 for (i
= 0; i
< n
; i
++) {
1826 _mesa_unpack_float_z_row(gl_format format
, GLuint n
,
1827 const void *src
, GLfloat
*dst
)
1829 unpack_float_z_func unpack
;
1832 case MESA_FORMAT_Z24_S8
:
1833 case MESA_FORMAT_Z24_X8
:
1834 unpack
= unpack_float_z_Z24_X8
;
1836 case MESA_FORMAT_S8_Z24
:
1837 case MESA_FORMAT_X8_Z24
:
1838 unpack
= unpack_float_z_X8_Z24
;
1840 case MESA_FORMAT_Z16
:
1841 unpack
= unpack_float_z_Z16
;
1843 case MESA_FORMAT_Z32
:
1844 unpack
= unpack_float_z_Z32
;
1846 case MESA_FORMAT_Z32_FLOAT
:
1847 unpack
= unpack_float_z_Z32F
;
1849 case MESA_FORMAT_Z32_FLOAT_X24S8
:
1850 unpack
= unpack_float_z_Z32X24S8
;
1853 _mesa_problem(NULL
, "bad format %s in _mesa_unpack_float_z_row",
1854 _mesa_get_format_name(format
));
1858 unpack(n
, src
, dst
);
1863 typedef void (*unpack_uint_z_func
)(const void *src
, GLuint
*dst
, GLuint n
);
1866 unpack_uint_z_Z24_X8(const void *src
, GLuint
*dst
, GLuint n
)
1868 /* only return Z, not stencil data */
1869 const GLuint
*s
= ((const GLuint
*) src
);
1871 for (i
= 0; i
< n
; i
++) {
1872 dst
[i
] = (s
[i
] & 0xffffff00) | (s
[i
] >> 24);
1877 unpack_uint_z_X8_Z24(const void *src
, GLuint
*dst
, GLuint n
)
1879 /* only return Z, not stencil data */
1880 const GLuint
*s
= ((const GLuint
*) src
);
1882 for (i
= 0; i
< n
; i
++) {
1883 dst
[i
] = (s
[i
] << 8) | ((s
[i
] >> 16) & 0xff);
1888 unpack_uint_z_Z16(const void *src
, GLuint
*dst
, GLuint n
)
1890 const GLushort
*s
= ((const GLushort
*)src
);
1892 for (i
= 0; i
< n
; i
++) {
1893 dst
[i
] = (s
[i
] << 16) | s
[i
];
1898 unpack_uint_z_Z32(const void *src
, GLuint
*dst
, GLuint n
)
1900 memcpy(dst
, src
, n
* sizeof(GLuint
));
1905 _mesa_unpack_uint_z_row(gl_format format
, GLuint n
,
1906 const void *src
, GLuint
*dst
)
1908 unpack_uint_z_func unpack
;
1909 const GLubyte
*srcPtr
= (GLubyte
*) src
;
1912 case MESA_FORMAT_Z24_S8
:
1913 case MESA_FORMAT_Z24_X8
:
1914 unpack
= unpack_uint_z_Z24_X8
;
1916 case MESA_FORMAT_S8_Z24
:
1917 case MESA_FORMAT_X8_Z24
:
1918 unpack
= unpack_uint_z_X8_Z24
;
1920 case MESA_FORMAT_Z16
:
1921 unpack
= unpack_uint_z_Z16
;
1923 case MESA_FORMAT_Z32
:
1924 unpack
= unpack_uint_z_Z32
;
1927 _mesa_problem(NULL
, "bad format %s in _mesa_unpack_uint_z_row",
1928 _mesa_get_format_name(format
));
1932 unpack(srcPtr
, dst
, n
);
1937 unpack_ubyte_s_S8(const void *src
, GLubyte
*dst
, GLuint n
)
1939 memcpy(dst
, src
, n
);
1943 unpack_ubyte_s_Z24_S8(const void *src
, GLubyte
*dst
, GLuint n
)
1946 const GLuint
*src32
= src
;
1948 for (i
= 0; i
< n
; i
++)
1949 dst
[i
] = src32
[i
] & 0xff;
1953 unpack_ubyte_s_S8_Z24(const void *src
, GLubyte
*dst
, GLuint n
)
1956 const GLuint
*src32
= src
;
1958 for (i
= 0; i
< n
; i
++)
1959 dst
[i
] = src32
[i
] >> 24;
1963 unpack_ubyte_s_Z32_FLOAT_X24S8(const void *src
, GLubyte
*dst
, GLuint n
)
1966 const GLuint
*src32
= src
;
1968 for (i
= 0; i
< n
; i
++)
1969 dst
[i
] = src32
[i
* 2 + 1] & 0xff;
1973 _mesa_unpack_ubyte_stencil_row(gl_format format
, GLuint n
,
1974 const void *src
, GLubyte
*dst
)
1977 case MESA_FORMAT_S8
:
1978 unpack_ubyte_s_S8(src
, dst
, n
);
1980 case MESA_FORMAT_Z24_S8
:
1981 unpack_ubyte_s_Z24_S8(src
, dst
, n
);
1983 case MESA_FORMAT_S8_Z24
:
1984 unpack_ubyte_s_S8_Z24(src
, dst
, n
);
1986 case MESA_FORMAT_Z32_FLOAT_X24S8
:
1987 unpack_ubyte_s_Z32_FLOAT_X24S8(src
, dst
, n
);
1990 _mesa_problem(NULL
, "bad format %s in _mesa_unpack_ubyte_s_row",
1991 _mesa_get_format_name(format
));
1997 unpack_uint_24_8_depth_stencil_S8_Z24(const GLuint
*src
, GLuint
*dst
, GLuint n
)
2001 for (i
= 0; i
< n
; i
++) {
2002 GLuint val
= src
[i
];
2003 dst
[i
] = val
>> 24 | val
<< 8;
2008 unpack_uint_24_8_depth_stencil_Z24_S8(const GLuint
*src
, GLuint
*dst
, GLuint n
)
2010 memcpy(dst
, src
, n
* 4);
2014 _mesa_unpack_uint_24_8_depth_stencil_row(gl_format format
, GLuint n
,
2015 const void *src
, GLuint
*dst
)
2018 case MESA_FORMAT_Z24_S8
:
2019 unpack_uint_24_8_depth_stencil_Z24_S8(src
, dst
, n
);
2021 case MESA_FORMAT_S8_Z24
:
2022 unpack_uint_24_8_depth_stencil_S8_Z24(src
, dst
, n
);
2026 "bad format %s in _mesa_unpack_uint_24_8_depth_stencil_row",
2027 _mesa_get_format_name(format
));