1 | /* $Id: VBoxD3DIf.h 72621 2018-06-20 11:27:14Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxVideo Display D3D User mode dll
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2012-2017 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef ___VBoxDispD3DRcIf_h__
|
---|
19 | #define ___VBoxDispD3DRcIf_h__
|
---|
20 |
|
---|
21 | #include "VBoxDispD3DCmn.h"
|
---|
22 |
|
---|
23 | D3DFORMAT vboxDDI2D3DFormat(D3DDDIFORMAT format);
|
---|
24 | D3DMULTISAMPLE_TYPE vboxDDI2D3DMultiSampleType(D3DDDIMULTISAMPLE_TYPE enmType);
|
---|
25 | D3DPOOL vboxDDI2D3DPool(D3DDDI_POOL enmPool);
|
---|
26 | D3DRENDERSTATETYPE vboxDDI2D3DRenderStateType(D3DDDIRENDERSTATETYPE enmType);
|
---|
27 | VBOXWDDMDISP_TSS_LOOKUP vboxDDI2D3DTestureStageStateType(D3DDDITEXTURESTAGESTATETYPE enmType);
|
---|
28 | DWORD vboxDDI2D3DUsage(D3DDDI_RESOURCEFLAGS fFlags);
|
---|
29 | DWORD vboxDDI2D3DLockFlags(D3DDDI_LOCKFLAGS fLockFlags);
|
---|
30 | D3DTEXTUREFILTERTYPE vboxDDI2D3DBltFlags(D3DDDI_BLTFLAGS fFlags);
|
---|
31 | D3DQUERYTYPE vboxDDI2D3DQueryType(D3DDDIQUERYTYPE enmType);
|
---|
32 | DWORD vboxDDI2D3DIssueQueryFlags(D3DDDI_ISSUEQUERYFLAGS Flags);
|
---|
33 |
|
---|
34 | HRESULT VBoxD3DIfCreateForRc(struct VBOXWDDMDISP_RESOURCE *pRc);
|
---|
35 | HRESULT VBoxD3DIfLockRect(struct VBOXWDDMDISP_RESOURCE *pRc, UINT iAlloc,
|
---|
36 | D3DLOCKED_RECT * pLockedRect,
|
---|
37 | CONST RECT *pRect,
|
---|
38 | DWORD fLockFlags);
|
---|
39 | HRESULT VBoxD3DIfUnlockRect(struct VBOXWDDMDISP_RESOURCE *pRc, UINT iAlloc);
|
---|
40 | void VBoxD3DIfLockUnlockMemSynch(struct VBOXWDDMDISP_ALLOCATION *pAlloc, D3DLOCKED_RECT *pLockInfo, RECT *pRect, bool bToLockInfo);
|
---|
41 |
|
---|
42 | IUnknown* vboxD3DIfCreateSharedPrimary(PVBOXWDDMDISP_ALLOCATION pAlloc);
|
---|
43 |
|
---|
44 |
|
---|
45 | /* NOTE: does NOT increment a ref counter! NO Release needed!! */
|
---|
46 | DECLINLINE(IUnknown*) vboxD3DIfGet(PVBOXWDDMDISP_ALLOCATION pAlloc)
|
---|
47 | {
|
---|
48 | if (pAlloc->pD3DIf)
|
---|
49 | return pAlloc->pD3DIf;
|
---|
50 |
|
---|
51 | if (pAlloc->enmType != VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE)
|
---|
52 | {
|
---|
53 | WARN(("dynamic creation is supported for VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE only!, current type is %d", pAlloc->enmType));
|
---|
54 | return NULL;
|
---|
55 | }
|
---|
56 |
|
---|
57 | Assert(pAlloc->pRc->pDevice->pfnCreateSharedPrimary);
|
---|
58 | return pAlloc->pRc->pDevice->pfnCreateSharedPrimary(pAlloc);
|
---|
59 | }
|
---|
60 |
|
---|
61 | /* on success increments the surface ref counter,
|
---|
62 | * i.e. one must call pSurf->Release() once the surface is not needed*/
|
---|
63 | DECLINLINE(HRESULT) VBoxD3DIfSurfGet(PVBOXWDDMDISP_RESOURCE pRc, UINT iAlloc, IDirect3DSurface9 **ppSurf)
|
---|
64 | {
|
---|
65 | HRESULT hr = S_OK;
|
---|
66 | Assert(pRc->cAllocations > iAlloc);
|
---|
67 | *ppSurf = NULL;
|
---|
68 | IUnknown* pD3DIf = vboxD3DIfGet(&pRc->aAllocations[iAlloc]);
|
---|
69 |
|
---|
70 | switch (pRc->aAllocations[0].enmD3DIfType)
|
---|
71 | {
|
---|
72 | case VBOXDISP_D3DIFTYPE_SURFACE:
|
---|
73 | {
|
---|
74 | IDirect3DSurface9 *pD3DIfSurf = (IDirect3DSurface9*)pD3DIf;
|
---|
75 | Assert(pD3DIfSurf);
|
---|
76 | pD3DIfSurf->AddRef();
|
---|
77 | *ppSurf = pD3DIfSurf;
|
---|
78 | break;
|
---|
79 | }
|
---|
80 | case VBOXDISP_D3DIFTYPE_TEXTURE:
|
---|
81 | {
|
---|
82 | /* @todo VBoxD3DIfSurfGet is typically used in Blt & ColorFill functions
|
---|
83 | * in this case, if texture is used as a destination,
|
---|
84 | * we should update sub-layers as well which is not done currently. */
|
---|
85 | IDirect3DTexture9 *pD3DIfTex = (IDirect3DTexture9*)pD3DIf;
|
---|
86 | IDirect3DSurface9 *pSurfaceLevel;
|
---|
87 | Assert(pD3DIfTex);
|
---|
88 | hr = pD3DIfTex->GetSurfaceLevel(iAlloc, &pSurfaceLevel);
|
---|
89 | Assert(hr == S_OK);
|
---|
90 | if (hr == S_OK)
|
---|
91 | {
|
---|
92 | *ppSurf = pSurfaceLevel;
|
---|
93 | }
|
---|
94 | break;
|
---|
95 | }
|
---|
96 | case VBOXDISP_D3DIFTYPE_CUBE_TEXTURE:
|
---|
97 | {
|
---|
98 | IDirect3DCubeTexture9 *pD3DIfCubeTex = (IDirect3DCubeTexture9*)pD3DIf;
|
---|
99 | IDirect3DSurface9 *pSurfaceLevel;
|
---|
100 | Assert(pD3DIfCubeTex);
|
---|
101 | hr = pD3DIfCubeTex->GetCubeMapSurface(VBOXDISP_CUBEMAP_INDEX_TO_FACE(pRc, iAlloc),
|
---|
102 | VBOXDISP_CUBEMAP_INDEX_TO_LEVEL(pRc, iAlloc), &pSurfaceLevel);
|
---|
103 | Assert(hr == S_OK);
|
---|
104 | if (hr == S_OK)
|
---|
105 | {
|
---|
106 | *ppSurf = pSurfaceLevel;
|
---|
107 | }
|
---|
108 | break;
|
---|
109 | }
|
---|
110 | default:
|
---|
111 | {
|
---|
112 | WARN(("unexpected enmD3DIfType %d", pRc->aAllocations[0].enmD3DIfType));
|
---|
113 | hr = E_FAIL;
|
---|
114 | break;
|
---|
115 | }
|
---|
116 | }
|
---|
117 | return hr;
|
---|
118 | }
|
---|
119 |
|
---|
120 | VOID VBoxD3DIfFillPresentParams(D3DPRESENT_PARAMETERS *pParams, PVBOXWDDMDISP_RESOURCE pRc, UINT cRTs);
|
---|
121 | HRESULT VBoxD3DIfDeviceCreateDummy(PVBOXWDDMDISP_DEVICE pDevice);
|
---|
122 |
|
---|
123 | DECLINLINE(IDirect3DDevice9*) VBoxD3DIfDeviceGet(PVBOXWDDMDISP_DEVICE pDevice)
|
---|
124 | {
|
---|
125 | if (pDevice->pDevice9If)
|
---|
126 | return pDevice->pDevice9If;
|
---|
127 |
|
---|
128 | #ifdef VBOXWDDMDISP_DEBUG
|
---|
129 | g_VBoxVDbgInternalDevice = pDevice;
|
---|
130 | #endif
|
---|
131 |
|
---|
132 | Assert(pDevice->pfnCreateDirect3DDevice);
|
---|
133 | HRESULT hr = pDevice->pfnCreateDirect3DDevice(pDevice);
|
---|
134 | Assert(hr == S_OK); NOREF(hr);
|
---|
135 | Assert(pDevice->pDevice9If);
|
---|
136 | return pDevice->pDevice9If;
|
---|
137 | }
|
---|
138 |
|
---|
139 | #define VBOXDISPMODE_IS_3D(_p) ((_p)->f3D)
|
---|
140 | #ifdef VBOXDISP_EARLYCREATEDEVICE
|
---|
141 | #define VBOXDISP_D3DEV(_p) (_p)->pDevice9If
|
---|
142 | #else
|
---|
143 | #define VBOXDISP_D3DEV(_p) VBoxD3DIfDeviceGet(_p)
|
---|
144 | #endif
|
---|
145 |
|
---|
146 | #endif /* ___VBoxDispD3DRcIf_h__ */
|
---|