fce351b7d37ce4e7746a1c074a24a8b14a27bdd6
[platform/adaptation/renesas_rcar/renesas_kernel.git] / drivers / gpu / drm / vmwgfx / svga3d_reg.h
1 /**********************************************************
2  * Copyright 1998-2009 VMware, Inc.  All rights reserved.
3  *
4  * Permission is hereby granted, free of charge, to any person
5  * obtaining a copy of this software and associated documentation
6  * files (the "Software"), to deal in the Software without
7  * restriction, including without limitation the rights to use, copy,
8  * modify, merge, publish, distribute, sublicense, and/or sell copies
9  * of the Software, and to permit persons to whom the Software is
10  * furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be
13  * included in all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  *
24  **********************************************************/
25
26 /*
27  * svga3d_reg.h --
28  *
29  *       SVGA 3D hardware definitions
30  */
31
32 #ifndef _SVGA3D_REG_H_
33 #define _SVGA3D_REG_H_
34
35 #include "svga_reg.h"
36
37 typedef uint32 PPN;
38
39 /*
40  * 3D Hardware Version
41  *
42  *   The hardware version is stored in the SVGA_FIFO_3D_HWVERSION fifo
43  *   register.   Is set by the host and read by the guest.  This lets
44  *   us make new guest drivers which are backwards-compatible with old
45  *   SVGA hardware revisions.  It does not let us support old guest
46  *   drivers.  Good enough for now.
47  *
48  */
49
50 #define SVGA3D_MAKE_HWVERSION(major, minor)      (((major) << 16) | ((minor) & 0xFF))
51 #define SVGA3D_MAJOR_HWVERSION(version)          ((version) >> 16)
52 #define SVGA3D_MINOR_HWVERSION(version)          ((version) & 0xFF)
53
54 typedef enum {
55    SVGA3D_HWVERSION_WS5_RC1   = SVGA3D_MAKE_HWVERSION(0, 1),
56    SVGA3D_HWVERSION_WS5_RC2   = SVGA3D_MAKE_HWVERSION(0, 2),
57    SVGA3D_HWVERSION_WS51_RC1  = SVGA3D_MAKE_HWVERSION(0, 3),
58    SVGA3D_HWVERSION_WS6_B1    = SVGA3D_MAKE_HWVERSION(1, 1),
59    SVGA3D_HWVERSION_FUSION_11 = SVGA3D_MAKE_HWVERSION(1, 4),
60    SVGA3D_HWVERSION_WS65_B1   = SVGA3D_MAKE_HWVERSION(2, 0),
61    SVGA3D_HWVERSION_WS8_B1    = SVGA3D_MAKE_HWVERSION(2, 1),
62    SVGA3D_HWVERSION_CURRENT   = SVGA3D_HWVERSION_WS8_B1,
63 } SVGA3dHardwareVersion;
64
65 /*
66  * Generic Types
67  */
68
69 typedef uint32 SVGA3dBool; /* 32-bit Bool definition */
70 #define SVGA3D_NUM_CLIPPLANES                   6
71 #define SVGA3D_MAX_SIMULTANEOUS_RENDER_TARGETS  8
72 #define SVGA3D_MAX_CONTEXT_IDS                  256
73 #define SVGA3D_MAX_SURFACE_IDS                  (32 * 1024)
74
75 #define SVGA3D_NUM_TEXTURE_UNITS                32
76 #define SVGA3D_NUM_LIGHTS                       8
77
78 /*
79  * Surface formats.
80  *
81  * If you modify this list, be sure to keep GLUtil.c in sync. It
82  * includes the internal format definition of each surface in
83  * GLUtil_ConvertSurfaceFormat, and it contains a table of
84  * human-readable names in GLUtil_GetFormatName.
85  */
86
87 typedef enum SVGA3dSurfaceFormat {
88    SVGA3D_FORMAT_MIN                   = 0,
89    SVGA3D_FORMAT_INVALID               = 0,
90
91    SVGA3D_X8R8G8B8                     = 1,
92    SVGA3D_A8R8G8B8                     = 2,
93
94    SVGA3D_R5G6B5                       = 3,
95    SVGA3D_X1R5G5B5                     = 4,
96    SVGA3D_A1R5G5B5                     = 5,
97    SVGA3D_A4R4G4B4                     = 6,
98
99    SVGA3D_Z_D32                        = 7,
100    SVGA3D_Z_D16                        = 8,
101    SVGA3D_Z_D24S8                      = 9,
102    SVGA3D_Z_D15S1                      = 10,
103
104    SVGA3D_LUMINANCE8                   = 11,
105    SVGA3D_LUMINANCE4_ALPHA4            = 12,
106    SVGA3D_LUMINANCE16                  = 13,
107    SVGA3D_LUMINANCE8_ALPHA8            = 14,
108
109    SVGA3D_DXT1                         = 15,
110    SVGA3D_DXT2                         = 16,
111    SVGA3D_DXT3                         = 17,
112    SVGA3D_DXT4                         = 18,
113    SVGA3D_DXT5                         = 19,
114
115    SVGA3D_BUMPU8V8                     = 20,
116    SVGA3D_BUMPL6V5U5                   = 21,
117    SVGA3D_BUMPX8L8V8U8                 = 22,
118    SVGA3D_BUMPL8V8U8                   = 23,
119
120    SVGA3D_ARGB_S10E5                   = 24,   /* 16-bit floating-point ARGB */
121    SVGA3D_ARGB_S23E8                   = 25,   /* 32-bit floating-point ARGB */
122
123    SVGA3D_A2R10G10B10                  = 26,
124
125    /* signed formats */
126    SVGA3D_V8U8                         = 27,
127    SVGA3D_Q8W8V8U8                     = 28,
128    SVGA3D_CxV8U8                       = 29,
129
130    /* mixed formats */
131    SVGA3D_X8L8V8U8                     = 30,
132    SVGA3D_A2W10V10U10                  = 31,
133
134    SVGA3D_ALPHA8                       = 32,
135
136    /* Single- and dual-component floating point formats */
137    SVGA3D_R_S10E5                      = 33,
138    SVGA3D_R_S23E8                      = 34,
139    SVGA3D_RG_S10E5                     = 35,
140    SVGA3D_RG_S23E8                     = 36,
141
142    SVGA3D_BUFFER                       = 37,
143
144    SVGA3D_Z_D24X8                      = 38,
145
146    SVGA3D_V16U16                       = 39,
147
148    SVGA3D_G16R16                       = 40,
149    SVGA3D_A16B16G16R16                 = 41,
150
151    /* Packed Video formats */
152    SVGA3D_UYVY                         = 42,
153    SVGA3D_YUY2                         = 43,
154
155    /* Planar video formats */
156    SVGA3D_NV12                         = 44,
157
158    /* Video format with alpha */
159    SVGA3D_AYUV                         = 45,
160
161    SVGA3D_R32G32B32A32_TYPELESS        = 46,
162    SVGA3D_R32G32B32A32_FLOAT           = 25,
163    SVGA3D_R32G32B32A32_UINT            = 47,
164    SVGA3D_R32G32B32A32_SINT            = 48,
165    SVGA3D_R32G32B32_TYPELESS           = 49,
166    SVGA3D_R32G32B32_FLOAT              = 50,
167    SVGA3D_R32G32B32_UINT               = 51,
168    SVGA3D_R32G32B32_SINT               = 52,
169    SVGA3D_R16G16B16A16_TYPELESS        = 53,
170    SVGA3D_R16G16B16A16_FLOAT           = 24,
171    SVGA3D_R16G16B16A16_UNORM           = 41,
172    SVGA3D_R16G16B16A16_UINT            = 54,
173    SVGA3D_R16G16B16A16_SNORM           = 55,
174    SVGA3D_R16G16B16A16_SINT            = 56,
175    SVGA3D_R32G32_TYPELESS              = 57,
176    SVGA3D_R32G32_FLOAT                 = 36,
177    SVGA3D_R32G32_UINT                  = 58,
178    SVGA3D_R32G32_SINT                  = 59,
179    SVGA3D_R32G8X24_TYPELESS            = 60,
180    SVGA3D_D32_FLOAT_S8X24_UINT         = 61,
181    SVGA3D_R32_FLOAT_X8X24_TYPELESS     = 62,
182    SVGA3D_X32_TYPELESS_G8X24_UINT      = 63,
183    SVGA3D_R10G10B10A2_TYPELESS         = 64,
184    SVGA3D_R10G10B10A2_UNORM            = 26,
185    SVGA3D_R10G10B10A2_UINT             = 65,
186    SVGA3D_R11G11B10_FLOAT              = 66,
187    SVGA3D_R8G8B8A8_TYPELESS            = 67,
188    SVGA3D_R8G8B8A8_UNORM               = 68,
189    SVGA3D_R8G8B8A8_UNORM_SRGB          = 69,
190    SVGA3D_R8G8B8A8_UINT                = 70,
191    SVGA3D_R8G8B8A8_SNORM               = 28,
192    SVGA3D_R8G8B8A8_SINT                = 71,
193    SVGA3D_R16G16_TYPELESS              = 72,
194    SVGA3D_R16G16_FLOAT                 = 35,
195    SVGA3D_R16G16_UNORM                 = 40,
196    SVGA3D_R16G16_UINT                  = 73,
197    SVGA3D_R16G16_SNORM                 = 39,
198    SVGA3D_R16G16_SINT                  = 74,
199    SVGA3D_R32_TYPELESS                 = 75,
200    SVGA3D_D32_FLOAT                    = 76,
201    SVGA3D_R32_FLOAT                    = 34,
202    SVGA3D_R32_UINT                     = 77,
203    SVGA3D_R32_SINT                     = 78,
204    SVGA3D_R24G8_TYPELESS               = 79,
205    SVGA3D_D24_UNORM_S8_UINT            = 80,
206    SVGA3D_R24_UNORM_X8_TYPELESS        = 81,
207    SVGA3D_X24_TYPELESS_G8_UINT         = 82,
208    SVGA3D_R8G8_TYPELESS                = 83,
209    SVGA3D_R8G8_UNORM                   = 84,
210    SVGA3D_R8G8_UINT                    = 85,
211    SVGA3D_R8G8_SNORM                   = 27,
212    SVGA3D_R8G8_SINT                    = 86,
213    SVGA3D_R16_TYPELESS                 = 87,
214    SVGA3D_R16_FLOAT                    = 33,
215    SVGA3D_D16_UNORM                    = 8,
216    SVGA3D_R16_UNORM                    = 88,
217    SVGA3D_R16_UINT                     = 89,
218    SVGA3D_R16_SNORM                    = 90,
219    SVGA3D_R16_SINT                     = 91,
220    SVGA3D_R8_TYPELESS                  = 92,
221    SVGA3D_R8_UNORM                     = 93,
222    SVGA3D_R8_UINT                      = 94,
223    SVGA3D_R8_SNORM                     = 95,
224    SVGA3D_R8_SINT                      = 96,
225    SVGA3D_A8_UNORM                     = 32,
226    SVGA3D_R1_UNORM                     = 97,
227    SVGA3D_R9G9B9E5_SHAREDEXP           = 98,
228    SVGA3D_R8G8_B8G8_UNORM              = 99,
229    SVGA3D_G8R8_G8B8_UNORM              = 100,
230    SVGA3D_BC1_TYPELESS                 = 101,
231    SVGA3D_BC1_UNORM                    = 15,
232    SVGA3D_BC1_UNORM_SRGB               = 102,
233    SVGA3D_BC2_TYPELESS                 = 103,
234    SVGA3D_BC2_UNORM                    = 17,
235    SVGA3D_BC2_UNORM_SRGB               = 104,
236    SVGA3D_BC3_TYPELESS                 = 105,
237    SVGA3D_BC3_UNORM                    = 19,
238    SVGA3D_BC3_UNORM_SRGB               = 106,
239    SVGA3D_BC4_TYPELESS                 = 107,
240    SVGA3D_BC4_UNORM                    = 108,
241    SVGA3D_BC4_SNORM                    = 109,
242    SVGA3D_BC5_TYPELESS                 = 110,
243    SVGA3D_BC5_UNORM                    = 111,
244    SVGA3D_BC5_SNORM                    = 112,
245    SVGA3D_B5G6R5_UNORM                 = 3,
246    SVGA3D_B5G5R5A1_UNORM               = 5,
247    SVGA3D_B8G8R8A8_UNORM               = 2,
248    SVGA3D_B8G8R8X8_UNORM               = 1,
249    SVGA3D_R10G10B10_XR_BIAS_A2_UNORM   = 113,
250    SVGA3D_B8G8R8A8_TYPELESS            = 114,
251    SVGA3D_B8G8R8A8_UNORM_SRGB          = 115,
252    SVGA3D_B8G8R8X8_TYPELESS            = 116,
253    SVGA3D_B8G8R8X8_UNORM_SRGB          = 117,
254
255    /* Advanced D3D9 depth formats. */
256    SVGA3D_Z_DF16                       = 118,
257    SVGA3D_Z_DF24                       = 119,
258    SVGA3D_Z_D24S8_INT                  = 120,
259
260    /* Planar video formats. */
261    SVGA3D_YV12                         = 121,
262
263    /* Shader constant formats. */
264    SVGA3D_SURFACE_SHADERCONST_FLOAT    = 122,
265    SVGA3D_SURFACE_SHADERCONST_INT      = 123,
266    SVGA3D_SURFACE_SHADERCONST_BOOL     = 124,
267
268    SVGA3D_FORMAT_MAX                   = 125,
269 } SVGA3dSurfaceFormat;
270
271 typedef uint32 SVGA3dColor; /* a, r, g, b */
272
273 /*
274  * These match the D3DFORMAT_OP definitions used by Direct3D. We need
275  * them so that we can query the host for what the supported surface
276  * operations are (when we're using the D3D backend, in particular),
277  * and so we can send those operations to the guest.
278  */
279 typedef enum {
280    SVGA3DFORMAT_OP_TEXTURE                               = 0x00000001,
281    SVGA3DFORMAT_OP_VOLUMETEXTURE                         = 0x00000002,
282    SVGA3DFORMAT_OP_CUBETEXTURE                           = 0x00000004,
283    SVGA3DFORMAT_OP_OFFSCREEN_RENDERTARGET                = 0x00000008,
284    SVGA3DFORMAT_OP_SAME_FORMAT_RENDERTARGET              = 0x00000010,
285    SVGA3DFORMAT_OP_ZSTENCIL                              = 0x00000040,
286    SVGA3DFORMAT_OP_ZSTENCIL_WITH_ARBITRARY_COLOR_DEPTH   = 0x00000080,
287
288 /*
289  * This format can be used as a render target if the current display mode
290  * is the same depth if the alpha channel is ignored. e.g. if the device
291  * can render to A8R8G8B8 when the display mode is X8R8G8B8, then the
292  * format op list entry for A8R8G8B8 should have this cap.
293  */
294    SVGA3DFORMAT_OP_SAME_FORMAT_UP_TO_ALPHA_RENDERTARGET  = 0x00000100,
295
296 /*
297  * This format contains DirectDraw support (including Flip).  This flag
298  * should not to be set on alpha formats.
299  */
300    SVGA3DFORMAT_OP_DISPLAYMODE                           = 0x00000400,
301
302 /*
303  * The rasterizer can support some level of Direct3D support in this format
304  * and implies that the driver can create a Context in this mode (for some
305  * render target format).  When this flag is set, the SVGA3DFORMAT_OP_DISPLAYMODE
306  * flag must also be set.
307  */
308    SVGA3DFORMAT_OP_3DACCELERATION                        = 0x00000800,
309
310 /*
311  * This is set for a private format when the driver has put the bpp in
312  * the structure.
313  */
314    SVGA3DFORMAT_OP_PIXELSIZE                             = 0x00001000,
315
316 /*
317  * Indicates that this format can be converted to any RGB format for which
318  * SVGA3DFORMAT_OP_MEMBEROFGROUP_ARGB is specified
319  */
320    SVGA3DFORMAT_OP_CONVERT_TO_ARGB                       = 0x00002000,
321
322 /*
323  * Indicates that this format can be used to create offscreen plain surfaces.
324  */
325    SVGA3DFORMAT_OP_OFFSCREENPLAIN                        = 0x00004000,
326
327 /*
328  * Indicated that this format can be read as an SRGB texture (meaning that the
329  * sampler will linearize the looked up data)
330  */
331    SVGA3DFORMAT_OP_SRGBREAD                              = 0x00008000,
332
333 /*
334  * Indicates that this format can be used in the bumpmap instructions
335  */
336    SVGA3DFORMAT_OP_BUMPMAP                               = 0x00010000,
337
338 /*
339  * Indicates that this format can be sampled by the displacement map sampler
340  */
341    SVGA3DFORMAT_OP_DMAP                                  = 0x00020000,
342
343 /*
344  * Indicates that this format cannot be used with texture filtering
345  */
346    SVGA3DFORMAT_OP_NOFILTER                              = 0x00040000,
347
348 /*
349  * Indicates that format conversions are supported to this RGB format if
350  * SVGA3DFORMAT_OP_CONVERT_TO_ARGB is specified in the source format.
351  */
352    SVGA3DFORMAT_OP_MEMBEROFGROUP_ARGB                    = 0x00080000,
353
354 /*
355  * Indicated that this format can be written as an SRGB target (meaning that the
356  * pixel pipe will DE-linearize data on output to format)
357  */
358    SVGA3DFORMAT_OP_SRGBWRITE                             = 0x00100000,
359
360 /*
361  * Indicates that this format cannot be used with alpha blending
362  */
363    SVGA3DFORMAT_OP_NOALPHABLEND                          = 0x00200000,
364
365 /*
366  * Indicates that the device can auto-generated sublevels for resources
367  * of this format
368  */
369    SVGA3DFORMAT_OP_AUTOGENMIPMAP                         = 0x00400000,
370
371 /*
372  * Indicates that this format can be used by vertex texture sampler
373  */
374    SVGA3DFORMAT_OP_VERTEXTEXTURE                         = 0x00800000,
375
376 /*
377  * Indicates that this format supports neither texture coordinate wrap
378  * modes, nor mipmapping
379  */
380    SVGA3DFORMAT_OP_NOTEXCOORDWRAPNORMIP                  = 0x01000000
381 } SVGA3dFormatOp;
382
383 /*
384  * This structure is a conversion of SVGA3DFORMAT_OP_*.
385  * Entries must be located at the same position.
386  */
387 typedef union {
388    uint32 value;
389    struct {
390       uint32 texture : 1;
391       uint32 volumeTexture : 1;
392       uint32 cubeTexture : 1;
393       uint32 offscreenRenderTarget : 1;
394       uint32 sameFormatRenderTarget : 1;
395       uint32 unknown1 : 1;
396       uint32 zStencil : 1;
397       uint32 zStencilArbitraryDepth : 1;
398       uint32 sameFormatUpToAlpha : 1;
399       uint32 unknown2 : 1;
400       uint32 displayMode : 1;
401       uint32 acceleration3d : 1;
402       uint32 pixelSize : 1;
403       uint32 convertToARGB : 1;
404       uint32 offscreenPlain : 1;
405       uint32 sRGBRead : 1;
406       uint32 bumpMap : 1;
407       uint32 dmap : 1;
408       uint32 noFilter : 1;
409       uint32 memberOfGroupARGB : 1;
410       uint32 sRGBWrite : 1;
411       uint32 noAlphaBlend : 1;
412       uint32 autoGenMipMap : 1;
413       uint32 vertexTexture : 1;
414       uint32 noTexCoordWrapNorMip : 1;
415    };
416 } SVGA3dSurfaceFormatCaps;
417
418 /*
419  * SVGA_3D_CMD_SETRENDERSTATE Types.  All value types
420  * must fit in a uint32.
421  */
422
423 typedef enum {
424    SVGA3D_RS_INVALID                   = 0,
425    SVGA3D_RS_ZENABLE                   = 1,     /* SVGA3dBool */
426    SVGA3D_RS_ZWRITEENABLE              = 2,     /* SVGA3dBool */
427    SVGA3D_RS_ALPHATESTENABLE           = 3,     /* SVGA3dBool */
428    SVGA3D_RS_DITHERENABLE              = 4,     /* SVGA3dBool */
429    SVGA3D_RS_BLENDENABLE               = 5,     /* SVGA3dBool */
430    SVGA3D_RS_FOGENABLE                 = 6,     /* SVGA3dBool */
431    SVGA3D_RS_SPECULARENABLE            = 7,     /* SVGA3dBool */
432    SVGA3D_RS_STENCILENABLE             = 8,     /* SVGA3dBool */
433    SVGA3D_RS_LIGHTINGENABLE            = 9,     /* SVGA3dBool */
434    SVGA3D_RS_NORMALIZENORMALS          = 10,    /* SVGA3dBool */
435    SVGA3D_RS_POINTSPRITEENABLE         = 11,    /* SVGA3dBool */
436    SVGA3D_RS_POINTSCALEENABLE          = 12,    /* SVGA3dBool */
437    SVGA3D_RS_STENCILREF                = 13,    /* uint32 */
438    SVGA3D_RS_STENCILMASK               = 14,    /* uint32 */
439    SVGA3D_RS_STENCILWRITEMASK          = 15,    /* uint32 */
440    SVGA3D_RS_FOGSTART                  = 16,    /* float */
441    SVGA3D_RS_FOGEND                    = 17,    /* float */
442    SVGA3D_RS_FOGDENSITY                = 18,    /* float */
443    SVGA3D_RS_POINTSIZE                 = 19,    /* float */
444    SVGA3D_RS_POINTSIZEMIN              = 20,    /* float */
445    SVGA3D_RS_POINTSIZEMAX              = 21,    /* float */
446    SVGA3D_RS_POINTSCALE_A              = 22,    /* float */
447    SVGA3D_RS_POINTSCALE_B              = 23,    /* float */
448    SVGA3D_RS_POINTSCALE_C              = 24,    /* float */
449    SVGA3D_RS_FOGCOLOR                  = 25,    /* SVGA3dColor */
450    SVGA3D_RS_AMBIENT                   = 26,    /* SVGA3dColor */
451    SVGA3D_RS_CLIPPLANEENABLE           = 27,    /* SVGA3dClipPlanes */
452    SVGA3D_RS_FOGMODE                   = 28,    /* SVGA3dFogMode */
453    SVGA3D_RS_FILLMODE                  = 29,    /* SVGA3dFillMode */
454    SVGA3D_RS_SHADEMODE                 = 30,    /* SVGA3dShadeMode */
455    SVGA3D_RS_LINEPATTERN               = 31,    /* SVGA3dLinePattern */
456    SVGA3D_RS_SRCBLEND                  = 32,    /* SVGA3dBlendOp */
457    SVGA3D_RS_DSTBLEND                  = 33,    /* SVGA3dBlendOp */
458    SVGA3D_RS_BLENDEQUATION             = 34,    /* SVGA3dBlendEquation */
459    SVGA3D_RS_CULLMODE                  = 35,    /* SVGA3dFace */
460    SVGA3D_RS_ZFUNC                     = 36,    /* SVGA3dCmpFunc */
461    SVGA3D_RS_ALPHAFUNC                 = 37,    /* SVGA3dCmpFunc */
462    SVGA3D_RS_STENCILFUNC               = 38,    /* SVGA3dCmpFunc */
463    SVGA3D_RS_STENCILFAIL               = 39,    /* SVGA3dStencilOp */
464    SVGA3D_RS_STENCILZFAIL              = 40,    /* SVGA3dStencilOp */
465    SVGA3D_RS_STENCILPASS               = 41,    /* SVGA3dStencilOp */
466    SVGA3D_RS_ALPHAREF                  = 42,    /* float (0.0 .. 1.0) */
467    SVGA3D_RS_FRONTWINDING              = 43,    /* SVGA3dFrontWinding */
468    SVGA3D_RS_COORDINATETYPE            = 44,    /* SVGA3dCoordinateType */
469    SVGA3D_RS_ZBIAS                     = 45,    /* float */
470    SVGA3D_RS_RANGEFOGENABLE            = 46,    /* SVGA3dBool */
471    SVGA3D_RS_COLORWRITEENABLE          = 47,    /* SVGA3dColorMask */
472    SVGA3D_RS_VERTEXMATERIALENABLE      = 48,    /* SVGA3dBool */
473    SVGA3D_RS_DIFFUSEMATERIALSOURCE     = 49,    /* SVGA3dVertexMaterial */
474    SVGA3D_RS_SPECULARMATERIALSOURCE    = 50,    /* SVGA3dVertexMaterial */
475    SVGA3D_RS_AMBIENTMATERIALSOURCE     = 51,    /* SVGA3dVertexMaterial */
476    SVGA3D_RS_EMISSIVEMATERIALSOURCE    = 52,    /* SVGA3dVertexMaterial */
477    SVGA3D_RS_TEXTUREFACTOR             = 53,    /* SVGA3dColor */
478    SVGA3D_RS_LOCALVIEWER               = 54,    /* SVGA3dBool */
479    SVGA3D_RS_SCISSORTESTENABLE         = 55,    /* SVGA3dBool */
480    SVGA3D_RS_BLENDCOLOR                = 56,    /* SVGA3dColor */
481    SVGA3D_RS_STENCILENABLE2SIDED       = 57,    /* SVGA3dBool */
482    SVGA3D_RS_CCWSTENCILFUNC            = 58,    /* SVGA3dCmpFunc */
483    SVGA3D_RS_CCWSTENCILFAIL            = 59,    /* SVGA3dStencilOp */
484    SVGA3D_RS_CCWSTENCILZFAIL           = 60,    /* SVGA3dStencilOp */
485    SVGA3D_RS_CCWSTENCILPASS            = 61,    /* SVGA3dStencilOp */
486    SVGA3D_RS_VERTEXBLEND               = 62,    /* SVGA3dVertexBlendFlags */
487    SVGA3D_RS_SLOPESCALEDEPTHBIAS       = 63,    /* float */
488    SVGA3D_RS_DEPTHBIAS                 = 64,    /* float */
489
490
491    /*
492     * Output Gamma Level
493     *
494     * Output gamma effects the gamma curve of colors that are output from the
495     * rendering pipeline.  A value of 1.0 specifies a linear color space. If the
496     * value is <= 0.0, gamma correction is ignored and linear color space is
497     * used.
498     */
499
500    SVGA3D_RS_OUTPUTGAMMA               = 65,    /* float */
501    SVGA3D_RS_ZVISIBLE                  = 66,    /* SVGA3dBool */
502    SVGA3D_RS_LASTPIXEL                 = 67,    /* SVGA3dBool */
503    SVGA3D_RS_CLIPPING                  = 68,    /* SVGA3dBool */
504    SVGA3D_RS_WRAP0                     = 69,    /* SVGA3dWrapFlags */
505    SVGA3D_RS_WRAP1                     = 70,    /* SVGA3dWrapFlags */
506    SVGA3D_RS_WRAP2                     = 71,    /* SVGA3dWrapFlags */
507    SVGA3D_RS_WRAP3                     = 72,    /* SVGA3dWrapFlags */
508    SVGA3D_RS_WRAP4                     = 73,    /* SVGA3dWrapFlags */
509    SVGA3D_RS_WRAP5                     = 74,    /* SVGA3dWrapFlags */
510    SVGA3D_RS_WRAP6                     = 75,    /* SVGA3dWrapFlags */
511    SVGA3D_RS_WRAP7                     = 76,    /* SVGA3dWrapFlags */
512    SVGA3D_RS_WRAP8                     = 77,    /* SVGA3dWrapFlags */
513    SVGA3D_RS_WRAP9                     = 78,    /* SVGA3dWrapFlags */
514    SVGA3D_RS_WRAP10                    = 79,    /* SVGA3dWrapFlags */
515    SVGA3D_RS_WRAP11                    = 80,    /* SVGA3dWrapFlags */
516    SVGA3D_RS_WRAP12                    = 81,    /* SVGA3dWrapFlags */
517    SVGA3D_RS_WRAP13                    = 82,    /* SVGA3dWrapFlags */
518    SVGA3D_RS_WRAP14                    = 83,    /* SVGA3dWrapFlags */
519    SVGA3D_RS_WRAP15                    = 84,    /* SVGA3dWrapFlags */
520    SVGA3D_RS_MULTISAMPLEANTIALIAS      = 85,    /* SVGA3dBool */
521    SVGA3D_RS_MULTISAMPLEMASK           = 86,    /* uint32 */
522    SVGA3D_RS_INDEXEDVERTEXBLENDENABLE  = 87,    /* SVGA3dBool */
523    SVGA3D_RS_TWEENFACTOR               = 88,    /* float */
524    SVGA3D_RS_ANTIALIASEDLINEENABLE     = 89,    /* SVGA3dBool */
525    SVGA3D_RS_COLORWRITEENABLE1         = 90,    /* SVGA3dColorMask */
526    SVGA3D_RS_COLORWRITEENABLE2         = 91,    /* SVGA3dColorMask */
527    SVGA3D_RS_COLORWRITEENABLE3         = 92,    /* SVGA3dColorMask */
528    SVGA3D_RS_SEPARATEALPHABLENDENABLE  = 93,    /* SVGA3dBool */
529    SVGA3D_RS_SRCBLENDALPHA             = 94,    /* SVGA3dBlendOp */
530    SVGA3D_RS_DSTBLENDALPHA             = 95,    /* SVGA3dBlendOp */
531    SVGA3D_RS_BLENDEQUATIONALPHA        = 96,    /* SVGA3dBlendEquation */
532    SVGA3D_RS_TRANSPARENCYANTIALIAS     = 97,    /* SVGA3dTransparencyAntialiasType */
533    SVGA3D_RS_LINEAA                    = 98,    /* SVGA3dBool */
534    SVGA3D_RS_LINEWIDTH                 = 99,    /* float */
535    SVGA3D_RS_MAX
536 } SVGA3dRenderStateName;
537
538 typedef enum {
539    SVGA3D_TRANSPARENCYANTIALIAS_NORMAL            = 0,
540    SVGA3D_TRANSPARENCYANTIALIAS_ALPHATOCOVERAGE   = 1,
541    SVGA3D_TRANSPARENCYANTIALIAS_SUPERSAMPLE       = 2,
542    SVGA3D_TRANSPARENCYANTIALIAS_MAX
543 } SVGA3dTransparencyAntialiasType;
544
545 typedef enum {
546    SVGA3D_VERTEXMATERIAL_NONE     = 0,    /* Use the value in the current material */
547    SVGA3D_VERTEXMATERIAL_DIFFUSE  = 1,    /* Use the value in the diffuse component */
548    SVGA3D_VERTEXMATERIAL_SPECULAR = 2,    /* Use the value in the specular component */
549 } SVGA3dVertexMaterial;
550
551 typedef enum {
552    SVGA3D_FILLMODE_INVALID = 0,
553    SVGA3D_FILLMODE_POINT   = 1,
554    SVGA3D_FILLMODE_LINE    = 2,
555    SVGA3D_FILLMODE_FILL    = 3,
556    SVGA3D_FILLMODE_MAX
557 } SVGA3dFillModeType;
558
559
560 typedef
561 union {
562    struct {
563       uint16   mode;       /* SVGA3dFillModeType */
564       uint16   face;       /* SVGA3dFace */
565    };
566    uint32 uintValue;
567 } SVGA3dFillMode;
568
569 typedef enum {
570    SVGA3D_SHADEMODE_INVALID = 0,
571    SVGA3D_SHADEMODE_FLAT    = 1,
572    SVGA3D_SHADEMODE_SMOOTH  = 2,
573    SVGA3D_SHADEMODE_PHONG   = 3,     /* Not supported */
574    SVGA3D_SHADEMODE_MAX
575 } SVGA3dShadeMode;
576
577 typedef
578 union {
579    struct {
580       uint16 repeat;
581       uint16 pattern;
582    };
583    uint32 uintValue;
584 } SVGA3dLinePattern;
585
586 typedef enum {
587    SVGA3D_BLENDOP_INVALID            = 0,
588    SVGA3D_BLENDOP_ZERO               = 1,
589    SVGA3D_BLENDOP_ONE                = 2,
590    SVGA3D_BLENDOP_SRCCOLOR           = 3,
591    SVGA3D_BLENDOP_INVSRCCOLOR        = 4,
592    SVGA3D_BLENDOP_SRCALPHA           = 5,
593    SVGA3D_BLENDOP_INVSRCALPHA        = 6,
594    SVGA3D_BLENDOP_DESTALPHA          = 7,
595    SVGA3D_BLENDOP_INVDESTALPHA       = 8,
596    SVGA3D_BLENDOP_DESTCOLOR          = 9,
597    SVGA3D_BLENDOP_INVDESTCOLOR       = 10,
598    SVGA3D_BLENDOP_SRCALPHASAT        = 11,
599    SVGA3D_BLENDOP_BLENDFACTOR        = 12,
600    SVGA3D_BLENDOP_INVBLENDFACTOR     = 13,
601    SVGA3D_BLENDOP_MAX
602 } SVGA3dBlendOp;
603
604 typedef enum {
605    SVGA3D_BLENDEQ_INVALID            = 0,
606    SVGA3D_BLENDEQ_ADD                = 1,
607    SVGA3D_BLENDEQ_SUBTRACT           = 2,
608    SVGA3D_BLENDEQ_REVSUBTRACT        = 3,
609    SVGA3D_BLENDEQ_MINIMUM            = 4,
610    SVGA3D_BLENDEQ_MAXIMUM            = 5,
611    SVGA3D_BLENDEQ_MAX
612 } SVGA3dBlendEquation;
613
614 typedef enum {
615    SVGA3D_FRONTWINDING_INVALID = 0,
616    SVGA3D_FRONTWINDING_CW      = 1,
617    SVGA3D_FRONTWINDING_CCW     = 2,
618    SVGA3D_FRONTWINDING_MAX
619 } SVGA3dFrontWinding;
620
621 typedef enum {
622    SVGA3D_FACE_INVALID  = 0,
623    SVGA3D_FACE_NONE     = 1,
624    SVGA3D_FACE_FRONT    = 2,
625    SVGA3D_FACE_BACK     = 3,
626    SVGA3D_FACE_FRONT_BACK = 4,
627    SVGA3D_FACE_MAX
628 } SVGA3dFace;
629
630 /*
631  * The order and the values should not be changed
632  */
633
634 typedef enum {
635    SVGA3D_CMP_INVALID              = 0,
636    SVGA3D_CMP_NEVER                = 1,
637    SVGA3D_CMP_LESS                 = 2,
638    SVGA3D_CMP_EQUAL                = 3,
639    SVGA3D_CMP_LESSEQUAL            = 4,
640    SVGA3D_CMP_GREATER              = 5,
641    SVGA3D_CMP_NOTEQUAL             = 6,
642    SVGA3D_CMP_GREATEREQUAL         = 7,
643    SVGA3D_CMP_ALWAYS               = 8,
644    SVGA3D_CMP_MAX
645 } SVGA3dCmpFunc;
646
647 /*
648  * SVGA3D_FOGFUNC_* specifies the fog equation, or PER_VERTEX which allows
649  * the fog factor to be specified in the alpha component of the specular
650  * (a.k.a. secondary) vertex color.
651  */
652 typedef enum {
653    SVGA3D_FOGFUNC_INVALID          = 0,
654    SVGA3D_FOGFUNC_EXP              = 1,
655    SVGA3D_FOGFUNC_EXP2             = 2,
656    SVGA3D_FOGFUNC_LINEAR           = 3,
657    SVGA3D_FOGFUNC_PER_VERTEX       = 4
658 } SVGA3dFogFunction;
659
660 /*
661  * SVGA3D_FOGTYPE_* specifies if fog factors are computed on a per-vertex
662  * or per-pixel basis.
663  */
664 typedef enum {
665    SVGA3D_FOGTYPE_INVALID          = 0,
666    SVGA3D_FOGTYPE_VERTEX           = 1,
667    SVGA3D_FOGTYPE_PIXEL            = 2,
668    SVGA3D_FOGTYPE_MAX              = 3
669 } SVGA3dFogType;
670
671 /*
672  * SVGA3D_FOGBASE_* selects depth or range-based fog. Depth-based fog is
673  * computed using the eye Z value of each pixel (or vertex), whereas range-
674  * based fog is computed using the actual distance (range) to the eye.
675  */
676 typedef enum {
677    SVGA3D_FOGBASE_INVALID          = 0,
678    SVGA3D_FOGBASE_DEPTHBASED       = 1,
679    SVGA3D_FOGBASE_RANGEBASED       = 2,
680    SVGA3D_FOGBASE_MAX              = 3
681 } SVGA3dFogBase;
682
683 typedef enum {
684    SVGA3D_STENCILOP_INVALID        = 0,
685    SVGA3D_STENCILOP_KEEP           = 1,
686    SVGA3D_STENCILOP_ZERO           = 2,
687    SVGA3D_STENCILOP_REPLACE        = 3,
688    SVGA3D_STENCILOP_INCRSAT        = 4,
689    SVGA3D_STENCILOP_DECRSAT        = 5,
690    SVGA3D_STENCILOP_INVERT         = 6,
691    SVGA3D_STENCILOP_INCR           = 7,
692    SVGA3D_STENCILOP_DECR           = 8,
693    SVGA3D_STENCILOP_MAX
694 } SVGA3dStencilOp;
695
696 typedef enum {
697    SVGA3D_CLIPPLANE_0              = (1 << 0),
698    SVGA3D_CLIPPLANE_1              = (1 << 1),
699    SVGA3D_CLIPPLANE_2              = (1 << 2),
700    SVGA3D_CLIPPLANE_3              = (1 << 3),
701    SVGA3D_CLIPPLANE_4              = (1 << 4),
702    SVGA3D_CLIPPLANE_5              = (1 << 5),
703 } SVGA3dClipPlanes;
704
705 typedef enum {
706    SVGA3D_CLEAR_COLOR              = 0x1,
707    SVGA3D_CLEAR_DEPTH              = 0x2,
708    SVGA3D_CLEAR_STENCIL            = 0x4
709 } SVGA3dClearFlag;
710
711 typedef enum {
712    SVGA3D_RT_DEPTH                 = 0,
713    SVGA3D_RT_STENCIL               = 1,
714    SVGA3D_RT_COLOR0                = 2,
715    SVGA3D_RT_COLOR1                = 3,
716    SVGA3D_RT_COLOR2                = 4,
717    SVGA3D_RT_COLOR3                = 5,
718    SVGA3D_RT_COLOR4                = 6,
719    SVGA3D_RT_COLOR5                = 7,
720    SVGA3D_RT_COLOR6                = 8,
721    SVGA3D_RT_COLOR7                = 9,
722    SVGA3D_RT_MAX,
723    SVGA3D_RT_INVALID               = ((uint32)-1),
724 } SVGA3dRenderTargetType;
725
726 #define SVGA3D_MAX_RT_COLOR (SVGA3D_RT_COLOR7 - SVGA3D_RT_COLOR0 + 1)
727
728 typedef
729 union {
730    struct {
731       uint32  red   : 1;
732       uint32  green : 1;
733       uint32  blue  : 1;
734       uint32  alpha : 1;
735    };
736    uint32 uintValue;
737 } SVGA3dColorMask;
738
739 typedef enum {
740    SVGA3D_VBLEND_DISABLE            = 0,
741    SVGA3D_VBLEND_1WEIGHT            = 1,
742    SVGA3D_VBLEND_2WEIGHT            = 2,
743    SVGA3D_VBLEND_3WEIGHT            = 3,
744 } SVGA3dVertexBlendFlags;
745
746 typedef enum {
747    SVGA3D_WRAPCOORD_0   = 1 << 0,
748    SVGA3D_WRAPCOORD_1   = 1 << 1,
749    SVGA3D_WRAPCOORD_2   = 1 << 2,
750    SVGA3D_WRAPCOORD_3   = 1 << 3,
751    SVGA3D_WRAPCOORD_ALL = 0xF,
752 } SVGA3dWrapFlags;
753
754 /*
755  * SVGA_3D_CMD_TEXTURESTATE Types.  All value types
756  * must fit in a uint32.
757  */
758
759 typedef enum {
760    SVGA3D_TS_INVALID                    = 0,
761    SVGA3D_TS_BIND_TEXTURE               = 1,    /* SVGA3dSurfaceId */
762    SVGA3D_TS_COLOROP                    = 2,    /* SVGA3dTextureCombiner */
763    SVGA3D_TS_COLORARG1                  = 3,    /* SVGA3dTextureArgData */
764    SVGA3D_TS_COLORARG2                  = 4,    /* SVGA3dTextureArgData */
765    SVGA3D_TS_ALPHAOP                    = 5,    /* SVGA3dTextureCombiner */
766    SVGA3D_TS_ALPHAARG1                  = 6,    /* SVGA3dTextureArgData */
767    SVGA3D_TS_ALPHAARG2                  = 7,    /* SVGA3dTextureArgData */
768    SVGA3D_TS_ADDRESSU                   = 8,    /* SVGA3dTextureAddress */
769    SVGA3D_TS_ADDRESSV                   = 9,    /* SVGA3dTextureAddress */
770    SVGA3D_TS_MIPFILTER                  = 10,   /* SVGA3dTextureFilter */
771    SVGA3D_TS_MAGFILTER                  = 11,   /* SVGA3dTextureFilter */
772    SVGA3D_TS_MINFILTER                  = 12,   /* SVGA3dTextureFilter */
773    SVGA3D_TS_BORDERCOLOR                = 13,   /* SVGA3dColor */
774    SVGA3D_TS_TEXCOORDINDEX              = 14,   /* uint32 */
775    SVGA3D_TS_TEXTURETRANSFORMFLAGS      = 15,   /* SVGA3dTexTransformFlags */
776    SVGA3D_TS_TEXCOORDGEN                = 16,   /* SVGA3dTextureCoordGen */
777    SVGA3D_TS_BUMPENVMAT00               = 17,   /* float */
778    SVGA3D_TS_BUMPENVMAT01               = 18,   /* float */
779    SVGA3D_TS_BUMPENVMAT10               = 19,   /* float */
780    SVGA3D_TS_BUMPENVMAT11               = 20,   /* float */
781    SVGA3D_TS_TEXTURE_MIPMAP_LEVEL       = 21,   /* uint32 */
782    SVGA3D_TS_TEXTURE_LOD_BIAS           = 22,   /* float */
783    SVGA3D_TS_TEXTURE_ANISOTROPIC_LEVEL  = 23,   /* uint32 */
784    SVGA3D_TS_ADDRESSW                   = 24,   /* SVGA3dTextureAddress */
785
786
787    /*
788     * Sampler Gamma Level
789     *
790     * Sampler gamma effects the color of samples taken from the sampler.  A
791     * value of 1.0 will produce linear samples.  If the value is <= 0.0 the
792     * gamma value is ignored and a linear space is used.
793     */
794
795    SVGA3D_TS_GAMMA                      = 25,   /* float */
796    SVGA3D_TS_BUMPENVLSCALE              = 26,   /* float */
797    SVGA3D_TS_BUMPENVLOFFSET             = 27,   /* float */
798    SVGA3D_TS_COLORARG0                  = 28,   /* SVGA3dTextureArgData */
799    SVGA3D_TS_ALPHAARG0                  = 29,   /* SVGA3dTextureArgData */
800    SVGA3D_TS_MAX
801 } SVGA3dTextureStateName;
802
803 typedef enum {
804    SVGA3D_TC_INVALID                   = 0,
805    SVGA3D_TC_DISABLE                   = 1,
806    SVGA3D_TC_SELECTARG1                = 2,
807    SVGA3D_TC_SELECTARG2                = 3,
808    SVGA3D_TC_MODULATE                  = 4,
809    SVGA3D_TC_ADD                       = 5,
810    SVGA3D_TC_ADDSIGNED                 = 6,
811    SVGA3D_TC_SUBTRACT                  = 7,
812    SVGA3D_TC_BLENDTEXTUREALPHA         = 8,
813    SVGA3D_TC_BLENDDIFFUSEALPHA         = 9,
814    SVGA3D_TC_BLENDCURRENTALPHA         = 10,
815    SVGA3D_TC_BLENDFACTORALPHA          = 11,
816    SVGA3D_TC_MODULATE2X                = 12,
817    SVGA3D_TC_MODULATE4X                = 13,
818    SVGA3D_TC_DSDT                      = 14,
819    SVGA3D_TC_DOTPRODUCT3               = 15,
820    SVGA3D_TC_BLENDTEXTUREALPHAPM       = 16,
821    SVGA3D_TC_ADDSIGNED2X               = 17,
822    SVGA3D_TC_ADDSMOOTH                 = 18,
823    SVGA3D_TC_PREMODULATE               = 19,
824    SVGA3D_TC_MODULATEALPHA_ADDCOLOR    = 20,
825    SVGA3D_TC_MODULATECOLOR_ADDALPHA    = 21,
826    SVGA3D_TC_MODULATEINVALPHA_ADDCOLOR = 22,
827    SVGA3D_TC_MODULATEINVCOLOR_ADDALPHA = 23,
828    SVGA3D_TC_BUMPENVMAPLUMINANCE       = 24,
829    SVGA3D_TC_MULTIPLYADD               = 25,
830    SVGA3D_TC_LERP                      = 26,
831    SVGA3D_TC_MAX
832 } SVGA3dTextureCombiner;
833
834 #define SVGA3D_TC_CAP_BIT(svga3d_tc_op) (svga3d_tc_op ? (1 << (svga3d_tc_op - 1)) : 0)
835
836 typedef enum {
837    SVGA3D_TEX_ADDRESS_INVALID    = 0,
838    SVGA3D_TEX_ADDRESS_WRAP       = 1,
839    SVGA3D_TEX_ADDRESS_MIRROR     = 2,
840    SVGA3D_TEX_ADDRESS_CLAMP      = 3,
841    SVGA3D_TEX_ADDRESS_BORDER     = 4,
842    SVGA3D_TEX_ADDRESS_MIRRORONCE = 5,
843    SVGA3D_TEX_ADDRESS_EDGE       = 6,
844    SVGA3D_TEX_ADDRESS_MAX
845 } SVGA3dTextureAddress;
846
847 /*
848  * SVGA3D_TEX_FILTER_NONE as the minification filter means mipmapping is
849  * disabled, and the rasterizer should use the magnification filter instead.
850  */
851 typedef enum {
852    SVGA3D_TEX_FILTER_NONE           = 0,
853    SVGA3D_TEX_FILTER_NEAREST        = 1,
854    SVGA3D_TEX_FILTER_LINEAR         = 2,
855    SVGA3D_TEX_FILTER_ANISOTROPIC    = 3,
856    SVGA3D_TEX_FILTER_FLATCUBIC      = 4, /* Deprecated, not implemented */
857    SVGA3D_TEX_FILTER_GAUSSIANCUBIC  = 5, /* Deprecated, not implemented */
858    SVGA3D_TEX_FILTER_PYRAMIDALQUAD  = 6, /* Not currently implemented */
859    SVGA3D_TEX_FILTER_GAUSSIANQUAD   = 7, /* Not currently implemented */
860    SVGA3D_TEX_FILTER_MAX
861 } SVGA3dTextureFilter;
862
863 typedef enum {
864    SVGA3D_TEX_TRANSFORM_OFF    = 0,
865    SVGA3D_TEX_TRANSFORM_S      = (1 << 0),
866    SVGA3D_TEX_TRANSFORM_T      = (1 << 1),
867    SVGA3D_TEX_TRANSFORM_R      = (1 << 2),
868    SVGA3D_TEX_TRANSFORM_Q      = (1 << 3),
869    SVGA3D_TEX_PROJECTED        = (1 << 15),
870 } SVGA3dTexTransformFlags;
871
872 typedef enum {
873    SVGA3D_TEXCOORD_GEN_OFF              = 0,
874    SVGA3D_TEXCOORD_GEN_EYE_POSITION     = 1,
875    SVGA3D_TEXCOORD_GEN_EYE_NORMAL       = 2,
876    SVGA3D_TEXCOORD_GEN_REFLECTIONVECTOR = 3,
877    SVGA3D_TEXCOORD_GEN_SPHERE           = 4,
878    SVGA3D_TEXCOORD_GEN_MAX
879 } SVGA3dTextureCoordGen;
880
881 /*
882  * Texture argument constants for texture combiner
883  */
884 typedef enum {
885    SVGA3D_TA_INVALID    = 0,
886    SVGA3D_TA_CONSTANT   = 1,
887    SVGA3D_TA_PREVIOUS   = 2,
888    SVGA3D_TA_DIFFUSE    = 3,
889    SVGA3D_TA_TEXTURE    = 4,
890    SVGA3D_TA_SPECULAR   = 5,
891    SVGA3D_TA_MAX
892 } SVGA3dTextureArgData;
893
894 #define SVGA3D_TM_MASK_LEN 4
895
896 /* Modifiers for texture argument constants defined above. */
897 typedef enum {
898    SVGA3D_TM_NONE       = 0,
899    SVGA3D_TM_ALPHA      = (1 << SVGA3D_TM_MASK_LEN),
900    SVGA3D_TM_ONE_MINUS  = (2 << SVGA3D_TM_MASK_LEN),
901 } SVGA3dTextureArgModifier;
902
903 #define SVGA3D_INVALID_ID         ((uint32)-1)
904 #define SVGA3D_MAX_CLIP_PLANES    6
905
906 /*
907  * This is the limit to the number of fixed-function texture
908  * transforms and texture coordinates we can support. It does *not*
909  * correspond to the number of texture image units (samplers) we
910  * support!
911  */
912 #define SVGA3D_MAX_TEXTURE_COORDS 8
913
914 /*
915  * Vertex declarations
916  *
917  * Notes:
918  *
919  * SVGA3D_DECLUSAGE_POSITIONT is for pre-transformed vertices. If you
920  * draw with any POSITIONT vertex arrays, the programmable vertex
921  * pipeline will be implicitly disabled. Drawing will take place as if
922  * no vertex shader was bound.
923  */
924
925 typedef enum {
926    SVGA3D_DECLUSAGE_POSITION     = 0,
927    SVGA3D_DECLUSAGE_BLENDWEIGHT,       /*  1 */
928    SVGA3D_DECLUSAGE_BLENDINDICES,      /*  2 */
929    SVGA3D_DECLUSAGE_NORMAL,            /*  3 */
930    SVGA3D_DECLUSAGE_PSIZE,             /*  4 */
931    SVGA3D_DECLUSAGE_TEXCOORD,          /*  5 */
932    SVGA3D_DECLUSAGE_TANGENT,           /*  6 */
933    SVGA3D_DECLUSAGE_BINORMAL,          /*  7 */
934    SVGA3D_DECLUSAGE_TESSFACTOR,        /*  8 */
935    SVGA3D_DECLUSAGE_POSITIONT,         /*  9 */
936    SVGA3D_DECLUSAGE_COLOR,             /* 10 */
937    SVGA3D_DECLUSAGE_FOG,               /* 11 */
938    SVGA3D_DECLUSAGE_DEPTH,             /* 12 */
939    SVGA3D_DECLUSAGE_SAMPLE,            /* 13 */
940    SVGA3D_DECLUSAGE_MAX
941 } SVGA3dDeclUsage;
942
943 typedef enum {
944    SVGA3D_DECLMETHOD_DEFAULT     = 0,
945    SVGA3D_DECLMETHOD_PARTIALU,
946    SVGA3D_DECLMETHOD_PARTIALV,
947    SVGA3D_DECLMETHOD_CROSSUV,          /* Normal */
948    SVGA3D_DECLMETHOD_UV,
949    SVGA3D_DECLMETHOD_LOOKUP,           /* Lookup a displacement map */
950    SVGA3D_DECLMETHOD_LOOKUPPRESAMPLED, /* Lookup a pre-sampled displacement map */
951 } SVGA3dDeclMethod;
952
953 typedef enum {
954    SVGA3D_DECLTYPE_FLOAT1        =  0,
955    SVGA3D_DECLTYPE_FLOAT2        =  1,
956    SVGA3D_DECLTYPE_FLOAT3        =  2,
957    SVGA3D_DECLTYPE_FLOAT4        =  3,
958    SVGA3D_DECLTYPE_D3DCOLOR      =  4,
959    SVGA3D_DECLTYPE_UBYTE4        =  5,
960    SVGA3D_DECLTYPE_SHORT2        =  6,
961    SVGA3D_DECLTYPE_SHORT4        =  7,
962    SVGA3D_DECLTYPE_UBYTE4N       =  8,
963    SVGA3D_DECLTYPE_SHORT2N       =  9,
964    SVGA3D_DECLTYPE_SHORT4N       = 10,
965    SVGA3D_DECLTYPE_USHORT2N      = 11,
966    SVGA3D_DECLTYPE_USHORT4N      = 12,
967    SVGA3D_DECLTYPE_UDEC3         = 13,
968    SVGA3D_DECLTYPE_DEC3N         = 14,
969    SVGA3D_DECLTYPE_FLOAT16_2     = 15,
970    SVGA3D_DECLTYPE_FLOAT16_4     = 16,
971    SVGA3D_DECLTYPE_MAX,
972 } SVGA3dDeclType;
973
974 /*
975  * This structure is used for the divisor for geometry instancing;
976  * it's a direct translation of the Direct3D equivalent.
977  */
978 typedef union {
979    struct {
980       /*
981        * For index data, this number represents the number of instances to draw.
982        * For instance data, this number represents the number of
983        * instances/vertex in this stream
984        */
985       uint32 count : 30;
986
987       /*
988        * This is 1 if this is supposed to be the data that is repeated for
989        * every instance.
990        */
991       uint32 indexedData : 1;
992
993       /*
994        * This is 1 if this is supposed to be the per-instance data.
995        */
996       uint32 instanceData : 1;
997    };
998
999    uint32 value;
1000 } SVGA3dVertexDivisor;
1001
1002 typedef enum {
1003    SVGA3D_PRIMITIVE_INVALID                     = 0,
1004    SVGA3D_PRIMITIVE_TRIANGLELIST                = 1,
1005    SVGA3D_PRIMITIVE_POINTLIST                   = 2,
1006    SVGA3D_PRIMITIVE_LINELIST                    = 3,
1007    SVGA3D_PRIMITIVE_LINESTRIP                   = 4,
1008    SVGA3D_PRIMITIVE_TRIANGLESTRIP               = 5,
1009    SVGA3D_PRIMITIVE_TRIANGLEFAN                 = 6,
1010    SVGA3D_PRIMITIVE_MAX
1011 } SVGA3dPrimitiveType;
1012
1013 typedef enum {
1014    SVGA3D_COORDINATE_INVALID                   = 0,
1015    SVGA3D_COORDINATE_LEFTHANDED                = 1,
1016    SVGA3D_COORDINATE_RIGHTHANDED               = 2,
1017    SVGA3D_COORDINATE_MAX
1018 } SVGA3dCoordinateType;
1019
1020 typedef enum {
1021    SVGA3D_TRANSFORM_INVALID                     = 0,
1022    SVGA3D_TRANSFORM_WORLD                       = 1,
1023    SVGA3D_TRANSFORM_VIEW                        = 2,
1024    SVGA3D_TRANSFORM_PROJECTION                  = 3,
1025    SVGA3D_TRANSFORM_TEXTURE0                    = 4,
1026    SVGA3D_TRANSFORM_TEXTURE1                    = 5,
1027    SVGA3D_TRANSFORM_TEXTURE2                    = 6,
1028    SVGA3D_TRANSFORM_TEXTURE3                    = 7,
1029    SVGA3D_TRANSFORM_TEXTURE4                    = 8,
1030    SVGA3D_TRANSFORM_TEXTURE5                    = 9,
1031    SVGA3D_TRANSFORM_TEXTURE6                    = 10,
1032    SVGA3D_TRANSFORM_TEXTURE7                    = 11,
1033    SVGA3D_TRANSFORM_WORLD1                      = 12,
1034    SVGA3D_TRANSFORM_WORLD2                      = 13,
1035    SVGA3D_TRANSFORM_WORLD3                      = 14,
1036    SVGA3D_TRANSFORM_MAX
1037 } SVGA3dTransformType;
1038
1039 typedef enum {
1040    SVGA3D_LIGHTTYPE_INVALID                     = 0,
1041    SVGA3D_LIGHTTYPE_POINT                       = 1,
1042    SVGA3D_LIGHTTYPE_SPOT1                       = 2, /* 1-cone, in degrees */
1043    SVGA3D_LIGHTTYPE_SPOT2                       = 3, /* 2-cone, in radians */
1044    SVGA3D_LIGHTTYPE_DIRECTIONAL                 = 4,
1045    SVGA3D_LIGHTTYPE_MAX
1046 } SVGA3dLightType;
1047
1048 typedef enum {
1049    SVGA3D_CUBEFACE_POSX                         = 0,
1050    SVGA3D_CUBEFACE_NEGX                         = 1,
1051    SVGA3D_CUBEFACE_POSY                         = 2,
1052    SVGA3D_CUBEFACE_NEGY                         = 3,
1053    SVGA3D_CUBEFACE_POSZ                         = 4,
1054    SVGA3D_CUBEFACE_NEGZ                         = 5,
1055 } SVGA3dCubeFace;
1056
1057 typedef enum {
1058    SVGA3D_SHADERTYPE_INVALID                    = 0,
1059    SVGA3D_SHADERTYPE_MIN                        = 1,
1060    SVGA3D_SHADERTYPE_VS                         = 1,
1061    SVGA3D_SHADERTYPE_PS                         = 2,
1062    SVGA3D_SHADERTYPE_MAX                        = 3,
1063    SVGA3D_SHADERTYPE_GS                         = 3,
1064 } SVGA3dShaderType;
1065
1066 #define SVGA3D_NUM_SHADERTYPE (SVGA3D_SHADERTYPE_MAX - SVGA3D_SHADERTYPE_MIN)
1067
1068 typedef enum {
1069    SVGA3D_CONST_TYPE_FLOAT                      = 0,
1070    SVGA3D_CONST_TYPE_INT                        = 1,
1071    SVGA3D_CONST_TYPE_BOOL                       = 2,
1072    SVGA3D_CONST_TYPE_MAX
1073 } SVGA3dShaderConstType;
1074
1075 #define SVGA3D_MAX_SURFACE_FACES                6
1076
1077 typedef enum {
1078    SVGA3D_STRETCH_BLT_POINT                     = 0,
1079    SVGA3D_STRETCH_BLT_LINEAR                    = 1,
1080    SVGA3D_STRETCH_BLT_MAX
1081 } SVGA3dStretchBltMode;
1082
1083 typedef enum {
1084    SVGA3D_QUERYTYPE_OCCLUSION                   = 0,
1085    SVGA3D_QUERYTYPE_MAX
1086 } SVGA3dQueryType;
1087
1088 typedef enum {
1089    SVGA3D_QUERYSTATE_PENDING     = 0,      /* Waiting on the host (set by guest) */
1090    SVGA3D_QUERYSTATE_SUCCEEDED   = 1,      /* Completed successfully (set by host) */
1091    SVGA3D_QUERYSTATE_FAILED      = 2,      /* Completed unsuccessfully (set by host) */
1092    SVGA3D_QUERYSTATE_NEW         = 3,      /* Never submitted (For guest use only) */
1093 } SVGA3dQueryState;
1094
1095 typedef enum {
1096    SVGA3D_WRITE_HOST_VRAM        = 1,
1097    SVGA3D_READ_HOST_VRAM         = 2,
1098 } SVGA3dTransferType;
1099
1100 /*
1101  * The maximum number of vertex arrays we're guaranteed to support in
1102  * SVGA_3D_CMD_DRAWPRIMITIVES.
1103  */
1104 #define SVGA3D_MAX_VERTEX_ARRAYS   32
1105
1106 /*
1107  * The maximum number of primitive ranges we're guaranteed to support
1108  * in SVGA_3D_CMD_DRAWPRIMITIVES.
1109  */
1110 #define SVGA3D_MAX_DRAW_PRIMITIVE_RANGES 32
1111
1112 /*
1113  * Identifiers for commands in the command FIFO.
1114  *
1115  * IDs between 1000 and 1039 (inclusive) were used by obsolete versions of
1116  * the SVGA3D protocol and remain reserved; they should not be used in the
1117  * future.
1118  *
1119  * IDs between 1040 and 1999 (inclusive) are available for use by the
1120  * current SVGA3D protocol.
1121  *
1122  * FIFO clients other than SVGA3D should stay below 1000, or at 2000
1123  * and up.
1124  */
1125
1126 #define SVGA_3D_CMD_LEGACY_BASE            1000
1127 #define SVGA_3D_CMD_BASE                   1040
1128
1129 #define SVGA_3D_CMD_SURFACE_DEFINE         SVGA_3D_CMD_BASE + 0     /* Deprecated */
1130 #define SVGA_3D_CMD_SURFACE_DESTROY        SVGA_3D_CMD_BASE + 1
1131 #define SVGA_3D_CMD_SURFACE_COPY           SVGA_3D_CMD_BASE + 2
1132 #define SVGA_3D_CMD_SURFACE_STRETCHBLT     SVGA_3D_CMD_BASE + 3
1133 #define SVGA_3D_CMD_SURFACE_DMA            SVGA_3D_CMD_BASE + 4
1134 #define SVGA_3D_CMD_CONTEXT_DEFINE         SVGA_3D_CMD_BASE + 5
1135 #define SVGA_3D_CMD_CONTEXT_DESTROY        SVGA_3D_CMD_BASE + 6
1136 #define SVGA_3D_CMD_SETTRANSFORM           SVGA_3D_CMD_BASE + 7
1137 #define SVGA_3D_CMD_SETZRANGE              SVGA_3D_CMD_BASE + 8
1138 #define SVGA_3D_CMD_SETRENDERSTATE         SVGA_3D_CMD_BASE + 9
1139 #define SVGA_3D_CMD_SETRENDERTARGET        SVGA_3D_CMD_BASE + 10
1140 #define SVGA_3D_CMD_SETTEXTURESTATE        SVGA_3D_CMD_BASE + 11
1141 #define SVGA_3D_CMD_SETMATERIAL            SVGA_3D_CMD_BASE + 12
1142 #define SVGA_3D_CMD_SETLIGHTDATA           SVGA_3D_CMD_BASE + 13
1143 #define SVGA_3D_CMD_SETLIGHTENABLED        SVGA_3D_CMD_BASE + 14
1144 #define SVGA_3D_CMD_SETVIEWPORT            SVGA_3D_CMD_BASE + 15
1145 #define SVGA_3D_CMD_SETCLIPPLANE           SVGA_3D_CMD_BASE + 16
1146 #define SVGA_3D_CMD_CLEAR                  SVGA_3D_CMD_BASE + 17
1147 #define SVGA_3D_CMD_PRESENT                SVGA_3D_CMD_BASE + 18    /* Deprecated */
1148 #define SVGA_3D_CMD_SHADER_DEFINE          SVGA_3D_CMD_BASE + 19
1149 #define SVGA_3D_CMD_SHADER_DESTROY         SVGA_3D_CMD_BASE + 20
1150 #define SVGA_3D_CMD_SET_SHADER             SVGA_3D_CMD_BASE + 21
1151 #define SVGA_3D_CMD_SET_SHADER_CONST       SVGA_3D_CMD_BASE + 22
1152 #define SVGA_3D_CMD_DRAW_PRIMITIVES        SVGA_3D_CMD_BASE + 23
1153 #define SVGA_3D_CMD_SETSCISSORRECT         SVGA_3D_CMD_BASE + 24
1154 #define SVGA_3D_CMD_BEGIN_QUERY            SVGA_3D_CMD_BASE + 25
1155 #define SVGA_3D_CMD_END_QUERY              SVGA_3D_CMD_BASE + 26
1156 #define SVGA_3D_CMD_WAIT_FOR_QUERY         SVGA_3D_CMD_BASE + 27
1157 #define SVGA_3D_CMD_PRESENT_READBACK       SVGA_3D_CMD_BASE + 28    /* Deprecated */
1158 #define SVGA_3D_CMD_BLIT_SURFACE_TO_SCREEN SVGA_3D_CMD_BASE + 29
1159 #define SVGA_3D_CMD_SURFACE_DEFINE_V2      SVGA_3D_CMD_BASE + 30
1160 #define SVGA_3D_CMD_GENERATE_MIPMAPS       SVGA_3D_CMD_BASE + 31
1161 #define SVGA_3D_CMD_ACTIVATE_SURFACE       SVGA_3D_CMD_BASE + 40
1162 #define SVGA_3D_CMD_DEACTIVATE_SURFACE     SVGA_3D_CMD_BASE + 41
1163 #define SVGA_3D_CMD_SCREEN_DMA               1082
1164 #define SVGA_3D_CMD_SET_UNITY_SURFACE_COOKIE 1083
1165 #define SVGA_3D_CMD_OPEN_CONTEXT_SURFACE     1084
1166
1167 #define SVGA_3D_CMD_LOGICOPS_BITBLT          1085
1168 #define SVGA_3D_CMD_LOGICOPS_TRANSBLT        1086
1169 #define SVGA_3D_CMD_LOGICOPS_STRETCHBLT      1087
1170 #define SVGA_3D_CMD_LOGICOPS_COLORFILL       1088
1171 #define SVGA_3D_CMD_LOGICOPS_ALPHABLEND      1089
1172 #define SVGA_3D_CMD_LOGICOPS_CLEARTYPEBLEND  1090
1173
1174 #define SVGA_3D_CMD_SET_OTABLE_BASE          1091
1175 #define SVGA_3D_CMD_READBACK_OTABLE          1092
1176
1177 #define SVGA_3D_CMD_DEFINE_GB_MOB            1093
1178 #define SVGA_3D_CMD_DESTROY_GB_MOB           1094
1179 #define SVGA_3D_CMD_REDEFINE_GB_MOB          1095
1180 #define SVGA_3D_CMD_UPDATE_GB_MOB_MAPPING    1096
1181
1182 #define SVGA_3D_CMD_DEFINE_GB_SURFACE        1097
1183 #define SVGA_3D_CMD_DESTROY_GB_SURFACE       1098
1184 #define SVGA_3D_CMD_BIND_GB_SURFACE          1099
1185 #define SVGA_3D_CMD_COND_BIND_GB_SURFACE     1100
1186 #define SVGA_3D_CMD_UPDATE_GB_IMAGE          1101
1187 #define SVGA_3D_CMD_UPDATE_GB_SURFACE        1102
1188 #define SVGA_3D_CMD_READBACK_GB_IMAGE        1103
1189 #define SVGA_3D_CMD_READBACK_GB_SURFACE      1104
1190 #define SVGA_3D_CMD_INVALIDATE_GB_IMAGE      1105
1191 #define SVGA_3D_CMD_INVALIDATE_GB_SURFACE    1106
1192
1193 #define SVGA_3D_CMD_DEFINE_GB_CONTEXT        1107
1194 #define SVGA_3D_CMD_DESTROY_GB_CONTEXT       1108
1195 #define SVGA_3D_CMD_BIND_GB_CONTEXT          1109
1196 #define SVGA_3D_CMD_READBACK_GB_CONTEXT      1110
1197 #define SVGA_3D_CMD_INVALIDATE_GB_CONTEXT    1111
1198
1199 #define SVGA_3D_CMD_DEFINE_GB_SHADER         1112
1200 #define SVGA_3D_CMD_DESTROY_GB_SHADER        1113
1201 #define SVGA_3D_CMD_BIND_GB_SHADER           1114
1202
1203 #define SVGA_3D_CMD_BIND_SHADERCONSTS        1115
1204
1205 #define SVGA_3D_CMD_BEGIN_GB_QUERY           1116
1206 #define SVGA_3D_CMD_END_GB_QUERY             1117
1207 #define SVGA_3D_CMD_WAIT_FOR_GB_QUERY        1118
1208
1209 #define SVGA_3D_CMD_NOP                      1119
1210
1211 #define SVGA_3D_CMD_ENABLE_GART              1120
1212 #define SVGA_3D_CMD_DISABLE_GART             1121
1213 #define SVGA_3D_CMD_MAP_MOB_INTO_GART        1122
1214 #define SVGA_3D_CMD_UNMAP_GART_RANGE         1123
1215
1216 #define SVGA_3D_CMD_DEFINE_GB_SCREENTARGET   1124
1217 #define SVGA_3D_CMD_DESTROY_GB_SCREENTARGET  1125
1218 #define SVGA_3D_CMD_BIND_GB_SCREENTARGET     1126
1219 #define SVGA_3D_CMD_UPDATE_GB_SCREENTARGET   1127
1220
1221 #define SVGA_3D_CMD_READBACK_GB_IMAGE_PARTIAL   1128
1222 #define SVGA_3D_CMD_INVALIDATE_GB_IMAGE_PARTIAL 1129
1223
1224 #define SVGA_3D_CMD_SET_GB_SHADERCONSTS_INLINE  1130
1225
1226 #define SVGA_3D_CMD_MAX                      1131
1227 #define SVGA_3D_CMD_FUTURE_MAX               3000
1228
1229 /*
1230  * Common substructures used in multiple FIFO commands:
1231  */
1232
1233 typedef struct {
1234    union {
1235       struct {
1236          uint16  function;       /* SVGA3dFogFunction */
1237          uint8   type;           /* SVGA3dFogType */
1238          uint8   base;           /* SVGA3dFogBase */
1239       };
1240       uint32     uintValue;
1241    };
1242 } SVGA3dFogMode;
1243
1244 /*
1245  * Uniquely identify one image (a 1D/2D/3D array) from a surface. This
1246  * is a surface ID as well as face/mipmap indices.
1247  */
1248
1249 typedef
1250 struct SVGA3dSurfaceImageId {
1251    uint32               sid;
1252    uint32               face;
1253    uint32               mipmap;
1254 } SVGA3dSurfaceImageId;
1255
1256 typedef
1257 struct SVGA3dGuestImage {
1258    SVGAGuestPtr         ptr;
1259
1260    /*
1261     * A note on interpretation of pitch: This value of pitch is the
1262     * number of bytes between vertically adjacent image
1263     * blocks. Normally this is the number of bytes between the first
1264     * pixel of two adjacent scanlines. With compressed textures,
1265     * however, this may represent the number of bytes between
1266     * compression blocks rather than between rows of pixels.
1267     *
1268     * XXX: Compressed textures currently must be tightly packed in guest memory.
1269     *
1270     * If the image is 1-dimensional, pitch is ignored.
1271     *
1272     * If 'pitch' is zero, the SVGA3D device calculates a pitch value
1273     * assuming each row of blocks is tightly packed.
1274     */
1275    uint32 pitch;
1276 } SVGA3dGuestImage;
1277
1278
1279 /*
1280  * FIFO command format definitions:
1281  */
1282
1283 /*
1284  * The data size header following cmdNum for every 3d command
1285  */
1286 typedef
1287 struct {
1288    uint32               id;
1289    uint32               size;
1290 } SVGA3dCmdHeader;
1291
1292 /*
1293  * A surface is a hierarchy of host VRAM surfaces: 1D, 2D, or 3D, with
1294  * optional mipmaps and cube faces.
1295  */
1296
1297 typedef
1298 struct {
1299    uint32               width;
1300    uint32               height;
1301    uint32               depth;
1302 } SVGA3dSize;
1303
1304 typedef enum {
1305    SVGA3D_SURFACE_CUBEMAP              = (1 << 0),
1306    SVGA3D_SURFACE_HINT_STATIC          = (1 << 1),
1307    SVGA3D_SURFACE_HINT_DYNAMIC         = (1 << 2),
1308    SVGA3D_SURFACE_HINT_INDEXBUFFER     = (1 << 3),
1309    SVGA3D_SURFACE_HINT_VERTEXBUFFER    = (1 << 4),
1310    SVGA3D_SURFACE_HINT_TEXTURE         = (1 << 5),
1311    SVGA3D_SURFACE_HINT_RENDERTARGET    = (1 << 6),
1312    SVGA3D_SURFACE_HINT_DEPTHSTENCIL    = (1 << 7),
1313    SVGA3D_SURFACE_HINT_WRITEONLY       = (1 << 8),
1314    SVGA3D_SURFACE_MASKABLE_ANTIALIAS   = (1 << 9),
1315    SVGA3D_SURFACE_AUTOGENMIPMAPS       = (1 << 10),
1316 } SVGA3dSurfaceFlags;
1317
1318 typedef
1319 struct {
1320    uint32               numMipLevels;
1321 } SVGA3dSurfaceFace;
1322
1323 typedef
1324 struct {
1325    uint32                      sid;
1326    SVGA3dSurfaceFlags          surfaceFlags;
1327    SVGA3dSurfaceFormat         format;
1328    /*
1329     * If surfaceFlags has SVGA3D_SURFACE_CUBEMAP bit set, all SVGA3dSurfaceFace
1330     * structures must have the same value of numMipLevels field.
1331     * Otherwise, all but the first SVGA3dSurfaceFace structures must have the
1332     * numMipLevels set to 0.
1333     */
1334    SVGA3dSurfaceFace           face[SVGA3D_MAX_SURFACE_FACES];
1335    /*
1336     * Followed by an SVGA3dSize structure for each mip level in each face.
1337     *
1338     * A note on surface sizes: Sizes are always specified in pixels,
1339     * even if the true surface size is not a multiple of the minimum
1340     * block size of the surface's format. For example, a 3x3x1 DXT1
1341     * compressed texture would actually be stored as a 4x4x1 image in
1342     * memory.
1343     */
1344 } SVGA3dCmdDefineSurface;       /* SVGA_3D_CMD_SURFACE_DEFINE */
1345
1346 typedef
1347 struct {
1348    uint32                      sid;
1349    SVGA3dSurfaceFlags          surfaceFlags;
1350    SVGA3dSurfaceFormat         format;
1351    /*
1352     * If surfaceFlags has SVGA3D_SURFACE_CUBEMAP bit set, all SVGA3dSurfaceFace
1353     * structures must have the same value of numMipLevels field.
1354     * Otherwise, all but the first SVGA3dSurfaceFace structures must have the
1355     * numMipLevels set to 0.
1356     */
1357    SVGA3dSurfaceFace           face[SVGA3D_MAX_SURFACE_FACES];
1358    uint32                      multisampleCount;
1359    SVGA3dTextureFilter         autogenFilter;
1360    /*
1361     * Followed by an SVGA3dSize structure for each mip level in each face.
1362     *
1363     * A note on surface sizes: Sizes are always specified in pixels,
1364     * even if the true surface size is not a multiple of the minimum
1365     * block size of the surface's format. For example, a 3x3x1 DXT1
1366     * compressed texture would actually be stored as a 4x4x1 image in
1367     * memory.
1368     */
1369 } SVGA3dCmdDefineSurface_v2;     /* SVGA_3D_CMD_SURFACE_DEFINE_V2 */
1370
1371 typedef
1372 struct {
1373    uint32               sid;
1374 } SVGA3dCmdDestroySurface;      /* SVGA_3D_CMD_SURFACE_DESTROY */
1375
1376 typedef
1377 struct {
1378    uint32               cid;
1379 } SVGA3dCmdDefineContext;       /* SVGA_3D_CMD_CONTEXT_DEFINE */
1380
1381 typedef
1382 struct {
1383    uint32               cid;
1384 } SVGA3dCmdDestroyContext;      /* SVGA_3D_CMD_CONTEXT_DESTROY */
1385
1386 typedef
1387 struct {
1388    uint32               cid;
1389    SVGA3dClearFlag      clearFlag;
1390    uint32               color;
1391    float                depth;
1392    uint32               stencil;
1393    /* Followed by variable number of SVGA3dRect structures */
1394 } SVGA3dCmdClear;               /* SVGA_3D_CMD_CLEAR */
1395
1396 typedef
1397 struct SVGA3dCopyRect {
1398    uint32               x;
1399    uint32               y;
1400    uint32               w;
1401    uint32               h;
1402    uint32               srcx;
1403    uint32               srcy;
1404 } SVGA3dCopyRect;
1405
1406 typedef
1407 struct SVGA3dCopyBox {
1408    uint32               x;
1409    uint32               y;
1410    uint32               z;
1411    uint32               w;
1412    uint32               h;
1413    uint32               d;
1414    uint32               srcx;
1415    uint32               srcy;
1416    uint32               srcz;
1417 } SVGA3dCopyBox;
1418
1419 typedef
1420 struct {
1421    uint32               x;
1422    uint32               y;
1423    uint32               w;
1424    uint32               h;
1425 } SVGA3dRect;
1426
1427 typedef
1428 struct {
1429    uint32               x;
1430    uint32               y;
1431    uint32               z;
1432    uint32               w;
1433    uint32               h;
1434    uint32               d;
1435 } SVGA3dBox;
1436
1437 typedef
1438 struct {
1439    uint32               x;
1440    uint32               y;
1441    uint32               z;
1442 } SVGA3dPoint;
1443
1444 typedef
1445 struct {
1446    SVGA3dLightType      type;
1447    SVGA3dBool           inWorldSpace;
1448    float                diffuse[4];
1449    float                specular[4];
1450    float                ambient[4];
1451    float                position[4];
1452    float                direction[4];
1453    float                range;
1454    float                falloff;
1455    float                attenuation0;
1456    float                attenuation1;
1457    float                attenuation2;
1458    float                theta;
1459    float                phi;
1460 } SVGA3dLightData;
1461
1462 typedef
1463 struct {
1464    uint32               sid;
1465    /* Followed by variable number of SVGA3dCopyRect structures */
1466 } SVGA3dCmdPresent;             /* SVGA_3D_CMD_PRESENT */
1467
1468 typedef
1469 struct {
1470    SVGA3dRenderStateName   state;
1471    union {
1472       uint32               uintValue;
1473       float                floatValue;
1474    };
1475 } SVGA3dRenderState;
1476
1477 typedef
1478 struct {
1479    uint32               cid;
1480    /* Followed by variable number of SVGA3dRenderState structures */
1481 } SVGA3dCmdSetRenderState;      /* SVGA_3D_CMD_SETRENDERSTATE */
1482
1483 typedef
1484 struct {
1485    uint32                 cid;
1486    SVGA3dRenderTargetType type;
1487    SVGA3dSurfaceImageId   target;
1488 } SVGA3dCmdSetRenderTarget;     /* SVGA_3D_CMD_SETRENDERTARGET */
1489
1490 typedef
1491 struct {
1492    SVGA3dSurfaceImageId  src;
1493    SVGA3dSurfaceImageId  dest;
1494    /* Followed by variable number of SVGA3dCopyBox structures */
1495 } SVGA3dCmdSurfaceCopy;               /* SVGA_3D_CMD_SURFACE_COPY */
1496
1497 typedef
1498 struct {
1499    SVGA3dSurfaceImageId  src;
1500    SVGA3dSurfaceImageId  dest;
1501    SVGA3dBox             boxSrc;
1502    SVGA3dBox             boxDest;
1503    SVGA3dStretchBltMode  mode;
1504 } SVGA3dCmdSurfaceStretchBlt;         /* SVGA_3D_CMD_SURFACE_STRETCHBLT */
1505
1506 typedef
1507 struct {
1508    /*
1509     * If the discard flag is present in a surface DMA operation, the host may
1510     * discard the contents of the current mipmap level and face of the target
1511     * surface before applying the surface DMA contents.
1512     */
1513    uint32 discard : 1;
1514
1515    /*
1516     * If the unsynchronized flag is present, the host may perform this upload
1517     * without syncing to pending reads on this surface.
1518     */
1519    uint32 unsynchronized : 1;
1520
1521    /*
1522     * Guests *MUST* set the reserved bits to 0 before submitting the command
1523     * suffix as future flags may occupy these bits.
1524     */
1525    uint32 reserved : 30;
1526 } SVGA3dSurfaceDMAFlags;
1527
1528 typedef
1529 struct {
1530    SVGA3dGuestImage      guest;
1531    SVGA3dSurfaceImageId  host;
1532    SVGA3dTransferType    transfer;
1533    /*
1534     * Followed by variable number of SVGA3dCopyBox structures. For consistency
1535     * in all clipping logic and coordinate translation, we define the
1536     * "source" in each copyBox as the guest image and the
1537     * "destination" as the host image, regardless of transfer
1538     * direction.
1539     *
1540     * For efficiency, the SVGA3D device is free to copy more data than
1541     * specified. For example, it may round copy boxes outwards such
1542     * that they lie on particular alignment boundaries.
1543     */
1544 } SVGA3dCmdSurfaceDMA;                /* SVGA_3D_CMD_SURFACE_DMA */
1545
1546 /*
1547  * SVGA3dCmdSurfaceDMASuffix --
1548  *
1549  *    This is a command suffix that will appear after a SurfaceDMA command in
1550  *    the FIFO.  It contains some extra information that hosts may use to
1551  *    optimize performance or protect the guest.  This suffix exists to preserve
1552  *    backwards compatibility while also allowing for new functionality to be
1553  *    implemented.
1554  */
1555
1556 typedef
1557 struct {
1558    uint32 suffixSize;
1559
1560    /*
1561     * The maximum offset is used to determine the maximum offset from the
1562     * guestPtr base address that will be accessed or written to during this
1563     * surfaceDMA.  If the suffix is supported, the host will respect this
1564     * boundary while performing surface DMAs.
1565     *
1566     * Defaults to MAX_UINT32
1567     */
1568    uint32 maximumOffset;
1569
1570    /*
1571     * A set of flags that describes optimizations that the host may perform
1572     * while performing this surface DMA operation.  The guest should never rely
1573     * on behaviour that is different when these flags are set for correctness.
1574     *
1575     * Defaults to 0
1576     */
1577    SVGA3dSurfaceDMAFlags flags;
1578 } SVGA3dCmdSurfaceDMASuffix;
1579
1580 /*
1581  * SVGA_3D_CMD_DRAW_PRIMITIVES --
1582  *
1583  *   This command is the SVGA3D device's generic drawing entry point.
1584  *   It can draw multiple ranges of primitives, optionally using an
1585  *   index buffer, using an arbitrary collection of vertex buffers.
1586  *
1587  *   Each SVGA3dVertexDecl defines a distinct vertex array to bind
1588  *   during this draw call. The declarations specify which surface
1589  *   the vertex data lives in, what that vertex data is used for,
1590  *   and how to interpret it.
1591  *
1592  *   Each SVGA3dPrimitiveRange defines a collection of primitives
1593  *   to render using the same vertex arrays. An index buffer is
1594  *   optional.
1595  */
1596
1597 typedef
1598 struct {
1599    /*
1600     * A range hint is an optional specification for the range of indices
1601     * in an SVGA3dArray that will be used. If 'last' is zero, it is assumed
1602     * that the entire array will be used.
1603     *
1604     * These are only hints. The SVGA3D device may use them for
1605     * performance optimization if possible, but it's also allowed to
1606     * ignore these values.
1607     */
1608    uint32               first;
1609    uint32               last;
1610 } SVGA3dArrayRangeHint;
1611
1612 typedef
1613 struct {
1614    /*
1615     * Define the origin and shape of a vertex or index array. Both
1616     * 'offset' and 'stride' are in bytes. The provided surface will be
1617     * reinterpreted as a flat array of bytes in the same format used
1618     * by surface DMA operations. To avoid unnecessary conversions, the
1619     * surface should be created with the SVGA3D_BUFFER format.
1620     *
1621     * Index 0 in the array starts 'offset' bytes into the surface.
1622     * Index 1 begins at byte 'offset + stride', etc. Array indices may
1623     * not be negative.
1624     */
1625    uint32               surfaceId;
1626    uint32               offset;
1627    uint32               stride;
1628 } SVGA3dArray;
1629
1630 typedef
1631 struct {
1632    /*
1633     * Describe a vertex array's data type, and define how it is to be
1634     * used by the fixed function pipeline or the vertex shader. It
1635     * isn't useful to have two VertexDecls with the same
1636     * VertexArrayIdentity in one draw call.
1637     */
1638    SVGA3dDeclType       type;
1639    SVGA3dDeclMethod     method;
1640    SVGA3dDeclUsage      usage;
1641    uint32               usageIndex;
1642 } SVGA3dVertexArrayIdentity;
1643
1644 typedef
1645 struct {
1646    SVGA3dVertexArrayIdentity  identity;
1647    SVGA3dArray                array;
1648    SVGA3dArrayRangeHint       rangeHint;
1649 } SVGA3dVertexDecl;
1650
1651 typedef
1652 struct {
1653    /*
1654     * Define a group of primitives to render, from sequential indices.
1655     *
1656     * The value of 'primitiveType' and 'primitiveCount' imply the
1657     * total number of vertices that will be rendered.
1658     */
1659    SVGA3dPrimitiveType  primType;
1660    uint32               primitiveCount;
1661
1662    /*
1663     * Optional index buffer. If indexArray.surfaceId is
1664     * SVGA3D_INVALID_ID, we render without an index buffer. Rendering
1665     * without an index buffer is identical to rendering with an index
1666     * buffer containing the sequence [0, 1, 2, 3, ...].
1667     *
1668     * If an index buffer is in use, indexWidth specifies the width in
1669     * bytes of each index value. It must be less than or equal to
1670     * indexArray.stride.
1671     *
1672     * (Currently, the SVGA3D device requires index buffers to be tightly
1673     * packed. In other words, indexWidth == indexArray.stride)
1674     */
1675    SVGA3dArray          indexArray;
1676    uint32               indexWidth;
1677
1678    /*
1679     * Optional index bias. This number is added to all indices from
1680     * indexArray before they are used as vertex array indices. This
1681     * can be used in multiple ways:
1682     *
1683     *  - When not using an indexArray, this bias can be used to
1684     *    specify where in the vertex arrays to begin rendering.
1685     *
1686     *  - A positive number here is equivalent to increasing the
1687     *    offset in each vertex array.
1688     *
1689     *  - A negative number can be used to render using a small
1690     *    vertex array and an index buffer that contains large
1691     *    values. This may be used by some applications that
1692     *    crop a vertex buffer without modifying their index
1693     *    buffer.
1694     *
1695     * Note that rendering with a negative bias value may be slower and
1696     * use more memory than rendering with a positive or zero bias.
1697     */
1698    int32                indexBias;
1699 } SVGA3dPrimitiveRange;
1700
1701 typedef
1702 struct {
1703    uint32               cid;
1704    uint32               numVertexDecls;
1705    uint32               numRanges;
1706
1707    /*
1708     * There are two variable size arrays after the
1709     * SVGA3dCmdDrawPrimitives structure. In order,
1710     * they are:
1711     *
1712     * 1. SVGA3dVertexDecl, quantity 'numVertexDecls', but no more than
1713     *    SVGA3D_MAX_VERTEX_ARRAYS;
1714     * 2. SVGA3dPrimitiveRange, quantity 'numRanges', but no more than
1715     *    SVGA3D_MAX_DRAW_PRIMITIVE_RANGES;
1716     * 3. Optionally, SVGA3dVertexDivisor, quantity 'numVertexDecls' (contains
1717     *    the frequency divisor for the corresponding vertex decl).
1718     */
1719 } SVGA3dCmdDrawPrimitives;      /* SVGA_3D_CMD_DRAWPRIMITIVES */
1720
1721 typedef
1722 struct {
1723    uint32                   stage;
1724    SVGA3dTextureStateName   name;
1725    union {
1726       uint32                value;
1727       float                 floatValue;
1728    };
1729 } SVGA3dTextureState;
1730
1731 typedef
1732 struct {
1733    uint32               cid;
1734    /* Followed by variable number of SVGA3dTextureState structures */
1735 } SVGA3dCmdSetTextureState;      /* SVGA_3D_CMD_SETTEXTURESTATE */
1736
1737 typedef
1738 struct {
1739    uint32                   cid;
1740    SVGA3dTransformType      type;
1741    float                    matrix[16];
1742 } SVGA3dCmdSetTransform;          /* SVGA_3D_CMD_SETTRANSFORM */
1743
1744 typedef
1745 struct {
1746    float                min;
1747    float                max;
1748 } SVGA3dZRange;
1749
1750 typedef
1751 struct {
1752    uint32               cid;
1753    SVGA3dZRange         zRange;
1754 } SVGA3dCmdSetZRange;             /* SVGA_3D_CMD_SETZRANGE */
1755
1756 typedef
1757 struct {
1758    float                diffuse[4];
1759    float                ambient[4];
1760    float                specular[4];
1761    float                emissive[4];
1762    float                shininess;
1763 } SVGA3dMaterial;
1764
1765 typedef
1766 struct {
1767    uint32               cid;
1768    SVGA3dFace           face;
1769    SVGA3dMaterial       material;
1770 } SVGA3dCmdSetMaterial;           /* SVGA_3D_CMD_SETMATERIAL */
1771
1772 typedef
1773 struct {
1774    uint32               cid;
1775    uint32               index;
1776    SVGA3dLightData      data;
1777 } SVGA3dCmdSetLightData;           /* SVGA_3D_CMD_SETLIGHTDATA */
1778
1779 typedef
1780 struct {
1781    uint32               cid;
1782    uint32               index;
1783    uint32               enabled;
1784 } SVGA3dCmdSetLightEnabled;      /* SVGA_3D_CMD_SETLIGHTENABLED */
1785
1786 typedef
1787 struct {
1788    uint32               cid;
1789    SVGA3dRect           rect;
1790 } SVGA3dCmdSetViewport;           /* SVGA_3D_CMD_SETVIEWPORT */
1791
1792 typedef
1793 struct {
1794    uint32               cid;
1795    SVGA3dRect           rect;
1796 } SVGA3dCmdSetScissorRect;         /* SVGA_3D_CMD_SETSCISSORRECT */
1797
1798 typedef
1799 struct {
1800    uint32               cid;
1801    uint32               index;
1802    float                plane[4];
1803 } SVGA3dCmdSetClipPlane;           /* SVGA_3D_CMD_SETCLIPPLANE */
1804
1805 typedef
1806 struct {
1807    uint32               cid;
1808    uint32               shid;
1809    SVGA3dShaderType     type;
1810    /* Followed by variable number of DWORDs for shader bycode */
1811 } SVGA3dCmdDefineShader;           /* SVGA_3D_CMD_SHADER_DEFINE */
1812
1813 typedef
1814 struct {
1815    uint32               cid;
1816    uint32               shid;
1817    SVGA3dShaderType     type;
1818 } SVGA3dCmdDestroyShader;         /* SVGA_3D_CMD_SHADER_DESTROY */
1819
1820 typedef
1821 struct {
1822    uint32                  cid;
1823    uint32                  reg;     /* register number */
1824    SVGA3dShaderType        type;
1825    SVGA3dShaderConstType   ctype;
1826    uint32                  values[4];
1827 } SVGA3dCmdSetShaderConst;        /* SVGA_3D_CMD_SET_SHADER_CONST */
1828
1829 typedef
1830 struct {
1831    uint32               cid;
1832    SVGA3dShaderType     type;
1833    uint32               shid;
1834 } SVGA3dCmdSetShader;             /* SVGA_3D_CMD_SET_SHADER */
1835
1836 typedef
1837 struct {
1838    uint32               cid;
1839    SVGA3dQueryType      type;
1840 } SVGA3dCmdBeginQuery;           /* SVGA_3D_CMD_BEGIN_QUERY */
1841
1842 typedef
1843 struct {
1844    uint32               cid;
1845    SVGA3dQueryType      type;
1846    SVGAGuestPtr         guestResult;  /* Points to an SVGA3dQueryResult structure */
1847 } SVGA3dCmdEndQuery;                  /* SVGA_3D_CMD_END_QUERY */
1848
1849 typedef
1850 struct {
1851    uint32               cid;          /* Same parameters passed to END_QUERY */
1852    SVGA3dQueryType      type;
1853    SVGAGuestPtr         guestResult;
1854 } SVGA3dCmdWaitForQuery;              /* SVGA_3D_CMD_WAIT_FOR_QUERY */
1855
1856 typedef
1857 struct {
1858    uint32               totalSize;    /* Set by guest before query is ended. */
1859    SVGA3dQueryState     state;        /* Set by host or guest. See SVGA3dQueryState. */
1860    union {                            /* Set by host on exit from PENDING state */
1861       uint32            result32;
1862    };
1863 } SVGA3dQueryResult;
1864
1865 /*
1866  * SVGA_3D_CMD_BLIT_SURFACE_TO_SCREEN --
1867  *
1868  *    This is a blit from an SVGA3D surface to a Screen Object. Just
1869  *    like GMR-to-screen blits, this blit may be directed at a
1870  *    specific screen or to the virtual coordinate space.
1871  *
1872  *    The blit copies from a rectangular region of an SVGA3D surface
1873  *    image to a rectangular region of a screen or screens.
1874  *
1875  *    This command takes an optional variable-length list of clipping
1876  *    rectangles after the body of the command. If no rectangles are
1877  *    specified, there is no clipping region. The entire destRect is
1878  *    drawn to. If one or more rectangles are included, they describe
1879  *    a clipping region. The clip rectangle coordinates are measured
1880  *    relative to the top-left corner of destRect.
1881  *
1882  *    This clipping region serves multiple purposes:
1883  *
1884  *      - It can be used to perform an irregularly shaped blit more
1885  *        efficiently than by issuing many separate blit commands.
1886  *
1887  *      - It is equivalent to allowing blits with non-integer
1888  *        source coordinates. You could blit just one half-pixel
1889  *        of a source, for example, by specifying a larger
1890  *        destination rectangle than you need, then removing
1891  *        part of it using a clip rectangle.
1892  *
1893  * Availability:
1894  *    SVGA_FIFO_CAP_SCREEN_OBJECT
1895  *
1896  * Limitations:
1897  *
1898  *    - Currently, no backend supports blits from a mipmap or face
1899  *      other than the first one.
1900  */
1901
1902 typedef
1903 struct {
1904    SVGA3dSurfaceImageId srcImage;
1905    SVGASignedRect       srcRect;
1906    uint32               destScreenId; /* Screen ID or SVGA_ID_INVALID for virt. coords */
1907    SVGASignedRect       destRect;     /* Supports scaling if src/rest different size */
1908    /* Clipping: zero or more SVGASignedRects follow */
1909 } SVGA3dCmdBlitSurfaceToScreen;         /* SVGA_3D_CMD_BLIT_SURFACE_TO_SCREEN */
1910
1911 typedef
1912 struct {
1913    uint32               sid;
1914    SVGA3dTextureFilter  filter;
1915 } SVGA3dCmdGenerateMipmaps;             /* SVGA_3D_CMD_GENERATE_MIPMAPS */
1916
1917
1918 /*
1919  * Guest-backed surface definitions.
1920  */
1921
1922 typedef uint32 SVGAMobId;
1923
1924 typedef enum SVGAMobFormat {
1925    SVGA3D_MOBFMT_INVALID = SVGA3D_INVALID_ID,
1926    SVGA3D_MOBFMT_PTDEPTH_0 = 0,
1927    SVGA3D_MOBFMT_PTDEPTH_1 = 1,
1928    SVGA3D_MOBFMT_PTDEPTH_2 = 2,
1929    SVGA3D_MOBFMT_RANGE     = 3,
1930    SVGA3D_MOBFMT_MAX,
1931 } SVGAMobFormat;
1932
1933 /*
1934  * Sizes of opaque types.
1935  */
1936
1937 #define SVGA3D_OTABLE_MOB_ENTRY_SIZE 16
1938 #define SVGA3D_OTABLE_CONTEXT_ENTRY_SIZE 8
1939 #define SVGA3D_OTABLE_SURFACE_ENTRY_SIZE 64
1940 #define SVGA3D_OTABLE_SHADER_ENTRY_SIZE 16
1941 #define SVGA3D_OTABLE_SCREEN_TARGET_ENTRY_SIZE 64
1942 #define SVGA3D_CONTEXT_DATA_SIZE 16384
1943
1944 /*
1945  * SVGA3dCmdSetOTableBase --
1946  *
1947  * This command allows the guest to specify the base PPN of the
1948  * specified object table.
1949  */
1950
1951 typedef enum {
1952    SVGA_OTABLE_MOB           = 0,
1953    SVGA_OTABLE_MIN           = 0,
1954    SVGA_OTABLE_SURFACE       = 1,
1955    SVGA_OTABLE_CONTEXT       = 2,
1956    SVGA_OTABLE_SHADER        = 3,
1957    SVGA_OTABLE_SCREEN_TARGET = 4,
1958    SVGA_OTABLE_DX9_MAX       = 5,
1959    SVGA_OTABLE_MAX           = 8
1960 } SVGAOTableType;
1961
1962 typedef
1963 struct {
1964    SVGAOTableType type;
1965    PPN baseAddress;
1966    uint32 sizeInBytes;
1967    uint32 validSizeInBytes;
1968    SVGAMobFormat ptDepth;
1969 } SVGA3dCmdSetOTableBase;  /* SVGA_3D_CMD_SET_OTABLE_BASE */
1970
1971 typedef
1972 struct {
1973    SVGAOTableType type;
1974 } SVGA3dCmdReadbackOTable;  /* SVGA_3D_CMD_READBACK_OTABLE */
1975
1976 /*
1977  * Define a memory object (Mob) in the OTable.
1978  */
1979
1980 typedef
1981 struct SVGA3dCmdDefineGBMob {
1982    SVGAMobId mobid;
1983    SVGAMobFormat ptDepth;
1984    PPN base;
1985    uint32 sizeInBytes;
1986 } SVGA3dCmdDefineGBMob;   /* SVGA_3D_CMD_DEFINE_GB_MOB */
1987
1988
1989 /*
1990  * Destroys an object in the OTable.
1991  */
1992
1993 typedef
1994 struct SVGA3dCmdDestroyGBMob {
1995    SVGAMobId mobid;
1996 } SVGA3dCmdDestroyGBMob;   /* SVGA_3D_CMD_DESTROY_GB_MOB */
1997
1998 /*
1999  * Redefine an object in the OTable.
2000  */
2001
2002 typedef
2003 struct SVGA3dCmdRedefineGBMob {
2004    SVGAMobId mobid;
2005    SVGAMobFormat ptDepth;
2006    PPN base;
2007    uint32 sizeInBytes;
2008 } SVGA3dCmdRedefineGBMob;   /* SVGA_3D_CMD_REDEFINE_GB_MOB */
2009
2010 /*
2011  * Notification that the page tables have been modified.
2012  */
2013
2014 typedef
2015 struct SVGA3dCmdUpdateGBMobMapping {
2016    SVGAMobId mobid;
2017 } SVGA3dCmdUpdateGBMobMapping;   /* SVGA_3D_CMD_UPDATE_GB_MOB_MAPPING */
2018
2019 /*
2020  * Define a guest-backed surface.
2021  */
2022
2023 typedef
2024 struct SVGA3dCmdDefineGBSurface {
2025    uint32 sid;
2026    SVGA3dSurfaceFlags surfaceFlags;
2027    SVGA3dSurfaceFormat format;
2028    uint32 numMipLevels;
2029    uint32 multisampleCount;
2030    SVGA3dTextureFilter autogenFilter;
2031    SVGA3dSize size;
2032 } SVGA3dCmdDefineGBSurface;   /* SVGA_3D_CMD_DEFINE_GB_SURFACE */
2033
2034 /*
2035  * Destroy a guest-backed surface.
2036  */
2037
2038 typedef
2039 struct SVGA3dCmdDestroyGBSurface {
2040    uint32 sid;
2041 } SVGA3dCmdDestroyGBSurface;   /* SVGA_3D_CMD_DESTROY_GB_SURFACE */
2042
2043 /*
2044  * Bind a guest-backed surface to an object.
2045  */
2046
2047 typedef
2048 struct SVGA3dCmdBindGBSurface {
2049    uint32 sid;
2050    SVGAMobId mobid;
2051 } SVGA3dCmdBindGBSurface;   /* SVGA_3D_CMD_BIND_GB_SURFACE */
2052
2053 /*
2054  * Conditionally bind a mob to a guest backed surface if testMobid
2055  * matches the currently bound mob.  Optionally issue a readback on
2056  * the surface while it is still bound to the old mobid if the mobid
2057  * is changed by this command.
2058  */
2059
2060 #define SVGA3D_COND_BIND_GB_SURFACE_FLAG_READBACK (1 << 0)
2061
2062 typedef
2063 struct{
2064    uint32 sid;
2065    SVGAMobId testMobid;
2066    SVGAMobId mobid;
2067    uint32 flags;
2068 }
2069 SVGA3dCmdCondBindGBSurface;          /* SVGA_3D_CMD_COND_BIND_GB_SURFACE */
2070
2071 /*
2072  * Update an image in a guest-backed surface.
2073  * (Inform the device that the guest-contents have been updated.)
2074  */
2075
2076 typedef
2077 struct SVGA3dCmdUpdateGBImage {
2078    SVGA3dSurfaceImageId image;
2079    SVGA3dBox box;
2080 } SVGA3dCmdUpdateGBImage;   /* SVGA_3D_CMD_UPDATE_GB_IMAGE */
2081
2082 /*
2083  * Update an entire guest-backed surface.
2084  * (Inform the device that the guest-contents have been updated.)
2085  */
2086
2087 typedef
2088 struct SVGA3dCmdUpdateGBSurface {
2089    uint32 sid;
2090 } SVGA3dCmdUpdateGBSurface;   /* SVGA_3D_CMD_UPDATE_GB_SURFACE */
2091
2092 /*
2093  * Readback an image in a guest-backed surface.
2094  * (Request the device to flush the dirty contents into the guest.)
2095  */
2096
2097 typedef
2098 struct SVGA3dCmdReadbackGBImage {
2099    SVGA3dSurfaceImageId image;
2100 } SVGA3dCmdReadbackGBImage;   /* SVGA_3D_CMD_READBACK_GB_IMAGE*/
2101
2102 /*
2103  * Readback an entire guest-backed surface.
2104  * (Request the device to flush the dirty contents into the guest.)
2105  */
2106
2107 typedef
2108 struct SVGA3dCmdReadbackGBSurface {
2109    uint32 sid;
2110 } SVGA3dCmdReadbackGBSurface;   /* SVGA_3D_CMD_READBACK_GB_SURFACE */
2111
2112 /*
2113  * Readback a sub rect of an image in a guest-backed surface.  After
2114  * issuing this command the driver is required to issue an update call
2115  * of the same region before issuing any other commands that reference
2116  * this surface or rendering is not guaranteed.
2117  */
2118
2119 typedef
2120 struct SVGA3dCmdReadbackGBImagePartial {
2121    SVGA3dSurfaceImageId image;
2122    SVGA3dBox box;
2123    uint32 invertBox;
2124 }
2125 SVGA3dCmdReadbackGBImagePartial; /* SVGA_3D_CMD_READBACK_GB_IMAGE_PARTIAL */
2126
2127 /*
2128  * Invalidate an image in a guest-backed surface.
2129  * (Notify the device that the contents can be lost.)
2130  */
2131
2132 typedef
2133 struct SVGA3dCmdInvalidateGBImage {
2134    SVGA3dSurfaceImageId image;
2135 } SVGA3dCmdInvalidateGBImage;   /* SVGA_3D_CMD_INVALIDATE_GB_IMAGE */
2136
2137 /*
2138  * Invalidate an entire guest-backed surface.
2139  * (Notify the device that the contents if all images can be lost.)
2140  */
2141
2142 typedef
2143 struct SVGA3dCmdInvalidateGBSurface {
2144    uint32 sid;
2145 } SVGA3dCmdInvalidateGBSurface; /* SVGA_3D_CMD_INVALIDATE_GB_SURFACE */
2146
2147 /*
2148  * Invalidate a sub rect of an image in a guest-backed surface.  After
2149  * issuing this command the driver is required to issue an update call
2150  * of the same region before issuing any other commands that reference
2151  * this surface or rendering is not guaranteed.
2152  */
2153
2154 typedef
2155 struct SVGA3dCmdInvalidateGBImagePartial {
2156    SVGA3dSurfaceImageId image;
2157    SVGA3dBox box;
2158    uint32 invertBox;
2159 }
2160 SVGA3dCmdInvalidateGBImagePartial; /* SVGA_3D_CMD_INVALIDATE_GB_IMAGE_PARTIAL */
2161
2162 /*
2163  * Define a guest-backed context.
2164  */
2165
2166 typedef
2167 struct SVGA3dCmdDefineGBContext {
2168    uint32 cid;
2169 } SVGA3dCmdDefineGBContext;   /* SVGA_3D_CMD_DEFINE_GB_CONTEXT */
2170
2171 /*
2172  * Destroy a guest-backed context.
2173  */
2174
2175 typedef
2176 struct SVGA3dCmdDestroyGBContext {
2177    uint32 cid;
2178 } SVGA3dCmdDestroyGBContext;   /* SVGA_3D_CMD_DESTROY_GB_CONTEXT */
2179
2180 /*
2181  * Bind a guest-backed context.
2182  *
2183  * validContents should be set to 0 for new contexts,
2184  * and 1 if this is an old context which is getting paged
2185  * back on to the device.
2186  *
2187  * For new contexts, it is recommended that the driver
2188  * issue commands to initialize all interesting state
2189  * prior to rendering.
2190  */
2191
2192 typedef
2193 struct SVGA3dCmdBindGBContext {
2194    uint32 cid;
2195    SVGAMobId mobid;
2196    uint32 validContents;
2197 } SVGA3dCmdBindGBContext;   /* SVGA_3D_CMD_BIND_GB_CONTEXT */
2198
2199 /*
2200  * Readback a guest-backed context.
2201  * (Request that the device flush the contents back into guest memory.)
2202  */
2203
2204 typedef
2205 struct SVGA3dCmdReadbackGBContext {
2206    uint32 cid;
2207 } SVGA3dCmdReadbackGBContext;   /* SVGA_3D_CMD_READBACK_GB_CONTEXT */
2208
2209 /*
2210  * Invalidate a guest-backed context.
2211  */
2212 typedef
2213 struct SVGA3dCmdInvalidateGBContext {
2214    uint32 cid;
2215 } SVGA3dCmdInvalidateGBContext;   /* SVGA_3D_CMD_INVALIDATE_GB_CONTEXT */
2216
2217 /*
2218  * Define a guest-backed shader.
2219  */
2220
2221 typedef
2222 struct SVGA3dCmdDefineGBShader {
2223    uint32 shid;
2224    SVGA3dShaderType type;
2225    uint32 sizeInBytes;
2226 } SVGA3dCmdDefineGBShader;   /* SVGA_3D_CMD_DEFINE_GB_SHADER */
2227
2228 /*
2229  * Bind a guest-backed shader.
2230  */
2231
2232 typedef struct SVGA3dCmdBindGBShader {
2233    uint32 shid;
2234    SVGAMobId mobid;
2235    uint32 offsetInBytes;
2236 } SVGA3dCmdBindGBShader;   /* SVGA_3D_CMD_BIND_GB_SHADER */
2237
2238 /*
2239  * Destroy a guest-backed shader.
2240  */
2241
2242 typedef struct SVGA3dCmdDestroyGBShader {
2243    uint32 shid;
2244 } SVGA3dCmdDestroyGBShader;   /* SVGA_3D_CMD_DESTROY_GB_SHADER */
2245
2246
2247 typedef struct SVGA3dCmdBindGBShaderConsts {
2248    uint32 cid;
2249    SVGA3dShaderType shaderType;
2250    SVGA3dShaderConstType shaderConstType;
2251    uint32 sid;
2252 } SVGA3dCmdBindGBShaderConsts;   /* SVGA_3D_CMD_BIND_SHADERCONSTS */
2253
2254 typedef
2255 struct {
2256    uint32                  cid;
2257    uint32                  regStart;
2258    SVGA3dShaderType        shaderType;
2259    SVGA3dShaderConstType   constType;
2260
2261    /*
2262     * Followed by a variable number of shader constants.
2263     *
2264     * Note that FLOAT and INT constants are 4-dwords in length, while
2265     * BOOL constants are 1-dword in length.
2266     */
2267 } SVGA3dCmdSetGBShaderConstInline;
2268 /* SVGA_3D_CMD_SET_GB_SHADERCONSTS_INLINE */
2269
2270 typedef
2271 struct {
2272    uint32               cid;
2273    SVGA3dQueryType      type;
2274 } SVGA3dCmdBeginGBQuery;           /* SVGA_3D_CMD_BEGIN_GB_QUERY */
2275
2276 typedef
2277 struct {
2278    uint32               cid;
2279    SVGA3dQueryType      type;
2280    SVGAMobId mobid;
2281    uint32 offset;
2282 } SVGA3dCmdEndGBQuery;                  /* SVGA_3D_CMD_END_GB_QUERY */
2283
2284
2285 /*
2286  * SVGA_3D_CMD_WAIT_FOR_GB_QUERY --
2287  *
2288  *    The semantics of this command are identical to the
2289  *    SVGA_3D_CMD_WAIT_FOR_QUERY except that the results are written
2290  *    to a Mob instead of a GMR.
2291  */
2292
2293 typedef
2294 struct {
2295    uint32               cid;
2296    SVGA3dQueryType      type;
2297    SVGAMobId mobid;
2298    uint32 offset;
2299 } SVGA3dCmdWaitForGBQuery;          /* SVGA_3D_CMD_WAIT_FOR_GB_QUERY */
2300
2301 typedef
2302 struct {
2303    SVGAMobId mobid;
2304    uint32 fbOffset;
2305    uint32 initalized;
2306 }
2307 SVGA3dCmdEnableGart;              /* SVGA_3D_CMD_ENABLE_GART */
2308
2309 typedef
2310 struct {
2311    SVGAMobId mobid;
2312    uint32 gartOffset;
2313 }
2314 SVGA3dCmdMapMobIntoGart;          /* SVGA_3D_CMD_MAP_MOB_INTO_GART */
2315
2316
2317 typedef
2318 struct {
2319    uint32 gartOffset;
2320    uint32 numPages;
2321 }
2322 SVGA3dCmdUnmapGartRange;          /* SVGA_3D_CMD_UNMAP_GART_RANGE */
2323
2324
2325 /*
2326  * Screen Targets
2327  */
2328 #define SVGA_STFLAG_PRIMARY (1 << 0)
2329
2330 typedef
2331 struct {
2332    uint32 stid;
2333    uint32 width;
2334    uint32 height;
2335    int32 xRoot;
2336    int32 yRoot;
2337    uint32 flags;
2338 }
2339 SVGA3dCmdDefineGBScreenTarget;    /* SVGA_3D_CMD_DEFINE_GB_SCREENTARGET */
2340
2341 typedef
2342 struct {
2343    uint32 stid;
2344 }
2345 SVGA3dCmdDestroyGBScreenTarget;  /* SVGA_3D_CMD_DESTROY_GB_SCREENTARGET */
2346
2347 typedef
2348 struct {
2349    uint32 stid;
2350    SVGA3dSurfaceImageId image;
2351 }
2352 SVGA3dCmdBindGBScreenTarget;  /* SVGA_3D_CMD_BIND_GB_SCREENTARGET */
2353
2354 typedef
2355 struct {
2356    uint32 stid;
2357    SVGA3dBox box;
2358 }
2359 SVGA3dCmdUpdateGBScreenTarget;  /* SVGA_3D_CMD_UPDATE_GB_SCREENTARGET */
2360
2361 /*
2362  * Capability query index.
2363  *
2364  * Notes:
2365  *
2366  *   1. SVGA3D_DEVCAP_MAX_TEXTURES reflects the maximum number of
2367  *      fixed-function texture units available. Each of these units
2368  *      work in both FFP and Shader modes, and they support texture
2369  *      transforms and texture coordinates. The host may have additional
2370  *      texture image units that are only usable with shaders.
2371  *
2372  *   2. The BUFFER_FORMAT capabilities are deprecated, and they always
2373  *      return TRUE. Even on physical hardware that does not support
2374  *      these formats natively, the SVGA3D device will provide an emulation
2375  *      which should be invisible to the guest OS.
2376  *
2377  *      In general, the SVGA3D device should support any operation on
2378  *      any surface format, it just may perform some of these
2379  *      operations in software depending on the capabilities of the
2380  *      available physical hardware.
2381  *
2382  *      XXX: In the future, we will add capabilities that describe in
2383  *      detail what formats are supported in hardware for what kinds
2384  *      of operations.
2385  */
2386
2387 typedef enum {
2388    SVGA3D_DEVCAP_3D                                = 0,
2389    SVGA3D_DEVCAP_MAX_LIGHTS                        = 1,
2390    SVGA3D_DEVCAP_MAX_TEXTURES                      = 2,  /* See note (1) */
2391    SVGA3D_DEVCAP_MAX_CLIP_PLANES                   = 3,
2392    SVGA3D_DEVCAP_VERTEX_SHADER_VERSION             = 4,
2393    SVGA3D_DEVCAP_VERTEX_SHADER                     = 5,
2394    SVGA3D_DEVCAP_FRAGMENT_SHADER_VERSION           = 6,
2395    SVGA3D_DEVCAP_FRAGMENT_SHADER                   = 7,
2396    SVGA3D_DEVCAP_MAX_RENDER_TARGETS                = 8,
2397    SVGA3D_DEVCAP_S23E8_TEXTURES                    = 9,
2398    SVGA3D_DEVCAP_S10E5_TEXTURES                    = 10,
2399    SVGA3D_DEVCAP_MAX_FIXED_VERTEXBLEND             = 11,
2400    SVGA3D_DEVCAP_D16_BUFFER_FORMAT                 = 12, /* See note (2) */
2401    SVGA3D_DEVCAP_D24S8_BUFFER_FORMAT               = 13, /* See note (2) */
2402    SVGA3D_DEVCAP_D24X8_BUFFER_FORMAT               = 14, /* See note (2) */
2403    SVGA3D_DEVCAP_QUERY_TYPES                       = 15,
2404    SVGA3D_DEVCAP_TEXTURE_GRADIENT_SAMPLING         = 16,
2405    SVGA3D_DEVCAP_MAX_POINT_SIZE                    = 17,
2406    SVGA3D_DEVCAP_MAX_SHADER_TEXTURES               = 18,
2407    SVGA3D_DEVCAP_MAX_TEXTURE_WIDTH                 = 19,
2408    SVGA3D_DEVCAP_MAX_TEXTURE_HEIGHT                = 20,
2409    SVGA3D_DEVCAP_MAX_VOLUME_EXTENT                 = 21,
2410    SVGA3D_DEVCAP_MAX_TEXTURE_REPEAT                = 22,
2411    SVGA3D_DEVCAP_MAX_TEXTURE_ASPECT_RATIO          = 23,
2412    SVGA3D_DEVCAP_MAX_TEXTURE_ANISOTROPY            = 24,
2413    SVGA3D_DEVCAP_MAX_PRIMITIVE_COUNT               = 25,
2414    SVGA3D_DEVCAP_MAX_VERTEX_INDEX                  = 26,
2415    SVGA3D_DEVCAP_MAX_VERTEX_SHADER_INSTRUCTIONS    = 27,
2416    SVGA3D_DEVCAP_MAX_FRAGMENT_SHADER_INSTRUCTIONS  = 28,
2417    SVGA3D_DEVCAP_MAX_VERTEX_SHADER_TEMPS           = 29,
2418    SVGA3D_DEVCAP_MAX_FRAGMENT_SHADER_TEMPS         = 30,
2419    SVGA3D_DEVCAP_TEXTURE_OPS                       = 31,
2420    SVGA3D_DEVCAP_SURFACEFMT_X8R8G8B8               = 32,
2421    SVGA3D_DEVCAP_SURFACEFMT_A8R8G8B8               = 33,
2422    SVGA3D_DEVCAP_SURFACEFMT_A2R10G10B10            = 34,
2423    SVGA3D_DEVCAP_SURFACEFMT_X1R5G5B5               = 35,
2424    SVGA3D_DEVCAP_SURFACEFMT_A1R5G5B5               = 36,
2425    SVGA3D_DEVCAP_SURFACEFMT_A4R4G4B4               = 37,
2426    SVGA3D_DEVCAP_SURFACEFMT_R5G6B5                 = 38,
2427    SVGA3D_DEVCAP_SURFACEFMT_LUMINANCE16            = 39,
2428    SVGA3D_DEVCAP_SURFACEFMT_LUMINANCE8_ALPHA8      = 40,
2429    SVGA3D_DEVCAP_SURFACEFMT_ALPHA8                 = 41,
2430    SVGA3D_DEVCAP_SURFACEFMT_LUMINANCE8             = 42,
2431    SVGA3D_DEVCAP_SURFACEFMT_Z_D16                  = 43,
2432    SVGA3D_DEVCAP_SURFACEFMT_Z_D24S8                = 44,
2433    SVGA3D_DEVCAP_SURFACEFMT_Z_D24X8                = 45,
2434    SVGA3D_DEVCAP_SURFACEFMT_DXT1                   = 46,
2435    SVGA3D_DEVCAP_SURFACEFMT_DXT2                   = 47,
2436    SVGA3D_DEVCAP_SURFACEFMT_DXT3                   = 48,
2437    SVGA3D_DEVCAP_SURFACEFMT_DXT4                   = 49,
2438    SVGA3D_DEVCAP_SURFACEFMT_DXT5                   = 50,
2439    SVGA3D_DEVCAP_SURFACEFMT_BUMPX8L8V8U8           = 51,
2440    SVGA3D_DEVCAP_SURFACEFMT_A2W10V10U10            = 52,
2441    SVGA3D_DEVCAP_SURFACEFMT_BUMPU8V8               = 53,
2442    SVGA3D_DEVCAP_SURFACEFMT_Q8W8V8U8               = 54,
2443    SVGA3D_DEVCAP_SURFACEFMT_CxV8U8                 = 55,
2444    SVGA3D_DEVCAP_SURFACEFMT_R_S10E5                = 56,
2445    SVGA3D_DEVCAP_SURFACEFMT_R_S23E8                = 57,
2446    SVGA3D_DEVCAP_SURFACEFMT_RG_S10E5               = 58,
2447    SVGA3D_DEVCAP_SURFACEFMT_RG_S23E8               = 59,
2448    SVGA3D_DEVCAP_SURFACEFMT_ARGB_S10E5             = 60,
2449    SVGA3D_DEVCAP_SURFACEFMT_ARGB_S23E8             = 61,
2450    SVGA3D_DEVCAP_MAX_VERTEX_SHADER_TEXTURES        = 63,
2451
2452    /*
2453     * Note that MAX_SIMULTANEOUS_RENDER_TARGETS is a maximum count of color
2454     * render targets.  This does no include the depth or stencil targets.
2455     */
2456    SVGA3D_DEVCAP_MAX_SIMULTANEOUS_RENDER_TARGETS   = 64,
2457
2458    SVGA3D_DEVCAP_SURFACEFMT_V16U16                 = 65,
2459    SVGA3D_DEVCAP_SURFACEFMT_G16R16                 = 66,
2460    SVGA3D_DEVCAP_SURFACEFMT_A16B16G16R16           = 67,
2461    SVGA3D_DEVCAP_SURFACEFMT_UYVY                   = 68,
2462    SVGA3D_DEVCAP_SURFACEFMT_YUY2                   = 69,
2463    SVGA3D_DEVCAP_MULTISAMPLE_NONMASKABLESAMPLES    = 70,
2464    SVGA3D_DEVCAP_MULTISAMPLE_MASKABLESAMPLES       = 71,
2465    SVGA3D_DEVCAP_ALPHATOCOVERAGE                   = 72,
2466    SVGA3D_DEVCAP_SUPERSAMPLE                       = 73,
2467    SVGA3D_DEVCAP_AUTOGENMIPMAPS                    = 74,
2468    SVGA3D_DEVCAP_SURFACEFMT_NV12                   = 75,
2469    SVGA3D_DEVCAP_SURFACEFMT_AYUV                   = 76,
2470
2471    /*
2472     * This is the maximum number of SVGA context IDs that the guest
2473     * can define using SVGA_3D_CMD_CONTEXT_DEFINE.
2474     */
2475    SVGA3D_DEVCAP_MAX_CONTEXT_IDS                   = 77,
2476
2477    /*
2478     * This is the maximum number of SVGA surface IDs that the guest
2479     * can define using SVGA_3D_CMD_SURFACE_DEFINE*.
2480     */
2481    SVGA3D_DEVCAP_MAX_SURFACE_IDS                   = 78,
2482
2483    SVGA3D_DEVCAP_SURFACEFMT_Z_DF16                 = 79,
2484    SVGA3D_DEVCAP_SURFACEFMT_Z_DF24                 = 80,
2485    SVGA3D_DEVCAP_SURFACEFMT_Z_D24S8_INT            = 81,
2486
2487    SVGA3D_DEVCAP_SURFACEFMT_BC4_UNORM              = 82,
2488    SVGA3D_DEVCAP_SURFACEFMT_BC5_UNORM              = 83,
2489
2490    /*
2491     * Deprecated.
2492     */
2493    SVGA3D_DEVCAP_VGPU10                            = 84,
2494
2495    /*
2496     * This contains several SVGA_3D_CAPS_VIDEO_DECODE elements
2497     * ored together, one for every type of video decoding supported.
2498     */
2499    SVGA3D_DEVCAP_VIDEO_DECODE                      = 85,
2500
2501    /*
2502     * This contains several SVGA_3D_CAPS_VIDEO_PROCESS elements
2503     * ored together, one for every type of video processing supported.
2504     */
2505    SVGA3D_DEVCAP_VIDEO_PROCESS                     = 86,
2506
2507    SVGA3D_DEVCAP_LINE_AA                           = 87,  /* boolean */
2508    SVGA3D_DEVCAP_LINE_STIPPLE                      = 88,  /* boolean */
2509    SVGA3D_DEVCAP_MAX_LINE_WIDTH                    = 89,  /* float */
2510    SVGA3D_DEVCAP_MAX_AA_LINE_WIDTH                 = 90,  /* float */
2511
2512    SVGA3D_DEVCAP_SURFACEFMT_YV12                   = 91,
2513
2514    /*
2515     * Does the host support the SVGA logic ops commands?
2516     */
2517    SVGA3D_DEVCAP_LOGICOPS                          = 92,
2518
2519    /*
2520     * What support does the host have for screen targets?
2521     *
2522     * See the SVGA3D_SCREENTARGET_CAP bits below.
2523     */
2524    SVGA3D_DEVCAP_SCREENTARGETS                     = 93,
2525
2526    SVGA3D_DEVCAP_MAX                                  /* This must be the last index. */
2527 } SVGA3dDevCapIndex;
2528
2529 typedef union {
2530    Bool   b;
2531    uint32 u;
2532    int32  i;
2533    float  f;
2534 } SVGA3dDevCapResult;
2535
2536 #endif /* _SVGA3D_REG_H_ */