VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxCrHgsmi.cpp@ 43621

Last change on this file since 43621 was 42499, checked in by vboxsync, 12 years ago

crOgl/wddm: per-context connections

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.8 KB
Line 
1/* $Id: VBoxCrHgsmi.cpp 42499 2012-08-01 10:26:43Z vboxsync $ */
2
3/** @file
4 * VBoxVideo Display D3D User mode dll
5 */
6
7/*
8 * Copyright (C) 2011 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#include <VBox/VBoxCrHgsmi.h>
20#include <iprt/err.h>
21
22#include "VBoxUhgsmiKmt.h"
23
24static VBOXDISPKMT_CALLBACKS g_VBoxCrHgsmiKmtCallbacks;
25static int g_bVBoxKmtCallbacksInited = 0;
26
27static int vboxCrHgsmiInitPerform(VBOXDISPKMT_CALLBACKS *pCallbacks)
28{
29 HRESULT hr = vboxDispKmtCallbacksInit(pCallbacks);
30 /*Assert(hr == S_OK);*/
31 if (hr == S_OK)
32 {
33 /* check if we can create the hgsmi */
34 PVBOXUHGSMI pHgsmi = VBoxCrHgsmiCreate();
35 if (pHgsmi)
36 {
37 /* yes, we can, so this is wddm mode */
38 VBoxCrHgsmiDestroy(pHgsmi);
39 Log(("CrHgsmi: WDDM mode supported\n"));
40 return 1;
41 }
42 vboxDispKmtCallbacksTerm(pCallbacks);
43 }
44 Log(("CrHgsmi: unsupported\n"));
45 return -1;
46}
47
48VBOXCRHGSMI_DECL(int) VBoxCrHgsmiInit()
49{
50 if (!g_bVBoxKmtCallbacksInited)
51 {
52 g_bVBoxKmtCallbacksInited = vboxCrHgsmiInitPerform(&g_VBoxCrHgsmiKmtCallbacks);
53 Assert(g_bVBoxKmtCallbacksInited);
54 }
55
56 return g_bVBoxKmtCallbacksInited > 0 ? VINF_SUCCESS : VERR_NOT_SUPPORTED;
57}
58
59VBOXCRHGSMI_DECL(PVBOXUHGSMI) VBoxCrHgsmiCreate()
60{
61 PVBOXUHGSMI_PRIVATE_KMT pHgsmiGL = (PVBOXUHGSMI_PRIVATE_KMT)RTMemAllocZ(sizeof (*pHgsmiGL));
62 if (pHgsmiGL)
63 {
64#if 0
65 HRESULT hr = vboxUhgsmiKmtCreate(pHgsmiGL, TRUE /* bD3D tmp for injection thread*/);
66#else
67 HRESULT hr = vboxUhgsmiKmtEscCreate(pHgsmiGL, TRUE /* bD3D tmp for injection thread*/);
68#endif
69 Log(("CrHgsmi: faled to create KmtEsc VBOXUHGSMI instance, hr (0x%x)\n", hr));
70 if (hr == S_OK)
71 {
72 return &pHgsmiGL->BasePrivate.Base;
73 }
74 RTMemFree(pHgsmiGL);
75 }
76
77 return NULL;
78}
79
80VBOXCRHGSMI_DECL(void) VBoxCrHgsmiDestroy(PVBOXUHGSMI pHgsmi)
81{
82 PVBOXUHGSMI_PRIVATE_KMT pHgsmiGL = VBOXUHGSMIKMT_GET(pHgsmi);
83 HRESULT hr = vboxUhgsmiKmtDestroy(pHgsmiGL);
84 Assert(hr == S_OK);
85 if (hr == S_OK)
86 {
87 RTMemFree(pHgsmiGL);
88 }
89}
90
91VBOXCRHGSMI_DECL(int) VBoxCrHgsmiTerm()
92{
93#if 0
94 PVBOXUHGSMI_PRIVATE_KMT pHgsmiGL = gt_pHgsmiGL;
95 if (pHgsmiGL)
96 {
97 g_VBoxCrHgsmiCallbacks.pfnClientDestroy(pHgsmiGL->BasePrivate.hClient);
98 vboxUhgsmiKmtDestroy(pHgsmiGL);
99 gt_pHgsmiGL = NULL;
100 }
101
102 if (g_pfnVBoxDispCrHgsmiTerm)
103 g_pfnVBoxDispCrHgsmiTerm();
104#endif
105 if (g_bVBoxKmtCallbacksInited > 0)
106 {
107 vboxDispKmtCallbacksTerm(&g_VBoxCrHgsmiKmtCallbacks);
108 }
109 return VINF_SUCCESS;
110}
111
112VBOXCRHGSMI_DECL(int) VBoxCrHgsmiCtlConGetClientID(PVBOXUHGSMI pHgsmi, uint32_t *pu32ClientID)
113{
114 PVBOXUHGSMI_PRIVATE_BASE pHgsmiPrivate = (PVBOXUHGSMI_PRIVATE_BASE)pHgsmi;
115 int rc = vboxCrHgsmiPrivateCtlConGetClientID(pHgsmiPrivate, pu32ClientID);
116 if (!RT_SUCCESS(rc))
117 {
118 WARN(("VBoxCrHgsmiPrivateCtlConCall failed with rc (%d)", rc));
119 }
120 return rc;
121}
122
123VBOXCRHGSMI_DECL(int) VBoxCrHgsmiCtlConCall(PVBOXUHGSMI pHgsmi, struct VBoxGuestHGCMCallInfo *pCallInfo, int cbCallInfo)
124{
125 PVBOXUHGSMI_PRIVATE_BASE pHgsmiPrivate = (PVBOXUHGSMI_PRIVATE_BASE)pHgsmi;
126 int rc = vboxCrHgsmiPrivateCtlConCall(pHgsmiPrivate, pCallInfo, cbCallInfo);
127 if (!RT_SUCCESS(rc))
128 {
129 WARN(("VBoxCrHgsmiPrivateCtlConCall failed with rc (%d)", rc));
130 }
131 return rc;
132}
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