1 /**************************************************************************
3 * Copyright 2009 Vmware, Inc.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
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.
26 **************************************************************************/
33 #include "pipe/p_format.h"
37 * Describe how to best pack/unpack pixels into/from the prescribed format.
39 * These are used for automatic code generation of pixel packing and unpacking
40 * routines (in compile time, e.g., u_format_access.py, or in runtime, like
43 * Thumb rule is: if you're not code generating pixel packing/unpacking then
44 * these are irrelevant for you.
46 * Note that this can be deduced from other values in util_format_description
47 * structure. This is by design, to make code generation of pixel
48 * packing/unpacking/sampling routines simple and efficient.
50 * XXX: This should be renamed to something like util_format_pack.
52 enum util_format_layout
{
54 * Single scalar component.
56 UTIL_FORMAT_LAYOUT_SCALAR
= 0,
59 * One or more components of mixed integer formats, arithmetically encoded
60 * in a word up to 32bits.
62 UTIL_FORMAT_LAYOUT_ARITH
= 1,
65 * One or more components, no mixed formats, each with equal power of two
68 UTIL_FORMAT_LAYOUT_ARRAY
= 2,
71 * XXX: Not used yet. These might go away and be replaced by a single entry,
72 * for formats where multiple pixels have to be
73 * read in order to determine a single pixel value (i.e., block.width > 1
74 * || block.height > 1)
76 UTIL_FORMAT_LAYOUT_YUV
= 3,
77 UTIL_FORMAT_LAYOUT_DXT
= 4
81 struct util_format_block
83 /** Block width in pixels */
86 /** Block height in pixels */
89 /** Block size in bits */
94 enum util_format_type
{
95 UTIL_FORMAT_TYPE_VOID
= 0,
96 UTIL_FORMAT_TYPE_UNSIGNED
= 1,
97 UTIL_FORMAT_TYPE_SIGNED
= 2,
98 UTIL_FORMAT_TYPE_FIXED
= 3,
99 UTIL_FORMAT_TYPE_FLOAT
= 4
103 enum util_format_swizzle
{
104 UTIL_FORMAT_SWIZZLE_X
= 0,
105 UTIL_FORMAT_SWIZZLE_Y
= 1,
106 UTIL_FORMAT_SWIZZLE_Z
= 2,
107 UTIL_FORMAT_SWIZZLE_W
= 3,
108 UTIL_FORMAT_SWIZZLE_0
= 4,
109 UTIL_FORMAT_SWIZZLE_1
= 5,
110 UTIL_FORMAT_SWIZZLE_NONE
= 6
114 enum util_format_colorspace
{
115 UTIL_FORMAT_COLORSPACE_RGB
= 0,
116 UTIL_FORMAT_COLORSPACE_SRGB
= 1,
117 UTIL_FORMAT_COLORSPACE_YUV
= 2,
118 UTIL_FORMAT_COLORSPACE_ZS
= 3,
122 struct util_format_channel_description
125 unsigned normalized
:1;
130 struct util_format_description
132 enum pipe_format format
;
134 struct util_format_block block
;
135 enum util_format_layout layout
;
136 struct util_format_channel_description channel
[4];
137 unsigned char swizzle
[4];
138 enum util_format_colorspace colorspace
;
142 extern const struct util_format_description
143 util_format_description_table
[];
146 const struct util_format_description
*
147 util_format_description(enum pipe_format format
);
151 util_format_read_4f(enum pipe_format format
,
152 float *dst
, unsigned dst_stride
,
153 const void *src
, unsigned src_stride
,
154 unsigned x
, unsigned y
, unsigned w
, unsigned h
);
157 util_format_write_4f(enum pipe_format format
,
158 const float *src
, unsigned src_stride
,
159 void *dst
, unsigned dst_stride
,
160 unsigned x
, unsigned y
, unsigned w
, unsigned h
);
163 util_format_read_4ub(enum pipe_format format
,
164 uint8_t *dst
, unsigned dst_stride
,
165 const void *src
, unsigned src_stride
,
166 unsigned x
, unsigned y
, unsigned w
, unsigned h
);
169 util_format_write_4ub(enum pipe_format format
,
170 const uint8_t *src
, unsigned src_stride
,
171 void *dst
, unsigned dst_stride
,
172 unsigned x
, unsigned y
, unsigned w
, unsigned h
);
174 #endif /* ! U_FORMAT_H */