1 | /* $Id: VBoxMPDevExt.h 80876 2019-09-18 06:09:19Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Miniport device extension header
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2011-2019 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef GA_INCLUDED_SRC_WINNT_Graphics_Video_mp_common_VBoxMPDevExt_h
|
---|
19 | #define GA_INCLUDED_SRC_WINNT_Graphics_Video_mp_common_VBoxMPDevExt_h
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | #include "VBoxMPUtils.h"
|
---|
25 | #include <VBoxVideoGuest.h>
|
---|
26 | #include <HGSMIHostCmd.h>
|
---|
27 |
|
---|
28 | #ifdef VBOX_XPDM_MINIPORT
|
---|
29 | # include <iprt/nt/miniport.h>
|
---|
30 | # include <ntddvdeo.h>
|
---|
31 | # include <iprt/nt/video.h>
|
---|
32 | # include "common/xpdm/VBoxVideoPortAPI.h"
|
---|
33 | #endif
|
---|
34 |
|
---|
35 | #ifdef VBOX_WDDM_MINIPORT
|
---|
36 | extern DWORD g_VBoxDisplayOnly;
|
---|
37 | # include "wddm/VBoxMPTypes.h"
|
---|
38 | #endif
|
---|
39 |
|
---|
40 | #ifdef VBOX_WDDM_MINIPORT
|
---|
41 | typedef struct VBOXWDDM_HWRESOURCES
|
---|
42 | {
|
---|
43 | PHYSICAL_ADDRESS phVRAM;
|
---|
44 | ULONG cbVRAM;
|
---|
45 | ULONG ulApertureSize;
|
---|
46 | #ifdef VBOX_WITH_MESA3D
|
---|
47 | PHYSICAL_ADDRESS phFIFO;
|
---|
48 | ULONG cbFIFO;
|
---|
49 | PHYSICAL_ADDRESS phIO;
|
---|
50 | ULONG cbIO;
|
---|
51 | #endif
|
---|
52 | } VBOXWDDM_HWRESOURCES, *PVBOXWDDM_HWRESOURCES;
|
---|
53 |
|
---|
54 | #ifdef VBOX_WITH_MESA3D
|
---|
55 | typedef struct VBOXWDDM_EXT_GA *PVBOXWDDM_EXT_GA;
|
---|
56 | #endif
|
---|
57 |
|
---|
58 | #endif /* VBOX_WDDM_MINIPORT */
|
---|
59 |
|
---|
60 | #define VBOXMP_MAX_VIDEO_MODES 128
|
---|
61 | typedef struct VBOXMP_COMMON
|
---|
62 | {
|
---|
63 | int cDisplays; /* Number of displays. */
|
---|
64 |
|
---|
65 | uint32_t cbVRAM; /* The VRAM size. */
|
---|
66 |
|
---|
67 | PHYSICAL_ADDRESS phVRAM; /* Physical VRAM base. */
|
---|
68 |
|
---|
69 | ULONG ulApertureSize; /* Size of the LFB aperture (>= VRAM size). */
|
---|
70 |
|
---|
71 | uint32_t cbMiniportHeap; /* The size of reserved VRAM for miniport driver heap.
|
---|
72 | * It is at offset:
|
---|
73 | * cbAdapterMemorySize - VBOX_VIDEO_ADAPTER_INFORMATION_SIZE - cbMiniportHeap
|
---|
74 | */
|
---|
75 | void *pvMiniportHeap; /* The pointer to the miniport heap VRAM.
|
---|
76 | * This is mapped by miniport separately.
|
---|
77 | */
|
---|
78 | void *pvAdapterInformation; /* The pointer to the last 4K of VRAM.
|
---|
79 | * This is mapped by miniport separately.
|
---|
80 | */
|
---|
81 |
|
---|
82 | /** Whether HGSMI is enabled. */
|
---|
83 | bool bHGSMI;
|
---|
84 | /** Context information needed to receive commands from the host. */
|
---|
85 | HGSMIHOSTCOMMANDCONTEXT hostCtx;
|
---|
86 | /** Context information needed to submit commands to the host. */
|
---|
87 | HGSMIGUESTCOMMANDCONTEXT guestCtx;
|
---|
88 |
|
---|
89 | BOOLEAN fAnyX; /* Unrestricted horizontal resolution flag. */
|
---|
90 | uint16_t u16SupportedScreenFlags; /* VBVA_SCREEN_F_* flags supported by the host. */
|
---|
91 | } VBOXMP_COMMON, *PVBOXMP_COMMON;
|
---|
92 |
|
---|
93 | typedef struct _VBOXMP_DEVEXT
|
---|
94 | {
|
---|
95 | struct _VBOXMP_DEVEXT *pNext; /* Next extension in the DualView extension list.
|
---|
96 | * The primary extension is the first one.
|
---|
97 | */
|
---|
98 | #ifdef VBOX_XPDM_MINIPORT
|
---|
99 | struct _VBOXMP_DEVEXT *pPrimary; /* Pointer to the primary device extension. */
|
---|
100 |
|
---|
101 | ULONG iDevice; /* Device index: 0 for primary, otherwise a secondary device. */
|
---|
102 | /* Standart video modes list.
|
---|
103 | * Additional space is reserved for a custom video mode for this guest monitor.
|
---|
104 | * The custom video mode index is alternating for each mode set and 2 indexes are needed for the custom mode.
|
---|
105 | */
|
---|
106 | VIDEO_MODE_INFORMATION aVideoModes[VBOXMP_MAX_VIDEO_MODES + 2];
|
---|
107 | /* Number of available video modes, set by VBoxMPCmnBuildVideoModesTable. */
|
---|
108 | uint32_t cVideoModes;
|
---|
109 | ULONG CurrentMode; /* Saved information about video modes */
|
---|
110 | ULONG CurrentModeWidth;
|
---|
111 | ULONG CurrentModeHeight;
|
---|
112 | ULONG CurrentModeBPP;
|
---|
113 |
|
---|
114 | ULONG ulFrameBufferOffset; /* The framebuffer position in the VRAM. */
|
---|
115 | ULONG ulFrameBufferSize; /* The size of the current framebuffer. */
|
---|
116 |
|
---|
117 | uint8_t iInvocationCounter;
|
---|
118 | uint32_t Prev_xres;
|
---|
119 | uint32_t Prev_yres;
|
---|
120 | uint32_t Prev_bpp;
|
---|
121 | #endif /*VBOX_XPDM_MINIPORT*/
|
---|
122 |
|
---|
123 | #ifdef VBOX_WDDM_MINIPORT
|
---|
124 | PDEVICE_OBJECT pPDO;
|
---|
125 | UNICODE_STRING RegKeyName;
|
---|
126 | UNICODE_STRING VideoGuid;
|
---|
127 |
|
---|
128 | uint8_t * pvVisibleVram;
|
---|
129 |
|
---|
130 | VBOXVIDEOCM_MGR CmMgr;
|
---|
131 | VBOXVIDEOCM_MGR SeamlessCtxMgr;
|
---|
132 | /* hgsmi allocation manager */
|
---|
133 | VBOXVIDEOCM_ALLOC_MGR AllocMgr;
|
---|
134 | /* mutex for context list operations */
|
---|
135 | KSPIN_LOCK ContextLock;
|
---|
136 | KSPIN_LOCK SynchLock;
|
---|
137 | volatile uint32_t cContexts3D;
|
---|
138 | volatile uint32_t cContexts2D;
|
---|
139 | volatile uint32_t cContextsDispIfResize;
|
---|
140 | volatile uint32_t cUnlockedVBVADisabled;
|
---|
141 |
|
---|
142 | volatile uint32_t fCompletingCommands;
|
---|
143 |
|
---|
144 | DWORD dwDrvCfgFlags;
|
---|
145 |
|
---|
146 | BOOLEAN f3DEnabled;
|
---|
147 | BOOLEAN fCmdVbvaEnabled;
|
---|
148 | BOOLEAN fComplexTopologiesEnabled;
|
---|
149 |
|
---|
150 | VBOXWDDM_GLOBAL_POINTER_INFO PointerInfo;
|
---|
151 |
|
---|
152 | VBOXVTLIST CtlList;
|
---|
153 | VBOXVTLIST DmaCmdList;
|
---|
154 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
155 | VBOXVTLIST VhwaCmdList;
|
---|
156 | #endif
|
---|
157 | BOOLEAN bNotifyDxDpc;
|
---|
158 |
|
---|
159 | BOOLEAN fDisableTargetUpdate;
|
---|
160 |
|
---|
161 |
|
---|
162 |
|
---|
163 | BOOL bVSyncTimerEnabled;
|
---|
164 | volatile uint32_t fVSyncInVBlank;
|
---|
165 | volatile LARGE_INTEGER VSyncTime;
|
---|
166 | KTIMER VSyncTimer;
|
---|
167 | KDPC VSyncDpc;
|
---|
168 |
|
---|
169 | #if 0
|
---|
170 | FAST_MUTEX ShRcTreeMutex;
|
---|
171 | AVLPVTREE ShRcTree;
|
---|
172 | #endif
|
---|
173 |
|
---|
174 | VBOXWDDM_SOURCE aSources[VBOX_VIDEO_MAX_SCREENS];
|
---|
175 | VBOXWDDM_TARGET aTargets[VBOX_VIDEO_MAX_SCREENS];
|
---|
176 | #endif /*VBOX_WDDM_MINIPORT*/
|
---|
177 |
|
---|
178 | union {
|
---|
179 | /* Information that is only relevant to the primary device or is the same for all devices. */
|
---|
180 | struct {
|
---|
181 |
|
---|
182 | void *pvReqFlush; /* Pointer to preallocated generic request structure for
|
---|
183 | * VMMDevReq_VideoAccelFlush. Allocated when VBVA status
|
---|
184 | * is changed. Deallocated on HwReset.
|
---|
185 | */
|
---|
186 | ULONG ulVbvaEnabled; /* Indicates that VBVA mode is enabled. */
|
---|
187 | ULONG ulMaxFrameBufferSize; /* The size of the VRAM allocated for the a single framebuffer. */
|
---|
188 | BOOLEAN fMouseHidden; /* Has the mouse cursor been hidden by the guest? */
|
---|
189 | VBOXMP_COMMON commonInfo;
|
---|
190 | #ifdef VBOX_XPDM_MINIPORT
|
---|
191 | /* Video Port API dynamically picked up at runtime for binary backwards compatibility with older NT versions */
|
---|
192 | VBOXVIDEOPORTPROCS VideoPortProcs;
|
---|
193 | #endif
|
---|
194 |
|
---|
195 | #ifdef VBOX_WDDM_MINIPORT
|
---|
196 | VBOXVDMAINFO Vdma;
|
---|
197 | # ifdef VBOXVDMA_WITH_VBVA
|
---|
198 | VBOXVBVAINFO Vbva;
|
---|
199 | # endif
|
---|
200 | D3DKMDT_HVIDPN hCommittedVidPn; /* committed VidPn handle */
|
---|
201 | DXGKRNL_INTERFACE DxgkInterface; /* Display Port handle and callbacks */
|
---|
202 | #endif
|
---|
203 | } primary;
|
---|
204 |
|
---|
205 | /* Secondary device information. */
|
---|
206 | struct {
|
---|
207 | BOOLEAN bEnabled; /* Device enabled flag */
|
---|
208 | } secondary;
|
---|
209 | } u;
|
---|
210 |
|
---|
211 | HGSMIAREA areaDisplay; /* Entire VRAM chunk for this display device. */
|
---|
212 |
|
---|
213 | #ifdef VBOX_WDDM_MINIPORT
|
---|
214 | VBOXVIDEO_HWTYPE enmHwType;
|
---|
215 | VBOXWDDM_HWRESOURCES HwResources;
|
---|
216 | #endif
|
---|
217 |
|
---|
218 | #ifdef VBOX_WITH_MESA3D
|
---|
219 | PVBOXWDDM_EXT_GA pGa; /* Pointer to Gallium backend data. */
|
---|
220 | #endif
|
---|
221 |
|
---|
222 | ULONG cbVRAMCpuVisible; /* How much video memory is available for the CPU visible segment. */
|
---|
223 | } VBOXMP_DEVEXT, *PVBOXMP_DEVEXT;
|
---|
224 |
|
---|
225 | DECLINLINE(PVBOXMP_DEVEXT) VBoxCommonToPrimaryExt(PVBOXMP_COMMON pCommon)
|
---|
226 | {
|
---|
227 | return RT_FROM_MEMBER(pCommon, VBOXMP_DEVEXT, u.primary.commonInfo);
|
---|
228 | }
|
---|
229 |
|
---|
230 | DECLINLINE(PVBOXMP_COMMON) VBoxCommonFromDeviceExt(PVBOXMP_DEVEXT pExt)
|
---|
231 | {
|
---|
232 | #ifdef VBOX_XPDM_MINIPORT
|
---|
233 | return &pExt->pPrimary->u.primary.commonInfo;
|
---|
234 | #else
|
---|
235 | return &pExt->u.primary.commonInfo;
|
---|
236 | #endif
|
---|
237 | }
|
---|
238 |
|
---|
239 | #ifdef VBOX_WDDM_MINIPORT
|
---|
240 | DECLINLINE(ULONG) vboxWddmVramCpuVisibleSize(PVBOXMP_DEVEXT pDevExt)
|
---|
241 | {
|
---|
242 | return pDevExt->cbVRAMCpuVisible;
|
---|
243 | }
|
---|
244 |
|
---|
245 | DECLINLINE(ULONG) vboxWddmVramCpuVisibleSegmentSize(PVBOXMP_DEVEXT pDevExt)
|
---|
246 | {
|
---|
247 | return vboxWddmVramCpuVisibleSize(pDevExt);
|
---|
248 | }
|
---|
249 |
|
---|
250 | /* 128 MB */
|
---|
251 | DECLINLINE(ULONG) vboxWddmVramCpuInvisibleSegmentSize(PVBOXMP_DEVEXT pDevExt)
|
---|
252 | {
|
---|
253 | RT_NOREF(pDevExt);
|
---|
254 | return 128 * 1024 * 1024;
|
---|
255 | }
|
---|
256 |
|
---|
257 | #ifdef VBOXWDDM_RENDER_FROM_SHADOW
|
---|
258 |
|
---|
259 | DECLINLINE(bool) vboxWddmCmpSurfDescsBase(VBOXWDDM_SURFACE_DESC *pDesc1, VBOXWDDM_SURFACE_DESC *pDesc2)
|
---|
260 | {
|
---|
261 | if (pDesc1->width != pDesc2->width)
|
---|
262 | return false;
|
---|
263 | if (pDesc1->height != pDesc2->height)
|
---|
264 | return false;
|
---|
265 | if (pDesc1->format != pDesc2->format)
|
---|
266 | return false;
|
---|
267 | if (pDesc1->bpp != pDesc2->bpp)
|
---|
268 | return false;
|
---|
269 | if (pDesc1->pitch != pDesc2->pitch)
|
---|
270 | return false;
|
---|
271 | return true;
|
---|
272 | }
|
---|
273 |
|
---|
274 | #endif
|
---|
275 | #endif /*VBOX_WDDM_MINIPORT*/
|
---|
276 |
|
---|
277 | #endif /* !GA_INCLUDED_SRC_WINNT_Graphics_Video_mp_common_VBoxMPDevExt_h */
|
---|