1 /*
2  * Mesa 3-D graphics library
3  *
4  * Copyright (c) 2011 VMware, Inc.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22  * OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
25 #ifndef FORMAT_UNPACK_H
26 #define FORMAT_UNPACK_H
27 
28 #include "util/format/u_format.h"
29 #include "formats.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 static inline void
_mesa_unpack_rgba_row(mesa_format format,uint32_t n,const void * src,float dst[][4])36 _mesa_unpack_rgba_row(mesa_format format, uint32_t n,
37                       const void *src, float dst[][4])
38 {
39    util_format_unpack_rgba(format, dst, src, n);
40 }
41 
42 extern void
43 _mesa_unpack_ubyte_rgba_row(mesa_format format, uint32_t n,
44                             const void *src, uint8_t dst[][4]);
45 
46 static inline void
_mesa_unpack_uint_rgba_row(mesa_format format,uint32_t n,const void * src,uint32_t dst[][4])47 _mesa_unpack_uint_rgba_row(mesa_format format, uint32_t n,
48                            const void *src, uint32_t dst[][4])
49 {
50    util_format_unpack_rgba(format, dst, src, n);
51 }
52 
53 static inline void
_mesa_unpack_float_z_row(mesa_format format,uint32_t n,const void * src,float * dst)54 _mesa_unpack_float_z_row(mesa_format format, uint32_t n,
55                          const void *src, float *dst)
56 {
57    util_format_unpack_z_float((enum pipe_format)format, dst, src, n);
58 }
59 
60 
61 static inline void
_mesa_unpack_uint_z_row(mesa_format format,uint32_t n,const void * src,uint32_t * dst)62 _mesa_unpack_uint_z_row(mesa_format format, uint32_t n,
63                         const void *src, uint32_t *dst)
64 {
65    util_format_unpack_z_32unorm((enum pipe_format)format, dst, src, n);
66 }
67 
68 static inline void
_mesa_unpack_ubyte_stencil_row(mesa_format format,uint32_t n,const void * src,uint8_t * dst)69 _mesa_unpack_ubyte_stencil_row(mesa_format format, uint32_t n,
70                                const void *src, uint8_t *dst)
71 {
72    util_format_unpack_s_8uint((enum pipe_format)format, dst, src, n);
73 }
74 
75 void
76 _mesa_unpack_uint_24_8_depth_stencil_row(mesa_format format, uint32_t n,
77                                          const void *src, uint32_t *dst);
78 
79 void
80 _mesa_unpack_float_32_uint_24_8_depth_stencil_row(mesa_format format,
81                                                   uint32_t n,
82                                                   const void *src,
83                                                   uint32_t *dst);
84 
85 #ifdef __cplusplus
86 }
87 #endif
88 
89 #endif /* FORMAT_UNPACK_H */
90