xref: /aosp_15_r20/external/mesa3d/src/util/u_pack_color.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /**************************************************************************
2  *
3  * Copyright 2008 VMware, Inc.
4  * All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the
8  * "Software"), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish,
10  * distribute, sub license, and/or sell copies of the Software, and to
11  * permit persons to whom the Software is furnished to do so, subject to
12  * the following conditions:
13  *
14  * The above copyright notice and this permission notice (including the
15  * next paragraph) shall be included in all copies or substantial portions
16  * of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21  * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25  *
26  **************************************************************************/
27 
28 /**
29  * @file
30  * Functions to produce packed colors/Z from floats.
31  */
32 
33 
34 #ifndef U_PACK_COLOR_H
35 #define U_PACK_COLOR_H
36 
37 
38 #include "util/compiler.h"
39 #include "util/format/u_formats.h"
40 #include "util/format/u_format.h"
41 #include "util/u_math.h"
42 
43 
44 /**
45  * Helper union for packing pixel values.
46  * Will often contain values in formats which are too complex to be described
47  * in simple terms, hence might just effectively contain a number of bytes.
48  * Must be big enough to hold data for all formats (currently 256 bits).
49  */
50 union util_color {
51    uint8_t ub;
52    uint16_t us;
53    uint32_t ui[4];
54    uint16_t h[4]; /* half float */
55    float f[4];
56    double d[4];
57 };
58 
59 /**
60  * Pack uint8 R,G,B,A into dest pixel.
61  */
62 static inline void
util_pack_color_ub(uint8_t r,uint8_t g,uint8_t b,uint8_t a,enum pipe_format format,union util_color * uc)63 util_pack_color_ub(uint8_t r, uint8_t g, uint8_t b, uint8_t a,
64                    enum pipe_format format, union util_color *uc)
65 {
66    switch (format) {
67    case PIPE_FORMAT_ABGR8888_UNORM:
68       {
69          uc->ui[0] = (r << 24) | (g << 16) | (b << 8) | a;
70       }
71       return;
72    case PIPE_FORMAT_XBGR8888_UNORM:
73       {
74          uc->ui[0] = (r << 24) | (g << 16) | (b << 8) | 0xff;
75       }
76       return;
77    case PIPE_FORMAT_BGRA8888_UNORM:
78       {
79          uc->ui[0] = (a << 24) | (r << 16) | (g << 8) | b;
80       }
81       return;
82    case PIPE_FORMAT_BGRX8888_UNORM:
83       {
84          uc->ui[0] = (0xff << 24) | (r << 16) | (g << 8) | b;
85       }
86       return;
87    case PIPE_FORMAT_ARGB8888_UNORM:
88       {
89          uc->ui[0] = (b << 24) | (g << 16) | (r << 8) | a;
90       }
91       return;
92    case PIPE_FORMAT_XRGB8888_UNORM:
93       {
94          uc->ui[0] = (b << 24) | (g << 16) | (r << 8) | 0xff;
95       }
96       return;
97    case PIPE_FORMAT_B5G6R5_UNORM:
98       {
99          uc->us = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | (b >> 3);
100       }
101       return;
102    case PIPE_FORMAT_B5G5R5X1_UNORM:
103       {
104          uc->us = ((0x80) << 8) | ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | (b >> 3);
105       }
106       return;
107    case PIPE_FORMAT_B5G5R5A1_UNORM:
108       {
109          uc->us = ((a & 0x80) << 8) | ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | (b >> 3);
110       }
111       return;
112    case PIPE_FORMAT_B4G4R4A4_UNORM:
113       {
114          uc->us = ((a & 0xf0) << 8) | ((r & 0xf0) << 4) | ((g & 0xf0) << 0) | (b >> 4);
115       }
116       return;
117    case PIPE_FORMAT_A8_UNORM:
118       {
119          uc->ub = a;
120       }
121       return;
122    case PIPE_FORMAT_L8_UNORM:
123    case PIPE_FORMAT_I8_UNORM:
124       {
125          uc->ub = r;
126       }
127       return;
128    case PIPE_FORMAT_R32G32B32A32_FLOAT:
129       {
130          uc->f[0] = (float)r / 255.0f;
131          uc->f[1] = (float)g / 255.0f;
132          uc->f[2] = (float)b / 255.0f;
133          uc->f[3] = (float)a / 255.0f;
134       }
135       return;
136    case PIPE_FORMAT_R32G32B32_FLOAT:
137       {
138          uc->f[0] = (float)r / 255.0f;
139          uc->f[1] = (float)g / 255.0f;
140          uc->f[2] = (float)b / 255.0f;
141       }
142       return;
143 
144    /* Handle other cases with a generic function.
145     */
146    default:
147       {
148          uint8_t src[4];
149 
150          src[0] = r;
151          src[1] = g;
152          src[2] = b;
153          src[3] = a;
154          util_format_write_4ub(format, src, 0, uc, 0, 0, 0, 1, 1);
155       }
156    }
157 }
158 
159 
160 /**
161  * Unpack RGBA from a packed pixel, returning values as uint8_ts in [0,255].
162  */
163 static inline void
util_unpack_color_ub(enum pipe_format format,union util_color * uc,uint8_t * r,uint8_t * g,uint8_t * b,uint8_t * a)164 util_unpack_color_ub(enum pipe_format format, union util_color *uc,
165                      uint8_t *r, uint8_t *g, uint8_t *b, uint8_t *a)
166 {
167    switch (format) {
168    case PIPE_FORMAT_ABGR8888_UNORM:
169       {
170          uint32_t p = uc->ui[0];
171          *r = (uint8_t) ((p >> 24) & 0xff);
172          *g = (uint8_t) ((p >> 16) & 0xff);
173          *b = (uint8_t) ((p >>  8) & 0xff);
174          *a = (uint8_t) ((p >>  0) & 0xff);
175       }
176       return;
177    case PIPE_FORMAT_XBGR8888_UNORM:
178       {
179          uint32_t p = uc->ui[0];
180          *r = (uint8_t) ((p >> 24) & 0xff);
181          *g = (uint8_t) ((p >> 16) & 0xff);
182          *b = (uint8_t) ((p >>  8) & 0xff);
183          *a = (uint8_t) 0xff;
184       }
185       return;
186    case PIPE_FORMAT_BGRA8888_UNORM:
187       {
188          uint32_t p = uc->ui[0];
189          *r = (uint8_t) ((p >> 16) & 0xff);
190          *g = (uint8_t) ((p >>  8) & 0xff);
191          *b = (uint8_t) ((p >>  0) & 0xff);
192          *a = (uint8_t) ((p >> 24) & 0xff);
193       }
194       return;
195    case PIPE_FORMAT_BGRX8888_UNORM:
196       {
197          uint32_t p = uc->ui[0];
198          *r = (uint8_t) ((p >> 16) & 0xff);
199          *g = (uint8_t) ((p >>  8) & 0xff);
200          *b = (uint8_t) ((p >>  0) & 0xff);
201          *a = (uint8_t) 0xff;
202       }
203       return;
204    case PIPE_FORMAT_ARGB8888_UNORM:
205       {
206          uint32_t p = uc->ui[0];
207          *r = (uint8_t) ((p >>  8) & 0xff);
208          *g = (uint8_t) ((p >> 16) & 0xff);
209          *b = (uint8_t) ((p >> 24) & 0xff);
210          *a = (uint8_t) ((p >>  0) & 0xff);
211       }
212       return;
213    case PIPE_FORMAT_XRGB8888_UNORM:
214       {
215          uint32_t p = uc->ui[0];
216          *r = (uint8_t) ((p >>  8) & 0xff);
217          *g = (uint8_t) ((p >> 16) & 0xff);
218          *b = (uint8_t) ((p >> 24) & 0xff);
219          *a = (uint8_t) 0xff;
220       }
221       return;
222    case PIPE_FORMAT_B5G6R5_UNORM:
223       {
224          uint16_t p = uc->us;
225          *r = (uint8_t) (((p >> 8) & 0xf8) | ((p >> 13) & 0x7));
226          *g = (uint8_t) (((p >> 3) & 0xfc) | ((p >>  9) & 0x3));
227          *b = (uint8_t) (((p << 3) & 0xf8) | ((p >>  2) & 0x7));
228          *a = (uint8_t) 0xff;
229       }
230       return;
231    case PIPE_FORMAT_B5G5R5X1_UNORM:
232       {
233          uint16_t p = uc->us;
234          *r = (uint8_t) (((p >>  7) & 0xf8) | ((p >> 12) & 0x7));
235          *g = (uint8_t) (((p >>  2) & 0xf8) | ((p >>  7) & 0x7));
236          *b = (uint8_t) (((p <<  3) & 0xf8) | ((p >>  2) & 0x7));
237          *a = (uint8_t) 0xff;
238       }
239       return;
240    case PIPE_FORMAT_B5G5R5A1_UNORM:
241       {
242          uint16_t p = uc->us;
243          *r = (uint8_t) (((p >>  7) & 0xf8) | ((p >> 12) & 0x7));
244          *g = (uint8_t) (((p >>  2) & 0xf8) | ((p >>  7) & 0x7));
245          *b = (uint8_t) (((p <<  3) & 0xf8) | ((p >>  2) & 0x7));
246          *a = (uint8_t) (0xff * (p >> 15));
247       }
248       return;
249    case PIPE_FORMAT_B4G4R4A4_UNORM:
250       {
251          uint16_t p = uc->us;
252          *r = (uint8_t) (((p >> 4) & 0xf0) | ((p >>  8) & 0xf));
253          *g = (uint8_t) (((p >> 0) & 0xf0) | ((p >>  4) & 0xf));
254          *b = (uint8_t) (((p << 4) & 0xf0) | ((p >>  0) & 0xf));
255          *a = (uint8_t) (((p >> 8) & 0xf0) | ((p >> 12) & 0xf));
256       }
257       return;
258    case PIPE_FORMAT_A8_UNORM:
259       {
260          uint8_t p = uc->ub;
261          *r = *g = *b = (uint8_t) 0xff;
262          *a = p;
263       }
264       return;
265    case PIPE_FORMAT_L8_UNORM:
266       {
267          uint8_t p = uc->ub;
268          *r = *g = *b = p;
269          *a = (uint8_t) 0xff;
270       }
271       return;
272    case PIPE_FORMAT_I8_UNORM:
273       {
274          uint8_t p = uc->ub;
275          *r = *g = *b = *a = p;
276       }
277       return;
278    case PIPE_FORMAT_R32G32B32A32_FLOAT:
279       {
280          const float *p = &uc->f[0];
281          *r = float_to_ubyte(p[0]);
282          *g = float_to_ubyte(p[1]);
283          *b = float_to_ubyte(p[2]);
284          *a = float_to_ubyte(p[3]);
285       }
286       return;
287    case PIPE_FORMAT_R32G32B32_FLOAT:
288       {
289          const float *p = &uc->f[0];
290          *r = float_to_ubyte(p[0]);
291          *g = float_to_ubyte(p[1]);
292          *b = float_to_ubyte(p[2]);
293          *a = (uint8_t) 0xff;
294       }
295       return;
296 
297    case PIPE_FORMAT_R32G32_FLOAT:
298       {
299          const float *p = &uc->f[0];
300          *r = float_to_ubyte(p[0]);
301          *g = float_to_ubyte(p[1]);
302          *b = *a = (uint8_t) 0xff;
303       }
304       return;
305 
306    case PIPE_FORMAT_R32_FLOAT:
307       {
308          const float *p = &uc->f[0];
309          *r = float_to_ubyte(p[0]);
310          *g = *b = *a = (uint8_t) 0xff;
311       }
312       return;
313 
314    /* Handle other cases with a generic function.
315     */
316    default:
317       {
318          uint8_t dst[4];
319 
320          util_format_read_4ub(format, dst, 0, uc, 0, 0, 0, 1, 1);
321          *r = dst[0];
322          *g = dst[1];
323          *b = dst[2];
324          *a = dst[3];
325       }
326    }
327 }
328 
329 
330 /**
331  * Note rgba outside [0,1] will be clamped for int pixel formats.
332  * This will not work (and might not really be useful with float input)
333  * for pure integer formats (which lack the pack_rgba_float function).
334  */
335 static inline void
util_pack_color(const float rgba[4],enum pipe_format format,union util_color * uc)336 util_pack_color(const float rgba[4], enum pipe_format format, union util_color *uc)
337 {
338    uint8_t r = 0;
339    uint8_t g = 0;
340    uint8_t b = 0;
341    uint8_t a = 0;
342 
343    if (util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0) <= 8) {
344       /* format uses 8-bit components or less */
345       r = float_to_ubyte(rgba[0]);
346       g = float_to_ubyte(rgba[1]);
347       b = float_to_ubyte(rgba[2]);
348       a = float_to_ubyte(rgba[3]);
349    }
350 
351 #define PACK32(r,g,b,a) (((uint32_t)(r) << 24) | \
352                          ((uint32_t)(g) << 16) | \
353                          ((uint32_t)(b) <<  8) | \
354                           (uint32_t)(a))
355 
356    switch (format) {
357    case PIPE_FORMAT_ABGR8888_UNORM:
358       {
359          uc->ui[0] = PACK32(r, g, b, a);
360       }
361       return;
362    case PIPE_FORMAT_XBGR8888_UNORM:
363       {
364          uc->ui[0] = PACK32(r, g, b, 0xff);
365       }
366       return;
367    case PIPE_FORMAT_BGRA8888_UNORM:
368       {
369          uc->ui[0] = PACK32(a, r, g, b);
370       }
371       return;
372    case PIPE_FORMAT_BGRX8888_UNORM:
373       {
374          uc->ui[0] = PACK32(0xff, r, g, b);
375       }
376       return;
377    case PIPE_FORMAT_ARGB8888_UNORM:
378       {
379          uc->ui[0] = PACK32(b, g, r, a);
380       }
381       return;
382    case PIPE_FORMAT_XRGB8888_UNORM:
383       {
384          uc->ui[0] = PACK32(b, g, r, 0xff);
385       }
386       return;
387    case PIPE_FORMAT_B5G6R5_UNORM:
388       {
389          uc->us = (((uint16_t)r & 0xf8) << 8) |
390                   (((uint16_t)g & 0xfc) << 3) |
391                   ((uint16_t)b >> 3);
392       }
393       return;
394    case PIPE_FORMAT_B5G5R5X1_UNORM:
395       {
396          uc->us = ((uint16_t)0x80 << 8) |
397                   (((uint16_t)r & 0xf8) << 7) |
398                   (((uint16_t)g & 0xf8) << 2) |
399                   ((uint16_t)b >> 3);
400       }
401       return;
402    case PIPE_FORMAT_B5G5R5A1_UNORM:
403       {
404          uc->us = (((uint16_t)a & 0x80) << 8) |
405                   (((uint16_t)r & 0xf8) << 7) |
406                   (((uint16_t)g & 0xf8) << 2) |
407                   ((uint16_t)b >> 3);
408       }
409       return;
410    case PIPE_FORMAT_B4G4R4A4_UNORM:
411       {
412          uc->us = (((uint16_t)a & 0xf0) << 8) |
413                   (((uint16_t)r & 0xf0) << 4) |
414                   (((uint16_t)g & 0xf0) << 0) |
415                   ((uint16_t)b >> 4);
416       }
417       return;
418    case PIPE_FORMAT_A8_UNORM:
419       {
420          uc->ub = a;
421       }
422       return;
423    case PIPE_FORMAT_L8_UNORM:
424    case PIPE_FORMAT_I8_UNORM:
425       {
426          uc->ub = r;
427       }
428       return;
429    case PIPE_FORMAT_R32G32B32A32_FLOAT:
430       {
431          uc->f[0] = rgba[0];
432          uc->f[1] = rgba[1];
433          uc->f[2] = rgba[2];
434          uc->f[3] = rgba[3];
435       }
436       return;
437    case PIPE_FORMAT_R32G32B32_FLOAT:
438       {
439          uc->f[0] = rgba[0];
440          uc->f[1] = rgba[1];
441          uc->f[2] = rgba[2];
442       }
443       return;
444 
445 #undef PACK32
446 
447    /* Handle other cases with a generic function.
448     */
449    default:
450       util_format_pack_rgba(format, uc, rgba, 1);
451    }
452 }
453 
454 static inline void
util_pack_color_union(enum pipe_format format,union util_color * dst,const union pipe_color_union * src)455 util_pack_color_union(enum pipe_format format,
456                       union util_color *dst,
457                       const union pipe_color_union *src)
458 {
459    util_format_pack_rgba(format, dst, &src->ui, 1);
460 }
461 
462 /* Integer versions of util_pack_z and util_pack_z_stencil - useful for
463  * constructing clear masks.
464  */
465 static inline uint32_t
util_pack_mask_z(enum pipe_format format,uint32_t z)466 util_pack_mask_z(enum pipe_format format, uint32_t z)
467 {
468    switch (format) {
469    case PIPE_FORMAT_Z16_UNORM:
470       return z & 0xffff;
471    case PIPE_FORMAT_Z32_UNORM:
472    case PIPE_FORMAT_Z32_FLOAT:
473       return z;
474    case PIPE_FORMAT_Z24_UNORM_S8_UINT:
475    case PIPE_FORMAT_Z24X8_UNORM:
476       return z & 0xffffff;
477    case PIPE_FORMAT_S8_UINT_Z24_UNORM:
478    case PIPE_FORMAT_X8Z24_UNORM:
479       return (z & 0xffffff) << 8;
480    case PIPE_FORMAT_S8_UINT:
481       return 0;
482    default:
483       debug_printf("gallium: unhandled format in util_pack_mask_z(): %s\n",
484                    util_format_name(format));
485       assert(0);
486       return 0;
487    }
488 }
489 
490 
491 static inline uint64_t
util_pack64_mask_z(enum pipe_format format,uint32_t z)492 util_pack64_mask_z(enum pipe_format format, uint32_t z)
493 {
494    switch (format) {
495    case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT:
496       return z;
497    default:
498       return util_pack_mask_z(format, z);
499    }
500 }
501 
502 
503 static inline uint32_t
util_pack_mask_z_stencil(enum pipe_format format,uint32_t z,uint8_t s)504 util_pack_mask_z_stencil(enum pipe_format format, uint32_t z, uint8_t s)
505 {
506    uint32_t packed = util_pack_mask_z(format, z);
507 
508    switch (format) {
509    case PIPE_FORMAT_Z24_UNORM_S8_UINT:
510       packed |= (uint32_t)s << 24;
511       break;
512    case PIPE_FORMAT_S8_UINT_Z24_UNORM:
513       packed |= s;
514       break;
515    case PIPE_FORMAT_S8_UINT:
516       packed |= s;
517       break;
518    default:
519       break;
520    }
521 
522    return packed;
523 }
524 
525 
526 static inline uint64_t
util_pack64_mask_z_stencil(enum pipe_format format,uint32_t z,uint8_t s)527 util_pack64_mask_z_stencil(enum pipe_format format, uint32_t z, uint8_t s)
528 {
529    uint64_t packed;
530 
531    switch (format) {
532    case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT:
533       packed = util_pack64_mask_z(format, z);
534       packed |= (uint64_t)s << 32ull;
535       return packed;
536    default:
537       return util_pack_mask_z_stencil(format, z, s);
538    }
539 }
540 
541 
542 /**
543  * Note: it's assumed that z is in [0,1]
544  */
545 static inline uint32_t
util_pack_z(enum pipe_format format,double z)546 util_pack_z(enum pipe_format format, double z)
547 {
548    union fi fui;
549 
550    if (format == PIPE_FORMAT_Z32_FLOAT) {
551       fui.f = (float)z;
552       return fui.ui;
553    }
554 
555    if (z <= 0.0)
556       return 0;
557 
558    switch (format) {
559    case PIPE_FORMAT_Z16_UNORM:
560       if (z >= 1.0)
561          return 0xffff;
562       return (uint32_t) lrint(z * 0xffff);
563    case PIPE_FORMAT_Z32_UNORM:
564       /* special-case to avoid overflow */
565       if (z >= 1.0)
566          return 0xffffffff;
567       return (uint32_t) llrint(z * 0xffffffff);
568    case PIPE_FORMAT_Z24_UNORM_S8_UINT:
569    case PIPE_FORMAT_Z24X8_UNORM:
570       if (z >= 1.0)
571          return 0xffffff;
572       return (uint32_t) lrint(z * 0xffffff);
573    case PIPE_FORMAT_S8_UINT_Z24_UNORM:
574    case PIPE_FORMAT_X8Z24_UNORM:
575       if (z >= 1.0)
576          return 0xffffff00;
577       return ((uint32_t) lrint(z * 0xffffff)) << 8;
578    case PIPE_FORMAT_S8_UINT:
579       /* this case can get it via util_pack_z_stencil() */
580       return 0;
581    default:
582       debug_printf("gallium: unhandled format in util_pack_z(): %s\n",
583                    util_format_name(format));
584       assert(0);
585       return 0;
586    }
587 }
588 
589 
590 static inline uint64_t
util_pack64_z(enum pipe_format format,double z)591 util_pack64_z(enum pipe_format format, double z)
592 {
593    union fi fui;
594 
595    if (z == 0)
596       return 0;
597 
598    switch (format) {
599    case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT:
600       fui.f = (float)z;
601       return fui.ui;
602    default:
603       return util_pack_z(format, z);
604    }
605 }
606 
607 
608 /**
609  * Pack Z and/or stencil values into a 32-bit value described by format.
610  * Note: it's assumed that z is in [0,1] and s in [0,255]
611  */
612 static inline uint32_t
util_pack_z_stencil(enum pipe_format format,double z,uint8_t s)613 util_pack_z_stencil(enum pipe_format format, double z, uint8_t s)
614 {
615    uint32_t packed = util_pack_z(format, z);
616 
617    switch (format) {
618    case PIPE_FORMAT_Z24_UNORM_S8_UINT:
619       packed |= (uint32_t)s << 24;
620       break;
621    case PIPE_FORMAT_S8_UINT_Z24_UNORM:
622       packed |= s;
623       break;
624    case PIPE_FORMAT_S8_UINT:
625       packed |= s;
626       break;
627    default:
628       break;
629    }
630 
631    return packed;
632 }
633 
634 
635 static inline uint64_t
util_pack64_z_stencil(enum pipe_format format,double z,uint8_t s)636 util_pack64_z_stencil(enum pipe_format format, double z, uint8_t s)
637 {
638    uint64_t packed;
639 
640    switch (format) {
641    case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT:
642       packed = util_pack64_z(format, z);
643       packed |= (uint64_t)s << 32ull;
644       break;
645    default:
646       return util_pack_z_stencil(format, z, s);
647    }
648 
649    return packed;
650 }
651 
652 
653 /**
654  * Pack 4 uint8_ts into a 4-byte word
655  */
656 static inline uint32_t
pack_ub4(uint8_t b0,uint8_t b1,uint8_t b2,uint8_t b3)657 pack_ub4(uint8_t b0, uint8_t b1, uint8_t b2, uint8_t b3)
658 {
659    return ((((uint32_t)b0) << 0) |
660 	   (((uint32_t)b1) << 8) |
661 	   (((uint32_t)b2) << 16) |
662 	   (((uint32_t)b3) << 24));
663 }
664 
665 
666 /**
667  * Pack/convert 4 floats into one 4-byte word.
668  */
669 static inline uint32_t
pack_ui32_float4(float a,float b,float c,float d)670 pack_ui32_float4(float a, float b, float c, float d)
671 {
672    return pack_ub4( float_to_ubyte(a),
673 		    float_to_ubyte(b),
674 		    float_to_ubyte(c),
675 		    float_to_ubyte(d) );
676 }
677 
678 
679 
680 #endif /* U_PACK_COLOR_H */
681