isl/formats: Integer formats are not filterable
[mesa.git] / src / intel / isl / isl_format.c
1 /*
2 * Copyright 2015 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 */
23
24 #include <assert.h>
25
26 #include "isl.h"
27 #include "brw_device_info.h"
28
29 struct surface_format_info {
30 bool exists;
31 uint8_t sampling;
32 uint8_t filtering;
33 uint8_t shadow_compare;
34 uint8_t chroma_key;
35 uint8_t render_target;
36 uint8_t alpha_blend;
37 uint8_t input_vb;
38 uint8_t streamed_output_vb;
39 uint8_t color_processing;
40 uint8_t lossless_compression;
41 };
42
43 /* This macro allows us to write the table almost as it appears in the PRM,
44 * while restructuring it to turn it into the C code we want.
45 */
46 #define SF(sampl, filt, shad, ck, rt, ab, vb, so, color, ccs_e, sf) \
47 [ISL_FORMAT_##sf] = { true, sampl, filt, shad, ck, rt, ab, vb, so, color, ccs_e},
48
49 #define Y 0
50 #define x 255
51 /**
52 * This is the table of support for surface (texture, renderbuffer, and vertex
53 * buffer, but not depthbuffer) formats across the various hardware generations.
54 *
55 * The table is formatted to match the documentation, except that the docs have
56 * this ridiculous mapping of Y[*+~^#&] for "supported on DevWhatever". To put
57 * it in our table, here's the mapping:
58 *
59 * Y*: 45
60 * Y+: 45 (g45/gm45)
61 * Y~: 50 (gen5)
62 * Y^: 60 (gen6)
63 * Y#: 70 (gen7)
64 *
65 * The abbreviations in the header below are:
66 * smpl - Sampling Engine
67 * filt - Sampling Engine Filtering
68 * shad - Sampling Engine Shadow Map
69 * CK - Sampling Engine Chroma Key
70 * RT - Render Target
71 * AB - Alpha Blend Render Target
72 * VB - Input Vertex Buffer
73 * SO - Steamed Output Vertex Buffers (transform feedback)
74 * color - Color Processing
75 * ccs_e - Lossless Compression Support (gen9+ only)
76 * sf - Surface Format
77 *
78 * See page 88 of the Sandybridge PRM VOL4_Part1 PDF.
79 *
80 * As of Ivybridge, the columns are no longer in that table and the
81 * information can be found spread across:
82 *
83 * - VOL2_Part1 section 2.5.11 Format Conversion (vertex fetch).
84 * - VOL4_Part1 section 2.12.2.1.2 Sampler Output Channel Mapping.
85 * - VOL4_Part1 section 3.9.11 Render Target Write.
86 * - Render Target Surface Types [SKL+]
87 */
88 static const struct surface_format_info format_info[] = {
89 /* smpl filt shad CK RT AB VB SO color ccs_e */
90 SF( Y, 50, x, x, Y, Y, Y, Y, x, 90, R32G32B32A32_FLOAT)
91 SF( Y, x, x, x, Y, x, Y, Y, x, 90, R32G32B32A32_SINT)
92 SF( Y, x, x, x, Y, x, Y, Y, x, 90, R32G32B32A32_UINT)
93 SF( x, x, x, x, x, x, Y, x, x, x, R32G32B32A32_UNORM)
94 SF( x, x, x, x, x, x, Y, x, x, x, R32G32B32A32_SNORM)
95 SF( x, x, x, x, x, x, Y, x, x, x, R64G64_FLOAT)
96 SF( Y, 50, x, x, x, x, x, x, x, x, R32G32B32X32_FLOAT)
97 SF( x, x, x, x, x, x, Y, x, x, x, R32G32B32A32_SSCALED)
98 SF( x, x, x, x, x, x, Y, x, x, x, R32G32B32A32_USCALED)
99 SF( x, x, x, x, x, x, 75, x, x, x, R32G32B32A32_SFIXED)
100 SF( x, x, x, x, x, x, x, x, x, x, R64G64_PASSTHRU)
101 SF( Y, 50, x, x, x, x, Y, Y, x, x, R32G32B32_FLOAT)
102 SF( Y, x, x, x, x, x, Y, Y, x, x, R32G32B32_SINT)
103 SF( Y, x, x, x, x, x, Y, Y, x, x, R32G32B32_UINT)
104 SF( x, x, x, x, x, x, Y, x, x, x, R32G32B32_UNORM)
105 SF( x, x, x, x, x, x, Y, x, x, x, R32G32B32_SNORM)
106 SF( x, x, x, x, x, x, Y, x, x, x, R32G32B32_SSCALED)
107 SF( x, x, x, x, x, x, Y, x, x, x, R32G32B32_USCALED)
108 SF( x, x, x, x, x, x, 75, x, x, x, R32G32B32_SFIXED)
109 SF( Y, Y, x, x, Y, 45, Y, x, 60, 90, R16G16B16A16_UNORM)
110 SF( Y, Y, x, x, Y, 60, Y, x, x, 90, R16G16B16A16_SNORM)
111 SF( Y, x, x, x, Y, x, Y, x, x, 90, R16G16B16A16_SINT)
112 SF( Y, x, x, x, Y, x, Y, x, x, 90, R16G16B16A16_UINT)
113 SF( Y, Y, x, x, Y, Y, Y, x, x, 90, R16G16B16A16_FLOAT)
114 SF( Y, 50, x, x, Y, Y, Y, Y, x, 90, R32G32_FLOAT)
115 SF( Y, 70, x, x, Y, Y, Y, Y, x, x, R32G32_FLOAT_LD)
116 SF( Y, x, x, x, Y, x, Y, Y, x, 90, R32G32_SINT)
117 SF( Y, x, x, x, Y, x, Y, Y, x, 90, R32G32_UINT)
118 SF( Y, 50, Y, x, x, x, x, x, x, x, R32_FLOAT_X8X24_TYPELESS)
119 SF( Y, x, x, x, x, x, x, x, x, x, X32_TYPELESS_G8X24_UINT)
120 SF( Y, 50, x, x, x, x, x, x, x, x, L32A32_FLOAT)
121 SF( x, x, x, x, x, x, Y, x, x, x, R32G32_UNORM)
122 SF( x, x, x, x, x, x, Y, x, x, x, R32G32_SNORM)
123 SF( x, x, x, x, x, x, Y, x, x, x, R64_FLOAT)
124 SF( Y, Y, x, x, x, x, x, x, x, x, R16G16B16X16_UNORM)
125 SF( Y, Y, x, x, x, x, x, x, x, 90, R16G16B16X16_FLOAT)
126 SF( Y, 50, x, x, x, x, x, x, x, x, A32X32_FLOAT)
127 SF( Y, 50, x, x, x, x, x, x, x, x, L32X32_FLOAT)
128 SF( Y, 50, x, x, x, x, x, x, x, x, I32X32_FLOAT)
129 SF( x, x, x, x, x, x, Y, x, x, x, R16G16B16A16_SSCALED)
130 SF( x, x, x, x, x, x, Y, x, x, x, R16G16B16A16_USCALED)
131 SF( x, x, x, x, x, x, Y, x, x, x, R32G32_SSCALED)
132 SF( x, x, x, x, x, x, Y, x, x, x, R32G32_USCALED)
133 SF( x, x, x, x, x, x, 75, x, x, x, R32G32_SFIXED)
134 SF( x, x, x, x, x, x, x, x, x, x, R64_PASSTHRU)
135 SF( Y, Y, x, Y, Y, Y, Y, x, 60, 90, B8G8R8A8_UNORM)
136 SF( Y, Y, x, x, Y, Y, x, x, x, x, B8G8R8A8_UNORM_SRGB)
137 /* smpl filt shad CK RT AB VB SO color ccs_e */
138 SF( Y, Y, x, x, Y, Y, Y, x, 60, x, R10G10B10A2_UNORM)
139 SF( Y, Y, x, x, x, x, x, x, 60, x, R10G10B10A2_UNORM_SRGB)
140 SF( Y, x, x, x, Y, x, Y, x, x, x, R10G10B10A2_UINT)
141 SF( Y, Y, x, x, x, x, Y, x, x, x, R10G10B10_SNORM_A2_UNORM)
142 SF( Y, Y, x, x, Y, Y, Y, x, 60, 90, R8G8B8A8_UNORM)
143 SF( Y, Y, x, x, Y, Y, x, x, 60, x, R8G8B8A8_UNORM_SRGB)
144 SF( Y, Y, x, x, Y, 60, Y, x, x, 90, R8G8B8A8_SNORM)
145 SF( Y, x, x, x, Y, x, Y, x, x, 90, R8G8B8A8_SINT)
146 SF( Y, x, x, x, Y, x, Y, x, x, 90, R8G8B8A8_UINT)
147 SF( Y, Y, x, x, Y, 45, Y, x, x, 90, R16G16_UNORM)
148 SF( Y, Y, x, x, Y, 60, Y, x, x, 90, R16G16_SNORM)
149 SF( Y, x, x, x, Y, x, Y, x, x, 90, R16G16_SINT)
150 SF( Y, x, x, x, Y, x, Y, x, x, 90, R16G16_UINT)
151 SF( Y, Y, x, x, Y, Y, Y, x, x, 90, R16G16_FLOAT)
152 SF( Y, Y, x, x, Y, Y, 75, x, 60, x, B10G10R10A2_UNORM)
153 SF( Y, Y, x, x, Y, Y, x, x, 60, x, B10G10R10A2_UNORM_SRGB)
154 SF( Y, Y, x, x, Y, Y, Y, x, x, x, R11G11B10_FLOAT)
155 SF( Y, x, x, x, Y, x, Y, Y, x, 90, R32_SINT)
156 SF( Y, x, x, x, Y, x, Y, Y, x, 90, R32_UINT)
157 SF( Y, 50, Y, x, Y, Y, Y, Y, x, 90, R32_FLOAT)
158 SF( Y, 50, Y, x, x, x, x, x, x, x, R24_UNORM_X8_TYPELESS)
159 SF( Y, x, x, x, x, x, x, x, x, x, X24_TYPELESS_G8_UINT)
160 SF( Y, Y, x, x, x, x, x, x, x, x, L16A16_UNORM)
161 SF( Y, 50, Y, x, x, x, x, x, x, x, I24X8_UNORM)
162 SF( Y, 50, Y, x, x, x, x, x, x, x, L24X8_UNORM)
163 SF( Y, 50, Y, x, x, x, x, x, x, x, A24X8_UNORM)
164 SF( Y, 50, Y, x, x, x, x, x, x, x, I32_FLOAT)
165 SF( Y, 50, Y, x, x, x, x, x, x, x, L32_FLOAT)
166 SF( Y, 50, Y, x, x, x, x, x, x, x, A32_FLOAT)
167 SF( Y, Y, x, Y, 80, 80, x, x, 60, 90, B8G8R8X8_UNORM)
168 SF( Y, Y, x, x, 80, 80, x, x, x, x, B8G8R8X8_UNORM_SRGB)
169 SF( Y, Y, x, x, x, x, x, x, x, x, R8G8B8X8_UNORM)
170 SF( Y, Y, x, x, x, x, x, x, x, x, R8G8B8X8_UNORM_SRGB)
171 SF( Y, Y, x, x, x, x, x, x, x, x, R9G9B9E5_SHAREDEXP)
172 SF( Y, Y, x, x, x, x, x, x, x, x, B10G10R10X2_UNORM)
173 SF( Y, Y, x, x, x, x, x, x, x, x, L16A16_FLOAT)
174 SF( x, x, x, x, x, x, Y, x, x, x, R32_UNORM)
175 SF( x, x, x, x, x, x, Y, x, x, x, R32_SNORM)
176 /* smpl filt shad CK RT AB VB SO color ccs_e */
177 SF( x, x, x, x, x, x, Y, x, x, x, R10G10B10X2_USCALED)
178 SF( x, x, x, x, x, x, Y, x, x, x, R8G8B8A8_SSCALED)
179 SF( x, x, x, x, x, x, Y, x, x, x, R8G8B8A8_USCALED)
180 SF( x, x, x, x, x, x, Y, x, x, x, R16G16_SSCALED)
181 SF( x, x, x, x, x, x, Y, x, x, x, R16G16_USCALED)
182 SF( x, x, x, x, x, x, Y, x, x, x, R32_SSCALED)
183 SF( x, x, x, x, x, x, Y, x, x, x, R32_USCALED)
184 SF( Y, Y, x, Y, Y, Y, x, x, x, x, B5G6R5_UNORM)
185 SF( Y, Y, x, x, Y, Y, x, x, x, x, B5G6R5_UNORM_SRGB)
186 SF( Y, Y, x, Y, Y, Y, x, x, x, x, B5G5R5A1_UNORM)
187 SF( Y, Y, x, x, Y, Y, x, x, x, x, B5G5R5A1_UNORM_SRGB)
188 SF( Y, Y, x, Y, Y, Y, x, x, x, x, B4G4R4A4_UNORM)
189 SF( Y, Y, x, x, Y, Y, x, x, x, x, B4G4R4A4_UNORM_SRGB)
190 SF( Y, Y, x, x, Y, Y, Y, x, x, x, R8G8_UNORM)
191 SF( Y, Y, x, Y, Y, 60, Y, x, x, x, R8G8_SNORM)
192 SF( Y, x, x, x, Y, x, Y, x, x, x, R8G8_SINT)
193 SF( Y, x, x, x, Y, x, Y, x, x, x, R8G8_UINT)
194 SF( Y, Y, Y, x, Y, 45, Y, x, 70, x, R16_UNORM)
195 SF( Y, Y, x, x, Y, 60, Y, x, x, x, R16_SNORM)
196 SF( Y, x, x, x, Y, x, Y, x, x, x, R16_SINT)
197 SF( Y, x, x, x, Y, x, Y, x, x, x, R16_UINT)
198 SF( Y, Y, x, x, Y, Y, Y, x, x, x, R16_FLOAT)
199 SF(50, 50, x, x, x, x, x, x, x, x, A8P8_UNORM_PALETTE0)
200 SF(50, 50, x, x, x, x, x, x, x, x, A8P8_UNORM_PALETTE1)
201 SF( Y, Y, Y, x, x, x, x, x, x, x, I16_UNORM)
202 SF( Y, Y, Y, x, x, x, x, x, x, x, L16_UNORM)
203 SF( Y, Y, Y, x, x, x, x, x, x, x, A16_UNORM)
204 SF( Y, Y, x, Y, x, x, x, x, x, x, L8A8_UNORM)
205 SF( Y, Y, Y, x, x, x, x, x, x, x, I16_FLOAT)
206 SF( Y, Y, Y, x, x, x, x, x, x, x, L16_FLOAT)
207 SF( Y, Y, Y, x, x, x, x, x, x, x, A16_FLOAT)
208 SF(45, 45, x, x, x, x, x, x, x, x, L8A8_UNORM_SRGB)
209 SF( Y, Y, x, Y, x, x, x, x, x, x, R5G5_SNORM_B6_UNORM)
210 SF( x, x, x, x, Y, Y, x, x, x, x, B5G5R5X1_UNORM)
211 SF( x, x, x, x, Y, Y, x, x, x, x, B5G5R5X1_UNORM_SRGB)
212 SF( x, x, x, x, x, x, Y, x, x, x, R8G8_SSCALED)
213 SF( x, x, x, x, x, x, Y, x, x, x, R8G8_USCALED)
214 /* smpl filt shad CK RT AB VB SO color ccs_e */
215 SF( x, x, x, x, x, x, Y, x, x, x, R16_SSCALED)
216 SF( x, x, x, x, x, x, Y, x, x, x, R16_USCALED)
217 SF(50, 50, x, x, x, x, x, x, x, x, P8A8_UNORM_PALETTE0)
218 SF(50, 50, x, x, x, x, x, x, x, x, P8A8_UNORM_PALETTE1)
219 SF( x, x, x, x, x, x, x, x, x, x, A1B5G5R5_UNORM)
220 SF(90, 90, x, x, 90, x, x, x, x, x, A4B4G4R4_UNORM)
221 SF(90, x, x, x, x, x, x, x, x, x, L8A8_UINT)
222 SF(90, x, x, x, x, x, x, x, x, x, L8A8_SINT)
223 SF( Y, Y, x, 45, Y, Y, Y, x, x, x, R8_UNORM)
224 SF( Y, Y, x, x, Y, 60, Y, x, x, x, R8_SNORM)
225 SF( Y, x, x, x, Y, x, Y, x, x, x, R8_SINT)
226 SF( Y, x, x, x, Y, x, Y, x, x, x, R8_UINT)
227 SF( Y, Y, x, Y, Y, Y, x, x, x, x, A8_UNORM)
228 SF( Y, Y, x, x, x, x, x, x, x, x, I8_UNORM)
229 SF( Y, Y, x, Y, x, x, x, x, x, x, L8_UNORM)
230 SF( Y, Y, x, x, x, x, x, x, x, x, P4A4_UNORM_PALETTE0)
231 SF( Y, Y, x, x, x, x, x, x, x, x, A4P4_UNORM_PALETTE0)
232 SF( x, x, x, x, x, x, Y, x, x, x, R8_SSCALED)
233 SF( x, x, x, x, x, x, Y, x, x, x, R8_USCALED)
234 SF(45, 45, x, x, x, x, x, x, x, x, P8_UNORM_PALETTE0)
235 SF(45, 45, x, x, x, x, x, x, x, x, L8_UNORM_SRGB)
236 SF(45, 45, x, x, x, x, x, x, x, x, P8_UNORM_PALETTE1)
237 SF(45, 45, x, x, x, x, x, x, x, x, P4A4_UNORM_PALETTE1)
238 SF(45, 45, x, x, x, x, x, x, x, x, A4P4_UNORM_PALETTE1)
239 SF( x, x, x, x, x, x, x, x, x, x, Y8_UNORM)
240 SF(90, x, x, x, x, x, x, x, x, x, L8_UINT)
241 SF(90, x, x, x, x, x, x, x, x, x, L8_SINT)
242 SF(90, x, x, x, x, x, x, x, x, x, I8_UINT)
243 SF(90, x, x, x, x, x, x, x, x, x, I8_SINT)
244 SF(45, 45, x, x, x, x, x, x, x, x, DXT1_RGB_SRGB)
245 SF( Y, Y, x, x, x, x, x, x, x, x, R1_UNORM)
246 SF( Y, Y, x, Y, Y, x, x, x, 60, x, YCRCB_NORMAL)
247 SF( Y, Y, x, Y, Y, x, x, x, 60, x, YCRCB_SWAPUVY)
248 SF(45, 45, x, x, x, x, x, x, x, x, P2_UNORM_PALETTE0)
249 SF(45, 45, x, x, x, x, x, x, x, x, P2_UNORM_PALETTE1)
250 SF( Y, Y, x, Y, x, x, x, x, x, x, BC1_UNORM)
251 SF( Y, Y, x, Y, x, x, x, x, x, x, BC2_UNORM)
252 SF( Y, Y, x, Y, x, x, x, x, x, x, BC3_UNORM)
253 SF( Y, Y, x, x, x, x, x, x, x, x, BC4_UNORM)
254 SF( Y, Y, x, x, x, x, x, x, x, x, BC5_UNORM)
255 SF( Y, Y, x, x, x, x, x, x, x, x, BC1_UNORM_SRGB)
256 SF( Y, Y, x, x, x, x, x, x, x, x, BC2_UNORM_SRGB)
257 SF( Y, Y, x, x, x, x, x, x, x, x, BC3_UNORM_SRGB)
258 SF( Y, x, x, x, x, x, x, x, x, x, MONO8)
259 SF( Y, Y, x, x, Y, x, x, x, 60, x, YCRCB_SWAPUV)
260 SF( Y, Y, x, x, Y, x, x, x, 60, x, YCRCB_SWAPY)
261 SF( Y, Y, x, x, x, x, x, x, x, x, DXT1_RGB)
262 /* smpl filt shad CK RT AB VB SO color ccs_e */
263 SF( Y, Y, x, x, x, x, x, x, x, x, FXT1)
264 SF(75, 75, x, x, x, x, Y, x, x, x, R8G8B8_UNORM)
265 SF(75, 75, x, x, x, x, Y, x, x, x, R8G8B8_SNORM)
266 SF( x, x, x, x, x, x, Y, x, x, x, R8G8B8_SSCALED)
267 SF( x, x, x, x, x, x, Y, x, x, x, R8G8B8_USCALED)
268 SF( x, x, x, x, x, x, Y, x, x, x, R64G64B64A64_FLOAT)
269 SF( x, x, x, x, x, x, Y, x, x, x, R64G64B64_FLOAT)
270 SF( Y, Y, x, x, x, x, x, x, x, x, BC4_SNORM)
271 SF( Y, Y, x, x, x, x, x, x, x, x, BC5_SNORM)
272 SF(50, 50, x, x, x, x, 60, x, x, x, R16G16B16_FLOAT)
273 SF(75, 75, x, x, x, x, Y, x, x, x, R16G16B16_UNORM)
274 SF(75, 75, x, x, x, x, Y, x, x, x, R16G16B16_SNORM)
275 SF( x, x, x, x, x, x, Y, x, x, x, R16G16B16_SSCALED)
276 SF( x, x, x, x, x, x, Y, x, x, x, R16G16B16_USCALED)
277 SF(70, 70, x, x, x, x, x, x, x, x, BC6H_SF16)
278 SF(70, 70, x, x, x, x, x, x, x, x, BC7_UNORM)
279 SF(70, 70, x, x, x, x, x, x, x, x, BC7_UNORM_SRGB)
280 SF(70, 70, x, x, x, x, x, x, x, x, BC6H_UF16)
281 SF( x, x, x, x, x, x, x, x, x, x, PLANAR_420_8)
282 SF(75, 75, x, x, x, x, x, x, x, x, R8G8B8_UNORM_SRGB)
283 SF(80, 80, x, x, x, x, x, x, x, x, ETC1_RGB8)
284 SF(80, 80, x, x, x, x, x, x, x, x, ETC2_RGB8)
285 SF(80, 80, x, x, x, x, x, x, x, x, EAC_R11)
286 SF(80, 80, x, x, x, x, x, x, x, x, EAC_RG11)
287 SF(80, 80, x, x, x, x, x, x, x, x, EAC_SIGNED_R11)
288 SF(80, 80, x, x, x, x, x, x, x, x, EAC_SIGNED_RG11)
289 SF(80, 80, x, x, x, x, x, x, x, x, ETC2_SRGB8)
290 SF(90, x, x, x, x, x, 75, x, x, x, R16G16B16_UINT)
291 SF(90, x, x, x, x, x, 75, x, x, x, R16G16B16_SINT)
292 SF( x, x, x, x, x, x, 75, x, x, x, R32_SFIXED)
293 SF( x, x, x, x, x, x, 75, x, x, x, R10G10B10A2_SNORM)
294 SF( x, x, x, x, x, x, 75, x, x, x, R10G10B10A2_USCALED)
295 SF( x, x, x, x, x, x, 75, x, x, x, R10G10B10A2_SSCALED)
296 SF( x, x, x, x, x, x, 75, x, x, x, R10G10B10A2_SINT)
297 SF( x, x, x, x, x, x, 75, x, x, x, B10G10R10A2_SNORM)
298 SF( x, x, x, x, x, x, 75, x, x, x, B10G10R10A2_USCALED)
299 SF( x, x, x, x, x, x, 75, x, x, x, B10G10R10A2_SSCALED)
300 SF( x, x, x, x, x, x, 75, x, x, x, B10G10R10A2_UINT)
301 SF( x, x, x, x, x, x, 75, x, x, x, B10G10R10A2_SINT)
302 SF( x, x, x, x, x, x, 80, x, x, x, R64G64B64A64_PASSTHRU)
303 SF( x, x, x, x, x, x, 80, x, x, x, R64G64B64_PASSTHRU)
304 SF(80, 80, x, x, x, x, x, x, x, x, ETC2_RGB8_PTA)
305 SF(80, 80, x, x, x, x, x, x, x, x, ETC2_SRGB8_PTA)
306 SF(80, 80, x, x, x, x, x, x, x, x, ETC2_EAC_RGBA8)
307 SF(80, 80, x, x, x, x, x, x, x, x, ETC2_EAC_SRGB8_A8)
308 SF(90, x, x, x, x, x, 75, x, x, x, R8G8B8_UINT)
309 SF(90, x, x, x, x, x, 75, x, x, x, R8G8B8_SINT)
310 SF(80, 80, x, x, x, x, x, x, x, x, ASTC_LDR_2D_4X4_FLT16)
311 SF(80, 80, x, x, x, x, x, x, x, x, ASTC_LDR_2D_5X4_FLT16)
312 SF(80, 80, x, x, x, x, x, x, x, x, ASTC_LDR_2D_5X5_FLT16)
313 SF(80, 80, x, x, x, x, x, x, x, x, ASTC_LDR_2D_6X5_FLT16)
314 SF(80, 80, x, x, x, x, x, x, x, x, ASTC_LDR_2D_6X6_FLT16)
315 SF(80, 80, x, x, x, x, x, x, x, x, ASTC_LDR_2D_8X5_FLT16)
316 SF(80, 80, x, x, x, x, x, x, x, x, ASTC_LDR_2D_8X6_FLT16)
317 SF(80, 80, x, x, x, x, x, x, x, x, ASTC_LDR_2D_8X8_FLT16)
318 SF(80, 80, x, x, x, x, x, x, x, x, ASTC_LDR_2D_10X5_FLT16)
319 SF(80, 80, x, x, x, x, x, x, x, x, ASTC_LDR_2D_10X6_FLT16)
320 SF(80, 80, x, x, x, x, x, x, x, x, ASTC_LDR_2D_10X8_FLT16)
321 SF(80, 80, x, x, x, x, x, x, x, x, ASTC_LDR_2D_10X10_FLT16)
322 SF(80, 80, x, x, x, x, x, x, x, x, ASTC_LDR_2D_12X10_FLT16)
323 SF(80, 80, x, x, x, x, x, x, x, x, ASTC_LDR_2D_12X12_FLT16)
324 SF(80, 80, x, x, x, x, x, x, x, x, ASTC_LDR_2D_4X4_U8SRGB)
325 SF(80, 80, x, x, x, x, x, x, x, x, ASTC_LDR_2D_5X4_U8SRGB)
326 SF(80, 80, x, x, x, x, x, x, x, x, ASTC_LDR_2D_5X5_U8SRGB)
327 SF(80, 80, x, x, x, x, x, x, x, x, ASTC_LDR_2D_6X5_U8SRGB)
328 SF(80, 80, x, x, x, x, x, x, x, x, ASTC_LDR_2D_6X6_U8SRGB)
329 SF(80, 80, x, x, x, x, x, x, x, x, ASTC_LDR_2D_8X5_U8SRGB)
330 SF(80, 80, x, x, x, x, x, x, x, x, ASTC_LDR_2D_8X6_U8SRGB)
331 SF(80, 80, x, x, x, x, x, x, x, x, ASTC_LDR_2D_8X8_U8SRGB)
332 SF(80, 80, x, x, x, x, x, x, x, x, ASTC_LDR_2D_10X5_U8SRGB)
333 SF(80, 80, x, x, x, x, x, x, x, x, ASTC_LDR_2D_10X6_U8SRGB)
334 SF(80, 80, x, x, x, x, x, x, x, x, ASTC_LDR_2D_10X8_U8SRGB)
335 SF(80, 80, x, x, x, x, x, x, x, x, ASTC_LDR_2D_10X10_U8SRGB)
336 SF(80, 80, x, x, x, x, x, x, x, x, ASTC_LDR_2D_12X10_U8SRGB)
337 SF(80, 80, x, x, x, x, x, x, x, x, ASTC_LDR_2D_12X12_U8SRGB)
338 };
339 #undef x
340 #undef Y
341
342 static unsigned
343 format_gen(const struct brw_device_info *devinfo)
344 {
345 return devinfo->gen * 10 + (devinfo->is_g4x || devinfo->is_haswell) * 5;
346 }
347
348 bool
349 isl_format_supports_rendering(const struct brw_device_info *devinfo,
350 enum isl_format format)
351 {
352 if (!format_info[format].exists)
353 return false;
354
355 return format_gen(devinfo) >= format_info[format].render_target;
356 }
357
358 bool
359 isl_format_supports_alpha_blending(const struct brw_device_info *devinfo,
360 enum isl_format format)
361 {
362 if (!format_info[format].exists)
363 return false;
364
365 return format_gen(devinfo) >= format_info[format].alpha_blend;
366 }
367
368 bool
369 isl_format_supports_sampling(const struct brw_device_info *devinfo,
370 enum isl_format format)
371 {
372 if (!format_info[format].exists)
373 return false;
374
375 if (devinfo->is_baytrail) {
376 const struct isl_format_layout *fmtl = isl_format_get_layout(format);
377 /* Support for ETC1 and ETC2 exists on Bay Trail even though big-core
378 * GPUs didn't get it until Broadwell.
379 */
380 if (fmtl->txc == ISL_TXC_ETC1 || fmtl->txc == ISL_TXC_ETC2)
381 return true;
382 }
383
384 return format_gen(devinfo) >= format_info[format].sampling;
385 }
386
387 bool
388 isl_format_supports_filtering(const struct brw_device_info *devinfo,
389 enum isl_format format)
390 {
391 if (!format_info[format].exists)
392 return false;
393
394 if (devinfo->is_baytrail) {
395 const struct isl_format_layout *fmtl = isl_format_get_layout(format);
396 /* Support for ETC1 and ETC2 exists on Bay Trail even though big-core
397 * GPUs didn't get it until Broadwell.
398 */
399 if (fmtl->txc == ISL_TXC_ETC1 || fmtl->txc == ISL_TXC_ETC2)
400 return true;
401 }
402
403 return format_gen(devinfo) >= format_info[format].filtering;
404 }
405
406 bool
407 isl_format_supports_vertex_fetch(const struct brw_device_info *devinfo,
408 enum isl_format format)
409 {
410 if (!format_info[format].exists)
411 return false;
412
413 /* For vertex fetch, Bay Trail supports the same set of formats as Haswell
414 * but is a superset of Ivy Bridge.
415 */
416 if (devinfo->is_baytrail)
417 return 75 >= format_info[format].input_vb;
418
419 return format_gen(devinfo) >= format_info[format].input_vb;
420 }
421
422 bool
423 isl_format_supports_lossless_compression(const struct brw_device_info *devinfo,
424 enum isl_format format)
425 {
426 if (!format_info[format].exists)
427 return false;
428
429 return format_gen(devinfo) >= format_info[format].lossless_compression;
430 }
431
432 static inline bool
433 isl_format_has_channel_type(enum isl_format fmt, enum isl_base_type type)
434 {
435 const struct isl_format_layout *fmtl = isl_format_get_layout(fmt);
436
437 return fmtl->channels.r.type == type ||
438 fmtl->channels.g.type == type ||
439 fmtl->channels.b.type == type ||
440 fmtl->channels.a.type == type ||
441 fmtl->channels.l.type == type ||
442 fmtl->channels.i.type == type ||
443 fmtl->channels.p.type == type;
444 }
445
446 bool
447 isl_format_has_unorm_channel(enum isl_format fmt)
448 {
449 return isl_format_has_channel_type(fmt, ISL_UNORM);
450 }
451
452 bool
453 isl_format_has_snorm_channel(enum isl_format fmt)
454 {
455 return isl_format_has_channel_type(fmt, ISL_SNORM);
456 }
457
458 bool
459 isl_format_has_ufloat_channel(enum isl_format fmt)
460 {
461 return isl_format_has_channel_type(fmt, ISL_UFLOAT);
462 }
463
464 bool
465 isl_format_has_sfloat_channel(enum isl_format fmt)
466 {
467 return isl_format_has_channel_type(fmt, ISL_SFLOAT);
468 }
469
470 bool
471 isl_format_has_uint_channel(enum isl_format fmt)
472 {
473 return isl_format_has_channel_type(fmt, ISL_UINT);
474 }
475
476 bool
477 isl_format_has_sint_channel(enum isl_format fmt)
478 {
479 return isl_format_has_channel_type(fmt, ISL_SINT);
480 }
481
482 unsigned
483 isl_format_get_num_channels(enum isl_format fmt)
484 {
485 const struct isl_format_layout *fmtl = isl_format_get_layout(fmt);
486
487 assert(fmtl->channels.p.bits == 0);
488
489 return (fmtl->channels.r.bits > 0) +
490 (fmtl->channels.g.bits > 0) +
491 (fmtl->channels.b.bits > 0) +
492 (fmtl->channels.a.bits > 0) +
493 (fmtl->channels.l.bits > 0) +
494 (fmtl->channels.i.bits > 0);
495 }
496
497 uint32_t
498 isl_format_get_depth_format(enum isl_format fmt, bool has_stencil)
499 {
500 switch (fmt) {
501 default:
502 unreachable("bad isl depth format");
503 case ISL_FORMAT_R32_FLOAT_X8X24_TYPELESS:
504 assert(has_stencil);
505 return 0; /* D32_FLOAT_S8X24_UINT */
506 case ISL_FORMAT_R32_FLOAT:
507 assert(!has_stencil);
508 return 1; /* D32_FLOAT */
509 case ISL_FORMAT_R24_UNORM_X8_TYPELESS:
510 if (has_stencil) {
511 return 2; /* D24_UNORM_S8_UINT */
512 } else {
513 return 3; /* D24_UNORM_X8_UINT */
514 }
515 case ISL_FORMAT_R16_UNORM:
516 assert(!has_stencil);
517 return 5; /* D16_UNORM */
518 }
519 }
520
521 enum isl_format
522 isl_format_rgb_to_rgba(enum isl_format rgb)
523 {
524 assert(isl_format_is_rgb(rgb));
525
526 switch (rgb) {
527 case ISL_FORMAT_R32G32B32_FLOAT: return ISL_FORMAT_R32G32B32A32_FLOAT;
528 case ISL_FORMAT_R32G32B32_SINT: return ISL_FORMAT_R32G32B32A32_SINT;
529 case ISL_FORMAT_R32G32B32_UINT: return ISL_FORMAT_R32G32B32A32_UINT;
530 case ISL_FORMAT_R32G32B32_UNORM: return ISL_FORMAT_R32G32B32A32_UNORM;
531 case ISL_FORMAT_R32G32B32_SNORM: return ISL_FORMAT_R32G32B32A32_SNORM;
532 case ISL_FORMAT_R32G32B32_SSCALED: return ISL_FORMAT_R32G32B32A32_SSCALED;
533 case ISL_FORMAT_R32G32B32_USCALED: return ISL_FORMAT_R32G32B32A32_USCALED;
534 case ISL_FORMAT_R32G32B32_SFIXED: return ISL_FORMAT_R32G32B32A32_SFIXED;
535 case ISL_FORMAT_R8G8B8_UNORM: return ISL_FORMAT_R8G8B8A8_UNORM;
536 case ISL_FORMAT_R8G8B8_SNORM: return ISL_FORMAT_R8G8B8A8_SNORM;
537 case ISL_FORMAT_R8G8B8_SSCALED: return ISL_FORMAT_R8G8B8A8_SSCALED;
538 case ISL_FORMAT_R8G8B8_USCALED: return ISL_FORMAT_R8G8B8A8_USCALED;
539 case ISL_FORMAT_R16G16B16_FLOAT: return ISL_FORMAT_R16G16B16A16_FLOAT;
540 case ISL_FORMAT_R16G16B16_UNORM: return ISL_FORMAT_R16G16B16A16_UNORM;
541 case ISL_FORMAT_R16G16B16_SNORM: return ISL_FORMAT_R16G16B16A16_SNORM;
542 case ISL_FORMAT_R16G16B16_SSCALED: return ISL_FORMAT_R16G16B16A16_SSCALED;
543 case ISL_FORMAT_R16G16B16_USCALED: return ISL_FORMAT_R16G16B16A16_USCALED;
544 case ISL_FORMAT_R8G8B8_UNORM_SRGB: return ISL_FORMAT_R8G8B8A8_UNORM_SRGB;
545 case ISL_FORMAT_R16G16B16_UINT: return ISL_FORMAT_R16G16B16A16_UINT;
546 case ISL_FORMAT_R16G16B16_SINT: return ISL_FORMAT_R16G16B16A16_SINT;
547 case ISL_FORMAT_R8G8B8_UINT: return ISL_FORMAT_R8G8B8A8_UINT;
548 case ISL_FORMAT_R8G8B8_SINT: return ISL_FORMAT_R8G8B8A8_SINT;
549 default:
550 return ISL_FORMAT_UNSUPPORTED;
551 }
552 }
553
554 enum isl_format
555 isl_format_rgb_to_rgbx(enum isl_format rgb)
556 {
557 assert(isl_format_is_rgb(rgb));
558
559 switch (rgb) {
560 case ISL_FORMAT_R32G32B32_FLOAT:
561 return ISL_FORMAT_R32G32B32X32_FLOAT;
562 case ISL_FORMAT_R16G16B16_UNORM:
563 return ISL_FORMAT_R16G16B16X16_UNORM;
564 case ISL_FORMAT_R16G16B16_FLOAT:
565 return ISL_FORMAT_R16G16B16X16_FLOAT;
566 case ISL_FORMAT_R8G8B8_UNORM:
567 return ISL_FORMAT_R8G8B8X8_UNORM;
568 case ISL_FORMAT_R8G8B8_UNORM_SRGB:
569 return ISL_FORMAT_R8G8B8X8_UNORM_SRGB;
570 default:
571 return ISL_FORMAT_UNSUPPORTED;
572 }
573 }