aboutsummaryrefslogtreecommitdiff
path: root/contrib/DirectX-Headers/include/directx/dxcore_interface.h
blob: b487fe13fb6637d07c71ff3db788740cd4a809a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
//
// DXCore Interface
// Copyright (C) Microsoft Corporation.
// Licensed under the MIT license.
//

#ifndef __dxcore_interface_h__
#define __dxcore_interface_h__

#ifndef COM_NO_WINDOWS_H
#include "windows.h"
#include "ole2.h"
#endif /*COM_NO_WINDOWS_H*/

#include <stdint.h>

#ifdef __cplusplus

#define _FACDXCORE    0x880
#define MAKE_DXCORE_HRESULT( code )     MAKE_HRESULT( 1, _FACDXCORE, code )

enum class DXCoreAdapterProperty : uint32_t
{
    InstanceLuid = 0,
    DriverVersion = 1,
    DriverDescription = 2,
    HardwareID = 3, // Use HardwareIDParts instead, if available.
    KmdModelVersion = 4,
    ComputePreemptionGranularity = 5,
    GraphicsPreemptionGranularity = 6,
    DedicatedAdapterMemory = 7,
    DedicatedSystemMemory = 8,
    SharedSystemMemory = 9,
    AcgCompatible = 10,
    IsHardware = 11,
    IsIntegrated = 12,
    IsDetachable = 13,
    HardwareIDParts = 14
};

enum class DXCoreAdapterState : uint32_t
{
    IsDriverUpdateInProgress = 0,
    AdapterMemoryBudget = 1
};

enum class DXCoreSegmentGroup : uint32_t
{
    Local = 0,
    NonLocal = 1
};

enum class DXCoreNotificationType : uint32_t
{
    AdapterListStale = 0,
    AdapterNoLongerValid = 1,
    AdapterBudgetChange = 2,
    AdapterHardwareContentProtectionTeardown = 3
};

enum class DXCoreAdapterPreference : uint32_t
{
    Hardware = 0,
    MinimumPower = 1,
    HighPerformance = 2
};

struct DXCoreHardwareID
{
    uint32_t vendorID;
    uint32_t deviceID;
    uint32_t subSysID;
    uint32_t revision;
};

struct DXCoreHardwareIDParts
{
    uint32_t vendorID;
    uint32_t deviceID;
    uint32_t subSystemID;
    uint32_t subVendorID;
    uint32_t revisionID;
};

struct DXCoreAdapterMemoryBudgetNodeSegmentGroup
{
    uint32_t nodeIndex;
    DXCoreSegmentGroup segmentGroup;
};

struct DXCoreAdapterMemoryBudget
{
    uint64_t budget;
    uint64_t currentUsage;
    uint64_t availableForReservation;
    uint64_t currentReservation;
};

typedef void (STDMETHODCALLTYPE *PFN_DXCORE_NOTIFICATION_CALLBACK)(
    DXCoreNotificationType notificationType,
    _In_ IUnknown *object,
    _In_opt_ void *context);

static_assert(sizeof(bool) == 1, "bool assumed as one byte");

DEFINE_GUID(IID_IDXCoreAdapterFactory, 0x78ee5945, 0xc36e, 0x4b13, 0xa6, 0x69, 0x00, 0x5d, 0xd1, 0x1c, 0x0f, 0x06);
DEFINE_GUID(IID_IDXCoreAdapterList, 0x526c7776, 0x40e9, 0x459b, 0xb7, 0x11, 0xf3, 0x2a, 0xd7, 0x6d, 0xfc, 0x28);
DEFINE_GUID(IID_IDXCoreAdapter, 0xf0db4c7f, 0xfe5a, 0x42a2, 0xbd, 0x62, 0xf2, 0xa6, 0xcf, 0x6f, 0xc8, 0x3e);
DEFINE_GUID(DXCORE_ADAPTER_ATTRIBUTE_D3D11_GRAPHICS, 0x8c47866b, 0x7583, 0x450d, 0xf0, 0xf0, 0x6b, 0xad, 0xa8, 0x95, 0xaf, 0x4b);
DEFINE_GUID(DXCORE_ADAPTER_ATTRIBUTE_D3D12_GRAPHICS, 0x0c9ece4d, 0x2f6e, 0x4f01, 0x8c, 0x96, 0xe8, 0x9e, 0x33, 0x1b, 0x47, 0xb1);
DEFINE_GUID(DXCORE_ADAPTER_ATTRIBUTE_D3D12_CORE_COMPUTE, 0x248e2800, 0xa793, 0x4724, 0xab, 0xaa, 0x23, 0xa6, 0xde, 0x1b, 0xe0, 0x90);

/* interface IDXCoreAdapter */
MIDL_INTERFACE("f0db4c7f-fe5a-42a2-bd62-f2a6cf6fc83e")
IDXCoreAdapter : public IUnknown
{
public:
    virtual bool STDMETHODCALLTYPE IsValid() = 0;

    virtual bool STDMETHODCALLTYPE IsAttributeSupported( 
        REFGUID attributeGUID) = 0;

    virtual bool STDMETHODCALLTYPE IsPropertySupported( 
        DXCoreAdapterProperty property) = 0;

    virtual HRESULT STDMETHODCALLTYPE GetProperty( 
        DXCoreAdapterProperty property,
        size_t bufferSize,
        _Out_writes_bytes_(bufferSize)  void *propertyData) = 0;

    template <class T>
    HRESULT GetProperty( 
        DXCoreAdapterProperty property,
        _Out_writes_bytes_(sizeof(T))  T *propertyData)
    {
        return GetProperty(property,
                           sizeof(T),
                           (void*)propertyData);
    }

    virtual HRESULT STDMETHODCALLTYPE GetPropertySize( 
        DXCoreAdapterProperty property,
        _Out_ size_t *bufferSize) = 0;

    virtual bool STDMETHODCALLTYPE IsQueryStateSupported( 
        DXCoreAdapterState property) = 0;

    virtual HRESULT STDMETHODCALLTYPE QueryState( 
        DXCoreAdapterState state,
        size_t inputStateDetailsSize,
        _In_reads_bytes_opt_(inputStateDetailsSize) const void *inputStateDetails,
        size_t outputBufferSize,
        _Out_writes_bytes_(outputBufferSize) void *outputBuffer) = 0;

    template <class T1, class T2>
    HRESULT QueryState( 
        DXCoreAdapterState state,
        _In_reads_bytes_opt_(sizeof(T1)) const T1 *inputStateDetails,
        _Out_writes_bytes_(sizeof(T2)) T2 *outputBuffer)
    {
        return QueryState(state,
                          sizeof(T1),
                          (const void*)inputStateDetails,
                          sizeof(T2),
                          (void*)outputBuffer);
    }

    template <class T>
    HRESULT QueryState( 
        DXCoreAdapterState state,
        _Out_writes_bytes_(sizeof(T)) T *outputBuffer)
    {
        return QueryState(state,
                          0,
                          nullptr,
                          sizeof(T),
                          (void*)outputBuffer);
    }

    virtual bool STDMETHODCALLTYPE IsSetStateSupported( 
        DXCoreAdapterState property) = 0;

    virtual HRESULT STDMETHODCALLTYPE SetState( 
        DXCoreAdapterState state,
        size_t inputStateDetailsSize,
        _In_reads_bytes_opt_(inputStateDetailsSize) const void *inputStateDetails,
        size_t inputDataSize,
        _In_reads_bytes_(inputDataSize) const void *inputData) = 0;

    template <class T1, class T2>
    HRESULT SetState( 
        DXCoreAdapterState state,
        const T1 *inputStateDetails,
        const T2 *inputData)
    {
        return SetState(state,
                        sizeof(T1),
                        (const void*)inputStateDetails,
                        sizeof(T2),
                        (const void*)inputData);
    }

    virtual HRESULT STDMETHODCALLTYPE GetFactory(
        REFIID riid,
        _COM_Outptr_ void** ppvFactory
    ) = 0;

    template <class T>
    HRESULT GetFactory(
        _COM_Outptr_ T** ppvFactory
    )
    {
        return GetFactory(IID_PPV_ARGS(ppvFactory));
    }
};

/* interface IDXCoreAdapterList */
MIDL_INTERFACE("526c7776-40e9-459b-b711-f32ad76dfc28")
IDXCoreAdapterList : public IUnknown
{
public:
    virtual HRESULT STDMETHODCALLTYPE GetAdapter( 
        uint32_t index,
        REFIID riid,
        _COM_Outptr_ void **ppvAdapter) = 0;

    template<class T>
    HRESULT STDMETHODCALLTYPE GetAdapter( 
        uint32_t index,
        _COM_Outptr_ T **ppvAdapter)
    {
        return GetAdapter(index,
                          IID_PPV_ARGS(ppvAdapter));
    }

    virtual uint32_t STDMETHODCALLTYPE GetAdapterCount() = 0;

    virtual bool STDMETHODCALLTYPE IsStale() = 0;

    virtual HRESULT STDMETHODCALLTYPE GetFactory(
        REFIID riid,
        _COM_Outptr_ void** ppvFactory
    ) = 0;

    template <class T>
    HRESULT GetFactory(
        _COM_Outptr_ T** ppvFactory
    )
    {
        return GetFactory(IID_PPV_ARGS(ppvFactory));
    }

    virtual HRESULT STDMETHODCALLTYPE Sort(
        uint32_t numPreferences,
        _In_reads_(numPreferences) const DXCoreAdapterPreference* preferences) = 0;

    virtual bool STDMETHODCALLTYPE IsAdapterPreferenceSupported( 
        DXCoreAdapterPreference preference) = 0;
};

/* interface IDXCoreAdapterFactory */
MIDL_INTERFACE("78ee5945-c36e-4b13-a669-005dd11c0f06")
IDXCoreAdapterFactory : public IUnknown
{
public:

    virtual HRESULT STDMETHODCALLTYPE CreateAdapterList( 
        uint32_t numAttributes,
        _In_reads_(numAttributes) const GUID *filterAttributes,
        REFIID riid,
        _COM_Outptr_ void **ppvAdapterList) = 0;

    template<class T>
    HRESULT STDMETHODCALLTYPE CreateAdapterList( 
        uint32_t numAttributes,
        _In_reads_(numAttributes) const GUID *filterAttributes,
        _COM_Outptr_ T **ppvAdapterList)
    {
        return CreateAdapterList(numAttributes,
                                 filterAttributes,
                                 IID_PPV_ARGS(ppvAdapterList));
    }

    virtual HRESULT STDMETHODCALLTYPE GetAdapterByLuid( 
        const LUID &adapterLUID,
        REFIID riid,
        _COM_Outptr_ void **ppvAdapter) = 0;

    template<class T>
    HRESULT STDMETHODCALLTYPE GetAdapterByLuid( 
        const LUID &adapterLUID,
        _COM_Outptr_ T **ppvAdapter)
    {
        return GetAdapterByLuid(adapterLUID,
                                IID_PPV_ARGS(ppvAdapter));
    }

    virtual bool STDMETHODCALLTYPE IsNotificationTypeSupported( 
        DXCoreNotificationType notificationType) = 0;

    virtual HRESULT STDMETHODCALLTYPE RegisterEventNotification( 
        _In_ IUnknown *dxCoreObject,
        DXCoreNotificationType notificationType,
        _In_ PFN_DXCORE_NOTIFICATION_CALLBACK callbackFunction,
        _In_opt_ void *callbackContext,
        _Out_ uint32_t *eventCookie) = 0;

    virtual HRESULT STDMETHODCALLTYPE UnregisterEventNotification( 
        uint32_t eventCookie) = 0;
};

#endif // __cplusplus

#endif // __dxcore_interface_h__