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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
/*
* Copyright 2007 Andras Kovacs
*
* 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
*/
import "dxgitype.idl";
const UINT _FACDXGI = 0x87a;
cpp_quote("#define MAKE_DXGI_STATUS(x) MAKE_HRESULT(0, _FACDXGI, x)")
cpp_quote("#define DXGI_STATUS_OCCLUDED MAKE_DXGI_STATUS(1)")
cpp_quote("#define DXGI_STATUS_CLIPPED MAKE_DXGI_STATUS(2)")
cpp_quote("#define DXGI_STATUS_NO_REDIRECTION MAKE_DXGI_STATUS(4)")
cpp_quote("#define DXGI_STATUS_NO_DESKTOP_ACCESS MAKE_DXGI_STATUS(5)")
cpp_quote("#define DXGI_STATUS_GRAPHICS_VIDPN_SOURCE_IN_USE MAKE_DXGI_STATUS(6)")
cpp_quote("#define DXGI_STATUS_MODE_CHANGED MAKE_DXGI_STATUS(7)")
cpp_quote("#define DXGI_STATUS_MODE_CHANGE_IN_PROGRESS MAKE_DXGI_STATUS(8)")
cpp_quote("#define MAKE_DXGI_HRESULT(x) MAKE_HRESULT(1, _FACDXGI, x)")
cpp_quote("#define DXGI_ERROR_INVALID_CALL MAKE_DXGI_HRESULT(1)")
cpp_quote("#define DXGI_ERROR_NOT_FOUND MAKE_DXGI_HRESULT(2)")
cpp_quote("#define DXGI_ERROR_MORE_DATA MAKE_DXGI_HRESULT(3)")
cpp_quote("#define DXGI_ERROR_UNSUPPORTED MAKE_DXGI_HRESULT(4)")
cpp_quote("#define DXGI_ERROR_DEVICE_REMOVED MAKE_DXGI_HRESULT(5)")
cpp_quote("#define DXGI_ERROR_DEVICE_HUNG MAKE_DXGI_HRESULT(6)")
cpp_quote("#define DXGI_ERROR_DEVICE_RESET MAKE_DXGI_HRESULT(7)")
cpp_quote("#define DXGI_ERROR_WAS_STILL_DRAWING MAKE_DXGI_HRESULT(10)")
cpp_quote("#define DXGI_ERROR_FRAME_STATISTICS_DISJOINT MAKE_DXGI_HRESULT(11)")
cpp_quote("#define DXGI_ERROR_GRAPHICS_VIDPN_SOURCE_IN_USE MAKE_DXGI_HRESULT(12)")
cpp_quote("#define DXGI_ERROR_DRIVER_INTERNAL_ERROR MAKE_DXGI_HRESULT(32)")
cpp_quote("#define DXGI_ERROR_NONEXCLUSIVE MAKE_DXGI_HRESULT(33)")
cpp_quote("#define DXGI_ERROR_NOT_CURRENTLY_AVAILABLE MAKE_DXGI_HRESULT(34)")
cpp_quote("#if 0")
typedef HANDLE HMONITOR;
typedef struct _LUID {
DWORD LowPart;
LONG HighPart;
} LUID, *PLUID;
cpp_quote("#endif")
typedef UINT DXGI_USAGE;
const DXGI_USAGE DXGI_USAGE_SHADER_INPUT = 0x10L;
const DXGI_USAGE DXGI_USAGE_RENDER_TARGET_OUTPUT = 0x20L;
const DXGI_USAGE DXGI_USAGE_BACK_BUFFER = 0x40L;
const DXGI_USAGE DXGI_USAGE_SHARED = 0x80L;
const DXGI_USAGE DXGI_USAGE_READ_ONLY = 0x100L;
typedef enum DXGI_SWAP_EFFECT {
DXGI_SWAP_EFFECT_DISCARD = 0,
DXGI_SWAP_EFFECT_SEQUENTIAL = 1,
} DXGI_SWAP_EFFECT;
typedef enum DXGI_RESIDENCY {
DXGI_RESIDENCY_FULLY_RESIDENT = 1,
DXGI_RESIDENCY_RESIDENT_IN_SHARED_MEMORY = 2,
DXGI_RESIDENCY_EVICTED_TO_DISK = 3,
} DXGI_RESIDENCY;
typedef struct DXGI_SURFACE_DESC {
UINT Width;
UINT Height;
DXGI_FORMAT Format;
DXGI_SAMPLE_DESC SampleDesc;
} DXGI_SURFACE_DESC;
typedef struct DXGI_MAPPED_RECT {
INT Pitch;
BYTE *pBits;
} DXGI_MAPPED_RECT;
typedef struct DXGI_OUTPUT_DESC {
WCHAR DeviceName[32];
RECT DesktopCoordinates;
BOOL AttachedToDesktop;
DXGI_MODE_ROTATION Rotation;
HMONITOR Monitor;
} DXGI_OUTPUT_DESC;
typedef struct DXGI_FRAME_STATISTICS {
UINT PresentCount;
UINT PresentRefreshCount;
UINT SyncRefreshCount;
LARGE_INTEGER SyncQPCTime;
LARGE_INTEGER SyncGPUTime;
} DXGI_FRAME_STATISTICS;
typedef struct DXGI_ADAPTER_DESC {
WCHAR Description[128];
UINT VendorId;
UINT DeviceId;
UINT SubSysId;
UINT Revision;
SIZE_T DedicatedVideoMemory;
SIZE_T DedicatedSystemMemory;
SIZE_T SharedSystemMemory;
LUID AdapterLuid;
} DXGI_ADAPTER_DESC;
typedef struct DXGI_SWAP_CHAIN_DESC {
DXGI_MODE_DESC BufferDesc;
DXGI_SAMPLE_DESC SampleDesc;
DXGI_USAGE BufferUsage;
UINT BufferCount;
HWND OutputWindow;
BOOL Windowed;
DXGI_SWAP_EFFECT SwapEffect;
UINT Flags;
} DXGI_SWAP_CHAIN_DESC;
typedef struct DXGI_SHARED_RESOURCE {
HANDLE Handle;
} DXGI_SHARED_RESOURCE;
[
object,
local,
uuid(aec22fb8-76f3-4639-9be0-28eb43a67a2e)
]
interface IDXGIObject : IUnknown
{
HRESULT SetPrivateData(
[in] REFGUID guid,
[in] UINT data_size,
[in] const void *data
);
HRESULT SetPrivateDataInterface(
[in] REFGUID guid,
[in] const IUnknown *object
);
HRESULT GetPrivateData(
[in] REFGUID guid,
[in, out] UINT *data_size,
[out] void *data
);
HRESULT GetParent(
[in] REFIID riid,
[out] void **parent
);
}
[
object,
local,
uuid(3d3e0379-f9de-4d58-bb6c-18d62992f1a6)
]
interface IDXGIDeviceSubObject : IDXGIObject
{
HRESULT GetDevice(
[in] REFIID riid,
[out] void **device
);
}
[
object,
local,
uuid(cafcb56c-6ac3-4889-bf47-9e23bbd260ec)
]
interface IDXGISurface : IDXGIDeviceSubObject
{
HRESULT GetDesc(
[out] DXGI_SURFACE_DESC *desc
);
HRESULT Map(
[out] DXGI_MAPPED_RECT *mapped_rect,
[in] UINT flags
);
HRESULT Unmap(
);
}
[
object,
local,
uuid(ae02eedb-c735-4690-8d52-5a8dc20213aa)
]
interface IDXGIOutput : IDXGIObject
{
HRESULT GetDesc(
[out] DXGI_OUTPUT_DESC *desc
);
HRESULT GetDisplayModeList(
[in] DXGI_FORMAT format,
[in] UINT flags,
[in, out] UINT *mode_count,
[out] DXGI_MODE_DESC *desc
);
HRESULT FindClosestMatchingMode(
[in] const DXGI_MODE_DESC *mode,
[out] DXGI_MODE_DESC *closest_match,
[in] IUnknown *device
);
HRESULT WaitForVBlank(
);
HRESULT TakeOwnership(
[in] IUnknown *device,
[in] BOOL exclusive
);
void ReleaseOwnership(
);
HRESULT GetGammaControlCapabilities(
[out] DXGI_GAMMA_CONTROL_CAPABILITIES *gamma_caps
);
HRESULT SetGammaControl(
[in] const DXGI_GAMMA_CONTROL *gamma_control
);
HRESULT GetGammaControl(
[out] DXGI_GAMMA_CONTROL *gamma_control
);
HRESULT SetDisplaySurface(
[in] IDXGISurface *surface
);
HRESULT GetDisplaySurfaceData(
[in] IDXGISurface *surface
);
HRESULT GetFrameStatistics(
[out] DXGI_FRAME_STATISTICS *stats
);
}
[
object,
local,
uuid(2411e7e1-12ac-4ccf-bd14-9798e8534dc0)
]
interface IDXGIAdapter : IDXGIObject
{
HRESULT EnumOutputs(
[in] UINT output_idx,
[in, out] IDXGIOutput **output
);
HRESULT GetDesc(
[out] DXGI_ADAPTER_DESC *desc
);
HRESULT CheckInterfaceSupport(
[in] REFGUID guid,
[out] LARGE_INTEGER *umd_version
);
}
[
object,
local,
uuid(310d36a0-d2e7-4c0a-aa04-6a9d23b8886a)
]
interface IDXGISwapChain : IDXGIDeviceSubObject
{
HRESULT Present(
[in] UINT sync_interval,
[in] UINT flags
);
HRESULT GetBuffer(
[in] UINT buffer_idx,
[in] REFIID riid,
[in, out] void **surface
);
HRESULT SetFullscreenState(
[in] BOOL fullscreen,
[in] IDXGIOutput *target
);
HRESULT GetFullscreenState(
[out] BOOL *fullscreen,
[out] IDXGIOutput **target
);
HRESULT GetDesc(
[out] DXGI_SWAP_CHAIN_DESC *desc
);
HRESULT ResizeBuffers(
[in] UINT buffer_count,
[in] UINT width,
[in] UINT height,
[in] DXGI_FORMAT format,
[in] UINT flags
);
HRESULT ResizeTarget(
[in] const DXGI_MODE_DESC *target_mode_desc
);
HRESULT GetContainingOutput(
[out] IDXGIOutput **output
);
HRESULT GetFrameStatistics(
[out] DXGI_FRAME_STATISTICS *stats
);
HRESULT GetLastPresentCount(
[out] UINT *last_present_count
);
}
[
object,
local,
uuid(7b7166ec-21c7-44ae-b21a-c9ae321ae369)
]
interface IDXGIFactory : IDXGIObject
{
HRESULT EnumAdapters(
[in] UINT adapter_idx,
[out] IDXGIAdapter **adapter
);
HRESULT MakeWindowAssociation(
[in] HWND window,
[in] UINT flags
);
HRESULT GetWindowAssociation(
[in] HWND *window
);
HRESULT CreateSwapChain(
[in] IUnknown *device,
[in] DXGI_SWAP_CHAIN_DESC *desc,
[out] IDXGISwapChain **swapchain
);
HRESULT CreateSoftwareAdapter(
[in] HMODULE swrast,
[out] IDXGIAdapter **adapter
);
}
[local] HRESULT CreateDXGIFactory(REFIID riid, void **factory);
[
object,
local,
uuid(54ec77fa-1377-44e6-8c32-88fd5f44c84c)
]
interface IDXGIDevice : IDXGIObject
{
HRESULT GetAdapter(
[out] IDXGIAdapter **adapter
);
HRESULT CreateSurface(
[in] const DXGI_SURFACE_DESC *desc,
[in] UINT surface_count,
[in] DXGI_USAGE usage,
[in] const DXGI_SHARED_RESOURCE *shared_resource,
[out] IDXGISurface **surface
);
HRESULT QueryResourceResidency(
[in] IUnknown *const *resources,
[out] DXGI_RESIDENCY *residency,
[in] UINT resource_count
);
HRESULT SetGPUThreadPriority(
[in] INT priority
);
HRESULT GetGPUThreadPriority(
[out] INT *priority
);
}