VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPMisc.h@ 41058

Last change on this file since 41058 was 39981, checked in by vboxsync, 13 years ago

wddm/3d: visible regions fixes for WPF apps

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.7 KB
Line 
1/* $Id: VBoxMPMisc.h 39981 2012-02-03 12:13:33Z vboxsync $ */
2
3/** @file
4 * VBox WDDM Miniport driver
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 ___VBoxMPMisc_h__
20#define ___VBoxMPMisc_h__
21
22#include "../../common/VBoxVideoTools.h"
23
24DECLINLINE(void) vboxVideoLeDetach(LIST_ENTRY *pList, LIST_ENTRY *pDstList)
25{
26 if (IsListEmpty(pList))
27 {
28 InitializeListHead(pDstList);
29 }
30 else
31 {
32 *pDstList = *pList;
33 Assert(pDstList->Flink->Blink == pList);
34 Assert(pDstList->Blink->Flink == pList);
35 /* pDstList->Flink & pDstList->Blink point to the "real| entries, never to pList
36 * since we've checked IsListEmpty(pList) above */
37 pDstList->Flink->Blink = pDstList;
38 pDstList->Blink->Flink = pDstList;
39 InitializeListHead(pList);
40 }
41}
42
43typedef uint32_t VBOXWDDM_HANDLE;
44#define VBOXWDDM_HANDLE_INVALID 0UL
45
46typedef struct VBOXWDDM_HTABLE
47{
48 uint32_t cData;
49 uint32_t iNext2Search;
50 uint32_t cSize;
51 PVOID *paData;
52} VBOXWDDM_HTABLE, *PVBOXWDDM_HTABLE;
53
54typedef struct VBOXWDDM_HTABLE_ITERATOR
55{
56 PVBOXWDDM_HTABLE pTbl;
57 uint32_t iCur;
58 uint32_t cLeft;
59} VBOXWDDM_HTABLE_ITERATOR, *PVBOXWDDM_HTABLE_ITERATOR;
60
61VOID vboxWddmHTableIterInit(PVBOXWDDM_HTABLE pTbl, PVBOXWDDM_HTABLE_ITERATOR pIter);
62PVOID vboxWddmHTableIterNext(PVBOXWDDM_HTABLE_ITERATOR pIter, VBOXWDDM_HANDLE *phHandle);
63BOOL vboxWddmHTableIterHasNext(PVBOXWDDM_HTABLE_ITERATOR pIter);
64PVOID vboxWddmHTableIterRemoveCur(PVBOXWDDM_HTABLE_ITERATOR pIter);
65NTSTATUS vboxWddmHTableCreate(PVBOXWDDM_HTABLE pTbl, uint32_t cSize);
66VOID vboxWddmHTableDestroy(PVBOXWDDM_HTABLE pTbl);
67NTSTATUS vboxWddmHTableRealloc(PVBOXWDDM_HTABLE pTbl, uint32_t cNewSize);
68VBOXWDDM_HANDLE vboxWddmHTablePut(PVBOXWDDM_HTABLE pTbl, PVOID pvData);
69PVOID vboxWddmHTableRemove(PVBOXWDDM_HTABLE pTbl, VBOXWDDM_HANDLE hHandle);
70PVOID vboxWddmHTableGet(PVBOXWDDM_HTABLE pTbl, VBOXWDDM_HANDLE hHandle);
71
72
73PVBOXWDDM_SWAPCHAIN vboxWddmSwapchainCreate();
74DECLINLINE(BOOLEAN) vboxWddmSwapchainRetain(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_SWAPCHAIN pSwapchain);
75DECLINLINE(VOID) vboxWddmSwapchainRelease(PVBOXWDDM_SWAPCHAIN pSwapchain);
76PVBOXWDDM_SWAPCHAIN vboxWddmSwapchainRetainByAlloc(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_ALLOCATION pAlloc);
77VOID vboxWddmSwapchainAllocRemove(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_SWAPCHAIN pSwapchain, PVBOXWDDM_ALLOCATION pAlloc);
78BOOLEAN vboxWddmSwapchainAllocAdd(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_SWAPCHAIN pSwapchain, PVBOXWDDM_ALLOCATION pAlloc);
79VOID vboxWddmSwapchainAllocRemoveAll(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_SWAPCHAIN pSwapchain);
80VOID vboxWddmSwapchainDestroy(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_SWAPCHAIN pSwapchain);
81VOID vboxWddmSwapchainCtxDestroyAll(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_CONTEXT pContext);
82NTSTATUS vboxWddmSwapchainCtxEscape(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_CONTEXT pContext, PVBOXDISPIFESCAPE_SWAPCHAININFO pSwapchainInfo, UINT cbSize);
83NTSTATUS vboxWddmSwapchainCtxInit(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_CONTEXT pContext);
84VOID vboxWddmSwapchainCtxTerm(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_CONTEXT pContext);
85
86
87NTSTATUS vboxWddmRegQueryDisplaySettingsKeyName(PVBOXMP_DEVEXT pDevExt, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId,
88 ULONG cbBuf, PWCHAR pBuf, PULONG pcbResult);
89NTSTATUS vboxWddmRegOpenDisplaySettingsKey(IN PVBOXMP_DEVEXT pDeviceExtension, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId, OUT PHANDLE phKey);
90NTSTATUS vboxWddmRegDisplaySettingsQueryRelX(HANDLE hKey, int * pResult);
91NTSTATUS vboxWddmRegDisplaySettingsQueryRelY(HANDLE hKey, int * pResult);
92NTSTATUS vboxWddmDisplaySettingsQueryPos(IN PVBOXMP_DEVEXT pDeviceExtension, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId, POINT * pPos);
93NTSTATUS vboxWddmRegQueryVideoGuidString(ULONG cbBuf, PWCHAR pBuf, PULONG pcbResult);
94
95NTSTATUS vboxWddmRegQueryDrvKeyName(PVBOXMP_DEVEXT pDevExt, ULONG cbBuf, PWCHAR pBuf, PULONG pcbResult);
96
97NTSTATUS vboxWddmRegOpenKey(OUT PHANDLE phKey, IN PWCHAR pName, IN ACCESS_MASK fAccess);
98NTSTATUS vboxWddmRegQueryValueDword(IN HANDLE hKey, IN PWCHAR pName, OUT PDWORD pDword);
99NTSTATUS vboxWddmRegSetValueDword(IN HANDLE hKey, IN PWCHAR pName, OUT DWORD val);
100
101UNICODE_STRING* vboxWddmVGuidGet(PVBOXMP_DEVEXT pDevExt);
102VOID vboxWddmVGuidFree(PVBOXMP_DEVEXT pDevExt);
103
104#define VBOXWDDM_MM_VOID 0xffffffffUL
105
106typedef struct VBOXWDDM_MM
107{
108 RTL_BITMAP BitMap;
109 UINT cPages;
110 UINT cAllocs;
111 PULONG pBuffer;
112} VBOXWDDM_MM, *PVBOXWDDM_MM;
113
114NTSTATUS vboxMmInit(PVBOXWDDM_MM pMm, UINT cPages);
115ULONG vboxMmAlloc(PVBOXWDDM_MM pMm, UINT cPages);
116VOID vboxMmFree(PVBOXWDDM_MM pMm, UINT iPage, UINT cPages);
117NTSTATUS vboxMmTerm(PVBOXWDDM_MM pMm);
118
119typedef struct VBOXVIDEOCM_ALLOC_MGR
120{
121 /* synch lock */
122 FAST_MUTEX Mutex;
123 VBOXWDDM_HTABLE AllocTable;
124 VBOXWDDM_MM Mm;
125// PHYSICAL_ADDRESS PhData;
126 uint8_t *pvData;
127 uint32_t offData;
128 uint32_t cbData;
129} VBOXVIDEOCM_ALLOC_MGR, *PVBOXVIDEOCM_ALLOC_MGR;
130
131typedef struct VBOXVIDEOCM_ALLOC_CONTEXT
132{
133 PVBOXVIDEOCM_ALLOC_MGR pMgr;
134 /* synch lock */
135 FAST_MUTEX Mutex;
136 VBOXWDDM_HTABLE AllocTable;
137} VBOXVIDEOCM_ALLOC_CONTEXT, *PVBOXVIDEOCM_ALLOC_CONTEXT;
138
139NTSTATUS vboxVideoAMgrCreate(PVBOXMP_DEVEXT pDevExt, PVBOXVIDEOCM_ALLOC_MGR pMgr, uint32_t offData, uint32_t cbData);
140NTSTATUS vboxVideoAMgrDestroy(PVBOXMP_DEVEXT pDevExt, PVBOXVIDEOCM_ALLOC_MGR pMgr);
141
142NTSTATUS vboxVideoAMgrCtxCreate(PVBOXVIDEOCM_ALLOC_MGR pMgr, PVBOXVIDEOCM_ALLOC_CONTEXT pCtx);
143NTSTATUS vboxVideoAMgrCtxDestroy(PVBOXVIDEOCM_ALLOC_CONTEXT pCtx);
144
145NTSTATUS vboxVideoAMgrCtxAllocCreate(PVBOXVIDEOCM_ALLOC_CONTEXT pContext, PVBOXVIDEOCM_UM_ALLOC pUmAlloc);
146NTSTATUS vboxVideoAMgrCtxAllocDestroy(PVBOXVIDEOCM_ALLOC_CONTEXT pContext, VBOXDISP_KMHANDLE hSesionHandle);
147
148#ifdef VBOX_WITH_CRHGSMI
149NTSTATUS vboxVideoAMgrCtxAllocSubmit(PVBOXMP_DEVEXT pDevExt, PVBOXVIDEOCM_ALLOC_CONTEXT pContext, UINT cBuffers, VBOXWDDM_UHGSMI_BUFFER_UI_INFO_ESCAPE *paBuffers);
150#endif
151
152VOID vboxWddmSleep(uint32_t u32Val);
153VOID vboxWddmCounterU32Wait(uint32_t volatile * pu32, uint32_t u32Val);
154
155NTSTATUS vboxUmdDumpBuf(PVBOXDISPIFESCAPE_DBGDUMPBUF pBuf, uint32_t cbBuffer);
156
157#if 0
158/* wine shrc handle -> allocation map */
159VOID vboxShRcTreeInit(PVBOXMP_DEVEXT pDevExt);
160VOID vboxShRcTreeTerm(PVBOXMP_DEVEXT pDevExt);
161BOOLEAN vboxShRcTreePut(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_ALLOCATION pAlloc);
162PVBOXWDDM_ALLOCATION vboxShRcTreeGet(PVBOXMP_DEVEXT pDevExt, HANDLE hSharedRc);
163BOOLEAN vboxShRcTreeRemove(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_ALLOCATION pAlloc);
164#endif
165
166/* visible rects */
167typedef struct VBOXWDDMVR_LIST
168{
169 LIST_ENTRY ListHead;
170 UINT cEntries;
171} VBOXWDDMVR_LIST, *PVBOXWDDMVR_LIST;
172
173DECLINLINE(UINT) VBoxWddmVrListRectsCount(PVBOXWDDMVR_LIST pList)
174{
175 return pList->cEntries;
176}
177
178DECLINLINE(BOOLEAN) VBoxWddmVrListIsEmpty(PVBOXWDDMVR_LIST pList)
179{
180 return !VBoxWddmVrListRectsCount(pList);
181}
182
183DECLINLINE(void) VBoxWddmVrListInit(PVBOXWDDMVR_LIST pList)
184{
185 InitializeListHead(&pList->ListHead);
186 pList->cEntries = 0;
187}
188
189void VBoxWddmVrListClear(PVBOXWDDMVR_LIST pList);
190
191void VBoxWddmVrListTranslate(PVBOXWDDMVR_LIST pList, LONG x, LONG y);
192
193NTSTATUS VBoxWddmVrListRectsAdd(PVBOXWDDMVR_LIST pList, UINT cRects, const PRECT aRects, BOOLEAN *pfChanged);
194NTSTATUS VBoxWddmVrListRectsSubst(PVBOXWDDMVR_LIST pList, UINT cRects, const PRECT aRects, BOOLEAN *pfChanged);
195NTSTATUS VBoxWddmVrListRectsGet(PVBOXWDDMVR_LIST pList, UINT cRects, PRECT aRects);
196
197NTSTATUS VBoxWddmVrInit();
198void VBoxWddmVrTerm();
199
200#endif /* #ifndef ___VBoxMPMisc_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