1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
/**************************************************************************
*
* Copyright 2009 Vmware, Inc.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#ifndef U_FORMAT_H
#define U_FORMAT_H
#include "pipe/p_format.h"
enum util_format_layout {
UTIL_FORMAT_LAYOUT_SCALAR = 0,
UTIL_FORMAT_LAYOUT_ARITH = 1,
UTIL_FORMAT_LAYOUT_ARRAY = 2,
UTIL_FORMAT_LAYOUT_YUV = 3,
UTIL_FORMAT_LAYOUT_DXT = 4
};
struct util_format_block
{
/** Block width in pixels */
unsigned width;
/** Block height in pixels */
unsigned height;
/** Block size in bytes */
unsigned bits;
};
enum util_format_type {
UTIL_FORMAT_TYPE_VOID = 0,
UTIL_FORMAT_TYPE_UNSIGNED = 1,
UTIL_FORMAT_TYPE_SIGNED = 2,
UTIL_FORMAT_TYPE_FIXED = 3,
UTIL_FORMAT_TYPE_FLOAT = 4
};
enum util_format_swizzle {
UTIL_FORMAT_SWIZZLE_X = 0,
UTIL_FORMAT_SWIZZLE_Y = 1,
UTIL_FORMAT_SWIZZLE_Z = 2,
UTIL_FORMAT_SWIZZLE_W = 3,
UTIL_FORMAT_SWIZZLE_0 = 4,
UTIL_FORMAT_SWIZZLE_1 = 5,
UTIL_FORMAT_SWIZZLE_NONE = 6
};
enum util_format_colorspace {
UTIL_FORMAT_COLORSPACE_RGB = 0,
UTIL_FORMAT_COLORSPACE_SRGB = 1,
UTIL_FORMAT_COLORSPACE_YUV = 2,
UTIL_FORMAT_COLORSPACE_ZS = 3,
};
struct util_format_channel_description
{
unsigned type:6;
unsigned normalized:1;
unsigned size:9;
};
struct util_format_description
{
enum pipe_format format;
const char *name;
struct util_format_block block;
enum util_format_layout layout;
struct util_format_channel_description channel[4];
unsigned char swizzle[4];
enum util_format_colorspace colorspace;
};
extern const struct util_format_description
util_format_description_table[];
const struct util_format_description *
util_format_description(enum pipe_format format);
/*
* Format query functions.
*/
static INLINE boolean
util_format_is_compressed(enum pipe_format format)
{
const struct util_format_description *desc = util_format_description(format);
assert(format);
if (!format) {
return FALSE;
}
return desc->layout == UTIL_FORMAT_LAYOUT_DXT ? TRUE : FALSE;
}
static INLINE boolean
util_format_is_depth_or_stencil(enum pipe_format format)
{
const struct util_format_description *desc = util_format_description(format);
assert(format);
if (!format) {
return FALSE;
}
return desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS ? TRUE : FALSE;
}
/*
* Format access functions.
*/
void
util_format_read_4f(enum pipe_format format,
float *dst, unsigned dst_stride,
const void *src, unsigned src_stride,
unsigned x, unsigned y, unsigned w, unsigned h);
void
util_format_write_4f(enum pipe_format format,
const float *src, unsigned src_stride,
void *dst, unsigned dst_stride,
unsigned x, unsigned y, unsigned w, unsigned h);
void
util_format_read_4ub(enum pipe_format format,
uint8_t *dst, unsigned dst_stride,
const void *src, unsigned src_stride,
unsigned x, unsigned y, unsigned w, unsigned h);
void
util_format_write_4ub(enum pipe_format format,
const uint8_t *src, unsigned src_stride,
void *dst, unsigned dst_stride,
unsigned x, unsigned y, unsigned w, unsigned h);
#endif /* ! U_FORMAT_H */
|