VirtualBox

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

Last change on this file since 76474 was 76474, checked in by vboxsync, 6 years ago

scm --fix-err-h src/ (bugref:9344)

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