1 module directx.dxgi;
2 
3 public import directx.com;
4 public import directx.dxgitype;
5 
6 enum DXGI_CPU_ACCESS_NONE              = ( 0 );
7 enum DXGI_CPU_ACCESS_DYNAMIC           = ( 1 );
8 enum DXGI_CPU_ACCESS_READ_WRITE        = ( 2 );
9 enum DXGI_CPU_ACCESS_SCRATCH           = ( 3 );
10 enum DXGI_CPU_ACCESS_FIELD             = 15;
11 enum DXGI_USAGE_SHADER_INPUT           = ( 1L << (0 + 4) );
12 enum DXGI_USAGE_RENDER_TARGET_OUTPUT   = ( 1L << (1 + 4) );
13 enum DXGI_USAGE_BACK_BUFFER            = ( 1L << (2 + 4) );
14 enum DXGI_USAGE_SHARED                 = ( 1L << (3 + 4) );
15 enum DXGI_USAGE_READ_ONLY              = ( 1L << (4 + 4) );
16 enum DXGI_USAGE_DISCARD_ON_PRESENT     = ( 1L << (5 + 4) );
17 enum DXGI_USAGE_UNORDERED_ACCESS       = ( 1L << (6 + 4) );
18 alias UINT DXGI_USAGE;
19 
20 struct DXGI_FRAME_STATISTICS
21 {
22 	UINT PresentCount;
23 	UINT PresentRefreshCount;
24 	UINT SyncRefreshCount;
25 	LARGE_INTEGER SyncQPCTime;
26 	LARGE_INTEGER SyncGPUTime;
27 }
28 
29 struct DXGI_MAPPED_RECT
30 {
31 	INT Pitch;
32 	BYTE *pBits;
33 }
34 
35 struct DXGI_ADAPTER_DESC
36 {
37 	WCHAR[ 128 ] Description;
38 	UINT VendorId;
39 	UINT DeviceId;
40 	UINT SubSysId;
41 	UINT Revision;
42 	SIZE_T DedicatedVideoMemory;
43 	SIZE_T DedicatedSystemMemory;
44 	SIZE_T SharedSystemMemory;
45 	LUID AdapterLuid;
46 }
47 
48 alias HANDLE HMONITOR;
49 
50 struct DXGI_OUTPUT_DESC
51 {
52 	WCHAR[32] DeviceName;
53 	RECT DesktopCoordinates;
54 	BOOL AttachedToDesktop;
55 	DXGI_MODE_ROTATION Rotation;
56 	HMONITOR Monitor;
57 }
58 
59 struct DXGI_SHARED_RESOURCE
60 {
61 	HANDLE Handle;
62 }
63 
64 enum DXGI_RESOURCE_PRIORITY_MINIMUM = ( 0x28000000 );
65 enum DXGI_RESOURCE_PRIORITY_LOW     = ( 0x50000000 );
66 enum DXGI_RESOURCE_PRIORITY_NORMAL  = ( 0x78000000 );
67 enum DXGI_RESOURCE_PRIORITY_HIGH    = ( 0xa0000000 );
68 enum DXGI_RESOURCE_PRIORITY_MAXIMUM = ( 0xc8000000 );
69 
70 alias DXGI_RESIDENCY = int;
71 enum : DXGI_RESIDENCY
72 {
73 	DXGI_RESIDENCY_FULLY_RESIDENT                = 1,
74 	DXGI_RESIDENCY_RESIDENT_IN_SHARED_MEMORY     = 2,
75 	DXGI_RESIDENCY_EVICTED_TO_DISK               = 3
76 }
77 
78 struct DXGI_SURFACE_DESC
79 {
80 	UINT Width;
81 	UINT Height;
82 	DXGI_FORMAT Format;
83 	DXGI_SAMPLE_DESC SampleDesc;
84 }
85 
86 alias DXGI_SWAP_EFFECT = int;
87 enum : DXGI_SWAP_EFFECT
88 {
89 	DXGI_SWAP_EFFECT_DISCARD         = 0,
90 	DXGI_SWAP_EFFECT_SEQUENTIAL      = 1,
91     DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL = 3,
92     DXGI_SWAP_EFFECT_FLIP_DISCARD    = 4
93 }
94 
95 alias DXGI_SWAP_CHAIN_FLAG = int;
96 enum : DXGI_SWAP_CHAIN_FLAG
97 {
98 	DXGI_SWAP_CHAIN_FLAG_NONPREROTATED      = 1,
99 	DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH  = 2,
100 	DXGI_SWAP_CHAIN_FLAG_GDI_COMPATIBLE     = 4
101 }
102 
103 struct DXGI_SWAP_CHAIN_DESC
104 {
105 	DXGI_MODE_DESC BufferDesc;
106 	DXGI_SAMPLE_DESC SampleDesc;
107 	DXGI_USAGE BufferUsage;
108 	UINT BufferCount;
109 	HWND OutputWindow;
110 	BOOL Windowed;
111 	DXGI_SWAP_EFFECT SwapEffect;
112 	UINT Flags;
113 }
114 
115 mixin( uuid!(IDXGIObject, "aec22fb8-76f3-4639-9be0-28eb43a67a2e") );
116 extern (C++) interface IDXGIObject : IUnknown
117 {
118 	HRESULT SetPrivateData( 
119 				REFGUID Name,
120 				UINT DataSize,
121 				const void* pData);
122 
123 	HRESULT SetPrivateDataInterface( 
124 				REFGUID Name,
125 				const(IUnknown) pUnknown);
126 
127 	HRESULT GetPrivateData(
128 				REFGUID Name,
129 				UINT* pDataSize,
130 				void* pData);
131 
132 	HRESULT GetParent( 
133 				REFIID riid,
134 				void** ppParent);
135 }
136 
137 mixin( uuid!(IDXGIDeviceSubObject, "3d3e0379-f9de-4d58-bb6c-18d62992f1a6") );
138 extern (C++) interface IDXGIDeviceSubObject : IDXGIObject
139 {
140     HRESULT GetDevice( 
141 				REFIID riid,
142 				void** ppDevice);
143 }
144  
145 mixin( uuid!(IDXGIResource, "035f3ab4-482e-4e50-b41f-8a7f8bd8960b") );
146 extern (C++) interface IDXGIResource : IDXGIDeviceSubObject
147 {
148 	HRESULT GetSharedHandle( 
149 				HANDLE* pSharedHandle);
150 
151 	HRESULT GetUsage( 
152 				DXGI_USAGE* pUsage);
153 
154 	HRESULT SetEvictionPriority( 
155 				UINT EvictionPriority);
156 
157 	HRESULT GetEvictionPriority( 
158 				UINT* pEvictionPriority);
159 }
160 
161 mixin( uuid!(IDXGIKeyedMutex, "9d8e1289-d7b3-465f-8126-250e349af85d") );
162 extern (C++) interface IDXGIKeyedMutex : IDXGIDeviceSubObject
163 {
164 	HRESULT AcquireSync( 
165 				UINT64 Key,
166 				DWORD dwMilliseconds);
167 
168 	HRESULT ReleaseSync( 
169 				UINT64 Key);
170 }
171 
172 enum DXGI_MAP_READ    = ( 1UL );
173 enum DXGI_MAP_WRITE   = ( 2UL );
174 enum DXGI_MAP_DISCARD = ( 4UL );
175 
176 mixin( uuid!(IDXGISurface, "cafcb56c-6ac3-4889-bf47-9e23bbd260ec") );
177 extern (C++) interface IDXGISurface : IDXGIDeviceSubObject
178 {
179 	HRESULT GetDesc( 
180 				DXGI_SURFACE_DESC* pDesc);
181 
182 	HRESULT Map( 
183 				DXGI_MAPPED_RECT* pLockedRect,
184 				UINT MapFlags);
185 
186 	HRESULT Unmap();
187 }
188  
189 mixin( uuid!(IDXGISurface1, "4AE63092-6327-4c1b-80AE-BFE12EA32B86") );
190 extern (C++) interface IDXGISurface1 : IDXGISurface
191 {
192 	HRESULT GetDC( 
193 				BOOL Discard,
194 				HDC* phdc);
195 
196 	HRESULT ReleaseDC( 
197 				RECT* pDirtyRect);
198 }
199 
200 mixin( uuid!(IDXGIAdapter, "2411e7e1-12ac-4ccf-bd14-9798e8534dc0") );
201 extern (C++) interface IDXGIAdapter : IDXGIObject
202 {
203 	HRESULT EnumOutputs( 
204 				UINT Output,
205 				IDXGIOutput* ppOutput);
206 
207 	HRESULT GetDesc( 
208 				DXGI_ADAPTER_DESC* pDesc);
209 
210 	HRESULT CheckInterfaceSupport( 
211 				REFGUID InterfaceName,
212 				LARGE_INTEGER* pUMDVersion);
213 }
214 
215 mixin( uuid!(IDXGIOutput, "ae02eedb-c735-4690-8d52-5a8dc20213aa") );
216 extern (C++) interface IDXGIOutput : IDXGIObject
217 {
218 	HRESULT GetDesc( 
219 				DXGI_OUTPUT_DESC* pDesc);
220 
221 	HRESULT GetDisplayModeList( 
222 				DXGI_FORMAT EnumFormat,
223 				UINT Flags,
224 				UINT* pNumModes,
225 				DXGI_MODE_DESC* pDesc);
226 
227 	HRESULT FindClosestMatchingMode( 
228 				const (DXGI_MODE_DESC)* pModeToMatch,
229 				DXGI_MODE_DESC* pClosestMatch,
230 				IUnknown pConcernedDevice);
231 
232 	HRESULT WaitForVBlank();
233 
234 	HRESULT TakeOwnership( 
235 				IUnknown pDevice,
236 				BOOL Exclusive);
237 
238 	void ReleaseOwnership();
239 
240 	HRESULT GetGammaControlCapabilities( 
241 				DXGI_GAMMA_CONTROL_CAPABILITIES* pGammaCaps);
242 
243 	HRESULT SetGammaControl( 
244 				const(DXGI_GAMMA_CONTROL)* pArray);
245 
246 	HRESULT GetGammaControl( 
247 				DXGI_GAMMA_CONTROL* pArray);
248 
249 	HRESULT SetDisplaySurface( 
250 				IDXGISurface pScanoutSurface);
251 
252 	HRESULT  GetDisplaySurfaceData( 
253 				IDXGISurface pDestination);
254 
255 	HRESULT  GetFrameStatistics( 
256 				DXGI_FRAME_STATISTICS* pStats);
257 }
258 
259 enum DXGI_MAX_SWAP_CHAIN_BUFFERS          = ( 16 );
260 enum DXGI_PRESENT_TEST                    = 0x00000001UL;
261 enum DXGI_PRESENT_DO_NOT_SEQUENCE         = 0x00000002UL;
262 enum DXGI_PRESENT_RESTART                 = 0x00000004UL;
263 enum DXGI_PRESENT_DO_NOT_WAIT             = 0x00000008UL;
264 enum DXGI_PRESENT_STEREO_PREFER_RIGHT     = 0x00000010UL;
265 enum DXGI_PRESENT_STEREO_TEMPORARY_MONO   = 0x00000020UL;
266 enum DXGI_PRESENT_RESTRICT_TO_OUTPUT      = 0x00000040UL;
267 enum DXGI_PRESENT_USE_DURATION            = 0x00000100UL;
268 
269 mixin( uuid!(IDXGISwapChain, "310d36a0-d2e7-4c0a-aa04-6a9d23b8886a") );
270 extern (C++) interface IDXGISwapChain : IDXGIDeviceSubObject
271 {
272 	HRESULT Present( 
273 				UINT SyncInterval,
274 				UINT Flags);
275 
276 	HRESULT GetBuffer( 
277 				UINT Buffer,
278 				REFIID riid,
279 				void **ppSurface);
280 
281 	HRESULT SetFullscreenState( 
282 				BOOL Fullscreen,
283 				IDXGIOutput pTarget);
284 
285 	HRESULT GetFullscreenState( 
286 				BOOL* pFullscreen,
287 				IDXGIOutput* ppTarget);
288 
289 	HRESULT GetDesc( 
290 				DXGI_SWAP_CHAIN_DESC* pDesc);
291 
292 	HRESULT ResizeBuffers( 
293 				UINT BufferCount,
294 				UINT Width,
295 				UINT Height,
296 				DXGI_FORMAT NewFormat,
297 				UINT SwapChainFlags);
298 
299 	HRESULT ResizeTarget( 
300 				const(DXGI_MODE_DESC)* pNewTargetParameters);
301 
302 	HRESULT GetContainingOutput( 
303 				IDXGIOutput* ppOutput);
304 
305 	HRESULT GetFrameStatistics( 
306 				DXGI_FRAME_STATISTICS* pStats);
307 
308 	HRESULT GetLastPresentCount( 
309 				UINT* pLastPresentCount);
310 }
311     
312 enum DXGI_MWA_NO_WINDOW_CHANGES      = ( 1 << 0 );
313 enum DXGI_MWA_NO_ALT_ENTER           = ( 1 << 1 );
314 enum DXGI_MWA_NO_PRINT_SCREEN        = ( 1 << 2 );
315 enum DXGI_MWA_VALID                  = ( 0x7 );
316 
317 mixin( uuid!(IDXGIFactory, "7b7166ec-21c7-44ae-b21a-c9ae321ae369") );
318 extern (C++) interface IDXGIFactory : IDXGIObject
319 {
320 	HRESULT EnumAdapters( 
321 				UINT Adapter,
322 				IDXGIAdapter* ppAdapter);
323 
324 	HRESULT MakeWindowAssociation( 
325 				HWND WindowHandle,
326 				UINT Flags);
327 
328 	HRESULT GetWindowAssociation( 
329 				HWND *pWindowHandle);
330 
331 	HRESULT CreateSwapChain( 
332 				IUnknown pDevice,
333 				DXGI_SWAP_CHAIN_DESC* pDesc,
334 				IDXGISwapChain* ppSwapChain);
335 
336 	HRESULT CreateSoftwareAdapter( 
337 				HMODULE Module, 
338 				IDXGIAdapter* ppAdapter);
339 }
340 
341 
342 extern(Windows) nothrow 
343 HRESULT CreateDXGIFactory(REFIID riid, IDXGIFactory* ppFactory);
344 
345 extern(Windows) nothrow 
346 HRESULT CreateDXGIFactory1(REFIID riid, void** ppFactory);
347 
348 
349 alias _CreateDXGIFactory = extern(Windows) nothrow HRESULT function(REFIID riid,
350                                                 void** ppFactory);
351 
352 alias _CreateDXGIFactory1 = extern(Windows) nothrow HRESULT function(REFIID riid,
353                                                  void** ppFactory);
354 
355 
356 mixin( uuid!(IDXGIDevice, "54ec77fa-1377-44e6-8c32-88fd5f44c84c") );
357 extern (C++) interface IDXGIDevice : IDXGIObject
358 {
359 	HRESULT GetAdapter( 
360 				IDXGIAdapter* pAdapter);
361 
362 	HRESULT CreateSurface( 
363 				const(DXGI_SURFACE_DESC)* pDesc,
364 				UINT NumSurfaces,
365 				DXGI_USAGE Usage,
366 				const(DXGI_SHARED_RESOURCE)* pSharedResource,
367 				IDXGISurface* ppSurface);
368 
369 	HRESULT QueryResourceResidency( 
370 				const(IUnknown)* ppResources,
371 				DXGI_RESIDENCY* pResidencyStatus,
372 				UINT NumResources);
373 
374 	HRESULT SetGPUThreadPriority( 
375 				INT Priority);
376 
377 	HRESULT GetGPUThreadPriority( 
378 				INT* pPriority);
379 }
380 
381 alias DXGI_ADAPTER_FLAG = int;
382 enum : DXGI_ADAPTER_FLAG
383 {
384 	DXGI_ADAPTER_FLAG_NONE          = 0,
385 	DXGI_ADAPTER_FLAG_REMOTE        = 1,
386 	DXGI_ADAPTER_FLAG_SOFTWARE      = 2,
387 	DXGI_ADAPTER_FLAG_FORCE_DWORD   = 0xffffffff
388 }
389 
390 struct DXGI_ADAPTER_DESC1
391 {
392 	WCHAR[128] Description;
393 	UINT VendorId;
394 	UINT DeviceId;
395 	UINT SubSysId;
396 	UINT Revision;
397 	SIZE_T DedicatedVideoMemory;
398 	SIZE_T DedicatedSystemMemory;
399 	SIZE_T SharedSystemMemory;
400 	LUID AdapterLuid;
401 	UINT Flags;
402 }
403 
404 struct DXGI_DISPLAY_COLOR_SPACE
405 {
406 	FLOAT[8 ][2] PrimaryCoordinates;
407 	FLOAT[16][2] WhitePoints;
408 }
409 
410 mixin( uuid!(IDXGIFactory1, "770aae78-f26f-4dba-a829-253c83d1b387") );
411 extern (C++) interface IDXGIFactory1 : IDXGIFactory
412 {
413 	HRESULT EnumAdapters1( 
414 				UINT Adapter,
415 				IDXGIAdapter1* ppAdapter);
416 
417 	BOOL IsCurrent();
418 }
419    
420 mixin( uuid!(IDXGIAdapter1, "29038f61-3839-4626-91fd-086879011a05") );
421 extern (C++) interface IDXGIAdapter1 : IDXGIAdapter
422 {
423 	HRESULT GetDesc1( 
424 				DXGI_ADAPTER_DESC1* pDesc);
425 }
426 
427 mixin( uuid!(IDXGIDevice1, "77db970f-6276-48ba-ba28-070143b4392c") );
428 extern (C++) interface IDXGIDevice1 : IDXGIDevice
429 {
430 	HRESULT SetMaximumFrameLatency( 
431 				UINT MaxLatency);
432 
433     HRESULT GetMaximumFrameLatency( 
434 				UINT *pMaxLatency);
435 }