VirtualBox

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

Last change on this file since 30508 was 30462, checked in by vboxsync, 15 years ago

wddm/3d: visible regions reporting API & impl (not tested enough yet)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.9 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 UINT bPositionRect : 1;
170 UINT bAddVisibleRects : 1;
171 UINT bAddHiddenRects : 1;
172 UINT Reserved : 29;
173 };
174 uint32_t Value;
175 };
176} VBOXWDDM_RECTS_FLAFS, *PVBOXWDDM_RECTS_FLAFS;
177
178typedef struct VBOXWDDM_RECTS_INFO
179{
180 uint32_t cRects;
181 RECT aRects[1];
182} VBOXWDDM_RECTS_INFO, *PVBOXWDDM_RECTS_INFO;
183
184#define VBOXWDDM_RECTS_INFO_SIZE4CRECTS(_cRects) (RT_OFFSETOF(VBOXWDDM_RECTS_INFO, aRects[(_cRects)]))
185#define VBOXWDDM_RECTS_INFO_SIZE(_pRects) (VBOXVIDEOCM_CMD_RECTS_SIZE4CRECTS((_pRects)->cRects))
186
187typedef struct VBOXVIDEOCM_CMD_HDR
188{
189 uint64_t u64UmData;
190 uint32_t cbCmd;
191 uint32_t u32CmdSpecific;
192}VBOXVIDEOCM_CMD_HDR, *PVBOXVIDEOCM_CMD_HDR;
193
194AssertCompile((sizeof (VBOXVIDEOCM_CMD_HDR) & 7) == 0);
195
196typedef struct VBOXVIDEOCM_CMD_RECTS
197{
198 VBOXWDDM_RECTS_FLAFS fFlags;
199 VBOXWDDM_RECTS_INFO RectsInfo;
200} VBOXVIDEOCM_CMD_RECTS, *PVBOXVIDEOCM_CMD_RECTS;
201
202#define VBOXVIDEOCM_CMD_RECTS_SIZE4CRECTS(_cRects) (RT_OFFSETOF(VBOXVIDEOCM_CMD_RECTS, RectsInfo.aRects[(_cRects)]))
203#define VBOXVIDEOCM_CMD_RECTS_SIZE(_pCmd) (VBOXVIDEOCM_CMD_RECTS_SIZE4CRECTS((_pCmd)->cRects))
204
205typedef struct VBOXWDDM_GETVBOXVIDEOCMCMD_HDR
206{
207 uint32_t cbCmdsReturned;
208 uint32_t cbRemainingCmds;
209 uint32_t cbRemainingFirstCmd;
210 uint32_t u32Reserved;
211} VBOXWDDM_GETVBOXVIDEOCMCMD_HDR, *PVBOXWDDM_GETVBOXVIDEOCMCMD_HDR;
212
213typedef struct VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD
214{
215 VBOXDISPIFESCAPE EscapeHdr;
216 VBOXWDDM_GETVBOXVIDEOCMCMD_HDR Hdr;
217} VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD, *PVBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD;
218
219AssertCompile((sizeof (VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD) & 7) == 0);
220AssertCompile(RT_OFFSETOF(VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD, EscapeHdr) == 0);
221
222/* query info func */
223typedef struct VBOXWDDM_QI
224{
225 uint32_t u32Version;
226 uint32_t cInfos;
227 VBOXVHWA_INFO aInfos[VBOX_VIDEO_MAX_SCREENS];
228} VBOXWDDM_QI;
229
230/* submit cmd func */
231
232/* tooling */
233DECLINLINE(UINT) vboxWddmCalcBitsPerPixel(D3DDDIFORMAT format)
234{
235 switch (format)
236 {
237 case D3DDDIFMT_R8G8B8:
238 return 24;
239 case D3DDDIFMT_A8R8G8B8:
240 case D3DDDIFMT_X8R8G8B8:
241 return 32;
242 case D3DDDIFMT_R5G6B5:
243 case D3DDDIFMT_X1R5G5B5:
244 case D3DDDIFMT_A1R5G5B5:
245 case D3DDDIFMT_A4R4G4B4:
246 return 16;
247 case D3DDDIFMT_R3G3B2:
248 case D3DDDIFMT_A8:
249 return 8;
250 case D3DDDIFMT_A8R3G3B2:
251 case D3DDDIFMT_X4R4G4B4:
252 return 16;
253 case D3DDDIFMT_A2B10G10R10:
254 case D3DDDIFMT_A8B8G8R8:
255 case D3DDDIFMT_X8B8G8R8:
256 case D3DDDIFMT_G16R16:
257 case D3DDDIFMT_A2R10G10B10:
258 return 32;
259 case D3DDDIFMT_A16B16G16R16:
260 return 64;
261 case D3DDDIFMT_A8P8:
262 return 16;
263 case D3DDDIFMT_P8:
264 return 8;
265 case D3DDDIFMT_D16_LOCKABLE:
266 case D3DDDIFMT_D16:
267 case D3DDDIFMT_D15S1:
268 return 16;
269 case D3DDDIFMT_D32:
270 case D3DDDIFMT_D24S8:
271 case D3DDDIFMT_D24X8:
272 case D3DDDIFMT_D24X4S4:
273 case D3DDDIFMT_D24FS8:
274 case D3DDDIFMT_D32_LOCKABLE:
275 return 32;
276 case D3DDDIFMT_S8_LOCKABLE:
277 return 8;
278 default:
279 AssertBreakpoint();
280 return 0;
281 }
282}
283
284DECLINLINE(uint32_t) vboxWddmFormatToFourcc(D3DDDIFORMAT format)
285{
286 uint32_t uFormat = (uint32_t)format;
287 /* assume that in case both four bytes are non-zero, this is a fourcc */
288 if ((format & 0xff000000)
289 && (format & 0x00ff0000)
290 && (format & 0x0000ff00)
291 && (format & 0x000000ff)
292 )
293 return uFormat;
294 return 0;
295}
296
297#define VBOXWDDM_ROUNDBOUND(_v, _b) (((_v) + ((_b) - 1)) & ~((_b) - 1))
298
299DECLINLINE(UINT) vboxWddmCalcPitch(UINT w, UINT bitsPerPixel)
300{
301 UINT Pitch = bitsPerPixel * w;
302 /* pitch is now in bits, translate in bytes */
303 return VBOXWDDM_ROUNDBOUND(Pitch, 8) >> 3;
304}
305
306DECLINLINE(void) vboxWddmRectUnite(RECT *pR, const RECT *pR2Unite)
307{
308 pR->left = RT_MIN(pR->left, pR2Unite->left);
309 pR->top = RT_MIN(pR->top, pR2Unite->top);
310 pR->right = RT_MAX(pR->right, pR2Unite->right);
311 pR->bottom = RT_MAX(pR->bottom, pR2Unite->bottom);
312}
313
314DECLINLINE(bool) vboxWddmRectIntersection(const RECT *a, const RECT *b, RECT *rect)
315{
316 Assert(a);
317 Assert(b);
318 Assert(rect);
319 rect->left = RT_MAX(a->left, b->left);
320 rect->right = RT_MIN(a->right, b->right);
321 rect->top = RT_MAX(a->top, b->top);
322 rect->bottom = RT_MIN(a->bottom, b->bottom);
323 return (rect->right>rect->left) && (rect->bottom>rect->top);
324}
325
326DECLINLINE(void) vboxWddmDirtyRegionAddRect(PVBOXWDDM_DIRTYREGION pInfo, const RECT *pRect)
327{
328 if (!(pInfo->fFlags & VBOXWDDM_DIRTYREGION_F_VALID))
329 {
330 pInfo->fFlags = VBOXWDDM_DIRTYREGION_F_VALID;
331 if (pRect)
332 {
333 pInfo->fFlags |= VBOXWDDM_DIRTYREGION_F_RECT_VALID;
334 pInfo->Rect = *pRect;
335 }
336 }
337 else if (!!(pInfo->fFlags & VBOXWDDM_DIRTYREGION_F_RECT_VALID))
338 {
339 if (pRect)
340 vboxWddmRectUnite(&pInfo->Rect, pRect);
341 else
342 pInfo->fFlags &= ~VBOXWDDM_DIRTYREGION_F_RECT_VALID;
343 }
344}
345
346DECLINLINE(void) vboxWddmDirtyRegionUnite(PVBOXWDDM_DIRTYREGION pInfo, const PVBOXWDDM_DIRTYREGION pInfo2)
347{
348 if (pInfo2->fFlags & VBOXWDDM_DIRTYREGION_F_VALID)
349 {
350 if (pInfo2->fFlags & VBOXWDDM_DIRTYREGION_F_RECT_VALID)
351 vboxWddmDirtyRegionAddRect(pInfo, &pInfo2->Rect);
352 else
353 vboxWddmDirtyRegionAddRect(pInfo, NULL);
354 }
355}
356
357DECLINLINE(void) vboxWddmDirtyRegionClear(PVBOXWDDM_DIRTYREGION pInfo)
358{
359 pInfo->fFlags = 0;
360}
361
362#endif /* #ifndef ___VBoxVideoIf_h___ */
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette