u_format.h revision 15422b2d99be074e1d6ac064b6f791245975da83
1/**************************************************************************
2 *
3 * Copyright 2009 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#ifndef U_FORMAT_H
30#define U_FORMAT_H
31
32
33#include "pipe/p_format.h"
34
35
36enum util_format_layout {
37   UTIL_FORMAT_LAYOUT_RGBA = 0,
38   UTIL_FORMAT_LAYOUT_ZS = 1,
39   UTIL_FORMAT_LAYOUT_YUV = 2,
40   UTIL_FORMAT_LAYOUT_DXT = 3
41};
42
43
44struct util_format_block
45{
46   /** Block width in pixels */
47   unsigned width;
48
49   /** Block height in pixels */
50   unsigned height;
51
52   /** Block size in bytes */
53   unsigned bits;
54};
55
56
57enum util_format_type {
58   UTIL_FORMAT_TYPE_VOID = 0,
59   UTIL_FORMAT_TYPE_UNSIGNED = 1,
60   UTIL_FORMAT_TYPE_SIGNED = 2,
61   UTIL_FORMAT_TYPE_FIXED = 3,
62   UTIL_FORMAT_TYPE_FLOAT = 4
63};
64
65
66enum util_format_swizzle {
67   UTIL_FORMAT_SWIZZLE_X = 0,
68   UTIL_FORMAT_SWIZZLE_Y = 1,
69   UTIL_FORMAT_SWIZZLE_Z = 2,
70   UTIL_FORMAT_SWIZZLE_W = 3,
71   UTIL_FORMAT_SWIZZLE_0 = 4,
72   UTIL_FORMAT_SWIZZLE_1 = 5,
73   UTIL_FORMAT_SWIZZLE_NONE = 6
74};
75
76
77enum util_format_colorspace {
78   UTIL_FORMAT_COLORSPACE_RGB = 0,
79   UTIL_FORMAT_COLORSPACE_SRGB = 1
80};
81
82
83struct util_format_channel_description
84{
85   unsigned type:6;
86   unsigned normalized:1;
87   unsigned size:9;
88};
89
90
91struct util_format_description
92{
93   enum pipe_format format;
94   const char *name;
95   struct util_format_block block;
96   enum util_format_layout layout;
97   struct util_format_channel_description channel[4];
98   unsigned char swizzle[4];
99   enum util_format_colorspace colorspace;
100};
101
102
103extern const struct util_format_description
104util_format_description_table[];
105
106
107const struct util_format_description *
108util_format_description(enum pipe_format format);
109
110
111#endif /* ! U_FORMAT_H */
112