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 | /* one page size */
|
---|
18 | #define VBOXWDDM_C_DMA_BUFFER_SIZE 0x1000
|
---|
19 | #define VBOXWDDM_C_DMA_PRIVATEDATA_SIZE 0x4000
|
---|
20 | #define VBOXWDDM_C_ALLOC_LIST_SIZE 0xc00
|
---|
21 | #define VBOXWDDM_C_PATH_LOCATION_LIST_SIZE 0xc00
|
---|
22 |
|
---|
23 | #define VBOXWDDM_C_POINTER_MAX_WIDTH 64
|
---|
24 | #define VBOXWDDM_C_POINTER_MAX_HEIGHT 64
|
---|
25 |
|
---|
26 | #define VBOXWDDM_C_VDMA_BUFFER_SIZE (64*_1K)
|
---|
27 |
|
---|
28 | #ifdef VBOXWDDM_WITH_VBVA
|
---|
29 | # define VBOXWDDM_RENDER_FROM_SHADOW
|
---|
30 | #endif
|
---|
31 |
|
---|
32 | #ifndef DEBUG_misha
|
---|
33 | # ifdef Assert
|
---|
34 | # undef Assert
|
---|
35 | # define Assert(_a) do{}while(0)
|
---|
36 | # endif
|
---|
37 | # ifdef AssertBreakpoint
|
---|
38 | # undef AssertBreakpoint
|
---|
39 | # define AssertBreakpoint() do{}while(0)
|
---|
40 | # endif
|
---|
41 | # ifdef AssertFailed
|
---|
42 | # undef AssertFailed
|
---|
43 | # define AssertFailed() do{}while(0)
|
---|
44 | # endif
|
---|
45 | #endif
|
---|
46 |
|
---|
47 | PVOID vboxWddmMemAlloc(IN SIZE_T cbSize);
|
---|
48 | PVOID vboxWddmMemAllocZero(IN SIZE_T cbSize);
|
---|
49 | VOID vboxWddmMemFree(PVOID pvMem);
|
---|
50 |
|
---|
51 | /* allocation */
|
---|
52 | //#define VBOXWDDM_ALLOCATIONINDEX_VOID (~0U)
|
---|
53 | typedef struct VBOXWDDM_ALLOCATION
|
---|
54 | {
|
---|
55 | VBOXWDDM_ALLOC_TYPE enmType;
|
---|
56 | D3DDDI_RESOURCEFLAGS fRcFlags;
|
---|
57 | UINT SegmentId;
|
---|
58 | VBOXVIDEOOFFSET offVram;
|
---|
59 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
60 | VBOXVHWA_SURFHANDLE hHostHandle;
|
---|
61 | #endif
|
---|
62 | BOOLEAN bVisible;
|
---|
63 | BOOLEAN bAssigned;
|
---|
64 | VBOXWDDM_SURFACE_DESC SurfDesc;
|
---|
65 | struct VBOXWDDM_RESOURCE *pResource;
|
---|
66 | /* to return to the Runtime on DxgkDdiCreateAllocation */
|
---|
67 | DXGK_ALLOCATIONUSAGEHINT UsageHint;
|
---|
68 | uint32_t iIndex;
|
---|
69 | } VBOXWDDM_ALLOCATION, *PVBOXWDDM_ALLOCATION;
|
---|
70 |
|
---|
71 | typedef struct VBOXWDDM_RESOURCE
|
---|
72 | {
|
---|
73 | uint32_t fFlags;
|
---|
74 | VBOXWDDM_RC_DESC RcDesc;
|
---|
75 | uint32_t cAllocations;
|
---|
76 | VBOXWDDM_ALLOCATION aAllocations[1];
|
---|
77 | } VBOXWDDM_RESOURCE, *PVBOXWDDM_RESOURCE;
|
---|
78 |
|
---|
79 | DECLINLINE(PVBOXWDDM_RESOURCE) vboxWddmResourceForAlloc(PVBOXWDDM_ALLOCATION pAlloc)
|
---|
80 | {
|
---|
81 | #if 0
|
---|
82 | if(pAlloc->iIndex == VBOXWDDM_ALLOCATIONINDEX_VOID)
|
---|
83 | return NULL;
|
---|
84 | PVBOXWDDM_RESOURCE pRc = (PVBOXWDDM_RESOURCE)(((uint8_t*)pAlloc) - RT_OFFSETOF(VBOXWDDM_RESOURCE, aAllocations[pAlloc->iIndex]));
|
---|
85 | return pRc;
|
---|
86 | #else
|
---|
87 | return pAlloc->pResource;
|
---|
88 | #endif
|
---|
89 | }
|
---|
90 |
|
---|
91 | typedef struct VBOXWDDM_OVERLAY
|
---|
92 | {
|
---|
93 | PDEVICE_EXTENSION pDevExt;
|
---|
94 | PVBOXWDDM_RESOURCE pResource;
|
---|
95 | PVBOXWDDM_ALLOCATION pCurentAlloc;
|
---|
96 | D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId;
|
---|
97 | } VBOXWDDM_OVERLAY, *PVBOXWDDM_OVERLAY;
|
---|
98 |
|
---|
99 | typedef enum
|
---|
100 | {
|
---|
101 | VBOXWDDM_DEVICE_TYPE_UNDEFINED = 0,
|
---|
102 | VBOXWDDM_DEVICE_TYPE_SYSTEM
|
---|
103 | } VBOXWDDM_DEVICE_TYPE;
|
---|
104 |
|
---|
105 | typedef struct VBOXWDDM_DEVICE
|
---|
106 | {
|
---|
107 | struct _DEVICE_EXTENSION * pAdapter; /* Adapder info */
|
---|
108 | HANDLE hDevice; /* handle passed to CreateDevice */
|
---|
109 | VBOXWDDM_DEVICE_TYPE enmType; /* device creation flags passed to DxgkDdiCreateDevice, not sure we need it */
|
---|
110 | } VBOXWDDM_DEVICE, *PVBOXWDDM_DEVICE;
|
---|
111 |
|
---|
112 | typedef enum
|
---|
113 | {
|
---|
114 | VBOXWDDM_CONTEXT_TYPE_UNDEFINED = 0,
|
---|
115 | VBOXWDDM_CONTEXT_TYPE_SYSTEM,
|
---|
116 | VBOXWDDM_CONTEXT_TYPE_CUSTOM_3D,
|
---|
117 | VBOXWDDM_CONTEXT_TYPE_CUSTOM_2D
|
---|
118 | } VBOXWDDM_CONTEXT_TYPE;
|
---|
119 |
|
---|
120 | typedef struct VBOXWDDM_CONTEXT
|
---|
121 | {
|
---|
122 | LIST_ENTRY ListEntry;
|
---|
123 | struct VBOXWDDM_DEVICE * pDevice;
|
---|
124 | HANDLE hContext;
|
---|
125 | VBOXWDDM_CONTEXT_TYPE enmType;
|
---|
126 | UINT NodeOrdinal;
|
---|
127 | UINT EngineAffinity;
|
---|
128 | UINT uLastCompletedCmdFenceId;
|
---|
129 | RECT ViewRect;
|
---|
130 | PVBOXVIDEOCM_CMD_RECTS pLastReportedRects;
|
---|
131 | VBOXVIDEOCM_CTX CmContext;
|
---|
132 | } VBOXWDDM_CONTEXT, *PVBOXWDDM_CONTEXT;
|
---|
133 |
|
---|
134 | #define VBOXWDDMENTRY_2_CONTEXT(_pE) ((PVBOXWDDM_CONTEXT)((uint8_t*)(_pE) - RT_OFFSETOF(VBOXWDDM_CONTEXT, ListEntry)))
|
---|
135 |
|
---|
136 | typedef struct VBOXWDDM_DMA_ALLOCINFO
|
---|
137 | {
|
---|
138 | PVBOXWDDM_ALLOCATION pAlloc;
|
---|
139 | VBOXVIDEOOFFSET offAlloc;
|
---|
140 | UINT segmentIdAlloc;
|
---|
141 | D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId;
|
---|
142 | } VBOXWDDM_DMA_ALLOCINFO, *PVBOXWDDM_DMA_ALLOCINFO;
|
---|
143 |
|
---|
144 | typedef struct VBOXWDDM_DMA_PRIVATEDATA_FLAFS
|
---|
145 | {
|
---|
146 | union
|
---|
147 | {
|
---|
148 | struct
|
---|
149 | {
|
---|
150 | UINT bCmdInDmaBuffer : 1;
|
---|
151 | UINT bReserved : 31;
|
---|
152 | };
|
---|
153 | uint32_t Value;
|
---|
154 | };
|
---|
155 | } VBOXWDDM_DMA_PRIVATEDATA_FLAFS, *PVBOXWDDM_DMA_PRIVATEDATA_FLAFS;
|
---|
156 |
|
---|
157 | typedef struct VBOXWDDM_DMA_PRIVATEDATA_HDR
|
---|
158 | {
|
---|
159 | PVBOXWDDM_CONTEXT pContext;
|
---|
160 | VBOXWDDM_DMA_PRIVATEDATA_FLAFS fFlags;
|
---|
161 | VBOXVDMACMD_TYPE enmCmd;
|
---|
162 | VBOXWDDM_DMA_ALLOCINFO SrcAllocInfo;
|
---|
163 | VBOXWDDM_DMA_ALLOCINFO DstAllocInfo;
|
---|
164 | }VBOXWDDM_DMA_PRIVATEDATA_HDR, *PVBOXWDDM_DMA_PRIVATEDATA_HDR;
|
---|
165 |
|
---|
166 | #ifdef VBOXWDDM_RENDER_FROM_SHADOW
|
---|
167 |
|
---|
168 | typedef struct VBOXWDDM_DMA_PRESENT_RENDER_FROM_SHADOW
|
---|
169 | {
|
---|
170 | VBOXWDDM_DMA_PRIVATEDATA_HDR Hdr;
|
---|
171 | RECT rect;
|
---|
172 | } VBOXWDDM_DMA_PRESENT_RENDER_FROM_SHADOW, *PVBOXWDDM_DMA_PRESENT_RENDER_FROM_SHADOW;
|
---|
173 |
|
---|
174 | #endif
|
---|
175 |
|
---|
176 | typedef struct VBOXWDDM_DMA_PRESENT_BLT
|
---|
177 | {
|
---|
178 | VBOXWDDM_DMA_PRIVATEDATA_HDR Hdr;
|
---|
179 | RECT SrcRect;
|
---|
180 | VBOXVDMAPIPE_RECTS DstRects;
|
---|
181 | }VBOXWDDM_DMA_PRESENT_BLT, *PVBOXWDDM_DMA_PRESENT_BLT;
|
---|
182 |
|
---|
183 |
|
---|
184 | typedef struct VBOXWDDM_OPENALLOCATION
|
---|
185 | {
|
---|
186 | D3DKMT_HANDLE hAllocation;
|
---|
187 | } VBOXWDDM_OPENALLOCATION, *PVBOXWDDM_OPENALLOCATION;
|
---|
188 |
|
---|
189 | #ifdef VBOXWDDM_RENDER_FROM_SHADOW
|
---|
190 | # define VBOXWDDM_FB_ALLOCATION(_pSrc) ((_pSrc)->pShadowAllocation)
|
---|
191 | #else
|
---|
192 | # define VBOXWDDM_FB_ALLOCATION(_pSrc) ((_pSrc)->pPrimaryAllocation)
|
---|
193 | #endif
|
---|
194 |
|
---|
195 | //DECLINLINE(VBOXVIDEOOFFSET) vboxWddmOffsetFromPhAddress(PHYSICAL_ADDRESS phAddr)
|
---|
196 | //{
|
---|
197 | // return (VBOXVIDEOOFFSET)(phAddr.QuadPart ? phAddr.QuadPart - VBE_DISPI_LFB_PHYSICAL_ADDRESS : VBOXVIDEOOFFSET_VOID);
|
---|
198 | //}
|
---|
199 |
|
---|
200 | #endif /* #ifndef ___VBoxVideoWddm_h___ */
|
---|