VirtualBox

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

Last change on this file since 62522 was 62522, checked in by vboxsync, 9 years ago

(C) 2016

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