From: Mohamad Al-Jaf mohamadaljaf@gmail.com
--- include/Makefile.in | 1 + include/dxcore_interface.idl | 175 +++++++++++++++++++++++++++++++++++ 2 files changed, 176 insertions(+) create mode 100644 include/dxcore_interface.idl
diff --git a/include/Makefile.in b/include/Makefile.in index f4475d9438f..b4eff06f638 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -282,6 +282,7 @@ SOURCES = \ dwrite_1.idl \ dwrite_2.idl \ dwrite_3.idl \ + dxcore_interface.idl \ dxdiag.h \ dxerr8.h \ dxerr9.h \ diff --git a/include/dxcore_interface.idl b/include/dxcore_interface.idl new file mode 100644 index 00000000000..abc43063fb6 --- /dev/null +++ b/include/dxcore_interface.idl @@ -0,0 +1,175 @@ +/* + * Copyright (C) 2023 Mohamad Al-Jaf + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +cpp_quote("#include <windows.h>") +cpp_quote("#include <ole2.h>") +cpp_quote("#include <stdint.h>") + +import "unknwn.idl"; + +cpp_quote("#if 0") +typedef unsigned uint32_t; +typedef UINT64 uint64_t; + +typedef struct _LUID +{ + DWORD LowPart; + LONG HighPart; +} LUID; +cpp_quote("#endif") + +#ifdef __cplusplus +#define REFLUID const LUID & +#else +#define REFLUID const LUID * +#endif + +typedef enum DXCoreAdapterProperty +{ + InstanceLuid = 0, + DriverVersion = 1, + DriverDescription = 2, + HardwareID = 3, + KmdModelVersion = 4, + ComputePreemptionGranularity = 5, + GraphicsPreemptionGranularity = 6, + DedicatedAdapterMemory = 7, + DedicatedSystemMemory = 8, + SharedSystemMemory = 9, + AcgCompatible = 10, + IsHardware = 11, + IsIntegrated = 12, + IsDetachable = 13, + HardwareIDParts = 14, +} DXCoreAdapterProperty; + +typedef enum DXCoreAdapterState +{ + IsDriverUpdateInProgress = 0, + AdapterMemoryBudget = 1, +} DXCoreAdapterState; + +typedef enum DXCoreSegmentGroup +{ + Local = 0, + NonLocal = 1, +} DXCoreSegmentGroup; + +typedef enum DXCoreNotificationType +{ + AdapterListStale = 0, + AdapterNoLongerValid = 1, + AdapterBudgetChange = 2, + AdapterHardwareContentProtectionTeardown = 3, +} DXCoreNotificationType; + +typedef enum DXCoreAdapterPreference +{ + Hardware = 0, + MinimumPower = 1, + HighPerformance = 2, +} DXCoreAdapterPreference; + +typedef struct DXCoreHardwareID +{ + uint32_t vendorID; + uint32_t deviceID; + uint32_t subSysID; + uint32_t revision; +} DXCoreHardwareID; + +typedef struct DXCoreHardwareIDParts +{ + uint32_t vendorID; + uint32_t deviceID; + uint32_t subSystemID; + uint32_t subVendorID; + uint32_t revisionID; +} DXCoreHardwareIDParts; + +typedef struct DXCoreAdapterMemoryBudgetNodeSegmentGroup +{ + uint32_t nodeIndex; + DXCoreSegmentGroup segmentGroup; +} DXCoreAdapterMemoryBudgetNodeSegmentGroup; + +typedef struct DXCoreAdapterMemoryBudget +{ + uint64_t budget; + uint64_t currentUsage; + uint64_t availableForReservation; + uint64_t currentReservation; +} DXCoreAdapterMemoryBudget; + +typedef void (__stdcall *PFN_DXCORE_NOTIFICATION_CALLBACK)(DXCoreNotificationType type, IUnknown *object, void *context); + +cpp_quote("DEFINE_GUID(IID_IDXCoreAdapterFactory, 0x78ee5945, 0xc36e, 0x4b13, 0xa6, 0x69, 0x00, 0x5d, 0xd1, 0x1c, 0x0f, 0x06);") +cpp_quote("DEFINE_GUID(IID_IDXCoreAdapterList, 0x526c7776, 0x40e9, 0x459b, 0xb7, 0x11, 0xf3, 0x2a, 0xd7, 0x6d, 0xfc, 0x28);") +cpp_quote("DEFINE_GUID(IID_IDXCoreAdapter, 0xf0db4c7f, 0xfe5a, 0x42a2, 0xbd, 0x62, 0xf2, 0xa6, 0xcf, 0x6f, 0xc8, 0x3e);") +cpp_quote("DEFINE_GUID(DXCORE_ADAPTER_ATTRIBUTE_D3D11_GRAPHICS, 0x8c47866b, 0x7583, 0x450d, 0xf0, 0xf0, 0x6b, 0xad, 0xa8, 0x95, 0xaf, 0x4b);") +cpp_quote("DEFINE_GUID(DXCORE_ADAPTER_ATTRIBUTE_D3D12_GRAPHICS, 0x0c9ece4d, 0x2f6e, 0x4f01, 0x8c, 0x96, 0xe8, 0x9e, 0x33, 0x1b, 0x47, 0xb1);") +cpp_quote("DEFINE_GUID(DXCORE_ADAPTER_ATTRIBUTE_D3D12_CORE_COMPUTE, 0x248e2800, 0xa793, 0x4724, 0xab, 0xaa, 0x23, 0xa6, 0xde, 0x1b, 0xe0, 0x90);") + +[ + local, + object, + uuid(f0db4c7f-fe5a-42a2-bd62-f2a6cf6fc83e), +] +interface IDXCoreAdapter : IUnknown +{ + BOOL IsValid(); + BOOL IsAttributeSupported(GUID attribute); + BOOL IsPropertySupported(DXCoreAdapterProperty property); + HRESULT GetProperty(DXCoreAdapterProperty property, SIZE_T *buffer, void *data); + HRESULT GetPropertySize(DXCoreAdapterProperty property, SIZE_T *buffer); + BOOL IsQueryStateSupported(DXCoreAdapterState property); + HRESULT QueryState(DXCoreAdapterState state, SIZE_T state_size, const void *input, SIZE_T buffer_size, void *output); + BOOL IsSetStateSupported(DXCoreAdapterState property); + HRESULT SetState(DXCoreAdapterState state, SIZE_T state_size, const void *in_state, SIZE_T data_size, const void *data); + HRESULT GetFactory(REFIID riid, [out, iid_is(riid)] IUnknown **ppv); + HRESULT GetAdapterByLuid(LUID adapter, REFIID riid, [out, iid_is(riid)] IUnknown **ppv); +}; + +[ + local, + object, + uuid(526c7776-40e9-459b-b711-f32ad76dfc28), +] +interface IDXCoreAdapterList : IUnknown +{ + HRESULT GetAdapter(uint32_t index, REFIID riid, [out, iid_is(riid)] void **ppv); + uint32_t GetAdapterCount(); + BOOL IsStale(); + HRESULT GetFactory(REFIID riid, [out, iid_is(riid)] void **ppv); + HRESULT Sort(uint32_t num, const DXCoreAdapterPreference *preferences); + BOOL IsAdapterPreferenceSupported(DXCoreAdapterPreference preference); +}; + +[ + local, + object, + uuid(78ee5945-c36e-4b13-a669-005dd11c0f06), +] +interface IDXCoreAdapterFactory : IUnknown +{ + HRESULT CreateAdapterList(uint32_t num, const GUID *filter, REFIID riid, [out, iid_is(riid)] void **ppv); + HRESULT GetAdapterByLuid(REFLUID adapter, REFIID riid, [out, iid_is(riid)] void **ppv); + BOOL IsNotificationTypeSupported(DXCoreNotificationType type); + HRESULT RegisterEventNotification(IUnknown *object, DXCoreNotificationType type, PFN_DXCORE_NOTIFICATION_CALLBACK callback, void *context, uint32_t *cookie); + HRESULT UnregisterEventNotification(uint32_t cookie); +};