winewayland.drv: Ensure outputs can access xdg information robustly.
[wine.git] / include / dxcore_interface.h
blob635a7f047a5199e07528aea059c5b4858ac1bee9
1 /*
2 * Copyright (C) 2023 Mohamad Al-Jaf
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.
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.
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
19 #ifndef __DXCORE_INTERFACE__
20 #define __DXCORE_INTERFACE__
22 #include <stdarg.h>
23 #include <stdint.h>
24 #include <ole2.h>
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
34 DECLARE_ENUM_CLASS(DXCoreAdapterProperty)
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,
53 DECLARE_ENUM_CLASS(DXCoreAdapterState)
55 IsDriverUpdateInProgress = 0,
56 AdapterMemoryBudget = 1,
59 DECLARE_ENUM_CLASS(DXCoreSegmentGroup)
61 Local = 0,
62 NonLocal = 1,
65 DECLARE_ENUM_CLASS(DXCoreNotificationType)
67 AdapterListStale = 0,
68 AdapterNoLongerValid = 1,
69 AdapterBudgetChange = 2,
70 AdapterHardwareContentProtectionTeardown = 3,
73 DECLARE_ENUM_CLASS(DXCoreAdapterPreference)
75 Hardware = 0,
76 MinimumPower = 1,
77 HighPerformance = 2,
80 typedef struct DXCoreHardwareID
82 uint32_t vendorID;
83 uint32_t deviceID;
84 uint32_t subSysID;
85 uint32_t revision;
86 } DXCoreHardwareID;
88 typedef struct DXCoreHardwareIDParts
90 uint32_t vendorID;
91 uint32_t deviceID;
92 uint32_t subSystemID;
93 uint32_t subVendorID;
94 uint32_t revisionID;
95 } DXCoreHardwareIDParts;
97 typedef struct DXCoreAdapterMemoryBudgetNodeSegmentGroup
99 uint32_t nodeIndex;
100 DXCoreSegmentGroup segmentGroup;
101 } DXCoreAdapterMemoryBudgetNodeSegmentGroup;
103 typedef struct DXCoreAdapterMemoryBudget
105 uint64_t budget;
106 uint64_t currentUsage;
107 uint64_t availableForReservation;
108 uint64_t currentReservation;
109 } DXCoreAdapterMemoryBudget;
111 typedef void (STDMETHODCALLTYPE *PFN_DXCORE_NOTIFICATION_CALLBACK)(DXCoreNotificationType type, IUnknown *object, void *context);
113 DEFINE_GUID(IID_IDXCoreAdapterFactory, 0x78ee5945, 0xc36e, 0x4b13, 0xa6, 0x69, 0x00, 0x5d, 0xd1, 0x1c, 0x0f, 0x06);
114 DEFINE_GUID(IID_IDXCoreAdapterList, 0x526c7776, 0x40e9, 0x459b, 0xb7, 0x11, 0xf3, 0x2a, 0xd7, 0x6d, 0xfc, 0x28);
115 DEFINE_GUID(IID_IDXCoreAdapter, 0xf0db4c7f, 0xfe5a, 0x42a2, 0xbd, 0x62, 0xf2, 0xa6, 0xcf, 0x6f, 0xc8, 0x3e);
116 DEFINE_GUID(DXCORE_ADAPTER_ATTRIBUTE_D3D11_GRAPHICS, 0x8c47866b, 0x7583, 0x450d, 0xf0, 0xf0, 0x6b, 0xad, 0xa8, 0x95, 0xaf, 0x4b);
117 DEFINE_GUID(DXCORE_ADAPTER_ATTRIBUTE_D3D12_GRAPHICS, 0x0c9ece4d, 0x2f6e, 0x4f01, 0x8c, 0x96, 0xe8, 0x9e, 0x33, 0x1b, 0x47, 0xb1);
118 DEFINE_GUID(DXCORE_ADAPTER_ATTRIBUTE_D3D12_CORE_COMPUTE, 0x248e2800, 0xa793, 0x4724, 0xab, 0xaa, 0x23, 0xa6, 0xde, 0x1b, 0xe0, 0x90);
120 #undef INTERFACE
121 #define INTERFACE IDXCoreAdapter
122 DECLARE_INTERFACE_IID_(IDXCoreAdapter, IUnknown, "f0db4c7f-fe5a-42a2-bd62-f2a6cf6fc83e")
124 /* IUnknown methods */
125 STDMETHOD(QueryInterface) (THIS_ REFIID riid, void **ppv) PURE;
126 STDMETHOD_(ULONG, AddRef) (THIS) PURE;
127 STDMETHOD_(ULONG, Release) (THIS) PURE;
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;
140 #ifdef __cplusplus
141 template <class T>
142 HRESULT GetProperty(DXCoreAdapterProperty property, T *buffer)
144 return GetProperty(property, sizeof(T), (void *)buffer);
147 template <class T1, class T2>
148 HRESULT QueryState(DXCoreAdapterState state, const T1 *state_details, T2 *buffer)
150 return QueryState(state, sizeof(T1), (const void *)state_details, sizeof(T2), (void *)buffer);
153 template <class T>
154 HRESULT QueryState(DXCoreAdapterState state, T *buffer)
156 return QueryState(state, 0, NULL, sizeof(T), (void *)buffer);
159 template <class T1, class T2>
160 HRESULT SetState(DXCoreAdapterState state, const T1 *state_details, const T2 *buffer)
162 return SetState(state, sizeof(T1), (const void *)state_details, sizeof(T2), (const void *)buffer);
165 template <class T>
166 HRESULT GetFactory(T **ppv)
168 return GetFactory(IID_PPV_ARGS(ppv));
170 #endif
173 #undef INTERFACE
174 #define INTERFACE IDXCoreAdapterList
175 DECLARE_INTERFACE_IID_(IDXCoreAdapterList, IUnknown, "526c7776-40e9-459b-b711-f32ad76dfc28")
177 /* IUnknown methods */
178 STDMETHOD(QueryInterface) (THIS_ REFIID riid, void **ppv) PURE;
179 STDMETHOD_(ULONG, AddRef) (THIS) PURE;
180 STDMETHOD_(ULONG, Release) (THIS) PURE;
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;
189 #ifdef __cplusplus
190 template<class T>
191 HRESULT STDMETHODCALLTYPE GetAdapter(uint32_t index, T **ppv)
193 return GetAdapter(index, IID_PPV_ARGS(ppv));
196 template <class T>
197 HRESULT GetFactory(T **ppv)
199 return GetFactory(IID_PPV_ARGS(ppv));
201 #endif
204 #undef INTERFACE
205 #define INTERFACE IDXCoreAdapterFactory
206 DECLARE_INTERFACE_IID_(IDXCoreAdapterFactory, IUnknown, "78ee5945-c36e-4b13-a669-005dd11c0f06")
208 /* IUnknown methods */
209 STDMETHOD(QueryInterface) (THIS_ REFIID riid, void **ppv) PURE;
210 STDMETHOD_(ULONG, AddRef) (THIS) PURE;
211 STDMETHOD_(ULONG, Release) (THIS) PURE;
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;
220 #ifdef __cplusplus
221 template<class T>
222 HRESULT STDMETHODCALLTYPE CreateAdapterList(uint32_t num_attributes, const GUID *filter_attributes, T **ppv)
224 return CreateAdapterList(num_attributes, filter_attributes, IID_PPV_ARGS(ppv));
227 template<class T>
228 HRESULT STDMETHODCALLTYPE GetAdapterByLuid(const LUID &adapter_luid, T **ppv)
230 return GetAdapterByLuid(adapter_luid, IID_PPV_ARGS(ppv));
232 #endif
235 #endif /* __DXCORE_INTERFACE__ */