VirtualBox

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

Last change on this file since 95234 was 95234, checked in by vboxsync, 3 years ago

WDDM: allow gallium based d3d9 and opengl drivers to work with VGPU10. bugref:9845

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.5 KB
Line 
1/* $Id: VBoxD3DIf.h 95234 2022-06-08 16:31:28Z vboxsync $ */
2/** @file
3 * VBoxVideo Display D3D User mode dll
4 */
5
6/*
7 * Copyright (C) 2012-2022 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#ifdef VBOX_WITH_VMSVGA3D_DX9
55 if (pAlloc->enmType == VBOXWDDM_ALLOC_TYPE_D3D)
56 return pAlloc->pRc->pDevice->pfnCreateSharedPrimary(pAlloc);
57#endif
58
59 if (pAlloc->enmType != VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE)
60 {
61 WARN(("dynamic creation is supported for VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE only!, current type is %d", pAlloc->enmType));
62 return NULL;
63 }
64
65 Assert(pAlloc->pRc->pDevice->pfnCreateSharedPrimary);
66 return pAlloc->pRc->pDevice->pfnCreateSharedPrimary(pAlloc);
67}
68
69/* on success increments the surface ref counter,
70 * i.e. one must call pSurf->Release() once the surface is not needed*/
71DECLINLINE(HRESULT) VBoxD3DIfSurfGet(PVBOXWDDMDISP_RESOURCE pRc, UINT iAlloc, IDirect3DSurface9 **ppSurf)
72{
73 HRESULT hr = S_OK;
74 Assert(pRc->cAllocations > iAlloc);
75 *ppSurf = NULL;
76 IUnknown* pD3DIf = vboxD3DIfGet(&pRc->aAllocations[iAlloc]);
77
78 switch (pRc->aAllocations[0].enmD3DIfType)
79 {
80 case VBOXDISP_D3DIFTYPE_SURFACE:
81 {
82 IDirect3DSurface9 *pD3DIfSurf = (IDirect3DSurface9*)pD3DIf;
83 Assert(pD3DIfSurf);
84 pD3DIfSurf->AddRef();
85 *ppSurf = pD3DIfSurf;
86 break;
87 }
88 case VBOXDISP_D3DIFTYPE_TEXTURE:
89 {
90 /* @todo VBoxD3DIfSurfGet is typically used in Blt & ColorFill functions
91 * in this case, if texture is used as a destination,
92 * we should update sub-layers as well which is not done currently. */
93 IDirect3DTexture9 *pD3DIfTex = (IDirect3DTexture9*)pD3DIf;
94 IDirect3DSurface9 *pSurfaceLevel;
95 Assert(pD3DIfTex);
96 hr = pD3DIfTex->GetSurfaceLevel(iAlloc, &pSurfaceLevel);
97 Assert(hr == S_OK);
98 if (hr == S_OK)
99 {
100 *ppSurf = pSurfaceLevel;
101 }
102 break;
103 }
104 case VBOXDISP_D3DIFTYPE_CUBE_TEXTURE:
105 {
106 IDirect3DCubeTexture9 *pD3DIfCubeTex = (IDirect3DCubeTexture9*)pD3DIf;
107 IDirect3DSurface9 *pSurfaceLevel;
108 Assert(pD3DIfCubeTex);
109 hr = pD3DIfCubeTex->GetCubeMapSurface(VBOXDISP_CUBEMAP_INDEX_TO_FACE(pRc, iAlloc),
110 VBOXDISP_CUBEMAP_INDEX_TO_LEVEL(pRc, iAlloc), &pSurfaceLevel);
111 Assert(hr == S_OK);
112 if (hr == S_OK)
113 {
114 *ppSurf = pSurfaceLevel;
115 }
116 break;
117 }
118 default:
119 {
120 WARN(("unexpected enmD3DIfType %d", pRc->aAllocations[0].enmD3DIfType));
121 hr = E_FAIL;
122 break;
123 }
124 }
125 return hr;
126}
127
128VOID VBoxD3DIfFillPresentParams(D3DPRESENT_PARAMETERS *pParams, PVBOXWDDMDISP_RESOURCE pRc, UINT cRTs);
129HRESULT VBoxD3DIfDeviceCreateDummy(PVBOXWDDMDISP_DEVICE pDevice);
130
131DECLINLINE(IDirect3DDevice9*) VBoxD3DIfDeviceGet(PVBOXWDDMDISP_DEVICE pDevice)
132{
133 if (pDevice->pDevice9If)
134 return pDevice->pDevice9If;
135
136#ifdef VBOXWDDMDISP_DEBUG
137 g_VBoxVDbgInternalDevice = pDevice;
138#endif
139
140 Assert(pDevice->pfnCreateDirect3DDevice);
141 HRESULT hr = pDevice->pfnCreateDirect3DDevice(pDevice);
142 Assert(hr == S_OK); NOREF(hr);
143 Assert(pDevice->pDevice9If);
144 return pDevice->pDevice9If;
145}
146
147#define VBOXDISPMODE_IS_3D(_p) ((_p)->f3D)
148#define VBOXDISP_D3DEV(_p) VBoxD3DIfDeviceGet(_p)
149
150#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