VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/common/VBoxMPDevExt.h@ 41636

Last change on this file since 41636 was 41636, checked in by vboxsync, 12 years ago

wddm: fix win8 halt issues

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.9 KB
Line 
1/* $Id: VBoxMPDevExt.h 41636 2012-06-09 12:56:51Z vboxsync $ */
2
3/** @file
4 * VBox Miniport device extension header
5 */
6
7/*
8 * Copyright (C) 2011 Oracle Corporation
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 */
18
19#ifndef VBOXMPDEVEXT_H
20#define VBOXMPDEVEXT_H
21
22#include "VBoxMPUtils.h"
23#include <VBox/VBoxVideoGuest.h>
24
25#ifdef VBOX_XPDM_MINIPORT
26# include <miniport.h>
27# include <ntddvdeo.h>
28# include <video.h>
29# include "common/xpdm/VBoxVideoPortAPI.h"
30#endif
31
32#ifdef VBOX_WDDM_MINIPORT
33# include "wddm/VBoxMPTypes.h"
34#endif
35
36typedef struct VBOXMP_COMMON
37{
38 int cDisplays; /* Number of displays. */
39
40 uint32_t cbVRAM; /* The VRAM size. */
41
42 PHYSICAL_ADDRESS phVRAM; /* Physical VRAM base. */
43
44 ULONG ulApertureSize; /* Size of the LFB aperture (>= VRAM size). */
45
46 uint32_t cbMiniportHeap; /* The size of reserved VRAM for miniport driver heap.
47 * It is at offset:
48 * cbAdapterMemorySize - VBOX_VIDEO_ADAPTER_INFORMATION_SIZE - cbMiniportHeap
49 */
50 void *pvMiniportHeap; /* The pointer to the miniport heap VRAM.
51 * This is mapped by miniport separately.
52 */
53 void *pvAdapterInformation; /* The pointer to the last 4K of VRAM.
54 * This is mapped by miniport separately.
55 */
56
57 /** Whether HGSMI is enabled. */
58 bool bHGSMI;
59 /** Context information needed to receive commands from the host. */
60 HGSMIHOSTCOMMANDCONTEXT hostCtx;
61 /** Context information needed to submit commands to the host. */
62 HGSMIGUESTCOMMANDCONTEXT guestCtx;
63} VBOXMP_COMMON, *PVBOXMP_COMMON;
64
65typedef struct _VBOXMP_DEVEXT
66{
67 struct _VBOXMP_DEVEXT *pNext; /* Next extension in the DualView extension list.
68 * The primary extension is the first one.
69 */
70#ifdef VBOX_XPDM_MINIPORT
71 struct _VBOXMP_DEVEXT *pPrimary; /* Pointer to the primary device extension. */
72
73 ULONG iDevice; /* Device index: 0 for primary, otherwise a secondary device. */
74
75 ULONG CurrentMode; /* Saved information about video modes */
76 ULONG CurrentModeWidth;
77 ULONG CurrentModeHeight;
78 ULONG CurrentModeBPP;
79
80 ULONG ulFrameBufferOffset; /* The framebuffer position in the VRAM. */
81 ULONG ulFrameBufferSize; /* The size of the current framebuffer. */
82#endif /*VBOX_XPDM_MINIPORT*/
83
84#ifdef VBOX_WDDM_MINIPORT
85 PDEVICE_OBJECT pPDO;
86 UNICODE_STRING RegKeyName;
87 UNICODE_STRING VideoGuid;
88
89 uint8_t * pvVisibleVram;
90
91 VBOXVIDEOCM_MGR CmMgr;
92 /* hgsmi allocation manager */
93 VBOXVIDEOCM_ALLOC_MGR AllocMgr;
94 VBOXVDMADDI_NODE aNodes[VBOXWDDM_NUM_NODES];
95 LIST_ENTRY DpcCmdQueue;
96 LIST_ENTRY SwapchainList3D;
97 /* mutex for context list operations */
98 FAST_MUTEX ContextMutex;
99 KSPIN_LOCK SynchLock;
100 volatile uint32_t cContexts3D;
101 volatile uint32_t cContexts2D;
102 volatile uint32_t cRenderFromShadowDisabledContexts;
103 volatile uint32_t cUnlockedVBVADisabled;
104 /* this is examined and swicthed by DxgkDdiSubmitCommand only! */
105 volatile BOOLEAN fRenderToShadowDisabled;
106
107 VBOXMP_CRCTLCON CrCtlCon;
108
109 VBOXWDDM_GLOBAL_POINTER_INFO PointerInfo;
110
111 VBOXVTLIST CtlList;
112 VBOXVTLIST DmaCmdList;
113#ifdef VBOX_WITH_VIDEOHWACCEL
114 VBOXVTLIST VhwaCmdList;
115#endif
116 BOOL bNotifyDxDpc;
117
118#ifdef VBOX_VDMA_WITH_WATCHDOG
119 PKTHREAD pWdThread;
120 KEVENT WdEvent;
121#endif
122
123 KTIMER VSyncTimer;
124 KDPC VSyncDpc;
125
126#if 0
127 FAST_MUTEX ShRcTreeMutex;
128 AVLPVTREE ShRcTree;
129#endif
130
131 VBOXWDDM_SOURCE aSources[VBOX_VIDEO_MAX_SCREENS];
132 VBOXWDDM_TARGET aTargets[VBOX_VIDEO_MAX_SCREENS];
133#endif /*VBOX_WDDM_MINIPORT*/
134
135 union {
136 /* Information that is only relevant to the primary device or is the same for all devices. */
137 struct {
138
139 void *pvReqFlush; /* Pointer to preallocated generic request structure for
140 * VMMDevReq_VideoAccelFlush. Allocated when VBVA status
141 * is changed. Deallocated on HwReset.
142 */
143 ULONG ulVbvaEnabled; /* Indicates that VBVA mode is enabled. */
144 ULONG ulMaxFrameBufferSize; /* The size of the VRAM allocated for the a single framebuffer. */
145 BOOLEAN fMouseHidden; /* Has the mouse cursor been hidden by the guest? */
146 VBOXMP_COMMON commonInfo;
147#ifdef VBOX_XPDM_MINIPORT
148 /* Video Port API dynamically picked up at runtime for binary backwards compatibility with older NT versions */
149 VBOXVIDEOPORTPROCS VideoPortProcs;
150#endif
151
152#ifdef VBOX_WDDM_MINIPORT
153 VBOXVDMAINFO Vdma;
154# ifdef VBOXVDMA_WITH_VBVA
155 VBOXVBVAINFO Vbva;
156# endif
157 D3DKMDT_HVIDPN hCommittedVidPn; /* committed VidPn handle */
158 DXGKRNL_INTERFACE DxgkInterface; /* Display Port handle and callbacks */
159#endif
160 } primary;
161
162 /* Secondary device information. */
163 struct {
164 BOOLEAN bEnabled; /* Device enabled flag */
165 } secondary;
166 } u;
167
168 HGSMIAREA areaDisplay; /* Entire VRAM chunk for this display device. */
169 BOOLEAN fAnyX; /* Unrestricted horizontal resolution flag. */
170} VBOXMP_DEVEXT, *PVBOXMP_DEVEXT;
171
172DECLINLINE(PVBOXMP_DEVEXT) VBoxCommonToPrimaryExt(PVBOXMP_COMMON pCommon)
173{
174 return RT_FROM_MEMBER(pCommon, VBOXMP_DEVEXT, u.primary.commonInfo);
175}
176
177DECLINLINE(PVBOXMP_COMMON) VBoxCommonFromDeviceExt(PVBOXMP_DEVEXT pExt)
178{
179#ifdef VBOX_XPDM_MINIPORT
180 return &pExt->pPrimary->u.primary.commonInfo;
181#else
182 return &pExt->u.primary.commonInfo;
183#endif
184}
185
186#ifdef VBOX_WDDM_MINIPORT
187DECLINLINE(ULONG) vboxWddmVramCpuVisibleSize(PVBOXMP_DEVEXT pDevExt)
188{
189#ifdef VBOXWDDM_RENDER_FROM_SHADOW
190 /* all memory layout info should be initialized */
191 Assert(pDevExt->aSources[0].Vbva.offVBVA);
192 /* page aligned */
193 Assert(!(pDevExt->aSources[0].Vbva.offVBVA & 0xfff));
194
195 return (ULONG)(pDevExt->aSources[0].Vbva.offVBVA & ~0xfffULL);
196#else
197 /* all memory layout info should be initialized */
198 Assert(pDevExt->u.primary.Vdma.CmdHeap.Heap.area.offBase);
199 /* page aligned */
200 Assert(!(pDevExt->u.primary.Vdma.CmdHeap.Heap.area.offBase & 0xfff));
201
202 return pDevExt->u.primary.Vdma.CmdHeap.Heap.area.offBase & ~0xfffUL;
203#endif
204}
205
206DECLINLINE(ULONG) vboxWddmVramCpuVisibleSegmentSize(PVBOXMP_DEVEXT pDevExt)
207{
208 return vboxWddmVramCpuVisibleSize(pDevExt);
209}
210
211#ifdef VBOXWDDM_RENDER_FROM_SHADOW
212DECLINLINE(ULONG) vboxWddmVramCpuInvisibleSegmentSize(PVBOXMP_DEVEXT pDevExt)
213{
214 return vboxWddmVramCpuVisibleSegmentSize(pDevExt);
215}
216
217DECLINLINE(bool) vboxWddmCmpSurfDescsBase(VBOXWDDM_SURFACE_DESC *pDesc1, VBOXWDDM_SURFACE_DESC *pDesc2)
218{
219 if (pDesc1->width != pDesc2->width)
220 return false;
221 if (pDesc1->height != pDesc2->height)
222 return false;
223 if (pDesc1->format != pDesc2->format)
224 return false;
225 if (pDesc1->bpp != pDesc2->bpp)
226 return false;
227 if (pDesc1->pitch != pDesc2->pitch)
228 return false;
229 return true;
230}
231
232DECLINLINE(void) vboxWddmAssignShadow(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_SOURCE pSource, PVBOXWDDM_ALLOCATION pAllocation, D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId)
233{
234 if (pSource->pShadowAllocation == pAllocation)
235 {
236 Assert(pAllocation->bAssigned);
237 return;
238 }
239
240 if (pSource->pShadowAllocation)
241 {
242 PVBOXWDDM_ALLOCATION pOldAlloc = pSource->pShadowAllocation;
243 /* clear the visibility info fo the current primary */
244 pOldAlloc->bVisible = FALSE;
245 pOldAlloc->bAssigned = FALSE;
246 Assert(pOldAlloc->SurfDesc.VidPnSourceId == srcId);
247 /* release the shadow surface */
248 pOldAlloc->SurfDesc.VidPnSourceId = D3DDDI_ID_UNINITIALIZED;
249 }
250
251 if (pAllocation)
252 {
253 Assert(!pAllocation->bAssigned);
254 Assert(!pAllocation->bVisible);
255 pAllocation->bVisible = FALSE;
256 /* this check ensures the shadow is not used for other source simultaneously */
257 Assert(pAllocation->SurfDesc.VidPnSourceId == D3DDDI_ID_UNINITIALIZED);
258 pAllocation->SurfDesc.VidPnSourceId = srcId;
259 pAllocation->bAssigned = TRUE;
260 if (!vboxWddmCmpSurfDescsBase(&pSource->SurfDesc, &pAllocation->SurfDesc))
261 pSource->offVram = VBOXVIDEOOFFSET_VOID; /* force guest->host notification */
262 pSource->SurfDesc = pAllocation->SurfDesc;
263 }
264
265 pSource->pShadowAllocation = pAllocation;
266}
267#endif
268
269DECLINLINE(VOID) vboxWddmAssignPrimary(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_SOURCE pSource, PVBOXWDDM_ALLOCATION pAllocation, D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId)
270{
271 if (pSource->pPrimaryAllocation == pAllocation)
272 return;
273
274 if (pSource->pPrimaryAllocation)
275 {
276 PVBOXWDDM_ALLOCATION pOldAlloc = pSource->pPrimaryAllocation;
277 /* clear the visibility info fo the current primary */
278 pOldAlloc->bVisible = FALSE;
279 pOldAlloc->bAssigned = FALSE;
280 Assert(pOldAlloc->SurfDesc.VidPnSourceId == srcId);
281 }
282
283 if (pAllocation)
284 {
285 pAllocation->bVisible = FALSE;
286 Assert(pAllocation->SurfDesc.VidPnSourceId == srcId);
287 pAllocation->bAssigned = TRUE;
288 }
289
290 pSource->pPrimaryAllocation = pAllocation;
291}
292#endif /*VBOX_WDDM_MINIPORT*/
293
294#endif /*VBOXMPDEVEXT_H*/
Note: See TracBrowser for help on using the repository browser.

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