1 | /*
|
---|
2 | * Copyright (C) 2010 Oracle Corporation
|
---|
3 | *
|
---|
4 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
5 | * available from http://www.virtualbox.org. This file is free software;
|
---|
6 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
7 | * General Public License (GPL) as published by the Free Software
|
---|
8 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
9 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
10 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
11 | */
|
---|
12 | #ifndef ___VBoxVideoWddm_h___
|
---|
13 | #define ___VBoxVideoWddm_h___
|
---|
14 |
|
---|
15 | #include "../VBoxVideo.h"
|
---|
16 |
|
---|
17 | //#define VBOXWDDM_DEBUG_VIDPN
|
---|
18 |
|
---|
19 | /* one page size */
|
---|
20 | #define VBOXWDDM_C_DMA_BUFFER_SIZE 0x1000
|
---|
21 | #define VBOXWDDM_C_DMA_PRIVATEDATA_SIZE 0x4000
|
---|
22 | #define VBOXWDDM_C_ALLOC_LIST_SIZE 0xc00
|
---|
23 | #define VBOXWDDM_C_PATH_LOCATION_LIST_SIZE 0xc00
|
---|
24 |
|
---|
25 | #define VBOXWDDM_C_POINTER_MAX_WIDTH 64
|
---|
26 | #define VBOXWDDM_C_POINTER_MAX_HEIGHT 64
|
---|
27 |
|
---|
28 | #ifdef VBOX_WITH_VDMA
|
---|
29 | #define VBOXWDDM_C_VDMA_BUFFER_SIZE (64*_1K)
|
---|
30 | #endif
|
---|
31 |
|
---|
32 | #ifndef VBOXWDDM_RENDER_FROM_SHADOW
|
---|
33 | # ifndef VBOX_WITH_VDMA
|
---|
34 | # error "VBOX_WITH_VDMA must be defined!!!"
|
---|
35 | # endif
|
---|
36 | #endif
|
---|
37 |
|
---|
38 | #ifndef DEBUG_misha
|
---|
39 | # ifdef Assert
|
---|
40 | # undef Assert
|
---|
41 | # define Assert(_a) do{}while(0)
|
---|
42 | # endif
|
---|
43 | # ifdef AssertBreakpoint
|
---|
44 | # undef AssertBreakpoint
|
---|
45 | # define AssertBreakpoint() do{}while(0)
|
---|
46 | # endif
|
---|
47 | # ifdef AssertFailed
|
---|
48 | # undef AssertFailed
|
---|
49 | # define AssertFailed() do{}while(0)
|
---|
50 | # endif
|
---|
51 | #endif
|
---|
52 |
|
---|
53 | PVOID vboxWddmMemAlloc(IN SIZE_T cbSize);
|
---|
54 | PVOID vboxWddmMemAllocZero(IN SIZE_T cbSize);
|
---|
55 | VOID vboxWddmMemFree(PVOID pvMem);
|
---|
56 |
|
---|
57 | NTSTATUS vboxWddmCallIsr(PDEVICE_EXTENSION pDevExt);
|
---|
58 |
|
---|
59 | /* allocation */
|
---|
60 | //#define VBOXWDDM_ALLOCATIONINDEX_VOID (~0U)
|
---|
61 | typedef struct VBOXWDDM_ALLOCATION
|
---|
62 | {
|
---|
63 | LIST_ENTRY SwapchainEntry;
|
---|
64 | struct VBOXWDDM_SWAPCHAIN *pSwapchain;
|
---|
65 | VBOXWDDM_ALLOC_TYPE enmType;
|
---|
66 | // VBOXWDDM_ALLOCUSAGE_TYPE enmCurrentUsage;
|
---|
67 | D3DDDI_RESOURCEFLAGS fRcFlags;
|
---|
68 | UINT SegmentId;
|
---|
69 | VBOXVIDEOOFFSET offVram;
|
---|
70 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
71 | VBOXVHWA_SURFHANDLE hHostHandle;
|
---|
72 | #endif
|
---|
73 | BOOLEAN bVisible;
|
---|
74 | BOOLEAN bAssigned;
|
---|
75 | VBOXWDDM_SURFACE_DESC SurfDesc;
|
---|
76 | struct VBOXWDDM_RESOURCE *pResource;
|
---|
77 | /* to return to the Runtime on DxgkDdiCreateAllocation */
|
---|
78 | DXGK_ALLOCATIONUSAGEHINT UsageHint;
|
---|
79 | uint32_t iIndex;
|
---|
80 | VBOXUHGSMI_SYNCHOBJECT_TYPE enmSynchType;
|
---|
81 | union
|
---|
82 | {
|
---|
83 | PKEVENT pSynchEvent;
|
---|
84 | PRKSEMAPHORE pSynchSemaphore;
|
---|
85 | };
|
---|
86 | } VBOXWDDM_ALLOCATION, *PVBOXWDDM_ALLOCATION;
|
---|
87 |
|
---|
88 | typedef struct VBOXWDDM_RESOURCE
|
---|
89 | {
|
---|
90 | uint32_t fFlags;
|
---|
91 | VBOXWDDM_RC_DESC RcDesc;
|
---|
92 | uint32_t cAllocations;
|
---|
93 | VBOXWDDM_ALLOCATION aAllocations[1];
|
---|
94 | } VBOXWDDM_RESOURCE, *PVBOXWDDM_RESOURCE;
|
---|
95 |
|
---|
96 | DECLINLINE(PVBOXWDDM_RESOURCE) vboxWddmResourceForAlloc(PVBOXWDDM_ALLOCATION pAlloc)
|
---|
97 | {
|
---|
98 | #if 0
|
---|
99 | if(pAlloc->iIndex == VBOXWDDM_ALLOCATIONINDEX_VOID)
|
---|
100 | return NULL;
|
---|
101 | PVBOXWDDM_RESOURCE pRc = (PVBOXWDDM_RESOURCE)(((uint8_t*)pAlloc) - RT_OFFSETOF(VBOXWDDM_RESOURCE, aAllocations[pAlloc->iIndex]));
|
---|
102 | return pRc;
|
---|
103 | #else
|
---|
104 | return pAlloc->pResource;
|
---|
105 | #endif
|
---|
106 | }
|
---|
107 |
|
---|
108 | typedef struct VBOXWDDM_OVERLAY
|
---|
109 | {
|
---|
110 | LIST_ENTRY ListEntry;
|
---|
111 | PDEVICE_EXTENSION pDevExt;
|
---|
112 | PVBOXWDDM_RESOURCE pResource;
|
---|
113 | PVBOXWDDM_ALLOCATION pCurentAlloc;
|
---|
114 | D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId;
|
---|
115 | RECT DstRect;
|
---|
116 | } VBOXWDDM_OVERLAY, *PVBOXWDDM_OVERLAY;
|
---|
117 |
|
---|
118 | typedef enum
|
---|
119 | {
|
---|
120 | VBOXWDDM_DEVICE_TYPE_UNDEFINED = 0,
|
---|
121 | VBOXWDDM_DEVICE_TYPE_SYSTEM
|
---|
122 | } VBOXWDDM_DEVICE_TYPE;
|
---|
123 |
|
---|
124 | typedef struct VBOXWDDM_DEVICE
|
---|
125 | {
|
---|
126 | struct _DEVICE_EXTENSION * pAdapter; /* Adapder info */
|
---|
127 | HANDLE hDevice; /* handle passed to CreateDevice */
|
---|
128 | VBOXWDDM_DEVICE_TYPE enmType; /* device creation flags passed to DxgkDdiCreateDevice, not sure we need it */
|
---|
129 | } VBOXWDDM_DEVICE, *PVBOXWDDM_DEVICE;
|
---|
130 |
|
---|
131 | typedef enum
|
---|
132 | {
|
---|
133 | VBOXWDDM_OBJSTATE_TYPE_UNKNOWN = 0,
|
---|
134 | VBOXWDDM_OBJSTATE_TYPE_INITIALIZED,
|
---|
135 | VBOXWDDM_OBJSTATE_TYPE_TERMINATED
|
---|
136 | } VBOXWDDM_OBJSTATE_TYPE;
|
---|
137 | typedef struct VBOXWDDM_SWAPCHAIN
|
---|
138 | {
|
---|
139 | LIST_ENTRY DevExtListEntry;
|
---|
140 | LIST_ENTRY AllocList;
|
---|
141 | struct VBOXWDDM_CONTEXT *pContext;
|
---|
142 | RECT ViewRect;
|
---|
143 | VBOXWDDM_OBJSTATE_TYPE enmState;
|
---|
144 | volatile uint32_t cRefs;
|
---|
145 | VBOXDISP_UMHANDLE hSwapchainUm;
|
---|
146 | VBOXDISP_KMHANDLE hSwapchainKm;
|
---|
147 | PVBOXVIDEOCM_CMD_RECTS_INTERNAL pLastReportedRects;
|
---|
148 | }VBOXWDDM_SWAPCHAIN, *PVBOXWDDM_SWAPCHAIN;
|
---|
149 |
|
---|
150 | typedef struct VBOXWDDM_CONTEXT
|
---|
151 | {
|
---|
152 | // LIST_ENTRY ListEntry;
|
---|
153 | struct VBOXWDDM_DEVICE * pDevice;
|
---|
154 | HANDLE hContext;
|
---|
155 | VBOXWDDM_CONTEXT_TYPE enmType;
|
---|
156 | UINT NodeOrdinal;
|
---|
157 | UINT EngineAffinity;
|
---|
158 | // UINT uLastCompletedCmdFenceId;
|
---|
159 | FAST_MUTEX SwapchainMutex;
|
---|
160 | VBOXWDDM_HTABLE Swapchains;
|
---|
161 | VBOXVIDEOCM_CTX CmContext;
|
---|
162 | VBOXVIDEOCM_ALLOC_CONTEXT AllocContext;
|
---|
163 | } VBOXWDDM_CONTEXT, *PVBOXWDDM_CONTEXT;
|
---|
164 |
|
---|
165 | #define VBOXWDDMENTRY_2_SWAPCHAIN(_pE) ((PVBOXWDDM_SWAPCHAIN)((uint8_t*)(_pE) - RT_OFFSETOF(VBOXWDDM_SWAPCHAIN, DevExtListEntry)))
|
---|
166 |
|
---|
167 | typedef struct VBOXWDDM_DMA_PRIVATEDATA_PRESENTHDR
|
---|
168 | {
|
---|
169 | VBOXWDDM_DMA_PRIVATEDATA_BASEHDR BaseHdr;
|
---|
170 | }VBOXWDDM_DMA_PRIVATEDATA_PRESENTHDR, *PVBOXWDDM_DMA_PRIVATEDATA_PRESENTHDR;
|
---|
171 |
|
---|
172 | #ifdef VBOXWDDM_RENDER_FROM_SHADOW
|
---|
173 |
|
---|
174 | typedef struct VBOXWDDM_DMA_PRIVATEDATA_SHADOW2PRIMARY
|
---|
175 | {
|
---|
176 | VBOXWDDM_DMA_PRIVATEDATA_PRESENTHDR Hdr;
|
---|
177 | VBOXVDMA_SHADOW2PRIMARY Shadow2Primary;
|
---|
178 | } VBOXWDDM_DMA_PRIVATEDATA_SHADOW2PRIMARY, *PVBOXWDDM_DMA_PRIVATEDATA_SHADOW2PRIMARY;
|
---|
179 |
|
---|
180 | #endif
|
---|
181 |
|
---|
182 | typedef struct VBOXWDDM_DMA_PRIVATEDATA_BLT
|
---|
183 | {
|
---|
184 | VBOXWDDM_DMA_PRIVATEDATA_PRESENTHDR Hdr;
|
---|
185 | VBOXVDMA_BLT Blt;
|
---|
186 | } VBOXWDDM_DMA_PRIVATEDATA_BLT, *PVBOXWDDM_DMA_PRIVATEDATA_BLT;
|
---|
187 |
|
---|
188 | typedef struct VBOXWDDM_DMA_PRIVATEDATA_FLIP
|
---|
189 | {
|
---|
190 | VBOXWDDM_DMA_PRIVATEDATA_PRESENTHDR Hdr;
|
---|
191 | VBOXVDMA_FLIP Flip;
|
---|
192 | } VBOXWDDM_DMA_PRIVATEDATA_FLIP, *PVBOXWDDM_DMA_PRIVATEDATA_FLIP;
|
---|
193 |
|
---|
194 | typedef struct VBOXWDDM_DMA_PRIVATEDATA_CLRFILL
|
---|
195 | {
|
---|
196 | VBOXWDDM_DMA_PRIVATEDATA_PRESENTHDR Hdr;
|
---|
197 | VBOXVDMA_CLRFILL ClrFill;
|
---|
198 | } VBOXWDDM_DMA_PRIVATEDATA_CLRFILL, *PVBOXWDDM_DMA_PRIVATEDATA_CLRFILL;
|
---|
199 |
|
---|
200 | typedef struct VBOXWDDM_UHGSMI_BUFFER_SUBMIT_INFO
|
---|
201 | {
|
---|
202 | VBOXWDDM_DMA_ALLOCINFO Alloc;
|
---|
203 | uint32_t cbData;
|
---|
204 | uint32_t bDoNotSignalCompletion;
|
---|
205 | } VBOXWDDM_UHGSMI_BUFFER_SUBMIT_INFO, *PVBOXWDDM_UHGSMI_BUFFER_SUBMIT_INFO;
|
---|
206 |
|
---|
207 | typedef struct VBOXWDDM_DMA_PRIVATEDATA_CHROMIUM_CMD
|
---|
208 | {
|
---|
209 | VBOXWDDM_DMA_PRIVATEDATA_BASEHDR Base;
|
---|
210 | VBOXWDDM_UHGSMI_BUFFER_SUBMIT_INFO aBufInfos[1];
|
---|
211 | } VBOXWDDM_DMA_PRIVATEDATA_CHROMIUM_CMD, *PVBOXWDDM_DMA_PRIVATEDATA_CHROMIUM_CMD;
|
---|
212 |
|
---|
213 | typedef struct VBOXWDDM_OPENALLOCATION
|
---|
214 | {
|
---|
215 | D3DKMT_HANDLE hAllocation;
|
---|
216 | } VBOXWDDM_OPENALLOCATION, *PVBOXWDDM_OPENALLOCATION;
|
---|
217 |
|
---|
218 | #ifdef VBOXWDDM_RENDER_FROM_SHADOW
|
---|
219 | # define VBOXWDDM_FB_ALLOCATION(_pSrc) ((_pSrc)->pShadowAllocation)
|
---|
220 | #else
|
---|
221 | # define VBOXWDDM_FB_ALLOCATION(_pSrc) ((_pSrc)->pPrimaryAllocation)
|
---|
222 | #endif
|
---|
223 |
|
---|
224 | #define VBOXWDDM_MAX_VIDEOMODES 128
|
---|
225 |
|
---|
226 | typedef struct VBOXWDDM_VIDEOMODES_INFO
|
---|
227 | {
|
---|
228 | int32_t iPreferredMode;
|
---|
229 | uint32_t cModes;
|
---|
230 | uint32_t cPrevModes;
|
---|
231 | VIDEO_MODE_INFORMATION aModes[VBOXWDDM_MAX_VIDEOMODES];
|
---|
232 | uint32_t cResolutions;
|
---|
233 | D3DKMDT_2DREGION aResolutions[VBOXWDDM_MAX_VIDEOMODES];
|
---|
234 | } VBOXWDDM_VIDEOMODES_INFO, *PVBOXWDDM_VIDEOMODES_INFO;
|
---|
235 |
|
---|
236 | #endif /* #ifndef ___VBoxVideoWddm_h___ */
|
---|