VirtualBox

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

Last change on this file since 64186 was 63018, checked in by vboxsync, 8 years ago

GA/NT/Graphics: warnings

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.1 KB
Line 
1/* $Id: VBoxD3DIf.h 63018 2016-08-04 23:14:14Z vboxsync $ */
2
3/** @file
4 * VBoxVideo Display D3D User mode dll
5 */
6
7/*
8 * Copyright (C) 2012-2016 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 ___VBoxDispD3DRcIf_h__
20#define ___VBoxDispD3DRcIf_h__
21
22#include "VBoxDispD3DCmn.h"
23
24static D3DFORMAT vboxDDI2D3DFormat(D3DDDIFORMAT format);
25D3DMULTISAMPLE_TYPE vboxDDI2D3DMultiSampleType(D3DDDIMULTISAMPLE_TYPE enmType);
26D3DPOOL vboxDDI2D3DPool(D3DDDI_POOL enmPool);
27D3DRENDERSTATETYPE vboxDDI2D3DRenderStateType(D3DDDIRENDERSTATETYPE enmType);
28VBOXWDDMDISP_TSS_LOOKUP vboxDDI2D3DTestureStageStateType(D3DDDITEXTURESTAGESTATETYPE enmType);
29DWORD vboxDDI2D3DUsage(D3DDDI_RESOURCEFLAGS fFlags);
30DWORD vboxDDI2D3DLockFlags(D3DDDI_LOCKFLAGS fLockFlags);
31D3DTEXTUREFILTERTYPE vboxDDI2D3DBltFlags(D3DDDI_BLTFLAGS fFlags);
32D3DQUERYTYPE vboxDDI2D3DQueryType(D3DDDIQUERYTYPE enmType);
33DWORD vboxDDI2D3DIssueQueryFlags(D3DDDI_ISSUEQUERYFLAGS Flags);
34
35HRESULT VBoxD3DIfCreateForRc(struct VBOXWDDMDISP_RESOURCE *pRc);
36HRESULT VBoxD3DIfLockRect(struct VBOXWDDMDISP_RESOURCE *pRc, UINT iAlloc,
37 D3DLOCKED_RECT * pLockedRect,
38 CONST RECT *pRect,
39 DWORD fLockFlags);
40HRESULT VBoxD3DIfUnlockRect(struct VBOXWDDMDISP_RESOURCE *pRc, UINT iAlloc);
41void VBoxD3DIfLockUnlockMemSynch(struct VBOXWDDMDISP_ALLOCATION *pAlloc, D3DLOCKED_RECT *pLockInfo, RECT *pRect, bool bToLockInfo);
42
43IUnknown* vboxD3DIfCreateSharedPrimary(PVBOXWDDMDISP_ALLOCATION pAlloc);
44
45
46/* NOTE: does NOT increment a ref counter! NO Release needed!! */
47DECLINLINE(IUnknown*) vboxD3DIfGet(PVBOXWDDMDISP_ALLOCATION pAlloc)
48{
49 if (pAlloc->pD3DIf)
50 return pAlloc->pD3DIf;
51
52 if (pAlloc->enmType != VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE)
53 {
54 WARN(("dynamic creation is supported for VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE only!, current type is %d", pAlloc->enmType));
55 return NULL;
56 }
57
58 return vboxD3DIfCreateSharedPrimary(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*/
63DECLINLINE(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
120VOID VBoxD3DIfFillPresentParams(D3DPRESENT_PARAMETERS *pParams, PVBOXWDDMDISP_RESOURCE pRc, UINT cRTs);
121HRESULT VBoxD3DIfDeviceCreateDummy(PVBOXWDDMDISP_DEVICE pDevice);
122
123DECLINLINE(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 HRESULT hr = VBoxD3DIfDeviceCreateDummy(pDevice);
133 Assert(hr == S_OK); NOREF(hr);
134 Assert(pDevice->pDevice9If);
135 return pDevice->pDevice9If;
136}
137
138#define VBOXDISPMODE_IS_3D(_p) (!!((_p)->D3D.pD3D9If))
139#ifdef VBOXDISP_EARLYCREATEDEVICE
140#define VBOXDISP_D3DEV(_p) (_p)->pDevice9If
141#else
142#define VBOXDISP_D3DEV(_p) VBoxD3DIfDeviceGet(_p)
143#endif
144
145#endif /* ___VBoxDispD3DRcIf_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