VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Video/common/wddm/VBoxMPIf.h@ 49244

Last change on this file since 49244 was 49244, checked in by vboxsync, 11 years ago

wddm: fix 3D rendering to primary

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 24.0 KB
Line 
1/* $Id: VBoxMPIf.h 49244 2013-10-22 20:08:34Z vboxsync $ */
2
3/** @file
4 * VBox WDDM Miniport driver
5 *
6 * Contains base definitions of constants & structures used
7 * to control & perform rendering,
8 * such as DMA commands types, allocation types, escape codes, etc.
9 * used by both miniport & display drivers.
10 *
11 * The latter uses these and only these defs to communicate with the former
12 * by posting appropriate requests via D3D RT Krnl Svc accessing callbacks.
13 */
14
15/*
16 * Copyright (C) 2011-2012 Oracle Corporation
17 *
18 * This file is part of VirtualBox Open Source Edition (OSE), as
19 * available from http://www.virtualbox.org. This file is free software;
20 * you can redistribute it and/or modify it under the terms of the GNU
21 * General Public License (GPL) as published by the Free Software
22 * Foundation, in version 2 as it comes in the "COPYING" file of the
23 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
24 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
25 */
26
27#ifndef ___VBoxMPIf_h___
28#define ___VBoxMPIf_h___
29
30#include <VBox/VBoxVideo.h>
31#include "../../../../include/VBoxDisplay.h"
32#include "../VBoxVideoTools.h"
33#include <VBox/VBoxUhgsmi.h>
34#include <VBox/VBoxGuest2.h>
35
36/* One would increase this whenever definitions in this file are changed */
37#define VBOXVIDEOIF_VERSION 19
38
39#define VBOXWDDM_NODE_ID_SYSTEM 0
40#define VBOXWDDM_NODE_ID_3D (VBOXWDDM_NODE_ID_SYSTEM)
41#define VBOXWDDM_NODE_ID_3D_KMT (VBOXWDDM_NODE_ID_3D)
42#define VBOXWDDM_NODE_ID_2D_VIDEO (VBOXWDDM_NODE_ID_3D_KMT+1)
43#define VBOXWDDM_NUM_NODES (VBOXWDDM_NODE_ID_2D_VIDEO+1)
44
45#define VBOXWDDM_ENGINE_ID_SYSTEM 0
46#if (VBOXWDDM_NODE_ID_3D == VBOXWDDM_NODE_ID_SYSTEM)
47# define VBOXWDDM_ENGINE_ID_3D (VBOXWDDM_ENGINE_ID_SYSTEM+1)
48#else
49# define VBOXWDDM_ENGINE_ID_3D 0
50#endif
51#if (VBOXWDDM_NODE_ID_3D_KMT == VBOXWDDM_NODE_ID_3D)
52# define VBOXWDDM_ENGINE_ID_3D_KMT VBOXWDDM_ENGINE_ID_3D
53#else
54# define VBOXWDDM_ENGINE_ID_3D_KMT 0
55#endif
56#if (VBOXWDDM_NODE_ID_2D_VIDEO == VBOXWDDM_NODE_ID_3D)
57# define VBOXWDDM_ENGINE_ID_2D_VIDEO VBOXWDDM_ENGINE_ID_3D
58#else
59# define VBOXWDDM_ENGINE_ID_2D_VIDEO 0
60#endif
61
62
63/* create allocation func */
64typedef enum
65{
66 VBOXWDDM_ALLOC_TYPE_UNEFINED = 0,
67 VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE,
68 VBOXWDDM_ALLOC_TYPE_STD_SHADOWSURFACE,
69 VBOXWDDM_ALLOC_TYPE_STD_STAGINGSURFACE,
70 /* this one is win 7-specific and hence unused for now */
71 VBOXWDDM_ALLOC_TYPE_STD_GDISURFACE
72 /* custom allocation types requested from user-mode d3d module will go here */
73 , VBOXWDDM_ALLOC_TYPE_UMD_RC_GENERIC
74 , VBOXWDDM_ALLOC_TYPE_UMD_HGSMI_BUFFER
75} VBOXWDDM_ALLOC_TYPE;
76
77/* usage */
78typedef enum
79{
80 VBOXWDDM_ALLOCUSAGE_TYPE_UNEFINED = 0,
81 /* set for the allocation being primary */
82 VBOXWDDM_ALLOCUSAGE_TYPE_PRIMARY,
83} VBOXWDDM_ALLOCUSAGE_TYPE;
84
85typedef struct VBOXWDDM_SURFACE_DESC
86{
87 UINT width;
88 UINT height;
89 D3DDDIFORMAT format;
90 UINT bpp;
91 UINT pitch;
92 UINT depth;
93 UINT slicePitch;
94 UINT d3dWidth;
95 UINT cbSize;
96 D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId;
97 D3DDDI_RATIONAL RefreshRate;
98} VBOXWDDM_SURFACE_DESC, *PVBOXWDDM_SURFACE_DESC;
99
100typedef struct VBOXWDDM_ALLOCINFO
101{
102 VBOXWDDM_ALLOC_TYPE enmType;
103 union
104 {
105 struct
106 {
107 D3DDDI_RESOURCEFLAGS fFlags;
108 /* id used to identify the allocation on the host */
109 uint32_t hostID;
110 uint64_t hSharedHandle;
111 VBOXWDDM_SURFACE_DESC SurfDesc;
112 };
113
114 struct
115 {
116 uint32_t cbBuffer;
117 uint64_t hSynch;
118 VBOXUHGSMI_BUFFER_TYPE_FLAGS fUhgsmiType;
119 };
120 };
121} VBOXWDDM_ALLOCINFO, *PVBOXWDDM_ALLOCINFO;
122
123typedef struct VBOXWDDM_RC_DESC
124{
125 D3DDDI_RESOURCEFLAGS fFlags;
126 D3DDDIFORMAT enmFormat;
127 D3DDDI_POOL enmPool;
128 D3DDDIMULTISAMPLE_TYPE enmMultisampleType;
129 UINT MultisampleQuality;
130 UINT MipLevels;
131 UINT Fvf;
132 D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId;
133 D3DDDI_RATIONAL RefreshRate;
134 D3DDDI_ROTATION enmRotation;
135} VBOXWDDM_RC_DESC, *PVBOXWDDM_RC_DESC;
136
137typedef struct VBOXWDDMDISP_RESOURCE_FLAGS
138{
139 union
140 {
141 struct
142 {
143 UINT Opened : 1; /* this resource is OpenResource'd rather than CreateResource'd */
144 UINT Generic : 1; /* identifies this is a resource created with CreateResource, the VBOXWDDMDISP_RESOURCE::fRcFlags is valid */
145 UINT KmResource : 1; /* this resource has underlying km resource */
146 UINT Reserved : 29; /* reserved */
147 };
148 UINT Value;
149 };
150} VBOXWDDMDISP_RESOURCE_FLAGS, *PVBOXWDDMDISP_RESOURCE_FLAGS;
151
152typedef struct VBOXWDDM_RCINFO
153{
154 VBOXWDDMDISP_RESOURCE_FLAGS fFlags;
155 VBOXWDDM_RC_DESC RcDesc;
156 uint32_t cAllocInfos;
157// VBOXWDDM_ALLOCINFO aAllocInfos[1];
158} VBOXWDDM_RCINFO, *PVBOXWDDM_RCINFO;
159
160typedef struct VBOXWDDM_DMA_PRIVATEDATA_FLAFS
161{
162 union
163 {
164 struct
165 {
166 UINT bCmdInDmaBuffer : 1;
167 UINT bReserved : 31;
168 };
169 uint32_t Value;
170 };
171} VBOXWDDM_DMA_PRIVATEDATA_FLAFS, *PVBOXWDDM_DMA_PRIVATEDATA_FLAFS;
172
173typedef struct VBOXWDDM_DMA_PRIVATEDATA_BASEHDR
174{
175 VBOXVDMACMD_TYPE enmCmd;
176 union
177 {
178 VBOXWDDM_DMA_PRIVATEDATA_FLAFS fFlags;
179 uint32_t u32CmdReserved;
180 };
181} VBOXWDDM_DMA_PRIVATEDATA_BASEHDR, *PVBOXWDDM_DMA_PRIVATEDATA_BASEHDR;
182
183typedef struct VBOXWDDM_UHGSMI_BUFFER_UI_SUBMIT_INFO
184{
185 uint32_t bDoNotSignalCompletion;
186 uint32_t offData;
187 uint32_t cbData;
188} VBOXWDDM_UHGSMI_BUFFER_UI_SUBMIT_INFO, *PVBOXWDDM_UHGSMI_BUFFER_UI_SUBMIT_INFO;
189
190typedef struct VBOXWDDM_DMA_PRIVATEDATA_UM_CHROMIUM_CMD
191{
192 VBOXWDDM_DMA_PRIVATEDATA_BASEHDR Base;
193 VBOXWDDM_UHGSMI_BUFFER_UI_SUBMIT_INFO aBufInfos[1];
194} VBOXWDDM_DMA_PRIVATEDATA_UM_CHROMIUM_CMD, *PVBOXWDDM_DMA_PRIVATEDATA_UM_CHROMIUM_CMD;
195
196#define VBOXVHWA_F_ENABLED 0x00000001
197#define VBOXVHWA_F_CKEY_DST 0x00000002
198#define VBOXVHWA_F_CKEY_SRC 0x00000004
199
200#define VBOXVHWA_MAX_FORMATS 8
201
202typedef struct VBOXVHWA_INFO
203{
204 uint32_t fFlags;
205 uint32_t cOverlaysSupported;
206 uint32_t cFormats;
207 D3DDDIFORMAT aFormats[VBOXVHWA_MAX_FORMATS];
208} VBOXVHWA_INFO;
209
210#define VBOXWDDM_OVERLAY_F_CKEY_DST 0x00000001
211#define VBOXWDDM_OVERLAY_F_CKEY_DSTRANGE 0x00000002
212#define VBOXWDDM_OVERLAY_F_CKEY_SRC 0x00000004
213#define VBOXWDDM_OVERLAY_F_CKEY_SRCRANGE 0x00000008
214#define VBOXWDDM_OVERLAY_F_BOB 0x00000010
215#define VBOXWDDM_OVERLAY_F_INTERLEAVED 0x00000020
216#define VBOXWDDM_OVERLAY_F_MIRROR_LR 0x00000040
217#define VBOXWDDM_OVERLAY_F_MIRROR_UD 0x00000080
218#define VBOXWDDM_OVERLAY_F_DEINTERLACED 0x00000100
219
220typedef struct VBOXWDDM_OVERLAY_DESC
221{
222 uint32_t fFlags;
223 UINT DstColorKeyLow;
224 UINT DstColorKeyHigh;
225 UINT SrcColorKeyLow;
226 UINT SrcColorKeyHigh;
227} VBOXWDDM_OVERLAY_DESC, *PVBOXWDDM_OVERLAY_DESC;
228
229typedef struct VBOXWDDM_OVERLAY_INFO
230{
231 VBOXWDDM_OVERLAY_DESC OverlayDesc;
232 VBOXWDDM_DIRTYREGION DirtyRegion; /* <- the dirty region of the overlay surface */
233} VBOXWDDM_OVERLAY_INFO, *PVBOXWDDM_OVERLAY_INFO;
234
235typedef struct VBOXWDDM_OVERLAYFLIP_INFO
236{
237 VBOXWDDM_DIRTYREGION DirtyRegion; /* <- the dirty region of the overlay surface */
238} VBOXWDDM_OVERLAYFLIP_INFO, *PVBOXWDDM_OVERLAYFLIP_INFO;
239
240
241typedef enum
242{
243 VBOXWDDM_CONTEXT_TYPE_UNDEFINED = 0,
244 /* system-created context (for GDI rendering) */
245 VBOXWDDM_CONTEXT_TYPE_SYSTEM,
246 /* context created by the D3D User-mode driver when crogl IS available */
247 VBOXWDDM_CONTEXT_TYPE_CUSTOM_3D,
248 /* context created by the D3D User-mode driver when crogl is NOT available or for ddraw overlay acceleration */
249 VBOXWDDM_CONTEXT_TYPE_CUSTOM_2D,
250 /* contexts created by the cromium HGSMI transport for HGSMI commands submission */
251 VBOXWDDM_CONTEXT_TYPE_CUSTOM_UHGSMI_3D,
252 VBOXWDDM_CONTEXT_TYPE_CUSTOM_UHGSMI_GL,
253 /* context created by the kernel->user communication mechanism for visible rects reporting, etc. */
254 VBOXWDDM_CONTEXT_TYPE_CUSTOM_SESSION,
255 /* context created by VBoxTray to handle resize operations */
256 VBOXWDDM_CONTEXT_TYPE_CUSTOM_DISPIF_RESIZE,
257 /* context created by VBoxTray to handle seamless operations */
258 VBOXWDDM_CONTEXT_TYPE_CUSTOM_DISPIF_SEAMLESS
259} VBOXWDDM_CONTEXT_TYPE;
260
261typedef struct VBOXWDDM_CREATECONTEXT_INFO
262{
263 /* interface version, i.e. 9 for d3d9, 8 for d3d8, etc. */
264 uint32_t u32IfVersion;
265 /* true if d3d false if ddraw */
266 VBOXWDDM_CONTEXT_TYPE enmType;
267 uint32_t crVersionMajor;
268 uint32_t crVersionMinor;
269 /* we use uint64_t instead of HANDLE to ensure structure def is the same for both 32-bit and 64-bit
270 * since x64 kernel driver can be called by 32-bit UMD */
271 uint64_t hUmEvent;
272 /* info to be passed to UMD notification to identify the context */
273 uint64_t u64UmInfo;
274} VBOXWDDM_CREATECONTEXT_INFO, *PVBOXWDDM_CREATECONTEXT_INFO;
275
276typedef uint64_t VBOXDISP_UMHANDLE;
277typedef uint32_t VBOXDISP_KMHANDLE;
278
279typedef struct VBOXWDDM_RECTS_FLAFS
280{
281 union
282 {
283 struct
284 {
285 /* used only in conjunction with bSetVisibleRects.
286 * if set - VBOXWDDM_RECTS_INFO::aRects[0] contains view rectangle */
287 UINT bSetViewRect : 1;
288 /* adds visible regions */
289 UINT bAddVisibleRects : 1;
290 /* adds hidden regions */
291 UINT bAddHiddenRects : 1;
292 /* hide entire window */
293 UINT bHide : 1;
294 /* reserved */
295 UINT Reserved : 28;
296 };
297 uint32_t Value;
298 };
299} VBOXWDDM_RECTS_FLAFS, *PVBOXWDDM_RECTS_FLAFS;
300
301typedef struct VBOXWDDM_RECTS_INFO
302{
303 uint32_t cRects;
304 RECT aRects[1];
305} VBOXWDDM_RECTS_INFO, *PVBOXWDDM_RECTS_INFO;
306
307#define VBOXWDDM_RECTS_INFO_SIZE4CRECTS(_cRects) (RT_OFFSETOF(VBOXWDDM_RECTS_INFO, aRects[(_cRects)]))
308#define VBOXWDDM_RECTS_INFO_SIZE(_pRects) (VBOXVIDEOCM_CMD_RECTS_SIZE4CRECTS((_pRects)->cRects))
309
310typedef enum
311{
312 /* command to be post to user mode */
313 VBOXVIDEOCM_CMD_TYPE_UM = 0,
314 /* control command processed in kernel mode */
315 VBOXVIDEOCM_CMD_TYPE_CTL_KM,
316 VBOXVIDEOCM_CMD_DUMMY_32BIT = 0x7fffffff
317} VBOXVIDEOCM_CMD_TYPE;
318
319typedef struct VBOXVIDEOCM_CMD_HDR
320{
321 uint64_t u64UmData;
322 uint32_t cbCmd;
323 VBOXVIDEOCM_CMD_TYPE enmType;
324}VBOXVIDEOCM_CMD_HDR, *PVBOXVIDEOCM_CMD_HDR;
325
326AssertCompile((sizeof (VBOXVIDEOCM_CMD_HDR) & 7) == 0);
327
328typedef struct VBOXVIDEOCM_CMD_RECTS
329{
330 VBOXWDDM_RECTS_FLAFS fFlags;
331 VBOXWDDM_RECTS_INFO RectsInfo;
332} VBOXVIDEOCM_CMD_RECTS, *PVBOXVIDEOCM_CMD_RECTS;
333
334typedef struct VBOXVIDEOCM_CMD_RECTS_INTERNAL
335{
336 union
337 {
338 VBOXDISP_UMHANDLE hSwapchainUm;
339 uint64_t hWnd;
340 uint64_t u64Value;
341 };
342 VBOXVIDEOCM_CMD_RECTS Cmd;
343} VBOXVIDEOCM_CMD_RECTS_INTERNAL, *PVBOXVIDEOCM_CMD_RECTS_INTERNAL;
344
345typedef struct VBOXVIDEOCM_CMD_RECTS_HDR
346{
347 VBOXVIDEOCM_CMD_HDR Hdr;
348 VBOXVIDEOCM_CMD_RECTS_INTERNAL Data;
349} VBOXVIDEOCM_CMD_RECTS_HDR, *PVBOXVIDEOCM_CMD_RECTS_HDR;
350
351#define VBOXVIDEOCM_CMD_RECTS_INTERNAL_SIZE4CRECTS(_cRects) (RT_OFFSETOF(VBOXVIDEOCM_CMD_RECTS_INTERNAL, Cmd.RectsInfo.aRects[(_cRects)]))
352#define VBOXVIDEOCM_CMD_RECTS_INTERNAL_SIZE(_pCmd) (VBOXVIDEOCM_CMD_RECTS_INTERNAL_SIZE4CRECTS((_pCmd)->cRects))
353
354typedef struct VBOXWDDM_GETVBOXVIDEOCMCMD_HDR
355{
356 uint32_t cbCmdsReturned;
357 uint32_t cbRemainingCmds;
358 uint32_t cbRemainingFirstCmd;
359 uint32_t u32Reserved;
360} VBOXWDDM_GETVBOXVIDEOCMCMD_HDR, *PVBOXWDDM_GETVBOXVIDEOCMCMD_HDR;
361
362typedef struct VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD
363{
364 VBOXDISPIFESCAPE EscapeHdr;
365 VBOXWDDM_GETVBOXVIDEOCMCMD_HDR Hdr;
366} VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD, *PVBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD;
367
368AssertCompile((sizeof (VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD) & 7) == 0);
369AssertCompile(RT_OFFSETOF(VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD, EscapeHdr) == 0);
370
371typedef struct VBOXDISPIFESCAPE_DBGPRINT
372{
373 VBOXDISPIFESCAPE EscapeHdr;
374 /* null-terminated string to DbgPrint including \0 */
375 char aStringBuf[1];
376} VBOXDISPIFESCAPE_DBGPRINT, *PVBOXDISPIFESCAPE_DBGPRINT;
377AssertCompile(RT_OFFSETOF(VBOXDISPIFESCAPE_DBGPRINT, EscapeHdr) == 0);
378
379typedef enum
380{
381 VBOXDISPIFESCAPE_DBGDUMPBUF_TYPE_UNDEFINED = 0,
382 VBOXDISPIFESCAPE_DBGDUMPBUF_TYPE_D3DCAPS9 = 1,
383 VBOXDISPIFESCAPE_DBGDUMPBUF_TYPE_DUMMY32BIT = 0x7fffffff
384} VBOXDISPIFESCAPE_DBGDUMPBUF_TYPE;
385
386typedef struct VBOXDISPIFESCAPE_DBGDUMPBUF_FLAGS
387{
388 union
389 {
390 struct
391 {
392 UINT WoW64 : 1;
393 UINT Reserved : 31; /* reserved */
394 };
395 UINT Value;
396 };
397} VBOXDISPIFESCAPE_DBGDUMPBUF_FLAGS, *PVBOXDISPIFESCAPE_DBGDUMPBUF_FLAGS;
398
399typedef struct VBOXDISPIFESCAPE_DBGDUMPBUF
400{
401 VBOXDISPIFESCAPE EscapeHdr;
402 VBOXDISPIFESCAPE_DBGDUMPBUF_TYPE enmType;
403 VBOXDISPIFESCAPE_DBGDUMPBUF_FLAGS Flags;
404 char aBuf[1];
405} VBOXDISPIFESCAPE_DBGDUMPBUF, *PVBOXDISPIFESCAPE_DBGDUMPBUF;
406AssertCompile(RT_OFFSETOF(VBOXDISPIFESCAPE_DBGDUMPBUF, EscapeHdr) == 0);
407
408typedef struct VBOXSCREENLAYOUT_ELEMENT
409{
410 D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId;
411 POINT pos;
412} VBOXSCREENLAYOUT_ELEMENT, *PVBOXSCREENLAYOUT_ELEMENT;
413
414typedef struct VBOXSCREENLAYOUT
415{
416 uint32_t cScreens;
417 VBOXSCREENLAYOUT_ELEMENT aScreens[1];
418} VBOXSCREENLAYOUT, *PVBOXSCREENLAYOUT;
419
420typedef struct VBOXDISPIFESCAPE_SCREENLAYOUT
421{
422 VBOXDISPIFESCAPE EscapeHdr;
423 VBOXSCREENLAYOUT ScreenLayout;
424} VBOXDISPIFESCAPE_SCREENLAYOUT, *PVBOXDISPIFESCAPE_SCREENLAYOUT;
425
426typedef struct VBOXSWAPCHAININFO
427{
428 VBOXDISP_KMHANDLE hSwapchainKm; /* in, NULL if new is being created */
429 VBOXDISP_UMHANDLE hSwapchainUm; /* in, UMD private data */
430 int32_t winHostID;
431 RECT Rect;
432 UINT u32Reserved;
433 UINT cAllocs;
434 D3DKMT_HANDLE ahAllocs[1];
435}VBOXSWAPCHAININFO, *PVBOXSWAPCHAININFO;
436typedef struct VBOXDISPIFESCAPE_SWAPCHAININFO
437{
438 VBOXDISPIFESCAPE EscapeHdr;
439 VBOXSWAPCHAININFO SwapchainInfo;
440} VBOXDISPIFESCAPE_SWAPCHAININFO, *PVBOXDISPIFESCAPE_SWAPCHAININFO;
441
442typedef struct VBOXVIDEOCM_UM_ALLOC
443{
444 VBOXDISP_KMHANDLE hAlloc;
445 uint32_t cbData;
446 uint64_t pvData;
447 uint64_t hSynch;
448 VBOXUHGSMI_BUFFER_TYPE_FLAGS fUhgsmiType;
449} VBOXVIDEOCM_UM_ALLOC, *PVBOXVIDEOCM_UM_ALLOC;
450
451typedef struct VBOXDISPIFESCAPE_UHGSMI_ALLOCATE
452{
453 VBOXDISPIFESCAPE EscapeHdr;
454 VBOXVIDEOCM_UM_ALLOC Alloc;
455} VBOXDISPIFESCAPE_UHGSMI_ALLOCATE, *PVBOXDISPIFESCAPE_UHGSMI_ALLOCATE;
456
457typedef struct VBOXDISPIFESCAPE_UHGSMI_DEALLOCATE
458{
459 VBOXDISPIFESCAPE EscapeHdr;
460 VBOXDISP_KMHANDLE hAlloc;
461} VBOXDISPIFESCAPE_UHGSMI_DEALLOCATE, *PVBOXDISPIFESCAPE_UHGSMI_DEALLOCATE;
462
463typedef struct VBOXWDDM_UHGSMI_BUFFER_UI_INFO_ESCAPE
464{
465 VBOXDISP_KMHANDLE hAlloc;
466 VBOXWDDM_UHGSMI_BUFFER_UI_SUBMIT_INFO Info;
467} VBOXWDDM_UHGSMI_BUFFER_UI_INFO_ESCAPE, *PVBOXWDDM_UHGSMI_BUFFER_UI_INFO_ESCAPE;
468
469typedef struct VBOXDISPIFESCAPE_UHGSMI_SUBMIT
470{
471 VBOXDISPIFESCAPE EscapeHdr;
472 VBOXWDDM_UHGSMI_BUFFER_UI_INFO_ESCAPE aBuffers[1];
473} VBOXDISPIFESCAPE_UHGSMI_SUBMIT, *PVBOXDISPIFESCAPE_UHGSMI_SUBMIT;
474
475typedef struct VBOXDISPIFESCAPE_SHRC_REF
476{
477 VBOXDISPIFESCAPE EscapeHdr;
478 uint64_t hAlloc;
479} VBOXDISPIFESCAPE_SHRC_REF, *PVBOXDISPIFESCAPE_SHRC_REF;
480
481typedef struct VBOXDISPIFESCAPE_SETALLOCHOSTID
482{
483 VBOXDISPIFESCAPE EscapeHdr;
484 int32_t rc;
485 uint32_t hostID;
486 uint64_t hAlloc;
487
488} VBOXDISPIFESCAPE_SETALLOCHOSTID, *PVBOXDISPIFESCAPE_SETALLOCHOSTID;
489
490typedef struct VBOXDISPIFESCAPE_CRHGSMICTLCON_CALL
491{
492 VBOXDISPIFESCAPE EscapeHdr;
493 VBoxGuestHGCMCallInfo CallInfo;
494} VBOXDISPIFESCAPE_CRHGSMICTLCON_CALL, *PVBOXDISPIFESCAPE_CRHGSMICTLCON_CALL;
495
496/* query info func */
497typedef struct VBOXWDDM_QI
498{
499 uint32_t u32Version;
500 uint32_t u32VBox3DCaps;
501 uint32_t cInfos;
502 VBOXVHWA_INFO aInfos[VBOX_VIDEO_MAX_SCREENS];
503} VBOXWDDM_QI;
504
505/* submit cmd func */
506DECLINLINE(D3DDDIFORMAT) vboxWddmFmtNoAlphaFormat(D3DDDIFORMAT enmFormat)
507{
508 switch (enmFormat)
509 {
510 case D3DDDIFMT_A8R8G8B8:
511 return D3DDDIFMT_X8R8G8B8;
512 case D3DDDIFMT_A1R5G5B5:
513 return D3DDDIFMT_X1R5G5B5;
514 case D3DDDIFMT_A4R4G4B4:
515 return D3DDDIFMT_X4R4G4B4;
516 case D3DDDIFMT_A8B8G8R8:
517 return D3DDDIFMT_X8B8G8R8;
518 default:
519 return enmFormat;
520 }
521}
522
523/* tooling */
524DECLINLINE(UINT) vboxWddmCalcBitsPerPixel(D3DDDIFORMAT enmFormat)
525{
526 switch (enmFormat)
527 {
528 case D3DDDIFMT_R8G8B8:
529 return 24;
530 case D3DDDIFMT_A8R8G8B8:
531 case D3DDDIFMT_X8R8G8B8:
532 return 32;
533 case D3DDDIFMT_R5G6B5:
534 case D3DDDIFMT_X1R5G5B5:
535 case D3DDDIFMT_A1R5G5B5:
536 case D3DDDIFMT_A4R4G4B4:
537 return 16;
538 case D3DDDIFMT_R3G3B2:
539 case D3DDDIFMT_A8:
540 return 8;
541 case D3DDDIFMT_A8R3G3B2:
542 case D3DDDIFMT_X4R4G4B4:
543 return 16;
544 case D3DDDIFMT_A2B10G10R10:
545 case D3DDDIFMT_A8B8G8R8:
546 case D3DDDIFMT_X8B8G8R8:
547 case D3DDDIFMT_G16R16:
548 case D3DDDIFMT_A2R10G10B10:
549 return 32;
550 case D3DDDIFMT_A16B16G16R16:
551 case D3DDDIFMT_A16B16G16R16F:
552 return 64;
553 case D3DDDIFMT_A8P8:
554 return 16;
555 case D3DDDIFMT_P8:
556 case D3DDDIFMT_L8:
557 return 8;
558 case D3DDDIFMT_L16:
559 case D3DDDIFMT_A8L8:
560 return 16;
561 case D3DDDIFMT_A4L4:
562 return 8;
563 case D3DDDIFMT_V8U8:
564 case D3DDDIFMT_L6V5U5:
565 return 16;
566 case D3DDDIFMT_X8L8V8U8:
567 case D3DDDIFMT_Q8W8V8U8:
568 case D3DDDIFMT_V16U16:
569 case D3DDDIFMT_W11V11U10:
570 case D3DDDIFMT_A2W10V10U10:
571 return 32;
572 case D3DDDIFMT_D16_LOCKABLE:
573 case D3DDDIFMT_D16:
574 case D3DDDIFMT_D15S1:
575 return 16;
576 case D3DDDIFMT_D32:
577 case D3DDDIFMT_D24S8:
578 case D3DDDIFMT_D24X8:
579 case D3DDDIFMT_D24X4S4:
580 case D3DDDIFMT_D24FS8:
581 case D3DDDIFMT_D32_LOCKABLE:
582 case D3DDDIFMT_D32F_LOCKABLE:
583 return 32;
584 case D3DDDIFMT_S8_LOCKABLE:
585 return 8;
586 case D3DDDIFMT_DXT1:
587 return 4;
588 case D3DDDIFMT_DXT2:
589 case D3DDDIFMT_DXT3:
590 case D3DDDIFMT_DXT4:
591 case D3DDDIFMT_DXT5:
592 case D3DDDIFMT_VERTEXDATA:
593 case D3DDDIFMT_INDEX16: /* <- yes, dx runtime treats it as such */
594 return 8;
595 case D3DDDIFMT_INDEX32:
596 return 8;
597 case D3DDDIFMT_R32F:
598 return 32;
599 case D3DDDIFMT_R16F:
600 return 16;
601 default:
602 AssertBreakpoint();
603 return 0;
604 }
605}
606
607DECLINLINE(uint32_t) vboxWddmFormatToFourcc(D3DDDIFORMAT enmFormat)
608{
609 uint32_t uFormat = (uint32_t)enmFormat;
610 /* assume that in case both four bytes are non-zero, this is a fourcc */
611 if ((uFormat & 0xff000000)
612 && (uFormat & 0x00ff0000)
613 && (uFormat & 0x0000ff00)
614 && (uFormat & 0x000000ff)
615 )
616 return uFormat;
617 return 0;
618}
619
620#define VBOXWDDM_ROUNDBOUND(_v, _b) (((_v) + ((_b) - 1)) & ~((_b) - 1))
621
622DECLINLINE(UINT) vboxWddmCalcOffXru(UINT w, D3DDDIFORMAT enmFormat)
623{
624 switch (enmFormat)
625 {
626 /* pitch for the DXT* (aka compressed) formats is the size in bytes of blocks that fill in an image width
627 * i.e. each block decompressed into 4 x 4 pixels, so we have ((Width + 3) / 4) blocks for Width.
628 * then each block has 64 bits (8 bytes) for DXT1 and 64+64 bits (16 bytes) for DXT2-DXT5, so.. : */
629 case D3DDDIFMT_DXT1:
630 {
631 UINT Pitch = (w + 3) / 4; /* <- pitch size in blocks */
632 Pitch *= 8; /* <- pitch size in bytes */
633 return Pitch;
634 }
635 case D3DDDIFMT_DXT2:
636 case D3DDDIFMT_DXT3:
637 case D3DDDIFMT_DXT4:
638 case D3DDDIFMT_DXT5:
639 {
640 UINT Pitch = (w + 3) / 4; /* <- pitch size in blocks */
641 Pitch *= 8; /* <- pitch size in bytes */
642 return Pitch;
643 }
644 default:
645 {
646 /* the default is just to calculate the pitch from bpp */
647 UINT bpp = vboxWddmCalcBitsPerPixel(enmFormat);
648 UINT Pitch = bpp * w;
649 /* pitch is now in bits, translate in bytes */
650 return VBOXWDDM_ROUNDBOUND(Pitch, 8) >> 3;
651 }
652 }
653}
654
655DECLINLINE(UINT) vboxWddmCalcOffXrd(UINT w, D3DDDIFORMAT enmFormat)
656{
657 switch (enmFormat)
658 {
659 /* pitch for the DXT* (aka compressed) formats is the size in bytes of blocks that fill in an image width
660 * i.e. each block decompressed into 4 x 4 pixels, so we have ((Width + 3) / 4) blocks for Width.
661 * then each block has 64 bits (8 bytes) for DXT1 and 64+64 bits (16 bytes) for DXT2-DXT5, so.. : */
662 case D3DDDIFMT_DXT1:
663 {
664 UINT Pitch = w / 4; /* <- pitch size in blocks */
665 Pitch *= 8; /* <- pitch size in bytes */
666 return Pitch;
667 }
668 case D3DDDIFMT_DXT2:
669 case D3DDDIFMT_DXT3:
670 case D3DDDIFMT_DXT4:
671 case D3DDDIFMT_DXT5:
672 {
673 UINT Pitch = w / 4; /* <- pitch size in blocks */
674 Pitch *= 16; /* <- pitch size in bytes */
675 return Pitch;
676 }
677 default:
678 {
679 /* the default is just to calculate the pitch from bpp */
680 UINT bpp = vboxWddmCalcBitsPerPixel(enmFormat);
681 UINT Pitch = bpp * w;
682 /* pitch is now in bits, translate in bytes */
683 return Pitch >> 3;
684 }
685 }
686}
687
688DECLINLINE(UINT) vboxWddmCalcHightPacking(D3DDDIFORMAT enmFormat)
689{
690 switch (enmFormat)
691 {
692 /* for the DXT* (aka compressed) formats each block is decompressed into 4 x 4 pixels,
693 * so packing is 4
694 */
695 case D3DDDIFMT_DXT1:
696 case D3DDDIFMT_DXT2:
697 case D3DDDIFMT_DXT3:
698 case D3DDDIFMT_DXT4:
699 case D3DDDIFMT_DXT5:
700 return 4;
701 default:
702 return 1;
703 }
704}
705
706DECLINLINE(UINT) vboxWddmCalcOffYru(UINT height, D3DDDIFORMAT enmFormat)
707{
708 UINT packing = vboxWddmCalcHightPacking(enmFormat);
709 /* round it up */
710 return (height + packing - 1) / packing;
711}
712
713DECLINLINE(UINT) vboxWddmCalcOffYrd(UINT height, D3DDDIFORMAT enmFormat)
714{
715 UINT packing = vboxWddmCalcHightPacking(enmFormat);
716 /* round it up */
717 return height / packing;
718}
719
720DECLINLINE(UINT) vboxWddmCalcPitch(UINT w, D3DDDIFORMAT enmFormat)
721{
722 return vboxWddmCalcOffXru(w, enmFormat);
723}
724
725DECLINLINE(UINT) vboxWddmCalcWidthForPitch(UINT Pitch, D3DDDIFORMAT enmFormat)
726{
727 switch (enmFormat)
728 {
729 /* pitch for the DXT* (aka compressed) formats is the size in bytes of blocks that fill in an image width
730 * i.e. each block decompressed into 4 x 4 pixels, so we have ((Width + 3) / 4) blocks for Width.
731 * then each block has 64 bits (8 bytes) for DXT1 and 64+64 bits (16 bytes) for DXT2-DXT5, so.. : */
732 case D3DDDIFMT_DXT1:
733 {
734 return (Pitch / 8) * 4;
735 }
736 case D3DDDIFMT_DXT2:
737 case D3DDDIFMT_DXT3:
738 case D3DDDIFMT_DXT4:
739 case D3DDDIFMT_DXT5:
740 {
741 return (Pitch / 16) * 4;;
742 }
743 default:
744 {
745 /* the default is just to calculate it from bpp */
746 UINT bpp = vboxWddmCalcBitsPerPixel(enmFormat);
747 return (Pitch << 3) / bpp;
748 }
749 }
750}
751
752DECLINLINE(UINT) vboxWddmCalcNumRows(UINT top, UINT bottom, D3DDDIFORMAT enmFormat)
753{
754 Assert(bottom > top);
755 top = top ? vboxWddmCalcOffYrd(top, enmFormat) : 0; /* <- just to optimize it a bit */
756 bottom = vboxWddmCalcOffYru(bottom, enmFormat);
757 return bottom - top;
758}
759
760DECLINLINE(UINT) vboxWddmCalcRowSize(UINT left, UINT right, D3DDDIFORMAT enmFormat)
761{
762 Assert(right > left);
763 left = left ? vboxWddmCalcOffXrd(left, enmFormat) : 0; /* <- just to optimize it a bit */
764 right = vboxWddmCalcOffXru(right, enmFormat);
765 return right - left;
766}
767
768DECLINLINE(UINT) vboxWddmCalcSize(UINT pitch, UINT height, D3DDDIFORMAT enmFormat)
769{
770 UINT cRows = vboxWddmCalcNumRows(0, height, enmFormat);
771 return pitch * cRows;
772}
773
774DECLINLINE(UINT) vboxWddmCalcOffXYrd(UINT x, UINT y, UINT pitch, D3DDDIFORMAT enmFormat)
775{
776 UINT offY = 0;
777 if (y)
778 offY = vboxWddmCalcSize(pitch, y, enmFormat);
779
780 return offY + vboxWddmCalcOffXrd(x, enmFormat);
781}
782
783#define VBOXWDDM_ARRAY_MAXELEMENTSU32(_t) ((uint32_t)((UINT32_MAX) / sizeof (_t)))
784#define VBOXWDDM_TRAILARRAY_MAXELEMENTSU32(_t, _af) ((uint32_t)(((~(0UL)) - (uint32_t)RT_OFFSETOF(_t, _af[0])) / RT_SIZEOFMEMB(_t, _af[0])))
785
786#endif /* #ifndef ___VBoxMPIf_h___ */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette