VirtualBox

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

Last change on this file since 63018 was 63018, checked in by vboxsync, 8 years ago

GA/NT/Graphics: warnings

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