VirtualBox

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

Last change on this file since 53100 was 49244, checked in by vboxsync, 11 years ago

wddm: fix 3D rendering to primary

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.3 KB
Line 
1/* $Id: VBoxD3DIf.h 49244 2013-10-22 20:08:34Z vboxsync $ */
2
3/** @file
4 * VBoxVideo Display D3D User mode dll
5 */
6
7/*
8 * Copyright (C) 2012 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 Assert(pRc->cAllocations == 1); /* <- 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 * so for now check VBoxD3DIfSurfGet is used for one-level textures */
86 IDirect3DTexture9 *pD3DIfTex = (IDirect3DTexture9*)pD3DIf;
87 IDirect3DSurface9 *pSurfaceLevel;
88 Assert(pD3DIfTex);
89 hr = pD3DIfTex->GetSurfaceLevel(iAlloc, &pSurfaceLevel);
90 Assert(hr == S_OK);
91 if (hr == S_OK)
92 {
93 *ppSurf = pSurfaceLevel;
94 }
95 break;
96 }
97 case VBOXDISP_D3DIFTYPE_CUBE_TEXTURE:
98 {
99 IDirect3DCubeTexture9 *pD3DIfCubeTex = (IDirect3DCubeTexture9*)pD3DIf;
100 IDirect3DSurface9 *pSurfaceLevel;
101 Assert(pD3DIfCubeTex);
102 hr = pD3DIfCubeTex->GetCubeMapSurface(VBOXDISP_CUBEMAP_INDEX_TO_FACE(pRc, iAlloc),
103 VBOXDISP_CUBEMAP_INDEX_TO_LEVEL(pRc, iAlloc), &pSurfaceLevel);
104 Assert(hr == S_OK);
105 if (hr == S_OK)
106 {
107 *ppSurf = pSurfaceLevel;
108 }
109 break;
110 }
111 default:
112 {
113 WARN(("unexpected enmD3DIfType %d", pRc->aAllocations[0].enmD3DIfType));
114 hr = E_FAIL;
115 break;
116 }
117 }
118 return hr;
119}
120
121VOID VBoxD3DIfFillPresentParams(D3DPRESENT_PARAMETERS *pParams, PVBOXWDDMDISP_RESOURCE pRc, UINT cRTs);
122HRESULT VBoxD3DIfDeviceCreateDummy(PVBOXWDDMDISP_DEVICE pDevice);
123
124DECLINLINE(IDirect3DDevice9*) VBoxD3DIfDeviceGet(PVBOXWDDMDISP_DEVICE pDevice)
125{
126 if (pDevice->pDevice9If)
127 return pDevice->pDevice9If;
128
129#ifdef VBOXWDDMDISP_DEBUG
130 g_VBoxVDbgInternalDevice = pDevice;
131#endif
132
133 HRESULT hr = VBoxD3DIfDeviceCreateDummy(pDevice);
134 Assert(hr == S_OK);
135 Assert(pDevice->pDevice9If);
136 return pDevice->pDevice9If;
137}
138
139#define VBOXDISPMODE_IS_3D(_p) (!!((_p)->D3D.pD3D9If))
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__ */
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