1 /*	$NetBSD: svga3d_cmd.h,v 1.3 2021/12/18 23:45:45 riastradh Exp $	*/
2 
3 /* SPDX-License-Identifier: GPL-2.0 OR MIT */
4 /**********************************************************
5  * Copyright 1998-2015 VMware, Inc.
6  *
7  * Permission is hereby granted, free of charge, to any person
8  * obtaining a copy of this software and associated documentation
9  * files (the "Software"), to deal in the Software without
10  * restriction, including without limitation the rights to use, copy,
11  * modify, merge, publish, distribute, sublicense, and/or sell copies
12  * of the Software, and to permit persons to whom the Software is
13  * furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be
16  * included in all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
22  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
23  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25  * SOFTWARE.
26  *
27  **********************************************************/
28 
29 /*
30  * svga3d_cmd.h --
31  *
32  *       SVGA 3d hardware cmd definitions
33  */
34 
35 #ifndef _SVGA3D_CMD_H_
36 #define _SVGA3D_CMD_H_
37 
38 #define INCLUDE_ALLOW_MODULE
39 #define INCLUDE_ALLOW_USERLEVEL
40 #define INCLUDE_ALLOW_VMCORE
41 
42 #include "includeCheck.h"
43 #include "svga3d_types.h"
44 
45 /*
46  * Identifiers for commands in the command FIFO.
47  *
48  * IDs between 1000 and 1039 (inclusive) were used by obsolete versions of
49  * the SVGA3D protocol and remain reserved; they should not be used in the
50  * future.
51  *
52  * IDs between 1040 and 2999 (inclusive) are available for use by the
53  * current SVGA3D protocol.
54  *
55  * FIFO clients other than SVGA3D should stay below 1000, or at 3000
56  * and up.
57  */
58 
59 typedef enum {
60    SVGA_3D_CMD_LEGACY_BASE                                = 1000,
61    SVGA_3D_CMD_BASE                                       = 1040,
62 
63    SVGA_3D_CMD_SURFACE_DEFINE                             = 1040,
64    SVGA_3D_CMD_SURFACE_DESTROY                            = 1041,
65    SVGA_3D_CMD_SURFACE_COPY                               = 1042,
66    SVGA_3D_CMD_SURFACE_STRETCHBLT                         = 1043,
67    SVGA_3D_CMD_SURFACE_DMA                                = 1044,
68    SVGA_3D_CMD_CONTEXT_DEFINE                             = 1045,
69    SVGA_3D_CMD_CONTEXT_DESTROY                            = 1046,
70    SVGA_3D_CMD_SETTRANSFORM                               = 1047,
71    SVGA_3D_CMD_SETZRANGE                                  = 1048,
72    SVGA_3D_CMD_SETRENDERSTATE                             = 1049,
73    SVGA_3D_CMD_SETRENDERTARGET                            = 1050,
74    SVGA_3D_CMD_SETTEXTURESTATE                            = 1051,
75    SVGA_3D_CMD_SETMATERIAL                                = 1052,
76    SVGA_3D_CMD_SETLIGHTDATA                               = 1053,
77    SVGA_3D_CMD_SETLIGHTENABLED                            = 1054,
78    SVGA_3D_CMD_SETVIEWPORT                                = 1055,
79    SVGA_3D_CMD_SETCLIPPLANE                               = 1056,
80    SVGA_3D_CMD_CLEAR                                      = 1057,
81    SVGA_3D_CMD_PRESENT                                    = 1058,
82    SVGA_3D_CMD_SHADER_DEFINE                              = 1059,
83    SVGA_3D_CMD_SHADER_DESTROY                             = 1060,
84    SVGA_3D_CMD_SET_SHADER                                 = 1061,
85    SVGA_3D_CMD_SET_SHADER_CONST                           = 1062,
86    SVGA_3D_CMD_DRAW_PRIMITIVES                            = 1063,
87    SVGA_3D_CMD_SETSCISSORRECT                             = 1064,
88    SVGA_3D_CMD_BEGIN_QUERY                                = 1065,
89    SVGA_3D_CMD_END_QUERY                                  = 1066,
90    SVGA_3D_CMD_WAIT_FOR_QUERY                             = 1067,
91    SVGA_3D_CMD_PRESENT_READBACK                           = 1068,
92    SVGA_3D_CMD_BLIT_SURFACE_TO_SCREEN                     = 1069,
93    SVGA_3D_CMD_SURFACE_DEFINE_V2                          = 1070,
94    SVGA_3D_CMD_GENERATE_MIPMAPS                           = 1071,
95    SVGA_3D_CMD_DEAD4                                      = 1072,
96    SVGA_3D_CMD_DEAD5                                      = 1073,
97    SVGA_3D_CMD_DEAD6                                      = 1074,
98    SVGA_3D_CMD_DEAD7                                      = 1075,
99    SVGA_3D_CMD_DEAD8                                      = 1076,
100    SVGA_3D_CMD_DEAD9                                      = 1077,
101    SVGA_3D_CMD_DEAD10                                     = 1078,
102    SVGA_3D_CMD_DEAD11                                     = 1079,
103    SVGA_3D_CMD_ACTIVATE_SURFACE                           = 1080,
104    SVGA_3D_CMD_DEACTIVATE_SURFACE                         = 1081,
105    SVGA_3D_CMD_SCREEN_DMA                                 = 1082,
106    SVGA_3D_CMD_DEAD1                                      = 1083,
107    SVGA_3D_CMD_DEAD2                                      = 1084,
108 
109    SVGA_3D_CMD_LOGICOPS_BITBLT                            = 1085,
110    SVGA_3D_CMD_LOGICOPS_TRANSBLT                          = 1086,
111    SVGA_3D_CMD_LOGICOPS_STRETCHBLT                        = 1087,
112    SVGA_3D_CMD_LOGICOPS_COLORFILL                         = 1088,
113    SVGA_3D_CMD_LOGICOPS_ALPHABLEND                        = 1089,
114    SVGA_3D_CMD_LOGICOPS_CLEARTYPEBLEND                    = 1090,
115 
116    SVGA_3D_CMD_SET_OTABLE_BASE                            = 1091,
117    SVGA_3D_CMD_READBACK_OTABLE                            = 1092,
118 
119    SVGA_3D_CMD_DEFINE_GB_MOB                              = 1093,
120    SVGA_3D_CMD_DESTROY_GB_MOB                             = 1094,
121    SVGA_3D_CMD_DEAD3                                      = 1095,
122    SVGA_3D_CMD_UPDATE_GB_MOB_MAPPING                      = 1096,
123 
124    SVGA_3D_CMD_DEFINE_GB_SURFACE                          = 1097,
125    SVGA_3D_CMD_DESTROY_GB_SURFACE                         = 1098,
126    SVGA_3D_CMD_BIND_GB_SURFACE                            = 1099,
127    SVGA_3D_CMD_COND_BIND_GB_SURFACE                       = 1100,
128    SVGA_3D_CMD_UPDATE_GB_IMAGE                            = 1101,
129    SVGA_3D_CMD_UPDATE_GB_SURFACE                          = 1102,
130    SVGA_3D_CMD_READBACK_GB_IMAGE                          = 1103,
131    SVGA_3D_CMD_READBACK_GB_SURFACE                        = 1104,
132    SVGA_3D_CMD_INVALIDATE_GB_IMAGE                        = 1105,
133    SVGA_3D_CMD_INVALIDATE_GB_SURFACE                      = 1106,
134 
135    SVGA_3D_CMD_DEFINE_GB_CONTEXT                          = 1107,
136    SVGA_3D_CMD_DESTROY_GB_CONTEXT                         = 1108,
137    SVGA_3D_CMD_BIND_GB_CONTEXT                            = 1109,
138    SVGA_3D_CMD_READBACK_GB_CONTEXT                        = 1110,
139    SVGA_3D_CMD_INVALIDATE_GB_CONTEXT                      = 1111,
140 
141    SVGA_3D_CMD_DEFINE_GB_SHADER                           = 1112,
142    SVGA_3D_CMD_DESTROY_GB_SHADER                          = 1113,
143    SVGA_3D_CMD_BIND_GB_SHADER                             = 1114,
144 
145    SVGA_3D_CMD_SET_OTABLE_BASE64                          = 1115,
146 
147    SVGA_3D_CMD_BEGIN_GB_QUERY                             = 1116,
148    SVGA_3D_CMD_END_GB_QUERY                               = 1117,
149    SVGA_3D_CMD_WAIT_FOR_GB_QUERY                          = 1118,
150 
151    SVGA_3D_CMD_NOP                                        = 1119,
152 
153    SVGA_3D_CMD_ENABLE_GART                                = 1120,
154    SVGA_3D_CMD_DISABLE_GART                               = 1121,
155    SVGA_3D_CMD_MAP_MOB_INTO_GART                          = 1122,
156    SVGA_3D_CMD_UNMAP_GART_RANGE                           = 1123,
157 
158    SVGA_3D_CMD_DEFINE_GB_SCREENTARGET                     = 1124,
159    SVGA_3D_CMD_DESTROY_GB_SCREENTARGET                    = 1125,
160    SVGA_3D_CMD_BIND_GB_SCREENTARGET                       = 1126,
161    SVGA_3D_CMD_UPDATE_GB_SCREENTARGET                     = 1127,
162 
163    SVGA_3D_CMD_READBACK_GB_IMAGE_PARTIAL                  = 1128,
164    SVGA_3D_CMD_INVALIDATE_GB_IMAGE_PARTIAL                = 1129,
165 
166    SVGA_3D_CMD_SET_GB_SHADERCONSTS_INLINE                 = 1130,
167 
168    SVGA_3D_CMD_GB_SCREEN_DMA                              = 1131,
169    SVGA_3D_CMD_BIND_GB_SURFACE_WITH_PITCH                 = 1132,
170    SVGA_3D_CMD_GB_MOB_FENCE                               = 1133,
171    SVGA_3D_CMD_DEFINE_GB_SURFACE_V2                       = 1134,
172    SVGA_3D_CMD_DEFINE_GB_MOB64                            = 1135,
173    SVGA_3D_CMD_REDEFINE_GB_MOB64                          = 1136,
174    SVGA_3D_CMD_NOP_ERROR                                  = 1137,
175 
176    SVGA_3D_CMD_SET_VERTEX_STREAMS                         = 1138,
177    SVGA_3D_CMD_SET_VERTEX_DECLS                           = 1139,
178    SVGA_3D_CMD_SET_VERTEX_DIVISORS                        = 1140,
179    SVGA_3D_CMD_DRAW                                       = 1141,
180    SVGA_3D_CMD_DRAW_INDEXED                               = 1142,
181 
182    /*
183     * DX10 Commands
184     */
185    SVGA_3D_CMD_DX_MIN                                     = 1143,
186    SVGA_3D_CMD_DX_DEFINE_CONTEXT                          = 1143,
187    SVGA_3D_CMD_DX_DESTROY_CONTEXT                         = 1144,
188    SVGA_3D_CMD_DX_BIND_CONTEXT                            = 1145,
189    SVGA_3D_CMD_DX_READBACK_CONTEXT                        = 1146,
190    SVGA_3D_CMD_DX_INVALIDATE_CONTEXT                      = 1147,
191    SVGA_3D_CMD_DX_SET_SINGLE_CONSTANT_BUFFER              = 1148,
192    SVGA_3D_CMD_DX_SET_SHADER_RESOURCES                    = 1149,
193    SVGA_3D_CMD_DX_SET_SHADER                              = 1150,
194    SVGA_3D_CMD_DX_SET_SAMPLERS                            = 1151,
195    SVGA_3D_CMD_DX_DRAW                                    = 1152,
196    SVGA_3D_CMD_DX_DRAW_INDEXED                            = 1153,
197    SVGA_3D_CMD_DX_DRAW_INSTANCED                          = 1154,
198    SVGA_3D_CMD_DX_DRAW_INDEXED_INSTANCED                  = 1155,
199    SVGA_3D_CMD_DX_DRAW_AUTO                               = 1156,
200    SVGA_3D_CMD_DX_SET_INPUT_LAYOUT                        = 1157,
201    SVGA_3D_CMD_DX_SET_VERTEX_BUFFERS                      = 1158,
202    SVGA_3D_CMD_DX_SET_INDEX_BUFFER                        = 1159,
203    SVGA_3D_CMD_DX_SET_TOPOLOGY                            = 1160,
204    SVGA_3D_CMD_DX_SET_RENDERTARGETS                       = 1161,
205    SVGA_3D_CMD_DX_SET_BLEND_STATE                         = 1162,
206    SVGA_3D_CMD_DX_SET_DEPTHSTENCIL_STATE                  = 1163,
207    SVGA_3D_CMD_DX_SET_RASTERIZER_STATE                    = 1164,
208    SVGA_3D_CMD_DX_DEFINE_QUERY                            = 1165,
209    SVGA_3D_CMD_DX_DESTROY_QUERY                           = 1166,
210    SVGA_3D_CMD_DX_BIND_QUERY                              = 1167,
211    SVGA_3D_CMD_DX_SET_QUERY_OFFSET                        = 1168,
212    SVGA_3D_CMD_DX_BEGIN_QUERY                             = 1169,
213    SVGA_3D_CMD_DX_END_QUERY                               = 1170,
214    SVGA_3D_CMD_DX_READBACK_QUERY                          = 1171,
215    SVGA_3D_CMD_DX_SET_PREDICATION                         = 1172,
216    SVGA_3D_CMD_DX_SET_SOTARGETS                           = 1173,
217    SVGA_3D_CMD_DX_SET_VIEWPORTS                           = 1174,
218    SVGA_3D_CMD_DX_SET_SCISSORRECTS                        = 1175,
219    SVGA_3D_CMD_DX_CLEAR_RENDERTARGET_VIEW                 = 1176,
220    SVGA_3D_CMD_DX_CLEAR_DEPTHSTENCIL_VIEW                 = 1177,
221    SVGA_3D_CMD_DX_PRED_COPY_REGION                        = 1178,
222    SVGA_3D_CMD_DX_PRED_COPY                               = 1179,
223    SVGA_3D_CMD_DX_PRESENTBLT                              = 1180,
224    SVGA_3D_CMD_DX_GENMIPS                                 = 1181,
225    SVGA_3D_CMD_DX_UPDATE_SUBRESOURCE                      = 1182,
226    SVGA_3D_CMD_DX_READBACK_SUBRESOURCE                    = 1183,
227    SVGA_3D_CMD_DX_INVALIDATE_SUBRESOURCE                  = 1184,
228    SVGA_3D_CMD_DX_DEFINE_SHADERRESOURCE_VIEW              = 1185,
229    SVGA_3D_CMD_DX_DESTROY_SHADERRESOURCE_VIEW             = 1186,
230    SVGA_3D_CMD_DX_DEFINE_RENDERTARGET_VIEW                = 1187,
231    SVGA_3D_CMD_DX_DESTROY_RENDERTARGET_VIEW               = 1188,
232    SVGA_3D_CMD_DX_DEFINE_DEPTHSTENCIL_VIEW                = 1189,
233    SVGA_3D_CMD_DX_DESTROY_DEPTHSTENCIL_VIEW               = 1190,
234    SVGA_3D_CMD_DX_DEFINE_ELEMENTLAYOUT                    = 1191,
235    SVGA_3D_CMD_DX_DESTROY_ELEMENTLAYOUT                   = 1192,
236    SVGA_3D_CMD_DX_DEFINE_BLEND_STATE                      = 1193,
237    SVGA_3D_CMD_DX_DESTROY_BLEND_STATE                     = 1194,
238    SVGA_3D_CMD_DX_DEFINE_DEPTHSTENCIL_STATE               = 1195,
239    SVGA_3D_CMD_DX_DESTROY_DEPTHSTENCIL_STATE              = 1196,
240    SVGA_3D_CMD_DX_DEFINE_RASTERIZER_STATE                 = 1197,
241    SVGA_3D_CMD_DX_DESTROY_RASTERIZER_STATE                = 1198,
242    SVGA_3D_CMD_DX_DEFINE_SAMPLER_STATE                    = 1199,
243    SVGA_3D_CMD_DX_DESTROY_SAMPLER_STATE                   = 1200,
244    SVGA_3D_CMD_DX_DEFINE_SHADER                           = 1201,
245    SVGA_3D_CMD_DX_DESTROY_SHADER                          = 1202,
246    SVGA_3D_CMD_DX_BIND_SHADER                             = 1203,
247    SVGA_3D_CMD_DX_DEFINE_STREAMOUTPUT                     = 1204,
248    SVGA_3D_CMD_DX_DESTROY_STREAMOUTPUT                    = 1205,
249    SVGA_3D_CMD_DX_SET_STREAMOUTPUT                        = 1206,
250    SVGA_3D_CMD_DX_SET_COTABLE                             = 1207,
251    SVGA_3D_CMD_DX_READBACK_COTABLE                        = 1208,
252    SVGA_3D_CMD_DX_BUFFER_COPY                             = 1209,
253    SVGA_3D_CMD_DX_TRANSFER_FROM_BUFFER                    = 1210,
254    SVGA_3D_CMD_DX_SURFACE_COPY_AND_READBACK               = 1211,
255    SVGA_3D_CMD_DX_MOVE_QUERY                              = 1212,
256    SVGA_3D_CMD_DX_BIND_ALL_QUERY                          = 1213,
257    SVGA_3D_CMD_DX_READBACK_ALL_QUERY                      = 1214,
258    SVGA_3D_CMD_DX_PRED_TRANSFER_FROM_BUFFER               = 1215,
259    SVGA_3D_CMD_DX_MOB_FENCE_64                            = 1216,
260    SVGA_3D_CMD_DX_BIND_ALL_SHADER                         = 1217,
261    SVGA_3D_CMD_DX_HINT                                    = 1218,
262    SVGA_3D_CMD_DX_BUFFER_UPDATE                           = 1219,
263    SVGA_3D_CMD_DX_SET_VS_CONSTANT_BUFFER_OFFSET           = 1220,
264    SVGA_3D_CMD_DX_SET_PS_CONSTANT_BUFFER_OFFSET           = 1221,
265    SVGA_3D_CMD_DX_SET_GS_CONSTANT_BUFFER_OFFSET           = 1222,
266 
267    /*
268     * Reserve some IDs to be used for the SM5 shader types.
269     */
270    SVGA_3D_CMD_DX_RESERVED1                               = 1223,
271    SVGA_3D_CMD_DX_RESERVED2                               = 1224,
272    SVGA_3D_CMD_DX_RESERVED3                               = 1225,
273 
274    SVGA_3D_CMD_DX_COND_BIND_ALL_SHADER                    = 1226,
275    SVGA_3D_CMD_DX_MAX                                     = 1227,
276 
277    SVGA_3D_CMD_SCREEN_COPY                                = 1227,
278 
279    /*
280     * Reserve some IDs to be used for video.
281     */
282    SVGA_3D_CMD_VIDEO_RESERVED1                            = 1228,
283    SVGA_3D_CMD_VIDEO_RESERVED2                            = 1229,
284    SVGA_3D_CMD_VIDEO_RESERVED3                            = 1230,
285    SVGA_3D_CMD_VIDEO_RESERVED4                            = 1231,
286    SVGA_3D_CMD_VIDEO_RESERVED5                            = 1232,
287    SVGA_3D_CMD_VIDEO_RESERVED6                            = 1233,
288    SVGA_3D_CMD_VIDEO_RESERVED7                            = 1234,
289    SVGA_3D_CMD_VIDEO_RESERVED8                            = 1235,
290 
291    SVGA_3D_CMD_GROW_OTABLE                                = 1236,
292    SVGA_3D_CMD_DX_GROW_COTABLE                            = 1237,
293    SVGA_3D_CMD_INTRA_SURFACE_COPY                         = 1238,
294 
295    SVGA_3D_CMD_DEFINE_GB_SURFACE_V3                       = 1239,
296 
297    SVGA_3D_CMD_DX_RESOLVE_COPY                            = 1240,
298    SVGA_3D_CMD_DX_PRED_RESOLVE_COPY                       = 1241,
299    SVGA_3D_CMD_DX_PRED_CONVERT_REGION                     = 1242,
300    SVGA_3D_CMD_DX_PRED_CONVERT                            = 1243,
301    SVGA_3D_CMD_WHOLE_SURFACE_COPY                         = 1244,
302 
303    SVGA_3D_CMD_MAX                                        = 1245,
304    SVGA_3D_CMD_FUTURE_MAX                                 = 3000
305 } SVGAFifo3dCmdId;
306 
307 #define SVGA_NUM_3D_CMD (SVGA_3D_CMD_MAX - SVGA_3D_CMD_BASE)
308 
309 /*
310  * FIFO command format definitions:
311  */
312 
313 /*
314  * The data size header following cmdNum for every 3d command
315  */
316 typedef
317 #include "vmware_pack_begin.h"
318 struct {
319    uint32               id;
320    uint32               size;
321 }
322 #include "vmware_pack_end.h"
323 SVGA3dCmdHeader;
324 
325 typedef
326 #include "vmware_pack_begin.h"
327 struct {
328    uint32               numMipLevels;
329 }
330 #include "vmware_pack_end.h"
331 SVGA3dSurfaceFace;
332 
333 typedef
334 #include "vmware_pack_begin.h"
335 struct {
336    uint32                      sid;
337    SVGA3dSurface1Flags         surfaceFlags;
338    SVGA3dSurfaceFormat         format;
339    /*
340     * If surfaceFlags has SVGA3D_SURFACE_CUBEMAP bit set, all SVGA3dSurfaceFace
341     * structures must have the same value of numMipLevels field.
342     * Otherwise, all but the first SVGA3dSurfaceFace structures must have the
343     * numMipLevels set to 0.
344     */
345    SVGA3dSurfaceFace           face[SVGA3D_MAX_SURFACE_FACES];
346    /*
347     * Followed by an SVGA3dSize structure for each mip level in each face.
348     *
349     * A note on surface sizes: Sizes are always specified in pixels,
350     * even if the true surface size is not a multiple of the minimum
351     * block size of the surface's format. For example, a 3x3x1 DXT1
352     * compressed texture would actually be stored as a 4x4x1 image in
353     * memory.
354     */
355 }
356 #include "vmware_pack_end.h"
357 SVGA3dCmdDefineSurface;       /* SVGA_3D_CMD_SURFACE_DEFINE */
358 
359 typedef
360 #include "vmware_pack_begin.h"
361 struct {
362    uint32                      sid;
363    SVGA3dSurface1Flags         surfaceFlags;
364    SVGA3dSurfaceFormat         format;
365    /*
366     * If surfaceFlags has SVGA3D_SURFACE_CUBEMAP bit set, all SVGA3dSurfaceFace
367     * structures must have the same value of numMipLevels field.
368     * Otherwise, all but the first SVGA3dSurfaceFace structures must have the
369     * numMipLevels set to 0.
370     */
371    SVGA3dSurfaceFace           face[SVGA3D_MAX_SURFACE_FACES];
372    uint32                      multisampleCount;
373    SVGA3dTextureFilter         autogenFilter;
374    /*
375     * Followed by an SVGA3dSize structure for each mip level in each face.
376     *
377     * A note on surface sizes: Sizes are always specified in pixels,
378     * even if the true surface size is not a multiple of the minimum
379     * block size of the surface's format. For example, a 3x3x1 DXT1
380     * compressed texture would actually be stored as a 4x4x1 image in
381     * memory.
382     */
383 }
384 #include "vmware_pack_end.h"
385 SVGA3dCmdDefineSurface_v2;     /* SVGA_3D_CMD_SURFACE_DEFINE_V2 */
386 
387 typedef
388 #include "vmware_pack_begin.h"
389 struct {
390    uint32               sid;
391 }
392 #include "vmware_pack_end.h"
393 SVGA3dCmdDestroySurface;      /* SVGA_3D_CMD_SURFACE_DESTROY */
394 
395 typedef
396 #include "vmware_pack_begin.h"
397 struct {
398    uint32               cid;
399 }
400 #include "vmware_pack_end.h"
401 SVGA3dCmdDefineContext;       /* SVGA_3D_CMD_CONTEXT_DEFINE */
402 
403 typedef
404 #include "vmware_pack_begin.h"
405 struct {
406    uint32               cid;
407 }
408 #include "vmware_pack_end.h"
409 SVGA3dCmdDestroyContext;      /* SVGA_3D_CMD_CONTEXT_DESTROY */
410 
411 typedef
412 #include "vmware_pack_begin.h"
413 struct {
414    uint32               cid;
415    SVGA3dClearFlag      clearFlag;
416    uint32               color;
417    float                depth;
418    uint32               stencil;
419    /* Followed by variable number of SVGA3dRect structures */
420 }
421 #include "vmware_pack_end.h"
422 SVGA3dCmdClear;               /* SVGA_3D_CMD_CLEAR */
423 
424 typedef
425 #include "vmware_pack_begin.h"
426 struct {
427    SVGA3dLightType      type;
428    SVGA3dBool           inWorldSpace;
429    float                diffuse[4];
430    float                specular[4];
431    float                ambient[4];
432    float                position[4];
433    float                direction[4];
434    float                range;
435    float                falloff;
436    float                attenuation0;
437    float                attenuation1;
438    float                attenuation2;
439    float                theta;
440    float                phi;
441 }
442 #include "vmware_pack_end.h"
443 SVGA3dLightData;
444 
445 typedef
446 #include "vmware_pack_begin.h"
447 struct {
448    uint32               sid;
449    /* Followed by variable number of SVGA3dCopyRect structures */
450 }
451 #include "vmware_pack_end.h"
452 SVGA3dCmdPresent;             /* SVGA_3D_CMD_PRESENT */
453 
454 typedef
455 #include "vmware_pack_begin.h"
456 struct {
457    SVGA3dRenderStateName   state;
458    union {
459       uint32               uintValue;
460       float                floatValue;
461    };
462 }
463 #include "vmware_pack_end.h"
464 SVGA3dRenderState;
465 
466 typedef
467 #include "vmware_pack_begin.h"
468 struct {
469    uint32               cid;
470    /* Followed by variable number of SVGA3dRenderState structures */
471 }
472 #include "vmware_pack_end.h"
473 SVGA3dCmdSetRenderState;      /* SVGA_3D_CMD_SETRENDERSTATE */
474 
475 typedef
476 #include "vmware_pack_begin.h"
477 struct {
478    uint32                 cid;
479    SVGA3dRenderTargetType type;
480    SVGA3dSurfaceImageId   target;
481 }
482 #include "vmware_pack_end.h"
483 SVGA3dCmdSetRenderTarget;     /* SVGA_3D_CMD_SETRENDERTARGET */
484 
485 typedef
486 #include "vmware_pack_begin.h"
487 struct {
488    SVGA3dSurfaceImageId  src;
489    SVGA3dSurfaceImageId  dest;
490    /* Followed by variable number of SVGA3dCopyBox structures */
491 }
492 #include "vmware_pack_end.h"
493 SVGA3dCmdSurfaceCopy;               /* SVGA_3D_CMD_SURFACE_COPY */
494 
495 /*
496  * Perform a surface copy within the same image.
497  * The src/dest boxes are allowed to overlap.
498  */
499 typedef
500 #include "vmware_pack_begin.h"
501 struct {
502    SVGA3dSurfaceImageId  surface;
503    SVGA3dCopyBox box;
504 }
505 #include "vmware_pack_end.h"
506 SVGA3dCmdIntraSurfaceCopy;               /* SVGA_3D_CMD_INTRA_SURFACE_COPY */
507 
508 typedef
509 #include "vmware_pack_begin.h"
510 struct {
511    uint32 srcSid;
512    uint32 destSid;
513 }
514 #include "vmware_pack_end.h"
515 SVGA3dCmdWholeSurfaceCopy;               /* SVGA_3D_CMD_WHOLE_SURFACE_COPY */
516 
517 typedef
518 #include "vmware_pack_begin.h"
519 struct {
520    SVGA3dSurfaceImageId  src;
521    SVGA3dSurfaceImageId  dest;
522    SVGA3dBox             boxSrc;
523    SVGA3dBox             boxDest;
524    SVGA3dStretchBltMode  mode;
525 }
526 #include "vmware_pack_end.h"
527 SVGA3dCmdSurfaceStretchBlt;         /* SVGA_3D_CMD_SURFACE_STRETCHBLT */
528 
529 typedef
530 #include "vmware_pack_begin.h"
531 struct {
532    /*
533     * If the discard flag is present in a surface DMA operation, the host may
534     * discard the contents of the current mipmap level and face of the target
535     * surface before applying the surface DMA contents.
536     */
537    uint32 discard : 1;
538 
539    /*
540     * If the unsynchronized flag is present, the host may perform this upload
541     * without syncing to pending reads on this surface.
542     */
543    uint32 unsynchronized : 1;
544 
545    /*
546     * Guests *MUST* set the reserved bits to 0 before submitting the command
547     * suffix as future flags may occupy these bits.
548     */
549    uint32 reserved : 30;
550 }
551 #include "vmware_pack_end.h"
552 SVGA3dSurfaceDMAFlags;
553 
554 typedef
555 #include "vmware_pack_begin.h"
556 struct {
557    SVGAGuestImage guest;
558    SVGA3dSurfaceImageId host;
559    SVGA3dTransferType transfer;
560    /*
561     * Followed by variable number of SVGA3dCopyBox structures. For consistency
562     * in all clipping logic and coordinate translation, we define the
563     * "source" in each copyBox as the guest image and the
564     * "destination" as the host image, regardless of transfer
565     * direction.
566     *
567     * For efficiency, the SVGA3D device is free to copy more data than
568     * specified. For example, it may round copy boxes outwards such
569     * that they lie on particular alignment boundaries.
570     */
571 }
572 #include "vmware_pack_end.h"
573 SVGA3dCmdSurfaceDMA;                /* SVGA_3D_CMD_SURFACE_DMA */
574 
575 /*
576  * SVGA3dCmdSurfaceDMASuffix --
577  *
578  *    This is a command suffix that will appear after a SurfaceDMA command in
579  *    the FIFO.  It contains some extra information that hosts may use to
580  *    optimize performance or protect the guest.  This suffix exists to preserve
581  *    backwards compatibility while also allowing for new functionality to be
582  *    implemented.
583  */
584 
585 typedef
586 #include "vmware_pack_begin.h"
587 struct {
588    uint32 suffixSize;
589 
590    /*
591     * The maximum offset is used to determine the maximum offset from the
592     * guestPtr base address that will be accessed or written to during this
593     * surfaceDMA.  If the suffix is supported, the host will respect this
594     * boundary while performing surface DMAs.
595     *
596     * Defaults to MAX_UINT32
597     */
598    uint32 maximumOffset;
599 
600    /*
601     * A set of flags that describes optimizations that the host may perform
602     * while performing this surface DMA operation.  The guest should never rely
603     * on behaviour that is different when these flags are set for correctness.
604     *
605     * Defaults to 0
606     */
607    SVGA3dSurfaceDMAFlags flags;
608 }
609 #include "vmware_pack_end.h"
610 SVGA3dCmdSurfaceDMASuffix;
611 
612 /*
613  * SVGA_3D_CMD_DRAW_PRIMITIVES --
614  *
615  *   This command is the SVGA3D device's generic drawing entry point.
616  *   It can draw multiple ranges of primitives, optionally using an
617  *   index buffer, using an arbitrary collection of vertex buffers.
618  *
619  *   Each SVGA3dVertexDecl defines a distinct vertex array to bind
620  *   during this draw call. The declarations specify which surface
621  *   the vertex data lives in, what that vertex data is used for,
622  *   and how to interpret it.
623  *
624  *   Each SVGA3dPrimitiveRange defines a collection of primitives
625  *   to render using the same vertex arrays. An index buffer is
626  *   optional.
627  */
628 
629 typedef
630 #include "vmware_pack_begin.h"
631 struct {
632    /*
633     * A range hint is an optional specification for the range of indices
634     * in an SVGA3dArray that will be used. If 'last' is zero, it is assumed
635     * that the entire array will be used.
636     *
637     * These are only hints. The SVGA3D device may use them for
638     * performance optimization if possible, but it's also allowed to
639     * ignore these values.
640     */
641    uint32               first;
642    uint32               last;
643 }
644 #include "vmware_pack_end.h"
645 SVGA3dArrayRangeHint;
646 
647 typedef
648 #include "vmware_pack_begin.h"
649 struct {
650    /*
651     * Define the origin and shape of a vertex or index array. Both
652     * 'offset' and 'stride' are in bytes. The provided surface will be
653     * reinterpreted as a flat array of bytes in the same format used
654     * by surface DMA operations. To avoid unnecessary conversions, the
655     * surface should be created with the SVGA3D_BUFFER format.
656     *
657     * Index 0 in the array starts 'offset' bytes into the surface.
658     * Index 1 begins at byte 'offset + stride', etc. Array indices may
659     * not be negative.
660     */
661    uint32               surfaceId;
662    uint32               offset;
663    uint32               stride;
664 }
665 #include "vmware_pack_end.h"
666 SVGA3dArray;
667 
668 typedef
669 #include "vmware_pack_begin.h"
670 struct {
671    /*
672     * Describe a vertex array's data type, and define how it is to be
673     * used by the fixed function pipeline or the vertex shader. It
674     * isn't useful to have two VertexDecls with the same
675     * VertexArrayIdentity in one draw call.
676     */
677    SVGA3dDeclType       type;
678    SVGA3dDeclMethod     method;
679    SVGA3dDeclUsage      usage;
680    uint32               usageIndex;
681 }
682 #include "vmware_pack_end.h"
683 SVGA3dVertexArrayIdentity;
684 
685 typedef
686 #include "vmware_pack_begin.h"
687 struct SVGA3dVertexDecl {
688    SVGA3dVertexArrayIdentity  identity;
689    SVGA3dArray                array;
690    SVGA3dArrayRangeHint       rangeHint;
691 }
692 #include "vmware_pack_end.h"
693 SVGA3dVertexDecl;
694 
695 typedef
696 #include "vmware_pack_begin.h"
697 struct SVGA3dPrimitiveRange {
698    /*
699     * Define a group of primitives to render, from sequential indices.
700     *
701     * The value of 'primitiveType' and 'primitiveCount' imply the
702     * total number of vertices that will be rendered.
703     */
704    SVGA3dPrimitiveType  primType;
705    uint32               primitiveCount;
706 
707    /*
708     * Optional index buffer. If indexArray.surfaceId is
709     * SVGA3D_INVALID_ID, we render without an index buffer. Rendering
710     * without an index buffer is identical to rendering with an index
711     * buffer containing the sequence [0, 1, 2, 3, ...].
712     *
713     * If an index buffer is in use, indexWidth specifies the width in
714     * bytes of each index value. It must be less than or equal to
715     * indexArray.stride.
716     *
717     * (Currently, the SVGA3D device requires index buffers to be tightly
718     * packed. In other words, indexWidth == indexArray.stride)
719     */
720    SVGA3dArray          indexArray;
721    uint32               indexWidth;
722 
723    /*
724     * Optional index bias. This number is added to all indices from
725     * indexArray before they are used as vertex array indices. This
726     * can be used in multiple ways:
727     *
728     *  - When not using an indexArray, this bias can be used to
729     *    specify where in the vertex arrays to begin rendering.
730     *
731     *  - A positive number here is equivalent to increasing the
732     *    offset in each vertex array.
733     *
734     *  - A negative number can be used to render using a small
735     *    vertex array and an index buffer that contains large
736     *    values. This may be used by some applications that
737     *    crop a vertex buffer without modifying their index
738     *    buffer.
739     *
740     * Note that rendering with a negative bias value may be slower and
741     * use more memory than rendering with a positive or zero bias.
742     */
743    int32                indexBias;
744 }
745 #include "vmware_pack_end.h"
746 SVGA3dPrimitiveRange;
747 
748 typedef
749 #include "vmware_pack_begin.h"
750 struct {
751    uint32               cid;
752    uint32               numVertexDecls;
753    uint32               numRanges;
754 
755    /*
756     * There are two variable size arrays after the
757     * SVGA3dCmdDrawPrimitives structure. In order,
758     * they are:
759     *
760     * 1. SVGA3dVertexDecl, quantity 'numVertexDecls', but no more than
761     *    SVGA3D_MAX_VERTEX_ARRAYS;
762     * 2. SVGA3dPrimitiveRange, quantity 'numRanges', but no more than
763     *    SVGA3D_MAX_DRAW_PRIMITIVE_RANGES;
764     * 3. Optionally, SVGA3dVertexDivisor, quantity 'numVertexDecls' (contains
765     *    the frequency divisor for the corresponding vertex decl).
766     */
767 }
768 #include "vmware_pack_end.h"
769 SVGA3dCmdDrawPrimitives;      /* SVGA_3D_CMD_DRAWPRIMITIVES */
770 
771 typedef
772 #include "vmware_pack_begin.h"
773 struct {
774    uint32 cid;
775 
776    uint32 primitiveCount;        /* How many primitives to render */
777    uint32 startVertexLocation;   /* Which vertex do we start rendering at. */
778 
779    uint8 primitiveType;          /* SVGA3dPrimitiveType */
780    uint8 padding[3];
781 }
782 #include "vmware_pack_end.h"
783 SVGA3dCmdDraw;
784 
785 typedef
786 #include "vmware_pack_begin.h"
787 struct {
788    uint32 cid;
789 
790    uint8 primitiveType;       /* SVGA3dPrimitiveType */
791 
792    uint32 indexBufferSid;     /* Valid index buffer sid. */
793    uint32 indexBufferOffset;  /* Byte offset into the vertex buffer, almost */
794 			      /* always 0 for DX9 guests, non-zero for OpenGL */
795                               /* guests.  We can't represent non-multiple of */
796                               /* stride offsets in D3D9Renderer... */
797    uint8 indexBufferStride;   /* Allowable values = 1, 2, or 4 */
798 
799    int32 baseVertexLocation;  /* Bias applied to the index when selecting a */
800                               /* vertex from the streams, may be negative */
801 
802    uint32 primitiveCount;     /* How many primitives to render */
803    uint32 pad0;
804    uint16 pad1;
805 }
806 #include "vmware_pack_end.h"
807 SVGA3dCmdDrawIndexed;
808 
809 typedef
810 #include "vmware_pack_begin.h"
811 struct {
812    /*
813     * Describe a vertex array's data type, and define how it is to be
814     * used by the fixed function pipeline or the vertex shader. It
815     * isn't useful to have two VertexDecls with the same
816     * VertexArrayIdentity in one draw call.
817     */
818    uint16 streamOffset;
819    uint8 stream;
820    uint8 type;          /* SVGA3dDeclType */
821    uint8 method;        /* SVGA3dDeclMethod */
822    uint8 usage;         /* SVGA3dDeclUsage */
823    uint8 usageIndex;
824    uint8 padding;
825 
826 }
827 #include "vmware_pack_end.h"
828 SVGA3dVertexElement;
829 
830 /*
831  * Should the vertex element respect the stream value?  The high bit of the
832  * stream should be set to indicate that the stream should be respected.  If
833  * the high bit is not set, the stream will be ignored and replaced by the index
834  * of the position of the currently considered vertex element.
835  *
836  * All guests should set this bit and correctly specify the stream going
837  * forward.
838  */
839 #define SVGA3D_VERTEX_ELEMENT_RESPECT_STREAM (1 << 7)
840 
841 typedef
842 #include "vmware_pack_begin.h"
843 struct {
844    uint32 cid;
845 
846    uint32 numElements;
847 
848    /*
849     * Followed by numElements SVGA3dVertexElement structures.
850     *
851     * If numElements < SVGA3D_MAX_VERTEX_ARRAYS, the remaining elements
852     * are cleared and will not be used by following draws.
853     */
854 }
855 #include "vmware_pack_end.h"
856 SVGA3dCmdSetVertexDecls;
857 
858 typedef
859 #include "vmware_pack_begin.h"
860 struct {
861    uint32 sid;
862    uint32 stride;
863    uint32 offset;
864 }
865 #include "vmware_pack_end.h"
866 SVGA3dVertexStream;
867 
868 typedef
869 #include "vmware_pack_begin.h"
870 struct {
871    uint32 cid;
872 
873    uint32 numStreams;
874    /*
875     * Followed by numStream SVGA3dVertexStream structures.
876     *
877     * If numStreams < SVGA3D_MAX_VERTEX_ARRAYS, the remaining streams
878     * are cleared and will not be used by following draws.
879     */
880 }
881 #include "vmware_pack_end.h"
882 SVGA3dCmdSetVertexStreams;
883 
884 typedef
885 #include "vmware_pack_begin.h"
886 struct {
887    uint32 cid;
888    uint32 numDivisors;
889 }
890 #include "vmware_pack_end.h"
891 SVGA3dCmdSetVertexDivisors;
892 
893 typedef
894 #include "vmware_pack_begin.h"
895 struct {
896    uint32                   stage;
897    SVGA3dTextureStateName   name;
898    union {
899       uint32                value;
900       float                 floatValue;
901    };
902 }
903 #include "vmware_pack_end.h"
904 SVGA3dTextureState;
905 
906 typedef
907 #include "vmware_pack_begin.h"
908 struct {
909    uint32               cid;
910    /* Followed by variable number of SVGA3dTextureState structures */
911 }
912 #include "vmware_pack_end.h"
913 SVGA3dCmdSetTextureState;      /* SVGA_3D_CMD_SETTEXTURESTATE */
914 
915 typedef
916 #include "vmware_pack_begin.h"
917 struct {
918    uint32                   cid;
919    SVGA3dTransformType      type;
920    float                    matrix[16];
921 }
922 #include "vmware_pack_end.h"
923 SVGA3dCmdSetTransform;          /* SVGA_3D_CMD_SETTRANSFORM */
924 
925 typedef
926 #include "vmware_pack_begin.h"
927 struct {
928    float                min;
929    float                max;
930 }
931 #include "vmware_pack_end.h"
932 SVGA3dZRange;
933 
934 typedef
935 #include "vmware_pack_begin.h"
936 struct {
937    uint32               cid;
938    SVGA3dZRange         zRange;
939 }
940 #include "vmware_pack_end.h"
941 SVGA3dCmdSetZRange;             /* SVGA_3D_CMD_SETZRANGE */
942 
943 typedef
944 #include "vmware_pack_begin.h"
945 struct {
946    float                diffuse[4];
947    float                ambient[4];
948    float                specular[4];
949    float                emissive[4];
950    float                shininess;
951 }
952 #include "vmware_pack_end.h"
953 SVGA3dMaterial;
954 
955 typedef
956 #include "vmware_pack_begin.h"
957 struct {
958    uint32               cid;
959    SVGA3dFace           face;
960    SVGA3dMaterial       material;
961 }
962 #include "vmware_pack_end.h"
963 SVGA3dCmdSetMaterial;           /* SVGA_3D_CMD_SETMATERIAL */
964 
965 typedef
966 #include "vmware_pack_begin.h"
967 struct {
968    uint32               cid;
969    uint32               index;
970    SVGA3dLightData      data;
971 }
972 #include "vmware_pack_end.h"
973 SVGA3dCmdSetLightData;           /* SVGA_3D_CMD_SETLIGHTDATA */
974 
975 typedef
976 #include "vmware_pack_begin.h"
977 struct {
978    uint32               cid;
979    uint32               index;
980    uint32               enabled;
981 }
982 #include "vmware_pack_end.h"
983 SVGA3dCmdSetLightEnabled;      /* SVGA_3D_CMD_SETLIGHTENABLED */
984 
985 typedef
986 #include "vmware_pack_begin.h"
987 struct {
988    uint32               cid;
989    SVGA3dRect           rect;
990 }
991 #include "vmware_pack_end.h"
992 SVGA3dCmdSetViewport;           /* SVGA_3D_CMD_SETVIEWPORT */
993 
994 typedef
995 #include "vmware_pack_begin.h"
996 struct {
997    uint32               cid;
998    SVGA3dRect           rect;
999 }
1000 #include "vmware_pack_end.h"
1001 SVGA3dCmdSetScissorRect;         /* SVGA_3D_CMD_SETSCISSORRECT */
1002 
1003 typedef
1004 #include "vmware_pack_begin.h"
1005 struct {
1006    uint32               cid;
1007    uint32               index;
1008    float                plane[4];
1009 }
1010 #include "vmware_pack_end.h"
1011 SVGA3dCmdSetClipPlane;           /* SVGA_3D_CMD_SETCLIPPLANE */
1012 
1013 typedef
1014 #include "vmware_pack_begin.h"
1015 struct {
1016    uint32               cid;
1017    uint32               shid;
1018    SVGA3dShaderType     type;
1019    /* Followed by variable number of DWORDs for shader bycode */
1020 }
1021 #include "vmware_pack_end.h"
1022 SVGA3dCmdDefineShader;           /* SVGA_3D_CMD_SHADER_DEFINE */
1023 
1024 typedef
1025 #include "vmware_pack_begin.h"
1026 struct {
1027    uint32               cid;
1028    uint32               shid;
1029    SVGA3dShaderType     type;
1030 }
1031 #include "vmware_pack_end.h"
1032 SVGA3dCmdDestroyShader;         /* SVGA_3D_CMD_SHADER_DESTROY */
1033 
1034 typedef
1035 #include "vmware_pack_begin.h"
1036 struct {
1037    uint32                  cid;
1038    uint32                  reg;     /* register number */
1039    SVGA3dShaderType        type;
1040    SVGA3dShaderConstType   ctype;
1041    uint32                  values[4];
1042 
1043    /*
1044     * Followed by a variable number of additional values.
1045     */
1046 }
1047 #include "vmware_pack_end.h"
1048 SVGA3dCmdSetShaderConst;        /* SVGA_3D_CMD_SET_SHADER_CONST */
1049 
1050 typedef
1051 #include "vmware_pack_begin.h"
1052 struct {
1053    uint32               cid;
1054    SVGA3dShaderType     type;
1055    uint32               shid;
1056 }
1057 #include "vmware_pack_end.h"
1058 SVGA3dCmdSetShader;       /* SVGA_3D_CMD_SET_SHADER */
1059 
1060 typedef
1061 #include "vmware_pack_begin.h"
1062 struct {
1063    uint32               cid;
1064    SVGA3dQueryType      type;
1065 }
1066 #include "vmware_pack_end.h"
1067 SVGA3dCmdBeginQuery;           /* SVGA_3D_CMD_BEGIN_QUERY */
1068 
1069 typedef
1070 #include "vmware_pack_begin.h"
1071 struct {
1072    uint32               cid;
1073    SVGA3dQueryType      type;
1074    SVGAGuestPtr         guestResult;   /* Points to an SVGA3dQueryResult structure */
1075 }
1076 #include "vmware_pack_end.h"
1077 SVGA3dCmdEndQuery;                  /* SVGA_3D_CMD_END_QUERY */
1078 
1079 
1080 /*
1081  * SVGA3D_CMD_WAIT_FOR_QUERY --
1082  *
1083  *    Will read the SVGA3dQueryResult structure pointed to by guestResult,
1084  *    and if the state member is set to anything else than
1085  *    SVGA3D_QUERYSTATE_PENDING, this command will always be a no-op.
1086  *
1087  *    Otherwise, in addition to the query explicitly waited for,
1088  *    All queries with the same type and issued with the same cid, for which
1089  *    an SVGA_3D_CMD_END_QUERY command has previously been sent, will
1090  *    be finished after execution of this command.
1091  *
1092  *    A query will be identified by the gmrId and offset of the guestResult
1093  *    member. If the device can't find an SVGA_3D_CMD_END_QUERY that has
1094  *    been sent previously with an indentical gmrId and offset, it will
1095  *    effectively end all queries with an identical type issued with the
1096  *    same cid, and the SVGA3dQueryResult structure pointed to by
1097  *    guestResult will not be written to. This property can be used to
1098  *    implement a query barrier for a given cid and query type.
1099  */
1100 
1101 typedef
1102 #include "vmware_pack_begin.h"
1103 struct {
1104    uint32               cid;        /* Same parameters passed to END_QUERY */
1105    SVGA3dQueryType      type;
1106    SVGAGuestPtr         guestResult;
1107 }
1108 #include "vmware_pack_end.h"
1109 SVGA3dCmdWaitForQuery;              /* SVGA_3D_CMD_WAIT_FOR_QUERY */
1110 
1111 typedef
1112 #include "vmware_pack_begin.h"
1113 struct {
1114    uint32               totalSize;    /* Set by guest before query is ended. */
1115    SVGA3dQueryState     state;        /* Set by host or guest. See SVGA3dQueryState. */
1116    union {                            /* Set by host on exit from PENDING state */
1117       uint32            result32;
1118       uint32            queryCookie; /* May be used to identify which QueryGetData this
1119                                         result corresponds to. */
1120    };
1121 }
1122 #include "vmware_pack_end.h"
1123 SVGA3dQueryResult;
1124 
1125 
1126 /*
1127  * SVGA_3D_CMD_BLIT_SURFACE_TO_SCREEN --
1128  *
1129  *    This is a blit from an SVGA3D surface to a Screen Object.
1130  *    This blit must be directed at a specific screen.
1131  *
1132  *    The blit copies from a rectangular region of an SVGA3D surface
1133  *    image to a rectangular region of a screen.
1134  *
1135  *    This command takes an optional variable-length list of clipping
1136  *    rectangles after the body of the command. If no rectangles are
1137  *    specified, there is no clipping region. The entire destRect is
1138  *    drawn to. If one or more rectangles are included, they describe
1139  *    a clipping region. The clip rectangle coordinates are measured
1140  *    relative to the top-left corner of destRect.
1141  *
1142  *    The srcImage must be from mip=0 face=0.
1143  *
1144  *    This supports scaling if the src and dest are of different sizes.
1145  *
1146  * Availability:
1147  *    SVGA_FIFO_CAP_SCREEN_OBJECT
1148  */
1149 
1150 typedef
1151 #include "vmware_pack_begin.h"
1152 struct {
1153    SVGA3dSurfaceImageId srcImage;
1154    SVGASignedRect       srcRect;
1155    uint32               destScreenId; /* Screen Object ID */
1156    SVGASignedRect       destRect;
1157    /* Clipping: zero or more SVGASignedRects follow */
1158 }
1159 #include "vmware_pack_end.h"
1160 SVGA3dCmdBlitSurfaceToScreen;         /* SVGA_3D_CMD_BLIT_SURFACE_TO_SCREEN */
1161 
1162 typedef
1163 #include "vmware_pack_begin.h"
1164 struct {
1165    uint32               sid;
1166    SVGA3dTextureFilter  filter;
1167 }
1168 #include "vmware_pack_end.h"
1169 SVGA3dCmdGenerateMipmaps;             /* SVGA_3D_CMD_GENERATE_MIPMAPS */
1170 
1171 typedef
1172 #include "vmware_pack_begin.h"
1173 struct {
1174    uint32 sid;
1175 }
1176 #include "vmware_pack_end.h"
1177 SVGA3dCmdActivateSurface;               /* SVGA_3D_CMD_ACTIVATE_SURFACE */
1178 
1179 typedef
1180 #include "vmware_pack_begin.h"
1181 struct {
1182    uint32 sid;
1183 }
1184 #include "vmware_pack_end.h"
1185 SVGA3dCmdDeactivateSurface;             /* SVGA_3D_CMD_DEACTIVATE_SURFACE */
1186 
1187 /*
1188  * Screen DMA command
1189  *
1190  * Available with SVGA_FIFO_CAP_SCREEN_OBJECT_2.  The SVGA_CAP_3D device
1191  * cap bit is not required.
1192  *
1193  * - refBuffer and destBuffer are 32bit BGRX; refBuffer and destBuffer could
1194  *   be different, but it is required that guest makes sure refBuffer has
1195  *   exactly the same contents that were written to when last time screen DMA
1196  *   command is received by host.
1197  *
1198  * - changemap is generated by lib/blit, and it has the changes from last
1199  *   received screen DMA or more.
1200  */
1201 
1202 typedef
1203 #include "vmware_pack_begin.h"
1204 struct SVGA3dCmdScreenDMA {
1205    uint32 screenId;
1206    SVGAGuestImage refBuffer;
1207    SVGAGuestImage destBuffer;
1208    SVGAGuestImage changeMap;
1209 }
1210 #include "vmware_pack_end.h"
1211 SVGA3dCmdScreenDMA;        /* SVGA_3D_CMD_SCREEN_DMA */
1212 
1213 /*
1214  * Logic ops
1215  */
1216 
1217 #define SVGA3D_LOTRANSBLT_HONORALPHA     (0x01)
1218 #define SVGA3D_LOSTRETCHBLT_MIRRORX      (0x01)
1219 #define SVGA3D_LOSTRETCHBLT_MIRRORY      (0x02)
1220 #define SVGA3D_LOALPHABLEND_SRCHASALPHA  (0x01)
1221 
1222 typedef
1223 #include "vmware_pack_begin.h"
1224 struct SVGA3dCmdLogicOpsBitBlt {
1225    /*
1226     * All LogicOps surfaces are one-level
1227     * surfaces so mipmap & face should always
1228     * be zero.
1229     */
1230    SVGA3dSurfaceImageId src;
1231    SVGA3dSurfaceImageId dst;
1232    SVGA3dLogicOp logicOp;
1233    /* Followed by variable number of SVGA3dCopyBox structures */
1234 }
1235 #include "vmware_pack_end.h"
1236 SVGA3dCmdLogicOpsBitBlt;   /* SVGA_3D_CMD_LOGICOPS_BITBLT */
1237 
1238 
1239 typedef
1240 #include "vmware_pack_begin.h"
1241 struct SVGA3dCmdLogicOpsTransBlt {
1242    /*
1243     * All LogicOps surfaces are one-level
1244     * surfaces so mipmap & face should always
1245     * be zero.
1246     */
1247    SVGA3dSurfaceImageId src;
1248    SVGA3dSurfaceImageId dst;
1249    uint32 color;
1250    uint32 flags;
1251    SVGA3dBox srcBox;
1252    SVGA3dBox dstBox;
1253 }
1254 #include "vmware_pack_end.h"
1255 SVGA3dCmdLogicOpsTransBlt;   /* SVGA_3D_CMD_LOGICOPS_TRANSBLT */
1256 
1257 
1258 typedef
1259 #include "vmware_pack_begin.h"
1260 struct SVGA3dCmdLogicOpsStretchBlt {
1261    /*
1262     * All LogicOps surfaces are one-level
1263     * surfaces so mipmap & face should always
1264     * be zero.
1265     */
1266    SVGA3dSurfaceImageId src;
1267    SVGA3dSurfaceImageId dst;
1268    uint16 mode;
1269    uint16 flags;
1270    SVGA3dBox srcBox;
1271    SVGA3dBox dstBox;
1272 }
1273 #include "vmware_pack_end.h"
1274 SVGA3dCmdLogicOpsStretchBlt;   /* SVGA_3D_CMD_LOGICOPS_STRETCHBLT */
1275 
1276 
1277 typedef
1278 #include "vmware_pack_begin.h"
1279 struct SVGA3dCmdLogicOpsColorFill {
1280    /*
1281     * All LogicOps surfaces are one-level
1282     * surfaces so mipmap & face should always
1283     * be zero.
1284     */
1285    SVGA3dSurfaceImageId dst;
1286    uint32 color;
1287    SVGA3dLogicOp logicOp;
1288    /* Followed by variable number of SVGA3dRect structures. */
1289 }
1290 #include "vmware_pack_end.h"
1291 SVGA3dCmdLogicOpsColorFill;   /* SVGA_3D_CMD_LOGICOPS_COLORFILL */
1292 
1293 
1294 typedef
1295 #include "vmware_pack_begin.h"
1296 struct SVGA3dCmdLogicOpsAlphaBlend {
1297    /*
1298     * All LogicOps surfaces are one-level
1299     * surfaces so mipmap & face should always
1300     * be zero.
1301     */
1302    SVGA3dSurfaceImageId src;
1303    SVGA3dSurfaceImageId dst;
1304    uint32 alphaVal;
1305    uint32 flags;
1306    SVGA3dBox srcBox;
1307    SVGA3dBox dstBox;
1308 }
1309 #include "vmware_pack_end.h"
1310 SVGA3dCmdLogicOpsAlphaBlend;   /* SVGA_3D_CMD_LOGICOPS_ALPHABLEND */
1311 
1312 #define SVGA3D_CLEARTYPE_INVALID_GAMMA_INDEX 0xFFFFFFFF
1313 
1314 #define SVGA3D_CLEARTYPE_GAMMA_WIDTH  512
1315 #define SVGA3D_CLEARTYPE_GAMMA_HEIGHT 16
1316 
1317 typedef
1318 #include "vmware_pack_begin.h"
1319 struct SVGA3dCmdLogicOpsClearTypeBlend {
1320    /*
1321     * All LogicOps surfaces are one-level
1322     * surfaces so mipmap & face should always
1323     * be zero.
1324     */
1325    SVGA3dSurfaceImageId tmp;
1326    SVGA3dSurfaceImageId dst;
1327    SVGA3dSurfaceImageId gammaSurf;
1328    SVGA3dSurfaceImageId alphaSurf;
1329    uint32 gamma;
1330    uint32 color;
1331    uint32 color2;
1332    int32 alphaOffsetX;
1333    int32 alphaOffsetY;
1334    /* Followed by variable number of SVGA3dBox structures */
1335 }
1336 #include "vmware_pack_end.h"
1337 SVGA3dCmdLogicOpsClearTypeBlend;   /* SVGA_3D_CMD_LOGICOPS_CLEARTYPEBLEND */
1338 
1339 
1340 /*
1341  * Guest-backed objects definitions.
1342  */
1343 
1344 typedef
1345 #include "vmware_pack_begin.h"
1346 struct {
1347    SVGAMobFormat ptDepth;
1348    uint32 sizeInBytes;
1349    PPN64 base;
1350 }
1351 #include "vmware_pack_end.h"
1352 SVGAOTableMobEntry;
1353 #define SVGA3D_OTABLE_MOB_ENTRY_SIZE (sizeof(SVGAOTableMobEntry))
1354 
1355 typedef
1356 #include "vmware_pack_begin.h"
1357 struct {
1358    SVGA3dSurfaceFormat format;
1359    SVGA3dSurface1Flags surface1Flags;
1360    uint32 numMipLevels;
1361    uint32 multisampleCount;
1362    SVGA3dTextureFilter autogenFilter;
1363    SVGA3dSize size;
1364    SVGAMobId mobid;
1365    uint32 arraySize;
1366    uint32 mobPitch;
1367    SVGA3dSurface2Flags surface2Flags;
1368    uint8 multisamplePattern;
1369    uint8 qualityLevel;
1370    uint8  pad0[2];
1371    uint32 pad1[3];
1372 }
1373 #include "vmware_pack_end.h"
1374 SVGAOTableSurfaceEntry;
1375 #define SVGA3D_OTABLE_SURFACE_ENTRY_SIZE (sizeof(SVGAOTableSurfaceEntry))
1376 
1377 typedef
1378 #include "vmware_pack_begin.h"
1379 struct {
1380    uint32 cid;
1381    SVGAMobId mobid;
1382 }
1383 #include "vmware_pack_end.h"
1384 SVGAOTableContextEntry;
1385 #define SVGA3D_OTABLE_CONTEXT_ENTRY_SIZE (sizeof(SVGAOTableContextEntry))
1386 
1387 typedef
1388 #include "vmware_pack_begin.h"
1389 struct {
1390    SVGA3dShaderType type;
1391    uint32 sizeInBytes;
1392    uint32 offsetInBytes;
1393    SVGAMobId mobid;
1394 }
1395 #include "vmware_pack_end.h"
1396 SVGAOTableShaderEntry;
1397 #define SVGA3D_OTABLE_SHADER_ENTRY_SIZE (sizeof(SVGAOTableShaderEntry))
1398 
1399 #define SVGA_STFLAG_PRIMARY  (1 << 0)
1400 #define SVGA_STFLAG_RESERVED (1 << 1) /* Added with cap SVGA_CAP_HP_CMD_QUEUE */
1401 typedef uint32 SVGAScreenTargetFlags;
1402 
1403 typedef
1404 #include "vmware_pack_begin.h"
1405 struct {
1406    SVGA3dSurfaceImageId image;
1407    uint32 width;
1408    uint32 height;
1409    int32 xRoot;
1410    int32 yRoot;
1411    SVGAScreenTargetFlags flags;
1412    uint32 dpi;
1413    uint32 pad[7];
1414 }
1415 #include "vmware_pack_end.h"
1416 SVGAOTableScreenTargetEntry;
1417 #define SVGA3D_OTABLE_SCREEN_TARGET_ENTRY_SIZE \
1418 	(sizeof(SVGAOTableScreenTargetEntry))
1419 
1420 typedef
1421 #include "vmware_pack_begin.h"
1422 struct {
1423    float value[4];
1424 }
1425 #include "vmware_pack_end.h"
1426 SVGA3dShaderConstFloat;
1427 
1428 typedef
1429 #include "vmware_pack_begin.h"
1430 struct {
1431    int32 value[4];
1432 }
1433 #include "vmware_pack_end.h"
1434 SVGA3dShaderConstInt;
1435 
1436 typedef
1437 #include "vmware_pack_begin.h"
1438 struct {
1439    uint32 value;
1440 }
1441 #include "vmware_pack_end.h"
1442 SVGA3dShaderConstBool;
1443 
1444 typedef
1445 #include "vmware_pack_begin.h"
1446 struct {
1447    uint16 streamOffset;
1448    uint8 stream;
1449    uint8 type;
1450    uint8 methodUsage;
1451    uint8 usageIndex;
1452 }
1453 #include "vmware_pack_end.h"
1454 SVGAGBVertexElement;
1455 
1456 typedef
1457 #include "vmware_pack_begin.h"
1458 struct {
1459    uint32 sid;
1460    uint16 stride;
1461    uint32 offset;
1462 }
1463 #include "vmware_pack_end.h"
1464 SVGAGBVertexStream;
1465 typedef
1466 #include "vmware_pack_begin.h"
1467 struct {
1468    SVGA3dRect viewport;
1469    SVGA3dRect scissorRect;
1470    SVGA3dZRange zRange;
1471 
1472    SVGA3dSurfaceImageId renderTargets[SVGA3D_RT_MAX];
1473    SVGAGBVertexElement decl1[4];
1474 
1475    uint32 renderStates[SVGA3D_RS_MAX];
1476    SVGAGBVertexElement decl2[18];
1477    uint32 pad0[2];
1478 
1479    struct {
1480       SVGA3dFace face;
1481       SVGA3dMaterial material;
1482    } material;
1483 
1484    float clipPlanes[SVGA3D_NUM_CLIPPLANES][4];
1485    float matrices[SVGA3D_TRANSFORM_MAX][16];
1486 
1487    SVGA3dBool lightEnabled[SVGA3D_NUM_LIGHTS];
1488    SVGA3dLightData lightData[SVGA3D_NUM_LIGHTS];
1489 
1490    /*
1491     * Shaders currently bound
1492     */
1493    uint32 shaders[SVGA3D_NUM_SHADERTYPE_PREDX];
1494    SVGAGBVertexElement decl3[10];
1495    uint32 pad1[3];
1496 
1497    uint32 occQueryActive;
1498    uint32 occQueryValue;
1499 
1500    /*
1501     * Int/Bool Shader constants
1502     */
1503    SVGA3dShaderConstInt pShaderIValues[SVGA3D_CONSTINTREG_MAX];
1504    SVGA3dShaderConstInt vShaderIValues[SVGA3D_CONSTINTREG_MAX];
1505    uint16 pShaderBValues;
1506    uint16 vShaderBValues;
1507 
1508 
1509    SVGAGBVertexStream streams[SVGA3D_MAX_VERTEX_ARRAYS];
1510    SVGA3dVertexDivisor divisors[SVGA3D_MAX_VERTEX_ARRAYS];
1511    uint32 numVertexDecls;
1512    uint32 numVertexStreams;
1513    uint32 numVertexDivisors;
1514    uint32 pad2[30];
1515 
1516    /*
1517     * Texture Stages
1518     *
1519     * SVGA3D_TS_INVALID through SVGA3D_TS_CONSTANT are in the
1520     * textureStages array.
1521     * SVGA3D_TS_COLOR_KEY is in tsColorKey.
1522     */
1523    uint32 tsColorKey[SVGA3D_NUM_TEXTURE_UNITS];
1524    uint32 textureStages[SVGA3D_NUM_TEXTURE_UNITS][SVGA3D_TS_CONSTANT + 1];
1525    uint32 tsColorKeyEnable[SVGA3D_NUM_TEXTURE_UNITS];
1526 
1527    /*
1528     * Float Shader constants.
1529     */
1530    SVGA3dShaderConstFloat pShaderFValues[SVGA3D_CONSTREG_MAX];
1531    SVGA3dShaderConstFloat vShaderFValues[SVGA3D_CONSTREG_MAX];
1532 }
1533 #include "vmware_pack_end.h"
1534 SVGAGBContextData;
1535 #define SVGA3D_CONTEXT_DATA_SIZE (sizeof(SVGAGBContextData))
1536 
1537 /*
1538  * SVGA3dCmdSetOTableBase --
1539  *
1540  * This command allows the guest to specify the base PPN of the
1541  * specified object table.
1542  */
1543 
1544 typedef
1545 #include "vmware_pack_begin.h"
1546 struct {
1547    SVGAOTableType type;
1548    PPN baseAddress;
1549    uint32 sizeInBytes;
1550    uint32 validSizeInBytes;
1551    SVGAMobFormat ptDepth;
1552 }
1553 #include "vmware_pack_end.h"
1554 SVGA3dCmdSetOTableBase;  /* SVGA_3D_CMD_SET_OTABLE_BASE */
1555 
1556 typedef
1557 #include "vmware_pack_begin.h"
1558 struct {
1559    SVGAOTableType type;
1560    PPN64 baseAddress;
1561    uint32 sizeInBytes;
1562    uint32 validSizeInBytes;
1563    SVGAMobFormat ptDepth;
1564 }
1565 #include "vmware_pack_end.h"
1566 SVGA3dCmdSetOTableBase64;  /* SVGA_3D_CMD_SET_OTABLE_BASE64 */
1567 
1568 /*
1569  * Guests using SVGA_3D_CMD_GROW_OTABLE are promising that
1570  * the new OTable contains the same contents as the old one, except possibly
1571  * for some new invalid entries at the end.
1572  *
1573  * (Otherwise, guests should use one of the SetOTableBase commands.)
1574  */
1575 typedef
1576 #include "vmware_pack_begin.h"
1577 struct {
1578    SVGAOTableType type;
1579    PPN64 baseAddress;
1580    uint32 sizeInBytes;
1581    uint32 validSizeInBytes;
1582    SVGAMobFormat ptDepth;
1583 }
1584 #include "vmware_pack_end.h"
1585 SVGA3dCmdGrowOTable;  /* SVGA_3D_CMD_GROW_OTABLE */
1586 
1587 typedef
1588 #include "vmware_pack_begin.h"
1589 struct {
1590    SVGAOTableType type;
1591 }
1592 #include "vmware_pack_end.h"
1593 SVGA3dCmdReadbackOTable;  /* SVGA_3D_CMD_READBACK_OTABLE */
1594 
1595 /*
1596  * Define a memory object (Mob) in the OTable.
1597  */
1598 
1599 typedef
1600 #include "vmware_pack_begin.h"
1601 struct SVGA3dCmdDefineGBMob {
1602    SVGAMobId mobid;
1603    SVGAMobFormat ptDepth;
1604    PPN base;
1605    uint32 sizeInBytes;
1606 }
1607 #include "vmware_pack_end.h"
1608 SVGA3dCmdDefineGBMob;   /* SVGA_3D_CMD_DEFINE_GB_MOB */
1609 
1610 
1611 /*
1612  * Destroys an object in the OTable.
1613  */
1614 
1615 typedef
1616 #include "vmware_pack_begin.h"
1617 struct SVGA3dCmdDestroyGBMob {
1618    SVGAMobId mobid;
1619 }
1620 #include "vmware_pack_end.h"
1621 SVGA3dCmdDestroyGBMob;   /* SVGA_3D_CMD_DESTROY_GB_MOB */
1622 
1623 
1624 /*
1625  * Define a memory object (Mob) in the OTable with a PPN64 base.
1626  */
1627 
1628 typedef
1629 #include "vmware_pack_begin.h"
1630 struct SVGA3dCmdDefineGBMob64 {
1631    SVGAMobId mobid;
1632    SVGAMobFormat ptDepth;
1633    PPN64 base;
1634    uint32 sizeInBytes;
1635 }
1636 #include "vmware_pack_end.h"
1637 SVGA3dCmdDefineGBMob64;   /* SVGA_3D_CMD_DEFINE_GB_MOB64 */
1638 
1639 /*
1640  * Redefine an object in the OTable with PPN64 base.
1641  */
1642 
1643 typedef
1644 #include "vmware_pack_begin.h"
1645 struct SVGA3dCmdRedefineGBMob64 {
1646    SVGAMobId mobid;
1647    SVGAMobFormat ptDepth;
1648    PPN64 base;
1649    uint32 sizeInBytes;
1650 }
1651 #include "vmware_pack_end.h"
1652 SVGA3dCmdRedefineGBMob64;   /* SVGA_3D_CMD_REDEFINE_GB_MOB64 */
1653 
1654 /*
1655  * Notification that the page tables have been modified.
1656  */
1657 
1658 typedef
1659 #include "vmware_pack_begin.h"
1660 struct SVGA3dCmdUpdateGBMobMapping {
1661    SVGAMobId mobid;
1662 }
1663 #include "vmware_pack_end.h"
1664 SVGA3dCmdUpdateGBMobMapping;   /* SVGA_3D_CMD_UPDATE_GB_MOB_MAPPING */
1665 
1666 /*
1667  * Define a guest-backed surface.
1668  */
1669 
1670 typedef
1671 #include "vmware_pack_begin.h"
1672 struct SVGA3dCmdDefineGBSurface {
1673    uint32 sid;
1674    SVGA3dSurface1Flags surfaceFlags;
1675    SVGA3dSurfaceFormat format;
1676    uint32 numMipLevels;
1677    uint32 multisampleCount;
1678    SVGA3dTextureFilter autogenFilter;
1679    SVGA3dSize size;
1680 }
1681 #include "vmware_pack_end.h"
1682 SVGA3dCmdDefineGBSurface;   /* SVGA_3D_CMD_DEFINE_GB_SURFACE */
1683 
1684 /*
1685  * Defines a guest-backed surface, adding the arraySize field.
1686  */
1687 typedef
1688 #include "vmware_pack_begin.h"
1689 struct SVGA3dCmdDefineGBSurface_v2 {
1690    uint32 sid;
1691    SVGA3dSurface1Flags surfaceFlags;
1692    SVGA3dSurfaceFormat format;
1693    uint32 numMipLevels;
1694    uint32 multisampleCount;
1695    SVGA3dTextureFilter autogenFilter;
1696    SVGA3dSize size;
1697    uint32 arraySize;
1698    uint32 pad;
1699 }
1700 #include "vmware_pack_end.h"
1701 SVGA3dCmdDefineGBSurface_v2;   /* SVGA_3D_CMD_DEFINE_GB_SURFACE_V2 */
1702 
1703 /*
1704  * Defines a guest-backed surface, adding the larger flags.
1705  */
1706 typedef
1707 #include "vmware_pack_begin.h"
1708 struct SVGA3dCmdDefineGBSurface_v3 {
1709    uint32 sid;
1710    SVGA3dSurfaceAllFlags surfaceFlags;
1711    SVGA3dSurfaceFormat format;
1712    uint32 numMipLevels;
1713    uint32 multisampleCount;
1714    SVGA3dMSPattern multisamplePattern;
1715    SVGA3dMSQualityLevel qualityLevel;
1716    SVGA3dTextureFilter autogenFilter;
1717    SVGA3dSize size;
1718    uint32 arraySize;
1719 }
1720 #include "vmware_pack_end.h"
1721 SVGA3dCmdDefineGBSurface_v3;   /* SVGA_3D_CMD_DEFINE_GB_SURFACE_V3 */
1722 
1723 /*
1724  * Destroy a guest-backed surface.
1725  */
1726 
1727 typedef
1728 #include "vmware_pack_begin.h"
1729 struct SVGA3dCmdDestroyGBSurface {
1730    uint32 sid;
1731 }
1732 #include "vmware_pack_end.h"
1733 SVGA3dCmdDestroyGBSurface;   /* SVGA_3D_CMD_DESTROY_GB_SURFACE */
1734 
1735 /*
1736  * Bind a guest-backed surface to a mob.
1737  */
1738 
1739 typedef
1740 #include "vmware_pack_begin.h"
1741 struct SVGA3dCmdBindGBSurface {
1742    uint32 sid;
1743    SVGAMobId mobid;
1744 }
1745 #include "vmware_pack_end.h"
1746 SVGA3dCmdBindGBSurface;   /* SVGA_3D_CMD_BIND_GB_SURFACE */
1747 
1748 typedef
1749 #include "vmware_pack_begin.h"
1750 struct SVGA3dCmdBindGBSurfaceWithPitch {
1751    uint32 sid;
1752    SVGAMobId mobid;
1753    uint32 baseLevelPitch;
1754 }
1755 #include "vmware_pack_end.h"
1756 SVGA3dCmdBindGBSurfaceWithPitch;   /* SVGA_3D_CMD_BIND_GB_SURFACE_WITH_PITCH */
1757 
1758 /*
1759  * Conditionally bind a mob to a guest-backed surface if testMobid
1760  * matches the currently bound mob.  Optionally issue a
1761  * readback/update on the surface while it is still bound to the old
1762  * mobid if the mobid is changed by this command.
1763  */
1764 
1765 #define SVGA3D_COND_BIND_GB_SURFACE_FLAG_READBACK (1 << 0)
1766 #define SVGA3D_COND_BIND_GB_SURFACE_FLAG_UPDATE   (1 << 1)
1767 
1768 typedef
1769 #include "vmware_pack_begin.h"
1770 struct SVGA3dCmdCondBindGBSurface {
1771    uint32 sid;
1772    SVGAMobId testMobid;
1773    SVGAMobId mobid;
1774    uint32 flags;
1775 }
1776 #include "vmware_pack_end.h"
1777 SVGA3dCmdCondBindGBSurface;          /* SVGA_3D_CMD_COND_BIND_GB_SURFACE */
1778 
1779 /*
1780  * Update an image in a guest-backed surface.
1781  * (Inform the device that the guest-contents have been updated.)
1782  */
1783 
1784 typedef
1785 #include "vmware_pack_begin.h"
1786 struct SVGA3dCmdUpdateGBImage {
1787    SVGA3dSurfaceImageId image;
1788    SVGA3dBox box;
1789 }
1790 #include "vmware_pack_end.h"
1791 SVGA3dCmdUpdateGBImage;   /* SVGA_3D_CMD_UPDATE_GB_IMAGE */
1792 
1793 /*
1794  * Update an entire guest-backed surface.
1795  * (Inform the device that the guest-contents have been updated.)
1796  */
1797 
1798 typedef
1799 #include "vmware_pack_begin.h"
1800 struct SVGA3dCmdUpdateGBSurface {
1801    uint32 sid;
1802 }
1803 #include "vmware_pack_end.h"
1804 SVGA3dCmdUpdateGBSurface;   /* SVGA_3D_CMD_UPDATE_GB_SURFACE */
1805 
1806 /*
1807  * Readback an image in a guest-backed surface.
1808  * (Request the device to flush the dirty contents into the guest.)
1809  */
1810 
1811 typedef
1812 #include "vmware_pack_begin.h"
1813 struct SVGA3dCmdReadbackGBImage {
1814    SVGA3dSurfaceImageId image;
1815 }
1816 #include "vmware_pack_end.h"
1817 SVGA3dCmdReadbackGBImage;   /* SVGA_3D_CMD_READBACK_GB_IMAGE */
1818 
1819 /*
1820  * Readback an entire guest-backed surface.
1821  * (Request the device to flush the dirty contents into the guest.)
1822  */
1823 
1824 typedef
1825 #include "vmware_pack_begin.h"
1826 struct SVGA3dCmdReadbackGBSurface {
1827    uint32 sid;
1828 }
1829 #include "vmware_pack_end.h"
1830 SVGA3dCmdReadbackGBSurface;   /* SVGA_3D_CMD_READBACK_GB_SURFACE */
1831 
1832 /*
1833  * Readback a sub rect of an image in a guest-backed surface.  After
1834  * issuing this command the driver is required to issue an update call
1835  * of the same region before issuing any other commands that reference
1836  * this surface or rendering is not guaranteed.
1837  */
1838 
1839 typedef
1840 #include "vmware_pack_begin.h"
1841 struct SVGA3dCmdReadbackGBImagePartial {
1842    SVGA3dSurfaceImageId image;
1843    SVGA3dBox box;
1844    uint32 invertBox;
1845 }
1846 #include "vmware_pack_end.h"
1847 SVGA3dCmdReadbackGBImagePartial; /* SVGA_3D_CMD_READBACK_GB_IMAGE_PARTIAL */
1848 
1849 
1850 /*
1851  * Invalidate an image in a guest-backed surface.
1852  * (Notify the device that the contents can be lost.)
1853  */
1854 
1855 typedef
1856 #include "vmware_pack_begin.h"
1857 struct SVGA3dCmdInvalidateGBImage {
1858    SVGA3dSurfaceImageId image;
1859 }
1860 #include "vmware_pack_end.h"
1861 SVGA3dCmdInvalidateGBImage;   /* SVGA_3D_CMD_INVALIDATE_GB_IMAGE */
1862 
1863 /*
1864  * Invalidate an entire guest-backed surface.
1865  * (Notify the device that the contents if all images can be lost.)
1866  */
1867 
1868 typedef
1869 #include "vmware_pack_begin.h"
1870 struct SVGA3dCmdInvalidateGBSurface {
1871    uint32 sid;
1872 }
1873 #include "vmware_pack_end.h"
1874 SVGA3dCmdInvalidateGBSurface; /* SVGA_3D_CMD_INVALIDATE_GB_SURFACE */
1875 
1876 /*
1877  * Invalidate a sub rect of an image in a guest-backed surface.  After
1878  * issuing this command the driver is required to issue an update call
1879  * of the same region before issuing any other commands that reference
1880  * this surface or rendering is not guaranteed.
1881  */
1882 
1883 typedef
1884 #include "vmware_pack_begin.h"
1885 struct SVGA3dCmdInvalidateGBImagePartial {
1886    SVGA3dSurfaceImageId image;
1887    SVGA3dBox box;
1888    uint32 invertBox;
1889 }
1890 #include "vmware_pack_end.h"
1891 SVGA3dCmdInvalidateGBImagePartial; /* SVGA_3D_CMD_INVALIDATE_GB_IMAGE_PARTIAL */
1892 
1893 
1894 /*
1895  * Define a guest-backed context.
1896  */
1897 
1898 typedef
1899 #include "vmware_pack_begin.h"
1900 struct SVGA3dCmdDefineGBContext {
1901    uint32 cid;
1902 }
1903 #include "vmware_pack_end.h"
1904 SVGA3dCmdDefineGBContext;   /* SVGA_3D_CMD_DEFINE_GB_CONTEXT */
1905 
1906 /*
1907  * Destroy a guest-backed context.
1908  */
1909 
1910 typedef
1911 #include "vmware_pack_begin.h"
1912 struct SVGA3dCmdDestroyGBContext {
1913    uint32 cid;
1914 }
1915 #include "vmware_pack_end.h"
1916 SVGA3dCmdDestroyGBContext;   /* SVGA_3D_CMD_DESTROY_GB_CONTEXT */
1917 
1918 /*
1919  * Bind a guest-backed context.
1920  *
1921  * validContents should be set to 0 for new contexts,
1922  * and 1 if this is an old context which is getting paged
1923  * back on to the device.
1924  *
1925  * For new contexts, it is recommended that the driver
1926  * issue commands to initialize all interesting state
1927  * prior to rendering.
1928  */
1929 
1930 typedef
1931 #include "vmware_pack_begin.h"
1932 struct SVGA3dCmdBindGBContext {
1933    uint32 cid;
1934    SVGAMobId mobid;
1935    uint32 validContents;
1936 }
1937 #include "vmware_pack_end.h"
1938 SVGA3dCmdBindGBContext;   /* SVGA_3D_CMD_BIND_GB_CONTEXT */
1939 
1940 /*
1941  * Readback a guest-backed context.
1942  * (Request that the device flush the contents back into guest memory.)
1943  */
1944 
1945 typedef
1946 #include "vmware_pack_begin.h"
1947 struct SVGA3dCmdReadbackGBContext {
1948    uint32 cid;
1949 }
1950 #include "vmware_pack_end.h"
1951 SVGA3dCmdReadbackGBContext;   /* SVGA_3D_CMD_READBACK_GB_CONTEXT */
1952 
1953 /*
1954  * Invalidate a guest-backed context.
1955  */
1956 typedef
1957 #include "vmware_pack_begin.h"
1958 struct SVGA3dCmdInvalidateGBContext {
1959    uint32 cid;
1960 }
1961 #include "vmware_pack_end.h"
1962 SVGA3dCmdInvalidateGBContext;   /* SVGA_3D_CMD_INVALIDATE_GB_CONTEXT */
1963 
1964 /*
1965  * Define a guest-backed shader.
1966  */
1967 
1968 typedef
1969 #include "vmware_pack_begin.h"
1970 struct SVGA3dCmdDefineGBShader {
1971    uint32 shid;
1972    SVGA3dShaderType type;
1973    uint32 sizeInBytes;
1974 }
1975 #include "vmware_pack_end.h"
1976 SVGA3dCmdDefineGBShader;   /* SVGA_3D_CMD_DEFINE_GB_SHADER */
1977 
1978 /*
1979  * Bind a guest-backed shader.
1980  */
1981 
1982 typedef
1983 #include "vmware_pack_begin.h"
1984 struct SVGA3dCmdBindGBShader {
1985    uint32 shid;
1986    SVGAMobId mobid;
1987    uint32 offsetInBytes;
1988 }
1989 #include "vmware_pack_end.h"
1990 SVGA3dCmdBindGBShader;   /* SVGA_3D_CMD_BIND_GB_SHADER */
1991 
1992 /*
1993  * Destroy a guest-backed shader.
1994  */
1995 
1996 typedef
1997 #include "vmware_pack_begin.h"
1998 struct SVGA3dCmdDestroyGBShader {
1999    uint32 shid;
2000 }
2001 #include "vmware_pack_end.h"
2002 SVGA3dCmdDestroyGBShader;   /* SVGA_3D_CMD_DESTROY_GB_SHADER */
2003 
2004 typedef
2005 #include "vmware_pack_begin.h"
2006 struct {
2007    uint32                  cid;
2008    uint32                  regStart;
2009    SVGA3dShaderType        shaderType;
2010    SVGA3dShaderConstType   constType;
2011 
2012    /*
2013     * Followed by a variable number of shader constants.
2014     *
2015     * Note that FLOAT and INT constants are 4-dwords in length, while
2016     * BOOL constants are 1-dword in length.
2017     */
2018 }
2019 #include "vmware_pack_end.h"
2020 SVGA3dCmdSetGBShaderConstInline;   /* SVGA_3D_CMD_SET_GB_SHADERCONSTS_INLINE */
2021 
2022 
2023 typedef
2024 #include "vmware_pack_begin.h"
2025 struct {
2026    uint32               cid;
2027    SVGA3dQueryType      type;
2028 }
2029 #include "vmware_pack_end.h"
2030 SVGA3dCmdBeginGBQuery;           /* SVGA_3D_CMD_BEGIN_GB_QUERY */
2031 
2032 typedef
2033 #include "vmware_pack_begin.h"
2034 struct {
2035    uint32               cid;
2036    SVGA3dQueryType      type;
2037    SVGAMobId mobid;
2038    uint32 offset;
2039 }
2040 #include "vmware_pack_end.h"
2041 SVGA3dCmdEndGBQuery;                  /* SVGA_3D_CMD_END_GB_QUERY */
2042 
2043 
2044 /*
2045  * SVGA_3D_CMD_WAIT_FOR_GB_QUERY --
2046  *
2047  *    The semantics of this command are identical to the
2048  *    SVGA_3D_CMD_WAIT_FOR_QUERY except that the results are written
2049  *    to a Mob instead of a GMR.
2050  */
2051 
2052 typedef
2053 #include "vmware_pack_begin.h"
2054 struct {
2055    uint32               cid;
2056    SVGA3dQueryType      type;
2057    SVGAMobId mobid;
2058    uint32 offset;
2059 }
2060 #include "vmware_pack_end.h"
2061 SVGA3dCmdWaitForGBQuery;          /* SVGA_3D_CMD_WAIT_FOR_GB_QUERY */
2062 
2063 
2064 typedef
2065 #include "vmware_pack_begin.h"
2066 struct {
2067    SVGAMobId mobid;
2068    uint32 mustBeZero;
2069    uint32 initialized;
2070 }
2071 #include "vmware_pack_end.h"
2072 SVGA3dCmdEnableGart;              /* SVGA_3D_CMD_ENABLE_GART */
2073 
2074 typedef
2075 #include "vmware_pack_begin.h"
2076 struct {
2077    SVGAMobId mobid;
2078    uint32 gartOffset;
2079 }
2080 #include "vmware_pack_end.h"
2081 SVGA3dCmdMapMobIntoGart;          /* SVGA_3D_CMD_MAP_MOB_INTO_GART */
2082 
2083 
2084 typedef
2085 #include "vmware_pack_begin.h"
2086 struct {
2087    uint32 gartOffset;
2088    uint32 numPages;
2089 }
2090 #include "vmware_pack_end.h"
2091 SVGA3dCmdUnmapGartRange;          /* SVGA_3D_CMD_UNMAP_GART_RANGE */
2092 
2093 
2094 /*
2095  * Screen Targets
2096  */
2097 
2098 typedef
2099 #include "vmware_pack_begin.h"
2100 struct {
2101    uint32 stid;
2102    uint32 width;
2103    uint32 height;
2104    int32 xRoot;
2105    int32 yRoot;
2106    SVGAScreenTargetFlags flags;
2107 
2108    /*
2109     * The physical DPI that the guest expects this screen displayed at.
2110     *
2111     * Guests which are not DPI-aware should set this to zero.
2112     */
2113    uint32 dpi;
2114 }
2115 #include "vmware_pack_end.h"
2116 SVGA3dCmdDefineGBScreenTarget;    /* SVGA_3D_CMD_DEFINE_GB_SCREENTARGET */
2117 
2118 typedef
2119 #include "vmware_pack_begin.h"
2120 struct {
2121    uint32 stid;
2122 }
2123 #include "vmware_pack_end.h"
2124 SVGA3dCmdDestroyGBScreenTarget;  /* SVGA_3D_CMD_DESTROY_GB_SCREENTARGET */
2125 
2126 typedef
2127 #include "vmware_pack_begin.h"
2128 struct {
2129    uint32 stid;
2130    SVGA3dSurfaceImageId image;
2131 }
2132 #include "vmware_pack_end.h"
2133 SVGA3dCmdBindGBScreenTarget;  /* SVGA_3D_CMD_BIND_GB_SCREENTARGET */
2134 
2135 typedef
2136 #include "vmware_pack_begin.h"
2137 struct {
2138    uint32 stid;
2139    SVGA3dRect rect;
2140 }
2141 #include "vmware_pack_end.h"
2142 SVGA3dCmdUpdateGBScreenTarget;  /* SVGA_3D_CMD_UPDATE_GB_SCREENTARGET */
2143 
2144 typedef
2145 #include "vmware_pack_begin.h"
2146 struct SVGA3dCmdGBScreenDMA {
2147    uint32 screenId;
2148    uint32 dead;
2149    SVGAMobId destMobID;
2150    uint32 destPitch;
2151    SVGAMobId changeMapMobID;
2152 }
2153 #include "vmware_pack_end.h"
2154 SVGA3dCmdGBScreenDMA;        /* SVGA_3D_CMD_GB_SCREEN_DMA */
2155 
2156 typedef
2157 #include "vmware_pack_begin.h"
2158 struct {
2159    uint32 value;
2160    uint32 mobId;
2161    uint32 mobOffset;
2162 }
2163 #include "vmware_pack_end.h"
2164 SVGA3dCmdGBMobFence;  /* SVGA_3D_CMD_GB_MOB_FENCE */
2165 
2166 typedef
2167 #include "vmware_pack_begin.h"
2168 struct {
2169    uint32 stid;
2170    SVGA3dSurfaceImageId dest;
2171 
2172    uint32 statusMobId;
2173    uint32 statusMobOffset;
2174 
2175    /* Reserved fields */
2176    uint32 mustBeInvalidId;
2177    uint32 mustBeZero;
2178 }
2179 #include "vmware_pack_end.h"
2180 SVGA3dCmdScreenCopy;  /* SVGA_3D_CMD_SCREEN_COPY */
2181 
2182 #define SVGA_SCREEN_COPY_STATUS_FAILURE 0x00
2183 #define SVGA_SCREEN_COPY_STATUS_SUCCESS 0x01
2184 #define SVGA_SCREEN_COPY_STATUS_INVALID 0xFFFFFFFF
2185 
2186 #endif /* _SVGA3D_CMD_H_ */
2187