VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoIf.h@ 30953

Last change on this file since 30953 was 30953, checked in by vboxsync, 14 years ago

wddm/2d: notify host on color fill FB update, bugfix

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 13.5 KB
Line 
1/** @file
2 * Contains base definitions of constants & structures used
3 * to control & perform rendering,
4 * such as DMA commands types, allocation types, escape codes, etc.
5 * used by both miniport & display drivers.
6 *
7 * The latter uses these and only these defs to communicate with the former
8 * by posting appropriate requests via D3D RT Krnl Svc accessing callbacks.
9 */
10/*
11 * Copyright (C) 2010 Oracle Corporation
12 *
13 * This file is part of VirtualBox Open Source Edition (OSE), as
14 * available from http://www.virtualbox.org. This file is free software;
15 * you can redistribute it and/or modify it under the terms of the GNU
16 * General Public License (GPL) as published by the Free Software
17 * Foundation, in version 2 as it comes in the "COPYING" file of the
18 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
19 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
20 */
21#ifndef ___VBoxVideoIf_h___
22#define ___VBoxVideoIf_h___
23
24#include <VBox/VBoxVideo.h>
25#include "../../../include/VBoxDisplay.h"
26
27#include <iprt/assert.h>
28
29
30/* @todo: implement a check to ensure display & miniport versions match.
31 * One would increase this whenever definitions in this file are changed */
32#define VBOXVIDEOIF_VERSION 4
33
34/* create allocation func */
35typedef enum
36{
37 VBOXWDDM_ALLOC_TYPE_UNEFINED = 0,
38 VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE,
39 VBOXWDDM_ALLOC_TYPE_STD_SHADOWSURFACE,
40 VBOXWDDM_ALLOC_TYPE_STD_STAGINGSURFACE,
41 /* this one is win 7-specific and hence unused for now */
42 VBOXWDDM_ALLOC_TYPE_STD_GDISURFACE
43 /* custom allocation types requested from user-mode d3d module will go here */
44 , VBOXWDDM_ALLOC_TYPE_UMD_RC_GENERIC
45} VBOXWDDM_ALLOC_TYPE;
46
47/* usage */
48typedef enum
49{
50 VBOXWDDM_ALLOCUSAGE_TYPE_UNEFINED = 0,
51 /* set for the allocation being primary */
52 VBOXWDDM_ALLOCUSAGE_TYPE_PRIMARY,
53} VBOXWDDM_ALLOCUSAGE_TYPE;
54
55typedef struct VBOXWDDM_SURFACE_DESC
56{
57 UINT width;
58 UINT height;
59 D3DDDIFORMAT format;
60 UINT bpp;
61 UINT pitch;
62 UINT depth;
63 UINT slicePitch;
64 UINT cbSize;
65 D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId;
66 D3DDDI_RATIONAL RefreshRate;
67} VBOXWDDM_SURFACE_DESC, *PVBOXWDDM_SURFACE_DESC;
68
69typedef struct VBOXWDDM_ALLOCINFO
70{
71 VBOXWDDM_ALLOC_TYPE enmType;
72 D3DDDI_RESOURCEFLAGS fFlags;
73 VBOXWDDM_SURFACE_DESC SurfDesc;
74} VBOXWDDM_ALLOCINFO, *PVBOXWDDM_ALLOCINFO;
75
76/* this resource is OpenResource'd rather than CreateResource'd */
77#define VBOXWDDM_RESOURCE_F_OPENNED 0x00000001
78/* identifies this is a resource created with CreateResource, the VBOXWDDMDISP_RESOURCE::fRcFlags is valid */
79#define VBOXWDDM_RESOURCE_F_TYPE_GENERIC 0x00000002
80
81typedef struct VBOXWDDM_RC_DESC
82{
83 D3DDDI_RESOURCEFLAGS fFlags;
84 D3DDDIFORMAT enmFormat;
85 D3DDDI_POOL enmPool;
86 D3DDDIMULTISAMPLE_TYPE enmMultisampleType;
87 UINT MultisampleQuality;
88 UINT MipLevels;
89 UINT Fvf;
90 D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId;
91 D3DDDI_RATIONAL RefreshRate;
92 D3DDDI_ROTATION enmRotation;
93} VBOXWDDM_RC_DESC, *PVBOXWDDM_RC_DESC;
94
95typedef struct VBOXWDDM_RCINFO
96{
97 uint32_t fFlags;
98 VBOXWDDM_RC_DESC RcDesc;
99 uint32_t cAllocInfos;
100// VBOXWDDM_ALLOCINFO aAllocInfos[1];
101} VBOXWDDM_RCINFO, *PVBOXWDDM_RCINFO;
102
103#define VBOXVHWA_F_ENABLED 0x00000001
104#define VBOXVHWA_F_CKEY_DST 0x00000002
105#define VBOXVHWA_F_CKEY_SRC 0x00000004
106
107#define VBOXVHWA_MAX_FORMATS 8
108
109typedef struct VBOXVHWA_INFO
110{
111 uint32_t fFlags;
112 uint32_t cOverlaysSupported;
113 uint32_t cFormats;
114 D3DDDIFORMAT aFormats[VBOXVHWA_MAX_FORMATS];
115} VBOXVHWA_INFO;
116
117#define VBOXWDDM_OVERLAY_F_CKEY_DST 0x00000001
118#define VBOXWDDM_OVERLAY_F_CKEY_DSTRANGE 0x00000002
119#define VBOXWDDM_OVERLAY_F_CKEY_SRC 0x00000004
120#define VBOXWDDM_OVERLAY_F_CKEY_SRCRANGE 0x00000008
121#define VBOXWDDM_OVERLAY_F_BOB 0x00000010
122#define VBOXWDDM_OVERLAY_F_INTERLEAVED 0x00000020
123#define VBOXWDDM_OVERLAY_F_MIRROR_LR 0x00000040
124#define VBOXWDDM_OVERLAY_F_MIRROR_UD 0x00000080
125#define VBOXWDDM_OVERLAY_F_DEINTERLACED 0x00000100
126
127typedef struct VBOXWDDM_OVERLAY_DESC
128{
129 uint32_t fFlags;
130 UINT DstColorKeyLow;
131 UINT DstColorKeyHigh;
132 UINT SrcColorKeyLow;
133 UINT SrcColorKeyHigh;
134} VBOXWDDM_OVERLAY_DESC, *PVBOXWDDM_OVERLAY_DESC;
135
136/* the dirty rect info is valid */
137#define VBOXWDDM_DIRTYREGION_F_VALID 0x00000001
138#define VBOXWDDM_DIRTYREGION_F_RECT_VALID 0x00000002
139
140typedef struct VBOXWDDM_DIRTYREGION
141{
142 uint32_t fFlags; /* <-- see VBOXWDDM_DIRTYREGION_F_xxx flags above */
143 RECT Rect;
144} VBOXWDDM_DIRTYREGION, *PVBOXWDDM_DIRTYREGION;
145
146typedef struct VBOXWDDM_OVERLAY_INFO
147{
148 VBOXWDDM_OVERLAY_DESC OverlayDesc;
149 VBOXWDDM_DIRTYREGION DirtyRegion; /* <- the dirty region of the overlay surface */
150} VBOXWDDM_OVERLAY_INFO, *PVBOXWDDM_OVERLAY_INFO;
151
152typedef struct VBOXWDDM_OVERLAYFLIP_INFO
153{
154 VBOXWDDM_DIRTYREGION DirtyRegion; /* <- the dirty region of the overlay surface */
155} VBOXWDDM_OVERLAYFLIP_INFO, *PVBOXWDDM_OVERLAYFLIP_INFO;
156
157typedef struct VBOXWDDM_CREATECONTEXT_INFO
158{
159 /* interface version, i.e. 9 for d3d9, 8 for d3d8, etc. */
160 uint32_t u32IfVersion;
161 /* true if d3d false if ddraw */
162 uint32_t u32IsD3D;
163 /* we use uint64_t instead of HANDLE to ensure structure def is the same for both 32-bit and 64-bit
164 * since x64 kernel driver can be called by 32-bit UMD */
165 uint64_t hUmEvent;
166 /* info to be passed to UMD notification to identify the context */
167 uint64_t u64UmInfo;
168} VBOXWDDM_CREATECONTEXT_INFO, *PVBOXWDDM_CREATECONTEXT_INFO;
169
170
171typedef struct VBOXWDDM_RECTS_FLAFS
172{
173 union
174 {
175 struct
176 {
177 /* used only in conjunction with bSetVisibleRects.
178 * if set - VBOXWDDM_RECTS_INFO::aRects[0] contains view rectangle */
179 UINT bSetViewRect : 1;
180 /* sets visible regions */
181 UINT bSetVisibleRects : 1;
182 /* adds hidden regions */
183 UINT bAddHiddenRects : 1;
184 UINT Reserved : 29;
185 };
186 uint32_t Value;
187 };
188} VBOXWDDM_RECTS_FLAFS, *PVBOXWDDM_RECTS_FLAFS;
189
190typedef struct VBOXWDDM_RECTS_INFO
191{
192 uint32_t cRects;
193 RECT aRects[1];
194} VBOXWDDM_RECTS_INFO, *PVBOXWDDM_RECTS_INFO;
195
196#define VBOXWDDM_RECTS_INFO_SIZE4CRECTS(_cRects) (RT_OFFSETOF(VBOXWDDM_RECTS_INFO, aRects[(_cRects)]))
197#define VBOXWDDM_RECTS_INFO_SIZE(_pRects) (VBOXVIDEOCM_CMD_RECTS_SIZE4CRECTS((_pRects)->cRects))
198
199typedef struct VBOXVIDEOCM_CMD_HDR
200{
201 uint64_t u64UmData;
202 uint32_t cbCmd;
203 uint32_t u32CmdSpecific;
204}VBOXVIDEOCM_CMD_HDR, *PVBOXVIDEOCM_CMD_HDR;
205
206AssertCompile((sizeof (VBOXVIDEOCM_CMD_HDR) & 7) == 0);
207
208typedef struct VBOXVIDEOCM_CMD_RECTS
209{
210 VBOXWDDM_RECTS_FLAFS fFlags;
211 VBOXWDDM_RECTS_INFO RectsInfo;
212} VBOXVIDEOCM_CMD_RECTS, *PVBOXVIDEOCM_CMD_RECTS;
213
214#define VBOXVIDEOCM_CMD_RECTS_SIZE4CRECTS(_cRects) (RT_OFFSETOF(VBOXVIDEOCM_CMD_RECTS, RectsInfo.aRects[(_cRects)]))
215#define VBOXVIDEOCM_CMD_RECTS_SIZE(_pCmd) (VBOXVIDEOCM_CMD_RECTS_SIZE4CRECTS((_pCmd)->cRects))
216
217typedef struct VBOXWDDM_GETVBOXVIDEOCMCMD_HDR
218{
219 uint32_t cbCmdsReturned;
220 uint32_t cbRemainingCmds;
221 uint32_t cbRemainingFirstCmd;
222 uint32_t u32Reserved;
223} VBOXWDDM_GETVBOXVIDEOCMCMD_HDR, *PVBOXWDDM_GETVBOXVIDEOCMCMD_HDR;
224
225typedef struct VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD
226{
227 VBOXDISPIFESCAPE EscapeHdr;
228 VBOXWDDM_GETVBOXVIDEOCMCMD_HDR Hdr;
229} VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD, *PVBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD;
230
231AssertCompile((sizeof (VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD) & 7) == 0);
232AssertCompile(RT_OFFSETOF(VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD, EscapeHdr) == 0);
233
234typedef struct VBOXDISPIFESCAPE_DBGPRINT
235{
236 VBOXDISPIFESCAPE EscapeHdr;
237 /* null-terminated string to DbgPrint including \0 */
238 char aStringBuf[1];
239} VBOXDISPIFESCAPE_DBGPRINT, *PVBOXDISPIFESCAPE_DBGPRINT;
240AssertCompile(RT_OFFSETOF(VBOXDISPIFESCAPE_DBGPRINT, EscapeHdr) == 0);
241
242/* query info func */
243typedef struct VBOXWDDM_QI
244{
245 uint32_t u32Version;
246 uint32_t cInfos;
247 VBOXVHWA_INFO aInfos[VBOX_VIDEO_MAX_SCREENS];
248} VBOXWDDM_QI;
249
250/* submit cmd func */
251
252/* tooling */
253DECLINLINE(UINT) vboxWddmCalcBitsPerPixel(D3DDDIFORMAT format)
254{
255 switch (format)
256 {
257 case D3DDDIFMT_R8G8B8:
258 return 24;
259 case D3DDDIFMT_A8R8G8B8:
260 case D3DDDIFMT_X8R8G8B8:
261 return 32;
262 case D3DDDIFMT_R5G6B5:
263 case D3DDDIFMT_X1R5G5B5:
264 case D3DDDIFMT_A1R5G5B5:
265 case D3DDDIFMT_A4R4G4B4:
266 return 16;
267 case D3DDDIFMT_R3G3B2:
268 case D3DDDIFMT_A8:
269 return 8;
270 case D3DDDIFMT_A8R3G3B2:
271 case D3DDDIFMT_X4R4G4B4:
272 return 16;
273 case D3DDDIFMT_A2B10G10R10:
274 case D3DDDIFMT_A8B8G8R8:
275 case D3DDDIFMT_X8B8G8R8:
276 case D3DDDIFMT_G16R16:
277 case D3DDDIFMT_A2R10G10B10:
278 return 32;
279 case D3DDDIFMT_A16B16G16R16:
280 return 64;
281 case D3DDDIFMT_A8P8:
282 return 16;
283 case D3DDDIFMT_P8:
284 return 8;
285 case D3DDDIFMT_D16_LOCKABLE:
286 case D3DDDIFMT_D16:
287 case D3DDDIFMT_D15S1:
288 return 16;
289 case D3DDDIFMT_D32:
290 case D3DDDIFMT_D24S8:
291 case D3DDDIFMT_D24X8:
292 case D3DDDIFMT_D24X4S4:
293 case D3DDDIFMT_D24FS8:
294 case D3DDDIFMT_D32_LOCKABLE:
295 return 32;
296 case D3DDDIFMT_S8_LOCKABLE:
297 return 8;
298 default:
299 AssertBreakpoint();
300 return 0;
301 }
302}
303
304DECLINLINE(uint32_t) vboxWddmFormatToFourcc(D3DDDIFORMAT format)
305{
306 uint32_t uFormat = (uint32_t)format;
307 /* assume that in case both four bytes are non-zero, this is a fourcc */
308 if ((format & 0xff000000)
309 && (format & 0x00ff0000)
310 && (format & 0x0000ff00)
311 && (format & 0x000000ff)
312 )
313 return uFormat;
314 return 0;
315}
316
317#define VBOXWDDM_ROUNDBOUND(_v, _b) (((_v) + ((_b) - 1)) & ~((_b) - 1))
318
319DECLINLINE(UINT) vboxWddmCalcPitch(UINT w, UINT bitsPerPixel)
320{
321 UINT Pitch = bitsPerPixel * w;
322 /* pitch is now in bits, translate in bytes */
323 return VBOXWDDM_ROUNDBOUND(Pitch, 8) >> 3;
324}
325
326DECLINLINE(void) vboxWddmRectUnite(RECT *pR, const RECT *pR2Unite)
327{
328 pR->left = RT_MIN(pR->left, pR2Unite->left);
329 pR->top = RT_MIN(pR->top, pR2Unite->top);
330 pR->right = RT_MAX(pR->right, pR2Unite->right);
331 pR->bottom = RT_MAX(pR->bottom, pR2Unite->bottom);
332}
333
334DECLINLINE(bool) vboxWddmRectIntersection(const RECT *a, const RECT *b, RECT *rect)
335{
336 Assert(a);
337 Assert(b);
338 Assert(rect);
339 rect->left = RT_MAX(a->left, b->left);
340 rect->right = RT_MIN(a->right, b->right);
341 rect->top = RT_MAX(a->top, b->top);
342 rect->bottom = RT_MIN(a->bottom, b->bottom);
343 return (rect->right>rect->left) && (rect->bottom>rect->top);
344}
345
346DECLINLINE(bool) vboxWddmRectIsEqual(const RECT *pRect1, const RECT *pRect2)
347{
348 Assert(pRect1);
349 Assert(pRect2);
350 if (pRect1->left != pRect2->left)
351 return false;
352 if (pRect1->top != pRect2->top)
353 return false;
354 if (pRect1->right != pRect2->right)
355 return false;
356 if (pRect1->bottom != pRect2->bottom)
357 return false;
358 return true;
359}
360
361DECLINLINE(bool) vboxWddmRectIsCoveres(const RECT *pRect, const RECT *pCovered)
362{
363 Assert(pRect);
364 Assert(pCovered);
365 if (pRect->left > pCovered->left)
366 return false;
367 if (pRect->top > pCovered->top)
368 return false;
369 if (pRect->right < pCovered->right)
370 return false;
371 if (pRect->bottom < pCovered->bottom)
372 return false;
373 return true;
374}
375
376DECLINLINE(bool) vboxWddmRectIsEmpty(RECT * pRect)
377{
378 return pRect->left == pRect->right-1 && pRect->top == pRect->bottom-1;
379}
380
381DECLINLINE(bool) vboxWddmRectIsIntersect(RECT * pRect1, RECT * pRect2)
382{
383 return !((pRect1->left < pRect2->left && pRect1->right < pRect2->left)
384 || (pRect2->left < pRect1->left && pRect2->right < pRect1->left)
385 || (pRect1->top < pRect2->top && pRect1->bottom < pRect2->top)
386 || (pRect2->top < pRect1->top && pRect2->bottom < pRect1->top));
387}
388
389DECLINLINE(bool) vboxWddmRectIsInclude(RECT * pRect1, RECT * pRect2)
390{
391 return ((pRect1->left <= pRect2->left && pRect1->right >= pRect2->right)
392 && (pRect1->top <= pRect2->top && pRect1->bottom >= pRect2->bottom));
393}
394
395DECLINLINE(void) vboxWddmRectUnited(RECT * pDst, const RECT * pRect1, const RECT * pRect2)
396{
397 pDst->left = RT_MIN(pRect1->left, pRect2->left);
398 pDst->top = RT_MIN(pRect1->top, pRect2->top);
399 pDst->right = RT_MAX(pRect1->right, pRect2->right);
400 pDst->bottom = RT_MAX(pRect1->bottom, pRect2->bottom);
401}
402
403DECLINLINE(void) vboxWddmRectTranslate(RECT * pRect, int x, int y)
404{
405 pRect->left += x;
406 pRect->top += y;
407 pRect->right += x;
408 pRect->bottom += y;
409}
410
411DECLINLINE(void) vboxWddmDirtyRegionAddRect(PVBOXWDDM_DIRTYREGION pInfo, const RECT *pRect)
412{
413 if (!(pInfo->fFlags & VBOXWDDM_DIRTYREGION_F_VALID))
414 {
415 pInfo->fFlags = VBOXWDDM_DIRTYREGION_F_VALID;
416 if (pRect)
417 {
418 pInfo->fFlags |= VBOXWDDM_DIRTYREGION_F_RECT_VALID;
419 pInfo->Rect = *pRect;
420 }
421 }
422 else if (!!(pInfo->fFlags & VBOXWDDM_DIRTYREGION_F_RECT_VALID))
423 {
424 if (pRect)
425 vboxWddmRectUnite(&pInfo->Rect, pRect);
426 else
427 pInfo->fFlags &= ~VBOXWDDM_DIRTYREGION_F_RECT_VALID;
428 }
429}
430
431DECLINLINE(void) vboxWddmDirtyRegionUnite(PVBOXWDDM_DIRTYREGION pInfo, const PVBOXWDDM_DIRTYREGION pInfo2)
432{
433 if (pInfo2->fFlags & VBOXWDDM_DIRTYREGION_F_VALID)
434 {
435 if (pInfo2->fFlags & VBOXWDDM_DIRTYREGION_F_RECT_VALID)
436 vboxWddmDirtyRegionAddRect(pInfo, &pInfo2->Rect);
437 else
438 vboxWddmDirtyRegionAddRect(pInfo, NULL);
439 }
440}
441
442DECLINLINE(void) vboxWddmDirtyRegionClear(PVBOXWDDM_DIRTYREGION pInfo)
443{
444 pInfo->fFlags = 0;
445}
446
447#endif /* #ifndef ___VBoxVideoIf_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