VirtualBox

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

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

wddm/3d: visible region tracking fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.8 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
47typedef struct VBOXWDDM_SURFACE_DESC
48{
49 UINT width;
50 UINT height;
51 D3DDDIFORMAT format;
52 UINT bpp;
53 UINT pitch;
54 UINT depth;
55 UINT slicePitch;
56 UINT cbSize;
57 D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId;
58 D3DDDI_RATIONAL RefreshRate;
59} VBOXWDDM_SURFACE_DESC, *PVBOXWDDM_SURFACE_DESC;
60
61typedef struct VBOXWDDM_ALLOCINFO
62{
63 VBOXWDDM_ALLOC_TYPE enmType;
64 D3DDDI_RESOURCEFLAGS fFlags;
65 VBOXWDDM_SURFACE_DESC SurfDesc;
66} VBOXWDDM_ALLOCINFO, *PVBOXWDDM_ALLOCINFO;
67
68/* this resource is OpenResource'd rather than CreateResource'd */
69#define VBOXWDDM_RESOURCE_F_OPENNED 0x00000001
70/* identifies this is a resource created with CreateResource, the VBOXWDDMDISP_RESOURCE::fRcFlags is valid */
71#define VBOXWDDM_RESOURCE_F_TYPE_GENERIC 0x00000002
72
73typedef struct VBOXWDDM_RC_DESC
74{
75 D3DDDI_RESOURCEFLAGS fFlags;
76 D3DDDIFORMAT enmFormat;
77 D3DDDI_POOL enmPool;
78 D3DDDIMULTISAMPLE_TYPE enmMultisampleType;
79 UINT MultisampleQuality;
80 UINT MipLevels;
81 UINT Fvf;
82 D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId;
83 D3DDDI_RATIONAL RefreshRate;
84 D3DDDI_ROTATION enmRotation;
85} VBOXWDDM_RC_DESC, *PVBOXWDDM_RC_DESC;
86
87typedef struct VBOXWDDM_RCINFO
88{
89 uint32_t fFlags;
90 VBOXWDDM_RC_DESC RcDesc;
91 uint32_t cAllocInfos;
92// VBOXWDDM_ALLOCINFO aAllocInfos[1];
93} VBOXWDDM_RCINFO, *PVBOXWDDM_RCINFO;
94
95#define VBOXVHWA_F_ENABLED 0x00000001
96#define VBOXVHWA_F_CKEY_DST 0x00000002
97#define VBOXVHWA_F_CKEY_SRC 0x00000004
98
99#define VBOXVHWA_MAX_FORMATS 8
100
101typedef struct VBOXVHWA_INFO
102{
103 uint32_t fFlags;
104 uint32_t cOverlaysSupported;
105 uint32_t cFormats;
106 D3DDDIFORMAT aFormats[VBOXVHWA_MAX_FORMATS];
107} VBOXVHWA_INFO;
108
109#define VBOXWDDM_OVERLAY_F_CKEY_DST 0x00000001
110#define VBOXWDDM_OVERLAY_F_CKEY_DSTRANGE 0x00000002
111#define VBOXWDDM_OVERLAY_F_CKEY_SRC 0x00000004
112#define VBOXWDDM_OVERLAY_F_CKEY_SRCRANGE 0x00000008
113#define VBOXWDDM_OVERLAY_F_BOB 0x00000010
114#define VBOXWDDM_OVERLAY_F_INTERLEAVED 0x00000020
115#define VBOXWDDM_OVERLAY_F_MIRROR_LR 0x00000040
116#define VBOXWDDM_OVERLAY_F_MIRROR_UD 0x00000080
117#define VBOXWDDM_OVERLAY_F_DEINTERLACED 0x00000100
118
119typedef struct VBOXWDDM_OVERLAY_DESC
120{
121 uint32_t fFlags;
122 UINT DstColorKeyLow;
123 UINT DstColorKeyHigh;
124 UINT SrcColorKeyLow;
125 UINT SrcColorKeyHigh;
126} VBOXWDDM_OVERLAY_DESC, *PVBOXWDDM_OVERLAY_DESC;
127
128/* the dirty rect info is valid */
129#define VBOXWDDM_DIRTYREGION_F_VALID 0x00000001
130#define VBOXWDDM_DIRTYREGION_F_RECT_VALID 0x00000002
131
132typedef struct VBOXWDDM_DIRTYREGION
133{
134 uint32_t fFlags; /* <-- see VBOXWDDM_DIRTYREGION_F_xxx flags above */
135 RECT Rect;
136} VBOXWDDM_DIRTYREGION, *PVBOXWDDM_DIRTYREGION;
137
138typedef struct VBOXWDDM_OVERLAY_INFO
139{
140 VBOXWDDM_OVERLAY_DESC OverlayDesc;
141 VBOXWDDM_DIRTYREGION DirtyRegion; /* <- the dirty region of the overlay surface */
142} VBOXWDDM_OVERLAY_INFO, *PVBOXWDDM_OVERLAY_INFO;
143
144typedef struct VBOXWDDM_OVERLAYFLIP_INFO
145{
146 VBOXWDDM_DIRTYREGION DirtyRegion; /* <- the dirty region of the overlay surface */
147} VBOXWDDM_OVERLAYFLIP_INFO, *PVBOXWDDM_OVERLAYFLIP_INFO;
148
149typedef struct VBOXWDDM_CREATECONTEXT_INFO
150{
151 /* interface version, i.e. 9 for d3d9, 8 for d3d8, etc. */
152 uint32_t u32IfVersion;
153 /* true if d3d false if ddraw */
154 uint32_t u32IsD3D;
155 /* we use uint64_t instead of HANDLE to ensure structure def is the same for both 32-bit and 64-bit
156 * since x64 kernel driver can be called by 32-bit UMD */
157 uint64_t hUmEvent;
158 /* info to be passed to UMD notification to identify the context */
159 uint64_t u64UmInfo;
160} VBOXWDDM_CREATECONTEXT_INFO, *PVBOXWDDM_CREATECONTEXT_INFO;
161
162
163typedef struct VBOXWDDM_RECTS_FLAFS
164{
165 union
166 {
167 struct
168 {
169 /* used only in conjunction with bSetVisibleRects.
170 * if set - VBOXWDDM_RECTS_INFO::aRects[0] contains view rectangle */
171 UINT bSetViewRect : 1;
172 /* sets visible regions */
173 UINT bSetVisibleRects : 1;
174 /* adds hidden regions */
175 UINT bAddHiddenRects : 1;
176 UINT Reserved : 29;
177 };
178 uint32_t Value;
179 };
180} VBOXWDDM_RECTS_FLAFS, *PVBOXWDDM_RECTS_FLAFS;
181
182typedef struct VBOXWDDM_RECTS_INFO
183{
184 uint32_t cRects;
185 RECT aRects[1];
186} VBOXWDDM_RECTS_INFO, *PVBOXWDDM_RECTS_INFO;
187
188#define VBOXWDDM_RECTS_INFO_SIZE4CRECTS(_cRects) (RT_OFFSETOF(VBOXWDDM_RECTS_INFO, aRects[(_cRects)]))
189#define VBOXWDDM_RECTS_INFO_SIZE(_pRects) (VBOXVIDEOCM_CMD_RECTS_SIZE4CRECTS((_pRects)->cRects))
190
191typedef struct VBOXVIDEOCM_CMD_HDR
192{
193 uint64_t u64UmData;
194 uint32_t cbCmd;
195 uint32_t u32CmdSpecific;
196}VBOXVIDEOCM_CMD_HDR, *PVBOXVIDEOCM_CMD_HDR;
197
198AssertCompile((sizeof (VBOXVIDEOCM_CMD_HDR) & 7) == 0);
199
200typedef struct VBOXVIDEOCM_CMD_RECTS
201{
202 VBOXWDDM_RECTS_FLAFS fFlags;
203 VBOXWDDM_RECTS_INFO RectsInfo;
204} VBOXVIDEOCM_CMD_RECTS, *PVBOXVIDEOCM_CMD_RECTS;
205
206#define VBOXVIDEOCM_CMD_RECTS_SIZE4CRECTS(_cRects) (RT_OFFSETOF(VBOXVIDEOCM_CMD_RECTS, RectsInfo.aRects[(_cRects)]))
207#define VBOXVIDEOCM_CMD_RECTS_SIZE(_pCmd) (VBOXVIDEOCM_CMD_RECTS_SIZE4CRECTS((_pCmd)->cRects))
208
209typedef struct VBOXWDDM_GETVBOXVIDEOCMCMD_HDR
210{
211 uint32_t cbCmdsReturned;
212 uint32_t cbRemainingCmds;
213 uint32_t cbRemainingFirstCmd;
214 uint32_t u32Reserved;
215} VBOXWDDM_GETVBOXVIDEOCMCMD_HDR, *PVBOXWDDM_GETVBOXVIDEOCMCMD_HDR;
216
217typedef struct VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD
218{
219 VBOXDISPIFESCAPE EscapeHdr;
220 VBOXWDDM_GETVBOXVIDEOCMCMD_HDR Hdr;
221} VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD, *PVBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD;
222
223AssertCompile((sizeof (VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD) & 7) == 0);
224AssertCompile(RT_OFFSETOF(VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD, EscapeHdr) == 0);
225
226/* query info func */
227typedef struct VBOXWDDM_QI
228{
229 uint32_t u32Version;
230 uint32_t cInfos;
231 VBOXVHWA_INFO aInfos[VBOX_VIDEO_MAX_SCREENS];
232} VBOXWDDM_QI;
233
234/* submit cmd func */
235
236/* tooling */
237DECLINLINE(UINT) vboxWddmCalcBitsPerPixel(D3DDDIFORMAT format)
238{
239 switch (format)
240 {
241 case D3DDDIFMT_R8G8B8:
242 return 24;
243 case D3DDDIFMT_A8R8G8B8:
244 case D3DDDIFMT_X8R8G8B8:
245 return 32;
246 case D3DDDIFMT_R5G6B5:
247 case D3DDDIFMT_X1R5G5B5:
248 case D3DDDIFMT_A1R5G5B5:
249 case D3DDDIFMT_A4R4G4B4:
250 return 16;
251 case D3DDDIFMT_R3G3B2:
252 case D3DDDIFMT_A8:
253 return 8;
254 case D3DDDIFMT_A8R3G3B2:
255 case D3DDDIFMT_X4R4G4B4:
256 return 16;
257 case D3DDDIFMT_A2B10G10R10:
258 case D3DDDIFMT_A8B8G8R8:
259 case D3DDDIFMT_X8B8G8R8:
260 case D3DDDIFMT_G16R16:
261 case D3DDDIFMT_A2R10G10B10:
262 return 32;
263 case D3DDDIFMT_A16B16G16R16:
264 return 64;
265 case D3DDDIFMT_A8P8:
266 return 16;
267 case D3DDDIFMT_P8:
268 return 8;
269 case D3DDDIFMT_D16_LOCKABLE:
270 case D3DDDIFMT_D16:
271 case D3DDDIFMT_D15S1:
272 return 16;
273 case D3DDDIFMT_D32:
274 case D3DDDIFMT_D24S8:
275 case D3DDDIFMT_D24X8:
276 case D3DDDIFMT_D24X4S4:
277 case D3DDDIFMT_D24FS8:
278 case D3DDDIFMT_D32_LOCKABLE:
279 return 32;
280 case D3DDDIFMT_S8_LOCKABLE:
281 return 8;
282 default:
283 AssertBreakpoint();
284 return 0;
285 }
286}
287
288DECLINLINE(uint32_t) vboxWddmFormatToFourcc(D3DDDIFORMAT format)
289{
290 uint32_t uFormat = (uint32_t)format;
291 /* assume that in case both four bytes are non-zero, this is a fourcc */
292 if ((format & 0xff000000)
293 && (format & 0x00ff0000)
294 && (format & 0x0000ff00)
295 && (format & 0x000000ff)
296 )
297 return uFormat;
298 return 0;
299}
300
301#define VBOXWDDM_ROUNDBOUND(_v, _b) (((_v) + ((_b) - 1)) & ~((_b) - 1))
302
303DECLINLINE(UINT) vboxWddmCalcPitch(UINT w, UINT bitsPerPixel)
304{
305 UINT Pitch = bitsPerPixel * w;
306 /* pitch is now in bits, translate in bytes */
307 return VBOXWDDM_ROUNDBOUND(Pitch, 8) >> 3;
308}
309
310DECLINLINE(void) vboxWddmRectUnite(RECT *pR, const RECT *pR2Unite)
311{
312 pR->left = RT_MIN(pR->left, pR2Unite->left);
313 pR->top = RT_MIN(pR->top, pR2Unite->top);
314 pR->right = RT_MAX(pR->right, pR2Unite->right);
315 pR->bottom = RT_MAX(pR->bottom, pR2Unite->bottom);
316}
317
318DECLINLINE(bool) vboxWddmRectIntersection(const RECT *a, const RECT *b, RECT *rect)
319{
320 Assert(a);
321 Assert(b);
322 Assert(rect);
323 rect->left = RT_MAX(a->left, b->left);
324 rect->right = RT_MIN(a->right, b->right);
325 rect->top = RT_MAX(a->top, b->top);
326 rect->bottom = RT_MIN(a->bottom, b->bottom);
327 return (rect->right>rect->left) && (rect->bottom>rect->top);
328}
329
330DECLINLINE(bool) vboxWddmRectIsEqual(const RECT *pRect1, const RECT *pRect2)
331{
332 Assert(pRect1);
333 Assert(pRect2);
334 if (pRect1->left != pRect2->left)
335 return false;
336 if (pRect1->top != pRect2->top)
337 return false;
338 if (pRect1->right != pRect2->right)
339 return false;
340 if (pRect1->bottom != pRect2->bottom)
341 return false;
342 return true;
343}
344
345DECLINLINE(bool) vboxWddmRectIsCoveres(const RECT *pRect, const RECT *pCovered)
346{
347 Assert(pRect);
348 Assert(pCovered);
349 if (pRect->left > pCovered->left)
350 return false;
351 if (pRect->top > pCovered->top)
352 return false;
353 if (pRect->right < pCovered->right)
354 return false;
355 if (pRect->bottom < pCovered->bottom)
356 return false;
357 return true;
358}
359
360DECLINLINE(void) vboxWddmDirtyRegionAddRect(PVBOXWDDM_DIRTYREGION pInfo, const RECT *pRect)
361{
362 if (!(pInfo->fFlags & VBOXWDDM_DIRTYREGION_F_VALID))
363 {
364 pInfo->fFlags = VBOXWDDM_DIRTYREGION_F_VALID;
365 if (pRect)
366 {
367 pInfo->fFlags |= VBOXWDDM_DIRTYREGION_F_RECT_VALID;
368 pInfo->Rect = *pRect;
369 }
370 }
371 else if (!!(pInfo->fFlags & VBOXWDDM_DIRTYREGION_F_RECT_VALID))
372 {
373 if (pRect)
374 vboxWddmRectUnite(&pInfo->Rect, pRect);
375 else
376 pInfo->fFlags &= ~VBOXWDDM_DIRTYREGION_F_RECT_VALID;
377 }
378}
379
380DECLINLINE(void) vboxWddmDirtyRegionUnite(PVBOXWDDM_DIRTYREGION pInfo, const PVBOXWDDM_DIRTYREGION pInfo2)
381{
382 if (pInfo2->fFlags & VBOXWDDM_DIRTYREGION_F_VALID)
383 {
384 if (pInfo2->fFlags & VBOXWDDM_DIRTYREGION_F_RECT_VALID)
385 vboxWddmDirtyRegionAddRect(pInfo, &pInfo2->Rect);
386 else
387 vboxWddmDirtyRegionAddRect(pInfo, NULL);
388 }
389}
390
391DECLINLINE(void) vboxWddmDirtyRegionClear(PVBOXWDDM_DIRTYREGION pInfo)
392{
393 pInfo->fFlags = 0;
394}
395
396#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