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 | #include <VBox/VBoxUhgsmi.h>
|
---|
27 |
|
---|
28 | #include <iprt/assert.h>
|
---|
29 |
|
---|
30 |
|
---|
31 | /* One would increase this whenever definitions in this file are changed */
|
---|
32 | #define VBOXVIDEOIF_VERSION 7
|
---|
33 |
|
---|
34 | /* create allocation func */
|
---|
35 | typedef 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_UMD_HGSMI_BUFFER
|
---|
46 | } VBOXWDDM_ALLOC_TYPE;
|
---|
47 |
|
---|
48 | /* usage */
|
---|
49 | typedef enum
|
---|
50 | {
|
---|
51 | VBOXWDDM_ALLOCUSAGE_TYPE_UNEFINED = 0,
|
---|
52 | /* set for the allocation being primary */
|
---|
53 | VBOXWDDM_ALLOCUSAGE_TYPE_PRIMARY,
|
---|
54 | } VBOXWDDM_ALLOCUSAGE_TYPE;
|
---|
55 |
|
---|
56 | typedef struct VBOXWDDM_SURFACE_DESC
|
---|
57 | {
|
---|
58 | UINT width;
|
---|
59 | UINT height;
|
---|
60 | D3DDDIFORMAT format;
|
---|
61 | UINT bpp;
|
---|
62 | UINT pitch;
|
---|
63 | UINT depth;
|
---|
64 | UINT slicePitch;
|
---|
65 | UINT cbSize;
|
---|
66 | D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId;
|
---|
67 | D3DDDI_RATIONAL RefreshRate;
|
---|
68 | } VBOXWDDM_SURFACE_DESC, *PVBOXWDDM_SURFACE_DESC;
|
---|
69 |
|
---|
70 | typedef struct VBOXWDDM_ALLOCINFO
|
---|
71 | {
|
---|
72 | VBOXWDDM_ALLOC_TYPE enmType;
|
---|
73 | union
|
---|
74 | {
|
---|
75 | struct
|
---|
76 | {
|
---|
77 | D3DDDI_RESOURCEFLAGS fFlags;
|
---|
78 | HANDLE hSharedHandle;
|
---|
79 | VBOXWDDM_SURFACE_DESC SurfDesc;
|
---|
80 | };
|
---|
81 |
|
---|
82 | struct
|
---|
83 | {
|
---|
84 | uint32_t cbBuffer;
|
---|
85 | HANDLE hSynch;
|
---|
86 | VBOXUHGSMI_SYNCHOBJECT_TYPE enmSynchType;
|
---|
87 | };
|
---|
88 | };
|
---|
89 | } VBOXWDDM_ALLOCINFO, *PVBOXWDDM_ALLOCINFO;
|
---|
90 |
|
---|
91 | /* this resource is OpenResource'd rather than CreateResource'd */
|
---|
92 | #define VBOXWDDM_RESOURCE_F_OPENNED 0x00000001
|
---|
93 | /* identifies this is a resource created with CreateResource, the VBOXWDDMDISP_RESOURCE::fRcFlags is valid */
|
---|
94 | #define VBOXWDDM_RESOURCE_F_TYPE_GENERIC 0x00000002
|
---|
95 |
|
---|
96 | typedef struct VBOXWDDM_RC_DESC
|
---|
97 | {
|
---|
98 | D3DDDI_RESOURCEFLAGS fFlags;
|
---|
99 | D3DDDIFORMAT enmFormat;
|
---|
100 | D3DDDI_POOL enmPool;
|
---|
101 | D3DDDIMULTISAMPLE_TYPE enmMultisampleType;
|
---|
102 | UINT MultisampleQuality;
|
---|
103 | UINT MipLevels;
|
---|
104 | UINT Fvf;
|
---|
105 | D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId;
|
---|
106 | D3DDDI_RATIONAL RefreshRate;
|
---|
107 | D3DDDI_ROTATION enmRotation;
|
---|
108 | } VBOXWDDM_RC_DESC, *PVBOXWDDM_RC_DESC;
|
---|
109 |
|
---|
110 | typedef struct VBOXWDDM_RCINFO
|
---|
111 | {
|
---|
112 | uint32_t fFlags;
|
---|
113 | VBOXWDDM_RC_DESC RcDesc;
|
---|
114 | uint32_t cAllocInfos;
|
---|
115 | // VBOXWDDM_ALLOCINFO aAllocInfos[1];
|
---|
116 | } VBOXWDDM_RCINFO, *PVBOXWDDM_RCINFO;
|
---|
117 |
|
---|
118 | typedef struct VBOXWDDM_DMA_PRIVATEDATA_FLAFS
|
---|
119 | {
|
---|
120 | union
|
---|
121 | {
|
---|
122 | struct
|
---|
123 | {
|
---|
124 | UINT bCmdInDmaBuffer : 1;
|
---|
125 | UINT bReserved : 31;
|
---|
126 | };
|
---|
127 | uint32_t Value;
|
---|
128 | };
|
---|
129 | } VBOXWDDM_DMA_PRIVATEDATA_FLAFS, *PVBOXWDDM_DMA_PRIVATEDATA_FLAFS;
|
---|
130 |
|
---|
131 | typedef struct VBOXWDDM_DMA_PRIVATEDATA_BASEHDR
|
---|
132 | {
|
---|
133 | VBOXVDMACMD_TYPE enmCmd;
|
---|
134 | union
|
---|
135 | {
|
---|
136 | VBOXWDDM_DMA_PRIVATEDATA_FLAFS fFlags;
|
---|
137 | uint32_t u32CmdReserved;
|
---|
138 | };
|
---|
139 | } VBOXWDDM_DMA_PRIVATEDATA_BASEHDR, *PVBOXWDDM_DMA_PRIVATEDATA_BASEHDR;
|
---|
140 |
|
---|
141 | typedef struct VBOXWDDM_UHGSMI_BUFFER_UI_SUBMIT_INFO
|
---|
142 | {
|
---|
143 | VBOXUHGSMI_BUFFER_SUBMIT_FLAGS fSubFlags;
|
---|
144 | uint32_t offData;
|
---|
145 | uint32_t cbData;
|
---|
146 | } VBOXWDDM_UHGSMI_BUFFER_UI_SUBMIT_INFO, *PVBOXWDDM_UHGSMI_BUFFER_UI_SUBMIT_INFO;
|
---|
147 |
|
---|
148 | typedef struct VBOXWDDM_DMA_PRIVATEDATA_UM_CHROMIUM_CMD
|
---|
149 | {
|
---|
150 | VBOXWDDM_DMA_PRIVATEDATA_BASEHDR Base;
|
---|
151 | VBOXWDDM_UHGSMI_BUFFER_UI_SUBMIT_INFO aBufInfos[1];
|
---|
152 | } VBOXWDDM_DMA_PRIVATEDATA_UM_CHROMIUM_CMD, *PVBOXWDDM_DMA_PRIVATEDATA_UM_CHROMIUM_CMD;
|
---|
153 |
|
---|
154 | #define VBOXVHWA_F_ENABLED 0x00000001
|
---|
155 | #define VBOXVHWA_F_CKEY_DST 0x00000002
|
---|
156 | #define VBOXVHWA_F_CKEY_SRC 0x00000004
|
---|
157 |
|
---|
158 | #define VBOXVHWA_MAX_FORMATS 8
|
---|
159 |
|
---|
160 | typedef struct VBOXVHWA_INFO
|
---|
161 | {
|
---|
162 | uint32_t fFlags;
|
---|
163 | uint32_t cOverlaysSupported;
|
---|
164 | uint32_t cFormats;
|
---|
165 | D3DDDIFORMAT aFormats[VBOXVHWA_MAX_FORMATS];
|
---|
166 | } VBOXVHWA_INFO;
|
---|
167 |
|
---|
168 | #define VBOXWDDM_OVERLAY_F_CKEY_DST 0x00000001
|
---|
169 | #define VBOXWDDM_OVERLAY_F_CKEY_DSTRANGE 0x00000002
|
---|
170 | #define VBOXWDDM_OVERLAY_F_CKEY_SRC 0x00000004
|
---|
171 | #define VBOXWDDM_OVERLAY_F_CKEY_SRCRANGE 0x00000008
|
---|
172 | #define VBOXWDDM_OVERLAY_F_BOB 0x00000010
|
---|
173 | #define VBOXWDDM_OVERLAY_F_INTERLEAVED 0x00000020
|
---|
174 | #define VBOXWDDM_OVERLAY_F_MIRROR_LR 0x00000040
|
---|
175 | #define VBOXWDDM_OVERLAY_F_MIRROR_UD 0x00000080
|
---|
176 | #define VBOXWDDM_OVERLAY_F_DEINTERLACED 0x00000100
|
---|
177 |
|
---|
178 | typedef struct VBOXWDDM_OVERLAY_DESC
|
---|
179 | {
|
---|
180 | uint32_t fFlags;
|
---|
181 | UINT DstColorKeyLow;
|
---|
182 | UINT DstColorKeyHigh;
|
---|
183 | UINT SrcColorKeyLow;
|
---|
184 | UINT SrcColorKeyHigh;
|
---|
185 | } VBOXWDDM_OVERLAY_DESC, *PVBOXWDDM_OVERLAY_DESC;
|
---|
186 |
|
---|
187 | /* the dirty rect info is valid */
|
---|
188 | #define VBOXWDDM_DIRTYREGION_F_VALID 0x00000001
|
---|
189 | #define VBOXWDDM_DIRTYREGION_F_RECT_VALID 0x00000002
|
---|
190 |
|
---|
191 | typedef struct VBOXWDDM_DIRTYREGION
|
---|
192 | {
|
---|
193 | uint32_t fFlags; /* <-- see VBOXWDDM_DIRTYREGION_F_xxx flags above */
|
---|
194 | RECT Rect;
|
---|
195 | } VBOXWDDM_DIRTYREGION, *PVBOXWDDM_DIRTYREGION;
|
---|
196 |
|
---|
197 | typedef struct VBOXWDDM_OVERLAY_INFO
|
---|
198 | {
|
---|
199 | VBOXWDDM_OVERLAY_DESC OverlayDesc;
|
---|
200 | VBOXWDDM_DIRTYREGION DirtyRegion; /* <- the dirty region of the overlay surface */
|
---|
201 | } VBOXWDDM_OVERLAY_INFO, *PVBOXWDDM_OVERLAY_INFO;
|
---|
202 |
|
---|
203 | typedef struct VBOXWDDM_OVERLAYFLIP_INFO
|
---|
204 | {
|
---|
205 | VBOXWDDM_DIRTYREGION DirtyRegion; /* <- the dirty region of the overlay surface */
|
---|
206 | } VBOXWDDM_OVERLAYFLIP_INFO, *PVBOXWDDM_OVERLAYFLIP_INFO;
|
---|
207 |
|
---|
208 |
|
---|
209 | typedef enum
|
---|
210 | {
|
---|
211 | VBOXWDDM_CONTEXT_TYPE_UNDEFINED = 0,
|
---|
212 | VBOXWDDM_CONTEXT_TYPE_SYSTEM,
|
---|
213 | VBOXWDDM_CONTEXT_TYPE_CUSTOM_3D,
|
---|
214 | VBOXWDDM_CONTEXT_TYPE_CUSTOM_2D,
|
---|
215 | VBOXWDDM_CONTEXT_TYPE_CUSTOM_UHGSMI_3D,
|
---|
216 | VBOXWDDM_CONTEXT_TYPE_CUSTOM_UHGSMI_GL
|
---|
217 | } VBOXWDDM_CONTEXT_TYPE;
|
---|
218 |
|
---|
219 | typedef struct VBOXWDDM_CREATECONTEXT_INFO
|
---|
220 | {
|
---|
221 | /* interface version, i.e. 9 for d3d9, 8 for d3d8, etc. */
|
---|
222 | uint32_t u32IfVersion;
|
---|
223 | /* true if d3d false if ddraw */
|
---|
224 | VBOXWDDM_CONTEXT_TYPE enmType;
|
---|
225 | /* we use uint64_t instead of HANDLE to ensure structure def is the same for both 32-bit and 64-bit
|
---|
226 | * since x64 kernel driver can be called by 32-bit UMD */
|
---|
227 | uint64_t hUmEvent;
|
---|
228 | /* info to be passed to UMD notification to identify the context */
|
---|
229 | uint64_t u64UmInfo;
|
---|
230 | } VBOXWDDM_CREATECONTEXT_INFO, *PVBOXWDDM_CREATECONTEXT_INFO;
|
---|
231 |
|
---|
232 | typedef void *VBOXDISP_UMHANDLE;
|
---|
233 | typedef uint32_t VBOXDISP_KMHANDLE;
|
---|
234 |
|
---|
235 | typedef struct VBOXWDDM_RECTS_FLAFS
|
---|
236 | {
|
---|
237 | union
|
---|
238 | {
|
---|
239 | struct
|
---|
240 | {
|
---|
241 | /* used only in conjunction with bSetVisibleRects.
|
---|
242 | * if set - VBOXWDDM_RECTS_INFO::aRects[0] contains view rectangle */
|
---|
243 | UINT bSetViewRect : 1;
|
---|
244 | /* sets visible regions */
|
---|
245 | UINT bSetVisibleRects : 1;
|
---|
246 | /* adds hidden regions */
|
---|
247 | UINT bAddHiddenRects : 1;
|
---|
248 | UINT Reserved : 29;
|
---|
249 | };
|
---|
250 | uint32_t Value;
|
---|
251 | };
|
---|
252 | } VBOXWDDM_RECTS_FLAFS, *PVBOXWDDM_RECTS_FLAFS;
|
---|
253 |
|
---|
254 | typedef struct VBOXWDDM_RECTS_INFO
|
---|
255 | {
|
---|
256 | uint32_t cRects;
|
---|
257 | RECT aRects[1];
|
---|
258 | } VBOXWDDM_RECTS_INFO, *PVBOXWDDM_RECTS_INFO;
|
---|
259 |
|
---|
260 | #define VBOXWDDM_RECTS_INFO_SIZE4CRECTS(_cRects) (RT_OFFSETOF(VBOXWDDM_RECTS_INFO, aRects[(_cRects)]))
|
---|
261 | #define VBOXWDDM_RECTS_INFO_SIZE(_pRects) (VBOXVIDEOCM_CMD_RECTS_SIZE4CRECTS((_pRects)->cRects))
|
---|
262 |
|
---|
263 | typedef struct VBOXVIDEOCM_CMD_HDR
|
---|
264 | {
|
---|
265 | uint64_t u64UmData;
|
---|
266 | uint32_t cbCmd;
|
---|
267 | uint32_t u32CmdSpecific;
|
---|
268 | }VBOXVIDEOCM_CMD_HDR, *PVBOXVIDEOCM_CMD_HDR;
|
---|
269 |
|
---|
270 | AssertCompile((sizeof (VBOXVIDEOCM_CMD_HDR) & 7) == 0);
|
---|
271 |
|
---|
272 | typedef struct VBOXVIDEOCM_CMD_RECTS
|
---|
273 | {
|
---|
274 | VBOXWDDM_RECTS_FLAFS fFlags;
|
---|
275 | VBOXWDDM_RECTS_INFO RectsInfo;
|
---|
276 | } VBOXVIDEOCM_CMD_RECTS, *PVBOXVIDEOCM_CMD_RECTS;
|
---|
277 |
|
---|
278 | typedef struct VBOXVIDEOCM_CMD_RECTS_INTERNAL
|
---|
279 | {
|
---|
280 | union
|
---|
281 | {
|
---|
282 | VBOXDISP_UMHANDLE hSwapchainUm;
|
---|
283 | uint64_t u64Alignment;
|
---|
284 | };
|
---|
285 | VBOXVIDEOCM_CMD_RECTS Cmd;
|
---|
286 | } VBOXVIDEOCM_CMD_RECTS_INTERNAL, *PVBOXVIDEOCM_CMD_RECTS_INTERNAL;
|
---|
287 |
|
---|
288 | #define VBOXVIDEOCM_CMD_RECTS_INTERNAL_SIZE4CRECTS(_cRects) (RT_OFFSETOF(VBOXVIDEOCM_CMD_RECTS_INTERNAL, Cmd.RectsInfo.aRects[(_cRects)]))
|
---|
289 | #define VBOXVIDEOCM_CMD_RECTS_INTERNAL_SIZE(_pCmd) (VBOXVIDEOCM_CMD_RECTS_INTERNAL_SIZE4CRECTS((_pCmd)->cRects))
|
---|
290 |
|
---|
291 | typedef struct VBOXWDDM_GETVBOXVIDEOCMCMD_HDR
|
---|
292 | {
|
---|
293 | uint32_t cbCmdsReturned;
|
---|
294 | uint32_t cbRemainingCmds;
|
---|
295 | uint32_t cbRemainingFirstCmd;
|
---|
296 | uint32_t u32Reserved;
|
---|
297 | } VBOXWDDM_GETVBOXVIDEOCMCMD_HDR, *PVBOXWDDM_GETVBOXVIDEOCMCMD_HDR;
|
---|
298 |
|
---|
299 | typedef struct VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD
|
---|
300 | {
|
---|
301 | VBOXDISPIFESCAPE EscapeHdr;
|
---|
302 | VBOXWDDM_GETVBOXVIDEOCMCMD_HDR Hdr;
|
---|
303 | } VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD, *PVBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD;
|
---|
304 |
|
---|
305 | AssertCompile((sizeof (VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD) & 7) == 0);
|
---|
306 | AssertCompile(RT_OFFSETOF(VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD, EscapeHdr) == 0);
|
---|
307 |
|
---|
308 | typedef struct VBOXDISPIFESCAPE_DBGPRINT
|
---|
309 | {
|
---|
310 | VBOXDISPIFESCAPE EscapeHdr;
|
---|
311 | /* null-terminated string to DbgPrint including \0 */
|
---|
312 | char aStringBuf[1];
|
---|
313 | } VBOXDISPIFESCAPE_DBGPRINT, *PVBOXDISPIFESCAPE_DBGPRINT;
|
---|
314 | AssertCompile(RT_OFFSETOF(VBOXDISPIFESCAPE_DBGPRINT, EscapeHdr) == 0);
|
---|
315 |
|
---|
316 | typedef struct VBOXSCREENLAYOUT_ELEMENT
|
---|
317 | {
|
---|
318 | D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId;
|
---|
319 | POINT pos;
|
---|
320 | } VBOXSCREENLAYOUT_ELEMENT, *PVBOXSCREENLAYOUT_ELEMENT;
|
---|
321 |
|
---|
322 | typedef struct VBOXSCREENLAYOUT
|
---|
323 | {
|
---|
324 | uint32_t cScreens;
|
---|
325 | VBOXSCREENLAYOUT_ELEMENT aScreens[1];
|
---|
326 | } VBOXSCREENLAYOUT, *PVBOXSCREENLAYOUT;
|
---|
327 |
|
---|
328 | typedef struct VBOXDISPIFESCAPE_SCREENLAYOUT
|
---|
329 | {
|
---|
330 | VBOXDISPIFESCAPE EscapeHdr;
|
---|
331 | VBOXSCREENLAYOUT ScreenLayout;
|
---|
332 | } VBOXDISPIFESCAPE_SCREENLAYOUT, *PVBOXDISPIFESCAPE_SCREENLAYOUT;
|
---|
333 |
|
---|
334 | typedef struct VBOXSWAPCHAININFO
|
---|
335 | {
|
---|
336 | VBOXDISP_KMHANDLE hSwapchainKm; /* in, NULL if new is being created */
|
---|
337 | VBOXDISP_UMHANDLE hSwapchainUm; /* in, UMD private data */
|
---|
338 | RECT Rect;
|
---|
339 | UINT u32Reserved;
|
---|
340 | UINT cAllocs;
|
---|
341 | D3DKMT_HANDLE ahAllocs[1];
|
---|
342 | }VBOXSWAPCHAININFO, *PVBOXSWAPCHAININFO;
|
---|
343 | typedef struct VBOXDISPIFESCAPE_SWAPCHAININFO
|
---|
344 | {
|
---|
345 | VBOXDISPIFESCAPE EscapeHdr;
|
---|
346 | VBOXSWAPCHAININFO SwapchainInfo;
|
---|
347 | } VBOXDISPIFESCAPE_SWAPCHAININFO, *PVBOXDISPIFESCAPE_SWAPCHAININFO;
|
---|
348 |
|
---|
349 | /* query info func */
|
---|
350 | typedef struct VBOXWDDM_QI
|
---|
351 | {
|
---|
352 | uint32_t u32Version;
|
---|
353 | uint32_t cInfos;
|
---|
354 | VBOXVHWA_INFO aInfos[VBOX_VIDEO_MAX_SCREENS];
|
---|
355 | } VBOXWDDM_QI;
|
---|
356 |
|
---|
357 | /* submit cmd func */
|
---|
358 |
|
---|
359 | /* tooling */
|
---|
360 | DECLINLINE(UINT) vboxWddmCalcBitsPerPixel(D3DDDIFORMAT format)
|
---|
361 | {
|
---|
362 | switch (format)
|
---|
363 | {
|
---|
364 | case D3DDDIFMT_R8G8B8:
|
---|
365 | return 24;
|
---|
366 | case D3DDDIFMT_A8R8G8B8:
|
---|
367 | case D3DDDIFMT_X8R8G8B8:
|
---|
368 | return 32;
|
---|
369 | case D3DDDIFMT_R5G6B5:
|
---|
370 | case D3DDDIFMT_X1R5G5B5:
|
---|
371 | case D3DDDIFMT_A1R5G5B5:
|
---|
372 | case D3DDDIFMT_A4R4G4B4:
|
---|
373 | return 16;
|
---|
374 | case D3DDDIFMT_R3G3B2:
|
---|
375 | case D3DDDIFMT_A8:
|
---|
376 | return 8;
|
---|
377 | case D3DDDIFMT_A8R3G3B2:
|
---|
378 | case D3DDDIFMT_X4R4G4B4:
|
---|
379 | return 16;
|
---|
380 | case D3DDDIFMT_A2B10G10R10:
|
---|
381 | case D3DDDIFMT_A8B8G8R8:
|
---|
382 | case D3DDDIFMT_X8B8G8R8:
|
---|
383 | case D3DDDIFMT_G16R16:
|
---|
384 | case D3DDDIFMT_A2R10G10B10:
|
---|
385 | return 32;
|
---|
386 | case D3DDDIFMT_A16B16G16R16:
|
---|
387 | return 64;
|
---|
388 | case D3DDDIFMT_A8P8:
|
---|
389 | return 16;
|
---|
390 | case D3DDDIFMT_P8:
|
---|
391 | case D3DDDIFMT_L8:
|
---|
392 | return 8;
|
---|
393 | case D3DDDIFMT_A8L8:
|
---|
394 | return 16;
|
---|
395 | case D3DDDIFMT_A4L4:
|
---|
396 | return 8;
|
---|
397 | case D3DDDIFMT_V8U8:
|
---|
398 | case D3DDDIFMT_L6V5U5:
|
---|
399 | return 16;
|
---|
400 | case D3DDDIFMT_X8L8V8U8:
|
---|
401 | case D3DDDIFMT_Q8W8V8U8:
|
---|
402 | case D3DDDIFMT_V16U16:
|
---|
403 | case D3DDDIFMT_W11V11U10:
|
---|
404 | case D3DDDIFMT_A2W10V10U10:
|
---|
405 | return 32;
|
---|
406 | case D3DDDIFMT_D16_LOCKABLE:
|
---|
407 | case D3DDDIFMT_D16:
|
---|
408 | case D3DDDIFMT_D15S1:
|
---|
409 | return 16;
|
---|
410 | case D3DDDIFMT_D32:
|
---|
411 | case D3DDDIFMT_D24S8:
|
---|
412 | case D3DDDIFMT_D24X8:
|
---|
413 | case D3DDDIFMT_D24X4S4:
|
---|
414 | case D3DDDIFMT_D24FS8:
|
---|
415 | case D3DDDIFMT_D32_LOCKABLE:
|
---|
416 | case D3DDDIFMT_D32F_LOCKABLE:
|
---|
417 | return 32;
|
---|
418 | case D3DDDIFMT_S8_LOCKABLE:
|
---|
419 | return 8;
|
---|
420 | default:
|
---|
421 | AssertBreakpoint();
|
---|
422 | return 0;
|
---|
423 | }
|
---|
424 | }
|
---|
425 |
|
---|
426 | DECLINLINE(uint32_t) vboxWddmFormatToFourcc(D3DDDIFORMAT format)
|
---|
427 | {
|
---|
428 | uint32_t uFormat = (uint32_t)format;
|
---|
429 | /* assume that in case both four bytes are non-zero, this is a fourcc */
|
---|
430 | if ((format & 0xff000000)
|
---|
431 | && (format & 0x00ff0000)
|
---|
432 | && (format & 0x0000ff00)
|
---|
433 | && (format & 0x000000ff)
|
---|
434 | )
|
---|
435 | return uFormat;
|
---|
436 | return 0;
|
---|
437 | }
|
---|
438 |
|
---|
439 | #define VBOXWDDM_ROUNDBOUND(_v, _b) (((_v) + ((_b) - 1)) & ~((_b) - 1))
|
---|
440 |
|
---|
441 | DECLINLINE(UINT) vboxWddmCalcPitch(UINT w, UINT bitsPerPixel)
|
---|
442 | {
|
---|
443 | UINT Pitch = bitsPerPixel * w;
|
---|
444 | /* pitch is now in bits, translate in bytes */
|
---|
445 | return VBOXWDDM_ROUNDBOUND(Pitch, 8) >> 3;
|
---|
446 | }
|
---|
447 |
|
---|
448 | DECLINLINE(void) vboxWddmRectUnite(RECT *pR, const RECT *pR2Unite)
|
---|
449 | {
|
---|
450 | pR->left = RT_MIN(pR->left, pR2Unite->left);
|
---|
451 | pR->top = RT_MIN(pR->top, pR2Unite->top);
|
---|
452 | pR->right = RT_MAX(pR->right, pR2Unite->right);
|
---|
453 | pR->bottom = RT_MAX(pR->bottom, pR2Unite->bottom);
|
---|
454 | }
|
---|
455 |
|
---|
456 | DECLINLINE(bool) vboxWddmRectIntersection(const RECT *a, const RECT *b, RECT *rect)
|
---|
457 | {
|
---|
458 | Assert(a);
|
---|
459 | Assert(b);
|
---|
460 | Assert(rect);
|
---|
461 | rect->left = RT_MAX(a->left, b->left);
|
---|
462 | rect->right = RT_MIN(a->right, b->right);
|
---|
463 | rect->top = RT_MAX(a->top, b->top);
|
---|
464 | rect->bottom = RT_MIN(a->bottom, b->bottom);
|
---|
465 | return (rect->right>rect->left) && (rect->bottom>rect->top);
|
---|
466 | }
|
---|
467 |
|
---|
468 | DECLINLINE(bool) vboxWddmRectIsEqual(const RECT *pRect1, const RECT *pRect2)
|
---|
469 | {
|
---|
470 | Assert(pRect1);
|
---|
471 | Assert(pRect2);
|
---|
472 | if (pRect1->left != pRect2->left)
|
---|
473 | return false;
|
---|
474 | if (pRect1->top != pRect2->top)
|
---|
475 | return false;
|
---|
476 | if (pRect1->right != pRect2->right)
|
---|
477 | return false;
|
---|
478 | if (pRect1->bottom != pRect2->bottom)
|
---|
479 | return false;
|
---|
480 | return true;
|
---|
481 | }
|
---|
482 |
|
---|
483 | DECLINLINE(bool) vboxWddmRectIsCoveres(const RECT *pRect, const RECT *pCovered)
|
---|
484 | {
|
---|
485 | Assert(pRect);
|
---|
486 | Assert(pCovered);
|
---|
487 | if (pRect->left > pCovered->left)
|
---|
488 | return false;
|
---|
489 | if (pRect->top > pCovered->top)
|
---|
490 | return false;
|
---|
491 | if (pRect->right < pCovered->right)
|
---|
492 | return false;
|
---|
493 | if (pRect->bottom < pCovered->bottom)
|
---|
494 | return false;
|
---|
495 | return true;
|
---|
496 | }
|
---|
497 |
|
---|
498 | DECLINLINE(bool) vboxWddmRectIsEmpty(const RECT * pRect)
|
---|
499 | {
|
---|
500 | return pRect->left == pRect->right-1 && pRect->top == pRect->bottom-1;
|
---|
501 | }
|
---|
502 |
|
---|
503 | DECLINLINE(bool) vboxWddmRectIsIntersect(const RECT * pRect1, const RECT * pRect2)
|
---|
504 | {
|
---|
505 | return !((pRect1->left < pRect2->left && pRect1->right < pRect2->left)
|
---|
506 | || (pRect2->left < pRect1->left && pRect2->right < pRect1->left)
|
---|
507 | || (pRect1->top < pRect2->top && pRect1->bottom < pRect2->top)
|
---|
508 | || (pRect2->top < pRect1->top && pRect2->bottom < pRect1->top));
|
---|
509 | }
|
---|
510 |
|
---|
511 | DECLINLINE(void) vboxWddmRectUnited(RECT * pDst, const RECT * pRect1, const RECT * pRect2)
|
---|
512 | {
|
---|
513 | pDst->left = RT_MIN(pRect1->left, pRect2->left);
|
---|
514 | pDst->top = RT_MIN(pRect1->top, pRect2->top);
|
---|
515 | pDst->right = RT_MAX(pRect1->right, pRect2->right);
|
---|
516 | pDst->bottom = RT_MAX(pRect1->bottom, pRect2->bottom);
|
---|
517 | }
|
---|
518 |
|
---|
519 | DECLINLINE(void) vboxWddmRectTranslate(RECT * pRect, int x, int y)
|
---|
520 | {
|
---|
521 | pRect->left += x;
|
---|
522 | pRect->top += y;
|
---|
523 | pRect->right += x;
|
---|
524 | pRect->bottom += y;
|
---|
525 | }
|
---|
526 |
|
---|
527 | DECLINLINE(void) vboxWddmRectMove(RECT * pRect, int x, int y)
|
---|
528 | {
|
---|
529 | LONG w = pRect->right - pRect->left;
|
---|
530 | LONG h = pRect->bottom - pRect->top;
|
---|
531 | pRect->left = x;
|
---|
532 | pRect->top = y;
|
---|
533 | pRect->right = w + x;
|
---|
534 | pRect->bottom = h + y;
|
---|
535 | }
|
---|
536 |
|
---|
537 | DECLINLINE(void) vboxWddmRectTranslated(RECT *pDst, const RECT * pRect, int x, int y)
|
---|
538 | {
|
---|
539 | *pDst = *pRect;
|
---|
540 | vboxWddmRectTranslate(pDst, x, y);
|
---|
541 | }
|
---|
542 |
|
---|
543 | DECLINLINE(void) vboxWddmRectMoved(RECT *pDst, const RECT * pRect, int x, int y)
|
---|
544 | {
|
---|
545 | *pDst = *pRect;
|
---|
546 | vboxWddmRectMove(pDst, x, y);
|
---|
547 | }
|
---|
548 |
|
---|
549 | DECLINLINE(void) vboxWddmDirtyRegionAddRect(PVBOXWDDM_DIRTYREGION pInfo, const RECT *pRect)
|
---|
550 | {
|
---|
551 | if (!(pInfo->fFlags & VBOXWDDM_DIRTYREGION_F_VALID))
|
---|
552 | {
|
---|
553 | pInfo->fFlags = VBOXWDDM_DIRTYREGION_F_VALID;
|
---|
554 | if (pRect)
|
---|
555 | {
|
---|
556 | pInfo->fFlags |= VBOXWDDM_DIRTYREGION_F_RECT_VALID;
|
---|
557 | pInfo->Rect = *pRect;
|
---|
558 | }
|
---|
559 | }
|
---|
560 | else if (!!(pInfo->fFlags & VBOXWDDM_DIRTYREGION_F_RECT_VALID))
|
---|
561 | {
|
---|
562 | if (pRect)
|
---|
563 | vboxWddmRectUnite(&pInfo->Rect, pRect);
|
---|
564 | else
|
---|
565 | pInfo->fFlags &= ~VBOXWDDM_DIRTYREGION_F_RECT_VALID;
|
---|
566 | }
|
---|
567 | }
|
---|
568 |
|
---|
569 | DECLINLINE(void) vboxWddmDirtyRegionUnite(PVBOXWDDM_DIRTYREGION pInfo, const PVBOXWDDM_DIRTYREGION pInfo2)
|
---|
570 | {
|
---|
571 | if (pInfo2->fFlags & VBOXWDDM_DIRTYREGION_F_VALID)
|
---|
572 | {
|
---|
573 | if (pInfo2->fFlags & VBOXWDDM_DIRTYREGION_F_RECT_VALID)
|
---|
574 | vboxWddmDirtyRegionAddRect(pInfo, &pInfo2->Rect);
|
---|
575 | else
|
---|
576 | vboxWddmDirtyRegionAddRect(pInfo, NULL);
|
---|
577 | }
|
---|
578 | }
|
---|
579 |
|
---|
580 | DECLINLINE(void) vboxWddmDirtyRegionClear(PVBOXWDDM_DIRTYREGION pInfo)
|
---|
581 | {
|
---|
582 | pInfo->fFlags = 0;
|
---|
583 | }
|
---|
584 |
|
---|
585 | #endif /* #ifndef ___VBoxVideoIf_h___ */
|
---|