VirtualBox

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

Last change on this file since 69350 was 69350, checked in by vboxsync, 7 years ago

Additions/WINNT/Video: File header cleanups - first @file sentence should give brief desccription and stand by its lonely self.

  • 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 69350 2017-10-26 14:18:52Z vboxsync $ */
2/** @file
3 * VBoxVideo Display D3D User mode dll
4 */
5
6/*
7 * Copyright (C) 2012-2016 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
23D3DFORMAT vboxDDI2D3DFormat(D3DDDIFORMAT format);
24D3DMULTISAMPLE_TYPE vboxDDI2D3DMultiSampleType(D3DDDIMULTISAMPLE_TYPE enmType);
25D3DPOOL vboxDDI2D3DPool(D3DDDI_POOL enmPool);
26D3DRENDERSTATETYPE vboxDDI2D3DRenderStateType(D3DDDIRENDERSTATETYPE enmType);
27VBOXWDDMDISP_TSS_LOOKUP vboxDDI2D3DTestureStageStateType(D3DDDITEXTURESTAGESTATETYPE enmType);
28DWORD vboxDDI2D3DUsage(D3DDDI_RESOURCEFLAGS fFlags);
29DWORD vboxDDI2D3DLockFlags(D3DDDI_LOCKFLAGS fLockFlags);
30D3DTEXTUREFILTERTYPE vboxDDI2D3DBltFlags(D3DDDI_BLTFLAGS fFlags);
31D3DQUERYTYPE vboxDDI2D3DQueryType(D3DDDIQUERYTYPE enmType);
32DWORD vboxDDI2D3DIssueQueryFlags(D3DDDI_ISSUEQUERYFLAGS Flags);
33
34HRESULT VBoxD3DIfCreateForRc(struct VBOXWDDMDISP_RESOURCE *pRc);
35HRESULT VBoxD3DIfLockRect(struct VBOXWDDMDISP_RESOURCE *pRc, UINT iAlloc,
36 D3DLOCKED_RECT * pLockedRect,
37 CONST RECT *pRect,
38 DWORD fLockFlags);
39HRESULT VBoxD3DIfUnlockRect(struct VBOXWDDMDISP_RESOURCE *pRc, UINT iAlloc);
40void VBoxD3DIfLockUnlockMemSynch(struct VBOXWDDMDISP_ALLOCATION *pAlloc, D3DLOCKED_RECT *pLockInfo, RECT *pRect, bool bToLockInfo);
41
42IUnknown* vboxD3DIfCreateSharedPrimary(PVBOXWDDMDISP_ALLOCATION pAlloc);
43
44
45/* NOTE: does NOT increment a ref counter! NO Release needed!! */
46DECLINLINE(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 return vboxD3DIfCreateSharedPrimary(pAlloc);
58}
59
60/* on success increments the surface ref counter,
61 * i.e. one must call pSurf->Release() once the surface is not needed*/
62DECLINLINE(HRESULT) VBoxD3DIfSurfGet(PVBOXWDDMDISP_RESOURCE pRc, UINT iAlloc, IDirect3DSurface9 **ppSurf)
63{
64 HRESULT hr = S_OK;
65 Assert(pRc->cAllocations > iAlloc);
66 *ppSurf = NULL;
67 IUnknown* pD3DIf = vboxD3DIfGet(&pRc->aAllocations[iAlloc]);
68
69 switch (pRc->aAllocations[0].enmD3DIfType)
70 {
71 case VBOXDISP_D3DIFTYPE_SURFACE:
72 {
73 IDirect3DSurface9 *pD3DIfSurf = (IDirect3DSurface9*)pD3DIf;
74 Assert(pD3DIfSurf);
75 pD3DIfSurf->AddRef();
76 *ppSurf = pD3DIfSurf;
77 break;
78 }
79 case VBOXDISP_D3DIFTYPE_TEXTURE:
80 {
81 /* @todo VBoxD3DIfSurfGet is typically used in Blt & ColorFill functions
82 * in this case, if texture is used as a destination,
83 * we should update sub-layers as well which is not done currently. */
84 IDirect3DTexture9 *pD3DIfTex = (IDirect3DTexture9*)pD3DIf;
85 IDirect3DSurface9 *pSurfaceLevel;
86 Assert(pD3DIfTex);
87 hr = pD3DIfTex->GetSurfaceLevel(iAlloc, &pSurfaceLevel);
88 Assert(hr == S_OK);
89 if (hr == S_OK)
90 {
91 *ppSurf = pSurfaceLevel;
92 }
93 break;
94 }
95 case VBOXDISP_D3DIFTYPE_CUBE_TEXTURE:
96 {
97 IDirect3DCubeTexture9 *pD3DIfCubeTex = (IDirect3DCubeTexture9*)pD3DIf;
98 IDirect3DSurface9 *pSurfaceLevel;
99 Assert(pD3DIfCubeTex);
100 hr = pD3DIfCubeTex->GetCubeMapSurface(VBOXDISP_CUBEMAP_INDEX_TO_FACE(pRc, iAlloc),
101 VBOXDISP_CUBEMAP_INDEX_TO_LEVEL(pRc, iAlloc), &pSurfaceLevel);
102 Assert(hr == S_OK);
103 if (hr == S_OK)
104 {
105 *ppSurf = pSurfaceLevel;
106 }
107 break;
108 }
109 default:
110 {
111 WARN(("unexpected enmD3DIfType %d", pRc->aAllocations[0].enmD3DIfType));
112 hr = E_FAIL;
113 break;
114 }
115 }
116 return hr;
117}
118
119VOID VBoxD3DIfFillPresentParams(D3DPRESENT_PARAMETERS *pParams, PVBOXWDDMDISP_RESOURCE pRc, UINT cRTs);
120HRESULT VBoxD3DIfDeviceCreateDummy(PVBOXWDDMDISP_DEVICE pDevice);
121
122DECLINLINE(IDirect3DDevice9*) VBoxD3DIfDeviceGet(PVBOXWDDMDISP_DEVICE pDevice)
123{
124 if (pDevice->pDevice9If)
125 return pDevice->pDevice9If;
126
127#ifdef VBOXWDDMDISP_DEBUG
128 g_VBoxVDbgInternalDevice = pDevice;
129#endif
130
131 HRESULT hr = VBoxD3DIfDeviceCreateDummy(pDevice);
132 Assert(hr == S_OK); NOREF(hr);
133 Assert(pDevice->pDevice9If);
134 return pDevice->pDevice9If;
135}
136
137#define VBOXDISPMODE_IS_3D(_p) (!!((_p)->D3D.pD3D9If))
138#ifdef VBOXDISP_EARLYCREATEDEVICE
139#define VBOXDISP_D3DEV(_p) (_p)->pDevice9If
140#else
141#define VBOXDISP_D3DEV(_p) VBoxD3DIfDeviceGet(_p)
142#endif
143
144#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