1 | /* $Id: VBoxMPIf.h 89147 2021-05-18 19:48:37Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox WDDM Miniport driver.
|
---|
4 | *
|
---|
5 | * Contains base definitions of constants & structures used to control & perform
|
---|
6 | * rendering, such as DMA commands types, allocation types, escape codes, etc.
|
---|
7 | * used by both miniport & display drivers.
|
---|
8 | *
|
---|
9 | * The latter uses these and only these defs to communicate with the former
|
---|
10 | * by posting appropriate requests via D3D RT Krnl Svc accessing callbacks.
|
---|
11 | */
|
---|
12 |
|
---|
13 | /*
|
---|
14 | * Copyright (C) 2011-2020 Oracle Corporation
|
---|
15 | *
|
---|
16 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
17 | * available from http://www.virtualbox.org. This file is free software;
|
---|
18 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
19 | * General Public License (GPL) as published by the Free Software
|
---|
20 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
21 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
22 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
23 | */
|
---|
24 |
|
---|
25 | #ifndef GA_INCLUDED_SRC_WINNT_Graphics_Video_common_wddm_VBoxMPIf_h
|
---|
26 | #define GA_INCLUDED_SRC_WINNT_Graphics_Video_common_wddm_VBoxMPIf_h
|
---|
27 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
28 | # pragma once
|
---|
29 | #endif
|
---|
30 |
|
---|
31 | #include <VBoxVideo.h>
|
---|
32 | #include "../../../../include/VBoxDisplay.h"
|
---|
33 | #include "../VBoxVideoTools.h"
|
---|
34 | #include <VBoxUhgsmi.h>
|
---|
35 | #include <VBox/VBoxGuestCoreTypes.h> /* for VBGLIOCHGCMCALL */
|
---|
36 |
|
---|
37 | /* One would increase this whenever definitions in this file are changed */
|
---|
38 | #define VBOXVIDEOIF_VERSION 22
|
---|
39 |
|
---|
40 | /** @todo VBOXVIDEO_HWTYPE probably needs to be in VBoxVideo.h */
|
---|
41 | typedef enum VBOXVIDEO_HWTYPE
|
---|
42 | {
|
---|
43 | VBOXVIDEO_HWTYPE_VBOX = 0,
|
---|
44 | VBOXVIDEO_HWTYPE_VMSVGA = 1,
|
---|
45 | VBOXVIDEO_HWTYPE_32BIT = 0x7fffffff
|
---|
46 | } VBOXVIDEO_HWTYPE;
|
---|
47 | AssertCompileSize(VBOXVIDEO_HWTYPE, 4);
|
---|
48 |
|
---|
49 | #define VBOXWDDM_NODE_ID_SYSTEM 0
|
---|
50 | #define VBOXWDDM_NODE_ID_3D (VBOXWDDM_NODE_ID_SYSTEM)
|
---|
51 | #define VBOXWDDM_NODE_ID_3D_KMT (VBOXWDDM_NODE_ID_3D)
|
---|
52 | #define VBOXWDDM_NODE_ID_2D_VIDEO (VBOXWDDM_NODE_ID_3D_KMT + 1)
|
---|
53 | #define VBOXWDDM_NUM_NODES (VBOXWDDM_NODE_ID_2D_VIDEO + 1)
|
---|
54 |
|
---|
55 | #define VBOXWDDM_ENGINE_ID_SYSTEM 0
|
---|
56 | #if (VBOXWDDM_NODE_ID_3D == VBOXWDDM_NODE_ID_SYSTEM)
|
---|
57 | # define VBOXWDDM_ENGINE_ID_3D (VBOXWDDM_ENGINE_ID_SYSTEM + 1)
|
---|
58 | #else
|
---|
59 | # define VBOXWDDM_ENGINE_ID_3D 0
|
---|
60 | #endif
|
---|
61 | #if (VBOXWDDM_NODE_ID_3D_KMT == VBOXWDDM_NODE_ID_3D)
|
---|
62 | # define VBOXWDDM_ENGINE_ID_3D_KMT VBOXWDDM_ENGINE_ID_3D
|
---|
63 | #else
|
---|
64 | # define VBOXWDDM_ENGINE_ID_3D_KMT 0
|
---|
65 | #endif
|
---|
66 | #if (VBOXWDDM_NODE_ID_2D_VIDEO == VBOXWDDM_NODE_ID_3D)
|
---|
67 | # define VBOXWDDM_ENGINE_ID_2D_VIDEO VBOXWDDM_ENGINE_ID_3D
|
---|
68 | #else
|
---|
69 | # define VBOXWDDM_ENGINE_ID_2D_VIDEO 0
|
---|
70 | #endif
|
---|
71 |
|
---|
72 |
|
---|
73 | /* create allocation func */
|
---|
74 | typedef enum
|
---|
75 | {
|
---|
76 | VBOXWDDM_ALLOC_TYPE_UNEFINED = 0,
|
---|
77 | VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE,
|
---|
78 | VBOXWDDM_ALLOC_TYPE_STD_SHADOWSURFACE,
|
---|
79 | VBOXWDDM_ALLOC_TYPE_STD_STAGINGSURFACE,
|
---|
80 | /* this one is win 7-specific and hence unused for now */
|
---|
81 | VBOXWDDM_ALLOC_TYPE_STD_GDISURFACE
|
---|
82 | /* custom allocation types requested from user-mode d3d module will go here */
|
---|
83 | , VBOXWDDM_ALLOC_TYPE_UMD_RC_GENERIC
|
---|
84 | , VBOXWDDM_ALLOC_TYPE_UMD_HGSMI_BUFFER
|
---|
85 | } VBOXWDDM_ALLOC_TYPE;
|
---|
86 |
|
---|
87 | /* usage */
|
---|
88 | typedef enum
|
---|
89 | {
|
---|
90 | VBOXWDDM_ALLOCUSAGE_TYPE_UNEFINED = 0,
|
---|
91 | /* set for the allocation being primary */
|
---|
92 | VBOXWDDM_ALLOCUSAGE_TYPE_PRIMARY,
|
---|
93 | } VBOXWDDM_ALLOCUSAGE_TYPE;
|
---|
94 |
|
---|
95 | typedef struct VBOXWDDM_SURFACE_DESC
|
---|
96 | {
|
---|
97 | UINT width;
|
---|
98 | UINT height;
|
---|
99 | D3DDDIFORMAT format;
|
---|
100 | UINT bpp;
|
---|
101 | UINT pitch;
|
---|
102 | UINT depth;
|
---|
103 | UINT slicePitch;
|
---|
104 | UINT d3dWidth;
|
---|
105 | UINT cbSize;
|
---|
106 | D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId;
|
---|
107 | D3DDDI_RATIONAL RefreshRate;
|
---|
108 | } VBOXWDDM_SURFACE_DESC, *PVBOXWDDM_SURFACE_DESC;
|
---|
109 |
|
---|
110 | typedef struct VBOXWDDM_ALLOCINFO
|
---|
111 | {
|
---|
112 | VBOXWDDM_ALLOC_TYPE enmType;
|
---|
113 | union
|
---|
114 | {
|
---|
115 | struct
|
---|
116 | {
|
---|
117 | D3DDDI_RESOURCEFLAGS fFlags;
|
---|
118 | /* id used to identify the allocation on the host */
|
---|
119 | uint32_t hostID;
|
---|
120 | uint64_t hSharedHandle;
|
---|
121 | VBOXWDDM_SURFACE_DESC SurfDesc;
|
---|
122 | };
|
---|
123 |
|
---|
124 | struct
|
---|
125 | {
|
---|
126 | uint32_t cbBuffer;
|
---|
127 | VBOXUHGSMI_BUFFER_TYPE_FLAGS fUhgsmiType;
|
---|
128 | };
|
---|
129 | };
|
---|
130 | } VBOXWDDM_ALLOCINFO, *PVBOXWDDM_ALLOCINFO;
|
---|
131 |
|
---|
132 | typedef struct VBOXWDDM_RC_DESC
|
---|
133 | {
|
---|
134 | D3DDDI_RESOURCEFLAGS fFlags;
|
---|
135 | D3DDDIFORMAT enmFormat;
|
---|
136 | D3DDDI_POOL enmPool;
|
---|
137 | D3DDDIMULTISAMPLE_TYPE enmMultisampleType;
|
---|
138 | UINT MultisampleQuality;
|
---|
139 | UINT MipLevels;
|
---|
140 | UINT Fvf;
|
---|
141 | D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId;
|
---|
142 | D3DDDI_RATIONAL RefreshRate;
|
---|
143 | D3DDDI_ROTATION enmRotation;
|
---|
144 | } VBOXWDDM_RC_DESC, *PVBOXWDDM_RC_DESC;
|
---|
145 |
|
---|
146 | typedef struct VBOXWDDMDISP_RESOURCE_FLAGS
|
---|
147 | {
|
---|
148 | union
|
---|
149 | {
|
---|
150 | struct
|
---|
151 | {
|
---|
152 | UINT Opened : 1; /* this resource is OpenResource'd rather than CreateResource'd */
|
---|
153 | UINT Generic : 1; /* identifies this is a resource created with CreateResource, the VBOXWDDMDISP_RESOURCE::fRcFlags is valid */
|
---|
154 | UINT KmResource : 1; /* this resource has underlying km resource */
|
---|
155 | UINT Reserved : 29; /* reserved */
|
---|
156 | };
|
---|
157 | UINT Value;
|
---|
158 | };
|
---|
159 | } VBOXWDDMDISP_RESOURCE_FLAGS, *PVBOXWDDMDISP_RESOURCE_FLAGS;
|
---|
160 |
|
---|
161 | typedef struct VBOXWDDM_RCINFO
|
---|
162 | {
|
---|
163 | VBOXWDDMDISP_RESOURCE_FLAGS fFlags;
|
---|
164 | VBOXWDDM_RC_DESC RcDesc;
|
---|
165 | uint32_t cAllocInfos;
|
---|
166 | // VBOXWDDM_ALLOCINFO aAllocInfos[1];
|
---|
167 | } VBOXWDDM_RCINFO, *PVBOXWDDM_RCINFO;
|
---|
168 |
|
---|
169 | typedef struct VBOXWDDM_DMA_PRIVATEDATA_FLAFS
|
---|
170 | {
|
---|
171 | union
|
---|
172 | {
|
---|
173 | struct
|
---|
174 | {
|
---|
175 | UINT bCmdInDmaBuffer : 1;
|
---|
176 | UINT bReserved : 31;
|
---|
177 | };
|
---|
178 | uint32_t Value;
|
---|
179 | };
|
---|
180 | } VBOXWDDM_DMA_PRIVATEDATA_FLAFS, *PVBOXWDDM_DMA_PRIVATEDATA_FLAFS;
|
---|
181 |
|
---|
182 | typedef struct VBOXWDDM_DMA_PRIVATEDATA_BASEHDR
|
---|
183 | {
|
---|
184 | VBOXVDMACMD_TYPE enmCmd;
|
---|
185 | union
|
---|
186 | {
|
---|
187 | VBOXWDDM_DMA_PRIVATEDATA_FLAFS fFlags;
|
---|
188 | uint32_t u32CmdReserved;
|
---|
189 | };
|
---|
190 | } VBOXWDDM_DMA_PRIVATEDATA_BASEHDR, *PVBOXWDDM_DMA_PRIVATEDATA_BASEHDR;
|
---|
191 |
|
---|
192 | typedef struct VBOXWDDM_UHGSMI_BUFFER_UI_SUBMIT_INFO
|
---|
193 | {
|
---|
194 | uint32_t offData;
|
---|
195 | uint32_t cbData;
|
---|
196 | } VBOXWDDM_UHGSMI_BUFFER_UI_SUBMIT_INFO, *PVBOXWDDM_UHGSMI_BUFFER_UI_SUBMIT_INFO;
|
---|
197 |
|
---|
198 | typedef struct VBOXWDDM_DMA_PRIVATEDATA_UM_CHROMIUM_CMD
|
---|
199 | {
|
---|
200 | VBOXWDDM_DMA_PRIVATEDATA_BASEHDR Base;
|
---|
201 | VBOXWDDM_UHGSMI_BUFFER_UI_SUBMIT_INFO aBufInfos[1];
|
---|
202 | } VBOXWDDM_DMA_PRIVATEDATA_UM_CHROMIUM_CMD, *PVBOXWDDM_DMA_PRIVATEDATA_UM_CHROMIUM_CMD;
|
---|
203 |
|
---|
204 |
|
---|
205 | #define VBOXVHWA_F_ENABLED 0x00000001
|
---|
206 | #define VBOXVHWA_F_CKEY_DST 0x00000002
|
---|
207 | #define VBOXVHWA_F_CKEY_SRC 0x00000004
|
---|
208 |
|
---|
209 | #define VBOXVHWA_MAX_FORMATS 8
|
---|
210 |
|
---|
211 | typedef struct VBOXVHWA_INFO
|
---|
212 | {
|
---|
213 | uint32_t fFlags;
|
---|
214 | uint32_t cOverlaysSupported;
|
---|
215 | uint32_t cFormats;
|
---|
216 | D3DDDIFORMAT aFormats[VBOXVHWA_MAX_FORMATS];
|
---|
217 | } VBOXVHWA_INFO;
|
---|
218 |
|
---|
219 | #define VBOXWDDM_OVERLAY_F_CKEY_DST 0x00000001
|
---|
220 | #define VBOXWDDM_OVERLAY_F_CKEY_DSTRANGE 0x00000002
|
---|
221 | #define VBOXWDDM_OVERLAY_F_CKEY_SRC 0x00000004
|
---|
222 | #define VBOXWDDM_OVERLAY_F_CKEY_SRCRANGE 0x00000008
|
---|
223 | #define VBOXWDDM_OVERLAY_F_BOB 0x00000010
|
---|
224 | #define VBOXWDDM_OVERLAY_F_INTERLEAVED 0x00000020
|
---|
225 | #define VBOXWDDM_OVERLAY_F_MIRROR_LR 0x00000040
|
---|
226 | #define VBOXWDDM_OVERLAY_F_MIRROR_UD 0x00000080
|
---|
227 | #define VBOXWDDM_OVERLAY_F_DEINTERLACED 0x00000100
|
---|
228 |
|
---|
229 | typedef struct VBOXWDDM_OVERLAY_DESC
|
---|
230 | {
|
---|
231 | uint32_t fFlags;
|
---|
232 | UINT DstColorKeyLow;
|
---|
233 | UINT DstColorKeyHigh;
|
---|
234 | UINT SrcColorKeyLow;
|
---|
235 | UINT SrcColorKeyHigh;
|
---|
236 | } VBOXWDDM_OVERLAY_DESC, *PVBOXWDDM_OVERLAY_DESC;
|
---|
237 |
|
---|
238 | typedef struct VBOXWDDM_OVERLAY_INFO
|
---|
239 | {
|
---|
240 | VBOXWDDM_OVERLAY_DESC OverlayDesc;
|
---|
241 | VBOXWDDM_DIRTYREGION DirtyRegion; /* <- the dirty region of the overlay surface */
|
---|
242 | } VBOXWDDM_OVERLAY_INFO, *PVBOXWDDM_OVERLAY_INFO;
|
---|
243 |
|
---|
244 | typedef struct VBOXWDDM_OVERLAYFLIP_INFO
|
---|
245 | {
|
---|
246 | VBOXWDDM_DIRTYREGION DirtyRegion; /* <- the dirty region of the overlay surface */
|
---|
247 | } VBOXWDDM_OVERLAYFLIP_INFO, *PVBOXWDDM_OVERLAYFLIP_INFO;
|
---|
248 |
|
---|
249 |
|
---|
250 | typedef enum
|
---|
251 | {
|
---|
252 | VBOXWDDM_CONTEXT_TYPE_UNDEFINED = 0,
|
---|
253 | /* system-created context (for GDI rendering) */
|
---|
254 | VBOXWDDM_CONTEXT_TYPE_SYSTEM,
|
---|
255 | /* context created by the D3D User-mode driver when crogl IS available */
|
---|
256 | obsolete_VBOXWDDM_CONTEXT_TYPE_CUSTOM_3D,
|
---|
257 | /* context created by the D3D User-mode driver when crogl is NOT available or for ddraw overlay acceleration */
|
---|
258 | obsolete_VBOXWDDM_CONTEXT_TYPE_CUSTOM_2D,
|
---|
259 | /* contexts created by the cromium HGSMI transport for HGSMI commands submission */
|
---|
260 | obsolete_VBOXWDDM_CONTEXT_TYPE_CUSTOM_UHGSMI_3D,
|
---|
261 | obsolete_VBOXWDDM_CONTEXT_TYPE_CUSTOM_UHGSMI_GL,
|
---|
262 | /* context created by the kernel->user communication mechanism for visible rects reporting, etc. */
|
---|
263 | VBOXWDDM_CONTEXT_TYPE_CUSTOM_SESSION,
|
---|
264 | /* context created by VBoxTray to handle resize operations */
|
---|
265 | VBOXWDDM_CONTEXT_TYPE_CUSTOM_DISPIF_RESIZE,
|
---|
266 | /* context created by VBoxTray to handle seamless operations */
|
---|
267 | VBOXWDDM_CONTEXT_TYPE_CUSTOM_DISPIF_SEAMLESS,
|
---|
268 | /* Gallium driver context. */
|
---|
269 | VBOXWDDM_CONTEXT_TYPE_GA_3D,
|
---|
270 | /* context to handle SVGA_3D_CMD_DX_* commands */
|
---|
271 | VBOXWDDM_CONTEXT_TYPE_VMSVGA_DX,
|
---|
272 | } VBOXWDDM_CONTEXT_TYPE;
|
---|
273 |
|
---|
274 | typedef struct VBOXWDDM_CREATECONTEXT_INFO
|
---|
275 | {
|
---|
276 | /* interface version, i.e. 9 for d3d9, 8 for d3d8, etc. */
|
---|
277 | uint32_t u32IfVersion;
|
---|
278 | /* What kind of context to create. */
|
---|
279 | VBOXWDDM_CONTEXT_TYPE enmType;
|
---|
280 | union
|
---|
281 | {
|
---|
282 | struct
|
---|
283 | {
|
---|
284 | uint32_t crVersionMajor;
|
---|
285 | uint32_t crVersionMinor;
|
---|
286 | /* we use uint64_t instead of HANDLE to ensure structure def is the same for both 32-bit and 64-bit
|
---|
287 | * since x64 kernel driver can be called by 32-bit UMD */
|
---|
288 | uint64_t hUmEvent;
|
---|
289 | /* info to be passed to UMD notification to identify the context */
|
---|
290 | uint64_t u64UmInfo;
|
---|
291 | } vbox;
|
---|
292 | #ifdef VBOX_WITH_MESA3D
|
---|
293 | struct
|
---|
294 | {
|
---|
295 | /* VBOXWDDM_F_GA_CONTEXT_* */
|
---|
296 | uint32_t u32Flags;
|
---|
297 | } vmsvga;
|
---|
298 | #endif
|
---|
299 | } u;
|
---|
300 | } VBOXWDDM_CREATECONTEXT_INFO, *PVBOXWDDM_CREATECONTEXT_INFO;
|
---|
301 |
|
---|
302 | typedef uint64_t VBOXDISP_UMHANDLE;
|
---|
303 | typedef uint32_t VBOXDISP_KMHANDLE;
|
---|
304 |
|
---|
305 | typedef struct VBOXWDDM_RECTS_FLAFS
|
---|
306 | {
|
---|
307 | union
|
---|
308 | {
|
---|
309 | struct
|
---|
310 | {
|
---|
311 | /* used only in conjunction with bSetVisibleRects.
|
---|
312 | * if set - VBOXWDDM_RECTS_INFO::aRects[0] contains view rectangle */
|
---|
313 | UINT bSetViewRect : 1;
|
---|
314 | /* adds visible regions */
|
---|
315 | UINT bAddVisibleRects : 1;
|
---|
316 | /* adds hidden regions */
|
---|
317 | UINT bAddHiddenRects : 1;
|
---|
318 | /* hide entire window */
|
---|
319 | UINT bHide : 1;
|
---|
320 | /* reserved */
|
---|
321 | UINT Reserved : 28;
|
---|
322 | };
|
---|
323 | uint32_t Value;
|
---|
324 | };
|
---|
325 | } VBOXWDDM_RECTS_FLAFS, *PVBOXWDDM_RECTS_FLAFS;
|
---|
326 |
|
---|
327 | typedef struct VBOXWDDM_RECTS_INFO
|
---|
328 | {
|
---|
329 | uint32_t cRects;
|
---|
330 | RECT aRects[1];
|
---|
331 | } VBOXWDDM_RECTS_INFO, *PVBOXWDDM_RECTS_INFO;
|
---|
332 |
|
---|
333 | #define VBOXWDDM_RECTS_INFO_SIZE4CRECTS(_cRects) (RT_UOFFSETOF_DYN(VBOXWDDM_RECTS_INFO, aRects[(_cRects)]))
|
---|
334 | #define VBOXWDDM_RECTS_INFO_SIZE(_pRects) (VBOXVIDEOCM_CMD_RECTS_SIZE4CRECTS((_pRects)->cRects))
|
---|
335 |
|
---|
336 | typedef enum
|
---|
337 | {
|
---|
338 | /* command to be post to user mode */
|
---|
339 | VBOXVIDEOCM_CMD_TYPE_UM = 0,
|
---|
340 | /* control command processed in kernel mode */
|
---|
341 | VBOXVIDEOCM_CMD_TYPE_CTL_KM,
|
---|
342 | VBOXVIDEOCM_CMD_DUMMY_32BIT = 0x7fffffff
|
---|
343 | } VBOXVIDEOCM_CMD_TYPE;
|
---|
344 |
|
---|
345 | typedef struct VBOXVIDEOCM_CMD_HDR
|
---|
346 | {
|
---|
347 | uint64_t u64UmData;
|
---|
348 | uint32_t cbCmd;
|
---|
349 | VBOXVIDEOCM_CMD_TYPE enmType;
|
---|
350 | }VBOXVIDEOCM_CMD_HDR, *PVBOXVIDEOCM_CMD_HDR;
|
---|
351 |
|
---|
352 | AssertCompile((sizeof (VBOXVIDEOCM_CMD_HDR) & 7) == 0);
|
---|
353 |
|
---|
354 | typedef struct VBOXVIDEOCM_CMD_RECTS
|
---|
355 | {
|
---|
356 | VBOXWDDM_RECTS_FLAFS fFlags;
|
---|
357 | VBOXWDDM_RECTS_INFO RectsInfo;
|
---|
358 | } VBOXVIDEOCM_CMD_RECTS, *PVBOXVIDEOCM_CMD_RECTS;
|
---|
359 |
|
---|
360 | typedef struct VBOXWDDM_GETVBOXVIDEOCMCMD_HDR
|
---|
361 | {
|
---|
362 | uint32_t cbCmdsReturned;
|
---|
363 | uint32_t cbRemainingCmds;
|
---|
364 | uint32_t cbRemainingFirstCmd;
|
---|
365 | uint32_t u32Reserved;
|
---|
366 | } VBOXWDDM_GETVBOXVIDEOCMCMD_HDR, *PVBOXWDDM_GETVBOXVIDEOCMCMD_HDR;
|
---|
367 |
|
---|
368 | typedef struct VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD
|
---|
369 | {
|
---|
370 | VBOXDISPIFESCAPE EscapeHdr;
|
---|
371 | VBOXWDDM_GETVBOXVIDEOCMCMD_HDR Hdr;
|
---|
372 | } VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD, *PVBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD;
|
---|
373 |
|
---|
374 | AssertCompile((sizeof (VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD) & 7) == 0);
|
---|
375 | AssertCompile(RT_OFFSETOF(VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD, EscapeHdr) == 0);
|
---|
376 |
|
---|
377 | typedef struct VBOXDISPIFESCAPE_DBGPRINT
|
---|
378 | {
|
---|
379 | VBOXDISPIFESCAPE EscapeHdr;
|
---|
380 | /* null-terminated string to DbgPrint including \0 */
|
---|
381 | char aStringBuf[1];
|
---|
382 | } VBOXDISPIFESCAPE_DBGPRINT, *PVBOXDISPIFESCAPE_DBGPRINT;
|
---|
383 | AssertCompile(RT_OFFSETOF(VBOXDISPIFESCAPE_DBGPRINT, EscapeHdr) == 0);
|
---|
384 |
|
---|
385 | typedef enum
|
---|
386 | {
|
---|
387 | VBOXDISPIFESCAPE_DBGDUMPBUF_TYPE_UNDEFINED = 0,
|
---|
388 | VBOXDISPIFESCAPE_DBGDUMPBUF_TYPE_D3DCAPS9 = 1,
|
---|
389 | VBOXDISPIFESCAPE_DBGDUMPBUF_TYPE_DUMMY32BIT = 0x7fffffff
|
---|
390 | } VBOXDISPIFESCAPE_DBGDUMPBUF_TYPE;
|
---|
391 |
|
---|
392 | typedef struct VBOXDISPIFESCAPE_DBGDUMPBUF_FLAGS
|
---|
393 | {
|
---|
394 | union
|
---|
395 | {
|
---|
396 | struct
|
---|
397 | {
|
---|
398 | UINT WoW64 : 1;
|
---|
399 | UINT Reserved : 31; /* reserved */
|
---|
400 | };
|
---|
401 | UINT Value;
|
---|
402 | };
|
---|
403 | } VBOXDISPIFESCAPE_DBGDUMPBUF_FLAGS, *PVBOXDISPIFESCAPE_DBGDUMPBUF_FLAGS;
|
---|
404 |
|
---|
405 | typedef struct VBOXDISPIFESCAPE_DBGDUMPBUF
|
---|
406 | {
|
---|
407 | VBOXDISPIFESCAPE EscapeHdr;
|
---|
408 | VBOXDISPIFESCAPE_DBGDUMPBUF_TYPE enmType;
|
---|
409 | VBOXDISPIFESCAPE_DBGDUMPBUF_FLAGS Flags;
|
---|
410 | char aBuf[1];
|
---|
411 | } VBOXDISPIFESCAPE_DBGDUMPBUF, *PVBOXDISPIFESCAPE_DBGDUMPBUF;
|
---|
412 | AssertCompile(RT_OFFSETOF(VBOXDISPIFESCAPE_DBGDUMPBUF, EscapeHdr) == 0);
|
---|
413 |
|
---|
414 | typedef struct VBOXVIDEOCM_UM_ALLOC
|
---|
415 | {
|
---|
416 | VBOXDISP_KMHANDLE hAlloc;
|
---|
417 | uint32_t cbData;
|
---|
418 | uint64_t pvData;
|
---|
419 | uint64_t hSynch;
|
---|
420 | VBOXUHGSMI_BUFFER_TYPE_FLAGS fUhgsmiType;
|
---|
421 | } VBOXVIDEOCM_UM_ALLOC, *PVBOXVIDEOCM_UM_ALLOC;
|
---|
422 |
|
---|
423 | typedef struct VBOXDISPIFESCAPE_SETALLOCHOSTID
|
---|
424 | {
|
---|
425 | VBOXDISPIFESCAPE EscapeHdr;
|
---|
426 | int32_t rc;
|
---|
427 | uint32_t hostID;
|
---|
428 | uint64_t hAlloc;
|
---|
429 |
|
---|
430 | } VBOXDISPIFESCAPE_SETALLOCHOSTID, *PVBOXDISPIFESCAPE_SETALLOCHOSTID;
|
---|
431 |
|
---|
432 | #ifdef VBOX_WITH_MESA3D
|
---|
433 |
|
---|
434 | #define VBOXWDDM_F_GA_CONTEXT_EXTENDED 0x00000001
|
---|
435 | #define VBOXWDDM_F_GA_CONTEXT_VGPU10 0x00000002
|
---|
436 |
|
---|
437 | #define VBOXESC_GAGETCID 0xA0000002
|
---|
438 | #define VBOXESC_GAREGION 0xA0000003
|
---|
439 | #define VBOXESC_GAPRESENT 0xA0000004
|
---|
440 | #define VBOXESC_GASURFACEDEFINE 0xA0000005
|
---|
441 | #define VBOXESC_GASURFACEDESTROY 0xA0000006
|
---|
442 | #define VBOXESC_GASHAREDSID 0xA0000008
|
---|
443 | #define VBOXESC_GAFENCECREATE 0xA0000020
|
---|
444 | #define VBOXESC_GAFENCEQUERY 0xA0000021
|
---|
445 | #define VBOXESC_GAFENCEWAIT 0xA0000022
|
---|
446 | #define VBOXESC_GAFENCEUNREF 0xA0000023
|
---|
447 |
|
---|
448 | /* Get Gallium context id (cid) of the WDDM context. */
|
---|
449 | typedef struct VBOXDISPIFESCAPE_GAGETCID
|
---|
450 | {
|
---|
451 | VBOXDISPIFESCAPE EscapeHdr;
|
---|
452 | uint32_t u32Cid;
|
---|
453 | } VBOXDISPIFESCAPE_GAGETCID;
|
---|
454 |
|
---|
455 | /* Create or delete a Guest Memory Region (GMR). */
|
---|
456 | #define GA_REGION_CMD_CREATE 0
|
---|
457 | #define GA_REGION_CMD_DESTROY 1
|
---|
458 | typedef struct VBOXDISPIFESCAPE_GAREGION
|
---|
459 | {
|
---|
460 | VBOXDISPIFESCAPE EscapeHdr;
|
---|
461 | uint32_t u32Command;
|
---|
462 | uint32_t u32GmrId;
|
---|
463 | uint32_t u32NumPages;
|
---|
464 | uint32_t u32Reserved;
|
---|
465 | uint64_t u64UserAddress;
|
---|
466 | } VBOXDISPIFESCAPE_GAREGION;
|
---|
467 |
|
---|
468 | /* Debug helper. Present the specified surface by copying to the guest screen VRAM. */
|
---|
469 | typedef struct VBOXDISPIFESCAPE_GAPRESENT
|
---|
470 | {
|
---|
471 | VBOXDISPIFESCAPE EscapeHdr;
|
---|
472 | uint32_t u32Sid;
|
---|
473 | uint32_t u32Width;
|
---|
474 | uint32_t u32Height;
|
---|
475 | } VBOXDISPIFESCAPE_GAPRESENT;
|
---|
476 |
|
---|
477 | /* Create a host surface. */
|
---|
478 | typedef struct VBOXDISPIFESCAPE_GASURFACEDEFINE
|
---|
479 | {
|
---|
480 | VBOXDISPIFESCAPE EscapeHdr;
|
---|
481 | uint32_t u32Sid; /* Returned surface id. */
|
---|
482 | uint32_t cbReq; /* Size of data after cSizes field. */
|
---|
483 | uint32_t cSizes; /* Number of GASURFSIZE structures. */
|
---|
484 | /* GASURFCREATE */
|
---|
485 | /* GASURFSIZE[cSizes] */
|
---|
486 | } VBOXDISPIFESCAPE_GASURFACEDEFINE;
|
---|
487 |
|
---|
488 | /* Delete a host surface. */
|
---|
489 | typedef struct VBOXDISPIFESCAPE_GASURFACEDESTROY
|
---|
490 | {
|
---|
491 | VBOXDISPIFESCAPE EscapeHdr;
|
---|
492 | uint32_t u32Sid;
|
---|
493 | } VBOXDISPIFESCAPE_GASURFACEDESTROY;
|
---|
494 |
|
---|
495 | /* Inform the miniport that 'u32Sid' actually maps to 'u32SharedSid'.
|
---|
496 | * If 'u32SharedSid' is ~0, then remove the mapping.
|
---|
497 | */
|
---|
498 | typedef struct VBOXDISPIFESCAPE_GASHAREDSID
|
---|
499 | {
|
---|
500 | VBOXDISPIFESCAPE EscapeHdr;
|
---|
501 | uint32_t u32Sid;
|
---|
502 | uint32_t u32SharedSid;
|
---|
503 | } VBOXDISPIFESCAPE_GASHAREDSID;
|
---|
504 |
|
---|
505 | /* Create a user mode fence object. */
|
---|
506 | typedef struct VBOXDISPIFESCAPE_GAFENCECREATE
|
---|
507 | {
|
---|
508 | VBOXDISPIFESCAPE EscapeHdr;
|
---|
509 |
|
---|
510 | /* IN: The miniport's handle of the fence.
|
---|
511 | * Assigned by the miniport. Not DXGK fence id!
|
---|
512 | */
|
---|
513 | uint32_t u32FenceHandle;
|
---|
514 | } VBOXDISPIFESCAPE_GAFENCECREATE;
|
---|
515 |
|
---|
516 | /* Query a user mode fence object state. */
|
---|
517 | #define GA_FENCE_STATUS_NULL 0 /* Fence not found */
|
---|
518 | #define GA_FENCE_STATUS_IDLE 1
|
---|
519 | #define GA_FENCE_STATUS_SUBMITTED 2
|
---|
520 | #define GA_FENCE_STATUS_SIGNALED 3
|
---|
521 | typedef struct VBOXDISPIFESCAPE_GAFENCEQUERY
|
---|
522 | {
|
---|
523 | VBOXDISPIFESCAPE EscapeHdr;
|
---|
524 |
|
---|
525 | /* IN: The miniport's handle of the fence.
|
---|
526 | * Assigned by the miniport. Not DXGK fence id!
|
---|
527 | */
|
---|
528 | uint32_t u32FenceHandle;
|
---|
529 |
|
---|
530 | /* OUT: The miniport's sequence number associated with the command buffer.
|
---|
531 | */
|
---|
532 | uint32_t u32SubmittedSeqNo;
|
---|
533 |
|
---|
534 | /* OUT: The miniport's sequence number associated with the last command buffer completed on host.
|
---|
535 | */
|
---|
536 | uint32_t u32ProcessedSeqNo;
|
---|
537 |
|
---|
538 | /* OUT: GA_FENCE_STATUS_*. */
|
---|
539 | uint32_t u32FenceStatus;
|
---|
540 | } VBOXDISPIFESCAPE_GAFENCEQUERY;
|
---|
541 |
|
---|
542 | /* Wait on a user mode fence object. */
|
---|
543 | typedef struct VBOXDISPIFESCAPE_GAFENCEWAIT
|
---|
544 | {
|
---|
545 | VBOXDISPIFESCAPE EscapeHdr;
|
---|
546 |
|
---|
547 | /* IN: The miniport's handle of the fence.
|
---|
548 | * Assigned by the miniport. Not DXGK fence id!
|
---|
549 | */
|
---|
550 | uint32_t u32FenceHandle;
|
---|
551 |
|
---|
552 | /* IN: Timeout in microseconds.
|
---|
553 | */
|
---|
554 | uint32_t u32TimeoutUS;
|
---|
555 | } VBOXDISPIFESCAPE_GAFENCEWAIT;
|
---|
556 |
|
---|
557 | /* Delete a user mode fence object. */
|
---|
558 | typedef struct VBOXDISPIFESCAPE_GAFENCEUNREF
|
---|
559 | {
|
---|
560 | VBOXDISPIFESCAPE EscapeHdr;
|
---|
561 |
|
---|
562 | /* IN: The miniport's handle of the fence.
|
---|
563 | * Assigned by the miniport. Not DXGK fence id!
|
---|
564 | */
|
---|
565 | uint32_t u32FenceHandle;
|
---|
566 | } VBOXDISPIFESCAPE_GAFENCEUNREF;
|
---|
567 |
|
---|
568 | #endif /* VBOX_WITH_MESA3D */
|
---|
569 |
|
---|
570 | #if defined(VBOX_WITH_MESA3D) || defined(VBOX_WITH_VMSVGA3D_DX)
|
---|
571 | #include <VBoxGaHWInfo.h>
|
---|
572 | #endif
|
---|
573 |
|
---|
574 | #define VBOXWDDM_QAI_CAP_3D 0x00000001 /* 3D is enabled in the VM settings. */
|
---|
575 | #define VBOXWDDM_QAI_CAP_DXVA 0x00000002 /* DXVA is not disabled in the guest registry. */
|
---|
576 | #define VBOXWDDM_QAI_CAP_DXVAHD 0x00000004 /* DXVA-HD is not disabled in the guest registry. */
|
---|
577 | #define VBOXWDDM_QAI_CAP_WIN7 0x00000008 /* User mode driver can report D3D_UMD_INTERFACE_VERSION_WIN7. */
|
---|
578 |
|
---|
579 | /* D3DDDICB_QUERYADAPTERINFO::pPrivateDriverData */
|
---|
580 | typedef struct VBOXWDDM_QAI
|
---|
581 | {
|
---|
582 | uint32_t u32Version; /* VBOXVIDEOIF_VERSION */
|
---|
583 | uint32_t u32Reserved; /* Must be 0. */
|
---|
584 | VBOXVIDEO_HWTYPE enmHwType; /* Hardware type. Determines what kind of data is returned. */
|
---|
585 | uint32_t u32AdapterCaps; /* VBOXWDDM_QAI_CAP_* */
|
---|
586 | uint32_t cInfos; /* Number of initialized elements in aInfos (equal to number of guest
|
---|
587 | * displays). 0 if VBOX_WITH_VIDEOHWACCEL is not defined. */
|
---|
588 | VBOXVHWA_INFO aInfos[VBOX_VIDEO_MAX_SCREENS]; /* cInfos elements are initialized. */
|
---|
589 | union
|
---|
590 | {
|
---|
591 | struct
|
---|
592 | {
|
---|
593 | /* VBOXVIDEO_HWTYPE_VBOX */
|
---|
594 | uint32_t u32VBox3DCaps; /* CR_VBOX_CAP_* */
|
---|
595 | } vbox;
|
---|
596 | #if defined(VBOX_WITH_MESA3D) || defined(VBOX_WITH_VMSVGA3D_DX)
|
---|
597 | struct
|
---|
598 | {
|
---|
599 | /* VBOXVIDEO_HWTYPE_VMSVGA */
|
---|
600 | VBOXGAHWINFO HWInfo;
|
---|
601 | } vmsvga;
|
---|
602 | #endif
|
---|
603 | } u;
|
---|
604 | } VBOXWDDM_QAI;
|
---|
605 |
|
---|
606 | /** Convert a given FourCC code to a D3DDDIFORMAT enum. */
|
---|
607 | #define VBOXWDDM_D3DDDIFORMAT_FROM_FOURCC(_a, _b, _c, _d) \
|
---|
608 | ((D3DDDIFORMAT)MAKEFOURCC(_a, _b, _c, _d))
|
---|
609 |
|
---|
610 | /* submit cmd func */
|
---|
611 | DECLINLINE(D3DDDIFORMAT) vboxWddmFmtNoAlphaFormat(D3DDDIFORMAT enmFormat)
|
---|
612 | {
|
---|
613 | switch (enmFormat)
|
---|
614 | {
|
---|
615 | case D3DDDIFMT_A8R8G8B8:
|
---|
616 | return D3DDDIFMT_X8R8G8B8;
|
---|
617 | case D3DDDIFMT_A1R5G5B5:
|
---|
618 | return D3DDDIFMT_X1R5G5B5;
|
---|
619 | case D3DDDIFMT_A4R4G4B4:
|
---|
620 | return D3DDDIFMT_X4R4G4B4;
|
---|
621 | case D3DDDIFMT_A8B8G8R8:
|
---|
622 | return D3DDDIFMT_X8B8G8R8;
|
---|
623 | default:
|
---|
624 | return enmFormat;
|
---|
625 | }
|
---|
626 | }
|
---|
627 |
|
---|
628 | /* tooling */
|
---|
629 | DECLINLINE(UINT) vboxWddmCalcBitsPerPixel(D3DDDIFORMAT enmFormat)
|
---|
630 | {
|
---|
631 | #ifdef _MSC_VER
|
---|
632 | # pragma warning(push)
|
---|
633 | # pragma warning(disable:4063) /* VBOXWDDM_D3DDDIFORMAT_FROM_FOURCC('Y', 'V', '1', '2'): isn't part of the enum */
|
---|
634 | #endif
|
---|
635 | switch (enmFormat)
|
---|
636 | {
|
---|
637 | case D3DDDIFMT_R8G8B8:
|
---|
638 | return 24;
|
---|
639 | case D3DDDIFMT_A8R8G8B8:
|
---|
640 | case D3DDDIFMT_X8R8G8B8:
|
---|
641 | return 32;
|
---|
642 | case D3DDDIFMT_R5G6B5:
|
---|
643 | case D3DDDIFMT_X1R5G5B5:
|
---|
644 | case D3DDDIFMT_A1R5G5B5:
|
---|
645 | case D3DDDIFMT_A4R4G4B4:
|
---|
646 | return 16;
|
---|
647 | case D3DDDIFMT_R3G3B2:
|
---|
648 | case D3DDDIFMT_A8:
|
---|
649 | return 8;
|
---|
650 | case D3DDDIFMT_A8R3G3B2:
|
---|
651 | case D3DDDIFMT_X4R4G4B4:
|
---|
652 | return 16;
|
---|
653 | case D3DDDIFMT_A2B10G10R10:
|
---|
654 | case D3DDDIFMT_A8B8G8R8:
|
---|
655 | case D3DDDIFMT_X8B8G8R8:
|
---|
656 | case D3DDDIFMT_G16R16:
|
---|
657 | case D3DDDIFMT_A2R10G10B10:
|
---|
658 | return 32;
|
---|
659 | case D3DDDIFMT_A16B16G16R16:
|
---|
660 | case D3DDDIFMT_A16B16G16R16F:
|
---|
661 | return 64;
|
---|
662 | case D3DDDIFMT_A32B32G32R32F:
|
---|
663 | return 128;
|
---|
664 | case D3DDDIFMT_A8P8:
|
---|
665 | return 16;
|
---|
666 | case D3DDDIFMT_P8:
|
---|
667 | case D3DDDIFMT_L8:
|
---|
668 | return 8;
|
---|
669 | case D3DDDIFMT_L16:
|
---|
670 | case D3DDDIFMT_A8L8:
|
---|
671 | return 16;
|
---|
672 | case D3DDDIFMT_A4L4:
|
---|
673 | return 8;
|
---|
674 | case D3DDDIFMT_V8U8:
|
---|
675 | case D3DDDIFMT_L6V5U5:
|
---|
676 | return 16;
|
---|
677 | case D3DDDIFMT_X8L8V8U8:
|
---|
678 | case D3DDDIFMT_Q8W8V8U8:
|
---|
679 | case D3DDDIFMT_V16U16:
|
---|
680 | case D3DDDIFMT_W11V11U10:
|
---|
681 | case D3DDDIFMT_A2W10V10U10:
|
---|
682 | return 32;
|
---|
683 | case D3DDDIFMT_D16_LOCKABLE:
|
---|
684 | case D3DDDIFMT_D16:
|
---|
685 | case D3DDDIFMT_D15S1:
|
---|
686 | return 16;
|
---|
687 | case D3DDDIFMT_D32:
|
---|
688 | case D3DDDIFMT_D24S8:
|
---|
689 | case D3DDDIFMT_D24X8:
|
---|
690 | case D3DDDIFMT_D24X4S4:
|
---|
691 | case D3DDDIFMT_D24FS8:
|
---|
692 | case D3DDDIFMT_D32_LOCKABLE:
|
---|
693 | case D3DDDIFMT_D32F_LOCKABLE:
|
---|
694 | return 32;
|
---|
695 | case D3DDDIFMT_S8_LOCKABLE:
|
---|
696 | return 8;
|
---|
697 | case D3DDDIFMT_DXT1:
|
---|
698 | return 4;
|
---|
699 | case D3DDDIFMT_DXT2:
|
---|
700 | case D3DDDIFMT_DXT3:
|
---|
701 | case D3DDDIFMT_DXT4:
|
---|
702 | case D3DDDIFMT_DXT5:
|
---|
703 | case D3DDDIFMT_VERTEXDATA:
|
---|
704 | case D3DDDIFMT_INDEX16: /* <- yes, dx runtime treats it as such */
|
---|
705 | return 8;
|
---|
706 | case D3DDDIFMT_INDEX32:
|
---|
707 | return 8;
|
---|
708 | case D3DDDIFMT_R32F:
|
---|
709 | return 32;
|
---|
710 | case D3DDDIFMT_G32R32F:
|
---|
711 | return 64;
|
---|
712 | case D3DDDIFMT_R16F:
|
---|
713 | return 16;
|
---|
714 | case D3DDDIFMT_G16R16F:
|
---|
715 | return 32;
|
---|
716 | case D3DDDIFMT_YUY2: /* 4 bytes per 2 pixels. */
|
---|
717 | case VBOXWDDM_D3DDDIFORMAT_FROM_FOURCC('Y', 'V', '1', '2'):
|
---|
718 | return 16;
|
---|
719 | default:
|
---|
720 | AssertBreakpoint();
|
---|
721 | return 0;
|
---|
722 | }
|
---|
723 | #ifdef _MSC_VER
|
---|
724 | # pragma warning(pop)
|
---|
725 | #endif
|
---|
726 | }
|
---|
727 |
|
---|
728 | DECLINLINE(uint32_t) vboxWddmFormatToFourcc(D3DDDIFORMAT enmFormat)
|
---|
729 | {
|
---|
730 | uint32_t uFormat = (uint32_t)enmFormat;
|
---|
731 | /* assume that in case both four bytes are non-zero, this is a fourcc */
|
---|
732 | if ((uFormat & 0xff000000)
|
---|
733 | && (uFormat & 0x00ff0000)
|
---|
734 | && (uFormat & 0x0000ff00)
|
---|
735 | && (uFormat & 0x000000ff)
|
---|
736 | )
|
---|
737 | return uFormat;
|
---|
738 | return 0;
|
---|
739 | }
|
---|
740 |
|
---|
741 | #define VBOXWDDM_ROUNDBOUND(_v, _b) (((_v) + ((_b) - 1)) & ~((_b) - 1))
|
---|
742 |
|
---|
743 | DECLINLINE(UINT) vboxWddmCalcOffXru(UINT w, D3DDDIFORMAT enmFormat)
|
---|
744 | {
|
---|
745 | switch (enmFormat)
|
---|
746 | {
|
---|
747 | /* pitch for the DXT* (aka compressed) formats is the size in bytes of blocks that fill in an image width
|
---|
748 | * i.e. each block decompressed into 4 x 4 pixels, so we have ((Width + 3) / 4) blocks for Width.
|
---|
749 | * then each block has 64 bits (8 bytes) for DXT1 and 64+64 bits (16 bytes) for DXT2-DXT5, so.. : */
|
---|
750 | case D3DDDIFMT_DXT1:
|
---|
751 | {
|
---|
752 | UINT Pitch = (w + 3) / 4; /* <- pitch size in blocks */
|
---|
753 | Pitch *= 8; /* <- pitch size in bytes */
|
---|
754 | return Pitch;
|
---|
755 | }
|
---|
756 | case D3DDDIFMT_DXT2:
|
---|
757 | case D3DDDIFMT_DXT3:
|
---|
758 | case D3DDDIFMT_DXT4:
|
---|
759 | case D3DDDIFMT_DXT5:
|
---|
760 | {
|
---|
761 | UINT Pitch = (w + 3) / 4; /* <- pitch size in blocks */
|
---|
762 | Pitch *= 16; /* <- pitch size in bytes */
|
---|
763 | return Pitch;
|
---|
764 | }
|
---|
765 | default:
|
---|
766 | {
|
---|
767 | /* the default is just to calculate the pitch from bpp */
|
---|
768 | UINT bpp = vboxWddmCalcBitsPerPixel(enmFormat);
|
---|
769 | UINT Pitch = bpp * w;
|
---|
770 | /* pitch is now in bits, translate in bytes */
|
---|
771 | return VBOXWDDM_ROUNDBOUND(Pitch, 8) >> 3;
|
---|
772 | }
|
---|
773 | }
|
---|
774 | }
|
---|
775 |
|
---|
776 | DECLINLINE(UINT) vboxWddmCalcOffXrd(UINT w, D3DDDIFORMAT enmFormat)
|
---|
777 | {
|
---|
778 | switch (enmFormat)
|
---|
779 | {
|
---|
780 | /* pitch for the DXT* (aka compressed) formats is the size in bytes of blocks that fill in an image width
|
---|
781 | * i.e. each block decompressed into 4 x 4 pixels, so we have ((Width + 3) / 4) blocks for Width.
|
---|
782 | * then each block has 64 bits (8 bytes) for DXT1 and 64+64 bits (16 bytes) for DXT2-DXT5, so.. : */
|
---|
783 | case D3DDDIFMT_DXT1:
|
---|
784 | {
|
---|
785 | UINT Pitch = w / 4; /* <- pitch size in blocks */
|
---|
786 | Pitch *= 8; /* <- pitch size in bytes */
|
---|
787 | return Pitch;
|
---|
788 | }
|
---|
789 | case D3DDDIFMT_DXT2:
|
---|
790 | case D3DDDIFMT_DXT3:
|
---|
791 | case D3DDDIFMT_DXT4:
|
---|
792 | case D3DDDIFMT_DXT5:
|
---|
793 | {
|
---|
794 | UINT Pitch = w / 4; /* <- pitch size in blocks */
|
---|
795 | Pitch *= 16; /* <- pitch size in bytes */
|
---|
796 | return Pitch;
|
---|
797 | }
|
---|
798 | default:
|
---|
799 | {
|
---|
800 | /* the default is just to calculate the pitch from bpp */
|
---|
801 | UINT bpp = vboxWddmCalcBitsPerPixel(enmFormat);
|
---|
802 | UINT Pitch = bpp * w;
|
---|
803 | /* pitch is now in bits, translate in bytes */
|
---|
804 | return Pitch >> 3;
|
---|
805 | }
|
---|
806 | }
|
---|
807 | }
|
---|
808 |
|
---|
809 | DECLINLINE(UINT) vboxWddmCalcHightPacking(D3DDDIFORMAT enmFormat)
|
---|
810 | {
|
---|
811 | switch (enmFormat)
|
---|
812 | {
|
---|
813 | /* for the DXT* (aka compressed) formats each block is decompressed into 4 x 4 pixels,
|
---|
814 | * so packing is 4
|
---|
815 | */
|
---|
816 | case D3DDDIFMT_DXT1:
|
---|
817 | case D3DDDIFMT_DXT2:
|
---|
818 | case D3DDDIFMT_DXT3:
|
---|
819 | case D3DDDIFMT_DXT4:
|
---|
820 | case D3DDDIFMT_DXT5:
|
---|
821 | return 4;
|
---|
822 | default:
|
---|
823 | return 1;
|
---|
824 | }
|
---|
825 | }
|
---|
826 |
|
---|
827 | DECLINLINE(UINT) vboxWddmCalcOffYru(UINT height, D3DDDIFORMAT enmFormat)
|
---|
828 | {
|
---|
829 | UINT packing = vboxWddmCalcHightPacking(enmFormat);
|
---|
830 | /* round it up */
|
---|
831 | return (height + packing - 1) / packing;
|
---|
832 | }
|
---|
833 |
|
---|
834 | DECLINLINE(UINT) vboxWddmCalcOffYrd(UINT height, D3DDDIFORMAT enmFormat)
|
---|
835 | {
|
---|
836 | UINT packing = vboxWddmCalcHightPacking(enmFormat);
|
---|
837 | /* round it up */
|
---|
838 | return height / packing;
|
---|
839 | }
|
---|
840 |
|
---|
841 | DECLINLINE(UINT) vboxWddmCalcPitch(UINT w, D3DDDIFORMAT enmFormat)
|
---|
842 | {
|
---|
843 | return vboxWddmCalcOffXru(w, enmFormat);
|
---|
844 | }
|
---|
845 |
|
---|
846 | DECLINLINE(UINT) vboxWddmCalcWidthForPitch(UINT Pitch, D3DDDIFORMAT enmFormat)
|
---|
847 | {
|
---|
848 | switch (enmFormat)
|
---|
849 | {
|
---|
850 | /* pitch for the DXT* (aka compressed) formats is the size in bytes of blocks that fill in an image width
|
---|
851 | * i.e. each block decompressed into 4 x 4 pixels, so we have ((Width + 3) / 4) blocks for Width.
|
---|
852 | * then each block has 64 bits (8 bytes) for DXT1 and 64+64 bits (16 bytes) for DXT2-DXT5, so.. : */
|
---|
853 | case D3DDDIFMT_DXT1:
|
---|
854 | {
|
---|
855 | return (Pitch / 8) * 4;
|
---|
856 | }
|
---|
857 | case D3DDDIFMT_DXT2:
|
---|
858 | case D3DDDIFMT_DXT3:
|
---|
859 | case D3DDDIFMT_DXT4:
|
---|
860 | case D3DDDIFMT_DXT5:
|
---|
861 | {
|
---|
862 | return (Pitch / 16) * 4;;
|
---|
863 | }
|
---|
864 | default:
|
---|
865 | {
|
---|
866 | /* the default is just to calculate it from bpp */
|
---|
867 | UINT bpp = vboxWddmCalcBitsPerPixel(enmFormat);
|
---|
868 | return (Pitch << 3) / bpp;
|
---|
869 | }
|
---|
870 | }
|
---|
871 | }
|
---|
872 |
|
---|
873 | DECLINLINE(UINT) vboxWddmCalcNumRows(UINT top, UINT bottom, D3DDDIFORMAT enmFormat)
|
---|
874 | {
|
---|
875 | Assert(bottom > top);
|
---|
876 | top = top ? vboxWddmCalcOffYrd(top, enmFormat) : 0; /* <- just to optimize it a bit */
|
---|
877 | bottom = vboxWddmCalcOffYru(bottom, enmFormat);
|
---|
878 | return bottom - top;
|
---|
879 | }
|
---|
880 |
|
---|
881 | DECLINLINE(UINT) vboxWddmCalcRowSize(UINT left, UINT right, D3DDDIFORMAT enmFormat)
|
---|
882 | {
|
---|
883 | Assert(right > left);
|
---|
884 | left = left ? vboxWddmCalcOffXrd(left, enmFormat) : 0; /* <- just to optimize it a bit */
|
---|
885 | right = vboxWddmCalcOffXru(right, enmFormat);
|
---|
886 | return right - left;
|
---|
887 | }
|
---|
888 |
|
---|
889 | DECLINLINE(UINT) vboxWddmCalcSize(UINT pitch, UINT height, D3DDDIFORMAT enmFormat)
|
---|
890 | {
|
---|
891 | UINT cRows = vboxWddmCalcNumRows(0, height, enmFormat);
|
---|
892 | return pitch * cRows;
|
---|
893 | }
|
---|
894 |
|
---|
895 | DECLINLINE(UINT) vboxWddmCalcOffXYrd(UINT x, UINT y, UINT pitch, D3DDDIFORMAT enmFormat)
|
---|
896 | {
|
---|
897 | UINT offY = 0;
|
---|
898 | if (y)
|
---|
899 | offY = vboxWddmCalcSize(pitch, y, enmFormat);
|
---|
900 |
|
---|
901 | return offY + vboxWddmCalcOffXrd(x, enmFormat);
|
---|
902 | }
|
---|
903 |
|
---|
904 | #define VBOXWDDM_ARRAY_MAXELEMENTSU32(_t) ((uint32_t)((UINT32_MAX) / sizeof (_t)))
|
---|
905 | #define VBOXWDDM_TRAILARRAY_MAXELEMENTSU32(_t, _af) ((uint32_t)(((~(0UL)) - (uint32_t)RT_OFFSETOF(_t, _af[0])) / RT_SIZEOFMEMB(_t, _af[0])))
|
---|
906 |
|
---|
907 | #endif /* !GA_INCLUDED_SRC_WINNT_Graphics_Video_common_wddm_VBoxMPIf_h */
|
---|