• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2010 Christoph Bumiller
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 shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20  * OTHER DEALINGS IN THE SOFTWARE.
21  */
22 
23 #if NOUVEAU_DRIVER == 0xc0
24 # include "nvc0/nvc0_screen.h"
25 # include "nvc0/nvc0_3d.xml.h"
26 # include "nvc0/gm107_texture.xml.h"
27 #else
28 # include "nv50/nv50_screen.h"
29 # include "nv50/nv50_3d.xml.h"
30 #endif
31 #include "nv50/g80_texture.xml.h"
32 #include "nv50/g80_defs.xml.h"
33 
34 #include "pipe/p_defines.h"
35 
36 /* Abbreviated usage masks:
37  * T: texturing
38  * R: render target
39  * B: render target, blendable
40  * C: render target (color), blendable only on nvc0
41  * D: scanout/display target, blendable
42  * Z: depth/stencil
43  * I: image / surface, implies T
44  */
45 #define U_T   PIPE_BIND_SAMPLER_VIEW
46 #define U_I   PIPE_BIND_SHADER_BUFFER | PIPE_BIND_SHADER_IMAGE | PIPE_BIND_COMPUTE_RESOURCE
47 #define U_TR  PIPE_BIND_RENDER_TARGET | U_T
48 #define U_IR  U_TR | U_I
49 #define U_TB  PIPE_BIND_BLENDABLE | U_TR
50 #define U_IB  PIPE_BIND_BLENDABLE | U_IR
51 #define U_TD  PIPE_BIND_SCANOUT | PIPE_BIND_DISPLAY_TARGET | U_TB
52 #define U_TZ  PIPE_BIND_DEPTH_STENCIL | U_T
53 #define U_ID  U_TD | U_I
54 #if NOUVEAU_DRIVER == 0xc0
55 # define U_TC  U_TB
56 # define U_IC  U_IB
57 # define U_t   U_T
58 #else
59 # define U_TC  U_TR
60 # define U_IC  U_IR
61 # define U_t   0
62 #endif
63 
64 #define G80_ZETA_FORMAT_NONE    0
65 #define G80_SURFACE_FORMAT_NONE 0
66 
67 #define SF_A(sz) G80_TIC_0_COMPONENTS_SIZES_##sz
68 #define SF_B(sz) G200_TIC_0_COMPONENTS_SIZES_##sz
69 #define SF_C(sz) GF100_TIC_0_COMPONENTS_SIZES_##sz
70 #define SF_D(sz) GM107_TIC2_0_COMPONENTS_SIZES_##sz
71 #define SF(c, pf, sf, r, g, b, a, t0, t1, t2, t3, sz, u)                \
72    [PIPE_FORMAT_##pf] = {                                               \
73       sf, {                                                             \
74          SF_##c(sz),                                                    \
75          G80_TIC_TYPE_##t0,                                             \
76          G80_TIC_TYPE_##t1,                                             \
77          G80_TIC_TYPE_##t2,                                             \
78          G80_TIC_TYPE_##t3,                                             \
79          G80_TIC_SOURCE_##r,                                            \
80          G80_TIC_SOURCE_##g,                                            \
81          G80_TIC_SOURCE_##b,                                            \
82          G80_TIC_SOURCE_##a,                                            \
83       }, U_##u                                                          \
84    }
85 
86 #define C4(c, p, n, r, g, b, a, t, s, u)                                \
87    SF(c, p, G80_SURFACE_FORMAT_##n, r, g, b, a, t, t, t, t, s, u)
88 
89 #define ZX(c, p, n, r, g, b, a, t, s, u)                                \
90    SF(c, p, G80_ZETA_FORMAT_##n,                                        \
91       r, g, b, ONE_FLOAT, t, UINT, UINT, UINT, s, u)
92 #define ZS(c, p, n, r, g, b, a, t, s, u)                                \
93    SF(c, p, G80_ZETA_FORMAT_##n,                                        \
94       r, g, b, ONE_FLOAT, t, UINT, UINT, UINT, s, u)
95 #define SZ(c, p, n, r, g, b, a, t, s, u)                                \
96    SF(c, p, G80_ZETA_FORMAT_##n,                                        \
97       r, g, b, ONE_FLOAT, UINT, t, UINT, UINT, s, u)
98 #define SX(c, p, r, s, u)                                               \
99    SF(c, p, G80_ZETA_FORMAT_NONE,                                       \
100       r, r, r, r, UINT, UINT, UINT, UINT, s, u)
101 
102 #define F3(c, p, n, r, g, b, a, t, s, u)         \
103    C4(c, p, n, r, g, b, ONE_FLOAT, t, s, u)
104 #define I3(c, p, n, r, g, b, a, t, s, u)         \
105    C4(c, p, n, r, g, b, ONE_INT, t, s, u)
106 
107 #define F2(c, p, n, r, g, b, a, t, s, u)         \
108    C4(c, p, n, r, g, ZERO, ONE_FLOAT, t, s, u)
109 #define I2(c, p, n, r, g, b, a, t, s, u)         \
110    C4(c, p, n, r, g, ZERO, ONE_INT, t, s, u)
111 
112 #define F1(c, p, n, r, g, b, a, t, s, u)         \
113    C4(c, p, n, r, ZERO, ZERO, ONE_FLOAT, t, s, u)
114 #define I1(c, p, n, r, g, b, a, t, s, u)         \
115    C4(c, p, n, r, ZERO, ZERO, ONE_INT, t, s, u)
116 
117 #define A1(c, p, n, r, g, b, a, t, s, u)         \
118    C4(c, p, n, ZERO, ZERO, ZERO, a, t, s, u)
119 
120 #if NOUVEAU_DRIVER == 0xc0
121 const struct nvc0_format nvc0_format_table[PIPE_FORMAT_COUNT] =
122 #else
123 const struct nv50_format nv50_format_table[PIPE_FORMAT_COUNT] =
124 #endif
125 {
126    C4(A, B8G8R8A8_UNORM, BGRA8_UNORM, B, G, R, A, UNORM, A8B8G8R8, ID),
127    F3(A, B8G8R8X8_UNORM, BGRX8_UNORM, B, G, R, xx, UNORM, A8B8G8R8, TD),
128    C4(A, B8G8R8A8_SRGB, BGRA8_SRGB, B, G, R, A, UNORM, A8B8G8R8, TD),
129    F3(A, B8G8R8X8_SRGB, BGRX8_SRGB, B, G, R, xx, UNORM, A8B8G8R8, TD),
130    C4(A, R8G8B8A8_UNORM, RGBA8_UNORM, R, G, B, A, UNORM, A8B8G8R8, IB),
131    F3(A, R8G8B8X8_UNORM, RGBX8_UNORM, R, G, B, xx, UNORM, A8B8G8R8, TB),
132    C4(A, R8G8B8A8_SRGB, RGBA8_SRGB, R, G, B, A, UNORM, A8B8G8R8, TB),
133    F3(A, R8G8B8X8_SRGB, RGBX8_SRGB, R, G, B, xx, UNORM, A8B8G8R8, TB),
134 
135    ZX(B, Z16_UNORM, Z16_UNORM, R, R, R, xx, UNORM, Z16, TZ),
136    ZX(A, Z32_FLOAT, Z32_FLOAT, R, R, R, xx, FLOAT, ZF32, TZ),
137    ZX(A, Z24X8_UNORM, Z24_X8_UNORM, R, R, R, xx, UNORM, X8Z24, TZ),
138    SZ(A, X8Z24_UNORM, S8_Z24_UNORM, G, G, G, xx, UNORM, Z24S8, TZ),
139    ZS(A, Z24_UNORM_S8_UINT, Z24_S8_UNORM, R, R, R, xx, UNORM, S8Z24, TZ),
140    SZ(A, S8_UINT_Z24_UNORM, S8_Z24_UNORM, G, G, G, xx, UNORM, Z24S8, TZ),
141    ZS(A, Z32_FLOAT_S8X24_UINT, Z32_S8_X24_FLOAT, R, R, R, xx, FLOAT, ZF32_X24S8, TZ),
142 
143    SX(A, S8_UINT, R, R8, T),
144    SX(A, X24S8_UINT, G, G8R24, T),
145    SX(A, S8X24_UINT, R, G24R8, T),
146    SX(A, X32_S8X24_UINT, G, R32_B24G8, T),
147 
148    F3(A, B5G6R5_UNORM, B5G6R5_UNORM, B, G, R, xx, UNORM, B5G6R5, TD),
149    C4(A, B5G5R5A1_UNORM, BGR5_A1_UNORM, B, G, R, A, UNORM, A1B5G5R5, TD),
150    F3(A, B5G5R5X1_UNORM, BGR5_X1_UNORM, B, G, R, xx, UNORM, A1B5G5R5, TD),
151    C4(A, B4G4R4A4_UNORM, NONE, B, G, R, A, UNORM, A4B4G4R4, T),
152    F3(A, B4G4R4X4_UNORM, NONE, B, G, R, xx, UNORM, A4B4G4R4, T),
153    F3(A, R9G9B9E5_FLOAT, NONE, R, G, B, xx, FLOAT, E5B9G9R9_SHAREDEXP, T),
154 
155    C4(A, R10G10B10A2_UNORM, RGB10_A2_UNORM, R, G, B, A, UNORM, A2B10G10R10, ID),
156    F3(A, R10G10B10X2_UNORM, RGB10_A2_UNORM, R, G, B, xx, UNORM, A2B10G10R10, T),
157    C4(A, B10G10R10A2_UNORM, BGR10_A2_UNORM, B, G, R, A, UNORM, A2B10G10R10, TB),
158    F3(A, B10G10R10X2_UNORM, BGR10_A2_UNORM, B, G, R, xx, UNORM, A2B10G10R10, T),
159    C4(A, R10G10B10A2_SNORM, NONE, R, G, B, A, SNORM, A2B10G10R10, T),
160    C4(A, B10G10R10A2_SNORM, NONE, B, G, R, A, SNORM, A2B10G10R10, T),
161    C4(A, R10G10B10A2_UINT, RGB10_A2_UINT, R, G, B, A, UINT, A2B10G10R10, TR),
162    C4(A, B10G10R10A2_UINT, RGB10_A2_UINT, B, G, R, A, UINT, A2B10G10R10, T),
163 
164    F3(A, R11G11B10_FLOAT, R11G11B10_FLOAT, R, G, B, xx, FLOAT, BF10GF11RF11, IB),
165 
166    F3(A, L8_UNORM, R8_UNORM, R, R, R, xx, UNORM, R8, TB),
167    F3(A, L8_SRGB, NONE, R, R, R, xx, UNORM, R8, T),
168    F3(A, L8_SNORM, R8_SNORM, R, R, R, xx, SNORM, R8, TC),
169    I3(A, L8_SINT, R8_SINT, R, R, R, xx, SINT, R8, TR),
170    I3(A, L8_UINT, R8_UINT, R, R, R, xx, UINT, R8, TR),
171    F3(A, L16_UNORM, R16_UNORM, R, R, R, xx, UNORM, R16, TC),
172    F3(A, L16_SNORM, R16_SNORM, R, R, R, xx, SNORM, R16, TC),
173    F3(A, L16_FLOAT, R16_FLOAT, R, R, R, xx, FLOAT, R16, TB),
174    I3(A, L16_SINT, R16_SINT, R, R, R, xx, SINT, R16, TR),
175    I3(A, L16_UINT, R16_UINT, R, R, R, xx, UINT, R16, TR),
176    F3(A, L32_FLOAT, R32_FLOAT, R, R, R, xx, FLOAT, R32, TB),
177    I3(A, L32_SINT, R32_SINT, R, R, R, xx, SINT, R32, TR),
178    I3(A, L32_UINT, R32_UINT, R, R, R, xx, UINT, R32, TR),
179 
180    C4(A, I8_UNORM, R8_UNORM, R, R, R, R, UNORM, R8, TR),
181    C4(A, I8_SNORM, R8_SNORM, R, R, R, R, SNORM, R8, TR),
182    C4(A, I8_SINT, R8_SINT, R, R, R, R, SINT, R8, TR),
183    C4(A, I8_UINT, R8_UINT, R, R, R, R, UINT, R8, TR),
184    C4(A, I16_UNORM, R16_UNORM, R, R, R, R, UNORM, R16, TR),
185    C4(A, I16_SNORM, R16_SNORM, R, R, R, R, SNORM, R16, TR),
186    C4(A, I16_FLOAT, R16_FLOAT, R, R, R, R, FLOAT, R16, TR),
187    C4(A, I16_SINT, R16_SINT, R, R, R, R, SINT, R16, TR),
188    C4(A, I16_UINT, R16_UINT, R, R, R, R, UINT, R16, TR),
189    C4(A, I32_FLOAT, R32_FLOAT, R, R, R, R, FLOAT, R32, TR),
190    C4(A, I32_SINT, R32_SINT, R, R, R, R, SINT, R32, TR),
191    C4(A, I32_UINT, R32_UINT, R, R, R, R, UINT, R32, TR),
192 
193    A1(A, A8_UNORM, A8_UNORM, xx, xx, xx, R, UNORM, R8, TB),
194    A1(A, A8_SNORM, R8_SNORM, xx, xx, xx, R, SNORM, R8, T),
195    A1(A, A8_SINT, R8_SINT, xx, xx, xx, R, SINT, R8, T),
196    A1(A, A8_UINT, R8_UINT, xx, xx, xx, R, UINT, R8, T),
197    A1(A, A16_UNORM, R16_UNORM, xx, xx, xx, R, UNORM, R16, T),
198    A1(A, A16_SNORM, R16_SNORM, xx, xx, xx, R, SNORM, R16, T),
199    A1(A, A16_FLOAT, R16_FLOAT, xx, xx, xx, R, FLOAT, R16, T),
200    A1(A, A16_SINT, R16_SINT, xx, xx, xx, R, SINT, R16, T),
201    A1(A, A16_UINT, R16_UINT, xx, xx, xx, R, UINT, R16, T),
202    A1(A, A32_FLOAT, R32_FLOAT, xx, xx, xx, R, FLOAT, R32, T),
203    A1(A, A32_SINT, R32_SINT, xx, xx, xx, R, SINT, R32, T),
204    A1(A, A32_UINT, R32_UINT, xx, xx, xx, R, UINT, R32, T),
205 
206    C4(A, L4A4_UNORM, NONE, R, R, R, G, UNORM, G4R4, T),
207    C4(A, L8A8_UNORM, RG8_UNORM, R, R, R, G, UNORM, G8R8, T),
208    C4(A, L8A8_SNORM, RG8_SNORM, R, R, R, G, SNORM, G8R8, T),
209    C4(A, L8A8_SRGB, NONE, R, R, R, G, UNORM, G8R8, T),
210    C4(A, L8A8_SINT, RG8_SINT, R, R, R, G, SINT, G8R8, T),
211    C4(A, L8A8_UINT, RG8_UINT, R, R, R, G, UINT, G8R8, T),
212    C4(A, L16A16_UNORM, RG16_UNORM, R, R, R, G, UNORM, R16_G16, T),
213    C4(A, L16A16_SNORM, RG16_SNORM, R, R, R, G, SNORM, R16_G16, T),
214    C4(A, L16A16_FLOAT, RG16_FLOAT, R, R, R, G, FLOAT, R16_G16, T),
215    C4(A, L16A16_SINT, RG16_SINT, R, R, R, G, SINT, R16_G16, T),
216    C4(A, L16A16_UINT, RG16_UINT, R, R, R, G, UINT, R16_G16, T),
217    C4(A, L32A32_FLOAT, RG32_FLOAT, R, R, R, G, FLOAT, R32_G32, T),
218    C4(A, L32A32_SINT, RG32_SINT, R, R, R, G, SINT, R32_G32, T),
219    C4(A, L32A32_UINT, RG32_UINT, R, R, R, G, UINT, R32_G32, T),
220 
221    F3(A, DXT1_RGB,   NONE, R, G, B, xx, UNORM, DXT1, T),
222    F3(A, DXT1_SRGB,  NONE, R, G, B, xx, UNORM, DXT1, T),
223    C4(A, DXT1_RGBA,  NONE, R, G, B, A, UNORM, DXT1, T),
224    C4(A, DXT1_SRGBA, NONE, R, G, B, A, UNORM, DXT1, T),
225    C4(A, DXT3_RGBA,  NONE, R, G, B, A, UNORM, DXT23, T),
226    C4(A, DXT3_SRGBA, NONE, R, G, B, A, UNORM, DXT23, T),
227    C4(A, DXT5_RGBA,  NONE, R, G, B, A, UNORM, DXT45, T),
228    C4(A, DXT5_SRGBA, NONE, R, G, B, A, UNORM, DXT45, T),
229 
230    F1(A, RGTC1_UNORM, NONE, R, xx, xx, xx, UNORM, DXN1, T),
231    F1(A, RGTC1_SNORM, NONE, R, xx, xx, xx, SNORM, DXN1, T),
232    F2(A, RGTC2_UNORM, NONE, R, G, xx, xx, UNORM, DXN2, T),
233    F2(A, RGTC2_SNORM, NONE, R, G, xx, xx, SNORM, DXN2, T),
234    F3(A, LATC1_UNORM, NONE, R, R, R, xx, UNORM, DXN1, T),
235    F3(A, LATC1_SNORM, NONE, R, R, R, xx, SNORM, DXN1, T),
236    C4(A, LATC2_UNORM, NONE, R, R, R, G, UNORM, DXN2, T),
237    C4(A, LATC2_SNORM, NONE, R, R, R, G, SNORM, DXN2, T),
238 
239    C4(C, BPTC_RGBA_UNORM, NONE, R, G, B, A, UNORM, BC7U, t),
240    C4(C, BPTC_SRGBA,      NONE, R, G, B, A, UNORM, BC7U, t),
241    F3(C, BPTC_RGB_FLOAT,  NONE, R, G, B, xx, FLOAT, BC6H_SF16, t),
242    F3(C, BPTC_RGB_UFLOAT, NONE, R, G, B, xx, FLOAT, BC6H_UF16, t),
243 
244 #if NOUVEAU_DRIVER == 0xc0
245    F3(D, ETC1_RGB8,       NONE, R,  G,  B, xx, UNORM, ETC2_RGB,     t),
246    F3(D, ETC2_RGB8,       NONE, R,  G,  B, xx, UNORM, ETC2_RGB,     t),
247    F3(D, ETC2_SRGB8,      NONE, R,  G,  B, xx, UNORM, ETC2_RGB,     t),
248    C4(D, ETC2_RGB8A1,     NONE, R,  G,  B,  A, UNORM, ETC2_RGB_PTA, t),
249    C4(D, ETC2_SRGB8A1,    NONE, R,  G,  B,  A, UNORM, ETC2_RGB_PTA, t),
250    C4(D, ETC2_RGBA8,      NONE, R,  G,  B,  A, UNORM, ETC2_RGBA,    t),
251    C4(D, ETC2_SRGBA8,     NONE, R,  G,  B,  A, UNORM, ETC2_RGBA,    t),
252    F1(D, ETC2_R11_UNORM,  NONE, R, xx, xx, xx, UNORM, EAC,          t),
253    F1(D, ETC2_R11_SNORM,  NONE, R, xx, xx, xx, SNORM, EAC,          t),
254    F2(D, ETC2_RG11_UNORM, NONE, R,  G, xx, xx, UNORM, EACX2,        t),
255    F2(D, ETC2_RG11_SNORM, NONE, R,  G, xx, xx, SNORM, EACX2,        t),
256 
257    C4(D, ASTC_4x4,        NONE, R, G, B, A, UNORM, ASTC_2D_4X4,   t),
258    C4(D, ASTC_5x4,        NONE, R, G, B, A, UNORM, ASTC_2D_5X4,   t),
259    C4(D, ASTC_5x5,        NONE, R, G, B, A, UNORM, ASTC_2D_5X5,   t),
260    C4(D, ASTC_6x5,        NONE, R, G, B, A, UNORM, ASTC_2D_6X5,   t),
261    C4(D, ASTC_6x6,        NONE, R, G, B, A, UNORM, ASTC_2D_6X6,   t),
262    C4(D, ASTC_8x5,        NONE, R, G, B, A, UNORM, ASTC_2D_8X5,   t),
263    C4(D, ASTC_8x6,        NONE, R, G, B, A, UNORM, ASTC_2D_8X6,   t),
264    C4(D, ASTC_8x8,        NONE, R, G, B, A, UNORM, ASTC_2D_8X8,   t),
265    C4(D, ASTC_10x5,       NONE, R, G, B, A, UNORM, ASTC_2D_10X5,  t),
266    C4(D, ASTC_10x6,       NONE, R, G, B, A, UNORM, ASTC_2D_10X6,  t),
267    C4(D, ASTC_10x8,       NONE, R, G, B, A, UNORM, ASTC_2D_10X8,  t),
268    C4(D, ASTC_10x10,      NONE, R, G, B, A, UNORM, ASTC_2D_10X10, t),
269    C4(D, ASTC_12x10,      NONE, R, G, B, A, UNORM, ASTC_2D_12X10, t),
270    C4(D, ASTC_12x12,      NONE, R, G, B, A, UNORM, ASTC_2D_12X12, t),
271 
272    C4(D, ASTC_4x4_SRGB,   NONE, R, G, B, A, UNORM, ASTC_2D_4X4,   t),
273    C4(D, ASTC_5x4_SRGB,   NONE, R, G, B, A, UNORM, ASTC_2D_5X4,   t),
274    C4(D, ASTC_5x5_SRGB,   NONE, R, G, B, A, UNORM, ASTC_2D_5X5,   t),
275    C4(D, ASTC_6x5_SRGB,   NONE, R, G, B, A, UNORM, ASTC_2D_6X5,   t),
276    C4(D, ASTC_6x6_SRGB,   NONE, R, G, B, A, UNORM, ASTC_2D_6X6,   t),
277    C4(D, ASTC_8x5_SRGB,   NONE, R, G, B, A, UNORM, ASTC_2D_8X5,   t),
278    C4(D, ASTC_8x6_SRGB,   NONE, R, G, B, A, UNORM, ASTC_2D_8X6,   t),
279    C4(D, ASTC_8x8_SRGB,   NONE, R, G, B, A, UNORM, ASTC_2D_8X8,   t),
280    C4(D, ASTC_10x5_SRGB,  NONE, R, G, B, A, UNORM, ASTC_2D_10X5,  t),
281    C4(D, ASTC_10x6_SRGB,  NONE, R, G, B, A, UNORM, ASTC_2D_10X6,  t),
282    C4(D, ASTC_10x8_SRGB,  NONE, R, G, B, A, UNORM, ASTC_2D_10X8,  t),
283    C4(D, ASTC_10x10_SRGB, NONE, R, G, B, A, UNORM, ASTC_2D_10X10, t),
284    C4(D, ASTC_12x10_SRGB, NONE, R, G, B, A, UNORM, ASTC_2D_12X10, t),
285    C4(D, ASTC_12x12_SRGB, NONE, R, G, B, A, UNORM, ASTC_2D_12X12, t),
286 #endif
287 
288    C4(A, R32G32B32A32_FLOAT, RGBA32_FLOAT, R, G, B, A, FLOAT, R32_G32_B32_A32, IB),
289    C4(A, R32G32B32A32_UNORM, NONE, R, G, B, A, UNORM, R32_G32_B32_A32, T),
290    C4(A, R32G32B32A32_SNORM, NONE, R, G, B, A, SNORM, R32_G32_B32_A32, T),
291    C4(A, R32G32B32A32_SINT, RGBA32_SINT, R, G, B, A, SINT, R32_G32_B32_A32, IR),
292    C4(A, R32G32B32A32_UINT, RGBA32_UINT, R, G, B, A, UINT, R32_G32_B32_A32, IR),
293    F3(A, R32G32B32X32_FLOAT, RGBX32_FLOAT, R, G, B, xx, FLOAT, R32_G32_B32_A32, TB),
294    I3(A, R32G32B32X32_SINT, RGBX32_SINT, R, G, B, xx, SINT, R32_G32_B32_A32, TR),
295    I3(A, R32G32B32X32_UINT, RGBX32_UINT, R, G, B, xx, UINT, R32_G32_B32_A32, TR),
296 
297    F3(C, R32G32B32_FLOAT, NONE, R, G, B, xx, FLOAT, R32_G32_B32, t),
298    I3(C, R32G32B32_SINT, NONE, R, G, B, xx, SINT, R32_G32_B32, t),
299    I3(C, R32G32B32_UINT, NONE, R, G, B, xx, UINT, R32_G32_B32, t),
300 
301    F2(A, R32G32_FLOAT, RG32_FLOAT, R, G, xx, xx, FLOAT, R32_G32, IB),
302    F2(A, R32G32_UNORM, NONE, R, G, xx, xx, UNORM, R32_G32, T),
303    F2(A, R32G32_SNORM, NONE, R, G, xx, xx, SNORM, R32_G32, T),
304    I2(A, R32G32_SINT, RG32_SINT, R, G, xx, xx, SINT, R32_G32, IR),
305    I2(A, R32G32_UINT, RG32_UINT, R, G, xx, xx, UINT, R32_G32, IR),
306 
307    F1(A, R32_FLOAT, R32_FLOAT, R, xx, xx, xx, FLOAT, R32, IB),
308    F1(A, R32_UNORM, NONE, R, xx, xx, xx, UNORM, R32, T),
309    F1(A, R32_SNORM, NONE, R, xx, xx, xx, SNORM, R32, T),
310    I1(A, R32_SINT, R32_SINT, R, xx, xx, xx, SINT, R32, IR),
311    I1(A, R32_UINT, R32_UINT, R, xx, xx, xx, UINT, R32, IR),
312 
313    C4(A, R16G16B16A16_FLOAT, RGBA16_FLOAT, R, G, B, A, FLOAT, R16_G16_B16_A16, IB),
314    C4(A, R16G16B16A16_UNORM, RGBA16_UNORM, R, G, B, A, UNORM, R16_G16_B16_A16, IC),
315    C4(A, R16G16B16A16_SNORM, RGBA16_SNORM, R, G, B, A, SNORM, R16_G16_B16_A16, IC),
316    C4(A, R16G16B16A16_SINT, RGBA16_SINT, R, G, B, A, SINT, R16_G16_B16_A16, IR),
317    C4(A, R16G16B16A16_UINT, RGBA16_UINT, R, G, B, A, UINT, R16_G16_B16_A16, IR),
318    F3(A, R16G16B16X16_FLOAT, RGBX16_FLOAT, R, G, B, xx, FLOAT, R16_G16_B16_A16, TB),
319    F3(A, R16G16B16X16_UNORM, RGBA16_UNORM, R, G, B, xx, UNORM, R16_G16_B16_A16, T),
320    F3(A, R16G16B16X16_SNORM, RGBA16_SNORM, R, G, B, xx, SNORM, R16_G16_B16_A16, T),
321    I3(A, R16G16B16X16_SINT, RGBA16_SINT, R, G, B, xx, SINT, R16_G16_B16_A16, TR),
322    I3(A, R16G16B16X16_UINT, RGBA16_UINT, R, G, B, xx, UINT, R16_G16_B16_A16, TR),
323 
324    F2(A, R16G16_FLOAT, RG16_FLOAT, R, G, xx, xx, FLOAT, R16_G16, IB),
325    F2(A, R16G16_UNORM, RG16_UNORM, R, G, xx, xx, UNORM, R16_G16, IC),
326    F2(A, R16G16_SNORM, RG16_SNORM, R, G, xx, xx, SNORM, R16_G16, IC),
327    I2(A, R16G16_SINT, RG16_SINT, R, G, xx, xx, SINT, R16_G16, IR),
328    I2(A, R16G16_UINT, RG16_UINT, R, G, xx, xx, UINT, R16_G16, IR),
329 
330    F1(A, R16_FLOAT, R16_FLOAT, R, xx, xx, xx, FLOAT, R16, IB),
331    F1(A, R16_UNORM, R16_UNORM, R, xx, xx, xx, UNORM, R16, IC),
332    F1(A, R16_SNORM, R16_SNORM, R, xx, xx, xx, SNORM, R16, IC),
333    I1(A, R16_SINT, R16_SINT, R, xx, xx, xx, SINT, R16, IR),
334    I1(A, R16_UINT, R16_UINT, R, xx, xx, xx, UINT, R16, IR),
335 
336    C4(A, R8G8B8A8_SNORM, RGBA8_SNORM, R, G, B, A, SNORM, A8B8G8R8, IC),
337    C4(A, R8G8B8A8_SINT, RGBA8_SINT, R, G, B, A, SINT, A8B8G8R8, IR),
338    C4(A, R8G8B8A8_UINT, RGBA8_UINT, R, G, B, A, UINT, A8B8G8R8, IR),
339    F3(A, R8G8B8X8_SNORM, RGBA8_SNORM, R, G, B, xx, SNORM, A8B8G8R8, T),
340    I3(A, R8G8B8X8_SINT, RGBA8_SINT, R, G, B, xx, SINT, A8B8G8R8, TR),
341    I3(A, R8G8B8X8_UINT, RGBA8_UINT, R, G, B, xx, UINT, A8B8G8R8, TR),
342 
343    F2(A, R8G8_UNORM, RG8_UNORM, R, G, xx, xx, UNORM, G8R8, IB),
344    F2(A, R8G8_SNORM, RG8_SNORM, R, G, xx, xx, SNORM, G8R8, IC),
345    I2(A, R8G8_SINT, RG8_SINT, R, G, xx, xx, SINT, G8R8, IR),
346    I2(A, R8G8_UINT, RG8_UINT, R, G, xx, xx, UINT, G8R8, IR),
347 #if NOUVEAU_DRIVER < 0xc0
348    /* On Fermi+, the green component doesn't get decoding? */
349    F2(A, R8G8_SRGB, NONE, R, G, xx, xx, UNORM, G8R8, T),
350 #endif
351 
352    F1(A, R8_UNORM, R8_UNORM, R, xx, xx, xx, UNORM, R8, IB),
353    F1(A, R8_SNORM, R8_SNORM, R, xx, xx, xx, SNORM, R8, IC),
354    I1(A, R8_SINT, R8_SINT, R, xx, xx, xx, SINT, R8, IR),
355    I1(A, R8_UINT, R8_UINT, R, xx, xx, xx, UINT, R8, IR),
356    F1(A, R8_SRGB, NONE, R, xx, xx, xx, UNORM, R8, T),
357 
358    F3(A, R8G8_B8G8_UNORM, NONE, R, G, B, xx, UNORM, G8B8G8R8, T),
359    F3(A, G8R8_B8R8_UNORM, NONE, G, R, B, xx, UNORM, G8B8G8R8, T),
360    F3(A, G8R8_G8B8_UNORM, NONE, R, G, B, xx, UNORM, B8G8R8G8, T),
361    F3(A, R8G8_R8B8_UNORM, NONE, G, R, B, xx, UNORM, B8G8R8G8, T),
362 
363    F1(A, R1_UNORM, BITMAP, R, xx, xx, xx, UNORM, R1, T),
364 
365    C4(A, R4A4_UNORM, NONE, R, ZERO, ZERO, G, UNORM, G4R4, T),
366    C4(A, R8A8_UNORM, NONE, R, ZERO, ZERO, G, UNORM, G8R8, T),
367    C4(A, A4R4_UNORM, NONE, G, ZERO, ZERO, R, UNORM, G4R4, T),
368    C4(A, A8R8_UNORM, NONE, G, ZERO, ZERO, R, UNORM, G8R8, T),
369 
370    SF(A, R8SG8SB8UX8U_NORM, 0, R, G, B, ONE_FLOAT, SNORM, SNORM, UNORM, UNORM, A8B8G8R8, T),
371    SF(A, R5SG5SB6U_NORM, 0, R, G, B, ONE_FLOAT, SNORM, SNORM, UNORM, UNORM, B6G5R5, T),
372 };
373 
374 #if NOUVEAU_DRIVER == 0xc0
375 # define NVXX_3D_VAF_SIZE(s) NVC0_3D_VERTEX_ATTRIB_FORMAT_SIZE_##s
376 # define NVXX_3D_VAF_TYPE(t) NVC0_3D_VERTEX_ATTRIB_FORMAT_TYPE_##t
377 #else
378 # define NVXX_3D_VAF_SIZE(s) NV50_3D_VERTEX_ARRAY_ATTRIB_FORMAT_##s
379 # define NVXX_3D_VAF_TYPE(t) NV50_3D_VERTEX_ARRAY_ATTRIB_TYPE_##t
380 #endif
381 
382 #define VF_x(pf, type, size, bgra) 0
383 #define VF_A(pf, type, size, bgra)                                      \
384       NVXX_3D_VAF_SIZE(size) | NVXX_3D_VAF_TYPE(type) | (bgra << 31)
385 #define VF(c, pf, type, size, bgra)                                     \
386    [PIPE_FORMAT_##pf] = {                                               \
387       VF_##c(pf, type, size, bgra),                                     \
388       PIPE_BIND_VERTEX_BUFFER                                           \
389    }
390 
391 #if NOUVEAU_DRIVER == 0xc0
392 const struct nvc0_vertex_format nvc0_vertex_format[PIPE_FORMAT_COUNT] =
393 #else
394 const struct nv50_vertex_format nv50_vertex_format[PIPE_FORMAT_COUNT] =
395 #endif
396 {
397    VF(A, B8G8R8A8_UNORM, UNORM, 8_8_8_8, 1),
398    VF(A, R8G8B8A8_UNORM, UNORM, 8_8_8_8, 0),
399 
400    VF(A, R10G10B10A2_UNORM, UNORM, 10_10_10_2, 0),
401    VF(A, B10G10R10A2_UNORM, UNORM, 10_10_10_2, 1),
402    VF(A, R10G10B10A2_SNORM, SNORM, 10_10_10_2, 0),
403    VF(A, B10G10R10A2_SNORM, SNORM, 10_10_10_2, 1),
404    VF(A, R10G10B10A2_UINT, UINT, 10_10_10_2, 0),
405    VF(A, B10G10R10A2_UINT, UINT, 10_10_10_2, 1),
406 
407    VF(A, R11G11B10_FLOAT, FLOAT, 11_11_10, 0),
408 
409    VF(A, R32G32B32A32_FLOAT, FLOAT, 32_32_32_32, 0),
410    VF(A, R32G32B32A32_UNORM, UNORM, 32_32_32_32, 0),
411    VF(A, R32G32B32A32_SNORM, SNORM, 32_32_32_32, 0),
412    VF(A, R32G32B32A32_SINT, SINT, 32_32_32_32, 0),
413    VF(A, R32G32B32A32_UINT, UINT, 32_32_32_32, 0),
414 
415    VF(A, R32G32_FLOAT, FLOAT, 32_32, 0),
416    VF(A, R32G32_UNORM, UNORM, 32_32, 0),
417    VF(A, R32G32_SNORM, SNORM, 32_32, 0),
418    VF(A, R32G32_SINT, SINT, 32_32, 0),
419    VF(A, R32G32_UINT, UINT, 32_32, 0),
420 
421    VF(A, R32_FLOAT, FLOAT, 32, 0),
422    VF(A, R32_UNORM, UNORM, 32, 0),
423    VF(A, R32_SNORM, SNORM, 32, 0),
424    VF(A, R32_SINT, SINT, 32, 0),
425    VF(A, R32_UINT, UINT, 32, 0),
426 
427    VF(A, R16G16B16A16_FLOAT, FLOAT, 16_16_16_16, 0),
428    VF(A, R16G16B16A16_UNORM, UNORM, 16_16_16_16, 0),
429    VF(A, R16G16B16A16_SNORM, SNORM, 16_16_16_16, 0),
430    VF(A, R16G16B16A16_SINT, SINT, 16_16_16_16, 0),
431    VF(A, R16G16B16A16_UINT, UINT, 16_16_16_16, 0),
432 
433    VF(A, R16G16_FLOAT, FLOAT, 16_16, 0),
434    VF(A, R16G16_UNORM, UNORM, 16_16, 0),
435    VF(A, R16G16_SNORM, SNORM, 16_16, 0),
436    VF(A, R16G16_SINT, SINT, 16_16, 0),
437    VF(A, R16G16_UINT, UINT, 16_16, 0),
438 
439    VF(A, R16_FLOAT, FLOAT, 16, 0),
440    VF(A, R16_UNORM, UNORM, 16, 0),
441    VF(A, R16_SNORM, SNORM, 16, 0),
442    VF(A, R16_SINT, SINT, 16, 0),
443    VF(A, R16_UINT, UINT, 16, 0),
444 
445    VF(A, R8G8B8A8_SNORM, SNORM, 8_8_8_8, 0),
446    VF(A, R8G8B8A8_SINT, SINT, 8_8_8_8, 0),
447    VF(A, R8G8B8A8_UINT, UINT, 8_8_8_8, 0),
448 
449    VF(A, R8G8_UNORM, UNORM, 8_8, 0),
450    VF(A, R8G8_SNORM, SNORM, 8_8, 0),
451    VF(A, R8G8_SINT, SINT, 8_8, 0),
452    VF(A, R8G8_UINT, UINT, 8_8, 0),
453 
454    VF(A, R8_UNORM, UNORM, 8, 0),
455    VF(A, R8_SNORM, SNORM, 8, 0),
456    VF(A, R8_SINT, SINT, 8, 0),
457    VF(A, R8_UINT, UINT, 8, 0),
458 
459    VF(A, R32G32B32A32_SSCALED, SSCALED, 32_32_32_32, 0),
460    VF(A, R32G32B32A32_USCALED, USCALED, 32_32_32_32, 0),
461    VF(A, R32G32B32_FLOAT, FLOAT, 32_32_32, 0),
462    VF(A, R32G32B32_UNORM, UNORM, 32_32_32, 0),
463    VF(A, R32G32B32_SNORM, SNORM, 32_32_32, 0),
464    VF(A, R32G32B32_SINT, SINT, 32_32_32, 0),
465    VF(A, R32G32B32_UINT, UINT, 32_32_32, 0),
466    VF(A, R32G32B32_SSCALED, SSCALED, 32_32_32, 0),
467    VF(A, R32G32B32_USCALED, USCALED, 32_32_32, 0),
468    VF(A, R32G32_SSCALED, SSCALED, 32_32, 0),
469    VF(A, R32G32_USCALED, USCALED, 32_32, 0),
470    VF(A, R32_SSCALED, SSCALED, 32, 0),
471    VF(A, R32_USCALED, USCALED, 32, 0),
472 
473    VF(A, R16G16B16A16_SSCALED, SSCALED, 16_16_16_16, 0),
474    VF(A, R16G16B16A16_USCALED, USCALED, 16_16_16_16, 0),
475    VF(A, R16G16B16_FLOAT, FLOAT, 16_16_16, 0),
476    VF(A, R16G16B16_UNORM, UNORM, 16_16_16, 0),
477    VF(A, R16G16B16_SNORM, SNORM, 16_16_16, 0),
478    VF(A, R16G16B16_SINT, SINT, 16_16_16, 0),
479    VF(A, R16G16B16_UINT, UINT, 16_16_16, 0),
480    VF(A, R16G16B16_SSCALED, SSCALED, 16_16_16, 0),
481    VF(A, R16G16B16_USCALED, USCALED, 16_16_16, 0),
482    VF(A, R16G16_SSCALED, SSCALED, 16_16, 0),
483    VF(A, R16G16_USCALED, USCALED, 16_16, 0),
484    VF(A, R16_SSCALED, SSCALED, 16, 0),
485    VF(A, R16_USCALED, USCALED, 16, 0),
486 
487    VF(A, R10G10B10A2_USCALED, USCALED, 10_10_10_2, 0),
488    VF(A, R10G10B10A2_SSCALED, SSCALED, 10_10_10_2, 0),
489    VF(A, B10G10R10A2_USCALED, USCALED, 10_10_10_2, 1),
490    VF(A, B10G10R10A2_SSCALED, SSCALED, 10_10_10_2, 1),
491 
492    VF(A, R8G8B8A8_SSCALED, SSCALED, 8_8_8_8, 0),
493    VF(A, R8G8B8A8_USCALED, USCALED, 8_8_8_8, 0),
494    VF(A, R8G8B8_UNORM, UNORM, 8_8_8, 0),
495    VF(A, R8G8B8_SNORM, SNORM, 8_8_8, 0),
496    VF(A, R8G8B8_SINT, SINT, 8_8_8, 0),
497    VF(A, R8G8B8_UINT, UINT, 8_8_8, 0),
498    VF(A, R8G8B8_SSCALED, SSCALED, 8_8_8, 0),
499    VF(A, R8G8B8_USCALED, USCALED, 8_8_8, 0),
500    VF(A, R8G8_SSCALED, SSCALED, 8_8, 0),
501    VF(A, R8G8_USCALED, USCALED, 8_8, 0),
502    VF(A, R8_SSCALED, SSCALED, 8, 0),
503    VF(A, R8_USCALED, USCALED, 8, 0),
504 
505    /* FIXED types: not supported natively, converted on VBO push */
506 
507    VF(x, R32G32B32A32_FIXED, xx, xx, xx),
508    VF(x, R32G32B32_FIXED, xx, xx, xx),
509    VF(x, R32G32_FIXED, xx, xx, xx),
510    VF(x, R32_FIXED, xx, xx, xx),
511 
512    VF(x, R64G64B64A64_FLOAT, xx, xx, xx),
513    VF(x, R64G64B64_FLOAT, xx, xx, xx),
514    VF(x, R64G64_FLOAT, xx, xx, xx),
515    VF(x, R64_FLOAT, xx, xx, xx),
516 };
517