1 | /* $Id: VBoxWddmUmHlp.h 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox WDDM User Mode Driver Helpers
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2018-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 | #ifndef GA_INCLUDED_SRC_3D_win_VBoxWddmUmHlp_VBoxWddmUmHlp_h
|
---|
29 | #define GA_INCLUDED_SRC_3D_win_VBoxWddmUmHlp_VBoxWddmUmHlp_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | #include <iprt/win/d3d9.h>
|
---|
35 | #include <d3dumddi.h>
|
---|
36 | #include <iprt/win/d3dkmthk.h>
|
---|
37 |
|
---|
38 | #include <iprt/asm.h>
|
---|
39 | #include <iprt/cdefs.h>
|
---|
40 |
|
---|
41 | /* Do not require IPRT library. */
|
---|
42 | /** @todo r=bird: It is *NOT* okay to redefine Assert* (or Log*) macros! It
|
---|
43 | * causes confusing as the code no longer behaves in the way one expect. Thus,
|
---|
44 | * it is strictly forbidden. */
|
---|
45 | #ifndef IPRT_NO_CRT
|
---|
46 | # undef Assert
|
---|
47 | # undef AssertReturnVoid
|
---|
48 | # ifdef RT_STRICT
|
---|
49 | # define Assert(_e) (void)( (!!(_e)) || (ASMBreakpoint(), 0) )
|
---|
50 | # define AssertReturnVoid(a_Expr) do { if (RT_LIKELY(a_Expr)) {} else { ASMBreakpoint(); return; } } while (0)
|
---|
51 | # else
|
---|
52 | # define Assert(_e) (void)( 0 )
|
---|
53 | # define AssertReturnVoid(a_Expr) do { if (RT_LIKELY(a_Expr)) {} else return; } while (0)
|
---|
54 | # endif
|
---|
55 | #endif
|
---|
56 |
|
---|
57 | /* Do not require ntstatus.h.
|
---|
58 | * D3DKMT functions return NTSTATUS, but the driver code uses it only as a success/failure indicator.
|
---|
59 | * Therefore define the success and a failure status here.
|
---|
60 | */
|
---|
61 | #ifndef STATUS_SUCCESS
|
---|
62 | #define STATUS_SUCCESS 0
|
---|
63 | #endif
|
---|
64 | #ifndef STATUS_NOT_SUPPORTED
|
---|
65 | #define STATUS_NOT_SUPPORTED ((NTSTATUS)0xC00000BBL)
|
---|
66 | #endif
|
---|
67 |
|
---|
68 | RT_C_DECLS_BEGIN
|
---|
69 |
|
---|
70 | typedef struct VBOXWDDMDLLPROC
|
---|
71 | {
|
---|
72 | char const *pszName;
|
---|
73 | FARPROC *ppfn;
|
---|
74 | } VBOXWDDMDLLPROC;
|
---|
75 |
|
---|
76 | typedef struct D3DKMTFUNCTIONS
|
---|
77 | {
|
---|
78 | PFND3DKMT_OPENADAPTERFROMHDC pfnD3DKMTOpenAdapterFromHdc;
|
---|
79 | PFND3DKMT_OPENADAPTERFROMDEVICENAME pfnD3DKMTOpenAdapterFromDeviceName;
|
---|
80 | PFND3DKMT_CLOSEADAPTER pfnD3DKMTCloseAdapter;
|
---|
81 | PFND3DKMT_QUERYADAPTERINFO pfnD3DKMTQueryAdapterInfo;
|
---|
82 | PFND3DKMT_ESCAPE pfnD3DKMTEscape;
|
---|
83 | PFND3DKMT_CREATEDEVICE pfnD3DKMTCreateDevice;
|
---|
84 | PFND3DKMT_DESTROYDEVICE pfnD3DKMTDestroyDevice;
|
---|
85 | PFND3DKMT_CREATECONTEXT pfnD3DKMTCreateContext;
|
---|
86 | PFND3DKMT_DESTROYCONTEXT pfnD3DKMTDestroyContext;
|
---|
87 | PFND3DKMT_CREATEALLOCATION pfnD3DKMTCreateAllocation;
|
---|
88 | PFND3DKMT_DESTROYALLOCATION pfnD3DKMTDestroyAllocation;
|
---|
89 | PFND3DKMT_RENDER pfnD3DKMTRender;
|
---|
90 | PFND3DKMT_PRESENT pfnD3DKMTPresent;
|
---|
91 | PFND3DKMT_GETSHAREDPRIMARYHANDLE pfnD3DKMTGetSharedPrimaryHandle;
|
---|
92 | PFND3DKMT_QUERYRESOURCEINFO pfnD3DKMTQueryResourceInfo;
|
---|
93 | PFND3DKMT_OPENRESOURCE pfnD3DKMTOpenResource;
|
---|
94 |
|
---|
95 | /* Win 8+ */
|
---|
96 | PFND3DKMT_ENUMADAPTERS pfnD3DKMTEnumAdapters;
|
---|
97 | PFND3DKMT_OPENADAPTERFROMLUID pfnD3DKMTOpenAdapterFromLuid;
|
---|
98 | } D3DKMTFUNCTIONS;
|
---|
99 |
|
---|
100 | DECLCALLBACK(HMODULE) VBoxWddmLoadSystemDll(const char *pszName);
|
---|
101 | DECLCALLBACK(void) VBoxWddmLoadAdresses(HMODULE hmod, VBOXWDDMDLLPROC *paProcs);
|
---|
102 |
|
---|
103 | DECLCALLBACK(int) D3DKMTLoad(void);
|
---|
104 | DECLCALLBACK(D3DKMTFUNCTIONS const *) D3DKMTFunctions(void);
|
---|
105 |
|
---|
106 | DECLCALLBACK(void) VBoxDispMpLoggerLogF(const char *pszFormat, ...);
|
---|
107 | DECLCALLBACK(void) VBoxWddmUmLog(const char *pszString);
|
---|
108 |
|
---|
109 | /** @todo Rename to VBoxWddm* */
|
---|
110 | NTSTATUS vboxDispKmtOpenAdapter2(D3DKMT_HANDLE *phAdapter, LUID *pLuid);
|
---|
111 | NTSTATUS vboxDispKmtOpenAdapter(D3DKMT_HANDLE *phAdapter);
|
---|
112 | NTSTATUS vboxDispKmtCloseAdapter(D3DKMT_HANDLE hAdapter);
|
---|
113 |
|
---|
114 | RT_C_DECLS_END
|
---|
115 |
|
---|
116 | #endif /* !GA_INCLUDED_SRC_3D_win_VBoxWddmUmHlp_VBoxWddmUmHlp_h */
|
---|