VirtualBox

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

Last change on this file since 39524 was 39524, checked in by vboxsync, 13 years ago

wddm: DxgkDdiCreateAllocation fix

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