VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxCrHgsmi.cpp@ 33117

Last change on this file since 33117 was 33117, checked in by vboxsync, 14 years ago

wddm/3d: chromium hgsmi transport (guest part 2, disabled)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.4 KB
Line 
1#include <VBox/VBoxCrHgsmi.h>
2#include <iprt/err.h>
3
4#include "VBoxUhgsmiKmt.h"
5
6static VBOXCRHGSMI_CALLBACKS g_VBoxCrHgsmiCallbacks;
7static HMODULE g_hVBoxCrHgsmiProvider = NULL;
8//static uint32_t g_cVBoxCrHgsmiProvider = 0;
9
10typedef VBOXWDDMDISP_DECL(int) FNVBOXDISPCRHGSMI_INIT(PVBOXCRHGSMI_CALLBACKS pCallbacks);
11typedef FNVBOXDISPCRHGSMI_INIT *PFNVBOXDISPCRHGSMI_INIT;
12
13typedef VBOXWDDMDISP_DECL(int) FNVBOXDISPCRHGSMI_TERM();
14typedef FNVBOXDISPCRHGSMI_TERM *PFNVBOXDISPCRHGSMI_TERM;
15
16typedef VBOXWDDMDISP_DECL(HVBOXCRHGSMI_CLIENT) FNVBOXDISPCRHGSMI_QUERY_CLIENT();
17typedef FNVBOXDISPCRHGSMI_QUERY_CLIENT *PFNVBOXDISPCRHGSMI_QUERY_CLIENT;
18
19static PFNVBOXDISPCRHGSMI_INIT g_pfnVBoxDispCrHgsmiInit = NULL;
20static PFNVBOXDISPCRHGSMI_TERM g_pfnVBoxDispCrHgsmiTerm = NULL;
21static PFNVBOXDISPCRHGSMI_QUERY_CLIENT g_pfnVBoxDispCrHgsmiQueryClient = NULL;
22
23VBOXCRHGSMI_DECL(int) VBoxCrHgsmiInit(PVBOXCRHGSMI_CALLBACKS pCallbacks)
24{
25 g_VBoxCrHgsmiCallbacks = *pCallbacks;
26 if (!g_hVBoxCrHgsmiProvider)
27 {
28// BOOL bRc = GetModuleHandleEx(0, "VBoxDispD3D", &g_hVBoxCrHgsmiProvider);
29 g_hVBoxCrHgsmiProvider = GetModuleHandle(L"VBoxDispD3D");
30 if (g_hVBoxCrHgsmiProvider)
31 {
32 g_pfnVBoxDispCrHgsmiInit = (PFNVBOXDISPCRHGSMI_INIT)GetProcAddress(g_hVBoxCrHgsmiProvider, "VBoxDispCrHgsmiInit");
33 Assert(g_pfnVBoxDispCrHgsmiInit);
34 if (g_pfnVBoxDispCrHgsmiInit)
35 {
36 g_pfnVBoxDispCrHgsmiInit(pCallbacks);
37// g_cVBoxCrHgsmiProvider = 1;
38 }
39
40 g_pfnVBoxDispCrHgsmiTerm = (PFNVBOXDISPCRHGSMI_TERM)GetProcAddress(g_hVBoxCrHgsmiProvider, "VBoxDispCrHgsmiTerm");
41 Assert(g_pfnVBoxDispCrHgsmiTerm);
42
43 g_pfnVBoxDispCrHgsmiQueryClient = (PFNVBOXDISPCRHGSMI_QUERY_CLIENT)GetProcAddress(g_hVBoxCrHgsmiProvider, "VBoxDispCrHgsmiQueryClient");
44 Assert(g_pfnVBoxDispCrHgsmiQueryClient);
45 }
46#ifdef DEBUG_misha
47 else
48 {
49 DWORD winEr = GetLastError();
50 Assert(0);
51 }
52#endif
53 }
54// else
55// {
56// ++g_cVBoxCrHgsmiProvider;
57// }
58
59 if (g_hVBoxCrHgsmiProvider)
60 {
61 return VINF_SUCCESS;
62 }
63
64 /* we're called from ogl ICD driver*/
65 Assert(0);
66
67 return VINF_SUCCESS;
68}
69
70static __declspec(thread) PVBOXUHGSMI_PRIVATE_KMT gt_pHgsmiGL = NULL;
71
72VBOXCRHGSMI_DECL(HVBOXCRHGSMI_CLIENT) VBoxCrHgsmiQueryClient()
73{
74
75 HVBOXCRHGSMI_CLIENT hClient;
76 if (g_pfnVBoxDispCrHgsmiQueryClient)
77 {
78 hClient = g_pfnVBoxDispCrHgsmiQueryClient();
79 if (hClient)
80 return hClient;
81 }
82 PVBOXUHGSMI_PRIVATE_KMT pHgsmiGL = gt_pHgsmiGL;
83 if (pHgsmiGL)
84 return pHgsmiGL->BasePrivate.hClient;
85 pHgsmiGL = (PVBOXUHGSMI_PRIVATE_KMT)RTMemAllocZ(sizeof (*pHgsmiGL));
86 if (pHgsmiGL)
87 {
88 HRESULT hr = vboxUhgsmiKmtCreate(pHgsmiGL, TRUE /* bD3D tmp for injection thread*/);
89 Assert(hr == S_OK);
90 hClient = g_VBoxCrHgsmiCallbacks.pfnClientCreate(&pHgsmiGL->BasePrivate.Base);
91 Assert(hClient);
92 pHgsmiGL->BasePrivate.hClient = hClient;
93 gt_pHgsmiGL = pHgsmiGL;
94 }
95 else
96 hClient = NULL;
97 return hClient;
98}
99
100VBOXCRHGSMI_DECL(int) VBoxCrHgsmiTerm()
101{
102 PVBOXUHGSMI_PRIVATE_KMT pHgsmiGL = gt_pHgsmiGL;
103 if (pHgsmiGL)
104 {
105 g_VBoxCrHgsmiCallbacks.pfnClientDestroy(pHgsmiGL->BasePrivate.hClient);
106 vboxUhgsmiKmtDestroy(pHgsmiGL);
107 gt_pHgsmiGL = NULL;
108 }
109
110 if (g_pfnVBoxDispCrHgsmiTerm)
111 g_pfnVBoxDispCrHgsmiTerm();
112 return VINF_SUCCESS;
113}
114
115
116///* to be used by injection thread and by ogl ICD driver for hgsmi initialization*/
117//VBOXCRHGSMI_DECL(int) VBoxCrHgsmiCustomCreate(PVBOXUHGSMI *ppHgsmi)
118//{
119// PVBOXUHGSMI_PRIVATE_KMT pHgsmi = RTMemAllocZ(sizeof (*pHgsmi));
120// if (pHgsmi)
121// {
122// HRESULT hr = vboxUhgsmiKmtCreate(pHgsmi, FALSE);
123// Assert(hr == S_OK);
124// if (hr == S_OK)
125// {
126// *ppHgsmi = &pHgsmi->BasePrivate.Base;
127// return VINF_SUCCESS;
128// }
129// RTMemFree(pHgsmi);
130// return VERR_GENERAL_FAILURE;
131// }
132// return VERR_NO_MEMORY;
133//}
134//
135//VBOXCRHGSMI_DECL(int) VBoxCrHgsmiCustomDestroy(PVBOXUHGSMI pHgsmi)
136//{
137// PVBOXUHGSMI_PRIVATE_KMT pHgsmiKmt = VBOXUHGSMIKMT_GET(pHgsmi);
138// HRESULT hr = vboxUhgsmiKmtDestroy(pHgsmiKmt, FALSE);
139// Assert(hr == S_OK);
140// if (hr == S_OK)
141// {
142// RTMemFree(pHgsmiKmt);
143// return VINF_SUCCESS;
144// }
145// return VERR_GENERAL_FAILURE;
146//}
147
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette