1 | /** @file
|
---|
2 | *
|
---|
3 | * VBoxVideo Display D3D User mode dll
|
---|
4 | *
|
---|
5 | * Copyright (C) 2010 Oracle Corporation
|
---|
6 | *
|
---|
7 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
8 | * available from http://www.virtualbox.org. This file is free software;
|
---|
9 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
10 | * General Public License (GPL) as published by the Free Software
|
---|
11 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
12 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
13 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
14 | */
|
---|
15 | #ifndef ___VBoxDispD3D_h___
|
---|
16 | #define ___VBoxDispD3D_h___
|
---|
17 |
|
---|
18 | #include "VBoxDispD3DIf.h"
|
---|
19 | #include "../../Miniport/wddm/VBoxVideoIf.h"
|
---|
20 |
|
---|
21 | #include <iprt/cdefs.h>
|
---|
22 | #include <iprt/list.h>
|
---|
23 |
|
---|
24 | #define VBOXWDDMDISP_MAX_VERTEX_STREAMS 16
|
---|
25 |
|
---|
26 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
27 | typedef struct VBOXDISPVHWA_INFO
|
---|
28 | {
|
---|
29 | VBOXVHWA_INFO Settings;
|
---|
30 | }VBOXDISPVHWA_INFO;
|
---|
31 |
|
---|
32 | /* represents settings secific to
|
---|
33 | * display device (head) on the multiple-head graphics card
|
---|
34 | * currently used for 2D (overlay) only since in theory its settings
|
---|
35 | * can differ per each frontend's framebuffer. */
|
---|
36 | typedef struct VBOXWDDMDISP_HEAD
|
---|
37 | {
|
---|
38 | VBOXDISPVHWA_INFO Vhwa;
|
---|
39 | } VBOXWDDMDISP_HEAD;
|
---|
40 | #endif
|
---|
41 |
|
---|
42 | typedef struct VBOXWDDMDISP_ADAPTER
|
---|
43 | {
|
---|
44 | HANDLE hAdapter;
|
---|
45 | UINT uIfVersion;
|
---|
46 | UINT uRtVersion;
|
---|
47 | VBOXDISPD3D D3D;
|
---|
48 | VBOXDISPWORKER WndWorker;
|
---|
49 | IDirect3D9Ex * pD3D9If;
|
---|
50 | D3DDDI_ADAPTERCALLBACKS RtCallbacks;
|
---|
51 | uint32_t cFormstOps;
|
---|
52 | FORMATOP *paFormstOps;
|
---|
53 | uint32_t cSurfDescs;
|
---|
54 | DDSURFACEDESC *paSurfDescs;
|
---|
55 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
56 | uint32_t cHeads;
|
---|
57 | VBOXWDDMDISP_HEAD aHeads[1];
|
---|
58 | #endif
|
---|
59 | } VBOXWDDMDISP_ADAPTER, *PVBOXWDDMDISP_ADAPTER;
|
---|
60 |
|
---|
61 | typedef struct VBOXWDDMDISP_CONTEXT
|
---|
62 | {
|
---|
63 | RTLISTNODE ListNode;
|
---|
64 | struct VBOXWDDMDISP_DEVICE *pDevice;
|
---|
65 | D3DDDICB_CREATECONTEXT ContextInfo;
|
---|
66 | } VBOXWDDMDISP_CONTEXT, *PVBOXWDDMDISP_CONTEXT;
|
---|
67 |
|
---|
68 | typedef struct VBOXWDDMDISP_STREAMSOURCEUM
|
---|
69 | {
|
---|
70 | CONST VOID* pvBuffer;
|
---|
71 | UINT cbStride;
|
---|
72 | } VBOXWDDMDISP_STREAMSOURCEUM, *PVBOXWDDMDISP_STREAMSOURCEUM;
|
---|
73 |
|
---|
74 | typedef struct VBOXWDDMDISP_INDICIESUM
|
---|
75 | {
|
---|
76 | CONST VOID* pvBuffer;
|
---|
77 | UINT cbSize;
|
---|
78 | } VBOXWDDMDISP_INDICIESUM, *PVBOXWDDMDISP_INDICIESUM;
|
---|
79 |
|
---|
80 | struct VBOXWDDMDISP_ALLOCATION;
|
---|
81 |
|
---|
82 | typedef struct VBOXWDDMDISP_STREAM_SOURCE_INFO
|
---|
83 | {
|
---|
84 | UINT uiOffset;
|
---|
85 | UINT uiStride;
|
---|
86 | } VBOXWDDMDISP_STREAM_SOURCE_INFO;
|
---|
87 |
|
---|
88 | typedef struct VBOXWDDMDISP_INDICES_INFO
|
---|
89 | {
|
---|
90 | UINT uiStride;
|
---|
91 | } VBOXWDDMDISP_INDICES_INFO;
|
---|
92 |
|
---|
93 | typedef struct VBOXWDDMDISP_SCREEN
|
---|
94 | {
|
---|
95 | IDirect3DDevice9 *pDevice9If;
|
---|
96 | struct VBOXWDDMDISP_RESOURCE *pRenderTargetRc;
|
---|
97 | // struct VBOXWDDMDISP_RESOURCE *pDstSharedRc;
|
---|
98 | uint32_t iRenderTargetFrontBuf;
|
---|
99 | HWND hWnd;
|
---|
100 | } VBOXWDDMDISP_SCREEN, *PVBOXWDDMDISP_SCREEN;
|
---|
101 |
|
---|
102 | typedef struct VBOXWDDMDISP_DEVICE
|
---|
103 | {
|
---|
104 | HANDLE hDevice;
|
---|
105 | PVBOXWDDMDISP_ADAPTER pAdapter;
|
---|
106 | UINT u32IfVersion;
|
---|
107 | UINT uRtVersion;
|
---|
108 | D3DDDI_DEVICECALLBACKS RtCallbacks;
|
---|
109 | VOID *pvCmdBuffer;
|
---|
110 | UINT cbCmdBuffer;
|
---|
111 | D3DDDI_CREATEDEVICEFLAGS fFlags;
|
---|
112 | #ifndef VBOXWDDM_WITH_VISIBLE_FB
|
---|
113 | IDirect3DSurface9 *pRenderTargetFbCopy;
|
---|
114 | #endif
|
---|
115 | /* number of StreamSources set */
|
---|
116 | UINT cStreamSources;
|
---|
117 | VBOXWDDMDISP_STREAMSOURCEUM aStreamSourceUm[VBOXWDDMDISP_MAX_VERTEX_STREAMS];
|
---|
118 | VBOXWDDMDISP_ALLOCATION *aStreamSource[VBOXWDDMDISP_MAX_VERTEX_STREAMS];
|
---|
119 | VBOXWDDMDISP_STREAM_SOURCE_INFO StreamSourceInfo[VBOXWDDMDISP_MAX_VERTEX_STREAMS];
|
---|
120 | VBOXWDDMDISP_INDICIESUM IndiciesUm;
|
---|
121 | VBOXWDDMDISP_ALLOCATION *pIndicesAlloc;
|
---|
122 | VBOXWDDMDISP_INDICES_INFO IndiciesInfo;
|
---|
123 | /* need to cache the ViewPort data because IDirect3DDevice9::SetViewport
|
---|
124 | * is split into two calls : SetViewport & SetZRange */
|
---|
125 | D3DVIEWPORT9 ViewPort;
|
---|
126 | VBOXWDDMDISP_CONTEXT DefaultContext;
|
---|
127 |
|
---|
128 | CRITICAL_SECTION DirtyAllocListLock;
|
---|
129 | RTLISTNODE DirtyAllocList;
|
---|
130 |
|
---|
131 | UINT iPrimaryScreen;
|
---|
132 | UINT cScreens;
|
---|
133 | VBOXWDDMDISP_SCREEN aScreens[VBOX_VIDEO_MAX_SCREENS];
|
---|
134 | } VBOXWDDMDISP_DEVICE, *PVBOXWDDMDISP_DEVICE;
|
---|
135 |
|
---|
136 | typedef struct VBOXWDDMDISP_LOCKINFO
|
---|
137 | {
|
---|
138 | uint32_t cLocks;
|
---|
139 | union {
|
---|
140 | D3DDDIRANGE Range;
|
---|
141 | RECT Area;
|
---|
142 | D3DDDIBOX Box;
|
---|
143 | };
|
---|
144 | D3DDDI_LOCKFLAGS fFlags;
|
---|
145 | D3DLOCKED_RECT LockedRect;
|
---|
146 | } VBOXWDDMDISP_LOCKINFO;
|
---|
147 |
|
---|
148 | typedef enum
|
---|
149 | {
|
---|
150 | VBOXDISP_D3DIFTYPE_UNDEFINED = 0,
|
---|
151 | VBOXDISP_D3DIFTYPE_SURFACE,
|
---|
152 | VBOXDISP_D3DIFTYPE_TEXTURE,
|
---|
153 | VBOXDISP_D3DIFTYPE_VERTEXBUFFER,
|
---|
154 | VBOXDISP_D3DIFTYPE_INDEXBUFFER
|
---|
155 | } VBOXDISP_D3DIFTYPE;
|
---|
156 |
|
---|
157 | typedef struct VBOXWDDMDISP_ALLOCATION
|
---|
158 | {
|
---|
159 | D3DKMT_HANDLE hAllocation;
|
---|
160 | VBOXWDDM_ALLOC_TYPE enmType;
|
---|
161 | void* pvMem;
|
---|
162 | /* object type is defined by enmD3DIfType enum */
|
---|
163 | IUnknown *pD3DIf;
|
---|
164 | IUnknown *pSecondaryOpenedD3DIf;
|
---|
165 | VBOXDISP_D3DIFTYPE enmD3DIfType;
|
---|
166 | RTLISTNODE DirtyAllocListEntry;
|
---|
167 | HANDLE hSharedHandle;
|
---|
168 | VBOXWDDMDISP_LOCKINFO LockInfo;
|
---|
169 | VBOXWDDM_DIRTYREGION DirtyRegion; /* <- dirty region to notify host about */
|
---|
170 | VBOXWDDM_SURFACE_DESC SurfDesc;
|
---|
171 | } VBOXWDDMDISP_ALLOCATION, *PVBOXWDDMDISP_ALLOCATION;
|
---|
172 |
|
---|
173 | typedef struct VBOXWDDMDISP_RESOURCE
|
---|
174 | {
|
---|
175 | HANDLE hResource;
|
---|
176 | D3DKMT_HANDLE hKMResource;
|
---|
177 | PVBOXWDDMDISP_DEVICE pDevice;
|
---|
178 | uint32_t fFlags;
|
---|
179 | VBOXWDDM_RC_DESC RcDesc;
|
---|
180 | UINT cAllocations;
|
---|
181 | VBOXWDDMDISP_ALLOCATION aAllocations[1];
|
---|
182 | } VBOXWDDMDISP_RESOURCE, *PVBOXWDDMDISP_RESOURCE;
|
---|
183 |
|
---|
184 | typedef struct VBOXWDDMDISP_TSS_LOOKUP
|
---|
185 | {
|
---|
186 | BOOL bSamplerState;
|
---|
187 | DWORD dType;
|
---|
188 | } VBOXWDDMDISP_TSS_LOOKUP;
|
---|
189 |
|
---|
190 | typedef struct VBOXWDDMDISP_OVERLAY
|
---|
191 | {
|
---|
192 | D3DKMT_HANDLE hOverlay;
|
---|
193 | D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId;
|
---|
194 | PVBOXWDDMDISP_RESOURCE *pResource;
|
---|
195 | } VBOXWDDMDISP_OVERLAY, *PVBOXWDDMDISP_OVERLAY;
|
---|
196 |
|
---|
197 | #define VBOXDISPMODE_IS_3D(_p) (!!((_p)->pD3D9If))
|
---|
198 | #ifdef VBOXDISP_EARLYCREATEDEVICE
|
---|
199 | #define VBOXDISP_D3DEV(_p) (_p)->pDevice9If
|
---|
200 | #else
|
---|
201 | #define VBOXDISP_D3DEV(_p) vboxWddmD3DDeviceGetPrimary(_p)
|
---|
202 | #endif
|
---|
203 |
|
---|
204 | #endif /* #ifndef ___VBoxDispD3D_h___ */
|
---|