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 | //#define VBOXWDDM_ALLOCINFO_HEADSIZE() (sizeof (VBOXWDDM_ALLOCINFO))
|
---|
65 | //#define VBOXWDDM_ALLOCINFO_SIZE_FROMBODYSIZE(_s) (VBOXWDDM_ALLOCINFO_HEADSIZE() + (_s))
|
---|
66 | //#define VBOXWDDM_ALLOCINFO_SIZE(_tCmd) (VBOXWDDM_ALLOCINFO_SIZE_FROMBODYSIZE(sizeof(_tCmd)))
|
---|
67 | //#define VBOXWDDM_ALLOCINFO_BODY(_p, _t) ( (_t*)(((uint8_t*)(_p)) + VBOXWDDM_ALLOCINFO_HEADSIZE()) )
|
---|
68 | //#define VBOXWDDM_ALLOCINFO_HEAD(_pb) ((VBOXWDDM_ALLOCINFO*)((uint8_t *)(_pb) - VBOXWDDM_ALLOCATION_HEADSIZE()))
|
---|
69 |
|
---|
70 | /* this resource is OpenResource'd rather than CreateResource'd */
|
---|
71 | #define VBOXWDDM_RESOURCE_F_OPENNED 0x00000001
|
---|
72 | /* identifies this is a resource created with CreateResource, the VBOXWDDMDISP_RESOURCE::fRcFlags is valid */
|
---|
73 | #define VBOXWDDM_RESOURCE_F_TYPE_GENERIC 0x00000002
|
---|
74 |
|
---|
75 | typedef struct VBOXWDDM_RC_DESC
|
---|
76 | {
|
---|
77 | D3DDDI_RESOURCEFLAGS fFlags;
|
---|
78 | D3DDDIFORMAT enmFormat;
|
---|
79 | D3DDDI_POOL enmPool;
|
---|
80 | D3DDDIMULTISAMPLE_TYPE enmMultisampleType;
|
---|
81 | UINT MultisampleQuality;
|
---|
82 | UINT MipLevels;
|
---|
83 | UINT Fvf;
|
---|
84 | D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId;
|
---|
85 | D3DDDI_RATIONAL RefreshRate;
|
---|
86 | D3DDDI_ROTATION enmRotation;
|
---|
87 | } VBOXWDDM_RC_DESC, *PVBOXWDDM_RC_DESC;
|
---|
88 |
|
---|
89 | typedef struct VBOXWDDM_RCINFO
|
---|
90 | {
|
---|
91 | uint32_t fFlags;
|
---|
92 | VBOXWDDM_RC_DESC RcDesc;
|
---|
93 | uint32_t cAllocInfos;
|
---|
94 | // VBOXWDDM_ALLOCINFO aAllocInfos[1];
|
---|
95 | } VBOXWDDM_RCINFO, *PVBOXWDDM_RCINFO;
|
---|
96 |
|
---|
97 | #define VBOXVHWA_F_ENABLED 0x00000001
|
---|
98 | #define VBOXVHWA_F_CKEY_DST 0x00000002
|
---|
99 | #define VBOXVHWA_F_CKEY_SRC 0x00000004
|
---|
100 |
|
---|
101 | #define VBOXVHWA_MAX_FORMATS 8
|
---|
102 |
|
---|
103 | typedef struct VBOXVHWA_INFO
|
---|
104 | {
|
---|
105 | uint32_t fFlags;
|
---|
106 | uint32_t cOverlaysSupported;
|
---|
107 | uint32_t cFormats;
|
---|
108 | D3DDDIFORMAT aFormats[VBOXVHWA_MAX_FORMATS];
|
---|
109 | } VBOXVHWA_INFO;
|
---|
110 |
|
---|
111 | #define VBOXWDDM_OVERLAY_F_CKEY_DST 0x00000001
|
---|
112 | #define VBOXWDDM_OVERLAY_F_CKEY_DSTRANGE 0x00000002
|
---|
113 | #define VBOXWDDM_OVERLAY_F_CKEY_SRC 0x00000004
|
---|
114 | #define VBOXWDDM_OVERLAY_F_CKEY_SRCRANGE 0x00000008
|
---|
115 | #define VBOXWDDM_OVERLAY_F_BOB 0x00000010
|
---|
116 | #define VBOXWDDM_OVERLAY_F_INTERLEAVED 0x00000020
|
---|
117 | #define VBOXWDDM_OVERLAY_F_MIRROR_LR 0x00000040
|
---|
118 | #define VBOXWDDM_OVERLAY_F_MIRROR_UD 0x00000080
|
---|
119 | #define VBOXWDDM_OVERLAY_F_DEINTERLACED 0x00000100
|
---|
120 |
|
---|
121 | typedef struct VBOXWDDM_OVERLAY_DESC
|
---|
122 | {
|
---|
123 | uint32_t fFlags;
|
---|
124 | UINT DstColorKeyLow;
|
---|
125 | UINT DstColorKeyHigh;
|
---|
126 | UINT SrcColorKeyLow;
|
---|
127 | UINT SrcColorKeyHigh;
|
---|
128 | } VBOXWDDM_OVERLAY_DESC, *PVBOXWDDM_OVERLAY_DESC;
|
---|
129 |
|
---|
130 | /* the dirty rect info is valid */
|
---|
131 | #define VBOXWDDM_DIRTYREGION_F_VALID 0x00000001
|
---|
132 | #define VBOXWDDM_DIRTYREGION_F_RECT_VALID 0x00000002
|
---|
133 |
|
---|
134 | typedef struct VBOXWDDM_DIRTYREGION
|
---|
135 | {
|
---|
136 | uint32_t fFlags; /* <-- see VBOXWDDM_DIRTYREGION_F_xxx flags above */
|
---|
137 | RECT Rect;
|
---|
138 | } VBOXWDDM_DIRTYREGION, *PVBOXWDDM_DIRTYREGION;
|
---|
139 |
|
---|
140 | typedef struct VBOXWDDM_OVERLAY_INFO
|
---|
141 | {
|
---|
142 | VBOXWDDM_OVERLAY_DESC OverlayDesc;
|
---|
143 | VBOXWDDM_DIRTYREGION DirtyRegion; /* <- the dirty region of the overlay surface */
|
---|
144 | } VBOXWDDM_OVERLAY_INFO, *PVBOXWDDM_OVERLAY_INFO;
|
---|
145 |
|
---|
146 | typedef struct VBOXWDDM_OVERLAYFLIP_INFO
|
---|
147 | {
|
---|
148 | VBOXWDDM_DIRTYREGION DirtyRegion; /* <- the dirty region of the overlay surface */
|
---|
149 | } VBOXWDDM_OVERLAYFLIP_INFO, *PVBOXWDDM_OVERLAYFLIP_INFO;
|
---|
150 |
|
---|
151 | /* query info func */
|
---|
152 | typedef struct VBOXWDDM_QI
|
---|
153 | {
|
---|
154 | uint32_t u32Version;
|
---|
155 | uint32_t cInfos;
|
---|
156 | VBOXVHWA_INFO aInfos[VBOX_VIDEO_MAX_SCREENS];
|
---|
157 | } VBOXWDDM_QI;
|
---|
158 |
|
---|
159 | /* submit cmd func */
|
---|
160 |
|
---|
161 |
|
---|
162 |
|
---|
163 |
|
---|
164 | /* tooling */
|
---|
165 | DECLINLINE(UINT) vboxWddmCalcBitsPerPixel(D3DDDIFORMAT format)
|
---|
166 | {
|
---|
167 | switch (format)
|
---|
168 | {
|
---|
169 | case D3DDDIFMT_R8G8B8:
|
---|
170 | return 24;
|
---|
171 | case D3DDDIFMT_A8R8G8B8:
|
---|
172 | case D3DDDIFMT_X8R8G8B8:
|
---|
173 | return 32;
|
---|
174 | case D3DDDIFMT_R5G6B5:
|
---|
175 | case D3DDDIFMT_X1R5G5B5:
|
---|
176 | case D3DDDIFMT_A1R5G5B5:
|
---|
177 | case D3DDDIFMT_A4R4G4B4:
|
---|
178 | return 16;
|
---|
179 | case D3DDDIFMT_R3G3B2:
|
---|
180 | case D3DDDIFMT_A8:
|
---|
181 | return 8;
|
---|
182 | case D3DDDIFMT_A8R3G3B2:
|
---|
183 | case D3DDDIFMT_X4R4G4B4:
|
---|
184 | return 16;
|
---|
185 | case D3DDDIFMT_A2B10G10R10:
|
---|
186 | case D3DDDIFMT_A8B8G8R8:
|
---|
187 | case D3DDDIFMT_X8B8G8R8:
|
---|
188 | case D3DDDIFMT_G16R16:
|
---|
189 | case D3DDDIFMT_A2R10G10B10:
|
---|
190 | return 32;
|
---|
191 | case D3DDDIFMT_A16B16G16R16:
|
---|
192 | return 64;
|
---|
193 | case D3DDDIFMT_A8P8:
|
---|
194 | return 16;
|
---|
195 | case D3DDDIFMT_P8:
|
---|
196 | return 8;
|
---|
197 | case D3DDDIFMT_D16_LOCKABLE:
|
---|
198 | case D3DDDIFMT_D16:
|
---|
199 | case D3DDDIFMT_D15S1:
|
---|
200 | return 16;
|
---|
201 | case D3DDDIFMT_D32:
|
---|
202 | case D3DDDIFMT_D24S8:
|
---|
203 | case D3DDDIFMT_D24X8:
|
---|
204 | case D3DDDIFMT_D24X4S4:
|
---|
205 | case D3DDDIFMT_D24FS8:
|
---|
206 | case D3DDDIFMT_D32_LOCKABLE:
|
---|
207 | return 32;
|
---|
208 | case D3DDDIFMT_S8_LOCKABLE:
|
---|
209 | return 8;
|
---|
210 | default:
|
---|
211 | AssertBreakpoint();
|
---|
212 | return 0;
|
---|
213 | }
|
---|
214 | }
|
---|
215 |
|
---|
216 | DECLINLINE(uint32_t) vboxWddmFormatToFourcc(D3DDDIFORMAT format)
|
---|
217 | {
|
---|
218 | uint32_t uFormat = (uint32_t)format;
|
---|
219 | /* assume that in case both four bytes are non-zero, this is a fourcc */
|
---|
220 | if ((format & 0xff000000)
|
---|
221 | && (format & 0x00ff0000)
|
---|
222 | && (format & 0x0000ff00)
|
---|
223 | && (format & 0x000000ff)
|
---|
224 | )
|
---|
225 | return uFormat;
|
---|
226 | return 0;
|
---|
227 | }
|
---|
228 |
|
---|
229 | #define VBOXWDDM_ROUNDBOUND(_v, _b) (((_v) + ((_b) - 1)) & ~((_b) - 1))
|
---|
230 |
|
---|
231 | DECLINLINE(UINT) vboxWddmCalcPitch(UINT w, UINT bitsPerPixel)
|
---|
232 | {
|
---|
233 | UINT Pitch = bitsPerPixel * w;
|
---|
234 | /* pitch is now in bits, translate in bytes */
|
---|
235 | return VBOXWDDM_ROUNDBOUND(Pitch, 8) >> 3;
|
---|
236 | }
|
---|
237 |
|
---|
238 | DECLINLINE(void) vboxWddmRectUnite(RECT *pR, const RECT *pR2Unite)
|
---|
239 | {
|
---|
240 | pR->left = RT_MIN(pR->left, pR2Unite->left);
|
---|
241 | pR->top = RT_MIN(pR->top, pR2Unite->top);
|
---|
242 | pR->right = RT_MAX(pR->right, pR2Unite->right);
|
---|
243 | pR->bottom = RT_MAX(pR->bottom, pR2Unite->bottom);
|
---|
244 | }
|
---|
245 |
|
---|
246 | DECLINLINE(void) vboxWddmDirtyRegionAddRect(PVBOXWDDM_DIRTYREGION pInfo, const RECT *pRect)
|
---|
247 | {
|
---|
248 | if (!(pInfo->fFlags & VBOXWDDM_DIRTYREGION_F_VALID))
|
---|
249 | {
|
---|
250 | pInfo->fFlags = VBOXWDDM_DIRTYREGION_F_VALID;
|
---|
251 | if (pRect)
|
---|
252 | {
|
---|
253 | pInfo->fFlags |= VBOXWDDM_DIRTYREGION_F_RECT_VALID;
|
---|
254 | pInfo->Rect = *pRect;
|
---|
255 | }
|
---|
256 | }
|
---|
257 | else if (!!(pInfo->fFlags & VBOXWDDM_DIRTYREGION_F_RECT_VALID))
|
---|
258 | {
|
---|
259 | if (pRect)
|
---|
260 | vboxWddmRectUnite(&pInfo->Rect, pRect);
|
---|
261 | else
|
---|
262 | pInfo->fFlags &= ~VBOXWDDM_DIRTYREGION_F_RECT_VALID;
|
---|
263 | }
|
---|
264 | }
|
---|
265 |
|
---|
266 | DECLINLINE(void) vboxWddmDirtyRegionUnite(PVBOXWDDM_DIRTYREGION pInfo, const PVBOXWDDM_DIRTYREGION pInfo2)
|
---|
267 | {
|
---|
268 | if (pInfo2->fFlags & VBOXWDDM_DIRTYREGION_F_VALID)
|
---|
269 | {
|
---|
270 | if (pInfo2->fFlags & VBOXWDDM_DIRTYREGION_F_RECT_VALID)
|
---|
271 | vboxWddmDirtyRegionAddRect(pInfo, &pInfo2->Rect);
|
---|
272 | else
|
---|
273 | vboxWddmDirtyRegionAddRect(pInfo, NULL);
|
---|
274 | }
|
---|
275 | }
|
---|
276 |
|
---|
277 | DECLINLINE(void) vboxWddmDirtyRegionClear(PVBOXWDDM_DIRTYREGION pInfo)
|
---|
278 | {
|
---|
279 | pInfo->fFlags = 0;
|
---|
280 | }
|
---|
281 |
|
---|
282 | #endif /* #ifndef ___VBoxVideoIf_h___ */
|
---|