VirtualBox

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

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

wddm: fix 3d rendering for 3d-disabled, make wmp render correctly over d3d IF for 3d-disabled case to allow video detection

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