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 |
|
---|
26 | /* @todo: implement a check to ensure display & miniport versions match.
|
---|
27 | * One would increase this whenever definitions in this file are changed */
|
---|
28 | #define VBOXVIDEOIF_VERSION 3
|
---|
29 |
|
---|
30 | /* create allocation func */
|
---|
31 | typedef enum
|
---|
32 | {
|
---|
33 | VBOXWDDM_ALLOC_TYPE_UNEFINED = 0,
|
---|
34 | VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE,
|
---|
35 | VBOXWDDM_ALLOC_TYPE_STD_SHADOWSURFACE,
|
---|
36 | VBOXWDDM_ALLOC_TYPE_STD_STAGINGSURFACE,
|
---|
37 | /* this one is win 7-specific and hence unused for now */
|
---|
38 | VBOXWDDM_ALLOC_TYPE_STD_GDISURFACE
|
---|
39 | /* custom allocation types requested from user-mode d3d module will go here */
|
---|
40 | , VBOXWDDM_ALLOC_TYPE_UMD_RC_GENERIC
|
---|
41 | } VBOXWDDM_ALLOC_TYPE;
|
---|
42 |
|
---|
43 | typedef struct VBOXWDDM_SURFACE_DESC
|
---|
44 | {
|
---|
45 | UINT width;
|
---|
46 | UINT height;
|
---|
47 | D3DDDIFORMAT format;
|
---|
48 | UINT bpp;
|
---|
49 | UINT pitch;
|
---|
50 | UINT depth;
|
---|
51 | UINT slicePitch;
|
---|
52 | UINT cbSize;
|
---|
53 | D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId;
|
---|
54 | D3DDDI_RATIONAL RefreshRate;
|
---|
55 | } VBOXWDDM_SURFACE_DESC, *PVBOXWDDM_SURFACE_DESC;
|
---|
56 |
|
---|
57 | typedef struct VBOXWDDM_ALLOCINFO
|
---|
58 | {
|
---|
59 | VBOXWDDM_ALLOC_TYPE enmType;
|
---|
60 | D3DDDI_RESOURCEFLAGS fFlags;
|
---|
61 | VBOXWDDM_SURFACE_DESC SurfDesc;
|
---|
62 | } VBOXWDDM_ALLOCINFO, *PVBOXWDDM_ALLOCINFO;
|
---|
63 |
|
---|
64 | /* this resource is OpenResource'd rather than CreateResource'd */
|
---|
65 | #define VBOXWDDM_RESOURCE_F_OPENNED 0x00000001
|
---|
66 | /* identifies this is a resource created with CreateResource, the VBOXWDDMDISP_RESOURCE::fRcFlags is valid */
|
---|
67 | #define VBOXWDDM_RESOURCE_F_TYPE_GENERIC 0x00000002
|
---|
68 |
|
---|
69 | typedef struct VBOXWDDM_RC_DESC
|
---|
70 | {
|
---|
71 | D3DDDI_RESOURCEFLAGS fFlags;
|
---|
72 | D3DDDIFORMAT enmFormat;
|
---|
73 | D3DDDI_POOL enmPool;
|
---|
74 | D3DDDIMULTISAMPLE_TYPE enmMultisampleType;
|
---|
75 | UINT MultisampleQuality;
|
---|
76 | UINT MipLevels;
|
---|
77 | UINT Fvf;
|
---|
78 | D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId;
|
---|
79 | D3DDDI_RATIONAL RefreshRate;
|
---|
80 | D3DDDI_ROTATION enmRotation;
|
---|
81 | } VBOXWDDM_RC_DESC, *PVBOXWDDM_RC_DESC;
|
---|
82 |
|
---|
83 | typedef struct VBOXWDDM_RCINFO
|
---|
84 | {
|
---|
85 | uint32_t fFlags;
|
---|
86 | VBOXWDDM_RC_DESC RcDesc;
|
---|
87 | uint32_t cAllocInfos;
|
---|
88 | // VBOXWDDM_ALLOCINFO aAllocInfos[1];
|
---|
89 | } VBOXWDDM_RCINFO, *PVBOXWDDM_RCINFO;
|
---|
90 |
|
---|
91 | #define VBOXVHWA_F_ENABLED 0x00000001
|
---|
92 | #define VBOXVHWA_F_CKEY_DST 0x00000002
|
---|
93 | #define VBOXVHWA_F_CKEY_SRC 0x00000004
|
---|
94 |
|
---|
95 | #define VBOXVHWA_MAX_FORMATS 8
|
---|
96 |
|
---|
97 | typedef struct VBOXVHWA_INFO
|
---|
98 | {
|
---|
99 | uint32_t fFlags;
|
---|
100 | uint32_t cOverlaysSupported;
|
---|
101 | uint32_t cFormats;
|
---|
102 | D3DDDIFORMAT aFormats[VBOXVHWA_MAX_FORMATS];
|
---|
103 | } VBOXVHWA_INFO;
|
---|
104 |
|
---|
105 | #define VBOXWDDM_OVERLAY_F_CKEY_DST 0x00000001
|
---|
106 | #define VBOXWDDM_OVERLAY_F_CKEY_DSTRANGE 0x00000002
|
---|
107 | #define VBOXWDDM_OVERLAY_F_CKEY_SRC 0x00000004
|
---|
108 | #define VBOXWDDM_OVERLAY_F_CKEY_SRCRANGE 0x00000008
|
---|
109 | #define VBOXWDDM_OVERLAY_F_BOB 0x00000010
|
---|
110 | #define VBOXWDDM_OVERLAY_F_INTERLEAVED 0x00000020
|
---|
111 | #define VBOXWDDM_OVERLAY_F_MIRROR_LR 0x00000040
|
---|
112 | #define VBOXWDDM_OVERLAY_F_MIRROR_UD 0x00000080
|
---|
113 | #define VBOXWDDM_OVERLAY_F_DEINTERLACED 0x00000100
|
---|
114 |
|
---|
115 | typedef struct VBOXWDDM_OVERLAY_DESC
|
---|
116 | {
|
---|
117 | uint32_t fFlags;
|
---|
118 | UINT DstColorKeyLow;
|
---|
119 | UINT DstColorKeyHigh;
|
---|
120 | UINT SrcColorKeyLow;
|
---|
121 | UINT SrcColorKeyHigh;
|
---|
122 | } VBOXWDDM_OVERLAY_DESC, *PVBOXWDDM_OVERLAY_DESC;
|
---|
123 |
|
---|
124 | /* the dirty rect info is valid */
|
---|
125 | #define VBOXWDDM_DIRTYREGION_F_VALID 0x00000001
|
---|
126 | #define VBOXWDDM_DIRTYREGION_F_RECT_VALID 0x00000002
|
---|
127 |
|
---|
128 | typedef struct VBOXWDDM_DIRTYREGION
|
---|
129 | {
|
---|
130 | uint32_t fFlags; /* <-- see VBOXWDDM_DIRTYREGION_F_xxx flags above */
|
---|
131 | RECT Rect;
|
---|
132 | } VBOXWDDM_DIRTYREGION, *PVBOXWDDM_DIRTYREGION;
|
---|
133 |
|
---|
134 | typedef struct VBOXWDDM_OVERLAY_INFO
|
---|
135 | {
|
---|
136 | VBOXWDDM_OVERLAY_DESC OverlayDesc;
|
---|
137 | VBOXWDDM_DIRTYREGION DirtyRegion; /* <- the dirty region of the overlay surface */
|
---|
138 | } VBOXWDDM_OVERLAY_INFO, *PVBOXWDDM_OVERLAY_INFO;
|
---|
139 |
|
---|
140 | typedef struct VBOXWDDM_OVERLAYFLIP_INFO
|
---|
141 | {
|
---|
142 | VBOXWDDM_DIRTYREGION DirtyRegion; /* <- the dirty region of the overlay surface */
|
---|
143 | } VBOXWDDM_OVERLAYFLIP_INFO, *PVBOXWDDM_OVERLAYFLIP_INFO;
|
---|
144 |
|
---|
145 | typedef struct VBOXWDDM_CREATECONTEXT_INFO
|
---|
146 | {
|
---|
147 | /* we use uint64_t instead of HANDLE to ensure structure def is the same for both 32-bit and 64-bit
|
---|
148 | * since x64 kernel driver can be called by 32-bit UMD */
|
---|
149 | uint64_t hUmEvent;
|
---|
150 | /* info to be passed to UMD notification to identify the context */
|
---|
151 | uint64_t u64UmInfo;
|
---|
152 | } VBOXWDDM_CREATECONTEXT_INFO, *PVBOXWDDM_CREATECONTEXT_INFO;
|
---|
153 |
|
---|
154 |
|
---|
155 | typedef struct VBOXWDDM_RECTS_FLAFS
|
---|
156 | {
|
---|
157 | union
|
---|
158 | {
|
---|
159 | struct
|
---|
160 | {
|
---|
161 | UINT bPositionRect : 1;
|
---|
162 | UINT bAddVisibleRects : 1;
|
---|
163 | UINT bAddHiddenRects : 1;
|
---|
164 | UINT Reserved : 29;
|
---|
165 | };
|
---|
166 | uint32_t Value;
|
---|
167 | };
|
---|
168 | } VBOXWDDM_RECTS_FLAFS, *PVBOXWDDM_RECTS_FLAFS;
|
---|
169 |
|
---|
170 | typedef struct VBOXWDDM_RECTS_INFO
|
---|
171 | {
|
---|
172 | uint32_t cRects;
|
---|
173 | RECT aRects[1];
|
---|
174 | } VBOXWDDM_RECTS_INFO, *PVBOXWDDM_RECTS_INFO;
|
---|
175 |
|
---|
176 | #define VBOXWDDM_RECTS_INFO_SIZE4CRECTS(_cRects) (RT_OFFSETOF(VBOXWDDM_RECTS_INFO, aRects[(_cRects)]))
|
---|
177 | #define VBOXWDDM_RECTS_INFO_SIZE(_pRects) (VBOXVIDEOCM_CMD_RECTS_SIZE4CRECTS((_pRects)->cRects))
|
---|
178 |
|
---|
179 | typedef struct VBOXVIDEOCM_CMD_HDR
|
---|
180 | {
|
---|
181 | uint64_t u64UmData;
|
---|
182 | uint32_t cbCmd;
|
---|
183 | uint32_t u32CmdSpecific;
|
---|
184 | }VBOXVIDEOCM_CMD_HDR, *PVBOXVIDEOCM_CMD_HDR;
|
---|
185 |
|
---|
186 | typedef struct VBOXVIDEOCM_CMD_RECTS
|
---|
187 | {
|
---|
188 | VBOXWDDM_RECTS_FLAFS fFlags;
|
---|
189 | VBOXWDDM_RECTS_INFO RectsInfo;
|
---|
190 | } VBOXVIDEOCM_CMD_RECTS, *PVBOXVIDEOCM_CMD_RECTS;
|
---|
191 |
|
---|
192 | #define VBOXVIDEOCM_CMD_RECTS_SIZE4CRECTS(_cRects) (RT_OFFSETOF(VBOXVIDEOCM_CMD_RECTS, RectsInfo.aRects[(_cRects)]))
|
---|
193 | #define VBOXVIDEOCM_CMD_RECTS_SIZE(_pCmd) (VBOXVIDEOCM_CMD_RECTS_SIZE4CRECTS((_pCmd)->cRects))
|
---|
194 |
|
---|
195 | typedef struct VBOXWDDM_GETVBOXVIDEOCMCMD_HDR
|
---|
196 | {
|
---|
197 | uint32_t cbCmdsReturned;
|
---|
198 | uint32_t cbRemainingCmds;
|
---|
199 | uint32_t cbRemainingFirstCmd;
|
---|
200 | uint32_t u32Reserved;
|
---|
201 | } VBOXWDDM_GETVBOXVIDEOCMCMD_HDR, *PVBOXWDDM_GETVBOXVIDEOCMCMD_HDR;
|
---|
202 |
|
---|
203 | #define VBOXWDDM_GETVBOXVIDEOCMCMD_DATA_OFFSET() ((sizeof (VBOXWDDM_GETVBOXVIDEOCMCMD_HDR) + 7) & ~7)
|
---|
204 | #define VBOXWDDM_GETVBOXVIDEOCMCMD_DATA(_pHead, _t) ( (_t*)(((uint8_t*)(_pHead)) + VBOXWDDM_GETVBOXVIDEOCMCMD_DATA_OFFSET()))
|
---|
205 | #define VBOXWDDM_GETVBOXVIDEOCMCMD_DATA_SIZE(_s) ( (_s) < VBOXWDDM_GETVBOXVIDEOCMCMD_DATA_OFFSET() ? 0 : (_s) - VBOXWDDM_GETVBOXVIDEOCMCMD_DATA_OFFSET() )
|
---|
206 | #define VBOXWDDM_GETVBOXVIDEOCMCMD_SIZE(_cbData) ((_cbData) ? VBOXWDDM_GETVBOXVIDEOCMCMD_DATA_OFFSET() + (_cbData) : sizeof (VBOXWDDM_GETVBOXVIDEOCMCMD_HDR))
|
---|
207 |
|
---|
208 | /* query info func */
|
---|
209 | typedef struct VBOXWDDM_QI
|
---|
210 | {
|
---|
211 | uint32_t u32Version;
|
---|
212 | uint32_t cInfos;
|
---|
213 | VBOXVHWA_INFO aInfos[VBOX_VIDEO_MAX_SCREENS];
|
---|
214 | } VBOXWDDM_QI;
|
---|
215 |
|
---|
216 | /* submit cmd func */
|
---|
217 |
|
---|
218 | /* tooling */
|
---|
219 | DECLINLINE(UINT) vboxWddmCalcBitsPerPixel(D3DDDIFORMAT format)
|
---|
220 | {
|
---|
221 | switch (format)
|
---|
222 | {
|
---|
223 | case D3DDDIFMT_R8G8B8:
|
---|
224 | return 24;
|
---|
225 | case D3DDDIFMT_A8R8G8B8:
|
---|
226 | case D3DDDIFMT_X8R8G8B8:
|
---|
227 | return 32;
|
---|
228 | case D3DDDIFMT_R5G6B5:
|
---|
229 | case D3DDDIFMT_X1R5G5B5:
|
---|
230 | case D3DDDIFMT_A1R5G5B5:
|
---|
231 | case D3DDDIFMT_A4R4G4B4:
|
---|
232 | return 16;
|
---|
233 | case D3DDDIFMT_R3G3B2:
|
---|
234 | case D3DDDIFMT_A8:
|
---|
235 | return 8;
|
---|
236 | case D3DDDIFMT_A8R3G3B2:
|
---|
237 | case D3DDDIFMT_X4R4G4B4:
|
---|
238 | return 16;
|
---|
239 | case D3DDDIFMT_A2B10G10R10:
|
---|
240 | case D3DDDIFMT_A8B8G8R8:
|
---|
241 | case D3DDDIFMT_X8B8G8R8:
|
---|
242 | case D3DDDIFMT_G16R16:
|
---|
243 | case D3DDDIFMT_A2R10G10B10:
|
---|
244 | return 32;
|
---|
245 | case D3DDDIFMT_A16B16G16R16:
|
---|
246 | return 64;
|
---|
247 | case D3DDDIFMT_A8P8:
|
---|
248 | return 16;
|
---|
249 | case D3DDDIFMT_P8:
|
---|
250 | return 8;
|
---|
251 | case D3DDDIFMT_D16_LOCKABLE:
|
---|
252 | case D3DDDIFMT_D16:
|
---|
253 | case D3DDDIFMT_D15S1:
|
---|
254 | return 16;
|
---|
255 | case D3DDDIFMT_D32:
|
---|
256 | case D3DDDIFMT_D24S8:
|
---|
257 | case D3DDDIFMT_D24X8:
|
---|
258 | case D3DDDIFMT_D24X4S4:
|
---|
259 | case D3DDDIFMT_D24FS8:
|
---|
260 | case D3DDDIFMT_D32_LOCKABLE:
|
---|
261 | return 32;
|
---|
262 | case D3DDDIFMT_S8_LOCKABLE:
|
---|
263 | return 8;
|
---|
264 | default:
|
---|
265 | AssertBreakpoint();
|
---|
266 | return 0;
|
---|
267 | }
|
---|
268 | }
|
---|
269 |
|
---|
270 | DECLINLINE(uint32_t) vboxWddmFormatToFourcc(D3DDDIFORMAT format)
|
---|
271 | {
|
---|
272 | uint32_t uFormat = (uint32_t)format;
|
---|
273 | /* assume that in case both four bytes are non-zero, this is a fourcc */
|
---|
274 | if ((format & 0xff000000)
|
---|
275 | && (format & 0x00ff0000)
|
---|
276 | && (format & 0x0000ff00)
|
---|
277 | && (format & 0x000000ff)
|
---|
278 | )
|
---|
279 | return uFormat;
|
---|
280 | return 0;
|
---|
281 | }
|
---|
282 |
|
---|
283 | #define VBOXWDDM_ROUNDBOUND(_v, _b) (((_v) + ((_b) - 1)) & ~((_b) - 1))
|
---|
284 |
|
---|
285 | DECLINLINE(UINT) vboxWddmCalcPitch(UINT w, UINT bitsPerPixel)
|
---|
286 | {
|
---|
287 | UINT Pitch = bitsPerPixel * w;
|
---|
288 | /* pitch is now in bits, translate in bytes */
|
---|
289 | return VBOXWDDM_ROUNDBOUND(Pitch, 8) >> 3;
|
---|
290 | }
|
---|
291 |
|
---|
292 | DECLINLINE(void) vboxWddmRectUnite(RECT *pR, const RECT *pR2Unite)
|
---|
293 | {
|
---|
294 | pR->left = RT_MIN(pR->left, pR2Unite->left);
|
---|
295 | pR->top = RT_MIN(pR->top, pR2Unite->top);
|
---|
296 | pR->right = RT_MAX(pR->right, pR2Unite->right);
|
---|
297 | pR->bottom = RT_MAX(pR->bottom, pR2Unite->bottom);
|
---|
298 | }
|
---|
299 |
|
---|
300 | DECLINLINE(bool) vboxWddmRectIntersection(const RECT *a, const RECT *b, RECT *rect)
|
---|
301 | {
|
---|
302 | Assert(a);
|
---|
303 | Assert(b);
|
---|
304 | Assert(rect);
|
---|
305 | rect->left = RT_MAX(a->left, b->left);
|
---|
306 | rect->right = RT_MIN(a->right, b->right);
|
---|
307 | rect->top = RT_MAX(a->top, b->top);
|
---|
308 | rect->bottom = RT_MIN(a->bottom, b->bottom);
|
---|
309 | return (rect->right>rect->left) && (rect->bottom>rect->top);
|
---|
310 | }
|
---|
311 |
|
---|
312 | DECLINLINE(void) vboxWddmDirtyRegionAddRect(PVBOXWDDM_DIRTYREGION pInfo, const RECT *pRect)
|
---|
313 | {
|
---|
314 | if (!(pInfo->fFlags & VBOXWDDM_DIRTYREGION_F_VALID))
|
---|
315 | {
|
---|
316 | pInfo->fFlags = VBOXWDDM_DIRTYREGION_F_VALID;
|
---|
317 | if (pRect)
|
---|
318 | {
|
---|
319 | pInfo->fFlags |= VBOXWDDM_DIRTYREGION_F_RECT_VALID;
|
---|
320 | pInfo->Rect = *pRect;
|
---|
321 | }
|
---|
322 | }
|
---|
323 | else if (!!(pInfo->fFlags & VBOXWDDM_DIRTYREGION_F_RECT_VALID))
|
---|
324 | {
|
---|
325 | if (pRect)
|
---|
326 | vboxWddmRectUnite(&pInfo->Rect, pRect);
|
---|
327 | else
|
---|
328 | pInfo->fFlags &= ~VBOXWDDM_DIRTYREGION_F_RECT_VALID;
|
---|
329 | }
|
---|
330 | }
|
---|
331 |
|
---|
332 | DECLINLINE(void) vboxWddmDirtyRegionUnite(PVBOXWDDM_DIRTYREGION pInfo, const PVBOXWDDM_DIRTYREGION pInfo2)
|
---|
333 | {
|
---|
334 | if (pInfo2->fFlags & VBOXWDDM_DIRTYREGION_F_VALID)
|
---|
335 | {
|
---|
336 | if (pInfo2->fFlags & VBOXWDDM_DIRTYREGION_F_RECT_VALID)
|
---|
337 | vboxWddmDirtyRegionAddRect(pInfo, &pInfo2->Rect);
|
---|
338 | else
|
---|
339 | vboxWddmDirtyRegionAddRect(pInfo, NULL);
|
---|
340 | }
|
---|
341 | }
|
---|
342 |
|
---|
343 | DECLINLINE(void) vboxWddmDirtyRegionClear(PVBOXWDDM_DIRTYREGION pInfo)
|
---|
344 | {
|
---|
345 | pInfo->fFlags = 0;
|
---|
346 | }
|
---|
347 |
|
---|
348 | #endif /* #ifndef ___VBoxVideoIf_h___ */
|
---|