1 /*
2 * Mesa 3-D graphics library
3 *
4 * Copyright (c) 2011 VMware, Inc.
5 * Copyright (c) 2014 Intel Corporation.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
24 */
25
26
27 /**
28 * Color, depth, stencil packing functions.
29 * Used to pack basic color, depth and stencil formats to specific
30 * hardware formats.
31 *
32 * There are both per-pixel and per-row packing functions:
33 * - The former will be used by swrast to write values to the color, depth,
34 * stencil buffers when drawing points, lines and masked spans.
35 * - The later will be used for image-oriented functions like glDrawPixels,
36 * glAccum, and glTexImage.
37 */
38
39 #include <stdint.h>
40 #include <stdlib.h>
41
42 #include "format_unpack.h"
43 #include "format_utils.h"
44 #include "macros.h"
45 #include "util/format_rgb9e5.h"
46 #include "util/format_r11g11b10f.h"
47 #include "util/format_srgb.h"
48
49 #define UNPACK(SRC, OFFSET, BITS) (((SRC) >> (OFFSET)) & MAX_UINT(BITS))
50
51
52
53 /* float unpacking functions */
54
55
56 static inline void
unpack_float_a8b8g8r8_unorm(const void * void_src,float dst[4])57 unpack_float_a8b8g8r8_unorm(const void *void_src, float dst[4])
58 {
59 uint32_t *src = (uint32_t *)void_src;
60 uint8_t a = UNPACK(*src, 0, 8);
61 uint8_t b = UNPACK(*src, 8, 8);
62 uint8_t g = UNPACK(*src, 16, 8);
63 uint8_t r = UNPACK(*src, 24, 8);
64
65
66
67 dst[0] = _mesa_unorm_to_float(r, 8);
68
69
70 dst[1] = _mesa_unorm_to_float(g, 8);
71
72
73 dst[2] = _mesa_unorm_to_float(b, 8);
74
75
76 dst[3] = _mesa_unorm_to_float(a, 8);
77 }
78
79 static inline void
unpack_float_x8b8g8r8_unorm(const void * void_src,float dst[4])80 unpack_float_x8b8g8r8_unorm(const void *void_src, float dst[4])
81 {
82 uint32_t *src = (uint32_t *)void_src;
83 uint8_t b = UNPACK(*src, 8, 8);
84 uint8_t g = UNPACK(*src, 16, 8);
85 uint8_t r = UNPACK(*src, 24, 8);
86
87
88
89 dst[0] = _mesa_unorm_to_float(r, 8);
90
91
92 dst[1] = _mesa_unorm_to_float(g, 8);
93
94
95 dst[2] = _mesa_unorm_to_float(b, 8);
96
97 dst[3] = 1.0f;
98 }
99
100 static inline void
unpack_float_r8g8b8a8_unorm(const void * void_src,float dst[4])101 unpack_float_r8g8b8a8_unorm(const void *void_src, float dst[4])
102 {
103 uint32_t *src = (uint32_t *)void_src;
104 uint8_t r = UNPACK(*src, 0, 8);
105 uint8_t g = UNPACK(*src, 8, 8);
106 uint8_t b = UNPACK(*src, 16, 8);
107 uint8_t a = UNPACK(*src, 24, 8);
108
109
110
111 dst[0] = _mesa_unorm_to_float(r, 8);
112
113
114 dst[1] = _mesa_unorm_to_float(g, 8);
115
116
117 dst[2] = _mesa_unorm_to_float(b, 8);
118
119
120 dst[3] = _mesa_unorm_to_float(a, 8);
121 }
122
123 static inline void
unpack_float_r8g8b8x8_unorm(const void * void_src,float dst[4])124 unpack_float_r8g8b8x8_unorm(const void *void_src, float dst[4])
125 {
126 uint32_t *src = (uint32_t *)void_src;
127 uint8_t r = UNPACK(*src, 0, 8);
128 uint8_t g = UNPACK(*src, 8, 8);
129 uint8_t b = UNPACK(*src, 16, 8);
130
131
132
133 dst[0] = _mesa_unorm_to_float(r, 8);
134
135
136 dst[1] = _mesa_unorm_to_float(g, 8);
137
138
139 dst[2] = _mesa_unorm_to_float(b, 8);
140
141 dst[3] = 1.0f;
142 }
143
144 static inline void
unpack_float_b8g8r8a8_unorm(const void * void_src,float dst[4])145 unpack_float_b8g8r8a8_unorm(const void *void_src, float dst[4])
146 {
147 uint32_t *src = (uint32_t *)void_src;
148 uint8_t b = UNPACK(*src, 0, 8);
149 uint8_t g = UNPACK(*src, 8, 8);
150 uint8_t r = UNPACK(*src, 16, 8);
151 uint8_t a = UNPACK(*src, 24, 8);
152
153
154
155 dst[0] = _mesa_unorm_to_float(r, 8);
156
157
158 dst[1] = _mesa_unorm_to_float(g, 8);
159
160
161 dst[2] = _mesa_unorm_to_float(b, 8);
162
163
164 dst[3] = _mesa_unorm_to_float(a, 8);
165 }
166
167 static inline void
unpack_float_b8g8r8x8_unorm(const void * void_src,float dst[4])168 unpack_float_b8g8r8x8_unorm(const void *void_src, float dst[4])
169 {
170 uint32_t *src = (uint32_t *)void_src;
171 uint8_t b = UNPACK(*src, 0, 8);
172 uint8_t g = UNPACK(*src, 8, 8);
173 uint8_t r = UNPACK(*src, 16, 8);
174
175
176
177 dst[0] = _mesa_unorm_to_float(r, 8);
178
179
180 dst[1] = _mesa_unorm_to_float(g, 8);
181
182
183 dst[2] = _mesa_unorm_to_float(b, 8);
184
185 dst[3] = 1.0f;
186 }
187
188 static inline void
unpack_float_a8r8g8b8_unorm(const void * void_src,float dst[4])189 unpack_float_a8r8g8b8_unorm(const void *void_src, float dst[4])
190 {
191 uint32_t *src = (uint32_t *)void_src;
192 uint8_t a = UNPACK(*src, 0, 8);
193 uint8_t r = UNPACK(*src, 8, 8);
194 uint8_t g = UNPACK(*src, 16, 8);
195 uint8_t b = UNPACK(*src, 24, 8);
196
197
198
199 dst[0] = _mesa_unorm_to_float(r, 8);
200
201
202 dst[1] = _mesa_unorm_to_float(g, 8);
203
204
205 dst[2] = _mesa_unorm_to_float(b, 8);
206
207
208 dst[3] = _mesa_unorm_to_float(a, 8);
209 }
210
211 static inline void
unpack_float_x8r8g8b8_unorm(const void * void_src,float dst[4])212 unpack_float_x8r8g8b8_unorm(const void *void_src, float dst[4])
213 {
214 uint32_t *src = (uint32_t *)void_src;
215 uint8_t r = UNPACK(*src, 8, 8);
216 uint8_t g = UNPACK(*src, 16, 8);
217 uint8_t b = UNPACK(*src, 24, 8);
218
219
220
221 dst[0] = _mesa_unorm_to_float(r, 8);
222
223
224 dst[1] = _mesa_unorm_to_float(g, 8);
225
226
227 dst[2] = _mesa_unorm_to_float(b, 8);
228
229 dst[3] = 1.0f;
230 }
231
232 static inline void
unpack_float_b5g6r5_unorm(const void * void_src,float dst[4])233 unpack_float_b5g6r5_unorm(const void *void_src, float dst[4])
234 {
235 uint16_t *src = (uint16_t *)void_src;
236 uint8_t b = UNPACK(*src, 0, 5);
237 uint8_t g = UNPACK(*src, 5, 6);
238 uint8_t r = UNPACK(*src, 11, 5);
239
240
241
242 dst[0] = _mesa_unorm_to_float(r, 5);
243
244
245 dst[1] = _mesa_unorm_to_float(g, 6);
246
247
248 dst[2] = _mesa_unorm_to_float(b, 5);
249
250 dst[3] = 1.0f;
251 }
252
253 static inline void
unpack_float_r5g6b5_unorm(const void * void_src,float dst[4])254 unpack_float_r5g6b5_unorm(const void *void_src, float dst[4])
255 {
256 uint16_t *src = (uint16_t *)void_src;
257 uint8_t r = UNPACK(*src, 0, 5);
258 uint8_t g = UNPACK(*src, 5, 6);
259 uint8_t b = UNPACK(*src, 11, 5);
260
261
262
263 dst[0] = _mesa_unorm_to_float(r, 5);
264
265
266 dst[1] = _mesa_unorm_to_float(g, 6);
267
268
269 dst[2] = _mesa_unorm_to_float(b, 5);
270
271 dst[3] = 1.0f;
272 }
273
274 static inline void
unpack_float_b4g4r4a4_unorm(const void * void_src,float dst[4])275 unpack_float_b4g4r4a4_unorm(const void *void_src, float dst[4])
276 {
277 uint16_t *src = (uint16_t *)void_src;
278 uint8_t b = UNPACK(*src, 0, 4);
279 uint8_t g = UNPACK(*src, 4, 4);
280 uint8_t r = UNPACK(*src, 8, 4);
281 uint8_t a = UNPACK(*src, 12, 4);
282
283
284
285 dst[0] = _mesa_unorm_to_float(r, 4);
286
287
288 dst[1] = _mesa_unorm_to_float(g, 4);
289
290
291 dst[2] = _mesa_unorm_to_float(b, 4);
292
293
294 dst[3] = _mesa_unorm_to_float(a, 4);
295 }
296
297 static inline void
unpack_float_b4g4r4x4_unorm(const void * void_src,float dst[4])298 unpack_float_b4g4r4x4_unorm(const void *void_src, float dst[4])
299 {
300 uint16_t *src = (uint16_t *)void_src;
301 uint8_t b = UNPACK(*src, 0, 4);
302 uint8_t g = UNPACK(*src, 4, 4);
303 uint8_t r = UNPACK(*src, 8, 4);
304
305
306
307 dst[0] = _mesa_unorm_to_float(r, 4);
308
309
310 dst[1] = _mesa_unorm_to_float(g, 4);
311
312
313 dst[2] = _mesa_unorm_to_float(b, 4);
314
315 dst[3] = 1.0f;
316 }
317
318 static inline void
unpack_float_a4r4g4b4_unorm(const void * void_src,float dst[4])319 unpack_float_a4r4g4b4_unorm(const void *void_src, float dst[4])
320 {
321 uint16_t *src = (uint16_t *)void_src;
322 uint8_t a = UNPACK(*src, 0, 4);
323 uint8_t r = UNPACK(*src, 4, 4);
324 uint8_t g = UNPACK(*src, 8, 4);
325 uint8_t b = UNPACK(*src, 12, 4);
326
327
328
329 dst[0] = _mesa_unorm_to_float(r, 4);
330
331
332 dst[1] = _mesa_unorm_to_float(g, 4);
333
334
335 dst[2] = _mesa_unorm_to_float(b, 4);
336
337
338 dst[3] = _mesa_unorm_to_float(a, 4);
339 }
340
341 static inline void
unpack_float_a1b5g5r5_unorm(const void * void_src,float dst[4])342 unpack_float_a1b5g5r5_unorm(const void *void_src, float dst[4])
343 {
344 uint16_t *src = (uint16_t *)void_src;
345 uint8_t a = UNPACK(*src, 0, 1);
346 uint8_t b = UNPACK(*src, 1, 5);
347 uint8_t g = UNPACK(*src, 6, 5);
348 uint8_t r = UNPACK(*src, 11, 5);
349
350
351
352 dst[0] = _mesa_unorm_to_float(r, 5);
353
354
355 dst[1] = _mesa_unorm_to_float(g, 5);
356
357
358 dst[2] = _mesa_unorm_to_float(b, 5);
359
360
361 dst[3] = _mesa_unorm_to_float(a, 1);
362 }
363
364 static inline void
unpack_float_x1b5g5r5_unorm(const void * void_src,float dst[4])365 unpack_float_x1b5g5r5_unorm(const void *void_src, float dst[4])
366 {
367 uint16_t *src = (uint16_t *)void_src;
368 uint8_t b = UNPACK(*src, 1, 5);
369 uint8_t g = UNPACK(*src, 6, 5);
370 uint8_t r = UNPACK(*src, 11, 5);
371
372
373
374 dst[0] = _mesa_unorm_to_float(r, 5);
375
376
377 dst[1] = _mesa_unorm_to_float(g, 5);
378
379
380 dst[2] = _mesa_unorm_to_float(b, 5);
381
382 dst[3] = 1.0f;
383 }
384
385 static inline void
unpack_float_b5g5r5a1_unorm(const void * void_src,float dst[4])386 unpack_float_b5g5r5a1_unorm(const void *void_src, float dst[4])
387 {
388 uint16_t *src = (uint16_t *)void_src;
389 uint8_t b = UNPACK(*src, 0, 5);
390 uint8_t g = UNPACK(*src, 5, 5);
391 uint8_t r = UNPACK(*src, 10, 5);
392 uint8_t a = UNPACK(*src, 15, 1);
393
394
395
396 dst[0] = _mesa_unorm_to_float(r, 5);
397
398
399 dst[1] = _mesa_unorm_to_float(g, 5);
400
401
402 dst[2] = _mesa_unorm_to_float(b, 5);
403
404
405 dst[3] = _mesa_unorm_to_float(a, 1);
406 }
407
408 static inline void
unpack_float_b5g5r5x1_unorm(const void * void_src,float dst[4])409 unpack_float_b5g5r5x1_unorm(const void *void_src, float dst[4])
410 {
411 uint16_t *src = (uint16_t *)void_src;
412 uint8_t b = UNPACK(*src, 0, 5);
413 uint8_t g = UNPACK(*src, 5, 5);
414 uint8_t r = UNPACK(*src, 10, 5);
415
416
417
418 dst[0] = _mesa_unorm_to_float(r, 5);
419
420
421 dst[1] = _mesa_unorm_to_float(g, 5);
422
423
424 dst[2] = _mesa_unorm_to_float(b, 5);
425
426 dst[3] = 1.0f;
427 }
428
429 static inline void
unpack_float_a1r5g5b5_unorm(const void * void_src,float dst[4])430 unpack_float_a1r5g5b5_unorm(const void *void_src, float dst[4])
431 {
432 uint16_t *src = (uint16_t *)void_src;
433 uint8_t a = UNPACK(*src, 0, 1);
434 uint8_t r = UNPACK(*src, 1, 5);
435 uint8_t g = UNPACK(*src, 6, 5);
436 uint8_t b = UNPACK(*src, 11, 5);
437
438
439
440 dst[0] = _mesa_unorm_to_float(r, 5);
441
442
443 dst[1] = _mesa_unorm_to_float(g, 5);
444
445
446 dst[2] = _mesa_unorm_to_float(b, 5);
447
448
449 dst[3] = _mesa_unorm_to_float(a, 1);
450 }
451
452 static inline void
unpack_float_l4a4_unorm(const void * void_src,float dst[4])453 unpack_float_l4a4_unorm(const void *void_src, float dst[4])
454 {
455 uint8_t *src = (uint8_t *)void_src;
456 uint8_t l = UNPACK(*src, 0, 4);
457 uint8_t a = UNPACK(*src, 4, 4);
458
459
460
461 dst[0] = _mesa_unorm_to_float(l, 4);
462
463
464 dst[1] = _mesa_unorm_to_float(l, 4);
465
466
467 dst[2] = _mesa_unorm_to_float(l, 4);
468
469
470 dst[3] = _mesa_unorm_to_float(a, 4);
471 }
472
473 static inline void
unpack_float_b2g3r3_unorm(const void * void_src,float dst[4])474 unpack_float_b2g3r3_unorm(const void *void_src, float dst[4])
475 {
476 uint8_t *src = (uint8_t *)void_src;
477 uint8_t b = UNPACK(*src, 0, 2);
478 uint8_t g = UNPACK(*src, 2, 3);
479 uint8_t r = UNPACK(*src, 5, 3);
480
481
482
483 dst[0] = _mesa_unorm_to_float(r, 3);
484
485
486 dst[1] = _mesa_unorm_to_float(g, 3);
487
488
489 dst[2] = _mesa_unorm_to_float(b, 2);
490
491 dst[3] = 1.0f;
492 }
493
494 static inline void
unpack_float_b10g10r10a2_unorm(const void * void_src,float dst[4])495 unpack_float_b10g10r10a2_unorm(const void *void_src, float dst[4])
496 {
497 uint32_t *src = (uint32_t *)void_src;
498 uint16_t b = UNPACK(*src, 0, 10);
499 uint16_t g = UNPACK(*src, 10, 10);
500 uint16_t r = UNPACK(*src, 20, 10);
501 uint8_t a = UNPACK(*src, 30, 2);
502
503
504
505 dst[0] = _mesa_unorm_to_float(r, 10);
506
507
508 dst[1] = _mesa_unorm_to_float(g, 10);
509
510
511 dst[2] = _mesa_unorm_to_float(b, 10);
512
513
514 dst[3] = _mesa_unorm_to_float(a, 2);
515 }
516
517 static inline void
unpack_float_b10g10r10x2_unorm(const void * void_src,float dst[4])518 unpack_float_b10g10r10x2_unorm(const void *void_src, float dst[4])
519 {
520 uint32_t *src = (uint32_t *)void_src;
521 uint16_t b = UNPACK(*src, 0, 10);
522 uint16_t g = UNPACK(*src, 10, 10);
523 uint16_t r = UNPACK(*src, 20, 10);
524
525
526
527 dst[0] = _mesa_unorm_to_float(r, 10);
528
529
530 dst[1] = _mesa_unorm_to_float(g, 10);
531
532
533 dst[2] = _mesa_unorm_to_float(b, 10);
534
535 dst[3] = 1.0f;
536 }
537
538 static inline void
unpack_float_r10g10b10a2_unorm(const void * void_src,float dst[4])539 unpack_float_r10g10b10a2_unorm(const void *void_src, float dst[4])
540 {
541 uint32_t *src = (uint32_t *)void_src;
542 uint16_t r = UNPACK(*src, 0, 10);
543 uint16_t g = UNPACK(*src, 10, 10);
544 uint16_t b = UNPACK(*src, 20, 10);
545 uint8_t a = UNPACK(*src, 30, 2);
546
547
548
549 dst[0] = _mesa_unorm_to_float(r, 10);
550
551
552 dst[1] = _mesa_unorm_to_float(g, 10);
553
554
555 dst[2] = _mesa_unorm_to_float(b, 10);
556
557
558 dst[3] = _mesa_unorm_to_float(a, 2);
559 }
560
561 static inline void
unpack_float_r10g10b10x2_unorm(const void * void_src,float dst[4])562 unpack_float_r10g10b10x2_unorm(const void *void_src, float dst[4])
563 {
564 uint32_t *src = (uint32_t *)void_src;
565 uint16_t r = UNPACK(*src, 0, 10);
566 uint16_t g = UNPACK(*src, 10, 10);
567 uint16_t b = UNPACK(*src, 20, 10);
568
569
570
571 dst[0] = _mesa_unorm_to_float(r, 10);
572
573
574 dst[1] = _mesa_unorm_to_float(g, 10);
575
576
577 dst[2] = _mesa_unorm_to_float(b, 10);
578
579 dst[3] = 1.0f;
580 }
581
582 static inline void
unpack_float_r3g3b2_unorm(const void * void_src,float dst[4])583 unpack_float_r3g3b2_unorm(const void *void_src, float dst[4])
584 {
585 uint8_t *src = (uint8_t *)void_src;
586 uint8_t r = UNPACK(*src, 0, 3);
587 uint8_t g = UNPACK(*src, 3, 3);
588 uint8_t b = UNPACK(*src, 6, 2);
589
590
591
592 dst[0] = _mesa_unorm_to_float(r, 3);
593
594
595 dst[1] = _mesa_unorm_to_float(g, 3);
596
597
598 dst[2] = _mesa_unorm_to_float(b, 2);
599
600 dst[3] = 1.0f;
601 }
602
603 static inline void
unpack_float_a4b4g4r4_unorm(const void * void_src,float dst[4])604 unpack_float_a4b4g4r4_unorm(const void *void_src, float dst[4])
605 {
606 uint16_t *src = (uint16_t *)void_src;
607 uint8_t a = UNPACK(*src, 0, 4);
608 uint8_t b = UNPACK(*src, 4, 4);
609 uint8_t g = UNPACK(*src, 8, 4);
610 uint8_t r = UNPACK(*src, 12, 4);
611
612
613
614 dst[0] = _mesa_unorm_to_float(r, 4);
615
616
617 dst[1] = _mesa_unorm_to_float(g, 4);
618
619
620 dst[2] = _mesa_unorm_to_float(b, 4);
621
622
623 dst[3] = _mesa_unorm_to_float(a, 4);
624 }
625
626 static inline void
unpack_float_r4g4b4a4_unorm(const void * void_src,float dst[4])627 unpack_float_r4g4b4a4_unorm(const void *void_src, float dst[4])
628 {
629 uint16_t *src = (uint16_t *)void_src;
630 uint8_t r = UNPACK(*src, 0, 4);
631 uint8_t g = UNPACK(*src, 4, 4);
632 uint8_t b = UNPACK(*src, 8, 4);
633 uint8_t a = UNPACK(*src, 12, 4);
634
635
636
637 dst[0] = _mesa_unorm_to_float(r, 4);
638
639
640 dst[1] = _mesa_unorm_to_float(g, 4);
641
642
643 dst[2] = _mesa_unorm_to_float(b, 4);
644
645
646 dst[3] = _mesa_unorm_to_float(a, 4);
647 }
648
649 static inline void
unpack_float_r5g5b5a1_unorm(const void * void_src,float dst[4])650 unpack_float_r5g5b5a1_unorm(const void *void_src, float dst[4])
651 {
652 uint16_t *src = (uint16_t *)void_src;
653 uint8_t r = UNPACK(*src, 0, 5);
654 uint8_t g = UNPACK(*src, 5, 5);
655 uint8_t b = UNPACK(*src, 10, 5);
656 uint8_t a = UNPACK(*src, 15, 1);
657
658
659
660 dst[0] = _mesa_unorm_to_float(r, 5);
661
662
663 dst[1] = _mesa_unorm_to_float(g, 5);
664
665
666 dst[2] = _mesa_unorm_to_float(b, 5);
667
668
669 dst[3] = _mesa_unorm_to_float(a, 1);
670 }
671
672 static inline void
unpack_float_a2b10g10r10_unorm(const void * void_src,float dst[4])673 unpack_float_a2b10g10r10_unorm(const void *void_src, float dst[4])
674 {
675 uint32_t *src = (uint32_t *)void_src;
676 uint8_t a = UNPACK(*src, 0, 2);
677 uint16_t b = UNPACK(*src, 2, 10);
678 uint16_t g = UNPACK(*src, 12, 10);
679 uint16_t r = UNPACK(*src, 22, 10);
680
681
682
683 dst[0] = _mesa_unorm_to_float(r, 10);
684
685
686 dst[1] = _mesa_unorm_to_float(g, 10);
687
688
689 dst[2] = _mesa_unorm_to_float(b, 10);
690
691
692 dst[3] = _mesa_unorm_to_float(a, 2);
693 }
694
695 static inline void
unpack_float_a2r10g10b10_unorm(const void * void_src,float dst[4])696 unpack_float_a2r10g10b10_unorm(const void *void_src, float dst[4])
697 {
698 uint32_t *src = (uint32_t *)void_src;
699 uint8_t a = UNPACK(*src, 0, 2);
700 uint16_t r = UNPACK(*src, 2, 10);
701 uint16_t g = UNPACK(*src, 12, 10);
702 uint16_t b = UNPACK(*src, 22, 10);
703
704
705
706 dst[0] = _mesa_unorm_to_float(r, 10);
707
708
709 dst[1] = _mesa_unorm_to_float(g, 10);
710
711
712 dst[2] = _mesa_unorm_to_float(b, 10);
713
714
715 dst[3] = _mesa_unorm_to_float(a, 2);
716 }
717
718 static inline void
unpack_float_a_unorm8(const void * void_src,float dst[4])719 unpack_float_a_unorm8(const void *void_src, float dst[4])
720 {
721 uint8_t *src = (uint8_t *)void_src;
722 uint8_t a = src[0];
723
724
725 dst[0] = 0.0f;
726
727 dst[1] = 0.0f;
728
729 dst[2] = 0.0f;
730
731
732 dst[3] = _mesa_unorm_to_float(a, 8);
733 }
734
735 static inline void
unpack_float_a_unorm16(const void * void_src,float dst[4])736 unpack_float_a_unorm16(const void *void_src, float dst[4])
737 {
738 uint16_t *src = (uint16_t *)void_src;
739 uint16_t a = src[0];
740
741
742 dst[0] = 0.0f;
743
744 dst[1] = 0.0f;
745
746 dst[2] = 0.0f;
747
748
749 dst[3] = _mesa_unorm_to_float(a, 16);
750 }
751
752 static inline void
unpack_float_l_unorm8(const void * void_src,float dst[4])753 unpack_float_l_unorm8(const void *void_src, float dst[4])
754 {
755 uint8_t *src = (uint8_t *)void_src;
756 uint8_t l = src[0];
757
758
759
760 dst[0] = _mesa_unorm_to_float(l, 8);
761
762
763 dst[1] = _mesa_unorm_to_float(l, 8);
764
765
766 dst[2] = _mesa_unorm_to_float(l, 8);
767
768 dst[3] = 1.0f;
769 }
770
771 static inline void
unpack_float_l_unorm16(const void * void_src,float dst[4])772 unpack_float_l_unorm16(const void *void_src, float dst[4])
773 {
774 uint16_t *src = (uint16_t *)void_src;
775 uint16_t l = src[0];
776
777
778
779 dst[0] = _mesa_unorm_to_float(l, 16);
780
781
782 dst[1] = _mesa_unorm_to_float(l, 16);
783
784
785 dst[2] = _mesa_unorm_to_float(l, 16);
786
787 dst[3] = 1.0f;
788 }
789
790 static inline void
unpack_float_la_unorm8(const void * void_src,float dst[4])791 unpack_float_la_unorm8(const void *void_src, float dst[4])
792 {
793 uint8_t *src = (uint8_t *)void_src;
794 uint8_t l = src[0];
795 uint8_t a = src[1];
796
797
798
799 dst[0] = _mesa_unorm_to_float(l, 8);
800
801
802 dst[1] = _mesa_unorm_to_float(l, 8);
803
804
805 dst[2] = _mesa_unorm_to_float(l, 8);
806
807
808 dst[3] = _mesa_unorm_to_float(a, 8);
809 }
810
811 static inline void
unpack_float_la_unorm16(const void * void_src,float dst[4])812 unpack_float_la_unorm16(const void *void_src, float dst[4])
813 {
814 uint16_t *src = (uint16_t *)void_src;
815 uint16_t l = src[0];
816 uint16_t a = src[1];
817
818
819
820 dst[0] = _mesa_unorm_to_float(l, 16);
821
822
823 dst[1] = _mesa_unorm_to_float(l, 16);
824
825
826 dst[2] = _mesa_unorm_to_float(l, 16);
827
828
829 dst[3] = _mesa_unorm_to_float(a, 16);
830 }
831
832 static inline void
unpack_float_i_unorm8(const void * void_src,float dst[4])833 unpack_float_i_unorm8(const void *void_src, float dst[4])
834 {
835 uint8_t *src = (uint8_t *)void_src;
836 uint8_t i = src[0];
837
838
839
840 dst[0] = _mesa_unorm_to_float(i, 8);
841
842
843 dst[1] = _mesa_unorm_to_float(i, 8);
844
845
846 dst[2] = _mesa_unorm_to_float(i, 8);
847
848
849 dst[3] = _mesa_unorm_to_float(i, 8);
850 }
851
852 static inline void
unpack_float_i_unorm16(const void * void_src,float dst[4])853 unpack_float_i_unorm16(const void *void_src, float dst[4])
854 {
855 uint16_t *src = (uint16_t *)void_src;
856 uint16_t i = src[0];
857
858
859
860 dst[0] = _mesa_unorm_to_float(i, 16);
861
862
863 dst[1] = _mesa_unorm_to_float(i, 16);
864
865
866 dst[2] = _mesa_unorm_to_float(i, 16);
867
868
869 dst[3] = _mesa_unorm_to_float(i, 16);
870 }
871
872 static inline void
unpack_float_r_unorm8(const void * void_src,float dst[4])873 unpack_float_r_unorm8(const void *void_src, float dst[4])
874 {
875 uint8_t *src = (uint8_t *)void_src;
876 uint8_t r = src[0];
877
878
879
880 dst[0] = _mesa_unorm_to_float(r, 8);
881
882 dst[1] = 0.0f;
883
884 dst[2] = 0.0f;
885
886 dst[3] = 1.0f;
887 }
888
889 static inline void
unpack_float_r_unorm16(const void * void_src,float dst[4])890 unpack_float_r_unorm16(const void *void_src, float dst[4])
891 {
892 uint16_t *src = (uint16_t *)void_src;
893 uint16_t r = src[0];
894
895
896
897 dst[0] = _mesa_unorm_to_float(r, 16);
898
899 dst[1] = 0.0f;
900
901 dst[2] = 0.0f;
902
903 dst[3] = 1.0f;
904 }
905
906 static inline void
unpack_float_rg_unorm8(const void * void_src,float dst[4])907 unpack_float_rg_unorm8(const void *void_src, float dst[4])
908 {
909 uint8_t *src = (uint8_t *)void_src;
910 uint8_t r = src[0];
911 uint8_t g = src[1];
912
913
914
915 dst[0] = _mesa_unorm_to_float(r, 8);
916
917
918 dst[1] = _mesa_unorm_to_float(g, 8);
919
920 dst[2] = 0.0f;
921
922 dst[3] = 1.0f;
923 }
924
925 static inline void
unpack_float_rg_unorm16(const void * void_src,float dst[4])926 unpack_float_rg_unorm16(const void *void_src, float dst[4])
927 {
928 uint16_t *src = (uint16_t *)void_src;
929 uint16_t r = src[0];
930 uint16_t g = src[1];
931
932
933
934 dst[0] = _mesa_unorm_to_float(r, 16);
935
936
937 dst[1] = _mesa_unorm_to_float(g, 16);
938
939 dst[2] = 0.0f;
940
941 dst[3] = 1.0f;
942 }
943
944 static inline void
unpack_float_bgr_unorm8(const void * void_src,float dst[4])945 unpack_float_bgr_unorm8(const void *void_src, float dst[4])
946 {
947 uint8_t *src = (uint8_t *)void_src;
948 uint8_t b = src[0];
949 uint8_t g = src[1];
950 uint8_t r = src[2];
951
952
953
954 dst[0] = _mesa_unorm_to_float(r, 8);
955
956
957 dst[1] = _mesa_unorm_to_float(g, 8);
958
959
960 dst[2] = _mesa_unorm_to_float(b, 8);
961
962 dst[3] = 1.0f;
963 }
964
965 static inline void
unpack_float_rgb_unorm8(const void * void_src,float dst[4])966 unpack_float_rgb_unorm8(const void *void_src, float dst[4])
967 {
968 uint8_t *src = (uint8_t *)void_src;
969 uint8_t r = src[0];
970 uint8_t g = src[1];
971 uint8_t b = src[2];
972
973
974
975 dst[0] = _mesa_unorm_to_float(r, 8);
976
977
978 dst[1] = _mesa_unorm_to_float(g, 8);
979
980
981 dst[2] = _mesa_unorm_to_float(b, 8);
982
983 dst[3] = 1.0f;
984 }
985
986 static inline void
unpack_float_rgba_unorm16(const void * void_src,float dst[4])987 unpack_float_rgba_unorm16(const void *void_src, float dst[4])
988 {
989 uint16_t *src = (uint16_t *)void_src;
990 uint16_t r = src[0];
991 uint16_t g = src[1];
992 uint16_t b = src[2];
993 uint16_t a = src[3];
994
995
996
997 dst[0] = _mesa_unorm_to_float(r, 16);
998
999
1000 dst[1] = _mesa_unorm_to_float(g, 16);
1001
1002
1003 dst[2] = _mesa_unorm_to_float(b, 16);
1004
1005
1006 dst[3] = _mesa_unorm_to_float(a, 16);
1007 }
1008
1009 static inline void
unpack_float_rgbx_unorm16(const void * void_src,float dst[4])1010 unpack_float_rgbx_unorm16(const void *void_src, float dst[4])
1011 {
1012 uint16_t *src = (uint16_t *)void_src;
1013 uint16_t r = src[0];
1014 uint16_t g = src[1];
1015 uint16_t b = src[2];
1016
1017
1018
1019 dst[0] = _mesa_unorm_to_float(r, 16);
1020
1021
1022 dst[1] = _mesa_unorm_to_float(g, 16);
1023
1024
1025 dst[2] = _mesa_unorm_to_float(b, 16);
1026
1027 dst[3] = 1.0f;
1028 }
1029
1030 static inline void
unpack_float_a8b8g8r8_snorm(const void * void_src,float dst[4])1031 unpack_float_a8b8g8r8_snorm(const void *void_src, float dst[4])
1032 {
1033 uint32_t *src = (uint32_t *)void_src;
1034 int8_t a = UNPACK(*src, 0, 8);
1035 int8_t b = UNPACK(*src, 8, 8);
1036 int8_t g = UNPACK(*src, 16, 8);
1037 int8_t r = UNPACK(*src, 24, 8);
1038
1039
1040
1041 dst[0] = _mesa_snorm_to_float(r, 8);
1042
1043
1044 dst[1] = _mesa_snorm_to_float(g, 8);
1045
1046
1047 dst[2] = _mesa_snorm_to_float(b, 8);
1048
1049
1050 dst[3] = _mesa_snorm_to_float(a, 8);
1051 }
1052
1053 static inline void
unpack_float_x8b8g8r8_snorm(const void * void_src,float dst[4])1054 unpack_float_x8b8g8r8_snorm(const void *void_src, float dst[4])
1055 {
1056 uint32_t *src = (uint32_t *)void_src;
1057 int8_t b = UNPACK(*src, 8, 8);
1058 int8_t g = UNPACK(*src, 16, 8);
1059 int8_t r = UNPACK(*src, 24, 8);
1060
1061
1062
1063 dst[0] = _mesa_snorm_to_float(r, 8);
1064
1065
1066 dst[1] = _mesa_snorm_to_float(g, 8);
1067
1068
1069 dst[2] = _mesa_snorm_to_float(b, 8);
1070
1071 dst[3] = 1.0f;
1072 }
1073
1074 static inline void
unpack_float_r8g8b8a8_snorm(const void * void_src,float dst[4])1075 unpack_float_r8g8b8a8_snorm(const void *void_src, float dst[4])
1076 {
1077 uint32_t *src = (uint32_t *)void_src;
1078 int8_t r = UNPACK(*src, 0, 8);
1079 int8_t g = UNPACK(*src, 8, 8);
1080 int8_t b = UNPACK(*src, 16, 8);
1081 int8_t a = UNPACK(*src, 24, 8);
1082
1083
1084
1085 dst[0] = _mesa_snorm_to_float(r, 8);
1086
1087
1088 dst[1] = _mesa_snorm_to_float(g, 8);
1089
1090
1091 dst[2] = _mesa_snorm_to_float(b, 8);
1092
1093
1094 dst[3] = _mesa_snorm_to_float(a, 8);
1095 }
1096
1097 static inline void
unpack_float_r8g8b8x8_snorm(const void * void_src,float dst[4])1098 unpack_float_r8g8b8x8_snorm(const void *void_src, float dst[4])
1099 {
1100 uint32_t *src = (uint32_t *)void_src;
1101 int8_t r = UNPACK(*src, 0, 8);
1102 int8_t g = UNPACK(*src, 8, 8);
1103 int8_t b = UNPACK(*src, 16, 8);
1104
1105
1106
1107 dst[0] = _mesa_snorm_to_float(r, 8);
1108
1109
1110 dst[1] = _mesa_snorm_to_float(g, 8);
1111
1112
1113 dst[2] = _mesa_snorm_to_float(b, 8);
1114
1115 dst[3] = 1.0f;
1116 }
1117
1118 static inline void
unpack_float_a_snorm8(const void * void_src,float dst[4])1119 unpack_float_a_snorm8(const void *void_src, float dst[4])
1120 {
1121 int8_t *src = (int8_t *)void_src;
1122 int8_t a = src[0];
1123
1124
1125 dst[0] = 0.0f;
1126
1127 dst[1] = 0.0f;
1128
1129 dst[2] = 0.0f;
1130
1131
1132 dst[3] = _mesa_snorm_to_float(a, 8);
1133 }
1134
1135 static inline void
unpack_float_a_snorm16(const void * void_src,float dst[4])1136 unpack_float_a_snorm16(const void *void_src, float dst[4])
1137 {
1138 int16_t *src = (int16_t *)void_src;
1139 int16_t a = src[0];
1140
1141
1142 dst[0] = 0.0f;
1143
1144 dst[1] = 0.0f;
1145
1146 dst[2] = 0.0f;
1147
1148
1149 dst[3] = _mesa_snorm_to_float(a, 16);
1150 }
1151
1152 static inline void
unpack_float_l_snorm8(const void * void_src,float dst[4])1153 unpack_float_l_snorm8(const void *void_src, float dst[4])
1154 {
1155 int8_t *src = (int8_t *)void_src;
1156 int8_t l = src[0];
1157
1158
1159
1160 dst[0] = _mesa_snorm_to_float(l, 8);
1161
1162
1163 dst[1] = _mesa_snorm_to_float(l, 8);
1164
1165
1166 dst[2] = _mesa_snorm_to_float(l, 8);
1167
1168 dst[3] = 1.0f;
1169 }
1170
1171 static inline void
unpack_float_l_snorm16(const void * void_src,float dst[4])1172 unpack_float_l_snorm16(const void *void_src, float dst[4])
1173 {
1174 int16_t *src = (int16_t *)void_src;
1175 int16_t l = src[0];
1176
1177
1178
1179 dst[0] = _mesa_snorm_to_float(l, 16);
1180
1181
1182 dst[1] = _mesa_snorm_to_float(l, 16);
1183
1184
1185 dst[2] = _mesa_snorm_to_float(l, 16);
1186
1187 dst[3] = 1.0f;
1188 }
1189
1190 static inline void
unpack_float_i_snorm8(const void * void_src,float dst[4])1191 unpack_float_i_snorm8(const void *void_src, float dst[4])
1192 {
1193 int8_t *src = (int8_t *)void_src;
1194 int8_t i = src[0];
1195
1196
1197
1198 dst[0] = _mesa_snorm_to_float(i, 8);
1199
1200
1201 dst[1] = _mesa_snorm_to_float(i, 8);
1202
1203
1204 dst[2] = _mesa_snorm_to_float(i, 8);
1205
1206
1207 dst[3] = _mesa_snorm_to_float(i, 8);
1208 }
1209
1210 static inline void
unpack_float_i_snorm16(const void * void_src,float dst[4])1211 unpack_float_i_snorm16(const void *void_src, float dst[4])
1212 {
1213 int16_t *src = (int16_t *)void_src;
1214 int16_t i = src[0];
1215
1216
1217
1218 dst[0] = _mesa_snorm_to_float(i, 16);
1219
1220
1221 dst[1] = _mesa_snorm_to_float(i, 16);
1222
1223
1224 dst[2] = _mesa_snorm_to_float(i, 16);
1225
1226
1227 dst[3] = _mesa_snorm_to_float(i, 16);
1228 }
1229
1230 static inline void
unpack_float_r_snorm8(const void * void_src,float dst[4])1231 unpack_float_r_snorm8(const void *void_src, float dst[4])
1232 {
1233 int8_t *src = (int8_t *)void_src;
1234 int8_t r = src[0];
1235
1236
1237
1238 dst[0] = _mesa_snorm_to_float(r, 8);
1239
1240 dst[1] = 0.0f;
1241
1242 dst[2] = 0.0f;
1243
1244 dst[3] = 1.0f;
1245 }
1246
1247 static inline void
unpack_float_r_snorm16(const void * void_src,float dst[4])1248 unpack_float_r_snorm16(const void *void_src, float dst[4])
1249 {
1250 int16_t *src = (int16_t *)void_src;
1251 int16_t r = src[0];
1252
1253
1254
1255 dst[0] = _mesa_snorm_to_float(r, 16);
1256
1257 dst[1] = 0.0f;
1258
1259 dst[2] = 0.0f;
1260
1261 dst[3] = 1.0f;
1262 }
1263
1264 static inline void
unpack_float_la_snorm8(const void * void_src,float dst[4])1265 unpack_float_la_snorm8(const void *void_src, float dst[4])
1266 {
1267 int8_t *src = (int8_t *)void_src;
1268 int8_t l = src[0];
1269 int8_t a = src[1];
1270
1271
1272
1273 dst[0] = _mesa_snorm_to_float(l, 8);
1274
1275
1276 dst[1] = _mesa_snorm_to_float(l, 8);
1277
1278
1279 dst[2] = _mesa_snorm_to_float(l, 8);
1280
1281
1282 dst[3] = _mesa_snorm_to_float(a, 8);
1283 }
1284
1285 static inline void
unpack_float_la_snorm16(const void * void_src,float dst[4])1286 unpack_float_la_snorm16(const void *void_src, float dst[4])
1287 {
1288 int16_t *src = (int16_t *)void_src;
1289 int16_t l = src[0];
1290 int16_t a = src[1];
1291
1292
1293
1294 dst[0] = _mesa_snorm_to_float(l, 16);
1295
1296
1297 dst[1] = _mesa_snorm_to_float(l, 16);
1298
1299
1300 dst[2] = _mesa_snorm_to_float(l, 16);
1301
1302
1303 dst[3] = _mesa_snorm_to_float(a, 16);
1304 }
1305
1306 static inline void
unpack_float_rg_snorm8(const void * void_src,float dst[4])1307 unpack_float_rg_snorm8(const void *void_src, float dst[4])
1308 {
1309 int8_t *src = (int8_t *)void_src;
1310 int8_t r = src[0];
1311 int8_t g = src[1];
1312
1313
1314
1315 dst[0] = _mesa_snorm_to_float(r, 8);
1316
1317
1318 dst[1] = _mesa_snorm_to_float(g, 8);
1319
1320 dst[2] = 0.0f;
1321
1322 dst[3] = 1.0f;
1323 }
1324
1325 static inline void
unpack_float_rg_snorm16(const void * void_src,float dst[4])1326 unpack_float_rg_snorm16(const void *void_src, float dst[4])
1327 {
1328 int16_t *src = (int16_t *)void_src;
1329 int16_t r = src[0];
1330 int16_t g = src[1];
1331
1332
1333
1334 dst[0] = _mesa_snorm_to_float(r, 16);
1335
1336
1337 dst[1] = _mesa_snorm_to_float(g, 16);
1338
1339 dst[2] = 0.0f;
1340
1341 dst[3] = 1.0f;
1342 }
1343
1344 static inline void
unpack_float_rgb_snorm16(const void * void_src,float dst[4])1345 unpack_float_rgb_snorm16(const void *void_src, float dst[4])
1346 {
1347 int16_t *src = (int16_t *)void_src;
1348 int16_t r = src[0];
1349 int16_t g = src[1];
1350 int16_t b = src[2];
1351
1352
1353
1354 dst[0] = _mesa_snorm_to_float(r, 16);
1355
1356
1357 dst[1] = _mesa_snorm_to_float(g, 16);
1358
1359
1360 dst[2] = _mesa_snorm_to_float(b, 16);
1361
1362 dst[3] = 1.0f;
1363 }
1364
1365 static inline void
unpack_float_rgba_snorm16(const void * void_src,float dst[4])1366 unpack_float_rgba_snorm16(const void *void_src, float dst[4])
1367 {
1368 int16_t *src = (int16_t *)void_src;
1369 int16_t r = src[0];
1370 int16_t g = src[1];
1371 int16_t b = src[2];
1372 int16_t a = src[3];
1373
1374
1375
1376 dst[0] = _mesa_snorm_to_float(r, 16);
1377
1378
1379 dst[1] = _mesa_snorm_to_float(g, 16);
1380
1381
1382 dst[2] = _mesa_snorm_to_float(b, 16);
1383
1384
1385 dst[3] = _mesa_snorm_to_float(a, 16);
1386 }
1387
1388 static inline void
unpack_float_rgbx_snorm16(const void * void_src,float dst[4])1389 unpack_float_rgbx_snorm16(const void *void_src, float dst[4])
1390 {
1391 int16_t *src = (int16_t *)void_src;
1392 int16_t r = src[0];
1393 int16_t g = src[1];
1394 int16_t b = src[2];
1395
1396
1397
1398 dst[0] = _mesa_snorm_to_float(r, 16);
1399
1400
1401 dst[1] = _mesa_snorm_to_float(g, 16);
1402
1403
1404 dst[2] = _mesa_snorm_to_float(b, 16);
1405
1406 dst[3] = 1.0f;
1407 }
1408
1409 static inline void
unpack_float_a8b8g8r8_srgb(const void * void_src,float dst[4])1410 unpack_float_a8b8g8r8_srgb(const void *void_src, float dst[4])
1411 {
1412 uint32_t *src = (uint32_t *)void_src;
1413 uint8_t a = UNPACK(*src, 0, 8);
1414 uint8_t b = UNPACK(*src, 8, 8);
1415 uint8_t g = UNPACK(*src, 16, 8);
1416 uint8_t r = UNPACK(*src, 24, 8);
1417
1418
1419
1420
1421 dst[0] = util_format_srgb_8unorm_to_linear_float(r);
1422
1423
1424
1425 dst[1] = util_format_srgb_8unorm_to_linear_float(g);
1426
1427
1428
1429 dst[2] = util_format_srgb_8unorm_to_linear_float(b);
1430
1431
1432 dst[3] = _mesa_unorm_to_float(a, 8);
1433 }
1434
1435 static inline void
unpack_float_b8g8r8a8_srgb(const void * void_src,float dst[4])1436 unpack_float_b8g8r8a8_srgb(const void *void_src, float dst[4])
1437 {
1438 uint32_t *src = (uint32_t *)void_src;
1439 uint8_t b = UNPACK(*src, 0, 8);
1440 uint8_t g = UNPACK(*src, 8, 8);
1441 uint8_t r = UNPACK(*src, 16, 8);
1442 uint8_t a = UNPACK(*src, 24, 8);
1443
1444
1445
1446
1447 dst[0] = util_format_srgb_8unorm_to_linear_float(r);
1448
1449
1450
1451 dst[1] = util_format_srgb_8unorm_to_linear_float(g);
1452
1453
1454
1455 dst[2] = util_format_srgb_8unorm_to_linear_float(b);
1456
1457
1458 dst[3] = _mesa_unorm_to_float(a, 8);
1459 }
1460
1461 static inline void
unpack_float_a8r8g8b8_srgb(const void * void_src,float dst[4])1462 unpack_float_a8r8g8b8_srgb(const void *void_src, float dst[4])
1463 {
1464 uint32_t *src = (uint32_t *)void_src;
1465 uint8_t a = UNPACK(*src, 0, 8);
1466 uint8_t r = UNPACK(*src, 8, 8);
1467 uint8_t g = UNPACK(*src, 16, 8);
1468 uint8_t b = UNPACK(*src, 24, 8);
1469
1470
1471
1472
1473 dst[0] = util_format_srgb_8unorm_to_linear_float(r);
1474
1475
1476
1477 dst[1] = util_format_srgb_8unorm_to_linear_float(g);
1478
1479
1480
1481 dst[2] = util_format_srgb_8unorm_to_linear_float(b);
1482
1483
1484 dst[3] = _mesa_unorm_to_float(a, 8);
1485 }
1486
1487 static inline void
unpack_float_b8g8r8x8_srgb(const void * void_src,float dst[4])1488 unpack_float_b8g8r8x8_srgb(const void *void_src, float dst[4])
1489 {
1490 uint32_t *src = (uint32_t *)void_src;
1491 uint8_t b = UNPACK(*src, 0, 8);
1492 uint8_t g = UNPACK(*src, 8, 8);
1493 uint8_t r = UNPACK(*src, 16, 8);
1494
1495
1496
1497
1498 dst[0] = util_format_srgb_8unorm_to_linear_float(r);
1499
1500
1501
1502 dst[1] = util_format_srgb_8unorm_to_linear_float(g);
1503
1504
1505
1506 dst[2] = util_format_srgb_8unorm_to_linear_float(b);
1507
1508 dst[3] = 1.0f;
1509 }
1510
1511 static inline void
unpack_float_x8r8g8b8_srgb(const void * void_src,float dst[4])1512 unpack_float_x8r8g8b8_srgb(const void *void_src, float dst[4])
1513 {
1514 uint32_t *src = (uint32_t *)void_src;
1515 uint8_t r = UNPACK(*src, 8, 8);
1516 uint8_t g = UNPACK(*src, 16, 8);
1517 uint8_t b = UNPACK(*src, 24, 8);
1518
1519
1520
1521
1522 dst[0] = util_format_srgb_8unorm_to_linear_float(r);
1523
1524
1525
1526 dst[1] = util_format_srgb_8unorm_to_linear_float(g);
1527
1528
1529
1530 dst[2] = util_format_srgb_8unorm_to_linear_float(b);
1531
1532 dst[3] = 1.0f;
1533 }
1534
1535 static inline void
unpack_float_r8g8b8a8_srgb(const void * void_src,float dst[4])1536 unpack_float_r8g8b8a8_srgb(const void *void_src, float dst[4])
1537 {
1538 uint32_t *src = (uint32_t *)void_src;
1539 uint8_t r = UNPACK(*src, 0, 8);
1540 uint8_t g = UNPACK(*src, 8, 8);
1541 uint8_t b = UNPACK(*src, 16, 8);
1542 uint8_t a = UNPACK(*src, 24, 8);
1543
1544
1545
1546
1547 dst[0] = util_format_srgb_8unorm_to_linear_float(r);
1548
1549
1550
1551 dst[1] = util_format_srgb_8unorm_to_linear_float(g);
1552
1553
1554
1555 dst[2] = util_format_srgb_8unorm_to_linear_float(b);
1556
1557
1558 dst[3] = _mesa_unorm_to_float(a, 8);
1559 }
1560
1561 static inline void
unpack_float_r8g8b8x8_srgb(const void * void_src,float dst[4])1562 unpack_float_r8g8b8x8_srgb(const void *void_src, float dst[4])
1563 {
1564 uint32_t *src = (uint32_t *)void_src;
1565 uint8_t r = UNPACK(*src, 0, 8);
1566 uint8_t g = UNPACK(*src, 8, 8);
1567 uint8_t b = UNPACK(*src, 16, 8);
1568
1569
1570
1571
1572 dst[0] = util_format_srgb_8unorm_to_linear_float(r);
1573
1574
1575
1576 dst[1] = util_format_srgb_8unorm_to_linear_float(g);
1577
1578
1579
1580 dst[2] = util_format_srgb_8unorm_to_linear_float(b);
1581
1582 dst[3] = 1.0f;
1583 }
1584
1585 static inline void
unpack_float_x8b8g8r8_srgb(const void * void_src,float dst[4])1586 unpack_float_x8b8g8r8_srgb(const void *void_src, float dst[4])
1587 {
1588 uint32_t *src = (uint32_t *)void_src;
1589 uint8_t b = UNPACK(*src, 8, 8);
1590 uint8_t g = UNPACK(*src, 16, 8);
1591 uint8_t r = UNPACK(*src, 24, 8);
1592
1593
1594
1595
1596 dst[0] = util_format_srgb_8unorm_to_linear_float(r);
1597
1598
1599
1600 dst[1] = util_format_srgb_8unorm_to_linear_float(g);
1601
1602
1603
1604 dst[2] = util_format_srgb_8unorm_to_linear_float(b);
1605
1606 dst[3] = 1.0f;
1607 }
1608
1609 static inline void
unpack_float_r_srgb8(const void * void_src,float dst[4])1610 unpack_float_r_srgb8(const void *void_src, float dst[4])
1611 {
1612 uint8_t *src = (uint8_t *)void_src;
1613 uint8_t r = src[0];
1614
1615
1616
1617
1618 dst[0] = util_format_srgb_8unorm_to_linear_float(r);
1619
1620 dst[1] = 0.0f;
1621
1622 dst[2] = 0.0f;
1623
1624 dst[3] = 1.0f;
1625 }
1626
1627 static inline void
unpack_float_l_srgb8(const void * void_src,float dst[4])1628 unpack_float_l_srgb8(const void *void_src, float dst[4])
1629 {
1630 uint8_t *src = (uint8_t *)void_src;
1631 uint8_t l = src[0];
1632
1633
1634
1635 dst[0] = _mesa_unorm_to_float(l, 8);
1636
1637
1638 dst[1] = _mesa_unorm_to_float(l, 8);
1639
1640
1641 dst[2] = _mesa_unorm_to_float(l, 8);
1642
1643 dst[3] = 1.0f;
1644 }
1645
1646 static inline void
unpack_float_la_srgb8(const void * void_src,float dst[4])1647 unpack_float_la_srgb8(const void *void_src, float dst[4])
1648 {
1649 uint8_t *src = (uint8_t *)void_src;
1650 uint8_t l = src[0];
1651 uint8_t a = src[1];
1652
1653
1654
1655 dst[0] = _mesa_unorm_to_float(l, 8);
1656
1657
1658 dst[1] = _mesa_unorm_to_float(l, 8);
1659
1660
1661 dst[2] = _mesa_unorm_to_float(l, 8);
1662
1663
1664 dst[3] = _mesa_unorm_to_float(a, 8);
1665 }
1666
1667 static inline void
unpack_float_bgr_srgb8(const void * void_src,float dst[4])1668 unpack_float_bgr_srgb8(const void *void_src, float dst[4])
1669 {
1670 uint8_t *src = (uint8_t *)void_src;
1671 uint8_t b = src[0];
1672 uint8_t g = src[1];
1673 uint8_t r = src[2];
1674
1675
1676
1677
1678 dst[0] = util_format_srgb_8unorm_to_linear_float(r);
1679
1680
1681
1682 dst[1] = util_format_srgb_8unorm_to_linear_float(g);
1683
1684
1685
1686 dst[2] = util_format_srgb_8unorm_to_linear_float(b);
1687
1688 dst[3] = 1.0f;
1689 }
1690
1691 static inline void
unpack_float_a_float16(const void * void_src,float dst[4])1692 unpack_float_a_float16(const void *void_src, float dst[4])
1693 {
1694 uint16_t *src = (uint16_t *)void_src;
1695 uint16_t a = src[0];
1696
1697
1698 dst[0] = 0.0f;
1699
1700 dst[1] = 0.0f;
1701
1702 dst[2] = 0.0f;
1703
1704
1705 dst[3] = _mesa_half_to_float(a);
1706 }
1707
1708 static inline void
unpack_float_a_float32(const void * void_src,float dst[4])1709 unpack_float_a_float32(const void *void_src, float dst[4])
1710 {
1711 float *src = (float *)void_src;
1712 float a = src[0];
1713
1714
1715 dst[0] = 0.0f;
1716
1717 dst[1] = 0.0f;
1718
1719 dst[2] = 0.0f;
1720
1721
1722 dst[3] = a;
1723 }
1724
1725 static inline void
unpack_float_l_float16(const void * void_src,float dst[4])1726 unpack_float_l_float16(const void *void_src, float dst[4])
1727 {
1728 uint16_t *src = (uint16_t *)void_src;
1729 uint16_t l = src[0];
1730
1731
1732
1733 dst[0] = _mesa_half_to_float(l);
1734
1735
1736 dst[1] = _mesa_half_to_float(l);
1737
1738
1739 dst[2] = _mesa_half_to_float(l);
1740
1741 dst[3] = 1.0f;
1742 }
1743
1744 static inline void
unpack_float_l_float32(const void * void_src,float dst[4])1745 unpack_float_l_float32(const void *void_src, float dst[4])
1746 {
1747 float *src = (float *)void_src;
1748 float l = src[0];
1749
1750
1751
1752 dst[0] = l;
1753
1754
1755 dst[1] = l;
1756
1757
1758 dst[2] = l;
1759
1760 dst[3] = 1.0f;
1761 }
1762
1763 static inline void
unpack_float_la_float16(const void * void_src,float dst[4])1764 unpack_float_la_float16(const void *void_src, float dst[4])
1765 {
1766 uint16_t *src = (uint16_t *)void_src;
1767 uint16_t l = src[0];
1768 uint16_t a = src[1];
1769
1770
1771
1772 dst[0] = _mesa_half_to_float(l);
1773
1774
1775 dst[1] = _mesa_half_to_float(l);
1776
1777
1778 dst[2] = _mesa_half_to_float(l);
1779
1780
1781 dst[3] = _mesa_half_to_float(a);
1782 }
1783
1784 static inline void
unpack_float_la_float32(const void * void_src,float dst[4])1785 unpack_float_la_float32(const void *void_src, float dst[4])
1786 {
1787 float *src = (float *)void_src;
1788 float l = src[0];
1789 float a = src[1];
1790
1791
1792
1793 dst[0] = l;
1794
1795
1796 dst[1] = l;
1797
1798
1799 dst[2] = l;
1800
1801
1802 dst[3] = a;
1803 }
1804
1805 static inline void
unpack_float_i_float16(const void * void_src,float dst[4])1806 unpack_float_i_float16(const void *void_src, float dst[4])
1807 {
1808 uint16_t *src = (uint16_t *)void_src;
1809 uint16_t i = src[0];
1810
1811
1812
1813 dst[0] = _mesa_half_to_float(i);
1814
1815
1816 dst[1] = _mesa_half_to_float(i);
1817
1818
1819 dst[2] = _mesa_half_to_float(i);
1820
1821
1822 dst[3] = _mesa_half_to_float(i);
1823 }
1824
1825 static inline void
unpack_float_i_float32(const void * void_src,float dst[4])1826 unpack_float_i_float32(const void *void_src, float dst[4])
1827 {
1828 float *src = (float *)void_src;
1829 float i = src[0];
1830
1831
1832
1833 dst[0] = i;
1834
1835
1836 dst[1] = i;
1837
1838
1839 dst[2] = i;
1840
1841
1842 dst[3] = i;
1843 }
1844
1845 static inline void
unpack_float_r_float16(const void * void_src,float dst[4])1846 unpack_float_r_float16(const void *void_src, float dst[4])
1847 {
1848 uint16_t *src = (uint16_t *)void_src;
1849 uint16_t r = src[0];
1850
1851
1852
1853 dst[0] = _mesa_half_to_float(r);
1854
1855 dst[1] = 0.0f;
1856
1857 dst[2] = 0.0f;
1858
1859 dst[3] = 1.0f;
1860 }
1861
1862 static inline void
unpack_float_r_float32(const void * void_src,float dst[4])1863 unpack_float_r_float32(const void *void_src, float dst[4])
1864 {
1865 float *src = (float *)void_src;
1866 float r = src[0];
1867
1868
1869
1870 dst[0] = r;
1871
1872 dst[1] = 0.0f;
1873
1874 dst[2] = 0.0f;
1875
1876 dst[3] = 1.0f;
1877 }
1878
1879 static inline void
unpack_float_rg_float16(const void * void_src,float dst[4])1880 unpack_float_rg_float16(const void *void_src, float dst[4])
1881 {
1882 uint16_t *src = (uint16_t *)void_src;
1883 uint16_t r = src[0];
1884 uint16_t g = src[1];
1885
1886
1887
1888 dst[0] = _mesa_half_to_float(r);
1889
1890
1891 dst[1] = _mesa_half_to_float(g);
1892
1893 dst[2] = 0.0f;
1894
1895 dst[3] = 1.0f;
1896 }
1897
1898 static inline void
unpack_float_rg_float32(const void * void_src,float dst[4])1899 unpack_float_rg_float32(const void *void_src, float dst[4])
1900 {
1901 float *src = (float *)void_src;
1902 float r = src[0];
1903 float g = src[1];
1904
1905
1906
1907 dst[0] = r;
1908
1909
1910 dst[1] = g;
1911
1912 dst[2] = 0.0f;
1913
1914 dst[3] = 1.0f;
1915 }
1916
1917 static inline void
unpack_float_rgb_float16(const void * void_src,float dst[4])1918 unpack_float_rgb_float16(const void *void_src, float dst[4])
1919 {
1920 uint16_t *src = (uint16_t *)void_src;
1921 uint16_t r = src[0];
1922 uint16_t g = src[1];
1923 uint16_t b = src[2];
1924
1925
1926
1927 dst[0] = _mesa_half_to_float(r);
1928
1929
1930 dst[1] = _mesa_half_to_float(g);
1931
1932
1933 dst[2] = _mesa_half_to_float(b);
1934
1935 dst[3] = 1.0f;
1936 }
1937
1938 static inline void
unpack_float_rgb_float32(const void * void_src,float dst[4])1939 unpack_float_rgb_float32(const void *void_src, float dst[4])
1940 {
1941 float *src = (float *)void_src;
1942 float r = src[0];
1943 float g = src[1];
1944 float b = src[2];
1945
1946
1947
1948 dst[0] = r;
1949
1950
1951 dst[1] = g;
1952
1953
1954 dst[2] = b;
1955
1956 dst[3] = 1.0f;
1957 }
1958
1959 static inline void
unpack_float_rgba_float16(const void * void_src,float dst[4])1960 unpack_float_rgba_float16(const void *void_src, float dst[4])
1961 {
1962 uint16_t *src = (uint16_t *)void_src;
1963 uint16_t r = src[0];
1964 uint16_t g = src[1];
1965 uint16_t b = src[2];
1966 uint16_t a = src[3];
1967
1968
1969
1970 dst[0] = _mesa_half_to_float(r);
1971
1972
1973 dst[1] = _mesa_half_to_float(g);
1974
1975
1976 dst[2] = _mesa_half_to_float(b);
1977
1978
1979 dst[3] = _mesa_half_to_float(a);
1980 }
1981
1982 static inline void
unpack_float_rgba_float32(const void * void_src,float dst[4])1983 unpack_float_rgba_float32(const void *void_src, float dst[4])
1984 {
1985 float *src = (float *)void_src;
1986 float r = src[0];
1987 float g = src[1];
1988 float b = src[2];
1989 float a = src[3];
1990
1991
1992
1993 dst[0] = r;
1994
1995
1996 dst[1] = g;
1997
1998
1999 dst[2] = b;
2000
2001
2002 dst[3] = a;
2003 }
2004
2005 static inline void
unpack_float_rgbx_float16(const void * void_src,float dst[4])2006 unpack_float_rgbx_float16(const void *void_src, float dst[4])
2007 {
2008 uint16_t *src = (uint16_t *)void_src;
2009 uint16_t r = src[0];
2010 uint16_t g = src[1];
2011 uint16_t b = src[2];
2012
2013
2014
2015 dst[0] = _mesa_half_to_float(r);
2016
2017
2018 dst[1] = _mesa_half_to_float(g);
2019
2020
2021 dst[2] = _mesa_half_to_float(b);
2022
2023 dst[3] = 1.0f;
2024 }
2025
2026 static inline void
unpack_float_rgbx_float32(const void * void_src,float dst[4])2027 unpack_float_rgbx_float32(const void *void_src, float dst[4])
2028 {
2029 float *src = (float *)void_src;
2030 float r = src[0];
2031 float g = src[1];
2032 float b = src[2];
2033
2034
2035
2036 dst[0] = r;
2037
2038
2039 dst[1] = g;
2040
2041
2042 dst[2] = b;
2043
2044 dst[3] = 1.0f;
2045 }
2046
2047 static void
unpack_float_r9g9b9e5_float(const void * src,float dst[4])2048 unpack_float_r9g9b9e5_float(const void *src, float dst[4])
2049 {
2050 rgb9e5_to_float3(*(const uint32_t *)src, dst);
2051 dst[3] = 1.0f;
2052 }
2053
2054 static void
unpack_float_r11g11b10_float(const void * src,float dst[4])2055 unpack_float_r11g11b10_float(const void *src, float dst[4])
2056 {
2057 r11g11b10f_to_float3(*(const uint32_t *)src, dst);
2058 dst[3] = 1.0f;
2059 }
2060
2061 static void
unpack_float_ycbcr(const void * src,float dst[][4],uint32_t n)2062 unpack_float_ycbcr(const void *src, float dst[][4], uint32_t n)
2063 {
2064 uint32_t i;
2065 for (i = 0; i < n; i++) {
2066 const uint16_t *src0 = ((const uint16_t *) src) + i * 2; /* even */
2067 const uint16_t *src1 = src0 + 1; /* odd */
2068 const uint8_t y0 = (*src0 >> 8) & 0xff; /* luminance */
2069 const uint8_t cb = *src0 & 0xff; /* chroma U */
2070 const uint8_t y1 = (*src1 >> 8) & 0xff; /* luminance */
2071 const uint8_t cr = *src1 & 0xff; /* chroma V */
2072 const uint8_t y = (i & 1) ? y1 : y0; /* choose even/odd luminance */
2073 float r = 1.164F * (y - 16) + 1.596F * (cr - 128);
2074 float g = 1.164F * (y - 16) - 0.813F * (cr - 128) - 0.391F * (cb - 128);
2075 float b = 1.164F * (y - 16) + 2.018F * (cb - 128);
2076 r *= (1.0F / 255.0F);
2077 g *= (1.0F / 255.0F);
2078 b *= (1.0F / 255.0F);
2079 dst[i][0] = CLAMP(r, 0.0F, 1.0F);
2080 dst[i][1] = CLAMP(g, 0.0F, 1.0F);
2081 dst[i][2] = CLAMP(b, 0.0F, 1.0F);
2082 dst[i][3] = 1.0F;
2083 }
2084 }
2085
2086 static void
unpack_float_ycbcr_rev(const void * src,float dst[][4],uint32_t n)2087 unpack_float_ycbcr_rev(const void *src, float dst[][4], uint32_t n)
2088 {
2089 uint32_t i;
2090 for (i = 0; i < n; i++) {
2091 const uint16_t *src0 = ((const uint16_t *) src) + i * 2; /* even */
2092 const uint16_t *src1 = src0 + 1; /* odd */
2093 const uint8_t y0 = *src0 & 0xff; /* luminance */
2094 const uint8_t cr = (*src0 >> 8) & 0xff; /* chroma V */
2095 const uint8_t y1 = *src1 & 0xff; /* luminance */
2096 const uint8_t cb = (*src1 >> 8) & 0xff; /* chroma U */
2097 const uint8_t y = (i & 1) ? y1 : y0; /* choose even/odd luminance */
2098 float r = 1.164F * (y - 16) + 1.596F * (cr - 128);
2099 float g = 1.164F * (y - 16) - 0.813F * (cr - 128) - 0.391F * (cb - 128);
2100 float b = 1.164F * (y - 16) + 2.018F * (cb - 128);
2101 r *= (1.0F / 255.0F);
2102 g *= (1.0F / 255.0F);
2103 b *= (1.0F / 255.0F);
2104 dst[i][0] = CLAMP(r, 0.0F, 1.0F);
2105 dst[i][1] = CLAMP(g, 0.0F, 1.0F);
2106 dst[i][2] = CLAMP(b, 0.0F, 1.0F);
2107 dst[i][3] = 1.0F;
2108 }
2109 }
2110
2111 /* ubyte packing functions */
2112
2113
2114 static inline void
unpack_ubyte_a8b8g8r8_unorm(const void * void_src,uint8_t dst[4])2115 unpack_ubyte_a8b8g8r8_unorm(const void *void_src, uint8_t dst[4])
2116 {
2117 uint32_t *src = (uint32_t *)void_src;
2118 uint8_t a = UNPACK(*src, 0, 8);
2119 uint8_t b = UNPACK(*src, 8, 8);
2120 uint8_t g = UNPACK(*src, 16, 8);
2121 uint8_t r = UNPACK(*src, 24, 8);
2122
2123
2124
2125 dst[0] = _mesa_unorm_to_unorm(r, 8, 8);
2126
2127
2128 dst[1] = _mesa_unorm_to_unorm(g, 8, 8);
2129
2130
2131 dst[2] = _mesa_unorm_to_unorm(b, 8, 8);
2132
2133
2134 dst[3] = _mesa_unorm_to_unorm(a, 8, 8);
2135 }
2136
2137 static inline void
unpack_ubyte_x8b8g8r8_unorm(const void * void_src,uint8_t dst[4])2138 unpack_ubyte_x8b8g8r8_unorm(const void *void_src, uint8_t dst[4])
2139 {
2140 uint32_t *src = (uint32_t *)void_src;
2141 uint8_t b = UNPACK(*src, 8, 8);
2142 uint8_t g = UNPACK(*src, 16, 8);
2143 uint8_t r = UNPACK(*src, 24, 8);
2144
2145
2146
2147 dst[0] = _mesa_unorm_to_unorm(r, 8, 8);
2148
2149
2150 dst[1] = _mesa_unorm_to_unorm(g, 8, 8);
2151
2152
2153 dst[2] = _mesa_unorm_to_unorm(b, 8, 8);
2154
2155 dst[3] = 255;
2156 }
2157
2158 static inline void
unpack_ubyte_r8g8b8a8_unorm(const void * void_src,uint8_t dst[4])2159 unpack_ubyte_r8g8b8a8_unorm(const void *void_src, uint8_t dst[4])
2160 {
2161 uint32_t *src = (uint32_t *)void_src;
2162 uint8_t r = UNPACK(*src, 0, 8);
2163 uint8_t g = UNPACK(*src, 8, 8);
2164 uint8_t b = UNPACK(*src, 16, 8);
2165 uint8_t a = UNPACK(*src, 24, 8);
2166
2167
2168
2169 dst[0] = _mesa_unorm_to_unorm(r, 8, 8);
2170
2171
2172 dst[1] = _mesa_unorm_to_unorm(g, 8, 8);
2173
2174
2175 dst[2] = _mesa_unorm_to_unorm(b, 8, 8);
2176
2177
2178 dst[3] = _mesa_unorm_to_unorm(a, 8, 8);
2179 }
2180
2181 static inline void
unpack_ubyte_r8g8b8x8_unorm(const void * void_src,uint8_t dst[4])2182 unpack_ubyte_r8g8b8x8_unorm(const void *void_src, uint8_t dst[4])
2183 {
2184 uint32_t *src = (uint32_t *)void_src;
2185 uint8_t r = UNPACK(*src, 0, 8);
2186 uint8_t g = UNPACK(*src, 8, 8);
2187 uint8_t b = UNPACK(*src, 16, 8);
2188
2189
2190
2191 dst[0] = _mesa_unorm_to_unorm(r, 8, 8);
2192
2193
2194 dst[1] = _mesa_unorm_to_unorm(g, 8, 8);
2195
2196
2197 dst[2] = _mesa_unorm_to_unorm(b, 8, 8);
2198
2199 dst[3] = 255;
2200 }
2201
2202 static inline void
unpack_ubyte_b8g8r8a8_unorm(const void * void_src,uint8_t dst[4])2203 unpack_ubyte_b8g8r8a8_unorm(const void *void_src, uint8_t dst[4])
2204 {
2205 uint32_t *src = (uint32_t *)void_src;
2206 uint8_t b = UNPACK(*src, 0, 8);
2207 uint8_t g = UNPACK(*src, 8, 8);
2208 uint8_t r = UNPACK(*src, 16, 8);
2209 uint8_t a = UNPACK(*src, 24, 8);
2210
2211
2212
2213 dst[0] = _mesa_unorm_to_unorm(r, 8, 8);
2214
2215
2216 dst[1] = _mesa_unorm_to_unorm(g, 8, 8);
2217
2218
2219 dst[2] = _mesa_unorm_to_unorm(b, 8, 8);
2220
2221
2222 dst[3] = _mesa_unorm_to_unorm(a, 8, 8);
2223 }
2224
2225 static inline void
unpack_ubyte_b8g8r8x8_unorm(const void * void_src,uint8_t dst[4])2226 unpack_ubyte_b8g8r8x8_unorm(const void *void_src, uint8_t dst[4])
2227 {
2228 uint32_t *src = (uint32_t *)void_src;
2229 uint8_t b = UNPACK(*src, 0, 8);
2230 uint8_t g = UNPACK(*src, 8, 8);
2231 uint8_t r = UNPACK(*src, 16, 8);
2232
2233
2234
2235 dst[0] = _mesa_unorm_to_unorm(r, 8, 8);
2236
2237
2238 dst[1] = _mesa_unorm_to_unorm(g, 8, 8);
2239
2240
2241 dst[2] = _mesa_unorm_to_unorm(b, 8, 8);
2242
2243 dst[3] = 255;
2244 }
2245
2246 static inline void
unpack_ubyte_a8r8g8b8_unorm(const void * void_src,uint8_t dst[4])2247 unpack_ubyte_a8r8g8b8_unorm(const void *void_src, uint8_t dst[4])
2248 {
2249 uint32_t *src = (uint32_t *)void_src;
2250 uint8_t a = UNPACK(*src, 0, 8);
2251 uint8_t r = UNPACK(*src, 8, 8);
2252 uint8_t g = UNPACK(*src, 16, 8);
2253 uint8_t b = UNPACK(*src, 24, 8);
2254
2255
2256
2257 dst[0] = _mesa_unorm_to_unorm(r, 8, 8);
2258
2259
2260 dst[1] = _mesa_unorm_to_unorm(g, 8, 8);
2261
2262
2263 dst[2] = _mesa_unorm_to_unorm(b, 8, 8);
2264
2265
2266 dst[3] = _mesa_unorm_to_unorm(a, 8, 8);
2267 }
2268
2269 static inline void
unpack_ubyte_x8r8g8b8_unorm(const void * void_src,uint8_t dst[4])2270 unpack_ubyte_x8r8g8b8_unorm(const void *void_src, uint8_t dst[4])
2271 {
2272 uint32_t *src = (uint32_t *)void_src;
2273 uint8_t r = UNPACK(*src, 8, 8);
2274 uint8_t g = UNPACK(*src, 16, 8);
2275 uint8_t b = UNPACK(*src, 24, 8);
2276
2277
2278
2279 dst[0] = _mesa_unorm_to_unorm(r, 8, 8);
2280
2281
2282 dst[1] = _mesa_unorm_to_unorm(g, 8, 8);
2283
2284
2285 dst[2] = _mesa_unorm_to_unorm(b, 8, 8);
2286
2287 dst[3] = 255;
2288 }
2289
2290 static inline void
unpack_ubyte_b5g6r5_unorm(const void * void_src,uint8_t dst[4])2291 unpack_ubyte_b5g6r5_unorm(const void *void_src, uint8_t dst[4])
2292 {
2293 uint16_t *src = (uint16_t *)void_src;
2294 uint8_t b = UNPACK(*src, 0, 5);
2295 uint8_t g = UNPACK(*src, 5, 6);
2296 uint8_t r = UNPACK(*src, 11, 5);
2297
2298
2299
2300 dst[0] = _mesa_unorm_to_unorm(r, 5, 8);
2301
2302
2303 dst[1] = _mesa_unorm_to_unorm(g, 6, 8);
2304
2305
2306 dst[2] = _mesa_unorm_to_unorm(b, 5, 8);
2307
2308 dst[3] = 255;
2309 }
2310
2311 static inline void
unpack_ubyte_r5g6b5_unorm(const void * void_src,uint8_t dst[4])2312 unpack_ubyte_r5g6b5_unorm(const void *void_src, uint8_t dst[4])
2313 {
2314 uint16_t *src = (uint16_t *)void_src;
2315 uint8_t r = UNPACK(*src, 0, 5);
2316 uint8_t g = UNPACK(*src, 5, 6);
2317 uint8_t b = UNPACK(*src, 11, 5);
2318
2319
2320
2321 dst[0] = _mesa_unorm_to_unorm(r, 5, 8);
2322
2323
2324 dst[1] = _mesa_unorm_to_unorm(g, 6, 8);
2325
2326
2327 dst[2] = _mesa_unorm_to_unorm(b, 5, 8);
2328
2329 dst[3] = 255;
2330 }
2331
2332 static inline void
unpack_ubyte_b4g4r4a4_unorm(const void * void_src,uint8_t dst[4])2333 unpack_ubyte_b4g4r4a4_unorm(const void *void_src, uint8_t dst[4])
2334 {
2335 uint16_t *src = (uint16_t *)void_src;
2336 uint8_t b = UNPACK(*src, 0, 4);
2337 uint8_t g = UNPACK(*src, 4, 4);
2338 uint8_t r = UNPACK(*src, 8, 4);
2339 uint8_t a = UNPACK(*src, 12, 4);
2340
2341
2342
2343 dst[0] = _mesa_unorm_to_unorm(r, 4, 8);
2344
2345
2346 dst[1] = _mesa_unorm_to_unorm(g, 4, 8);
2347
2348
2349 dst[2] = _mesa_unorm_to_unorm(b, 4, 8);
2350
2351
2352 dst[3] = _mesa_unorm_to_unorm(a, 4, 8);
2353 }
2354
2355 static inline void
unpack_ubyte_b4g4r4x4_unorm(const void * void_src,uint8_t dst[4])2356 unpack_ubyte_b4g4r4x4_unorm(const void *void_src, uint8_t dst[4])
2357 {
2358 uint16_t *src = (uint16_t *)void_src;
2359 uint8_t b = UNPACK(*src, 0, 4);
2360 uint8_t g = UNPACK(*src, 4, 4);
2361 uint8_t r = UNPACK(*src, 8, 4);
2362
2363
2364
2365 dst[0] = _mesa_unorm_to_unorm(r, 4, 8);
2366
2367
2368 dst[1] = _mesa_unorm_to_unorm(g, 4, 8);
2369
2370
2371 dst[2] = _mesa_unorm_to_unorm(b, 4, 8);
2372
2373 dst[3] = 255;
2374 }
2375
2376 static inline void
unpack_ubyte_a4r4g4b4_unorm(const void * void_src,uint8_t dst[4])2377 unpack_ubyte_a4r4g4b4_unorm(const void *void_src, uint8_t dst[4])
2378 {
2379 uint16_t *src = (uint16_t *)void_src;
2380 uint8_t a = UNPACK(*src, 0, 4);
2381 uint8_t r = UNPACK(*src, 4, 4);
2382 uint8_t g = UNPACK(*src, 8, 4);
2383 uint8_t b = UNPACK(*src, 12, 4);
2384
2385
2386
2387 dst[0] = _mesa_unorm_to_unorm(r, 4, 8);
2388
2389
2390 dst[1] = _mesa_unorm_to_unorm(g, 4, 8);
2391
2392
2393 dst[2] = _mesa_unorm_to_unorm(b, 4, 8);
2394
2395
2396 dst[3] = _mesa_unorm_to_unorm(a, 4, 8);
2397 }
2398
2399 static inline void
unpack_ubyte_a1b5g5r5_unorm(const void * void_src,uint8_t dst[4])2400 unpack_ubyte_a1b5g5r5_unorm(const void *void_src, uint8_t dst[4])
2401 {
2402 uint16_t *src = (uint16_t *)void_src;
2403 uint8_t a = UNPACK(*src, 0, 1);
2404 uint8_t b = UNPACK(*src, 1, 5);
2405 uint8_t g = UNPACK(*src, 6, 5);
2406 uint8_t r = UNPACK(*src, 11, 5);
2407
2408
2409
2410 dst[0] = _mesa_unorm_to_unorm(r, 5, 8);
2411
2412
2413 dst[1] = _mesa_unorm_to_unorm(g, 5, 8);
2414
2415
2416 dst[2] = _mesa_unorm_to_unorm(b, 5, 8);
2417
2418
2419 dst[3] = _mesa_unorm_to_unorm(a, 1, 8);
2420 }
2421
2422 static inline void
unpack_ubyte_x1b5g5r5_unorm(const void * void_src,uint8_t dst[4])2423 unpack_ubyte_x1b5g5r5_unorm(const void *void_src, uint8_t dst[4])
2424 {
2425 uint16_t *src = (uint16_t *)void_src;
2426 uint8_t b = UNPACK(*src, 1, 5);
2427 uint8_t g = UNPACK(*src, 6, 5);
2428 uint8_t r = UNPACK(*src, 11, 5);
2429
2430
2431
2432 dst[0] = _mesa_unorm_to_unorm(r, 5, 8);
2433
2434
2435 dst[1] = _mesa_unorm_to_unorm(g, 5, 8);
2436
2437
2438 dst[2] = _mesa_unorm_to_unorm(b, 5, 8);
2439
2440 dst[3] = 255;
2441 }
2442
2443 static inline void
unpack_ubyte_b5g5r5a1_unorm(const void * void_src,uint8_t dst[4])2444 unpack_ubyte_b5g5r5a1_unorm(const void *void_src, uint8_t dst[4])
2445 {
2446 uint16_t *src = (uint16_t *)void_src;
2447 uint8_t b = UNPACK(*src, 0, 5);
2448 uint8_t g = UNPACK(*src, 5, 5);
2449 uint8_t r = UNPACK(*src, 10, 5);
2450 uint8_t a = UNPACK(*src, 15, 1);
2451
2452
2453
2454 dst[0] = _mesa_unorm_to_unorm(r, 5, 8);
2455
2456
2457 dst[1] = _mesa_unorm_to_unorm(g, 5, 8);
2458
2459
2460 dst[2] = _mesa_unorm_to_unorm(b, 5, 8);
2461
2462
2463 dst[3] = _mesa_unorm_to_unorm(a, 1, 8);
2464 }
2465
2466 static inline void
unpack_ubyte_b5g5r5x1_unorm(const void * void_src,uint8_t dst[4])2467 unpack_ubyte_b5g5r5x1_unorm(const void *void_src, uint8_t dst[4])
2468 {
2469 uint16_t *src = (uint16_t *)void_src;
2470 uint8_t b = UNPACK(*src, 0, 5);
2471 uint8_t g = UNPACK(*src, 5, 5);
2472 uint8_t r = UNPACK(*src, 10, 5);
2473
2474
2475
2476 dst[0] = _mesa_unorm_to_unorm(r, 5, 8);
2477
2478
2479 dst[1] = _mesa_unorm_to_unorm(g, 5, 8);
2480
2481
2482 dst[2] = _mesa_unorm_to_unorm(b, 5, 8);
2483
2484 dst[3] = 255;
2485 }
2486
2487 static inline void
unpack_ubyte_a1r5g5b5_unorm(const void * void_src,uint8_t dst[4])2488 unpack_ubyte_a1r5g5b5_unorm(const void *void_src, uint8_t dst[4])
2489 {
2490 uint16_t *src = (uint16_t *)void_src;
2491 uint8_t a = UNPACK(*src, 0, 1);
2492 uint8_t r = UNPACK(*src, 1, 5);
2493 uint8_t g = UNPACK(*src, 6, 5);
2494 uint8_t b = UNPACK(*src, 11, 5);
2495
2496
2497
2498 dst[0] = _mesa_unorm_to_unorm(r, 5, 8);
2499
2500
2501 dst[1] = _mesa_unorm_to_unorm(g, 5, 8);
2502
2503
2504 dst[2] = _mesa_unorm_to_unorm(b, 5, 8);
2505
2506
2507 dst[3] = _mesa_unorm_to_unorm(a, 1, 8);
2508 }
2509
2510 static inline void
unpack_ubyte_l4a4_unorm(const void * void_src,uint8_t dst[4])2511 unpack_ubyte_l4a4_unorm(const void *void_src, uint8_t dst[4])
2512 {
2513 uint8_t *src = (uint8_t *)void_src;
2514 uint8_t l = UNPACK(*src, 0, 4);
2515 uint8_t a = UNPACK(*src, 4, 4);
2516
2517
2518
2519 dst[0] = _mesa_unorm_to_unorm(l, 4, 8);
2520
2521
2522 dst[1] = _mesa_unorm_to_unorm(l, 4, 8);
2523
2524
2525 dst[2] = _mesa_unorm_to_unorm(l, 4, 8);
2526
2527
2528 dst[3] = _mesa_unorm_to_unorm(a, 4, 8);
2529 }
2530
2531 static inline void
unpack_ubyte_b2g3r3_unorm(const void * void_src,uint8_t dst[4])2532 unpack_ubyte_b2g3r3_unorm(const void *void_src, uint8_t dst[4])
2533 {
2534 uint8_t *src = (uint8_t *)void_src;
2535 uint8_t b = UNPACK(*src, 0, 2);
2536 uint8_t g = UNPACK(*src, 2, 3);
2537 uint8_t r = UNPACK(*src, 5, 3);
2538
2539
2540
2541 dst[0] = _mesa_unorm_to_unorm(r, 3, 8);
2542
2543
2544 dst[1] = _mesa_unorm_to_unorm(g, 3, 8);
2545
2546
2547 dst[2] = _mesa_unorm_to_unorm(b, 2, 8);
2548
2549 dst[3] = 255;
2550 }
2551
2552 static inline void
unpack_ubyte_b10g10r10a2_unorm(const void * void_src,uint8_t dst[4])2553 unpack_ubyte_b10g10r10a2_unorm(const void *void_src, uint8_t dst[4])
2554 {
2555 uint32_t *src = (uint32_t *)void_src;
2556 uint16_t b = UNPACK(*src, 0, 10);
2557 uint16_t g = UNPACK(*src, 10, 10);
2558 uint16_t r = UNPACK(*src, 20, 10);
2559 uint8_t a = UNPACK(*src, 30, 2);
2560
2561
2562
2563 dst[0] = _mesa_unorm_to_unorm(r, 10, 8);
2564
2565
2566 dst[1] = _mesa_unorm_to_unorm(g, 10, 8);
2567
2568
2569 dst[2] = _mesa_unorm_to_unorm(b, 10, 8);
2570
2571
2572 dst[3] = _mesa_unorm_to_unorm(a, 2, 8);
2573 }
2574
2575 static inline void
unpack_ubyte_b10g10r10x2_unorm(const void * void_src,uint8_t dst[4])2576 unpack_ubyte_b10g10r10x2_unorm(const void *void_src, uint8_t dst[4])
2577 {
2578 uint32_t *src = (uint32_t *)void_src;
2579 uint16_t b = UNPACK(*src, 0, 10);
2580 uint16_t g = UNPACK(*src, 10, 10);
2581 uint16_t r = UNPACK(*src, 20, 10);
2582
2583
2584
2585 dst[0] = _mesa_unorm_to_unorm(r, 10, 8);
2586
2587
2588 dst[1] = _mesa_unorm_to_unorm(g, 10, 8);
2589
2590
2591 dst[2] = _mesa_unorm_to_unorm(b, 10, 8);
2592
2593 dst[3] = 255;
2594 }
2595
2596 static inline void
unpack_ubyte_r10g10b10a2_unorm(const void * void_src,uint8_t dst[4])2597 unpack_ubyte_r10g10b10a2_unorm(const void *void_src, uint8_t dst[4])
2598 {
2599 uint32_t *src = (uint32_t *)void_src;
2600 uint16_t r = UNPACK(*src, 0, 10);
2601 uint16_t g = UNPACK(*src, 10, 10);
2602 uint16_t b = UNPACK(*src, 20, 10);
2603 uint8_t a = UNPACK(*src, 30, 2);
2604
2605
2606
2607 dst[0] = _mesa_unorm_to_unorm(r, 10, 8);
2608
2609
2610 dst[1] = _mesa_unorm_to_unorm(g, 10, 8);
2611
2612
2613 dst[2] = _mesa_unorm_to_unorm(b, 10, 8);
2614
2615
2616 dst[3] = _mesa_unorm_to_unorm(a, 2, 8);
2617 }
2618
2619 static inline void
unpack_ubyte_r10g10b10x2_unorm(const void * void_src,uint8_t dst[4])2620 unpack_ubyte_r10g10b10x2_unorm(const void *void_src, uint8_t dst[4])
2621 {
2622 uint32_t *src = (uint32_t *)void_src;
2623 uint16_t r = UNPACK(*src, 0, 10);
2624 uint16_t g = UNPACK(*src, 10, 10);
2625 uint16_t b = UNPACK(*src, 20, 10);
2626
2627
2628
2629 dst[0] = _mesa_unorm_to_unorm(r, 10, 8);
2630
2631
2632 dst[1] = _mesa_unorm_to_unorm(g, 10, 8);
2633
2634
2635 dst[2] = _mesa_unorm_to_unorm(b, 10, 8);
2636
2637 dst[3] = 255;
2638 }
2639
2640 static inline void
unpack_ubyte_r3g3b2_unorm(const void * void_src,uint8_t dst[4])2641 unpack_ubyte_r3g3b2_unorm(const void *void_src, uint8_t dst[4])
2642 {
2643 uint8_t *src = (uint8_t *)void_src;
2644 uint8_t r = UNPACK(*src, 0, 3);
2645 uint8_t g = UNPACK(*src, 3, 3);
2646 uint8_t b = UNPACK(*src, 6, 2);
2647
2648
2649
2650 dst[0] = _mesa_unorm_to_unorm(r, 3, 8);
2651
2652
2653 dst[1] = _mesa_unorm_to_unorm(g, 3, 8);
2654
2655
2656 dst[2] = _mesa_unorm_to_unorm(b, 2, 8);
2657
2658 dst[3] = 255;
2659 }
2660
2661 static inline void
unpack_ubyte_a4b4g4r4_unorm(const void * void_src,uint8_t dst[4])2662 unpack_ubyte_a4b4g4r4_unorm(const void *void_src, uint8_t dst[4])
2663 {
2664 uint16_t *src = (uint16_t *)void_src;
2665 uint8_t a = UNPACK(*src, 0, 4);
2666 uint8_t b = UNPACK(*src, 4, 4);
2667 uint8_t g = UNPACK(*src, 8, 4);
2668 uint8_t r = UNPACK(*src, 12, 4);
2669
2670
2671
2672 dst[0] = _mesa_unorm_to_unorm(r, 4, 8);
2673
2674
2675 dst[1] = _mesa_unorm_to_unorm(g, 4, 8);
2676
2677
2678 dst[2] = _mesa_unorm_to_unorm(b, 4, 8);
2679
2680
2681 dst[3] = _mesa_unorm_to_unorm(a, 4, 8);
2682 }
2683
2684 static inline void
unpack_ubyte_r4g4b4a4_unorm(const void * void_src,uint8_t dst[4])2685 unpack_ubyte_r4g4b4a4_unorm(const void *void_src, uint8_t dst[4])
2686 {
2687 uint16_t *src = (uint16_t *)void_src;
2688 uint8_t r = UNPACK(*src, 0, 4);
2689 uint8_t g = UNPACK(*src, 4, 4);
2690 uint8_t b = UNPACK(*src, 8, 4);
2691 uint8_t a = UNPACK(*src, 12, 4);
2692
2693
2694
2695 dst[0] = _mesa_unorm_to_unorm(r, 4, 8);
2696
2697
2698 dst[1] = _mesa_unorm_to_unorm(g, 4, 8);
2699
2700
2701 dst[2] = _mesa_unorm_to_unorm(b, 4, 8);
2702
2703
2704 dst[3] = _mesa_unorm_to_unorm(a, 4, 8);
2705 }
2706
2707 static inline void
unpack_ubyte_r5g5b5a1_unorm(const void * void_src,uint8_t dst[4])2708 unpack_ubyte_r5g5b5a1_unorm(const void *void_src, uint8_t dst[4])
2709 {
2710 uint16_t *src = (uint16_t *)void_src;
2711 uint8_t r = UNPACK(*src, 0, 5);
2712 uint8_t g = UNPACK(*src, 5, 5);
2713 uint8_t b = UNPACK(*src, 10, 5);
2714 uint8_t a = UNPACK(*src, 15, 1);
2715
2716
2717
2718 dst[0] = _mesa_unorm_to_unorm(r, 5, 8);
2719
2720
2721 dst[1] = _mesa_unorm_to_unorm(g, 5, 8);
2722
2723
2724 dst[2] = _mesa_unorm_to_unorm(b, 5, 8);
2725
2726
2727 dst[3] = _mesa_unorm_to_unorm(a, 1, 8);
2728 }
2729
2730 static inline void
unpack_ubyte_a2b10g10r10_unorm(const void * void_src,uint8_t dst[4])2731 unpack_ubyte_a2b10g10r10_unorm(const void *void_src, uint8_t dst[4])
2732 {
2733 uint32_t *src = (uint32_t *)void_src;
2734 uint8_t a = UNPACK(*src, 0, 2);
2735 uint16_t b = UNPACK(*src, 2, 10);
2736 uint16_t g = UNPACK(*src, 12, 10);
2737 uint16_t r = UNPACK(*src, 22, 10);
2738
2739
2740
2741 dst[0] = _mesa_unorm_to_unorm(r, 10, 8);
2742
2743
2744 dst[1] = _mesa_unorm_to_unorm(g, 10, 8);
2745
2746
2747 dst[2] = _mesa_unorm_to_unorm(b, 10, 8);
2748
2749
2750 dst[3] = _mesa_unorm_to_unorm(a, 2, 8);
2751 }
2752
2753 static inline void
unpack_ubyte_a2r10g10b10_unorm(const void * void_src,uint8_t dst[4])2754 unpack_ubyte_a2r10g10b10_unorm(const void *void_src, uint8_t dst[4])
2755 {
2756 uint32_t *src = (uint32_t *)void_src;
2757 uint8_t a = UNPACK(*src, 0, 2);
2758 uint16_t r = UNPACK(*src, 2, 10);
2759 uint16_t g = UNPACK(*src, 12, 10);
2760 uint16_t b = UNPACK(*src, 22, 10);
2761
2762
2763
2764 dst[0] = _mesa_unorm_to_unorm(r, 10, 8);
2765
2766
2767 dst[1] = _mesa_unorm_to_unorm(g, 10, 8);
2768
2769
2770 dst[2] = _mesa_unorm_to_unorm(b, 10, 8);
2771
2772
2773 dst[3] = _mesa_unorm_to_unorm(a, 2, 8);
2774 }
2775
2776 static inline void
unpack_ubyte_a_unorm8(const void * void_src,uint8_t dst[4])2777 unpack_ubyte_a_unorm8(const void *void_src, uint8_t dst[4])
2778 {
2779 uint8_t *src = (uint8_t *)void_src;
2780 uint8_t a = src[0];
2781
2782
2783 dst[0] = 0;
2784
2785 dst[1] = 0;
2786
2787 dst[2] = 0;
2788
2789
2790 dst[3] = _mesa_unorm_to_unorm(a, 8, 8);
2791 }
2792
2793 static inline void
unpack_ubyte_a_unorm16(const void * void_src,uint8_t dst[4])2794 unpack_ubyte_a_unorm16(const void *void_src, uint8_t dst[4])
2795 {
2796 uint16_t *src = (uint16_t *)void_src;
2797 uint16_t a = src[0];
2798
2799
2800 dst[0] = 0;
2801
2802 dst[1] = 0;
2803
2804 dst[2] = 0;
2805
2806
2807 dst[3] = _mesa_unorm_to_unorm(a, 16, 8);
2808 }
2809
2810 static inline void
unpack_ubyte_l_unorm8(const void * void_src,uint8_t dst[4])2811 unpack_ubyte_l_unorm8(const void *void_src, uint8_t dst[4])
2812 {
2813 uint8_t *src = (uint8_t *)void_src;
2814 uint8_t l = src[0];
2815
2816
2817
2818 dst[0] = _mesa_unorm_to_unorm(l, 8, 8);
2819
2820
2821 dst[1] = _mesa_unorm_to_unorm(l, 8, 8);
2822
2823
2824 dst[2] = _mesa_unorm_to_unorm(l, 8, 8);
2825
2826 dst[3] = 255;
2827 }
2828
2829 static inline void
unpack_ubyte_l_unorm16(const void * void_src,uint8_t dst[4])2830 unpack_ubyte_l_unorm16(const void *void_src, uint8_t dst[4])
2831 {
2832 uint16_t *src = (uint16_t *)void_src;
2833 uint16_t l = src[0];
2834
2835
2836
2837 dst[0] = _mesa_unorm_to_unorm(l, 16, 8);
2838
2839
2840 dst[1] = _mesa_unorm_to_unorm(l, 16, 8);
2841
2842
2843 dst[2] = _mesa_unorm_to_unorm(l, 16, 8);
2844
2845 dst[3] = 255;
2846 }
2847
2848 static inline void
unpack_ubyte_la_unorm8(const void * void_src,uint8_t dst[4])2849 unpack_ubyte_la_unorm8(const void *void_src, uint8_t dst[4])
2850 {
2851 uint8_t *src = (uint8_t *)void_src;
2852 uint8_t l = src[0];
2853 uint8_t a = src[1];
2854
2855
2856
2857 dst[0] = _mesa_unorm_to_unorm(l, 8, 8);
2858
2859
2860 dst[1] = _mesa_unorm_to_unorm(l, 8, 8);
2861
2862
2863 dst[2] = _mesa_unorm_to_unorm(l, 8, 8);
2864
2865
2866 dst[3] = _mesa_unorm_to_unorm(a, 8, 8);
2867 }
2868
2869 static inline void
unpack_ubyte_la_unorm16(const void * void_src,uint8_t dst[4])2870 unpack_ubyte_la_unorm16(const void *void_src, uint8_t dst[4])
2871 {
2872 uint16_t *src = (uint16_t *)void_src;
2873 uint16_t l = src[0];
2874 uint16_t a = src[1];
2875
2876
2877
2878 dst[0] = _mesa_unorm_to_unorm(l, 16, 8);
2879
2880
2881 dst[1] = _mesa_unorm_to_unorm(l, 16, 8);
2882
2883
2884 dst[2] = _mesa_unorm_to_unorm(l, 16, 8);
2885
2886
2887 dst[3] = _mesa_unorm_to_unorm(a, 16, 8);
2888 }
2889
2890 static inline void
unpack_ubyte_i_unorm8(const void * void_src,uint8_t dst[4])2891 unpack_ubyte_i_unorm8(const void *void_src, uint8_t dst[4])
2892 {
2893 uint8_t *src = (uint8_t *)void_src;
2894 uint8_t i = src[0];
2895
2896
2897
2898 dst[0] = _mesa_unorm_to_unorm(i, 8, 8);
2899
2900
2901 dst[1] = _mesa_unorm_to_unorm(i, 8, 8);
2902
2903
2904 dst[2] = _mesa_unorm_to_unorm(i, 8, 8);
2905
2906
2907 dst[3] = _mesa_unorm_to_unorm(i, 8, 8);
2908 }
2909
2910 static inline void
unpack_ubyte_i_unorm16(const void * void_src,uint8_t dst[4])2911 unpack_ubyte_i_unorm16(const void *void_src, uint8_t dst[4])
2912 {
2913 uint16_t *src = (uint16_t *)void_src;
2914 uint16_t i = src[0];
2915
2916
2917
2918 dst[0] = _mesa_unorm_to_unorm(i, 16, 8);
2919
2920
2921 dst[1] = _mesa_unorm_to_unorm(i, 16, 8);
2922
2923
2924 dst[2] = _mesa_unorm_to_unorm(i, 16, 8);
2925
2926
2927 dst[3] = _mesa_unorm_to_unorm(i, 16, 8);
2928 }
2929
2930 static inline void
unpack_ubyte_r_unorm8(const void * void_src,uint8_t dst[4])2931 unpack_ubyte_r_unorm8(const void *void_src, uint8_t dst[4])
2932 {
2933 uint8_t *src = (uint8_t *)void_src;
2934 uint8_t r = src[0];
2935
2936
2937
2938 dst[0] = _mesa_unorm_to_unorm(r, 8, 8);
2939
2940 dst[1] = 0;
2941
2942 dst[2] = 0;
2943
2944 dst[3] = 255;
2945 }
2946
2947 static inline void
unpack_ubyte_r_unorm16(const void * void_src,uint8_t dst[4])2948 unpack_ubyte_r_unorm16(const void *void_src, uint8_t dst[4])
2949 {
2950 uint16_t *src = (uint16_t *)void_src;
2951 uint16_t r = src[0];
2952
2953
2954
2955 dst[0] = _mesa_unorm_to_unorm(r, 16, 8);
2956
2957 dst[1] = 0;
2958
2959 dst[2] = 0;
2960
2961 dst[3] = 255;
2962 }
2963
2964 static inline void
unpack_ubyte_rg_unorm8(const void * void_src,uint8_t dst[4])2965 unpack_ubyte_rg_unorm8(const void *void_src, uint8_t dst[4])
2966 {
2967 uint8_t *src = (uint8_t *)void_src;
2968 uint8_t r = src[0];
2969 uint8_t g = src[1];
2970
2971
2972
2973 dst[0] = _mesa_unorm_to_unorm(r, 8, 8);
2974
2975
2976 dst[1] = _mesa_unorm_to_unorm(g, 8, 8);
2977
2978 dst[2] = 0;
2979
2980 dst[3] = 255;
2981 }
2982
2983 static inline void
unpack_ubyte_rg_unorm16(const void * void_src,uint8_t dst[4])2984 unpack_ubyte_rg_unorm16(const void *void_src, uint8_t dst[4])
2985 {
2986 uint16_t *src = (uint16_t *)void_src;
2987 uint16_t r = src[0];
2988 uint16_t g = src[1];
2989
2990
2991
2992 dst[0] = _mesa_unorm_to_unorm(r, 16, 8);
2993
2994
2995 dst[1] = _mesa_unorm_to_unorm(g, 16, 8);
2996
2997 dst[2] = 0;
2998
2999 dst[3] = 255;
3000 }
3001
3002 static inline void
unpack_ubyte_bgr_unorm8(const void * void_src,uint8_t dst[4])3003 unpack_ubyte_bgr_unorm8(const void *void_src, uint8_t dst[4])
3004 {
3005 uint8_t *src = (uint8_t *)void_src;
3006 uint8_t b = src[0];
3007 uint8_t g = src[1];
3008 uint8_t r = src[2];
3009
3010
3011
3012 dst[0] = _mesa_unorm_to_unorm(r, 8, 8);
3013
3014
3015 dst[1] = _mesa_unorm_to_unorm(g, 8, 8);
3016
3017
3018 dst[2] = _mesa_unorm_to_unorm(b, 8, 8);
3019
3020 dst[3] = 255;
3021 }
3022
3023 static inline void
unpack_ubyte_rgb_unorm8(const void * void_src,uint8_t dst[4])3024 unpack_ubyte_rgb_unorm8(const void *void_src, uint8_t dst[4])
3025 {
3026 uint8_t *src = (uint8_t *)void_src;
3027 uint8_t r = src[0];
3028 uint8_t g = src[1];
3029 uint8_t b = src[2];
3030
3031
3032
3033 dst[0] = _mesa_unorm_to_unorm(r, 8, 8);
3034
3035
3036 dst[1] = _mesa_unorm_to_unorm(g, 8, 8);
3037
3038
3039 dst[2] = _mesa_unorm_to_unorm(b, 8, 8);
3040
3041 dst[3] = 255;
3042 }
3043
3044 static inline void
unpack_ubyte_rgba_unorm16(const void * void_src,uint8_t dst[4])3045 unpack_ubyte_rgba_unorm16(const void *void_src, uint8_t dst[4])
3046 {
3047 uint16_t *src = (uint16_t *)void_src;
3048 uint16_t r = src[0];
3049 uint16_t g = src[1];
3050 uint16_t b = src[2];
3051 uint16_t a = src[3];
3052
3053
3054
3055 dst[0] = _mesa_unorm_to_unorm(r, 16, 8);
3056
3057
3058 dst[1] = _mesa_unorm_to_unorm(g, 16, 8);
3059
3060
3061 dst[2] = _mesa_unorm_to_unorm(b, 16, 8);
3062
3063
3064 dst[3] = _mesa_unorm_to_unorm(a, 16, 8);
3065 }
3066
3067 static inline void
unpack_ubyte_rgbx_unorm16(const void * void_src,uint8_t dst[4])3068 unpack_ubyte_rgbx_unorm16(const void *void_src, uint8_t dst[4])
3069 {
3070 uint16_t *src = (uint16_t *)void_src;
3071 uint16_t r = src[0];
3072 uint16_t g = src[1];
3073 uint16_t b = src[2];
3074
3075
3076
3077 dst[0] = _mesa_unorm_to_unorm(r, 16, 8);
3078
3079
3080 dst[1] = _mesa_unorm_to_unorm(g, 16, 8);
3081
3082
3083 dst[2] = _mesa_unorm_to_unorm(b, 16, 8);
3084
3085 dst[3] = 255;
3086 }
3087
3088 static inline void
unpack_ubyte_a8b8g8r8_snorm(const void * void_src,uint8_t dst[4])3089 unpack_ubyte_a8b8g8r8_snorm(const void *void_src, uint8_t dst[4])
3090 {
3091 uint32_t *src = (uint32_t *)void_src;
3092 int8_t a = UNPACK(*src, 0, 8);
3093 int8_t b = UNPACK(*src, 8, 8);
3094 int8_t g = UNPACK(*src, 16, 8);
3095 int8_t r = UNPACK(*src, 24, 8);
3096
3097
3098
3099 dst[0] = _mesa_snorm_to_unorm(r, 8, 8);
3100
3101
3102 dst[1] = _mesa_snorm_to_unorm(g, 8, 8);
3103
3104
3105 dst[2] = _mesa_snorm_to_unorm(b, 8, 8);
3106
3107
3108 dst[3] = _mesa_snorm_to_unorm(a, 8, 8);
3109 }
3110
3111 static inline void
unpack_ubyte_x8b8g8r8_snorm(const void * void_src,uint8_t dst[4])3112 unpack_ubyte_x8b8g8r8_snorm(const void *void_src, uint8_t dst[4])
3113 {
3114 uint32_t *src = (uint32_t *)void_src;
3115 int8_t b = UNPACK(*src, 8, 8);
3116 int8_t g = UNPACK(*src, 16, 8);
3117 int8_t r = UNPACK(*src, 24, 8);
3118
3119
3120
3121 dst[0] = _mesa_snorm_to_unorm(r, 8, 8);
3122
3123
3124 dst[1] = _mesa_snorm_to_unorm(g, 8, 8);
3125
3126
3127 dst[2] = _mesa_snorm_to_unorm(b, 8, 8);
3128
3129 dst[3] = 255;
3130 }
3131
3132 static inline void
unpack_ubyte_r8g8b8a8_snorm(const void * void_src,uint8_t dst[4])3133 unpack_ubyte_r8g8b8a8_snorm(const void *void_src, uint8_t dst[4])
3134 {
3135 uint32_t *src = (uint32_t *)void_src;
3136 int8_t r = UNPACK(*src, 0, 8);
3137 int8_t g = UNPACK(*src, 8, 8);
3138 int8_t b = UNPACK(*src, 16, 8);
3139 int8_t a = UNPACK(*src, 24, 8);
3140
3141
3142
3143 dst[0] = _mesa_snorm_to_unorm(r, 8, 8);
3144
3145
3146 dst[1] = _mesa_snorm_to_unorm(g, 8, 8);
3147
3148
3149 dst[2] = _mesa_snorm_to_unorm(b, 8, 8);
3150
3151
3152 dst[3] = _mesa_snorm_to_unorm(a, 8, 8);
3153 }
3154
3155 static inline void
unpack_ubyte_r8g8b8x8_snorm(const void * void_src,uint8_t dst[4])3156 unpack_ubyte_r8g8b8x8_snorm(const void *void_src, uint8_t dst[4])
3157 {
3158 uint32_t *src = (uint32_t *)void_src;
3159 int8_t r = UNPACK(*src, 0, 8);
3160 int8_t g = UNPACK(*src, 8, 8);
3161 int8_t b = UNPACK(*src, 16, 8);
3162
3163
3164
3165 dst[0] = _mesa_snorm_to_unorm(r, 8, 8);
3166
3167
3168 dst[1] = _mesa_snorm_to_unorm(g, 8, 8);
3169
3170
3171 dst[2] = _mesa_snorm_to_unorm(b, 8, 8);
3172
3173 dst[3] = 255;
3174 }
3175
3176 static inline void
unpack_ubyte_a_snorm8(const void * void_src,uint8_t dst[4])3177 unpack_ubyte_a_snorm8(const void *void_src, uint8_t dst[4])
3178 {
3179 int8_t *src = (int8_t *)void_src;
3180 int8_t a = src[0];
3181
3182
3183 dst[0] = 0;
3184
3185 dst[1] = 0;
3186
3187 dst[2] = 0;
3188
3189
3190 dst[3] = _mesa_snorm_to_unorm(a, 8, 8);
3191 }
3192
3193 static inline void
unpack_ubyte_a_snorm16(const void * void_src,uint8_t dst[4])3194 unpack_ubyte_a_snorm16(const void *void_src, uint8_t dst[4])
3195 {
3196 int16_t *src = (int16_t *)void_src;
3197 int16_t a = src[0];
3198
3199
3200 dst[0] = 0;
3201
3202 dst[1] = 0;
3203
3204 dst[2] = 0;
3205
3206
3207 dst[3] = _mesa_snorm_to_unorm(a, 16, 8);
3208 }
3209
3210 static inline void
unpack_ubyte_l_snorm8(const void * void_src,uint8_t dst[4])3211 unpack_ubyte_l_snorm8(const void *void_src, uint8_t dst[4])
3212 {
3213 int8_t *src = (int8_t *)void_src;
3214 int8_t l = src[0];
3215
3216
3217
3218 dst[0] = _mesa_snorm_to_unorm(l, 8, 8);
3219
3220
3221 dst[1] = _mesa_snorm_to_unorm(l, 8, 8);
3222
3223
3224 dst[2] = _mesa_snorm_to_unorm(l, 8, 8);
3225
3226 dst[3] = 255;
3227 }
3228
3229 static inline void
unpack_ubyte_l_snorm16(const void * void_src,uint8_t dst[4])3230 unpack_ubyte_l_snorm16(const void *void_src, uint8_t dst[4])
3231 {
3232 int16_t *src = (int16_t *)void_src;
3233 int16_t l = src[0];
3234
3235
3236
3237 dst[0] = _mesa_snorm_to_unorm(l, 16, 8);
3238
3239
3240 dst[1] = _mesa_snorm_to_unorm(l, 16, 8);
3241
3242
3243 dst[2] = _mesa_snorm_to_unorm(l, 16, 8);
3244
3245 dst[3] = 255;
3246 }
3247
3248 static inline void
unpack_ubyte_i_snorm8(const void * void_src,uint8_t dst[4])3249 unpack_ubyte_i_snorm8(const void *void_src, uint8_t dst[4])
3250 {
3251 int8_t *src = (int8_t *)void_src;
3252 int8_t i = src[0];
3253
3254
3255
3256 dst[0] = _mesa_snorm_to_unorm(i, 8, 8);
3257
3258
3259 dst[1] = _mesa_snorm_to_unorm(i, 8, 8);
3260
3261
3262 dst[2] = _mesa_snorm_to_unorm(i, 8, 8);
3263
3264
3265 dst[3] = _mesa_snorm_to_unorm(i, 8, 8);
3266 }
3267
3268 static inline void
unpack_ubyte_i_snorm16(const void * void_src,uint8_t dst[4])3269 unpack_ubyte_i_snorm16(const void *void_src, uint8_t dst[4])
3270 {
3271 int16_t *src = (int16_t *)void_src;
3272 int16_t i = src[0];
3273
3274
3275
3276 dst[0] = _mesa_snorm_to_unorm(i, 16, 8);
3277
3278
3279 dst[1] = _mesa_snorm_to_unorm(i, 16, 8);
3280
3281
3282 dst[2] = _mesa_snorm_to_unorm(i, 16, 8);
3283
3284
3285 dst[3] = _mesa_snorm_to_unorm(i, 16, 8);
3286 }
3287
3288 static inline void
unpack_ubyte_r_snorm8(const void * void_src,uint8_t dst[4])3289 unpack_ubyte_r_snorm8(const void *void_src, uint8_t dst[4])
3290 {
3291 int8_t *src = (int8_t *)void_src;
3292 int8_t r = src[0];
3293
3294
3295
3296 dst[0] = _mesa_snorm_to_unorm(r, 8, 8);
3297
3298 dst[1] = 0;
3299
3300 dst[2] = 0;
3301
3302 dst[3] = 255;
3303 }
3304
3305 static inline void
unpack_ubyte_r_snorm16(const void * void_src,uint8_t dst[4])3306 unpack_ubyte_r_snorm16(const void *void_src, uint8_t dst[4])
3307 {
3308 int16_t *src = (int16_t *)void_src;
3309 int16_t r = src[0];
3310
3311
3312
3313 dst[0] = _mesa_snorm_to_unorm(r, 16, 8);
3314
3315 dst[1] = 0;
3316
3317 dst[2] = 0;
3318
3319 dst[3] = 255;
3320 }
3321
3322 static inline void
unpack_ubyte_la_snorm8(const void * void_src,uint8_t dst[4])3323 unpack_ubyte_la_snorm8(const void *void_src, uint8_t dst[4])
3324 {
3325 int8_t *src = (int8_t *)void_src;
3326 int8_t l = src[0];
3327 int8_t a = src[1];
3328
3329
3330
3331 dst[0] = _mesa_snorm_to_unorm(l, 8, 8);
3332
3333
3334 dst[1] = _mesa_snorm_to_unorm(l, 8, 8);
3335
3336
3337 dst[2] = _mesa_snorm_to_unorm(l, 8, 8);
3338
3339
3340 dst[3] = _mesa_snorm_to_unorm(a, 8, 8);
3341 }
3342
3343 static inline void
unpack_ubyte_la_snorm16(const void * void_src,uint8_t dst[4])3344 unpack_ubyte_la_snorm16(const void *void_src, uint8_t dst[4])
3345 {
3346 int16_t *src = (int16_t *)void_src;
3347 int16_t l = src[0];
3348 int16_t a = src[1];
3349
3350
3351
3352 dst[0] = _mesa_snorm_to_unorm(l, 16, 8);
3353
3354
3355 dst[1] = _mesa_snorm_to_unorm(l, 16, 8);
3356
3357
3358 dst[2] = _mesa_snorm_to_unorm(l, 16, 8);
3359
3360
3361 dst[3] = _mesa_snorm_to_unorm(a, 16, 8);
3362 }
3363
3364 static inline void
unpack_ubyte_rg_snorm8(const void * void_src,uint8_t dst[4])3365 unpack_ubyte_rg_snorm8(const void *void_src, uint8_t dst[4])
3366 {
3367 int8_t *src = (int8_t *)void_src;
3368 int8_t r = src[0];
3369 int8_t g = src[1];
3370
3371
3372
3373 dst[0] = _mesa_snorm_to_unorm(r, 8, 8);
3374
3375
3376 dst[1] = _mesa_snorm_to_unorm(g, 8, 8);
3377
3378 dst[2] = 0;
3379
3380 dst[3] = 255;
3381 }
3382
3383 static inline void
unpack_ubyte_rg_snorm16(const void * void_src,uint8_t dst[4])3384 unpack_ubyte_rg_snorm16(const void *void_src, uint8_t dst[4])
3385 {
3386 int16_t *src = (int16_t *)void_src;
3387 int16_t r = src[0];
3388 int16_t g = src[1];
3389
3390
3391
3392 dst[0] = _mesa_snorm_to_unorm(r, 16, 8);
3393
3394
3395 dst[1] = _mesa_snorm_to_unorm(g, 16, 8);
3396
3397 dst[2] = 0;
3398
3399 dst[3] = 255;
3400 }
3401
3402 static inline void
unpack_ubyte_rgb_snorm16(const void * void_src,uint8_t dst[4])3403 unpack_ubyte_rgb_snorm16(const void *void_src, uint8_t dst[4])
3404 {
3405 int16_t *src = (int16_t *)void_src;
3406 int16_t r = src[0];
3407 int16_t g = src[1];
3408 int16_t b = src[2];
3409
3410
3411
3412 dst[0] = _mesa_snorm_to_unorm(r, 16, 8);
3413
3414
3415 dst[1] = _mesa_snorm_to_unorm(g, 16, 8);
3416
3417
3418 dst[2] = _mesa_snorm_to_unorm(b, 16, 8);
3419
3420 dst[3] = 255;
3421 }
3422
3423 static inline void
unpack_ubyte_rgba_snorm16(const void * void_src,uint8_t dst[4])3424 unpack_ubyte_rgba_snorm16(const void *void_src, uint8_t dst[4])
3425 {
3426 int16_t *src = (int16_t *)void_src;
3427 int16_t r = src[0];
3428 int16_t g = src[1];
3429 int16_t b = src[2];
3430 int16_t a = src[3];
3431
3432
3433
3434 dst[0] = _mesa_snorm_to_unorm(r, 16, 8);
3435
3436
3437 dst[1] = _mesa_snorm_to_unorm(g, 16, 8);
3438
3439
3440 dst[2] = _mesa_snorm_to_unorm(b, 16, 8);
3441
3442
3443 dst[3] = _mesa_snorm_to_unorm(a, 16, 8);
3444 }
3445
3446 static inline void
unpack_ubyte_rgbx_snorm16(const void * void_src,uint8_t dst[4])3447 unpack_ubyte_rgbx_snorm16(const void *void_src, uint8_t dst[4])
3448 {
3449 int16_t *src = (int16_t *)void_src;
3450 int16_t r = src[0];
3451 int16_t g = src[1];
3452 int16_t b = src[2];
3453
3454
3455
3456 dst[0] = _mesa_snorm_to_unorm(r, 16, 8);
3457
3458
3459 dst[1] = _mesa_snorm_to_unorm(g, 16, 8);
3460
3461
3462 dst[2] = _mesa_snorm_to_unorm(b, 16, 8);
3463
3464 dst[3] = 255;
3465 }
3466
3467 static inline void
unpack_ubyte_a8b8g8r8_srgb(const void * void_src,uint8_t dst[4])3468 unpack_ubyte_a8b8g8r8_srgb(const void *void_src, uint8_t dst[4])
3469 {
3470 uint32_t *src = (uint32_t *)void_src;
3471 uint8_t a = UNPACK(*src, 0, 8);
3472 uint8_t b = UNPACK(*src, 8, 8);
3473 uint8_t g = UNPACK(*src, 16, 8);
3474 uint8_t r = UNPACK(*src, 24, 8);
3475
3476
3477
3478
3479 dst[0] = util_format_srgb_to_linear_8unorm(r);
3480
3481
3482
3483 dst[1] = util_format_srgb_to_linear_8unorm(g);
3484
3485
3486
3487 dst[2] = util_format_srgb_to_linear_8unorm(b);
3488
3489
3490 dst[3] = _mesa_unorm_to_unorm(a, 8, 8);
3491 }
3492
3493 static inline void
unpack_ubyte_b8g8r8a8_srgb(const void * void_src,uint8_t dst[4])3494 unpack_ubyte_b8g8r8a8_srgb(const void *void_src, uint8_t dst[4])
3495 {
3496 uint32_t *src = (uint32_t *)void_src;
3497 uint8_t b = UNPACK(*src, 0, 8);
3498 uint8_t g = UNPACK(*src, 8, 8);
3499 uint8_t r = UNPACK(*src, 16, 8);
3500 uint8_t a = UNPACK(*src, 24, 8);
3501
3502
3503
3504
3505 dst[0] = util_format_srgb_to_linear_8unorm(r);
3506
3507
3508
3509 dst[1] = util_format_srgb_to_linear_8unorm(g);
3510
3511
3512
3513 dst[2] = util_format_srgb_to_linear_8unorm(b);
3514
3515
3516 dst[3] = _mesa_unorm_to_unorm(a, 8, 8);
3517 }
3518
3519 static inline void
unpack_ubyte_a8r8g8b8_srgb(const void * void_src,uint8_t dst[4])3520 unpack_ubyte_a8r8g8b8_srgb(const void *void_src, uint8_t dst[4])
3521 {
3522 uint32_t *src = (uint32_t *)void_src;
3523 uint8_t a = UNPACK(*src, 0, 8);
3524 uint8_t r = UNPACK(*src, 8, 8);
3525 uint8_t g = UNPACK(*src, 16, 8);
3526 uint8_t b = UNPACK(*src, 24, 8);
3527
3528
3529
3530
3531 dst[0] = util_format_srgb_to_linear_8unorm(r);
3532
3533
3534
3535 dst[1] = util_format_srgb_to_linear_8unorm(g);
3536
3537
3538
3539 dst[2] = util_format_srgb_to_linear_8unorm(b);
3540
3541
3542 dst[3] = _mesa_unorm_to_unorm(a, 8, 8);
3543 }
3544
3545 static inline void
unpack_ubyte_b8g8r8x8_srgb(const void * void_src,uint8_t dst[4])3546 unpack_ubyte_b8g8r8x8_srgb(const void *void_src, uint8_t dst[4])
3547 {
3548 uint32_t *src = (uint32_t *)void_src;
3549 uint8_t b = UNPACK(*src, 0, 8);
3550 uint8_t g = UNPACK(*src, 8, 8);
3551 uint8_t r = UNPACK(*src, 16, 8);
3552
3553
3554
3555
3556 dst[0] = util_format_srgb_to_linear_8unorm(r);
3557
3558
3559
3560 dst[1] = util_format_srgb_to_linear_8unorm(g);
3561
3562
3563
3564 dst[2] = util_format_srgb_to_linear_8unorm(b);
3565
3566 dst[3] = 255;
3567 }
3568
3569 static inline void
unpack_ubyte_x8r8g8b8_srgb(const void * void_src,uint8_t dst[4])3570 unpack_ubyte_x8r8g8b8_srgb(const void *void_src, uint8_t dst[4])
3571 {
3572 uint32_t *src = (uint32_t *)void_src;
3573 uint8_t r = UNPACK(*src, 8, 8);
3574 uint8_t g = UNPACK(*src, 16, 8);
3575 uint8_t b = UNPACK(*src, 24, 8);
3576
3577
3578
3579
3580 dst[0] = util_format_srgb_to_linear_8unorm(r);
3581
3582
3583
3584 dst[1] = util_format_srgb_to_linear_8unorm(g);
3585
3586
3587
3588 dst[2] = util_format_srgb_to_linear_8unorm(b);
3589
3590 dst[3] = 255;
3591 }
3592
3593 static inline void
unpack_ubyte_r8g8b8a8_srgb(const void * void_src,uint8_t dst[4])3594 unpack_ubyte_r8g8b8a8_srgb(const void *void_src, uint8_t dst[4])
3595 {
3596 uint32_t *src = (uint32_t *)void_src;
3597 uint8_t r = UNPACK(*src, 0, 8);
3598 uint8_t g = UNPACK(*src, 8, 8);
3599 uint8_t b = UNPACK(*src, 16, 8);
3600 uint8_t a = UNPACK(*src, 24, 8);
3601
3602
3603
3604
3605 dst[0] = util_format_srgb_to_linear_8unorm(r);
3606
3607
3608
3609 dst[1] = util_format_srgb_to_linear_8unorm(g);
3610
3611
3612
3613 dst[2] = util_format_srgb_to_linear_8unorm(b);
3614
3615
3616 dst[3] = _mesa_unorm_to_unorm(a, 8, 8);
3617 }
3618
3619 static inline void
unpack_ubyte_r8g8b8x8_srgb(const void * void_src,uint8_t dst[4])3620 unpack_ubyte_r8g8b8x8_srgb(const void *void_src, uint8_t dst[4])
3621 {
3622 uint32_t *src = (uint32_t *)void_src;
3623 uint8_t r = UNPACK(*src, 0, 8);
3624 uint8_t g = UNPACK(*src, 8, 8);
3625 uint8_t b = UNPACK(*src, 16, 8);
3626
3627
3628
3629
3630 dst[0] = util_format_srgb_to_linear_8unorm(r);
3631
3632
3633
3634 dst[1] = util_format_srgb_to_linear_8unorm(g);
3635
3636
3637
3638 dst[2] = util_format_srgb_to_linear_8unorm(b);
3639
3640 dst[3] = 255;
3641 }
3642
3643 static inline void
unpack_ubyte_x8b8g8r8_srgb(const void * void_src,uint8_t dst[4])3644 unpack_ubyte_x8b8g8r8_srgb(const void *void_src, uint8_t dst[4])
3645 {
3646 uint32_t *src = (uint32_t *)void_src;
3647 uint8_t b = UNPACK(*src, 8, 8);
3648 uint8_t g = UNPACK(*src, 16, 8);
3649 uint8_t r = UNPACK(*src, 24, 8);
3650
3651
3652
3653
3654 dst[0] = util_format_srgb_to_linear_8unorm(r);
3655
3656
3657
3658 dst[1] = util_format_srgb_to_linear_8unorm(g);
3659
3660
3661
3662 dst[2] = util_format_srgb_to_linear_8unorm(b);
3663
3664 dst[3] = 255;
3665 }
3666
3667 static inline void
unpack_ubyte_r_srgb8(const void * void_src,uint8_t dst[4])3668 unpack_ubyte_r_srgb8(const void *void_src, uint8_t dst[4])
3669 {
3670 uint8_t *src = (uint8_t *)void_src;
3671 uint8_t r = src[0];
3672
3673
3674
3675
3676 dst[0] = util_format_srgb_to_linear_8unorm(r);
3677
3678 dst[1] = 0;
3679
3680 dst[2] = 0;
3681
3682 dst[3] = 255;
3683 }
3684
3685 static inline void
unpack_ubyte_l_srgb8(const void * void_src,uint8_t dst[4])3686 unpack_ubyte_l_srgb8(const void *void_src, uint8_t dst[4])
3687 {
3688 uint8_t *src = (uint8_t *)void_src;
3689 uint8_t l = src[0];
3690
3691
3692
3693 dst[0] = _mesa_unorm_to_unorm(l, 8, 8);
3694
3695
3696 dst[1] = _mesa_unorm_to_unorm(l, 8, 8);
3697
3698
3699 dst[2] = _mesa_unorm_to_unorm(l, 8, 8);
3700
3701 dst[3] = 255;
3702 }
3703
3704 static inline void
unpack_ubyte_la_srgb8(const void * void_src,uint8_t dst[4])3705 unpack_ubyte_la_srgb8(const void *void_src, uint8_t dst[4])
3706 {
3707 uint8_t *src = (uint8_t *)void_src;
3708 uint8_t l = src[0];
3709 uint8_t a = src[1];
3710
3711
3712
3713 dst[0] = _mesa_unorm_to_unorm(l, 8, 8);
3714
3715
3716 dst[1] = _mesa_unorm_to_unorm(l, 8, 8);
3717
3718
3719 dst[2] = _mesa_unorm_to_unorm(l, 8, 8);
3720
3721
3722 dst[3] = _mesa_unorm_to_unorm(a, 8, 8);
3723 }
3724
3725 static inline void
unpack_ubyte_bgr_srgb8(const void * void_src,uint8_t dst[4])3726 unpack_ubyte_bgr_srgb8(const void *void_src, uint8_t dst[4])
3727 {
3728 uint8_t *src = (uint8_t *)void_src;
3729 uint8_t b = src[0];
3730 uint8_t g = src[1];
3731 uint8_t r = src[2];
3732
3733
3734
3735
3736 dst[0] = util_format_srgb_to_linear_8unorm(r);
3737
3738
3739
3740 dst[1] = util_format_srgb_to_linear_8unorm(g);
3741
3742
3743
3744 dst[2] = util_format_srgb_to_linear_8unorm(b);
3745
3746 dst[3] = 255;
3747 }
3748
3749 /* integer packing functions */
3750
3751
3752 static inline void
unpack_int_a8b8g8r8_uint(const void * void_src,uint32_t dst[4])3753 unpack_int_a8b8g8r8_uint(const void *void_src, uint32_t dst[4])
3754 {
3755 uint32_t *src = (uint32_t *)void_src;
3756 uint8_t a = UNPACK(*src, 0, 8);
3757 uint8_t b = UNPACK(*src, 8, 8);
3758 uint8_t g = UNPACK(*src, 16, 8);
3759 uint8_t r = UNPACK(*src, 24, 8);
3760
3761
3762 dst[0] = r;
3763
3764 dst[1] = g;
3765
3766 dst[2] = b;
3767
3768 dst[3] = a;
3769 }
3770
3771 static inline void
unpack_int_a8r8g8b8_uint(const void * void_src,uint32_t dst[4])3772 unpack_int_a8r8g8b8_uint(const void *void_src, uint32_t dst[4])
3773 {
3774 uint32_t *src = (uint32_t *)void_src;
3775 uint8_t a = UNPACK(*src, 0, 8);
3776 uint8_t r = UNPACK(*src, 8, 8);
3777 uint8_t g = UNPACK(*src, 16, 8);
3778 uint8_t b = UNPACK(*src, 24, 8);
3779
3780
3781 dst[0] = r;
3782
3783 dst[1] = g;
3784
3785 dst[2] = b;
3786
3787 dst[3] = a;
3788 }
3789
3790 static inline void
unpack_int_r8g8b8a8_uint(const void * void_src,uint32_t dst[4])3791 unpack_int_r8g8b8a8_uint(const void *void_src, uint32_t dst[4])
3792 {
3793 uint32_t *src = (uint32_t *)void_src;
3794 uint8_t r = UNPACK(*src, 0, 8);
3795 uint8_t g = UNPACK(*src, 8, 8);
3796 uint8_t b = UNPACK(*src, 16, 8);
3797 uint8_t a = UNPACK(*src, 24, 8);
3798
3799
3800 dst[0] = r;
3801
3802 dst[1] = g;
3803
3804 dst[2] = b;
3805
3806 dst[3] = a;
3807 }
3808
3809 static inline void
unpack_int_b8g8r8a8_uint(const void * void_src,uint32_t dst[4])3810 unpack_int_b8g8r8a8_uint(const void *void_src, uint32_t dst[4])
3811 {
3812 uint32_t *src = (uint32_t *)void_src;
3813 uint8_t b = UNPACK(*src, 0, 8);
3814 uint8_t g = UNPACK(*src, 8, 8);
3815 uint8_t r = UNPACK(*src, 16, 8);
3816 uint8_t a = UNPACK(*src, 24, 8);
3817
3818
3819 dst[0] = r;
3820
3821 dst[1] = g;
3822
3823 dst[2] = b;
3824
3825 dst[3] = a;
3826 }
3827
3828 static inline void
unpack_int_b10g10r10a2_uint(const void * void_src,uint32_t dst[4])3829 unpack_int_b10g10r10a2_uint(const void *void_src, uint32_t dst[4])
3830 {
3831 uint32_t *src = (uint32_t *)void_src;
3832 uint16_t b = UNPACK(*src, 0, 10);
3833 uint16_t g = UNPACK(*src, 10, 10);
3834 uint16_t r = UNPACK(*src, 20, 10);
3835 uint8_t a = UNPACK(*src, 30, 2);
3836
3837
3838 dst[0] = r;
3839
3840 dst[1] = g;
3841
3842 dst[2] = b;
3843
3844 dst[3] = a;
3845 }
3846
3847 static inline void
unpack_int_r10g10b10a2_uint(const void * void_src,uint32_t dst[4])3848 unpack_int_r10g10b10a2_uint(const void *void_src, uint32_t dst[4])
3849 {
3850 uint32_t *src = (uint32_t *)void_src;
3851 uint16_t r = UNPACK(*src, 0, 10);
3852 uint16_t g = UNPACK(*src, 10, 10);
3853 uint16_t b = UNPACK(*src, 20, 10);
3854 uint8_t a = UNPACK(*src, 30, 2);
3855
3856
3857 dst[0] = r;
3858
3859 dst[1] = g;
3860
3861 dst[2] = b;
3862
3863 dst[3] = a;
3864 }
3865
3866 static inline void
unpack_int_a2b10g10r10_uint(const void * void_src,uint32_t dst[4])3867 unpack_int_a2b10g10r10_uint(const void *void_src, uint32_t dst[4])
3868 {
3869 uint32_t *src = (uint32_t *)void_src;
3870 uint8_t a = UNPACK(*src, 0, 2);
3871 uint16_t b = UNPACK(*src, 2, 10);
3872 uint16_t g = UNPACK(*src, 12, 10);
3873 uint16_t r = UNPACK(*src, 22, 10);
3874
3875
3876 dst[0] = r;
3877
3878 dst[1] = g;
3879
3880 dst[2] = b;
3881
3882 dst[3] = a;
3883 }
3884
3885 static inline void
unpack_int_a2r10g10b10_uint(const void * void_src,uint32_t dst[4])3886 unpack_int_a2r10g10b10_uint(const void *void_src, uint32_t dst[4])
3887 {
3888 uint32_t *src = (uint32_t *)void_src;
3889 uint8_t a = UNPACK(*src, 0, 2);
3890 uint16_t r = UNPACK(*src, 2, 10);
3891 uint16_t g = UNPACK(*src, 12, 10);
3892 uint16_t b = UNPACK(*src, 22, 10);
3893
3894
3895 dst[0] = r;
3896
3897 dst[1] = g;
3898
3899 dst[2] = b;
3900
3901 dst[3] = a;
3902 }
3903
3904 static inline void
unpack_int_b5g6r5_uint(const void * void_src,uint32_t dst[4])3905 unpack_int_b5g6r5_uint(const void *void_src, uint32_t dst[4])
3906 {
3907 uint16_t *src = (uint16_t *)void_src;
3908 uint8_t b = UNPACK(*src, 0, 5);
3909 uint8_t g = UNPACK(*src, 5, 6);
3910 uint8_t r = UNPACK(*src, 11, 5);
3911
3912
3913 dst[0] = r;
3914
3915 dst[1] = g;
3916
3917 dst[2] = b;
3918
3919 dst[3] = 1;
3920 }
3921
3922 static inline void
unpack_int_r5g6b5_uint(const void * void_src,uint32_t dst[4])3923 unpack_int_r5g6b5_uint(const void *void_src, uint32_t dst[4])
3924 {
3925 uint16_t *src = (uint16_t *)void_src;
3926 uint8_t r = UNPACK(*src, 0, 5);
3927 uint8_t g = UNPACK(*src, 5, 6);
3928 uint8_t b = UNPACK(*src, 11, 5);
3929
3930
3931 dst[0] = r;
3932
3933 dst[1] = g;
3934
3935 dst[2] = b;
3936
3937 dst[3] = 1;
3938 }
3939
3940 static inline void
unpack_int_b2g3r3_uint(const void * void_src,uint32_t dst[4])3941 unpack_int_b2g3r3_uint(const void *void_src, uint32_t dst[4])
3942 {
3943 uint8_t *src = (uint8_t *)void_src;
3944 uint8_t b = UNPACK(*src, 0, 2);
3945 uint8_t g = UNPACK(*src, 2, 3);
3946 uint8_t r = UNPACK(*src, 5, 3);
3947
3948
3949 dst[0] = r;
3950
3951 dst[1] = g;
3952
3953 dst[2] = b;
3954
3955 dst[3] = 1;
3956 }
3957
3958 static inline void
unpack_int_r3g3b2_uint(const void * void_src,uint32_t dst[4])3959 unpack_int_r3g3b2_uint(const void *void_src, uint32_t dst[4])
3960 {
3961 uint8_t *src = (uint8_t *)void_src;
3962 uint8_t r = UNPACK(*src, 0, 3);
3963 uint8_t g = UNPACK(*src, 3, 3);
3964 uint8_t b = UNPACK(*src, 6, 2);
3965
3966
3967 dst[0] = r;
3968
3969 dst[1] = g;
3970
3971 dst[2] = b;
3972
3973 dst[3] = 1;
3974 }
3975
3976 static inline void
unpack_int_a4b4g4r4_uint(const void * void_src,uint32_t dst[4])3977 unpack_int_a4b4g4r4_uint(const void *void_src, uint32_t dst[4])
3978 {
3979 uint16_t *src = (uint16_t *)void_src;
3980 uint8_t a = UNPACK(*src, 0, 4);
3981 uint8_t b = UNPACK(*src, 4, 4);
3982 uint8_t g = UNPACK(*src, 8, 4);
3983 uint8_t r = UNPACK(*src, 12, 4);
3984
3985
3986 dst[0] = r;
3987
3988 dst[1] = g;
3989
3990 dst[2] = b;
3991
3992 dst[3] = a;
3993 }
3994
3995 static inline void
unpack_int_r4g4b4a4_uint(const void * void_src,uint32_t dst[4])3996 unpack_int_r4g4b4a4_uint(const void *void_src, uint32_t dst[4])
3997 {
3998 uint16_t *src = (uint16_t *)void_src;
3999 uint8_t r = UNPACK(*src, 0, 4);
4000 uint8_t g = UNPACK(*src, 4, 4);
4001 uint8_t b = UNPACK(*src, 8, 4);
4002 uint8_t a = UNPACK(*src, 12, 4);
4003
4004
4005 dst[0] = r;
4006
4007 dst[1] = g;
4008
4009 dst[2] = b;
4010
4011 dst[3] = a;
4012 }
4013
4014 static inline void
unpack_int_b4g4r4a4_uint(const void * void_src,uint32_t dst[4])4015 unpack_int_b4g4r4a4_uint(const void *void_src, uint32_t dst[4])
4016 {
4017 uint16_t *src = (uint16_t *)void_src;
4018 uint8_t b = UNPACK(*src, 0, 4);
4019 uint8_t g = UNPACK(*src, 4, 4);
4020 uint8_t r = UNPACK(*src, 8, 4);
4021 uint8_t a = UNPACK(*src, 12, 4);
4022
4023
4024 dst[0] = r;
4025
4026 dst[1] = g;
4027
4028 dst[2] = b;
4029
4030 dst[3] = a;
4031 }
4032
4033 static inline void
unpack_int_a4r4g4b4_uint(const void * void_src,uint32_t dst[4])4034 unpack_int_a4r4g4b4_uint(const void *void_src, uint32_t dst[4])
4035 {
4036 uint16_t *src = (uint16_t *)void_src;
4037 uint8_t a = UNPACK(*src, 0, 4);
4038 uint8_t r = UNPACK(*src, 4, 4);
4039 uint8_t g = UNPACK(*src, 8, 4);
4040 uint8_t b = UNPACK(*src, 12, 4);
4041
4042
4043 dst[0] = r;
4044
4045 dst[1] = g;
4046
4047 dst[2] = b;
4048
4049 dst[3] = a;
4050 }
4051
4052 static inline void
unpack_int_a1b5g5r5_uint(const void * void_src,uint32_t dst[4])4053 unpack_int_a1b5g5r5_uint(const void *void_src, uint32_t dst[4])
4054 {
4055 uint16_t *src = (uint16_t *)void_src;
4056 uint8_t a = UNPACK(*src, 0, 1);
4057 uint8_t b = UNPACK(*src, 1, 5);
4058 uint8_t g = UNPACK(*src, 6, 5);
4059 uint8_t r = UNPACK(*src, 11, 5);
4060
4061
4062 dst[0] = r;
4063
4064 dst[1] = g;
4065
4066 dst[2] = b;
4067
4068 dst[3] = a;
4069 }
4070
4071 static inline void
unpack_int_b5g5r5a1_uint(const void * void_src,uint32_t dst[4])4072 unpack_int_b5g5r5a1_uint(const void *void_src, uint32_t dst[4])
4073 {
4074 uint16_t *src = (uint16_t *)void_src;
4075 uint8_t b = UNPACK(*src, 0, 5);
4076 uint8_t g = UNPACK(*src, 5, 5);
4077 uint8_t r = UNPACK(*src, 10, 5);
4078 uint8_t a = UNPACK(*src, 15, 1);
4079
4080
4081 dst[0] = r;
4082
4083 dst[1] = g;
4084
4085 dst[2] = b;
4086
4087 dst[3] = a;
4088 }
4089
4090 static inline void
unpack_int_a1r5g5b5_uint(const void * void_src,uint32_t dst[4])4091 unpack_int_a1r5g5b5_uint(const void *void_src, uint32_t dst[4])
4092 {
4093 uint16_t *src = (uint16_t *)void_src;
4094 uint8_t a = UNPACK(*src, 0, 1);
4095 uint8_t r = UNPACK(*src, 1, 5);
4096 uint8_t g = UNPACK(*src, 6, 5);
4097 uint8_t b = UNPACK(*src, 11, 5);
4098
4099
4100 dst[0] = r;
4101
4102 dst[1] = g;
4103
4104 dst[2] = b;
4105
4106 dst[3] = a;
4107 }
4108
4109 static inline void
unpack_int_r5g5b5a1_uint(const void * void_src,uint32_t dst[4])4110 unpack_int_r5g5b5a1_uint(const void *void_src, uint32_t dst[4])
4111 {
4112 uint16_t *src = (uint16_t *)void_src;
4113 uint8_t r = UNPACK(*src, 0, 5);
4114 uint8_t g = UNPACK(*src, 5, 5);
4115 uint8_t b = UNPACK(*src, 10, 5);
4116 uint8_t a = UNPACK(*src, 15, 1);
4117
4118
4119 dst[0] = r;
4120
4121 dst[1] = g;
4122
4123 dst[2] = b;
4124
4125 dst[3] = a;
4126 }
4127
4128 static inline void
unpack_int_a_uint8(const void * void_src,uint32_t dst[4])4129 unpack_int_a_uint8(const void *void_src, uint32_t dst[4])
4130 {
4131 uint8_t *src = (uint8_t *)void_src;
4132 uint8_t a = src[0];
4133
4134
4135 dst[0] = 0;
4136
4137 dst[1] = 0;
4138
4139 dst[2] = 0;
4140
4141 dst[3] = a;
4142 }
4143
4144 static inline void
unpack_int_a_uint16(const void * void_src,uint32_t dst[4])4145 unpack_int_a_uint16(const void *void_src, uint32_t dst[4])
4146 {
4147 uint16_t *src = (uint16_t *)void_src;
4148 uint16_t a = src[0];
4149
4150
4151 dst[0] = 0;
4152
4153 dst[1] = 0;
4154
4155 dst[2] = 0;
4156
4157 dst[3] = a;
4158 }
4159
4160 static inline void
unpack_int_a_uint32(const void * void_src,uint32_t dst[4])4161 unpack_int_a_uint32(const void *void_src, uint32_t dst[4])
4162 {
4163 uint32_t *src = (uint32_t *)void_src;
4164 uint32_t a = src[0];
4165
4166
4167 dst[0] = 0;
4168
4169 dst[1] = 0;
4170
4171 dst[2] = 0;
4172
4173 dst[3] = a;
4174 }
4175
4176 static inline void
unpack_int_a_sint8(const void * void_src,uint32_t dst[4])4177 unpack_int_a_sint8(const void *void_src, uint32_t dst[4])
4178 {
4179 int8_t *src = (int8_t *)void_src;
4180 int8_t a = src[0];
4181
4182
4183 dst[0] = 0;
4184
4185 dst[1] = 0;
4186
4187 dst[2] = 0;
4188
4189 dst[3] = a;
4190 }
4191
4192 static inline void
unpack_int_a_sint16(const void * void_src,uint32_t dst[4])4193 unpack_int_a_sint16(const void *void_src, uint32_t dst[4])
4194 {
4195 int16_t *src = (int16_t *)void_src;
4196 int16_t a = src[0];
4197
4198
4199 dst[0] = 0;
4200
4201 dst[1] = 0;
4202
4203 dst[2] = 0;
4204
4205 dst[3] = a;
4206 }
4207
4208 static inline void
unpack_int_a_sint32(const void * void_src,uint32_t dst[4])4209 unpack_int_a_sint32(const void *void_src, uint32_t dst[4])
4210 {
4211 int32_t *src = (int32_t *)void_src;
4212 int32_t a = src[0];
4213
4214
4215 dst[0] = 0;
4216
4217 dst[1] = 0;
4218
4219 dst[2] = 0;
4220
4221 dst[3] = a;
4222 }
4223
4224 static inline void
unpack_int_i_uint8(const void * void_src,uint32_t dst[4])4225 unpack_int_i_uint8(const void *void_src, uint32_t dst[4])
4226 {
4227 uint8_t *src = (uint8_t *)void_src;
4228 uint8_t i = src[0];
4229
4230
4231 dst[0] = i;
4232
4233 dst[1] = i;
4234
4235 dst[2] = i;
4236
4237 dst[3] = i;
4238 }
4239
4240 static inline void
unpack_int_i_uint16(const void * void_src,uint32_t dst[4])4241 unpack_int_i_uint16(const void *void_src, uint32_t dst[4])
4242 {
4243 uint16_t *src = (uint16_t *)void_src;
4244 uint16_t i = src[0];
4245
4246
4247 dst[0] = i;
4248
4249 dst[1] = i;
4250
4251 dst[2] = i;
4252
4253 dst[3] = i;
4254 }
4255
4256 static inline void
unpack_int_i_uint32(const void * void_src,uint32_t dst[4])4257 unpack_int_i_uint32(const void *void_src, uint32_t dst[4])
4258 {
4259 uint32_t *src = (uint32_t *)void_src;
4260 uint32_t i = src[0];
4261
4262
4263 dst[0] = i;
4264
4265 dst[1] = i;
4266
4267 dst[2] = i;
4268
4269 dst[3] = i;
4270 }
4271
4272 static inline void
unpack_int_i_sint8(const void * void_src,uint32_t dst[4])4273 unpack_int_i_sint8(const void *void_src, uint32_t dst[4])
4274 {
4275 int8_t *src = (int8_t *)void_src;
4276 int8_t i = src[0];
4277
4278
4279 dst[0] = i;
4280
4281 dst[1] = i;
4282
4283 dst[2] = i;
4284
4285 dst[3] = i;
4286 }
4287
4288 static inline void
unpack_int_i_sint16(const void * void_src,uint32_t dst[4])4289 unpack_int_i_sint16(const void *void_src, uint32_t dst[4])
4290 {
4291 int16_t *src = (int16_t *)void_src;
4292 int16_t i = src[0];
4293
4294
4295 dst[0] = i;
4296
4297 dst[1] = i;
4298
4299 dst[2] = i;
4300
4301 dst[3] = i;
4302 }
4303
4304 static inline void
unpack_int_i_sint32(const void * void_src,uint32_t dst[4])4305 unpack_int_i_sint32(const void *void_src, uint32_t dst[4])
4306 {
4307 int32_t *src = (int32_t *)void_src;
4308 int32_t i = src[0];
4309
4310
4311 dst[0] = i;
4312
4313 dst[1] = i;
4314
4315 dst[2] = i;
4316
4317 dst[3] = i;
4318 }
4319
4320 static inline void
unpack_int_l_uint8(const void * void_src,uint32_t dst[4])4321 unpack_int_l_uint8(const void *void_src, uint32_t dst[4])
4322 {
4323 uint8_t *src = (uint8_t *)void_src;
4324 uint8_t l = src[0];
4325
4326
4327 dst[0] = l;
4328
4329 dst[1] = l;
4330
4331 dst[2] = l;
4332
4333 dst[3] = 1;
4334 }
4335
4336 static inline void
unpack_int_l_uint16(const void * void_src,uint32_t dst[4])4337 unpack_int_l_uint16(const void *void_src, uint32_t dst[4])
4338 {
4339 uint16_t *src = (uint16_t *)void_src;
4340 uint16_t l = src[0];
4341
4342
4343 dst[0] = l;
4344
4345 dst[1] = l;
4346
4347 dst[2] = l;
4348
4349 dst[3] = 1;
4350 }
4351
4352 static inline void
unpack_int_l_uint32(const void * void_src,uint32_t dst[4])4353 unpack_int_l_uint32(const void *void_src, uint32_t dst[4])
4354 {
4355 uint32_t *src = (uint32_t *)void_src;
4356 uint32_t l = src[0];
4357
4358
4359 dst[0] = l;
4360
4361 dst[1] = l;
4362
4363 dst[2] = l;
4364
4365 dst[3] = 1;
4366 }
4367
4368 static inline void
unpack_int_l_sint8(const void * void_src,uint32_t dst[4])4369 unpack_int_l_sint8(const void *void_src, uint32_t dst[4])
4370 {
4371 int8_t *src = (int8_t *)void_src;
4372 int8_t l = src[0];
4373
4374
4375 dst[0] = l;
4376
4377 dst[1] = l;
4378
4379 dst[2] = l;
4380
4381 dst[3] = 1;
4382 }
4383
4384 static inline void
unpack_int_l_sint16(const void * void_src,uint32_t dst[4])4385 unpack_int_l_sint16(const void *void_src, uint32_t dst[4])
4386 {
4387 int16_t *src = (int16_t *)void_src;
4388 int16_t l = src[0];
4389
4390
4391 dst[0] = l;
4392
4393 dst[1] = l;
4394
4395 dst[2] = l;
4396
4397 dst[3] = 1;
4398 }
4399
4400 static inline void
unpack_int_l_sint32(const void * void_src,uint32_t dst[4])4401 unpack_int_l_sint32(const void *void_src, uint32_t dst[4])
4402 {
4403 int32_t *src = (int32_t *)void_src;
4404 int32_t l = src[0];
4405
4406
4407 dst[0] = l;
4408
4409 dst[1] = l;
4410
4411 dst[2] = l;
4412
4413 dst[3] = 1;
4414 }
4415
4416 static inline void
unpack_int_la_uint8(const void * void_src,uint32_t dst[4])4417 unpack_int_la_uint8(const void *void_src, uint32_t dst[4])
4418 {
4419 uint8_t *src = (uint8_t *)void_src;
4420 uint8_t l = src[0];
4421 uint8_t a = src[1];
4422
4423
4424 dst[0] = l;
4425
4426 dst[1] = l;
4427
4428 dst[2] = l;
4429
4430 dst[3] = a;
4431 }
4432
4433 static inline void
unpack_int_la_uint16(const void * void_src,uint32_t dst[4])4434 unpack_int_la_uint16(const void *void_src, uint32_t dst[4])
4435 {
4436 uint16_t *src = (uint16_t *)void_src;
4437 uint16_t l = src[0];
4438 uint16_t a = src[1];
4439
4440
4441 dst[0] = l;
4442
4443 dst[1] = l;
4444
4445 dst[2] = l;
4446
4447 dst[3] = a;
4448 }
4449
4450 static inline void
unpack_int_la_uint32(const void * void_src,uint32_t dst[4])4451 unpack_int_la_uint32(const void *void_src, uint32_t dst[4])
4452 {
4453 uint32_t *src = (uint32_t *)void_src;
4454 uint32_t l = src[0];
4455 uint32_t a = src[1];
4456
4457
4458 dst[0] = l;
4459
4460 dst[1] = l;
4461
4462 dst[2] = l;
4463
4464 dst[3] = a;
4465 }
4466
4467 static inline void
unpack_int_la_sint8(const void * void_src,uint32_t dst[4])4468 unpack_int_la_sint8(const void *void_src, uint32_t dst[4])
4469 {
4470 int8_t *src = (int8_t *)void_src;
4471 int8_t l = src[0];
4472 int8_t a = src[1];
4473
4474
4475 dst[0] = l;
4476
4477 dst[1] = l;
4478
4479 dst[2] = l;
4480
4481 dst[3] = a;
4482 }
4483
4484 static inline void
unpack_int_la_sint16(const void * void_src,uint32_t dst[4])4485 unpack_int_la_sint16(const void *void_src, uint32_t dst[4])
4486 {
4487 int16_t *src = (int16_t *)void_src;
4488 int16_t l = src[0];
4489 int16_t a = src[1];
4490
4491
4492 dst[0] = l;
4493
4494 dst[1] = l;
4495
4496 dst[2] = l;
4497
4498 dst[3] = a;
4499 }
4500
4501 static inline void
unpack_int_la_sint32(const void * void_src,uint32_t dst[4])4502 unpack_int_la_sint32(const void *void_src, uint32_t dst[4])
4503 {
4504 int32_t *src = (int32_t *)void_src;
4505 int32_t l = src[0];
4506 int32_t a = src[1];
4507
4508
4509 dst[0] = l;
4510
4511 dst[1] = l;
4512
4513 dst[2] = l;
4514
4515 dst[3] = a;
4516 }
4517
4518 static inline void
unpack_int_r_uint8(const void * void_src,uint32_t dst[4])4519 unpack_int_r_uint8(const void *void_src, uint32_t dst[4])
4520 {
4521 uint8_t *src = (uint8_t *)void_src;
4522 uint8_t r = src[0];
4523
4524
4525 dst[0] = r;
4526
4527 dst[1] = 0;
4528
4529 dst[2] = 0;
4530
4531 dst[3] = 1;
4532 }
4533
4534 static inline void
unpack_int_r_uint16(const void * void_src,uint32_t dst[4])4535 unpack_int_r_uint16(const void *void_src, uint32_t dst[4])
4536 {
4537 uint16_t *src = (uint16_t *)void_src;
4538 uint16_t r = src[0];
4539
4540
4541 dst[0] = r;
4542
4543 dst[1] = 0;
4544
4545 dst[2] = 0;
4546
4547 dst[3] = 1;
4548 }
4549
4550 static inline void
unpack_int_r_uint32(const void * void_src,uint32_t dst[4])4551 unpack_int_r_uint32(const void *void_src, uint32_t dst[4])
4552 {
4553 uint32_t *src = (uint32_t *)void_src;
4554 uint32_t r = src[0];
4555
4556
4557 dst[0] = r;
4558
4559 dst[1] = 0;
4560
4561 dst[2] = 0;
4562
4563 dst[3] = 1;
4564 }
4565
4566 static inline void
unpack_int_r_sint8(const void * void_src,uint32_t dst[4])4567 unpack_int_r_sint8(const void *void_src, uint32_t dst[4])
4568 {
4569 int8_t *src = (int8_t *)void_src;
4570 int8_t r = src[0];
4571
4572
4573 dst[0] = r;
4574
4575 dst[1] = 0;
4576
4577 dst[2] = 0;
4578
4579 dst[3] = 1;
4580 }
4581
4582 static inline void
unpack_int_r_sint16(const void * void_src,uint32_t dst[4])4583 unpack_int_r_sint16(const void *void_src, uint32_t dst[4])
4584 {
4585 int16_t *src = (int16_t *)void_src;
4586 int16_t r = src[0];
4587
4588
4589 dst[0] = r;
4590
4591 dst[1] = 0;
4592
4593 dst[2] = 0;
4594
4595 dst[3] = 1;
4596 }
4597
4598 static inline void
unpack_int_r_sint32(const void * void_src,uint32_t dst[4])4599 unpack_int_r_sint32(const void *void_src, uint32_t dst[4])
4600 {
4601 int32_t *src = (int32_t *)void_src;
4602 int32_t r = src[0];
4603
4604
4605 dst[0] = r;
4606
4607 dst[1] = 0;
4608
4609 dst[2] = 0;
4610
4611 dst[3] = 1;
4612 }
4613
4614 static inline void
unpack_int_rg_uint8(const void * void_src,uint32_t dst[4])4615 unpack_int_rg_uint8(const void *void_src, uint32_t dst[4])
4616 {
4617 uint8_t *src = (uint8_t *)void_src;
4618 uint8_t r = src[0];
4619 uint8_t g = src[1];
4620
4621
4622 dst[0] = r;
4623
4624 dst[1] = g;
4625
4626 dst[2] = 0;
4627
4628 dst[3] = 1;
4629 }
4630
4631 static inline void
unpack_int_rg_uint16(const void * void_src,uint32_t dst[4])4632 unpack_int_rg_uint16(const void *void_src, uint32_t dst[4])
4633 {
4634 uint16_t *src = (uint16_t *)void_src;
4635 uint16_t r = src[0];
4636 uint16_t g = src[1];
4637
4638
4639 dst[0] = r;
4640
4641 dst[1] = g;
4642
4643 dst[2] = 0;
4644
4645 dst[3] = 1;
4646 }
4647
4648 static inline void
unpack_int_rg_uint32(const void * void_src,uint32_t dst[4])4649 unpack_int_rg_uint32(const void *void_src, uint32_t dst[4])
4650 {
4651 uint32_t *src = (uint32_t *)void_src;
4652 uint32_t r = src[0];
4653 uint32_t g = src[1];
4654
4655
4656 dst[0] = r;
4657
4658 dst[1] = g;
4659
4660 dst[2] = 0;
4661
4662 dst[3] = 1;
4663 }
4664
4665 static inline void
unpack_int_rg_sint8(const void * void_src,uint32_t dst[4])4666 unpack_int_rg_sint8(const void *void_src, uint32_t dst[4])
4667 {
4668 int8_t *src = (int8_t *)void_src;
4669 int8_t r = src[0];
4670 int8_t g = src[1];
4671
4672
4673 dst[0] = r;
4674
4675 dst[1] = g;
4676
4677 dst[2] = 0;
4678
4679 dst[3] = 1;
4680 }
4681
4682 static inline void
unpack_int_rg_sint16(const void * void_src,uint32_t dst[4])4683 unpack_int_rg_sint16(const void *void_src, uint32_t dst[4])
4684 {
4685 int16_t *src = (int16_t *)void_src;
4686 int16_t r = src[0];
4687 int16_t g = src[1];
4688
4689
4690 dst[0] = r;
4691
4692 dst[1] = g;
4693
4694 dst[2] = 0;
4695
4696 dst[3] = 1;
4697 }
4698
4699 static inline void
unpack_int_rg_sint32(const void * void_src,uint32_t dst[4])4700 unpack_int_rg_sint32(const void *void_src, uint32_t dst[4])
4701 {
4702 int32_t *src = (int32_t *)void_src;
4703 int32_t r = src[0];
4704 int32_t g = src[1];
4705
4706
4707 dst[0] = r;
4708
4709 dst[1] = g;
4710
4711 dst[2] = 0;
4712
4713 dst[3] = 1;
4714 }
4715
4716 static inline void
unpack_int_rgb_uint8(const void * void_src,uint32_t dst[4])4717 unpack_int_rgb_uint8(const void *void_src, uint32_t dst[4])
4718 {
4719 uint8_t *src = (uint8_t *)void_src;
4720 uint8_t r = src[0];
4721 uint8_t g = src[1];
4722 uint8_t b = src[2];
4723
4724
4725 dst[0] = r;
4726
4727 dst[1] = g;
4728
4729 dst[2] = b;
4730
4731 dst[3] = 1;
4732 }
4733
4734 static inline void
unpack_int_rgb_uint16(const void * void_src,uint32_t dst[4])4735 unpack_int_rgb_uint16(const void *void_src, uint32_t dst[4])
4736 {
4737 uint16_t *src = (uint16_t *)void_src;
4738 uint16_t r = src[0];
4739 uint16_t g = src[1];
4740 uint16_t b = src[2];
4741
4742
4743 dst[0] = r;
4744
4745 dst[1] = g;
4746
4747 dst[2] = b;
4748
4749 dst[3] = 1;
4750 }
4751
4752 static inline void
unpack_int_rgb_uint32(const void * void_src,uint32_t dst[4])4753 unpack_int_rgb_uint32(const void *void_src, uint32_t dst[4])
4754 {
4755 uint32_t *src = (uint32_t *)void_src;
4756 uint32_t r = src[0];
4757 uint32_t g = src[1];
4758 uint32_t b = src[2];
4759
4760
4761 dst[0] = r;
4762
4763 dst[1] = g;
4764
4765 dst[2] = b;
4766
4767 dst[3] = 1;
4768 }
4769
4770 static inline void
unpack_int_rgb_sint8(const void * void_src,uint32_t dst[4])4771 unpack_int_rgb_sint8(const void *void_src, uint32_t dst[4])
4772 {
4773 int8_t *src = (int8_t *)void_src;
4774 int8_t r = src[0];
4775 int8_t g = src[1];
4776 int8_t b = src[2];
4777
4778
4779 dst[0] = r;
4780
4781 dst[1] = g;
4782
4783 dst[2] = b;
4784
4785 dst[3] = 1;
4786 }
4787
4788 static inline void
unpack_int_rgb_sint16(const void * void_src,uint32_t dst[4])4789 unpack_int_rgb_sint16(const void *void_src, uint32_t dst[4])
4790 {
4791 int16_t *src = (int16_t *)void_src;
4792 int16_t r = src[0];
4793 int16_t g = src[1];
4794 int16_t b = src[2];
4795
4796
4797 dst[0] = r;
4798
4799 dst[1] = g;
4800
4801 dst[2] = b;
4802
4803 dst[3] = 1;
4804 }
4805
4806 static inline void
unpack_int_rgb_sint32(const void * void_src,uint32_t dst[4])4807 unpack_int_rgb_sint32(const void *void_src, uint32_t dst[4])
4808 {
4809 int32_t *src = (int32_t *)void_src;
4810 int32_t r = src[0];
4811 int32_t g = src[1];
4812 int32_t b = src[2];
4813
4814
4815 dst[0] = r;
4816
4817 dst[1] = g;
4818
4819 dst[2] = b;
4820
4821 dst[3] = 1;
4822 }
4823
4824 static inline void
unpack_int_rgba_uint16(const void * void_src,uint32_t dst[4])4825 unpack_int_rgba_uint16(const void *void_src, uint32_t dst[4])
4826 {
4827 uint16_t *src = (uint16_t *)void_src;
4828 uint16_t r = src[0];
4829 uint16_t g = src[1];
4830 uint16_t b = src[2];
4831 uint16_t a = src[3];
4832
4833
4834 dst[0] = r;
4835
4836 dst[1] = g;
4837
4838 dst[2] = b;
4839
4840 dst[3] = a;
4841 }
4842
4843 static inline void
unpack_int_rgba_uint32(const void * void_src,uint32_t dst[4])4844 unpack_int_rgba_uint32(const void *void_src, uint32_t dst[4])
4845 {
4846 uint32_t *src = (uint32_t *)void_src;
4847 uint32_t r = src[0];
4848 uint32_t g = src[1];
4849 uint32_t b = src[2];
4850 uint32_t a = src[3];
4851
4852
4853 dst[0] = r;
4854
4855 dst[1] = g;
4856
4857 dst[2] = b;
4858
4859 dst[3] = a;
4860 }
4861
4862 static inline void
unpack_int_rgba_sint8(const void * void_src,uint32_t dst[4])4863 unpack_int_rgba_sint8(const void *void_src, uint32_t dst[4])
4864 {
4865 int8_t *src = (int8_t *)void_src;
4866 int8_t r = src[0];
4867 int8_t g = src[1];
4868 int8_t b = src[2];
4869 int8_t a = src[3];
4870
4871
4872 dst[0] = r;
4873
4874 dst[1] = g;
4875
4876 dst[2] = b;
4877
4878 dst[3] = a;
4879 }
4880
4881 static inline void
unpack_int_rgba_sint16(const void * void_src,uint32_t dst[4])4882 unpack_int_rgba_sint16(const void *void_src, uint32_t dst[4])
4883 {
4884 int16_t *src = (int16_t *)void_src;
4885 int16_t r = src[0];
4886 int16_t g = src[1];
4887 int16_t b = src[2];
4888 int16_t a = src[3];
4889
4890
4891 dst[0] = r;
4892
4893 dst[1] = g;
4894
4895 dst[2] = b;
4896
4897 dst[3] = a;
4898 }
4899
4900 static inline void
unpack_int_rgba_sint32(const void * void_src,uint32_t dst[4])4901 unpack_int_rgba_sint32(const void *void_src, uint32_t dst[4])
4902 {
4903 int32_t *src = (int32_t *)void_src;
4904 int32_t r = src[0];
4905 int32_t g = src[1];
4906 int32_t b = src[2];
4907 int32_t a = src[3];
4908
4909
4910 dst[0] = r;
4911
4912 dst[1] = g;
4913
4914 dst[2] = b;
4915
4916 dst[3] = a;
4917 }
4918
4919 static inline void
unpack_int_rgbx_uint8(const void * void_src,uint32_t dst[4])4920 unpack_int_rgbx_uint8(const void *void_src, uint32_t dst[4])
4921 {
4922 uint8_t *src = (uint8_t *)void_src;
4923 uint8_t r = src[0];
4924 uint8_t g = src[1];
4925 uint8_t b = src[2];
4926
4927
4928 dst[0] = r;
4929
4930 dst[1] = g;
4931
4932 dst[2] = b;
4933
4934 dst[3] = 1;
4935 }
4936
4937 static inline void
unpack_int_rgbx_uint16(const void * void_src,uint32_t dst[4])4938 unpack_int_rgbx_uint16(const void *void_src, uint32_t dst[4])
4939 {
4940 uint16_t *src = (uint16_t *)void_src;
4941 uint16_t r = src[0];
4942 uint16_t g = src[1];
4943 uint16_t b = src[2];
4944
4945
4946 dst[0] = r;
4947
4948 dst[1] = g;
4949
4950 dst[2] = b;
4951
4952 dst[3] = 1;
4953 }
4954
4955 static inline void
unpack_int_rgbx_uint32(const void * void_src,uint32_t dst[4])4956 unpack_int_rgbx_uint32(const void *void_src, uint32_t dst[4])
4957 {
4958 uint32_t *src = (uint32_t *)void_src;
4959 uint32_t r = src[0];
4960 uint32_t g = src[1];
4961 uint32_t b = src[2];
4962
4963
4964 dst[0] = r;
4965
4966 dst[1] = g;
4967
4968 dst[2] = b;
4969
4970 dst[3] = 1;
4971 }
4972
4973 static inline void
unpack_int_rgbx_sint8(const void * void_src,uint32_t dst[4])4974 unpack_int_rgbx_sint8(const void *void_src, uint32_t dst[4])
4975 {
4976 int8_t *src = (int8_t *)void_src;
4977 int8_t r = src[0];
4978 int8_t g = src[1];
4979 int8_t b = src[2];
4980
4981
4982 dst[0] = r;
4983
4984 dst[1] = g;
4985
4986 dst[2] = b;
4987
4988 dst[3] = 1;
4989 }
4990
4991 static inline void
unpack_int_rgbx_sint16(const void * void_src,uint32_t dst[4])4992 unpack_int_rgbx_sint16(const void *void_src, uint32_t dst[4])
4993 {
4994 int16_t *src = (int16_t *)void_src;
4995 int16_t r = src[0];
4996 int16_t g = src[1];
4997 int16_t b = src[2];
4998
4999
5000 dst[0] = r;
5001
5002 dst[1] = g;
5003
5004 dst[2] = b;
5005
5006 dst[3] = 1;
5007 }
5008
5009 static inline void
unpack_int_rgbx_sint32(const void * void_src,uint32_t dst[4])5010 unpack_int_rgbx_sint32(const void *void_src, uint32_t dst[4])
5011 {
5012 int32_t *src = (int32_t *)void_src;
5013 int32_t r = src[0];
5014 int32_t g = src[1];
5015 int32_t b = src[2];
5016
5017
5018 dst[0] = r;
5019
5020 dst[1] = g;
5021
5022 dst[2] = b;
5023
5024 dst[3] = 1;
5025 }
5026
5027
5028 void
_mesa_unpack_rgba_row(mesa_format format,uint32_t n,const void * src,float dst[][4])5029 _mesa_unpack_rgba_row(mesa_format format, uint32_t n,
5030 const void *src, float dst[][4])
5031 {
5032 uint8_t *s = (uint8_t *)src;
5033 uint32_t i;
5034
5035 switch (format) {
5036 case MESA_FORMAT_A8B8G8R8_UNORM:
5037 for (i = 0; i < n; ++i) {
5038 unpack_float_a8b8g8r8_unorm(s, dst[i]);
5039 s += 4;
5040 }
5041 break;
5042 case MESA_FORMAT_X8B8G8R8_UNORM:
5043 for (i = 0; i < n; ++i) {
5044 unpack_float_x8b8g8r8_unorm(s, dst[i]);
5045 s += 4;
5046 }
5047 break;
5048 case MESA_FORMAT_R8G8B8A8_UNORM:
5049 for (i = 0; i < n; ++i) {
5050 unpack_float_r8g8b8a8_unorm(s, dst[i]);
5051 s += 4;
5052 }
5053 break;
5054 case MESA_FORMAT_R8G8B8X8_UNORM:
5055 for (i = 0; i < n; ++i) {
5056 unpack_float_r8g8b8x8_unorm(s, dst[i]);
5057 s += 4;
5058 }
5059 break;
5060 case MESA_FORMAT_B8G8R8A8_UNORM:
5061 for (i = 0; i < n; ++i) {
5062 unpack_float_b8g8r8a8_unorm(s, dst[i]);
5063 s += 4;
5064 }
5065 break;
5066 case MESA_FORMAT_B8G8R8X8_UNORM:
5067 for (i = 0; i < n; ++i) {
5068 unpack_float_b8g8r8x8_unorm(s, dst[i]);
5069 s += 4;
5070 }
5071 break;
5072 case MESA_FORMAT_A8R8G8B8_UNORM:
5073 for (i = 0; i < n; ++i) {
5074 unpack_float_a8r8g8b8_unorm(s, dst[i]);
5075 s += 4;
5076 }
5077 break;
5078 case MESA_FORMAT_X8R8G8B8_UNORM:
5079 for (i = 0; i < n; ++i) {
5080 unpack_float_x8r8g8b8_unorm(s, dst[i]);
5081 s += 4;
5082 }
5083 break;
5084 case MESA_FORMAT_B5G6R5_UNORM:
5085 for (i = 0; i < n; ++i) {
5086 unpack_float_b5g6r5_unorm(s, dst[i]);
5087 s += 2;
5088 }
5089 break;
5090 case MESA_FORMAT_R5G6B5_UNORM:
5091 for (i = 0; i < n; ++i) {
5092 unpack_float_r5g6b5_unorm(s, dst[i]);
5093 s += 2;
5094 }
5095 break;
5096 case MESA_FORMAT_B4G4R4A4_UNORM:
5097 for (i = 0; i < n; ++i) {
5098 unpack_float_b4g4r4a4_unorm(s, dst[i]);
5099 s += 2;
5100 }
5101 break;
5102 case MESA_FORMAT_B4G4R4X4_UNORM:
5103 for (i = 0; i < n; ++i) {
5104 unpack_float_b4g4r4x4_unorm(s, dst[i]);
5105 s += 2;
5106 }
5107 break;
5108 case MESA_FORMAT_A4R4G4B4_UNORM:
5109 for (i = 0; i < n; ++i) {
5110 unpack_float_a4r4g4b4_unorm(s, dst[i]);
5111 s += 2;
5112 }
5113 break;
5114 case MESA_FORMAT_A1B5G5R5_UNORM:
5115 for (i = 0; i < n; ++i) {
5116 unpack_float_a1b5g5r5_unorm(s, dst[i]);
5117 s += 2;
5118 }
5119 break;
5120 case MESA_FORMAT_X1B5G5R5_UNORM:
5121 for (i = 0; i < n; ++i) {
5122 unpack_float_x1b5g5r5_unorm(s, dst[i]);
5123 s += 2;
5124 }
5125 break;
5126 case MESA_FORMAT_B5G5R5A1_UNORM:
5127 for (i = 0; i < n; ++i) {
5128 unpack_float_b5g5r5a1_unorm(s, dst[i]);
5129 s += 2;
5130 }
5131 break;
5132 case MESA_FORMAT_B5G5R5X1_UNORM:
5133 for (i = 0; i < n; ++i) {
5134 unpack_float_b5g5r5x1_unorm(s, dst[i]);
5135 s += 2;
5136 }
5137 break;
5138 case MESA_FORMAT_A1R5G5B5_UNORM:
5139 for (i = 0; i < n; ++i) {
5140 unpack_float_a1r5g5b5_unorm(s, dst[i]);
5141 s += 2;
5142 }
5143 break;
5144 case MESA_FORMAT_L4A4_UNORM:
5145 for (i = 0; i < n; ++i) {
5146 unpack_float_l4a4_unorm(s, dst[i]);
5147 s += 1;
5148 }
5149 break;
5150 case MESA_FORMAT_B2G3R3_UNORM:
5151 for (i = 0; i < n; ++i) {
5152 unpack_float_b2g3r3_unorm(s, dst[i]);
5153 s += 1;
5154 }
5155 break;
5156 case MESA_FORMAT_B10G10R10A2_UNORM:
5157 for (i = 0; i < n; ++i) {
5158 unpack_float_b10g10r10a2_unorm(s, dst[i]);
5159 s += 4;
5160 }
5161 break;
5162 case MESA_FORMAT_B10G10R10X2_UNORM:
5163 for (i = 0; i < n; ++i) {
5164 unpack_float_b10g10r10x2_unorm(s, dst[i]);
5165 s += 4;
5166 }
5167 break;
5168 case MESA_FORMAT_R10G10B10A2_UNORM:
5169 for (i = 0; i < n; ++i) {
5170 unpack_float_r10g10b10a2_unorm(s, dst[i]);
5171 s += 4;
5172 }
5173 break;
5174 case MESA_FORMAT_R10G10B10X2_UNORM:
5175 for (i = 0; i < n; ++i) {
5176 unpack_float_r10g10b10x2_unorm(s, dst[i]);
5177 s += 4;
5178 }
5179 break;
5180 case MESA_FORMAT_R3G3B2_UNORM:
5181 for (i = 0; i < n; ++i) {
5182 unpack_float_r3g3b2_unorm(s, dst[i]);
5183 s += 1;
5184 }
5185 break;
5186 case MESA_FORMAT_A4B4G4R4_UNORM:
5187 for (i = 0; i < n; ++i) {
5188 unpack_float_a4b4g4r4_unorm(s, dst[i]);
5189 s += 2;
5190 }
5191 break;
5192 case MESA_FORMAT_R4G4B4A4_UNORM:
5193 for (i = 0; i < n; ++i) {
5194 unpack_float_r4g4b4a4_unorm(s, dst[i]);
5195 s += 2;
5196 }
5197 break;
5198 case MESA_FORMAT_R5G5B5A1_UNORM:
5199 for (i = 0; i < n; ++i) {
5200 unpack_float_r5g5b5a1_unorm(s, dst[i]);
5201 s += 2;
5202 }
5203 break;
5204 case MESA_FORMAT_A2B10G10R10_UNORM:
5205 for (i = 0; i < n; ++i) {
5206 unpack_float_a2b10g10r10_unorm(s, dst[i]);
5207 s += 4;
5208 }
5209 break;
5210 case MESA_FORMAT_A2R10G10B10_UNORM:
5211 for (i = 0; i < n; ++i) {
5212 unpack_float_a2r10g10b10_unorm(s, dst[i]);
5213 s += 4;
5214 }
5215 break;
5216 case MESA_FORMAT_A_UNORM8:
5217 for (i = 0; i < n; ++i) {
5218 unpack_float_a_unorm8(s, dst[i]);
5219 s += 1;
5220 }
5221 break;
5222 case MESA_FORMAT_A_UNORM16:
5223 for (i = 0; i < n; ++i) {
5224 unpack_float_a_unorm16(s, dst[i]);
5225 s += 2;
5226 }
5227 break;
5228 case MESA_FORMAT_L_UNORM8:
5229 for (i = 0; i < n; ++i) {
5230 unpack_float_l_unorm8(s, dst[i]);
5231 s += 1;
5232 }
5233 break;
5234 case MESA_FORMAT_L_UNORM16:
5235 for (i = 0; i < n; ++i) {
5236 unpack_float_l_unorm16(s, dst[i]);
5237 s += 2;
5238 }
5239 break;
5240 case MESA_FORMAT_LA_UNORM8:
5241 for (i = 0; i < n; ++i) {
5242 unpack_float_la_unorm8(s, dst[i]);
5243 s += 2;
5244 }
5245 break;
5246 case MESA_FORMAT_LA_UNORM16:
5247 for (i = 0; i < n; ++i) {
5248 unpack_float_la_unorm16(s, dst[i]);
5249 s += 4;
5250 }
5251 break;
5252 case MESA_FORMAT_I_UNORM8:
5253 for (i = 0; i < n; ++i) {
5254 unpack_float_i_unorm8(s, dst[i]);
5255 s += 1;
5256 }
5257 break;
5258 case MESA_FORMAT_I_UNORM16:
5259 for (i = 0; i < n; ++i) {
5260 unpack_float_i_unorm16(s, dst[i]);
5261 s += 2;
5262 }
5263 break;
5264 case MESA_FORMAT_R_UNORM8:
5265 for (i = 0; i < n; ++i) {
5266 unpack_float_r_unorm8(s, dst[i]);
5267 s += 1;
5268 }
5269 break;
5270 case MESA_FORMAT_R_UNORM16:
5271 for (i = 0; i < n; ++i) {
5272 unpack_float_r_unorm16(s, dst[i]);
5273 s += 2;
5274 }
5275 break;
5276 case MESA_FORMAT_RG_UNORM8:
5277 for (i = 0; i < n; ++i) {
5278 unpack_float_rg_unorm8(s, dst[i]);
5279 s += 2;
5280 }
5281 break;
5282 case MESA_FORMAT_RG_UNORM16:
5283 for (i = 0; i < n; ++i) {
5284 unpack_float_rg_unorm16(s, dst[i]);
5285 s += 4;
5286 }
5287 break;
5288 case MESA_FORMAT_BGR_UNORM8:
5289 for (i = 0; i < n; ++i) {
5290 unpack_float_bgr_unorm8(s, dst[i]);
5291 s += 3;
5292 }
5293 break;
5294 case MESA_FORMAT_RGB_UNORM8:
5295 for (i = 0; i < n; ++i) {
5296 unpack_float_rgb_unorm8(s, dst[i]);
5297 s += 3;
5298 }
5299 break;
5300 case MESA_FORMAT_RGBA_UNORM16:
5301 for (i = 0; i < n; ++i) {
5302 unpack_float_rgba_unorm16(s, dst[i]);
5303 s += 8;
5304 }
5305 break;
5306 case MESA_FORMAT_RGBX_UNORM16:
5307 for (i = 0; i < n; ++i) {
5308 unpack_float_rgbx_unorm16(s, dst[i]);
5309 s += 8;
5310 }
5311 break;
5312 case MESA_FORMAT_A8B8G8R8_SNORM:
5313 for (i = 0; i < n; ++i) {
5314 unpack_float_a8b8g8r8_snorm(s, dst[i]);
5315 s += 4;
5316 }
5317 break;
5318 case MESA_FORMAT_X8B8G8R8_SNORM:
5319 for (i = 0; i < n; ++i) {
5320 unpack_float_x8b8g8r8_snorm(s, dst[i]);
5321 s += 4;
5322 }
5323 break;
5324 case MESA_FORMAT_R8G8B8A8_SNORM:
5325 for (i = 0; i < n; ++i) {
5326 unpack_float_r8g8b8a8_snorm(s, dst[i]);
5327 s += 4;
5328 }
5329 break;
5330 case MESA_FORMAT_R8G8B8X8_SNORM:
5331 for (i = 0; i < n; ++i) {
5332 unpack_float_r8g8b8x8_snorm(s, dst[i]);
5333 s += 4;
5334 }
5335 break;
5336 case MESA_FORMAT_A_SNORM8:
5337 for (i = 0; i < n; ++i) {
5338 unpack_float_a_snorm8(s, dst[i]);
5339 s += 1;
5340 }
5341 break;
5342 case MESA_FORMAT_A_SNORM16:
5343 for (i = 0; i < n; ++i) {
5344 unpack_float_a_snorm16(s, dst[i]);
5345 s += 2;
5346 }
5347 break;
5348 case MESA_FORMAT_L_SNORM8:
5349 for (i = 0; i < n; ++i) {
5350 unpack_float_l_snorm8(s, dst[i]);
5351 s += 1;
5352 }
5353 break;
5354 case MESA_FORMAT_L_SNORM16:
5355 for (i = 0; i < n; ++i) {
5356 unpack_float_l_snorm16(s, dst[i]);
5357 s += 2;
5358 }
5359 break;
5360 case MESA_FORMAT_I_SNORM8:
5361 for (i = 0; i < n; ++i) {
5362 unpack_float_i_snorm8(s, dst[i]);
5363 s += 1;
5364 }
5365 break;
5366 case MESA_FORMAT_I_SNORM16:
5367 for (i = 0; i < n; ++i) {
5368 unpack_float_i_snorm16(s, dst[i]);
5369 s += 2;
5370 }
5371 break;
5372 case MESA_FORMAT_R_SNORM8:
5373 for (i = 0; i < n; ++i) {
5374 unpack_float_r_snorm8(s, dst[i]);
5375 s += 1;
5376 }
5377 break;
5378 case MESA_FORMAT_R_SNORM16:
5379 for (i = 0; i < n; ++i) {
5380 unpack_float_r_snorm16(s, dst[i]);
5381 s += 2;
5382 }
5383 break;
5384 case MESA_FORMAT_LA_SNORM8:
5385 for (i = 0; i < n; ++i) {
5386 unpack_float_la_snorm8(s, dst[i]);
5387 s += 2;
5388 }
5389 break;
5390 case MESA_FORMAT_LA_SNORM16:
5391 for (i = 0; i < n; ++i) {
5392 unpack_float_la_snorm16(s, dst[i]);
5393 s += 4;
5394 }
5395 break;
5396 case MESA_FORMAT_RG_SNORM8:
5397 for (i = 0; i < n; ++i) {
5398 unpack_float_rg_snorm8(s, dst[i]);
5399 s += 2;
5400 }
5401 break;
5402 case MESA_FORMAT_RG_SNORM16:
5403 for (i = 0; i < n; ++i) {
5404 unpack_float_rg_snorm16(s, dst[i]);
5405 s += 4;
5406 }
5407 break;
5408 case MESA_FORMAT_RGB_SNORM16:
5409 for (i = 0; i < n; ++i) {
5410 unpack_float_rgb_snorm16(s, dst[i]);
5411 s += 6;
5412 }
5413 break;
5414 case MESA_FORMAT_RGBA_SNORM16:
5415 for (i = 0; i < n; ++i) {
5416 unpack_float_rgba_snorm16(s, dst[i]);
5417 s += 8;
5418 }
5419 break;
5420 case MESA_FORMAT_RGBX_SNORM16:
5421 for (i = 0; i < n; ++i) {
5422 unpack_float_rgbx_snorm16(s, dst[i]);
5423 s += 8;
5424 }
5425 break;
5426 case MESA_FORMAT_A8B8G8R8_SRGB:
5427 for (i = 0; i < n; ++i) {
5428 unpack_float_a8b8g8r8_srgb(s, dst[i]);
5429 s += 4;
5430 }
5431 break;
5432 case MESA_FORMAT_B8G8R8A8_SRGB:
5433 for (i = 0; i < n; ++i) {
5434 unpack_float_b8g8r8a8_srgb(s, dst[i]);
5435 s += 4;
5436 }
5437 break;
5438 case MESA_FORMAT_A8R8G8B8_SRGB:
5439 for (i = 0; i < n; ++i) {
5440 unpack_float_a8r8g8b8_srgb(s, dst[i]);
5441 s += 4;
5442 }
5443 break;
5444 case MESA_FORMAT_B8G8R8X8_SRGB:
5445 for (i = 0; i < n; ++i) {
5446 unpack_float_b8g8r8x8_srgb(s, dst[i]);
5447 s += 4;
5448 }
5449 break;
5450 case MESA_FORMAT_X8R8G8B8_SRGB:
5451 for (i = 0; i < n; ++i) {
5452 unpack_float_x8r8g8b8_srgb(s, dst[i]);
5453 s += 4;
5454 }
5455 break;
5456 case MESA_FORMAT_R8G8B8A8_SRGB:
5457 for (i = 0; i < n; ++i) {
5458 unpack_float_r8g8b8a8_srgb(s, dst[i]);
5459 s += 4;
5460 }
5461 break;
5462 case MESA_FORMAT_R8G8B8X8_SRGB:
5463 for (i = 0; i < n; ++i) {
5464 unpack_float_r8g8b8x8_srgb(s, dst[i]);
5465 s += 4;
5466 }
5467 break;
5468 case MESA_FORMAT_X8B8G8R8_SRGB:
5469 for (i = 0; i < n; ++i) {
5470 unpack_float_x8b8g8r8_srgb(s, dst[i]);
5471 s += 4;
5472 }
5473 break;
5474 case MESA_FORMAT_R_SRGB8:
5475 for (i = 0; i < n; ++i) {
5476 unpack_float_r_srgb8(s, dst[i]);
5477 s += 1;
5478 }
5479 break;
5480 case MESA_FORMAT_L_SRGB8:
5481 for (i = 0; i < n; ++i) {
5482 unpack_float_l_srgb8(s, dst[i]);
5483 s += 1;
5484 }
5485 break;
5486 case MESA_FORMAT_LA_SRGB8:
5487 for (i = 0; i < n; ++i) {
5488 unpack_float_la_srgb8(s, dst[i]);
5489 s += 2;
5490 }
5491 break;
5492 case MESA_FORMAT_BGR_SRGB8:
5493 for (i = 0; i < n; ++i) {
5494 unpack_float_bgr_srgb8(s, dst[i]);
5495 s += 3;
5496 }
5497 break;
5498 case MESA_FORMAT_R9G9B9E5_FLOAT:
5499 for (i = 0; i < n; ++i) {
5500 unpack_float_r9g9b9e5_float(s, dst[i]);
5501 s += 4;
5502 }
5503 break;
5504 case MESA_FORMAT_R11G11B10_FLOAT:
5505 for (i = 0; i < n; ++i) {
5506 unpack_float_r11g11b10_float(s, dst[i]);
5507 s += 4;
5508 }
5509 break;
5510 case MESA_FORMAT_A_FLOAT16:
5511 for (i = 0; i < n; ++i) {
5512 unpack_float_a_float16(s, dst[i]);
5513 s += 2;
5514 }
5515 break;
5516 case MESA_FORMAT_A_FLOAT32:
5517 for (i = 0; i < n; ++i) {
5518 unpack_float_a_float32(s, dst[i]);
5519 s += 4;
5520 }
5521 break;
5522 case MESA_FORMAT_L_FLOAT16:
5523 for (i = 0; i < n; ++i) {
5524 unpack_float_l_float16(s, dst[i]);
5525 s += 2;
5526 }
5527 break;
5528 case MESA_FORMAT_L_FLOAT32:
5529 for (i = 0; i < n; ++i) {
5530 unpack_float_l_float32(s, dst[i]);
5531 s += 4;
5532 }
5533 break;
5534 case MESA_FORMAT_LA_FLOAT16:
5535 for (i = 0; i < n; ++i) {
5536 unpack_float_la_float16(s, dst[i]);
5537 s += 4;
5538 }
5539 break;
5540 case MESA_FORMAT_LA_FLOAT32:
5541 for (i = 0; i < n; ++i) {
5542 unpack_float_la_float32(s, dst[i]);
5543 s += 8;
5544 }
5545 break;
5546 case MESA_FORMAT_I_FLOAT16:
5547 for (i = 0; i < n; ++i) {
5548 unpack_float_i_float16(s, dst[i]);
5549 s += 2;
5550 }
5551 break;
5552 case MESA_FORMAT_I_FLOAT32:
5553 for (i = 0; i < n; ++i) {
5554 unpack_float_i_float32(s, dst[i]);
5555 s += 4;
5556 }
5557 break;
5558 case MESA_FORMAT_R_FLOAT16:
5559 for (i = 0; i < n; ++i) {
5560 unpack_float_r_float16(s, dst[i]);
5561 s += 2;
5562 }
5563 break;
5564 case MESA_FORMAT_R_FLOAT32:
5565 for (i = 0; i < n; ++i) {
5566 unpack_float_r_float32(s, dst[i]);
5567 s += 4;
5568 }
5569 break;
5570 case MESA_FORMAT_RG_FLOAT16:
5571 for (i = 0; i < n; ++i) {
5572 unpack_float_rg_float16(s, dst[i]);
5573 s += 4;
5574 }
5575 break;
5576 case MESA_FORMAT_RG_FLOAT32:
5577 for (i = 0; i < n; ++i) {
5578 unpack_float_rg_float32(s, dst[i]);
5579 s += 8;
5580 }
5581 break;
5582 case MESA_FORMAT_RGB_FLOAT16:
5583 for (i = 0; i < n; ++i) {
5584 unpack_float_rgb_float16(s, dst[i]);
5585 s += 6;
5586 }
5587 break;
5588 case MESA_FORMAT_RGB_FLOAT32:
5589 for (i = 0; i < n; ++i) {
5590 unpack_float_rgb_float32(s, dst[i]);
5591 s += 12;
5592 }
5593 break;
5594 case MESA_FORMAT_RGBA_FLOAT16:
5595 for (i = 0; i < n; ++i) {
5596 unpack_float_rgba_float16(s, dst[i]);
5597 s += 8;
5598 }
5599 break;
5600 case MESA_FORMAT_RGBA_FLOAT32:
5601 for (i = 0; i < n; ++i) {
5602 unpack_float_rgba_float32(s, dst[i]);
5603 s += 16;
5604 }
5605 break;
5606 case MESA_FORMAT_RGBX_FLOAT16:
5607 for (i = 0; i < n; ++i) {
5608 unpack_float_rgbx_float16(s, dst[i]);
5609 s += 8;
5610 }
5611 break;
5612 case MESA_FORMAT_RGBX_FLOAT32:
5613 for (i = 0; i < n; ++i) {
5614 unpack_float_rgbx_float32(s, dst[i]);
5615 s += 16;
5616 }
5617 break;
5618 case MESA_FORMAT_YCBCR:
5619 unpack_float_ycbcr(src, dst, n);
5620 break;
5621 case MESA_FORMAT_YCBCR_REV:
5622 unpack_float_ycbcr_rev(src, dst, n);
5623 break;
5624 default:
5625 unreachable("bad format");
5626 }
5627 }
5628
5629 void
_mesa_unpack_ubyte_rgba_row(mesa_format format,uint32_t n,const void * src,uint8_t dst[][4])5630 _mesa_unpack_ubyte_rgba_row(mesa_format format, uint32_t n,
5631 const void *src, uint8_t dst[][4])
5632 {
5633 uint8_t *s = (uint8_t *)src;
5634 uint32_t i;
5635
5636 switch (format) {
5637
5638 case MESA_FORMAT_A8B8G8R8_UNORM:
5639 for (i = 0; i < n; ++i) {
5640 unpack_ubyte_a8b8g8r8_unorm(s, dst[i]);
5641 s += 4;
5642 }
5643 break;
5644
5645 case MESA_FORMAT_X8B8G8R8_UNORM:
5646 for (i = 0; i < n; ++i) {
5647 unpack_ubyte_x8b8g8r8_unorm(s, dst[i]);
5648 s += 4;
5649 }
5650 break;
5651
5652 case MESA_FORMAT_R8G8B8A8_UNORM:
5653 for (i = 0; i < n; ++i) {
5654 unpack_ubyte_r8g8b8a8_unorm(s, dst[i]);
5655 s += 4;
5656 }
5657 break;
5658
5659 case MESA_FORMAT_R8G8B8X8_UNORM:
5660 for (i = 0; i < n; ++i) {
5661 unpack_ubyte_r8g8b8x8_unorm(s, dst[i]);
5662 s += 4;
5663 }
5664 break;
5665
5666 case MESA_FORMAT_B8G8R8A8_UNORM:
5667 for (i = 0; i < n; ++i) {
5668 unpack_ubyte_b8g8r8a8_unorm(s, dst[i]);
5669 s += 4;
5670 }
5671 break;
5672
5673 case MESA_FORMAT_B8G8R8X8_UNORM:
5674 for (i = 0; i < n; ++i) {
5675 unpack_ubyte_b8g8r8x8_unorm(s, dst[i]);
5676 s += 4;
5677 }
5678 break;
5679
5680 case MESA_FORMAT_A8R8G8B8_UNORM:
5681 for (i = 0; i < n; ++i) {
5682 unpack_ubyte_a8r8g8b8_unorm(s, dst[i]);
5683 s += 4;
5684 }
5685 break;
5686
5687 case MESA_FORMAT_X8R8G8B8_UNORM:
5688 for (i = 0; i < n; ++i) {
5689 unpack_ubyte_x8r8g8b8_unorm(s, dst[i]);
5690 s += 4;
5691 }
5692 break;
5693
5694 case MESA_FORMAT_B5G6R5_UNORM:
5695 for (i = 0; i < n; ++i) {
5696 unpack_ubyte_b5g6r5_unorm(s, dst[i]);
5697 s += 2;
5698 }
5699 break;
5700
5701 case MESA_FORMAT_R5G6B5_UNORM:
5702 for (i = 0; i < n; ++i) {
5703 unpack_ubyte_r5g6b5_unorm(s, dst[i]);
5704 s += 2;
5705 }
5706 break;
5707
5708 case MESA_FORMAT_B4G4R4A4_UNORM:
5709 for (i = 0; i < n; ++i) {
5710 unpack_ubyte_b4g4r4a4_unorm(s, dst[i]);
5711 s += 2;
5712 }
5713 break;
5714
5715 case MESA_FORMAT_B4G4R4X4_UNORM:
5716 for (i = 0; i < n; ++i) {
5717 unpack_ubyte_b4g4r4x4_unorm(s, dst[i]);
5718 s += 2;
5719 }
5720 break;
5721
5722 case MESA_FORMAT_A4R4G4B4_UNORM:
5723 for (i = 0; i < n; ++i) {
5724 unpack_ubyte_a4r4g4b4_unorm(s, dst[i]);
5725 s += 2;
5726 }
5727 break;
5728
5729 case MESA_FORMAT_A1B5G5R5_UNORM:
5730 for (i = 0; i < n; ++i) {
5731 unpack_ubyte_a1b5g5r5_unorm(s, dst[i]);
5732 s += 2;
5733 }
5734 break;
5735
5736 case MESA_FORMAT_X1B5G5R5_UNORM:
5737 for (i = 0; i < n; ++i) {
5738 unpack_ubyte_x1b5g5r5_unorm(s, dst[i]);
5739 s += 2;
5740 }
5741 break;
5742
5743 case MESA_FORMAT_B5G5R5A1_UNORM:
5744 for (i = 0; i < n; ++i) {
5745 unpack_ubyte_b5g5r5a1_unorm(s, dst[i]);
5746 s += 2;
5747 }
5748 break;
5749
5750 case MESA_FORMAT_B5G5R5X1_UNORM:
5751 for (i = 0; i < n; ++i) {
5752 unpack_ubyte_b5g5r5x1_unorm(s, dst[i]);
5753 s += 2;
5754 }
5755 break;
5756
5757 case MESA_FORMAT_A1R5G5B5_UNORM:
5758 for (i = 0; i < n; ++i) {
5759 unpack_ubyte_a1r5g5b5_unorm(s, dst[i]);
5760 s += 2;
5761 }
5762 break;
5763
5764 case MESA_FORMAT_L4A4_UNORM:
5765 for (i = 0; i < n; ++i) {
5766 unpack_ubyte_l4a4_unorm(s, dst[i]);
5767 s += 1;
5768 }
5769 break;
5770
5771 case MESA_FORMAT_B2G3R3_UNORM:
5772 for (i = 0; i < n; ++i) {
5773 unpack_ubyte_b2g3r3_unorm(s, dst[i]);
5774 s += 1;
5775 }
5776 break;
5777
5778 case MESA_FORMAT_B10G10R10A2_UNORM:
5779 for (i = 0; i < n; ++i) {
5780 unpack_ubyte_b10g10r10a2_unorm(s, dst[i]);
5781 s += 4;
5782 }
5783 break;
5784
5785 case MESA_FORMAT_B10G10R10X2_UNORM:
5786 for (i = 0; i < n; ++i) {
5787 unpack_ubyte_b10g10r10x2_unorm(s, dst[i]);
5788 s += 4;
5789 }
5790 break;
5791
5792 case MESA_FORMAT_R10G10B10A2_UNORM:
5793 for (i = 0; i < n; ++i) {
5794 unpack_ubyte_r10g10b10a2_unorm(s, dst[i]);
5795 s += 4;
5796 }
5797 break;
5798
5799 case MESA_FORMAT_R10G10B10X2_UNORM:
5800 for (i = 0; i < n; ++i) {
5801 unpack_ubyte_r10g10b10x2_unorm(s, dst[i]);
5802 s += 4;
5803 }
5804 break;
5805
5806 case MESA_FORMAT_R3G3B2_UNORM:
5807 for (i = 0; i < n; ++i) {
5808 unpack_ubyte_r3g3b2_unorm(s, dst[i]);
5809 s += 1;
5810 }
5811 break;
5812
5813 case MESA_FORMAT_A4B4G4R4_UNORM:
5814 for (i = 0; i < n; ++i) {
5815 unpack_ubyte_a4b4g4r4_unorm(s, dst[i]);
5816 s += 2;
5817 }
5818 break;
5819
5820 case MESA_FORMAT_R4G4B4A4_UNORM:
5821 for (i = 0; i < n; ++i) {
5822 unpack_ubyte_r4g4b4a4_unorm(s, dst[i]);
5823 s += 2;
5824 }
5825 break;
5826
5827 case MESA_FORMAT_R5G5B5A1_UNORM:
5828 for (i = 0; i < n; ++i) {
5829 unpack_ubyte_r5g5b5a1_unorm(s, dst[i]);
5830 s += 2;
5831 }
5832 break;
5833
5834 case MESA_FORMAT_A2B10G10R10_UNORM:
5835 for (i = 0; i < n; ++i) {
5836 unpack_ubyte_a2b10g10r10_unorm(s, dst[i]);
5837 s += 4;
5838 }
5839 break;
5840
5841 case MESA_FORMAT_A2R10G10B10_UNORM:
5842 for (i = 0; i < n; ++i) {
5843 unpack_ubyte_a2r10g10b10_unorm(s, dst[i]);
5844 s += 4;
5845 }
5846 break;
5847
5848 case MESA_FORMAT_A_UNORM8:
5849 for (i = 0; i < n; ++i) {
5850 unpack_ubyte_a_unorm8(s, dst[i]);
5851 s += 1;
5852 }
5853 break;
5854
5855 case MESA_FORMAT_A_UNORM16:
5856 for (i = 0; i < n; ++i) {
5857 unpack_ubyte_a_unorm16(s, dst[i]);
5858 s += 2;
5859 }
5860 break;
5861
5862 case MESA_FORMAT_L_UNORM8:
5863 for (i = 0; i < n; ++i) {
5864 unpack_ubyte_l_unorm8(s, dst[i]);
5865 s += 1;
5866 }
5867 break;
5868
5869 case MESA_FORMAT_L_UNORM16:
5870 for (i = 0; i < n; ++i) {
5871 unpack_ubyte_l_unorm16(s, dst[i]);
5872 s += 2;
5873 }
5874 break;
5875
5876 case MESA_FORMAT_LA_UNORM8:
5877 for (i = 0; i < n; ++i) {
5878 unpack_ubyte_la_unorm8(s, dst[i]);
5879 s += 2;
5880 }
5881 break;
5882
5883 case MESA_FORMAT_LA_UNORM16:
5884 for (i = 0; i < n; ++i) {
5885 unpack_ubyte_la_unorm16(s, dst[i]);
5886 s += 4;
5887 }
5888 break;
5889
5890 case MESA_FORMAT_I_UNORM8:
5891 for (i = 0; i < n; ++i) {
5892 unpack_ubyte_i_unorm8(s, dst[i]);
5893 s += 1;
5894 }
5895 break;
5896
5897 case MESA_FORMAT_I_UNORM16:
5898 for (i = 0; i < n; ++i) {
5899 unpack_ubyte_i_unorm16(s, dst[i]);
5900 s += 2;
5901 }
5902 break;
5903
5904 case MESA_FORMAT_R_UNORM8:
5905 for (i = 0; i < n; ++i) {
5906 unpack_ubyte_r_unorm8(s, dst[i]);
5907 s += 1;
5908 }
5909 break;
5910
5911 case MESA_FORMAT_R_UNORM16:
5912 for (i = 0; i < n; ++i) {
5913 unpack_ubyte_r_unorm16(s, dst[i]);
5914 s += 2;
5915 }
5916 break;
5917
5918 case MESA_FORMAT_RG_UNORM8:
5919 for (i = 0; i < n; ++i) {
5920 unpack_ubyte_rg_unorm8(s, dst[i]);
5921 s += 2;
5922 }
5923 break;
5924
5925 case MESA_FORMAT_RG_UNORM16:
5926 for (i = 0; i < n; ++i) {
5927 unpack_ubyte_rg_unorm16(s, dst[i]);
5928 s += 4;
5929 }
5930 break;
5931
5932 case MESA_FORMAT_BGR_UNORM8:
5933 for (i = 0; i < n; ++i) {
5934 unpack_ubyte_bgr_unorm8(s, dst[i]);
5935 s += 3;
5936 }
5937 break;
5938
5939 case MESA_FORMAT_RGB_UNORM8:
5940 for (i = 0; i < n; ++i) {
5941 unpack_ubyte_rgb_unorm8(s, dst[i]);
5942 s += 3;
5943 }
5944 break;
5945
5946 case MESA_FORMAT_RGBA_UNORM16:
5947 for (i = 0; i < n; ++i) {
5948 unpack_ubyte_rgba_unorm16(s, dst[i]);
5949 s += 8;
5950 }
5951 break;
5952
5953 case MESA_FORMAT_RGBX_UNORM16:
5954 for (i = 0; i < n; ++i) {
5955 unpack_ubyte_rgbx_unorm16(s, dst[i]);
5956 s += 8;
5957 }
5958 break;
5959
5960 case MESA_FORMAT_A8B8G8R8_SNORM:
5961 for (i = 0; i < n; ++i) {
5962 unpack_ubyte_a8b8g8r8_snorm(s, dst[i]);
5963 s += 4;
5964 }
5965 break;
5966
5967 case MESA_FORMAT_X8B8G8R8_SNORM:
5968 for (i = 0; i < n; ++i) {
5969 unpack_ubyte_x8b8g8r8_snorm(s, dst[i]);
5970 s += 4;
5971 }
5972 break;
5973
5974 case MESA_FORMAT_R8G8B8A8_SNORM:
5975 for (i = 0; i < n; ++i) {
5976 unpack_ubyte_r8g8b8a8_snorm(s, dst[i]);
5977 s += 4;
5978 }
5979 break;
5980
5981 case MESA_FORMAT_R8G8B8X8_SNORM:
5982 for (i = 0; i < n; ++i) {
5983 unpack_ubyte_r8g8b8x8_snorm(s, dst[i]);
5984 s += 4;
5985 }
5986 break;
5987
5988 case MESA_FORMAT_A_SNORM8:
5989 for (i = 0; i < n; ++i) {
5990 unpack_ubyte_a_snorm8(s, dst[i]);
5991 s += 1;
5992 }
5993 break;
5994
5995 case MESA_FORMAT_A_SNORM16:
5996 for (i = 0; i < n; ++i) {
5997 unpack_ubyte_a_snorm16(s, dst[i]);
5998 s += 2;
5999 }
6000 break;
6001
6002 case MESA_FORMAT_L_SNORM8:
6003 for (i = 0; i < n; ++i) {
6004 unpack_ubyte_l_snorm8(s, dst[i]);
6005 s += 1;
6006 }
6007 break;
6008
6009 case MESA_FORMAT_L_SNORM16:
6010 for (i = 0; i < n; ++i) {
6011 unpack_ubyte_l_snorm16(s, dst[i]);
6012 s += 2;
6013 }
6014 break;
6015
6016 case MESA_FORMAT_I_SNORM8:
6017 for (i = 0; i < n; ++i) {
6018 unpack_ubyte_i_snorm8(s, dst[i]);
6019 s += 1;
6020 }
6021 break;
6022
6023 case MESA_FORMAT_I_SNORM16:
6024 for (i = 0; i < n; ++i) {
6025 unpack_ubyte_i_snorm16(s, dst[i]);
6026 s += 2;
6027 }
6028 break;
6029
6030 case MESA_FORMAT_R_SNORM8:
6031 for (i = 0; i < n; ++i) {
6032 unpack_ubyte_r_snorm8(s, dst[i]);
6033 s += 1;
6034 }
6035 break;
6036
6037 case MESA_FORMAT_R_SNORM16:
6038 for (i = 0; i < n; ++i) {
6039 unpack_ubyte_r_snorm16(s, dst[i]);
6040 s += 2;
6041 }
6042 break;
6043
6044 case MESA_FORMAT_LA_SNORM8:
6045 for (i = 0; i < n; ++i) {
6046 unpack_ubyte_la_snorm8(s, dst[i]);
6047 s += 2;
6048 }
6049 break;
6050
6051 case MESA_FORMAT_LA_SNORM16:
6052 for (i = 0; i < n; ++i) {
6053 unpack_ubyte_la_snorm16(s, dst[i]);
6054 s += 4;
6055 }
6056 break;
6057
6058 case MESA_FORMAT_RG_SNORM8:
6059 for (i = 0; i < n; ++i) {
6060 unpack_ubyte_rg_snorm8(s, dst[i]);
6061 s += 2;
6062 }
6063 break;
6064
6065 case MESA_FORMAT_RG_SNORM16:
6066 for (i = 0; i < n; ++i) {
6067 unpack_ubyte_rg_snorm16(s, dst[i]);
6068 s += 4;
6069 }
6070 break;
6071
6072 case MESA_FORMAT_RGB_SNORM16:
6073 for (i = 0; i < n; ++i) {
6074 unpack_ubyte_rgb_snorm16(s, dst[i]);
6075 s += 6;
6076 }
6077 break;
6078
6079 case MESA_FORMAT_RGBA_SNORM16:
6080 for (i = 0; i < n; ++i) {
6081 unpack_ubyte_rgba_snorm16(s, dst[i]);
6082 s += 8;
6083 }
6084 break;
6085
6086 case MESA_FORMAT_RGBX_SNORM16:
6087 for (i = 0; i < n; ++i) {
6088 unpack_ubyte_rgbx_snorm16(s, dst[i]);
6089 s += 8;
6090 }
6091 break;
6092
6093 case MESA_FORMAT_A8B8G8R8_SRGB:
6094 for (i = 0; i < n; ++i) {
6095 unpack_ubyte_a8b8g8r8_srgb(s, dst[i]);
6096 s += 4;
6097 }
6098 break;
6099
6100 case MESA_FORMAT_B8G8R8A8_SRGB:
6101 for (i = 0; i < n; ++i) {
6102 unpack_ubyte_b8g8r8a8_srgb(s, dst[i]);
6103 s += 4;
6104 }
6105 break;
6106
6107 case MESA_FORMAT_A8R8G8B8_SRGB:
6108 for (i = 0; i < n; ++i) {
6109 unpack_ubyte_a8r8g8b8_srgb(s, dst[i]);
6110 s += 4;
6111 }
6112 break;
6113
6114 case MESA_FORMAT_B8G8R8X8_SRGB:
6115 for (i = 0; i < n; ++i) {
6116 unpack_ubyte_b8g8r8x8_srgb(s, dst[i]);
6117 s += 4;
6118 }
6119 break;
6120
6121 case MESA_FORMAT_X8R8G8B8_SRGB:
6122 for (i = 0; i < n; ++i) {
6123 unpack_ubyte_x8r8g8b8_srgb(s, dst[i]);
6124 s += 4;
6125 }
6126 break;
6127
6128 case MESA_FORMAT_R8G8B8A8_SRGB:
6129 for (i = 0; i < n; ++i) {
6130 unpack_ubyte_r8g8b8a8_srgb(s, dst[i]);
6131 s += 4;
6132 }
6133 break;
6134
6135 case MESA_FORMAT_R8G8B8X8_SRGB:
6136 for (i = 0; i < n; ++i) {
6137 unpack_ubyte_r8g8b8x8_srgb(s, dst[i]);
6138 s += 4;
6139 }
6140 break;
6141
6142 case MESA_FORMAT_X8B8G8R8_SRGB:
6143 for (i = 0; i < n; ++i) {
6144 unpack_ubyte_x8b8g8r8_srgb(s, dst[i]);
6145 s += 4;
6146 }
6147 break;
6148
6149 case MESA_FORMAT_R_SRGB8:
6150 for (i = 0; i < n; ++i) {
6151 unpack_ubyte_r_srgb8(s, dst[i]);
6152 s += 1;
6153 }
6154 break;
6155
6156 case MESA_FORMAT_L_SRGB8:
6157 for (i = 0; i < n; ++i) {
6158 unpack_ubyte_l_srgb8(s, dst[i]);
6159 s += 1;
6160 }
6161 break;
6162
6163 case MESA_FORMAT_LA_SRGB8:
6164 for (i = 0; i < n; ++i) {
6165 unpack_ubyte_la_srgb8(s, dst[i]);
6166 s += 2;
6167 }
6168 break;
6169
6170 case MESA_FORMAT_BGR_SRGB8:
6171 for (i = 0; i < n; ++i) {
6172 unpack_ubyte_bgr_srgb8(s, dst[i]);
6173 s += 3;
6174 }
6175 break;
6176 default:
6177 /* get float values, convert to ubyte */
6178 {
6179 float *tmp = malloc(n * 4 * sizeof(float));
6180 if (tmp) {
6181 uint32_t i;
6182 _mesa_unpack_rgba_row(format, n, src, (float (*)[4]) tmp);
6183 for (i = 0; i < n; i++) {
6184 dst[i][0] = _mesa_float_to_unorm(tmp[i*4+0], 8);
6185 dst[i][1] = _mesa_float_to_unorm(tmp[i*4+1], 8);
6186 dst[i][2] = _mesa_float_to_unorm(tmp[i*4+2], 8);
6187 dst[i][3] = _mesa_float_to_unorm(tmp[i*4+3], 8);
6188 }
6189 free(tmp);
6190 }
6191 }
6192 break;
6193 }
6194 }
6195
6196 void
_mesa_unpack_uint_rgba_row(mesa_format format,uint32_t n,const void * src,uint32_t dst[][4])6197 _mesa_unpack_uint_rgba_row(mesa_format format, uint32_t n,
6198 const void *src, uint32_t dst[][4])
6199 {
6200 uint8_t *s = (uint8_t *)src;
6201 uint32_t i;
6202
6203 switch (format) {
6204
6205 case MESA_FORMAT_A8B8G8R8_UINT:
6206 for (i = 0; i < n; ++i) {
6207 unpack_int_a8b8g8r8_uint(s, dst[i]);
6208 s += 4;
6209 }
6210 break;
6211
6212 case MESA_FORMAT_A8R8G8B8_UINT:
6213 for (i = 0; i < n; ++i) {
6214 unpack_int_a8r8g8b8_uint(s, dst[i]);
6215 s += 4;
6216 }
6217 break;
6218
6219 case MESA_FORMAT_R8G8B8A8_UINT:
6220 for (i = 0; i < n; ++i) {
6221 unpack_int_r8g8b8a8_uint(s, dst[i]);
6222 s += 4;
6223 }
6224 break;
6225
6226 case MESA_FORMAT_B8G8R8A8_UINT:
6227 for (i = 0; i < n; ++i) {
6228 unpack_int_b8g8r8a8_uint(s, dst[i]);
6229 s += 4;
6230 }
6231 break;
6232
6233 case MESA_FORMAT_B10G10R10A2_UINT:
6234 for (i = 0; i < n; ++i) {
6235 unpack_int_b10g10r10a2_uint(s, dst[i]);
6236 s += 4;
6237 }
6238 break;
6239
6240 case MESA_FORMAT_R10G10B10A2_UINT:
6241 for (i = 0; i < n; ++i) {
6242 unpack_int_r10g10b10a2_uint(s, dst[i]);
6243 s += 4;
6244 }
6245 break;
6246
6247 case MESA_FORMAT_A2B10G10R10_UINT:
6248 for (i = 0; i < n; ++i) {
6249 unpack_int_a2b10g10r10_uint(s, dst[i]);
6250 s += 4;
6251 }
6252 break;
6253
6254 case MESA_FORMAT_A2R10G10B10_UINT:
6255 for (i = 0; i < n; ++i) {
6256 unpack_int_a2r10g10b10_uint(s, dst[i]);
6257 s += 4;
6258 }
6259 break;
6260
6261 case MESA_FORMAT_B5G6R5_UINT:
6262 for (i = 0; i < n; ++i) {
6263 unpack_int_b5g6r5_uint(s, dst[i]);
6264 s += 2;
6265 }
6266 break;
6267
6268 case MESA_FORMAT_R5G6B5_UINT:
6269 for (i = 0; i < n; ++i) {
6270 unpack_int_r5g6b5_uint(s, dst[i]);
6271 s += 2;
6272 }
6273 break;
6274
6275 case MESA_FORMAT_B2G3R3_UINT:
6276 for (i = 0; i < n; ++i) {
6277 unpack_int_b2g3r3_uint(s, dst[i]);
6278 s += 1;
6279 }
6280 break;
6281
6282 case MESA_FORMAT_R3G3B2_UINT:
6283 for (i = 0; i < n; ++i) {
6284 unpack_int_r3g3b2_uint(s, dst[i]);
6285 s += 1;
6286 }
6287 break;
6288
6289 case MESA_FORMAT_A4B4G4R4_UINT:
6290 for (i = 0; i < n; ++i) {
6291 unpack_int_a4b4g4r4_uint(s, dst[i]);
6292 s += 2;
6293 }
6294 break;
6295
6296 case MESA_FORMAT_R4G4B4A4_UINT:
6297 for (i = 0; i < n; ++i) {
6298 unpack_int_r4g4b4a4_uint(s, dst[i]);
6299 s += 2;
6300 }
6301 break;
6302
6303 case MESA_FORMAT_B4G4R4A4_UINT:
6304 for (i = 0; i < n; ++i) {
6305 unpack_int_b4g4r4a4_uint(s, dst[i]);
6306 s += 2;
6307 }
6308 break;
6309
6310 case MESA_FORMAT_A4R4G4B4_UINT:
6311 for (i = 0; i < n; ++i) {
6312 unpack_int_a4r4g4b4_uint(s, dst[i]);
6313 s += 2;
6314 }
6315 break;
6316
6317 case MESA_FORMAT_A1B5G5R5_UINT:
6318 for (i = 0; i < n; ++i) {
6319 unpack_int_a1b5g5r5_uint(s, dst[i]);
6320 s += 2;
6321 }
6322 break;
6323
6324 case MESA_FORMAT_B5G5R5A1_UINT:
6325 for (i = 0; i < n; ++i) {
6326 unpack_int_b5g5r5a1_uint(s, dst[i]);
6327 s += 2;
6328 }
6329 break;
6330
6331 case MESA_FORMAT_A1R5G5B5_UINT:
6332 for (i = 0; i < n; ++i) {
6333 unpack_int_a1r5g5b5_uint(s, dst[i]);
6334 s += 2;
6335 }
6336 break;
6337
6338 case MESA_FORMAT_R5G5B5A1_UINT:
6339 for (i = 0; i < n; ++i) {
6340 unpack_int_r5g5b5a1_uint(s, dst[i]);
6341 s += 2;
6342 }
6343 break;
6344
6345 case MESA_FORMAT_A_UINT8:
6346 for (i = 0; i < n; ++i) {
6347 unpack_int_a_uint8(s, dst[i]);
6348 s += 1;
6349 }
6350 break;
6351
6352 case MESA_FORMAT_A_UINT16:
6353 for (i = 0; i < n; ++i) {
6354 unpack_int_a_uint16(s, dst[i]);
6355 s += 2;
6356 }
6357 break;
6358
6359 case MESA_FORMAT_A_UINT32:
6360 for (i = 0; i < n; ++i) {
6361 unpack_int_a_uint32(s, dst[i]);
6362 s += 4;
6363 }
6364 break;
6365
6366 case MESA_FORMAT_A_SINT8:
6367 for (i = 0; i < n; ++i) {
6368 unpack_int_a_sint8(s, dst[i]);
6369 s += 1;
6370 }
6371 break;
6372
6373 case MESA_FORMAT_A_SINT16:
6374 for (i = 0; i < n; ++i) {
6375 unpack_int_a_sint16(s, dst[i]);
6376 s += 2;
6377 }
6378 break;
6379
6380 case MESA_FORMAT_A_SINT32:
6381 for (i = 0; i < n; ++i) {
6382 unpack_int_a_sint32(s, dst[i]);
6383 s += 4;
6384 }
6385 break;
6386
6387 case MESA_FORMAT_I_UINT8:
6388 for (i = 0; i < n; ++i) {
6389 unpack_int_i_uint8(s, dst[i]);
6390 s += 1;
6391 }
6392 break;
6393
6394 case MESA_FORMAT_I_UINT16:
6395 for (i = 0; i < n; ++i) {
6396 unpack_int_i_uint16(s, dst[i]);
6397 s += 2;
6398 }
6399 break;
6400
6401 case MESA_FORMAT_I_UINT32:
6402 for (i = 0; i < n; ++i) {
6403 unpack_int_i_uint32(s, dst[i]);
6404 s += 4;
6405 }
6406 break;
6407
6408 case MESA_FORMAT_I_SINT8:
6409 for (i = 0; i < n; ++i) {
6410 unpack_int_i_sint8(s, dst[i]);
6411 s += 1;
6412 }
6413 break;
6414
6415 case MESA_FORMAT_I_SINT16:
6416 for (i = 0; i < n; ++i) {
6417 unpack_int_i_sint16(s, dst[i]);
6418 s += 2;
6419 }
6420 break;
6421
6422 case MESA_FORMAT_I_SINT32:
6423 for (i = 0; i < n; ++i) {
6424 unpack_int_i_sint32(s, dst[i]);
6425 s += 4;
6426 }
6427 break;
6428
6429 case MESA_FORMAT_L_UINT8:
6430 for (i = 0; i < n; ++i) {
6431 unpack_int_l_uint8(s, dst[i]);
6432 s += 1;
6433 }
6434 break;
6435
6436 case MESA_FORMAT_L_UINT16:
6437 for (i = 0; i < n; ++i) {
6438 unpack_int_l_uint16(s, dst[i]);
6439 s += 2;
6440 }
6441 break;
6442
6443 case MESA_FORMAT_L_UINT32:
6444 for (i = 0; i < n; ++i) {
6445 unpack_int_l_uint32(s, dst[i]);
6446 s += 4;
6447 }
6448 break;
6449
6450 case MESA_FORMAT_L_SINT8:
6451 for (i = 0; i < n; ++i) {
6452 unpack_int_l_sint8(s, dst[i]);
6453 s += 1;
6454 }
6455 break;
6456
6457 case MESA_FORMAT_L_SINT16:
6458 for (i = 0; i < n; ++i) {
6459 unpack_int_l_sint16(s, dst[i]);
6460 s += 2;
6461 }
6462 break;
6463
6464 case MESA_FORMAT_L_SINT32:
6465 for (i = 0; i < n; ++i) {
6466 unpack_int_l_sint32(s, dst[i]);
6467 s += 4;
6468 }
6469 break;
6470
6471 case MESA_FORMAT_LA_UINT8:
6472 for (i = 0; i < n; ++i) {
6473 unpack_int_la_uint8(s, dst[i]);
6474 s += 2;
6475 }
6476 break;
6477
6478 case MESA_FORMAT_LA_UINT16:
6479 for (i = 0; i < n; ++i) {
6480 unpack_int_la_uint16(s, dst[i]);
6481 s += 4;
6482 }
6483 break;
6484
6485 case MESA_FORMAT_LA_UINT32:
6486 for (i = 0; i < n; ++i) {
6487 unpack_int_la_uint32(s, dst[i]);
6488 s += 8;
6489 }
6490 break;
6491
6492 case MESA_FORMAT_LA_SINT8:
6493 for (i = 0; i < n; ++i) {
6494 unpack_int_la_sint8(s, dst[i]);
6495 s += 2;
6496 }
6497 break;
6498
6499 case MESA_FORMAT_LA_SINT16:
6500 for (i = 0; i < n; ++i) {
6501 unpack_int_la_sint16(s, dst[i]);
6502 s += 4;
6503 }
6504 break;
6505
6506 case MESA_FORMAT_LA_SINT32:
6507 for (i = 0; i < n; ++i) {
6508 unpack_int_la_sint32(s, dst[i]);
6509 s += 8;
6510 }
6511 break;
6512
6513 case MESA_FORMAT_R_UINT8:
6514 for (i = 0; i < n; ++i) {
6515 unpack_int_r_uint8(s, dst[i]);
6516 s += 1;
6517 }
6518 break;
6519
6520 case MESA_FORMAT_R_UINT16:
6521 for (i = 0; i < n; ++i) {
6522 unpack_int_r_uint16(s, dst[i]);
6523 s += 2;
6524 }
6525 break;
6526
6527 case MESA_FORMAT_R_UINT32:
6528 for (i = 0; i < n; ++i) {
6529 unpack_int_r_uint32(s, dst[i]);
6530 s += 4;
6531 }
6532 break;
6533
6534 case MESA_FORMAT_R_SINT8:
6535 for (i = 0; i < n; ++i) {
6536 unpack_int_r_sint8(s, dst[i]);
6537 s += 1;
6538 }
6539 break;
6540
6541 case MESA_FORMAT_R_SINT16:
6542 for (i = 0; i < n; ++i) {
6543 unpack_int_r_sint16(s, dst[i]);
6544 s += 2;
6545 }
6546 break;
6547
6548 case MESA_FORMAT_R_SINT32:
6549 for (i = 0; i < n; ++i) {
6550 unpack_int_r_sint32(s, dst[i]);
6551 s += 4;
6552 }
6553 break;
6554
6555 case MESA_FORMAT_RG_UINT8:
6556 for (i = 0; i < n; ++i) {
6557 unpack_int_rg_uint8(s, dst[i]);
6558 s += 2;
6559 }
6560 break;
6561
6562 case MESA_FORMAT_RG_UINT16:
6563 for (i = 0; i < n; ++i) {
6564 unpack_int_rg_uint16(s, dst[i]);
6565 s += 4;
6566 }
6567 break;
6568
6569 case MESA_FORMAT_RG_UINT32:
6570 for (i = 0; i < n; ++i) {
6571 unpack_int_rg_uint32(s, dst[i]);
6572 s += 8;
6573 }
6574 break;
6575
6576 case MESA_FORMAT_RG_SINT8:
6577 for (i = 0; i < n; ++i) {
6578 unpack_int_rg_sint8(s, dst[i]);
6579 s += 2;
6580 }
6581 break;
6582
6583 case MESA_FORMAT_RG_SINT16:
6584 for (i = 0; i < n; ++i) {
6585 unpack_int_rg_sint16(s, dst[i]);
6586 s += 4;
6587 }
6588 break;
6589
6590 case MESA_FORMAT_RG_SINT32:
6591 for (i = 0; i < n; ++i) {
6592 unpack_int_rg_sint32(s, dst[i]);
6593 s += 8;
6594 }
6595 break;
6596
6597 case MESA_FORMAT_RGB_UINT8:
6598 for (i = 0; i < n; ++i) {
6599 unpack_int_rgb_uint8(s, dst[i]);
6600 s += 3;
6601 }
6602 break;
6603
6604 case MESA_FORMAT_RGB_UINT16:
6605 for (i = 0; i < n; ++i) {
6606 unpack_int_rgb_uint16(s, dst[i]);
6607 s += 6;
6608 }
6609 break;
6610
6611 case MESA_FORMAT_RGB_UINT32:
6612 for (i = 0; i < n; ++i) {
6613 unpack_int_rgb_uint32(s, dst[i]);
6614 s += 12;
6615 }
6616 break;
6617
6618 case MESA_FORMAT_RGB_SINT8:
6619 for (i = 0; i < n; ++i) {
6620 unpack_int_rgb_sint8(s, dst[i]);
6621 s += 3;
6622 }
6623 break;
6624
6625 case MESA_FORMAT_RGB_SINT16:
6626 for (i = 0; i < n; ++i) {
6627 unpack_int_rgb_sint16(s, dst[i]);
6628 s += 6;
6629 }
6630 break;
6631
6632 case MESA_FORMAT_RGB_SINT32:
6633 for (i = 0; i < n; ++i) {
6634 unpack_int_rgb_sint32(s, dst[i]);
6635 s += 12;
6636 }
6637 break;
6638
6639 case MESA_FORMAT_RGBA_UINT16:
6640 for (i = 0; i < n; ++i) {
6641 unpack_int_rgba_uint16(s, dst[i]);
6642 s += 8;
6643 }
6644 break;
6645
6646 case MESA_FORMAT_RGBA_UINT32:
6647 for (i = 0; i < n; ++i) {
6648 unpack_int_rgba_uint32(s, dst[i]);
6649 s += 16;
6650 }
6651 break;
6652
6653 case MESA_FORMAT_RGBA_SINT8:
6654 for (i = 0; i < n; ++i) {
6655 unpack_int_rgba_sint8(s, dst[i]);
6656 s += 4;
6657 }
6658 break;
6659
6660 case MESA_FORMAT_RGBA_SINT16:
6661 for (i = 0; i < n; ++i) {
6662 unpack_int_rgba_sint16(s, dst[i]);
6663 s += 8;
6664 }
6665 break;
6666
6667 case MESA_FORMAT_RGBA_SINT32:
6668 for (i = 0; i < n; ++i) {
6669 unpack_int_rgba_sint32(s, dst[i]);
6670 s += 16;
6671 }
6672 break;
6673
6674 case MESA_FORMAT_RGBX_UINT8:
6675 for (i = 0; i < n; ++i) {
6676 unpack_int_rgbx_uint8(s, dst[i]);
6677 s += 4;
6678 }
6679 break;
6680
6681 case MESA_FORMAT_RGBX_UINT16:
6682 for (i = 0; i < n; ++i) {
6683 unpack_int_rgbx_uint16(s, dst[i]);
6684 s += 8;
6685 }
6686 break;
6687
6688 case MESA_FORMAT_RGBX_UINT32:
6689 for (i = 0; i < n; ++i) {
6690 unpack_int_rgbx_uint32(s, dst[i]);
6691 s += 16;
6692 }
6693 break;
6694
6695 case MESA_FORMAT_RGBX_SINT8:
6696 for (i = 0; i < n; ++i) {
6697 unpack_int_rgbx_sint8(s, dst[i]);
6698 s += 4;
6699 }
6700 break;
6701
6702 case MESA_FORMAT_RGBX_SINT16:
6703 for (i = 0; i < n; ++i) {
6704 unpack_int_rgbx_sint16(s, dst[i]);
6705 s += 8;
6706 }
6707 break;
6708
6709 case MESA_FORMAT_RGBX_SINT32:
6710 for (i = 0; i < n; ++i) {
6711 unpack_int_rgbx_sint32(s, dst[i]);
6712 s += 16;
6713 }
6714 break;
6715 default:
6716 unreachable("bad format");
6717 }
6718 }
6719
6720 /**
6721 * Unpack a 2D rect of pixels returning float RGBA colors.
6722 * \param format the source image format
6723 * \param src start address of the source image
6724 * \param srcRowStride source image row stride in bytes
6725 * \param dst start address of the dest image
6726 * \param dstRowStride dest image row stride in bytes
6727 * \param x source image start X pos
6728 * \param y source image start Y pos
6729 * \param width width of rect region to convert
6730 * \param height height of rect region to convert
6731 */
6732 void
_mesa_unpack_rgba_block(mesa_format format,const void * src,int32_t srcRowStride,float dst[][4],int32_t dstRowStride,uint32_t x,uint32_t y,uint32_t width,uint32_t height)6733 _mesa_unpack_rgba_block(mesa_format format,
6734 const void *src, int32_t srcRowStride,
6735 float dst[][4], int32_t dstRowStride,
6736 uint32_t x, uint32_t y, uint32_t width, uint32_t height)
6737 {
6738 const uint32_t srcPixStride = _mesa_get_format_bytes(format);
6739 const uint32_t dstPixStride = 4 * sizeof(float);
6740 const uint8_t *srcRow;
6741 uint8_t *dstRow;
6742 uint32_t i;
6743
6744 /* XXX needs to be fixed for compressed formats */
6745
6746 srcRow = ((const uint8_t *) src) + srcRowStride * y + srcPixStride * x;
6747 dstRow = ((uint8_t *) dst) + dstRowStride * y + dstPixStride * x;
6748
6749 for (i = 0; i < height; i++) {
6750 _mesa_unpack_rgba_row(format, width, srcRow, (float (*)[4]) dstRow);
6751
6752 dstRow += dstRowStride;
6753 srcRow += srcRowStride;
6754 }
6755 }
6756
6757 /** Helper struct for MESA_FORMAT_Z32_FLOAT_S8X24_UINT */
6758 struct z32f_x24s8
6759 {
6760 float z;
6761 uint32_t x24s8;
6762 };
6763
6764 typedef void (*unpack_float_z_func)(uint32_t n, const void *src, float *dst);
6765
6766 static void
unpack_float_z_X8_UINT_Z24_UNORM(uint32_t n,const void * src,float * dst)6767 unpack_float_z_X8_UINT_Z24_UNORM(uint32_t n, const void *src, float *dst)
6768 {
6769 /* only return Z, not stencil data */
6770 const uint32_t *s = ((const uint32_t *) src);
6771 const double scale = 1.0 / (double) 0xffffff;
6772 uint32_t i;
6773 for (i = 0; i < n; i++) {
6774 dst[i] = (float) ((s[i] >> 8) * scale);
6775 assert(dst[i] >= 0.0F);
6776 assert(dst[i] <= 1.0F);
6777 }
6778 }
6779
6780 static void
unpack_float_z_Z24_UNORM_X8_UINT(uint32_t n,const void * src,float * dst)6781 unpack_float_z_Z24_UNORM_X8_UINT(uint32_t n, const void *src, float *dst)
6782 {
6783 /* only return Z, not stencil data */
6784 const uint32_t *s = ((const uint32_t *) src);
6785 const double scale = 1.0 / (double) 0xffffff;
6786 uint32_t i;
6787 for (i = 0; i < n; i++) {
6788 dst[i] = (float) ((s[i] & 0x00ffffff) * scale);
6789 assert(dst[i] >= 0.0F);
6790 assert(dst[i] <= 1.0F);
6791 }
6792 }
6793
6794 static void
unpack_float_Z_UNORM16(uint32_t n,const void * src,float * dst)6795 unpack_float_Z_UNORM16(uint32_t n, const void *src, float *dst)
6796 {
6797 const uint16_t *s = ((const uint16_t *) src);
6798 uint32_t i;
6799 for (i = 0; i < n; i++) {
6800 dst[i] = s[i] * (1.0F / 65535.0F);
6801 }
6802 }
6803
6804 static void
unpack_float_Z_UNORM32(uint32_t n,const void * src,float * dst)6805 unpack_float_Z_UNORM32(uint32_t n, const void *src, float *dst)
6806 {
6807 const uint32_t *s = ((const uint32_t *) src);
6808 uint32_t i;
6809 for (i = 0; i < n; i++) {
6810 dst[i] = s[i] * (1.0F / 0xffffffff);
6811 }
6812 }
6813
6814 static void
unpack_float_Z_FLOAT32(uint32_t n,const void * src,float * dst)6815 unpack_float_Z_FLOAT32(uint32_t n, const void *src, float *dst)
6816 {
6817 memcpy(dst, src, n * sizeof(float));
6818 }
6819
6820 static void
unpack_float_z_Z32X24S8(uint32_t n,const void * src,float * dst)6821 unpack_float_z_Z32X24S8(uint32_t n, const void *src, float *dst)
6822 {
6823 const struct z32f_x24s8 *s = (const struct z32f_x24s8 *) src;
6824 uint32_t i;
6825 for (i = 0; i < n; i++) {
6826 dst[i] = s[i].z;
6827 }
6828 }
6829
6830
6831
6832 /**
6833 * Unpack Z values.
6834 * The returned values will always be in the range [0.0, 1.0].
6835 */
6836 void
_mesa_unpack_float_z_row(mesa_format format,uint32_t n,const void * src,float * dst)6837 _mesa_unpack_float_z_row(mesa_format format, uint32_t n,
6838 const void *src, float *dst)
6839 {
6840 unpack_float_z_func unpack;
6841
6842 switch (format) {
6843 case MESA_FORMAT_S8_UINT_Z24_UNORM:
6844 case MESA_FORMAT_X8_UINT_Z24_UNORM:
6845 unpack = unpack_float_z_X8_UINT_Z24_UNORM;
6846 break;
6847 case MESA_FORMAT_Z24_UNORM_S8_UINT:
6848 case MESA_FORMAT_Z24_UNORM_X8_UINT:
6849 unpack = unpack_float_z_Z24_UNORM_X8_UINT;
6850 break;
6851 case MESA_FORMAT_Z_UNORM16:
6852 unpack = unpack_float_Z_UNORM16;
6853 break;
6854 case MESA_FORMAT_Z_UNORM32:
6855 unpack = unpack_float_Z_UNORM32;
6856 break;
6857 case MESA_FORMAT_Z_FLOAT32:
6858 unpack = unpack_float_Z_FLOAT32;
6859 break;
6860 case MESA_FORMAT_Z32_FLOAT_S8X24_UINT:
6861 unpack = unpack_float_z_Z32X24S8;
6862 break;
6863 default:
6864 unreachable("bad format in _mesa_unpack_float_z_row");
6865 }
6866
6867 unpack(n, src, dst);
6868 }
6869
6870
6871
6872 typedef void (*unpack_uint_z_func)(const void *src, uint32_t *dst, uint32_t n);
6873
6874 static void
unpack_uint_z_X8_UINT_Z24_UNORM(const void * src,uint32_t * dst,uint32_t n)6875 unpack_uint_z_X8_UINT_Z24_UNORM(const void *src, uint32_t *dst, uint32_t n)
6876 {
6877 /* only return Z, not stencil data */
6878 const uint32_t *s = ((const uint32_t *) src);
6879 uint32_t i;
6880 for (i = 0; i < n; i++) {
6881 dst[i] = (s[i] & 0xffffff00) | (s[i] >> 24);
6882 }
6883 }
6884
6885 static void
unpack_uint_z_Z24_UNORM_X8_UINT(const void * src,uint32_t * dst,uint32_t n)6886 unpack_uint_z_Z24_UNORM_X8_UINT(const void *src, uint32_t *dst, uint32_t n)
6887 {
6888 /* only return Z, not stencil data */
6889 const uint32_t *s = ((const uint32_t *) src);
6890 uint32_t i;
6891 for (i = 0; i < n; i++) {
6892 dst[i] = (s[i] << 8) | ((s[i] >> 16) & 0xff);
6893 }
6894 }
6895
6896 static void
unpack_uint_Z_UNORM16(const void * src,uint32_t * dst,uint32_t n)6897 unpack_uint_Z_UNORM16(const void *src, uint32_t *dst, uint32_t n)
6898 {
6899 const uint16_t *s = ((const uint16_t *)src);
6900 uint32_t i;
6901 for (i = 0; i < n; i++) {
6902 dst[i] = (s[i] << 16) | s[i];
6903 }
6904 }
6905
6906 static void
unpack_uint_Z_UNORM32(const void * src,uint32_t * dst,uint32_t n)6907 unpack_uint_Z_UNORM32(const void *src, uint32_t *dst, uint32_t n)
6908 {
6909 memcpy(dst, src, n * sizeof(uint32_t));
6910 }
6911
6912 static void
unpack_uint_Z_FLOAT32(const void * src,uint32_t * dst,uint32_t n)6913 unpack_uint_Z_FLOAT32(const void *src, uint32_t *dst, uint32_t n)
6914 {
6915 const float *s = (const float *)src;
6916 uint32_t i;
6917 for (i = 0; i < n; i++) {
6918 dst[i] = FLOAT_TO_UINT(CLAMP(s[i], 0.0F, 1.0F));
6919 }
6920 }
6921
6922 static void
unpack_uint_Z_FLOAT32_X24S8(const void * src,uint32_t * dst,uint32_t n)6923 unpack_uint_Z_FLOAT32_X24S8(const void *src, uint32_t *dst, uint32_t n)
6924 {
6925 const struct z32f_x24s8 *s = (const struct z32f_x24s8 *) src;
6926 uint32_t i;
6927
6928 for (i = 0; i < n; i++) {
6929 dst[i] = FLOAT_TO_UINT(CLAMP(s[i].z, 0.0F, 1.0F));
6930 }
6931 }
6932
6933
6934 /**
6935 * Unpack Z values.
6936 * The returned values will always be in the range [0, 0xffffffff].
6937 */
6938 void
_mesa_unpack_uint_z_row(mesa_format format,uint32_t n,const void * src,uint32_t * dst)6939 _mesa_unpack_uint_z_row(mesa_format format, uint32_t n,
6940 const void *src, uint32_t *dst)
6941 {
6942 unpack_uint_z_func unpack;
6943 const uint8_t *srcPtr = (uint8_t *) src;
6944
6945 switch (format) {
6946 case MESA_FORMAT_S8_UINT_Z24_UNORM:
6947 case MESA_FORMAT_X8_UINT_Z24_UNORM:
6948 unpack = unpack_uint_z_X8_UINT_Z24_UNORM;
6949 break;
6950 case MESA_FORMAT_Z24_UNORM_S8_UINT:
6951 case MESA_FORMAT_Z24_UNORM_X8_UINT:
6952 unpack = unpack_uint_z_Z24_UNORM_X8_UINT;
6953 break;
6954 case MESA_FORMAT_Z_UNORM16:
6955 unpack = unpack_uint_Z_UNORM16;
6956 break;
6957 case MESA_FORMAT_Z_UNORM32:
6958 unpack = unpack_uint_Z_UNORM32;
6959 break;
6960 case MESA_FORMAT_Z_FLOAT32:
6961 unpack = unpack_uint_Z_FLOAT32;
6962 break;
6963 case MESA_FORMAT_Z32_FLOAT_S8X24_UINT:
6964 unpack = unpack_uint_Z_FLOAT32_X24S8;
6965 break;
6966 default:
6967 unreachable("bad format %s in _mesa_unpack_uint_z_row");
6968 }
6969
6970 unpack(srcPtr, dst, n);
6971 }
6972
6973
6974 static void
unpack_ubyte_s_S_UINT8(const void * src,uint8_t * dst,uint32_t n)6975 unpack_ubyte_s_S_UINT8(const void *src, uint8_t *dst, uint32_t n)
6976 {
6977 memcpy(dst, src, n);
6978 }
6979
6980 static void
unpack_ubyte_s_S8_UINT_Z24_UNORM(const void * src,uint8_t * dst,uint32_t n)6981 unpack_ubyte_s_S8_UINT_Z24_UNORM(const void *src, uint8_t *dst, uint32_t n)
6982 {
6983 uint32_t i;
6984 const uint32_t *src32 = src;
6985
6986 for (i = 0; i < n; i++)
6987 dst[i] = src32[i] & 0xff;
6988 }
6989
6990 static void
unpack_ubyte_s_Z24_UNORM_S8_UINT(const void * src,uint8_t * dst,uint32_t n)6991 unpack_ubyte_s_Z24_UNORM_S8_UINT(const void *src, uint8_t *dst, uint32_t n)
6992 {
6993 uint32_t i;
6994 const uint32_t *src32 = src;
6995
6996 for (i = 0; i < n; i++)
6997 dst[i] = src32[i] >> 24;
6998 }
6999
7000 static void
unpack_ubyte_s_Z32_FLOAT_S8X24_UINT(const void * src,uint8_t * dst,uint32_t n)7001 unpack_ubyte_s_Z32_FLOAT_S8X24_UINT(const void *src, uint8_t *dst, uint32_t n)
7002 {
7003 uint32_t i;
7004 const struct z32f_x24s8 *s = (const struct z32f_x24s8 *) src;
7005
7006 for (i = 0; i < n; i++)
7007 dst[i] = s[i].x24s8 & 0xff;
7008 }
7009
7010 void
_mesa_unpack_ubyte_stencil_row(mesa_format format,uint32_t n,const void * src,uint8_t * dst)7011 _mesa_unpack_ubyte_stencil_row(mesa_format format, uint32_t n,
7012 const void *src, uint8_t *dst)
7013 {
7014 switch (format) {
7015 case MESA_FORMAT_S_UINT8:
7016 unpack_ubyte_s_S_UINT8(src, dst, n);
7017 break;
7018 case MESA_FORMAT_S8_UINT_Z24_UNORM:
7019 unpack_ubyte_s_S8_UINT_Z24_UNORM(src, dst, n);
7020 break;
7021 case MESA_FORMAT_Z24_UNORM_S8_UINT:
7022 unpack_ubyte_s_Z24_UNORM_S8_UINT(src, dst, n);
7023 break;
7024 case MESA_FORMAT_Z32_FLOAT_S8X24_UINT:
7025 unpack_ubyte_s_Z32_FLOAT_S8X24_UINT(src, dst, n);
7026 break;
7027 default:
7028 unreachable("bad format %s in _mesa_unpack_ubyte_s_row");
7029 }
7030 }
7031
7032 static void
unpack_uint_24_8_depth_stencil_Z24_UNORM_S8_UINT(const uint32_t * src,uint32_t * dst,uint32_t n)7033 unpack_uint_24_8_depth_stencil_Z24_UNORM_S8_UINT(const uint32_t *src, uint32_t *dst, uint32_t n)
7034 {
7035 uint32_t i;
7036
7037 for (i = 0; i < n; i++) {
7038 uint32_t val = src[i];
7039 dst[i] = val >> 24 | val << 8;
7040 }
7041 }
7042
7043 static void
unpack_uint_24_8_depth_stencil_Z32_S8X24(const uint32_t * src,uint32_t * dst,uint32_t n)7044 unpack_uint_24_8_depth_stencil_Z32_S8X24(const uint32_t *src,
7045 uint32_t *dst, uint32_t n)
7046 {
7047 uint32_t i;
7048
7049 for (i = 0; i < n; i++) {
7050 /* 8 bytes per pixel (float + uint32) */
7051 float zf = ((float *) src)[i * 2 + 0];
7052 uint32_t z24 = (uint32_t) (zf * (float) 0xffffff);
7053 uint32_t s = src[i * 2 + 1] & 0xff;
7054 dst[i] = (z24 << 8) | s;
7055 }
7056 }
7057
7058 static void
unpack_uint_24_8_depth_stencil_S8_UINT_Z24_UNORM(const uint32_t * src,uint32_t * dst,uint32_t n)7059 unpack_uint_24_8_depth_stencil_S8_UINT_Z24_UNORM(const uint32_t *src, uint32_t *dst, uint32_t n)
7060 {
7061 memcpy(dst, src, n * 4);
7062 }
7063
7064 /**
7065 * Unpack depth/stencil returning as GL_UNSIGNED_INT_24_8.
7066 * \param format the source data format
7067 */
7068 void
_mesa_unpack_uint_24_8_depth_stencil_row(mesa_format format,uint32_t n,const void * src,uint32_t * dst)7069 _mesa_unpack_uint_24_8_depth_stencil_row(mesa_format format, uint32_t n,
7070 const void *src, uint32_t *dst)
7071 {
7072 switch (format) {
7073 case MESA_FORMAT_S8_UINT_Z24_UNORM:
7074 unpack_uint_24_8_depth_stencil_S8_UINT_Z24_UNORM(src, dst, n);
7075 break;
7076 case MESA_FORMAT_Z24_UNORM_S8_UINT:
7077 unpack_uint_24_8_depth_stencil_Z24_UNORM_S8_UINT(src, dst, n);
7078 break;
7079 case MESA_FORMAT_Z32_FLOAT_S8X24_UINT:
7080 unpack_uint_24_8_depth_stencil_Z32_S8X24(src, dst, n);
7081 break;
7082 default:
7083 unreachable("bad format %s in _mesa_unpack_uint_24_8_depth_stencil_row");
7084 }
7085 }
7086
7087 static void
unpack_float_32_uint_24_8_Z24_UNORM_S8_UINT(const uint32_t * src,uint32_t * dst,uint32_t n)7088 unpack_float_32_uint_24_8_Z24_UNORM_S8_UINT(const uint32_t *src,
7089 uint32_t *dst, uint32_t n)
7090 {
7091 uint32_t i;
7092 struct z32f_x24s8 *d = (struct z32f_x24s8 *) dst;
7093 const double scale = 1.0 / (double) 0xffffff;
7094
7095 for (i = 0; i < n; i++) {
7096 const uint32_t z24 = src[i] & 0xffffff;
7097 d[i].z = z24 * scale;
7098 d[i].x24s8 = src[i] >> 24;
7099 assert(d[i].z >= 0.0f);
7100 assert(d[i].z <= 1.0f);
7101 }
7102 }
7103
7104 static void
unpack_float_32_uint_24_8_Z32_FLOAT_S8X24_UINT(const uint32_t * src,uint32_t * dst,uint32_t n)7105 unpack_float_32_uint_24_8_Z32_FLOAT_S8X24_UINT(const uint32_t *src,
7106 uint32_t *dst, uint32_t n)
7107 {
7108 memcpy(dst, src, n * sizeof(struct z32f_x24s8));
7109 }
7110
7111 static void
unpack_float_32_uint_24_8_S8_UINT_Z24_UNORM(const uint32_t * src,uint32_t * dst,uint32_t n)7112 unpack_float_32_uint_24_8_S8_UINT_Z24_UNORM(const uint32_t *src,
7113 uint32_t *dst, uint32_t n)
7114 {
7115 uint32_t i;
7116 struct z32f_x24s8 *d = (struct z32f_x24s8 *) dst;
7117 const double scale = 1.0 / (double) 0xffffff;
7118
7119 for (i = 0; i < n; i++) {
7120 const uint32_t z24 = src[i] >> 8;
7121 d[i].z = z24 * scale;
7122 d[i].x24s8 = src[i] & 0xff;
7123 assert(d[i].z >= 0.0f);
7124 assert(d[i].z <= 1.0f);
7125 }
7126 }
7127
7128 /**
7129 * Unpack depth/stencil returning as GL_FLOAT_32_UNSIGNED_INT_24_8_REV.
7130 * \param format the source data format
7131 *
7132 * In GL_FLOAT_32_UNSIGNED_INT_24_8_REV lower 4 bytes contain float
7133 * component and higher 4 bytes contain packed 24-bit and 8-bit
7134 * components.
7135 *
7136 * 31 30 29 28 ... 4 3 2 1 0 31 30 29 ... 9 8 7 6 5 ... 2 1 0
7137 * +-------------------------+ +--------------------------------+
7138 * | Float Component | | Unused | 8 bit stencil |
7139 * +-------------------------+ +--------------------------------+
7140 * lower 4 bytes higher 4 bytes
7141 */
7142 void
_mesa_unpack_float_32_uint_24_8_depth_stencil_row(mesa_format format,uint32_t n,const void * src,uint32_t * dst)7143 _mesa_unpack_float_32_uint_24_8_depth_stencil_row(mesa_format format, uint32_t n,
7144 const void *src, uint32_t *dst)
7145 {
7146 switch (format) {
7147 case MESA_FORMAT_S8_UINT_Z24_UNORM:
7148 unpack_float_32_uint_24_8_S8_UINT_Z24_UNORM(src, dst, n);
7149 break;
7150 case MESA_FORMAT_Z24_UNORM_S8_UINT:
7151 unpack_float_32_uint_24_8_Z24_UNORM_S8_UINT(src, dst, n);
7152 break;
7153 case MESA_FORMAT_Z32_FLOAT_S8X24_UINT:
7154 unpack_float_32_uint_24_8_Z32_FLOAT_S8X24_UINT(src, dst, n);
7155 break;
7156 default:
7157 unreachable("bad format %s in _mesa_unpack_uint_24_8_depth_stencil_row");
7158 }
7159 }
7160
7161
7162