VirtualBox

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

Last change on this file since 83222 was 82968, checked in by vboxsync, 5 years ago

Copyright year updates by scm.

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