1 | /* $Id: VBoxSVGA.c 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox Windows Guest Mesa3D - VMSVGA hardware driver.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2016-2023 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 | #include <VBoxWddmUmHlp.h>
|
---|
29 |
|
---|
30 | #include "svga_public.h"
|
---|
31 | #include "svga_screen.h"
|
---|
32 | #include "pipe/p_screen.h"
|
---|
33 | #include "pipe/p_context.h"
|
---|
34 | #include "frontend/drm_driver.h"
|
---|
35 |
|
---|
36 | #include "wddm_screen.h"
|
---|
37 |
|
---|
38 | struct svga_winsys_screen *
|
---|
39 | svga_wddm_winsys_screen_create(const WDDMGalliumDriverEnv *pEnv);
|
---|
40 |
|
---|
41 | struct pipe_screen * WINAPI
|
---|
42 | GaDrvScreenCreate(const WDDMGalliumDriverEnv *pEnv)
|
---|
43 | {
|
---|
44 | struct svga_winsys_screen *sws = svga_wddm_winsys_screen_create(pEnv);
|
---|
45 | if (sws)
|
---|
46 | return svga_screen_create(sws);
|
---|
47 | return NULL;
|
---|
48 | }
|
---|
49 |
|
---|
50 | void WINAPI
|
---|
51 | GaDrvScreenDestroy(struct pipe_screen *s)
|
---|
52 | {
|
---|
53 | if (s)
|
---|
54 | s->destroy(s);
|
---|
55 | }
|
---|
56 |
|
---|
57 | uint32_t WINAPI
|
---|
58 | GaDrvGetSurfaceId(struct pipe_screen *pScreen, struct pipe_resource *pResource)
|
---|
59 | {
|
---|
60 | uint32_t u32Sid = 0;
|
---|
61 |
|
---|
62 | if ( pScreen
|
---|
63 | && pResource)
|
---|
64 | {
|
---|
65 | /* Get the sid (surface id). */
|
---|
66 | struct winsys_handle whandle;
|
---|
67 | memset(&whandle, 0, sizeof(whandle));
|
---|
68 | whandle.type = WINSYS_HANDLE_TYPE_SHARED;
|
---|
69 |
|
---|
70 | if (pScreen->resource_get_handle(pScreen, NULL, pResource, &whandle, 0))
|
---|
71 | {
|
---|
72 | u32Sid = (uint32_t)whandle.handle;
|
---|
73 | }
|
---|
74 | }
|
---|
75 |
|
---|
76 | return u32Sid;
|
---|
77 | }
|
---|
78 |
|
---|
79 | const WDDMGalliumDriverEnv *WINAPI
|
---|
80 | GaDrvGetWDDMEnv(struct pipe_screen *pScreen)
|
---|
81 | {
|
---|
82 | HANDLE hAdapter = NULL;
|
---|
83 |
|
---|
84 | if (pScreen)
|
---|
85 | {
|
---|
86 | struct svga_screen *pSvgaScreen = svga_screen(pScreen);
|
---|
87 | struct vmw_winsys_screen_wddm *vws_wddm = (struct vmw_winsys_screen_wddm *)pSvgaScreen->sws;
|
---|
88 |
|
---|
89 | return vws_wddm->pEnv;
|
---|
90 | }
|
---|
91 |
|
---|
92 | return hAdapter;
|
---|
93 | }
|
---|
94 |
|
---|
95 | uint32_t WINAPI
|
---|
96 | GaDrvGetContextId(struct pipe_context *pPipeContext)
|
---|
97 | {
|
---|
98 | uint32 u32Cid = ~0;
|
---|
99 |
|
---|
100 | if (pPipeContext)
|
---|
101 | {
|
---|
102 | struct svga_winsys_context *pSWC = svga_winsys_context(pPipeContext);
|
---|
103 | u32Cid = pSWC->cid;
|
---|
104 | }
|
---|
105 |
|
---|
106 | return u32Cid;
|
---|
107 | }
|
---|
108 |
|
---|
109 | void WINAPI
|
---|
110 | GaDrvContextFlush(struct pipe_context *pPipeContext)
|
---|
111 | {
|
---|
112 | if (pPipeContext)
|
---|
113 | pPipeContext->flush(pPipeContext, NULL, PIPE_FLUSH_END_OF_FRAME);
|
---|
114 | }
|
---|
115 |
|
---|
116 | BOOL WINAPI DllMain(HINSTANCE hDLLInst,
|
---|
117 | DWORD fdwReason,
|
---|
118 | LPVOID lpvReserved)
|
---|
119 | {
|
---|
120 | BOOL fReturn = TRUE;
|
---|
121 |
|
---|
122 | RT_NOREF2(hDLLInst, lpvReserved);
|
---|
123 |
|
---|
124 | switch (fdwReason)
|
---|
125 | {
|
---|
126 | case DLL_PROCESS_ATTACH:
|
---|
127 | //RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE);
|
---|
128 | D3DKMTLoad();
|
---|
129 | break;
|
---|
130 |
|
---|
131 | case DLL_PROCESS_DETACH:
|
---|
132 | /// @todo RTR3Term();
|
---|
133 | break;
|
---|
134 |
|
---|
135 | case DLL_THREAD_ATTACH:
|
---|
136 | break;
|
---|
137 |
|
---|
138 | case DLL_THREAD_DETACH:
|
---|
139 | break;
|
---|
140 |
|
---|
141 | default:
|
---|
142 | break;
|
---|
143 | }
|
---|
144 |
|
---|
145 | return fReturn;
|
---|
146 | }
|
---|