ReactOS 0.4.17-dev-966-gf06eace
dxcore_interface.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2023 Mohamad Al-Jaf
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19#ifndef __DXCORE_INTERFACE__
20#define __DXCORE_INTERFACE__
21
22#include <stdarg.h>
23#include <stdint.h>
24#include <ole2.h>
25
26#ifdef __cplusplus
27#define DECLARE_ENUM_CLASS(x) enum class x : uint32_t
28#define REFLUID const LUID &
29#else
30#define DECLARE_ENUM_CLASS(x) typedef enum x x; enum x
31#define REFLUID const LUID *
32#endif
33
34DECLARE_ENUM_CLASS(DXCoreAdapterProperty)
35{
36 InstanceLuid = 0,
37 DriverVersion = 1,
38 DriverDescription = 2,
39 HardwareID = 3,
40 KmdModelVersion = 4,
41 ComputePreemptionGranularity = 5,
42 GraphicsPreemptionGranularity = 6,
43 DedicatedAdapterMemory = 7,
44 DedicatedSystemMemory = 8,
45 SharedSystemMemory = 9,
46 AcgCompatible = 10,
47 IsHardware = 11,
48 IsIntegrated = 12,
49 IsDetachable = 13,
50 HardwareIDParts = 14,
51};
52
53DECLARE_ENUM_CLASS(DXCoreAdapterState)
54{
55 IsDriverUpdateInProgress = 0,
56 AdapterMemoryBudget = 1,
57};
58
59DECLARE_ENUM_CLASS(DXCoreSegmentGroup)
60{
61 Local = 0,
62 NonLocal = 1,
63};
64
65DECLARE_ENUM_CLASS(DXCoreNotificationType)
66{
67 AdapterListStale = 0,
68 AdapterNoLongerValid = 1,
69 AdapterBudgetChange = 2,
70 AdapterHardwareContentProtectionTeardown = 3,
71};
72
73DECLARE_ENUM_CLASS(DXCoreAdapterPreference)
74{
75 Hardware = 0,
76 MinimumPower = 1,
77 HighPerformance = 2,
78};
79
80typedef struct DXCoreHardwareID
81{
87
89{
96
98{
100 DXCoreSegmentGroup segmentGroup;
102
104{
110
112
113DEFINE_GUID(IID_IDXCoreAdapterFactory, 0x78ee5945, 0xc36e, 0x4b13, 0xa6, 0x69, 0x00, 0x5d, 0xd1, 0x1c, 0x0f, 0x06);
114DEFINE_GUID(IID_IDXCoreAdapterList, 0x526c7776, 0x40e9, 0x459b, 0xb7, 0x11, 0xf3, 0x2a, 0xd7, 0x6d, 0xfc, 0x28);
115DEFINE_GUID(IID_IDXCoreAdapter, 0xf0db4c7f, 0xfe5a, 0x42a2, 0xbd, 0x62, 0xf2, 0xa6, 0xcf, 0x6f, 0xc8, 0x3e);
116DEFINE_GUID(DXCORE_ADAPTER_ATTRIBUTE_D3D11_GRAPHICS, 0x8c47866b, 0x7583, 0x450d, 0xf0, 0xf0, 0x6b, 0xad, 0xa8, 0x95, 0xaf, 0x4b);
117DEFINE_GUID(DXCORE_ADAPTER_ATTRIBUTE_D3D12_GRAPHICS, 0x0c9ece4d, 0x2f6e, 0x4f01, 0x8c, 0x96, 0xe8, 0x9e, 0x33, 0x1b, 0x47, 0xb1);
118DEFINE_GUID(DXCORE_ADAPTER_ATTRIBUTE_D3D12_CORE_COMPUTE, 0x248e2800, 0xa793, 0x4724, 0xab, 0xaa, 0x23, 0xa6, 0xde, 0x1b, 0xe0, 0x90);
119
120#undef INTERFACE
121#define INTERFACE IDXCoreAdapter
122DECLARE_INTERFACE_IID_(IDXCoreAdapter, IUnknown, "f0db4c7f-fe5a-42a2-bd62-f2a6cf6fc83e")
123{
124 /* IUnknown methods */
128 /* IDXCoreAdapter methods */
129 STDMETHOD_(BOOL, IsValid) (THIS) PURE;
130 STDMETHOD_(BOOL, IsAttributeSupported) (THIS_ REFGUID attribute) PURE;
131 STDMETHOD_(BOOL, IsPropertySupported) (THIS_ DXCoreAdapterProperty property) PURE;
132 STDMETHOD(GetProperty) (THIS_ DXCoreAdapterProperty property, size_t buffer_size, void *buffer) PURE;
133 STDMETHOD(GetPropertySize) (THIS_ DXCoreAdapterProperty property, size_t *buffer_size) PURE;
134 STDMETHOD_(BOOL, IsQueryStateSupported) (THIS_ DXCoreAdapterState property) PURE;
135 STDMETHOD(QueryState) (THIS_ DXCoreAdapterState state, size_t state_details_size, const void *state_details, size_t buffer_size, void *buffer) PURE;
136 STDMETHOD_(BOOL, IsSetStateSupported) (THIS_ DXCoreAdapterState property) PURE;
137 STDMETHOD(SetState) (THIS_ DXCoreAdapterState state, size_t state_details_size, const void *state_details, size_t buffer_size, const void *buffer) PURE;
138 STDMETHOD(GetFactory) (THIS_ REFIID riid, void **ppv) PURE;
139
140 #ifdef __cplusplus
141 template <class T>
142 HRESULT GetProperty(DXCoreAdapterProperty property, T *buffer)
143 {
144 return GetProperty(property, sizeof(T), (void *)buffer);
145 }
146
147 template <class T1, class T2>
148 HRESULT QueryState(DXCoreAdapterState state, const T1 *state_details, T2 *buffer)
149 {
150 return QueryState(state, sizeof(T1), (const void *)state_details, sizeof(T2), (void *)buffer);
151 }
152
153 template <class T>
154 HRESULT QueryState(DXCoreAdapterState state, T *buffer)
155 {
156 return QueryState(state, 0, NULL, sizeof(T), (void *)buffer);
157 }
158
159 template <class T1, class T2>
160 HRESULT SetState(DXCoreAdapterState state, const T1 *state_details, const T2 *buffer)
161 {
162 return SetState(state, sizeof(T1), (const void *)state_details, sizeof(T2), (const void *)buffer);
163 }
164
165 template <class T>
166 HRESULT GetFactory(T **ppv)
167 {
168 return GetFactory(IID_PPV_ARGS(ppv));
169 }
170 #endif
171};
172
173#undef INTERFACE
174#define INTERFACE IDXCoreAdapterList
175DECLARE_INTERFACE_IID_(IDXCoreAdapterList, IUnknown, "526c7776-40e9-459b-b711-f32ad76dfc28")
176{
177 /* IUnknown methods */
181 /* IDXCoreAdapterList methods */
182 STDMETHOD(GetAdapter) (THIS_ uint32_t index, REFIID riid, void **ppv) PURE;
183 STDMETHOD_(uint32_t, GetAdapterCount) (THIS) PURE;
184 STDMETHOD_(BOOL, IsStale) (THIS) PURE;
185 STDMETHOD(GetFactory) (THIS_ REFIID riid, void **ppv) PURE;
186 STDMETHOD(Sort) (THIS_ uint32_t num_preferences, const DXCoreAdapterPreference *preferences) PURE;
187 STDMETHOD_(BOOL, IsAdapterPreferenceSupported) (THIS_ DXCoreAdapterPreference preference) PURE;
188
189 #ifdef __cplusplus
190 template<class T>
192 {
193 return GetAdapter(index, IID_PPV_ARGS(ppv));
194 }
195
196 template <class T>
197 HRESULT GetFactory(T **ppv)
198 {
199 return GetFactory(IID_PPV_ARGS(ppv));
200 }
201 #endif
202};
203
204#undef INTERFACE
205#define INTERFACE IDXCoreAdapterFactory
206DECLARE_INTERFACE_IID_(IDXCoreAdapterFactory, IUnknown, "78ee5945-c36e-4b13-a669-005dd11c0f06")
207{
208 /* IUnknown methods */
212 /* IDXCoreAdapterFactory methods */
213 STDMETHOD(CreateAdapterList) (THIS_ uint32_t num_attributes, const GUID *filter_attributes, REFIID riid, void **ppv) PURE;
214 STDMETHOD(GetAdapterByLuid) (THIS_ REFLUID adapter_luid, REFIID riid, void **ppv) PURE;
215 STDMETHOD_(BOOL, IsNotificationTypeSupported) (THIS_ DXCoreNotificationType type) PURE;
216 STDMETHOD(RegisterEventNotification) (THIS_ IUnknown *dxcore_object, DXCoreNotificationType type, PFN_DXCORE_NOTIFICATION_CALLBACK callback,
217 void *callback_context, uint32_t *event_cookie) PURE;
218 STDMETHOD(UnregisterEventNotification) (THIS_ uint32_t event_cookie) PURE;
219
220 #ifdef __cplusplus
221 template<class T>
222 HRESULT STDMETHODCALLTYPE CreateAdapterList(uint32_t num_attributes, const GUID *filter_attributes, T **ppv)
223 {
224 return CreateAdapterList(num_attributes, filter_attributes, IID_PPV_ARGS(ppv));
225 }
226
227 template<class T>
228 HRESULT STDMETHODCALLTYPE GetAdapterByLuid(const LUID &adapter_luid, T **ppv)
229 {
230 return GetAdapterByLuid(adapter_luid, IID_PPV_ARGS(ppv));
231 }
232 #endif
233};
234
235#endif /* __DXCORE_INTERFACE__ */
static int state
Definition: maze.c:121
#define index(s, c)
Definition: various.h:29
#define PURE
Definition: basetyps.h:64
#define THIS_
Definition: basetyps.h:65
#define THIS
Definition: basetyps.h:66
#define STDMETHOD_(t, m)
Definition: basetyps.h:63
#define STDMETHOD(m)
Definition: basetyps.h:62
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
_In_ BOOLEAN Release
Definition: cdrom.h:920
_Check_return_ _In_ PQUERY_INTERFACE QueryInterface
Definition: dispmprt.h:1318
#define NULL
Definition: types.h:112
UINT32 uint32_t
Definition: types.h:75
UINT64 uint64_t
Definition: types.h:77
#define DECLARE_ENUM_CLASS(x)
void(STDMETHODCALLTYPE * PFN_DXCORE_NOTIFICATION_CALLBACK)(DXCoreNotificationType type, IUnknown *object, void *context)
#define REFLUID
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLuint buffer
Definition: glext.h:5915
GLuint index
Definition: glext.h:6031
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
static IPrintDialogCallback callback
Definition: printdlg.c:325
static ULONG WINAPI AddRef(IStream *iface)
Definition: clist.c:83
#define DECLARE_INTERFACE_IID_(iface, ibase, iid)
Definition: objbase.h:229
#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8)
Definition: guiddef.h:68
#define REFIID
Definition: guiddef.h:118
#define T(num)
Definition: thunks.c:311
wchar_t const *const size_t const buffer_size
Definition: stat.cpp:95
Definition: scsiwmi.h:51
Definition: http.c:7252
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PCUNICODE_STRING HardwareID
Definition: wdfpdo.h:340