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