VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxDispD3D.h@ 43334

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

wddm/3d: volume texture func impl; fixes & cleanup

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.5 KB
Line 
1/* $Id: VBoxDispD3D.h 43334 2012-09-14 17:34:33Z vboxsync $ */
2
3/** @file
4 * VBoxVideo Display D3D User mode dll
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 ___VBoxDispD3D_h___
20#define ___VBoxDispD3D_h___
21
22#include "VBoxDispD3DIf.h"
23#include "common/wddm/VBoxMPIf.h"
24#ifdef VBOX_WITH_CRHGSMI
25#include "VBoxUhgsmiDisp.h"
26#endif
27
28#ifdef VBOX_WDDMDISP_WITH_PROFILE
29#include <iprt/asm.h>
30extern volatile uint32_t g_u32VBoxDispProfileFunctionLoggerIndex;
31# define VBOXDISPPROFILE_FUNCTION_LOGGER_INDEX_GEN() ASMAtomicIncU32(&g_u32VBoxDispProfileFunctionLoggerIndex);
32# include "VBoxDispProfile.h"
33#endif
34
35#include <iprt/cdefs.h>
36#include <iprt/list.h>
37
38#define VBOXWDDMDISP_MAX_VERTEX_STREAMS 16
39#define VBOXWDDMDISP_MAX_SWAPCHAIN_SIZE 16
40#define VBOXWDDMDISP_MAX_TEX_SAMPLERS 16
41#define VBOXWDDMDISP_TOTAL_SAMPLERS VBOXWDDMDISP_MAX_TEX_SAMPLERS + 5
42#define VBOXWDDMDISP_SAMPLER_IDX_IS_SPECIAL(_i) ((_i) >= D3DDMAPSAMPLER && (_i) <= D3DVERTEXTEXTURESAMPLER3)
43#define VBOXWDDMDISP_SAMPLER_IDX_SPECIAL(_i) (VBOXWDDMDISP_SAMPLER_IDX_IS_SPECIAL(_i) ? (int)((_i) - D3DDMAPSAMPLER + VBOXWDDMDISP_MAX_TEX_SAMPLERS) : (int)-1)
44#define VBOXWDDMDISP_SAMPLER_IDX(_i) (((_i) < VBOXWDDMDISP_MAX_TEX_SAMPLERS) ? (int)(_i) : VBOXWDDMDISP_SAMPLER_IDX_SPECIAL(_i))
45
46
47/* maximum number of direct render targets to be used before
48 * switching to offscreen rendering */
49#ifdef VBOXWDDMDISP_DEBUG
50# define VBOXWDDMDISP_MAX_DIRECT_RTS g_VBoxVDbgCfgMaxDirectRts
51#else
52# define VBOXWDDMDISP_MAX_DIRECT_RTS 3
53#endif
54
55#define VBOXWDDMDISP_IS_TEXTURE(_f) ((_f).Texture || (_f).Value == 0)
56
57#ifdef VBOX_WITH_VIDEOHWACCEL
58typedef struct VBOXDISPVHWA_INFO
59{
60 VBOXVHWA_INFO Settings;
61}VBOXDISPVHWA_INFO;
62
63/* represents settings secific to
64 * display device (head) on the multiple-head graphics card
65 * currently used for 2D (overlay) only since in theory its settings
66 * can differ per each frontend's framebuffer. */
67typedef struct VBOXWDDMDISP_HEAD
68{
69 VBOXDISPVHWA_INFO Vhwa;
70} VBOXWDDMDISP_HEAD;
71#endif
72
73typedef struct VBOXWDDMDISP_ADAPTER
74{
75 HANDLE hAdapter;
76 UINT uIfVersion;
77 UINT uRtVersion;
78 D3DDDI_ADAPTERCALLBACKS RtCallbacks;
79 VBOXWDDMDISP_D3D D3D;
80 VBOXWDDMDISP_FORMATS Formats;
81#ifdef VBOX_WDDMDISP_WITH_PROFILE
82 VBoxDispProfileFpsCounter ProfileDdiFps;
83 VBoxDispProfileSet ProfileDdiFunc;
84#endif
85#ifdef VBOX_WITH_VIDEOHWACCEL
86 uint32_t cHeads;
87 VBOXWDDMDISP_HEAD aHeads[1];
88#endif
89} VBOXWDDMDISP_ADAPTER, *PVBOXWDDMDISP_ADAPTER;
90
91typedef struct VBOXWDDMDISP_CONTEXT
92{
93 RTLISTNODE ListNode;
94 struct VBOXWDDMDISP_DEVICE *pDevice;
95 D3DDDICB_CREATECONTEXT ContextInfo;
96} VBOXWDDMDISP_CONTEXT, *PVBOXWDDMDISP_CONTEXT;
97
98typedef struct VBOXWDDMDISP_STREAMSOURCEUM
99{
100 CONST VOID* pvBuffer;
101 UINT cbStride;
102} VBOXWDDMDISP_STREAMSOURCEUM, *PVBOXWDDMDISP_STREAMSOURCEUM;
103
104typedef struct VBOXWDDMDISP_INDICIESUM
105{
106 CONST VOID* pvBuffer;
107 UINT cbSize;
108} VBOXWDDMDISP_INDICIESUM, *PVBOXWDDMDISP_INDICIESUM;
109
110struct VBOXWDDMDISP_ALLOCATION;
111
112typedef struct VBOXWDDMDISP_STREAM_SOURCE_INFO
113{
114 UINT uiOffset;
115 UINT uiStride;
116} VBOXWDDMDISP_STREAM_SOURCE_INFO;
117
118typedef struct VBOXWDDMDISP_INDICES_INFO
119{
120 UINT uiStride;
121} VBOXWDDMDISP_INDICES_INFO;
122
123typedef struct VBOXWDDMDISP_RENDERTGT_FLAGS
124{
125 union
126 {
127 struct
128 {
129 UINT bAdded : 1;
130 UINT bRemoved : 1;
131 UINT Reserved : 30;
132 };
133 uint32_t Value;
134 };
135}VBOXWDDMDISP_RENDERTGT_FLAGS;
136
137typedef struct VBOXWDDMDISP_RENDERTGT
138{
139 struct VBOXWDDMDISP_ALLOCATION *pAlloc;
140 UINT cNumFlips;
141 VBOXWDDMDISP_RENDERTGT_FLAGS fFlags;
142} VBOXWDDMDISP_RENDERTGT, *PVBOXWDDMDISP_RENDERTGT;
143
144#define VBOXWDDMDISP_INDEX_UNDEFINED (~0)
145typedef struct VBOXWDDMDISP_SWAPCHAIN_FLAGS
146{
147 union
148 {
149 struct
150 {
151 UINT bChanged : 1;
152 UINT bRtReportingPresent : 1; /* use VBox extension method for performing present */
153 UINT bSwitchReportingPresent : 1; /* switch to use VBox extension method for performing present on next present */
154 UINT Reserved : 29;
155 };
156 uint32_t Value;
157 };
158}VBOXWDDMDISP_SWAPCHAIN_FLAGS;
159
160typedef struct VBOXWDDMDISP_SWAPCHAIN
161{
162 RTLISTNODE ListEntry;
163 UINT iBB; /* Backbuffer index */
164 UINT cRTs; /* Number of render targets in the swapchain */
165 VBOXWDDMDISP_SWAPCHAIN_FLAGS fFlags;
166#ifndef VBOXWDDM_WITH_VISIBLE_FB
167 IDirect3DSurface9 *pRenderTargetFbCopy;
168 BOOL bRTFbCopyUpToDate;
169#endif
170 IDirect3DSwapChain9 *pSwapChainIf;
171 /* a read-only hWnd we receive from wine
172 * we use it for visible region notifications only,
173 * it MUST NOT be destroyed on swapchain destruction,
174 * wine will handle that for us */
175 HWND hWnd;
176 VBOXDISP_KMHANDLE hSwapchainKm;
177 VBOXWDDMDISP_RENDERTGT aRTs[VBOXWDDMDISP_MAX_SWAPCHAIN_SIZE];
178} VBOXWDDMDISP_SWAPCHAIN, *PVBOXWDDMDISP_SWAPCHAIN;
179
180typedef struct VBOXWDDMDISP_DEVICE
181{
182 HANDLE hDevice;
183 PVBOXWDDMDISP_ADAPTER pAdapter;
184 IDirect3DDevice9 *pDevice9If;
185 RTLISTANCHOR SwapchainList;
186 UINT u32IfVersion;
187 UINT uRtVersion;
188 D3DDDI_DEVICECALLBACKS RtCallbacks;
189 VOID *pvCmdBuffer;
190 UINT cbCmdBuffer;
191 D3DDDI_CREATEDEVICEFLAGS fFlags;
192 /* number of StreamSources set */
193 UINT cStreamSources;
194 VBOXWDDMDISP_STREAMSOURCEUM aStreamSourceUm[VBOXWDDMDISP_MAX_VERTEX_STREAMS];
195 struct VBOXWDDMDISP_ALLOCATION *aStreamSource[VBOXWDDMDISP_MAX_VERTEX_STREAMS];
196 VBOXWDDMDISP_STREAM_SOURCE_INFO StreamSourceInfo[VBOXWDDMDISP_MAX_VERTEX_STREAMS];
197 VBOXWDDMDISP_INDICIESUM IndiciesUm;
198 struct VBOXWDDMDISP_ALLOCATION *pIndicesAlloc;
199 VBOXWDDMDISP_INDICES_INFO IndiciesInfo;
200 /* need to cache the ViewPort data because IDirect3DDevice9::SetViewport
201 * is split into two calls : SetViewport & SetZRange */
202 D3DVIEWPORT9 ViewPort;
203 VBOXWDDMDISP_CONTEXT DefaultContext;
204 VBOXUHGSMI_PRIVATE_D3D Uhgsmi;
205
206 /* no lock is needed for this since we're guaranteed the per-device calls are not reentrant */
207 RTLISTANCHOR DirtyAllocList;
208
209 UINT cSamplerTextures;
210 struct VBOXWDDMDISP_RESOURCE *aSamplerTextures[VBOXWDDMDISP_TOTAL_SAMPLERS];
211
212#ifdef VBOX_WDDMDISP_WITH_PROFILE
213 VBoxDispProfileFpsCounter ProfileDdiFps;
214 VBoxDispProfileSet ProfileDdiFunc;
215
216 VBoxDispProfileSet ProfileDdiPresentCb;
217#endif
218
219#ifdef VBOXWDDMDISP_DEBUG_TIMER
220 HANDLE hTimerQueue;
221#endif
222
223 UINT cRTs;
224 struct VBOXWDDMDISP_ALLOCATION * apRTs[1];
225} VBOXWDDMDISP_DEVICE, *PVBOXWDDMDISP_DEVICE;
226
227typedef struct VBOXWDDMDISP_LOCKINFO
228{
229 uint32_t cLocks;
230 union {
231 D3DDDIRANGE Range;
232 RECT Area;
233 D3DDDIBOX Box;
234 };
235 D3DDDI_LOCKFLAGS fFlags;
236 union {
237 D3DLOCKED_RECT LockedRect;
238 D3DLOCKED_BOX LockedBox;
239 };
240#ifdef VBOXWDDMDISP_DEBUG
241 PVOID pvData;
242#endif
243} VBOXWDDMDISP_LOCKINFO;
244
245typedef enum
246{
247 VBOXDISP_D3DIFTYPE_UNDEFINED = 0,
248 VBOXDISP_D3DIFTYPE_SURFACE,
249 VBOXDISP_D3DIFTYPE_TEXTURE,
250 VBOXDISP_D3DIFTYPE_CUBE_TEXTURE,
251 VBOXDISP_D3DIFTYPE_VOLUME_TEXTURE,
252 VBOXDISP_D3DIFTYPE_VERTEXBUFFER,
253 VBOXDISP_D3DIFTYPE_INDEXBUFFER
254} VBOXDISP_D3DIFTYPE;
255
256typedef struct VBOXWDDMDISP_ALLOCATION
257{
258 D3DKMT_HANDLE hAllocation;
259 VBOXWDDM_ALLOC_TYPE enmType;
260 UINT iAlloc;
261 struct VBOXWDDMDISP_RESOURCE *pRc;
262 void* pvMem;
263 UINT D3DWidth;
264 /* object type is defined by enmD3DIfType enum */
265 IUnknown *pD3DIf;
266 VBOXDISP_D3DIFTYPE enmD3DIfType;
267 /* list entry used to add allocation to the dirty alloc list */
268 RTLISTNODE DirtyAllocListEntry;
269 BOOLEAN fDirtyWrite;
270 HANDLE hSharedHandle;
271 VBOXWDDMDISP_LOCKINFO LockInfo;
272 VBOXWDDM_DIRTYREGION DirtyRegion; /* <- dirty region to notify host about */
273 VBOXWDDM_SURFACE_DESC SurfDesc;
274 PVBOXWDDMDISP_SWAPCHAIN pSwapchain;
275} VBOXWDDMDISP_ALLOCATION, *PVBOXWDDMDISP_ALLOCATION;
276
277typedef struct VBOXWDDMDISP_RESOURCE
278{
279 HANDLE hResource;
280 D3DKMT_HANDLE hKMResource;
281 PVBOXWDDMDISP_DEVICE pDevice;
282 VBOXWDDMDISP_RESOURCE_FLAGS fFlags;
283 VBOXWDDM_RC_DESC RcDesc;
284 UINT cAllocations;
285 VBOXWDDMDISP_ALLOCATION aAllocations[1];
286} VBOXWDDMDISP_RESOURCE, *PVBOXWDDMDISP_RESOURCE;
287
288typedef struct VBOXWDDMDISP_QUERY
289{
290 D3DDDIQUERYTYPE enmType;
291 D3DDDI_ISSUEQUERYFLAGS fQueryState;
292 IDirect3DQuery9 *pQueryIf;
293} VBOXWDDMDISP_QUERY, *PVBOXWDDMDISP_QUERY;
294
295typedef struct VBOXWDDMDISP_TSS_LOOKUP
296{
297 BOOL bSamplerState;
298 DWORD dType;
299} VBOXWDDMDISP_TSS_LOOKUP;
300
301typedef struct VBOXWDDMDISP_OVERLAY
302{
303 D3DKMT_HANDLE hOverlay;
304 D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId;
305 PVBOXWDDMDISP_RESOURCE *pResource;
306} VBOXWDDMDISP_OVERLAY, *PVBOXWDDMDISP_OVERLAY;
307
308#define VBOXDISP_CUBEMAP_LEVELS_COUNT(pRc) (((pRc)->cAllocations)/6)
309#define VBOXDISP_CUBEMAP_INDEX_TO_FACE(pRc, idx) ((D3DCUBEMAP_FACES)(D3DCUBEMAP_FACE_POSITIVE_X+(idx)%VBOXDISP_CUBEMAP_LEVELS_COUNT(pRc)))
310#define VBOXDISP_CUBEMAP_INDEX_TO_LEVEL(pRc, idx) ((idx)%VBOXDISP_CUBEMAP_LEVELS_COUNT(pRc))
311
312DECLINLINE(PVBOXWDDMDISP_SWAPCHAIN) vboxWddmSwapchainForAlloc(PVBOXWDDMDISP_ALLOCATION pAlloc)
313{
314 return pAlloc->pSwapchain;
315}
316
317DECLINLINE(UINT) vboxWddmSwapchainIdxFb(PVBOXWDDMDISP_SWAPCHAIN pSwapchain)
318{
319 return (pSwapchain->iBB + pSwapchain->cRTs - 1) % pSwapchain->cRTs;
320}
321
322/* if swapchain contains only one surface returns this surface */
323DECLINLINE(PVBOXWDDMDISP_RENDERTGT) vboxWddmSwapchainGetBb(PVBOXWDDMDISP_SWAPCHAIN pSwapchain)
324{
325 if (pSwapchain->cRTs)
326 {
327 Assert(pSwapchain->iBB < pSwapchain->cRTs);
328 return &pSwapchain->aRTs[pSwapchain->iBB];
329 }
330 return NULL;
331}
332
333DECLINLINE(PVBOXWDDMDISP_RENDERTGT) vboxWddmSwapchainGetFb(PVBOXWDDMDISP_SWAPCHAIN pSwapchain)
334{
335 if (pSwapchain->cRTs)
336 {
337 UINT iFb = vboxWddmSwapchainIdxFb(pSwapchain);
338 return &pSwapchain->aRTs[iFb];
339 }
340 return NULL;
341}
342
343void vboxWddmResourceInit(PVBOXWDDMDISP_RESOURCE pRc, UINT cAllocs);
344
345#ifndef IN_VBOXCRHGSMI
346PVBOXWDDMDISP_SWAPCHAIN vboxWddmSwapchainFindCreate(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_ALLOCATION pBbAlloc, BOOL *pbNeedPresent);
347HRESULT vboxWddmSwapchainChkCreateIf(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain);
348VOID vboxWddmSwapchainDestroy(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain);
349
350#endif
351
352#endif /* #ifndef ___VBoxDispD3D_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