swr: [rasterizer] Fix Coverity issues reported by Mesa developers.
[mesa.git] / src / gallium / drivers / swr / rasterizer / common / formats.h
1
2 /****************************************************************************
3 * Copyright (C) 2014-2015 Intel Corporation. All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * 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 OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22 * IN THE SOFTWARE.
23 *
24 * @file formats.h
25 *
26 * @brief auto-generated file
27 *
28 * DO NOT EDIT
29 *
30 ******************************************************************************/
31
32 #pragma once
33
34 #include "common/os.h"
35
36 //////////////////////////////////////////////////////////////////////////
37 /// SWR_TYPE - Format component type
38 //////////////////////////////////////////////////////////////////////////
39 enum SWR_TYPE
40 {
41 SWR_TYPE_UNKNOWN,
42 SWR_TYPE_UNUSED,
43 SWR_TYPE_UNORM,
44 SWR_TYPE_SNORM,
45 SWR_TYPE_UINT,
46 SWR_TYPE_SINT,
47 SWR_TYPE_FLOAT,
48 SWR_TYPE_SSCALED,
49 SWR_TYPE_USCALED,
50 };
51 //////////////////////////////////////////////////////////////////////////
52 /// SWR_FORMAT
53 //////////////////////////////////////////////////////////////////////////
54 enum SWR_FORMAT
55 {
56 R32G32B32A32_FLOAT = 0x0,
57 R32G32B32A32_SINT = 0x1,
58 R32G32B32A32_UINT = 0x2,
59 R32G32B32X32_FLOAT = 0x6,
60 R32G32B32A32_SSCALED = 0x7,
61 R32G32B32A32_USCALED = 0x8,
62 R32G32B32_FLOAT = 0x40,
63 R32G32B32_SINT = 0x41,
64 R32G32B32_UINT = 0x42,
65 R32G32B32_SSCALED = 0x45,
66 R32G32B32_USCALED = 0x46,
67 R16G16B16A16_UNORM = 0x80,
68 R16G16B16A16_SNORM = 0x81,
69 R16G16B16A16_SINT = 0x82,
70 R16G16B16A16_UINT = 0x83,
71 R16G16B16A16_FLOAT = 0x84,
72 R32G32_FLOAT = 0x85,
73 R32G32_SINT = 0x86,
74 R32G32_UINT = 0x87,
75 R32_FLOAT_X8X24_TYPELESS = 0x88,
76 X32_TYPELESS_G8X24_UINT = 0x89,
77 L32A32_FLOAT = 0x8A,
78 R16G16B16X16_UNORM = 0x8E,
79 R16G16B16X16_FLOAT = 0x8F,
80 L32X32_FLOAT = 0x91,
81 I32X32_FLOAT = 0x92,
82 R16G16B16A16_SSCALED = 0x93,
83 R16G16B16A16_USCALED = 0x94,
84 R32G32_SSCALED = 0x95,
85 R32G32_USCALED = 0x96,
86 R32_FLOAT_X8X24_TYPELESS_LD = 0x98,
87 B8G8R8A8_UNORM = 0xC0,
88 B8G8R8A8_UNORM_SRGB = 0xC1,
89 R10G10B10A2_UNORM = 0xC2,
90 R10G10B10A2_UNORM_SRGB = 0xC3,
91 R10G10B10A2_UINT = 0xC4,
92 R8G8B8A8_UNORM = 0xC7,
93 R8G8B8A8_UNORM_SRGB = 0xC8,
94 R8G8B8A8_SNORM = 0xC9,
95 R8G8B8A8_SINT = 0xCA,
96 R8G8B8A8_UINT = 0xCB,
97 R16G16_UNORM = 0xCC,
98 R16G16_SNORM = 0xCD,
99 R16G16_SINT = 0xCE,
100 R16G16_UINT = 0xCF,
101 R16G16_FLOAT = 0xD0,
102 B10G10R10A2_UNORM = 0xD1,
103 B10G10R10A2_UNORM_SRGB = 0xD2,
104 R11G11B10_FLOAT = 0xD3,
105 R32_SINT = 0xD6,
106 R32_UINT = 0xD7,
107 R32_FLOAT = 0xD8,
108 R24_UNORM_X8_TYPELESS = 0xD9,
109 R24_UNORM_X8_TYPELESS_LD = 0xDC,
110 L32_UNORM = 0xDD,
111 L16A16_UNORM = 0xDF,
112 I24X8_UNORM = 0xE0,
113 L24X8_UNORM = 0xE1,
114 I32_FLOAT = 0xE3,
115 L32_FLOAT = 0xE4,
116 A32_FLOAT = 0xE5,
117 B8G8R8X8_UNORM = 0xE9,
118 B8G8R8X8_UNORM_SRGB = 0xEA,
119 R8G8B8X8_UNORM = 0xEB,
120 R8G8B8X8_UNORM_SRGB = 0xEC,
121 R9G9B9E5_SHAREDEXP = 0xED,
122 B10G10R10X2_UNORM = 0xEE,
123 L16A16_FLOAT = 0xF0,
124 R10G10B10X2_USCALED = 0xF3,
125 R8G8B8A8_SSCALED = 0xF4,
126 R8G8B8A8_USCALED = 0xF5,
127 R16G16_SSCALED = 0xF6,
128 R16G16_USCALED = 0xF7,
129 R32_SSCALED = 0xF8,
130 R32_USCALED = 0xF9,
131 B5G6R5_UNORM = 0x100,
132 B5G6R5_UNORM_SRGB = 0x101,
133 B5G5R5A1_UNORM = 0x102,
134 B5G5R5A1_UNORM_SRGB = 0x103,
135 B4G4R4A4_UNORM = 0x104,
136 B4G4R4A4_UNORM_SRGB = 0x105,
137 R8G8_UNORM = 0x106,
138 R8G8_SNORM = 0x107,
139 R8G8_SINT = 0x108,
140 R8G8_UINT = 0x109,
141 R16_UNORM = 0x10A,
142 R16_SNORM = 0x10B,
143 R16_SINT = 0x10C,
144 R16_UINT = 0x10D,
145 R16_FLOAT = 0x10E,
146 I16_UNORM = 0x111,
147 L16_UNORM = 0x112,
148 A16_UNORM = 0x113,
149 L8A8_UNORM = 0x114,
150 I16_FLOAT = 0x115,
151 L16_FLOAT = 0x116,
152 A16_FLOAT = 0x117,
153 L8A8_UNORM_SRGB = 0x118,
154 B5G5R5X1_UNORM = 0x11A,
155 B5G5R5X1_UNORM_SRGB = 0x11B,
156 R8G8_SSCALED = 0x11C,
157 R8G8_USCALED = 0x11D,
158 R16_SSCALED = 0x11E,
159 R16_USCALED = 0x11F,
160 L8A8_UINT = 0x126,
161 L8A8_SINT = 0x127,
162 R8_UNORM = 0x140,
163 R8_SNORM = 0x141,
164 R8_SINT = 0x142,
165 R8_UINT = 0x143,
166 A8_UNORM = 0x144,
167 I8_UNORM = 0x145,
168 L8_UNORM = 0x146,
169 R8_SSCALED = 0x149,
170 R8_USCALED = 0x14A,
171 L8_UNORM_SRGB = 0x14C,
172 L8_UINT = 0x152,
173 L8_SINT = 0x153,
174 I8_UINT = 0x154,
175 I8_SINT = 0x155,
176 YCRCB_SWAPUVY = 0x183,
177 BC1_UNORM = 0x186,
178 BC2_UNORM = 0x187,
179 BC3_UNORM = 0x188,
180 BC4_UNORM = 0x189,
181 BC5_UNORM = 0x18A,
182 BC1_UNORM_SRGB = 0x18B,
183 BC2_UNORM_SRGB = 0x18C,
184 BC3_UNORM_SRGB = 0x18D,
185 YCRCB_SWAPUV = 0x18F,
186 R8G8B8_UNORM = 0x193,
187 R8G8B8_SNORM = 0x194,
188 R8G8B8_SSCALED = 0x195,
189 R8G8B8_USCALED = 0x196,
190 BC4_SNORM = 0x199,
191 BC5_SNORM = 0x19A,
192 R16G16B16_FLOAT = 0x19B,
193 R16G16B16_UNORM = 0x19C,
194 R16G16B16_SNORM = 0x19D,
195 R16G16B16_SSCALED = 0x19E,
196 R16G16B16_USCALED = 0x19F,
197 BC6H_SF16 = 0x1A1,
198 BC7_UNORM = 0x1A2,
199 BC7_UNORM_SRGB = 0x1A3,
200 BC6H_UF16 = 0x1A4,
201 R8G8B8_UNORM_SRGB = 0x1A8,
202 R16G16B16_UINT = 0x1B0,
203 R16G16B16_SINT = 0x1B1,
204 R10G10B10A2_SNORM = 0x1B3,
205 R10G10B10A2_USCALED = 0x1B4,
206 R10G10B10A2_SSCALED = 0x1B5,
207 R10G10B10A2_SINT = 0x1B6,
208 B10G10R10A2_SNORM = 0x1B7,
209 B10G10R10A2_USCALED = 0x1B8,
210 B10G10R10A2_SSCALED = 0x1B9,
211 B10G10R10A2_UINT = 0x1BA,
212 B10G10R10A2_SINT = 0x1BB,
213 R8G8B8_UINT = 0x1C8,
214 R8G8B8_SINT = 0x1C9,
215 NUM_SWR_FORMATS = 0x1CA,
216 };
217 //////////////////////////////////////////////////////////////////////////
218 /// SWR_FORMAT_INFO - Format information
219 //////////////////////////////////////////////////////////////////////////
220 struct SWR_FORMAT_INFO
221 {
222 const char* name;
223 SWR_TYPE type[4];
224 uint32_t defaults[4];
225 uint32_t swizzle[4]; ///< swizzle per component
226 uint32_t bpc[4]; ///< bits per component
227 uint32_t bpp; ///< bits per pixel
228 uint32_t Bpp; ///< bytes per pixel
229 uint32_t numComps; ///< number of components
230 bool isSRGB;
231 bool isBC;
232 bool isSubsampled;
233 bool isNormalized[4];
234 float toFloat[4];
235 uint32_t bcWidth;
236 uint32_t bcHeight;
237 bool isLuminance;
238 };
239
240 extern const SWR_FORMAT_INFO gFormatInfo[];
241
242 //////////////////////////////////////////////////////////////////////////
243 /// @brief Retrieves format info struct for given format.
244 /// @param format - SWR format
245 INLINE const SWR_FORMAT_INFO& GetFormatInfo(SWR_FORMAT format)
246 {
247 return gFormatInfo[format];
248 }
249
250 // lookup table for unorm8 srgb -> float conversion
251 extern const uint32_t srgb8Table[256];