winapi_ui_automation/shared/
dxgi.rs

1// Licensed under the Apache License, Version 2.0
2// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
3// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
4// All files in the project carrying such notice may not be copied, modified, or distributed
5// except according to those terms.
6//! Mappings for the contents of dxgi.h
7use ctypes::c_void;
8use shared::basetsd::{SIZE_T, UINT64};
9use shared::dxgiformat::DXGI_FORMAT;
10use shared::dxgitype::{
11    DXGI_GAMMA_CONTROL, DXGI_GAMMA_CONTROL_CAPABILITIES, DXGI_MODE_DESC, DXGI_MODE_ROTATION,
12    DXGI_SAMPLE_DESC, DXGI_USAGE,
13};
14use shared::guiddef::{REFGUID, REFIID};
15use shared::minwindef::{BOOL, BYTE, DWORD, FLOAT, HMODULE, UINT};
16use shared::windef::{HDC, HMONITOR, HWND, RECT};
17use um::unknwnbase::{IUnknown, IUnknownVtbl};
18use um::winnt::{HANDLE, HRESULT, INT, LARGE_INTEGER, LUID, WCHAR};
19STRUCT!{struct DXGI_FRAME_STATISTICS {
20    PresentCount: UINT,
21    PresentRefreshCount: UINT,
22    SyncRefreshCount: UINT,
23    SyncQPCTime: LARGE_INTEGER,
24    SyncGPUTime: LARGE_INTEGER,
25}}
26STRUCT!{struct DXGI_MAPPED_RECT {
27    Pitch: INT,
28    pBits: *mut BYTE,
29}}
30STRUCT!{struct DXGI_ADAPTER_DESC {
31    Description: [WCHAR; 128],
32    VendorId: UINT,
33    DeviceId: UINT,
34    SubSysId: UINT,
35    Revision: UINT,
36    DedicatedVideoMemory: SIZE_T,
37    DedicatedSystemMemory: SIZE_T,
38    SharedSystemMemory: SIZE_T,
39    AdapterLuid: LUID,
40}}
41STRUCT!{struct DXGI_OUTPUT_DESC {
42    DeviceName: [WCHAR; 32],
43    DesktopCoordinates: RECT,
44    AttachedToDesktop: BOOL,
45    Rotation: DXGI_MODE_ROTATION,
46    Monitor: HMONITOR,
47}}
48STRUCT!{struct DXGI_SHARED_RESOURCE {
49    Handle: HANDLE,
50}}
51pub const DXGI_RESOURCE_PRIORITY_MINIMUM: DWORD = 0x28000000;
52pub const DXGI_RESOURCE_PRIORITY_LOW: DWORD = 0x50000000;
53pub const DXGI_RESOURCE_PRIORITY_NORMAL: DWORD = 0x78000000;
54pub const DXGI_RESOURCE_PRIORITY_HIGH: DWORD = 0xa0000000;
55pub const DXGI_RESOURCE_PRIORITY_MAXIMUM: DWORD = 0xc8000000;
56ENUM!{enum DXGI_RESIDENCY {
57    DXGI_RESIDENCY_FULLY_RESIDENT = 1,
58    DXGI_RESIDENCY_RESIDENT_IN_SHARED_MEMORY = 2,
59    DXGI_RESIDENCY_EVICTED_TO_DISK = 3,
60}}
61STRUCT!{struct DXGI_SURFACE_DESC {
62    Width: UINT,
63    Height: UINT,
64    Format: DXGI_FORMAT,
65    SampleDesc: DXGI_SAMPLE_DESC,
66}}
67ENUM!{enum DXGI_SWAP_EFFECT {
68    DXGI_SWAP_EFFECT_DISCARD = 0,
69    DXGI_SWAP_EFFECT_SEQUENTIAL = 1,
70    DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL = 3,
71    DXGI_SWAP_EFFECT_FLIP_DISCARD = 4,
72}}
73ENUM!{enum DXGI_SWAP_CHAIN_FLAG {
74    DXGI_SWAP_CHAIN_FLAG_NONPREROTATED = 1,
75    DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH = 2,
76    DXGI_SWAP_CHAIN_FLAG_GDI_COMPATIBLE = 4,
77    DXGI_SWAP_CHAIN_FLAG_RESTRICTED_CONTENT = 8,
78    DXGI_SWAP_CHAIN_FLAG_RESTRICT_SHARED_RESOURCE_DRIVER = 16,
79    DXGI_SWAP_CHAIN_FLAG_DISPLAY_ONLY = 32,
80    DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT = 64,
81    DXGI_SWAP_CHAIN_FLAG_FOREGROUND_LAYER = 128,
82    DXGI_SWAP_CHAIN_FLAG_FULLSCREEN_VIDEO = 256,
83    DXGI_SWAP_CHAIN_FLAG_YUV_VIDEO = 512,
84    DXGI_SWAP_CHAIN_FLAG_HW_PROTECTED = 1024,
85    DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING = 2048,
86}}
87STRUCT!{struct DXGI_SWAP_CHAIN_DESC {
88    BufferDesc: DXGI_MODE_DESC,
89    SampleDesc: DXGI_SAMPLE_DESC,
90    BufferUsage: DXGI_USAGE,
91    BufferCount: UINT,
92    OutputWindow: HWND,
93    Windowed: BOOL,
94    SwapEffect: DXGI_SWAP_EFFECT,
95    Flags: UINT,
96}}
97RIDL!{#[uuid(0xaec22fb8, 0x76f3, 0x4639, 0x9b, 0xe0, 0x28, 0xeb, 0x43, 0xa6, 0x7a, 0x2e)]
98interface IDXGIObject(IDXGIObjectVtbl): IUnknown(IUnknownVtbl) {
99    fn SetPrivateData(
100        Name: REFGUID,
101        DataSize: UINT,
102        pData: *const c_void,
103    ) -> HRESULT,
104    fn SetPrivateDataInterface(
105        Name: REFGUID,
106        pUnknown: *const IUnknown,
107    ) -> HRESULT,
108    fn GetPrivateData(
109        Name: REFGUID,
110        pDataSize: *mut UINT,
111        pData: *mut c_void,
112    ) -> HRESULT,
113    fn GetParent(
114        riid: REFIID,
115        ppParent: *mut *mut c_void,
116    ) -> HRESULT,
117}}
118RIDL!{#[uuid(0x3d3e0379, 0xf9de, 0x4d58, 0xbb, 0x6c, 0x18, 0xd6, 0x29, 0x92, 0xf1, 0xa6)]
119interface IDXGIDeviceSubObject(IDXGIDeviceSubObjectVtbl): IDXGIObject(IDXGIObjectVtbl) {
120    fn GetDevice(
121        riid: REFIID,
122        ppDevice: *mut *mut c_void,
123    ) -> HRESULT,
124}}
125RIDL!{#[uuid(0x035f3ab4, 0x482e, 0x4e50, 0xb4, 0x1f, 0x8a, 0x7f, 0x8b, 0xd8, 0x96, 0x0b)]
126interface IDXGIResource(IDXGIResourceVtbl): IDXGIDeviceSubObject(IDXGIDeviceSubObjectVtbl) {
127    fn GetSharedHandle(
128        pSharedHandle: *mut HANDLE,
129    ) -> HRESULT,
130    fn GetUsage(
131        pUsage: *mut DXGI_USAGE,
132    ) -> HRESULT,
133    fn SetEvictionPriority(
134        EvictionPriority: UINT,
135    ) -> HRESULT,
136    fn GetEvictionPriority(
137        pEvictionPriority: *mut UINT,
138    ) -> HRESULT,
139}}
140RIDL!{#[uuid(0x9d8e1289, 0xd7b3, 0x465f, 0x81, 0x26, 0x25, 0x0e, 0x34, 0x9a, 0xf8, 0x5d)]
141interface IDXGIKeyedMutex(IDXGIKeyedMutexVtbl): IDXGIDeviceSubObject(IDXGIDeviceSubObjectVtbl) {
142    fn AcquireSync(
143        Key: UINT64,
144        dwMilliseconds: DWORD,
145    ) -> HRESULT,
146    fn ReleaseSync(
147        Key: UINT64,
148    ) -> HRESULT,
149}}
150pub const DXGI_MAP_READ: UINT = 1;
151pub const DXGI_MAP_WRITE: UINT = 2;
152pub const DXGI_MAP_DISCARD: UINT = 4;
153RIDL!{#[uuid(0xcafcb56c, 0x6ac3, 0x4889, 0xbf, 0x47, 0x9e, 0x23, 0xbb, 0xd2, 0x60, 0xec)]
154interface IDXGISurface(IDXGISurfaceVtbl): IDXGIDeviceSubObject(IDXGIDeviceSubObjectVtbl) {
155    fn GetDesc(
156        pDesc: *mut DXGI_SURFACE_DESC,
157    ) -> HRESULT,
158    fn Map(
159        pLockedRect: *mut DXGI_MAPPED_RECT,
160        MapFlags: UINT,
161    ) -> HRESULT,
162    fn Unmap() -> HRESULT,
163}}
164RIDL!{#[uuid(0x4ae63092, 0x6327, 0x4c1b, 0x80, 0xae, 0xbf, 0xe1, 0x2e, 0xa3, 0x2b, 0x86)]
165interface IDXGISurface1(IDXGISurface1Vtbl): IDXGISurface(IDXGISurfaceVtbl) {
166    fn GetDC(
167        Discard: BOOL,
168        phdc: *mut HDC,
169    ) -> HRESULT,
170    fn ReleaseDC(
171        pDirtyRect: *mut RECT,
172    ) -> HRESULT,
173}}
174RIDL!{#[uuid(0x2411e7e1, 0x12ac, 0x4ccf, 0xbd, 0x14, 0x97, 0x98, 0xe8, 0x53, 0x4d, 0xc0)]
175interface IDXGIAdapter(IDXGIAdapterVtbl): IDXGIObject(IDXGIObjectVtbl) {
176    fn EnumOutputs(
177        Output: UINT,
178        ppOutput: *mut *mut IDXGIOutput,
179    ) -> HRESULT,
180    fn GetDesc(
181        pDesc: *mut DXGI_ADAPTER_DESC,
182    ) -> HRESULT,
183    fn CheckInterfaceSupport(
184        InterfaceName: REFGUID,
185        pUMDVersion: *mut LARGE_INTEGER,
186    ) -> HRESULT,
187}}
188RIDL!{#[uuid(0xae02eedb, 0xc735, 0x4690, 0x8d, 0x52, 0x5a, 0x8d, 0xc2, 0x02, 0x13, 0xaa)]
189interface IDXGIOutput(IDXGIOutputVtbl): IDXGIObject(IDXGIObjectVtbl) {
190    fn GetDesc(
191        pDesc: *mut DXGI_OUTPUT_DESC,
192    ) -> HRESULT,
193    fn GetDisplayModeList(
194        EnumFormat: DXGI_FORMAT,
195        Flags: UINT,
196        pNumModes: *mut UINT,
197        pDesc: *mut DXGI_MODE_DESC,
198    ) -> HRESULT,
199    fn FindClosestMatchingMode(
200        pModeToMatch: *const DXGI_MODE_DESC,
201        pClosestMatch: *mut DXGI_MODE_DESC,
202        pConcernedDevice: *mut IUnknown,
203    ) -> HRESULT,
204    fn WaitForVBlank() -> HRESULT,
205    fn TakeOwnership(
206        pDevice: *mut IUnknown,
207        Exclusive: BOOL,
208    ) -> HRESULT,
209    fn ReleaseOwnership() -> (),
210    fn GetGammaControlCapabilities(
211        pGammaCaps: *mut DXGI_GAMMA_CONTROL_CAPABILITIES,
212    ) -> HRESULT,
213    fn SetGammaControl(
214        pArray: *const DXGI_GAMMA_CONTROL,
215    ) -> HRESULT,
216    fn GetGammaControl(
217        pArray: *mut DXGI_GAMMA_CONTROL,
218    ) -> HRESULT,
219    fn SetDisplaySurface(
220        pScanoutSurface: *mut IDXGISurface,
221    ) -> HRESULT,
222    fn GetDisplaySurfaceData(
223        pDestination: *mut IDXGISurface,
224    ) -> HRESULT,
225    fn GetFrameStatistics(
226        pStats: *mut DXGI_FRAME_STATISTICS,
227    ) -> HRESULT,
228}}
229pub const DXGI_MAX_SWAP_CHAIN_BUFFERS: DWORD = 16;
230pub const DXGI_PRESENT_TEST: DWORD = 0x00000001;
231pub const DXGI_PRESENT_DO_NOT_SEQUENCE: DWORD = 0x00000002;
232pub const DXGI_PRESENT_RESTART: DWORD = 0x00000004;
233pub const DXGI_PRESENT_DO_NOT_WAIT: DWORD = 0x00000008;
234pub const DXGI_PRESENT_STEREO_PREFER_RIGHT: DWORD = 0x00000010;
235pub const DXGI_PRESENT_STEREO_TEMPORARY_MONO: DWORD = 0x00000020;
236pub const DXGI_PRESENT_RESTRICT_TO_OUTPUT: DWORD = 0x00000040;
237pub const DXGI_PRESENT_USE_DURATION: DWORD = 0x00000100;
238pub const DXGI_PRESENT_ALLOW_TEARING: DWORD = 0x00000200;
239pub const DXGI_ENUM_MODES_INTERLACED: UINT = 1;
240pub const DXGI_ENUM_MODES_SCALING: UINT = 2;
241RIDL!{#[uuid(0x310d36a0, 0xd2e7, 0x4c0a, 0xaa, 0x04, 0x6a, 0x9d, 0x23, 0xb8, 0x88, 0x6a)]
242interface IDXGISwapChain(IDXGISwapChainVtbl): IDXGIDeviceSubObject(IDXGIDeviceSubObjectVtbl) {
243    fn Present(
244        SyncInterval: UINT,
245        Flags: UINT,
246    ) -> HRESULT,
247    fn GetBuffer(
248        Buffer: UINT,
249        riid: REFIID,
250        ppSurface: *mut *mut c_void,
251    ) -> HRESULT,
252    fn SetFullscreenState(
253        Fullscreen: BOOL,
254        pTarget: *mut IDXGIOutput,
255    ) -> HRESULT,
256    fn GetFullscreenState(
257        pFullscreen: *mut BOOL,
258        ppTarget: *mut *mut IDXGIOutput,
259    ) -> HRESULT,
260    fn GetDesc(
261        pDesc: *mut DXGI_SWAP_CHAIN_DESC,
262    ) -> HRESULT,
263    fn ResizeBuffers(
264        BufferCount: UINT,
265        Width: UINT,
266        Height: UINT,
267        NewFormat: DXGI_FORMAT,
268        SwapChainFlags: UINT,
269    ) -> HRESULT,
270    fn ResizeTarget(
271        pNewTargetParameters: *const DXGI_MODE_DESC,
272    ) -> HRESULT,
273    fn GetContainingOutput(
274        ppOutput: *mut *mut IDXGIOutput,
275    ) -> HRESULT,
276    fn GetFrameStatistics(
277        pStats: *mut DXGI_FRAME_STATISTICS,
278    ) -> HRESULT,
279    fn GetLastPresentCount(
280        pLastPresentCount: *mut UINT,
281    ) -> HRESULT,
282}}
283RIDL!{#[uuid(0x7b7166ec, 0x21c7, 0x44ae, 0xb2, 0x1a, 0xc9, 0xae, 0x32, 0x1a, 0xe3, 0x69)]
284interface IDXGIFactory(IDXGIFactoryVtbl): IDXGIObject(IDXGIObjectVtbl) {
285    fn EnumAdapters(
286        Adapter: UINT,
287        ppAdapter: *mut *mut IDXGIAdapter,
288    ) -> HRESULT,
289    fn MakeWindowAssociation(
290        WindowHandle: HWND,
291        Flags: UINT,
292    ) -> HRESULT,
293    fn GetWindowAssociation(
294        pWindowHandle: *mut HWND,
295    ) -> HRESULT,
296    fn CreateSwapChain(
297        pDevice: *mut IUnknown,
298        pDesc: *mut DXGI_SWAP_CHAIN_DESC,
299        ppSwapChain: *mut *mut IDXGISwapChain,
300    ) -> HRESULT,
301    fn CreateSoftwareAdapter(
302        Module: HMODULE,
303        ppAdapter: *mut *mut IDXGIAdapter,
304    ) -> HRESULT,
305}}
306extern "system" {
307    pub fn CreateDXGIFactory(
308        riid: REFIID,
309        ppFactory: *mut *mut c_void,
310    ) -> HRESULT;
311    pub fn CreateDXGIFactory1(
312        riid: REFIID,
313        ppFactory: *mut *mut c_void,
314    ) -> HRESULT;
315}
316RIDL!{#[uuid(0x54ec77fa, 0x1377, 0x44e6, 0x8c, 0x32, 0x88, 0xfd, 0x5f, 0x44, 0xc8, 0x4c)]
317interface IDXGIDevice(IDXGIDeviceVtbl): IDXGIObject(IDXGIObjectVtbl) {
318    fn GetAdapter(
319        pAdapter: *mut *mut IDXGIAdapter,
320    ) -> HRESULT,
321    fn CreateSurface(
322        pDesc: *const DXGI_SURFACE_DESC,
323        NumSurfaces: UINT,
324        Usage: DXGI_USAGE,
325        pSharedResource: *const DXGI_SHARED_RESOURCE,
326        ppSurface: *mut *mut IDXGISurface,
327    ) -> HRESULT,
328    fn QueryResourceResidency(
329        ppResources: *const *mut IUnknown,
330        pResidencyStatus: *mut DXGI_RESIDENCY,
331        NumResources: UINT,
332    ) -> HRESULT,
333    fn SetGPUThreadPriority(
334        Priority: INT,
335    ) -> HRESULT,
336    fn GetGPUThreadPriority(
337        pPriority: *mut INT,
338    ) -> HRESULT,
339}}
340ENUM!{enum DXGI_ADAPTER_FLAG {
341    DXGI_ADAPTER_FLAG_NONE,
342    DXGI_ADAPTER_FLAG_REMOTE,
343    DXGI_ADAPTER_FLAG_SOFTWARE,
344}}
345STRUCT!{struct DXGI_ADAPTER_DESC1 {
346    Description: [WCHAR; 128],
347    VendorId: UINT,
348    DeviceId: UINT,
349    SubSysId: UINT,
350    Revision: UINT,
351    DedicatedVideoMemory: SIZE_T,
352    DedicatedSystemMemory: SIZE_T,
353    SharedSystemMemory: SIZE_T,
354    AdapterLuid: LUID,
355    Flags: UINT,
356}}
357STRUCT!{struct DXGI_DISPLAY_COLOR_SPACE {
358    PrimaryCoordinates: [[FLOAT; 2]; 8],
359    WhitePoints: [[FLOAT; 2]; 16],
360}}
361RIDL!{#[uuid(0x770aae78, 0xf26f, 0x4dba, 0xa8, 0x29, 0x25, 0x3c, 0x83, 0xd1, 0xb3, 0x87)]
362interface IDXGIFactory1(IDXGIFactory1Vtbl): IDXGIFactory(IDXGIFactoryVtbl) {
363    fn EnumAdapters1(
364        Adapter: UINT,
365        ppAdapter: *mut *mut IDXGIAdapter1,
366    ) -> HRESULT,
367    fn IsCurrent() -> BOOL,
368}}
369RIDL!{#[uuid(0x29038f61, 0x3839, 0x4626, 0x91, 0xfd, 0x08, 0x68, 0x79, 0x01, 0x1a, 0x05)]
370interface IDXGIAdapter1(IDXGIAdapter1Vtbl): IDXGIAdapter(IDXGIAdapterVtbl) {
371    fn GetDesc1(
372        pDesc: *mut DXGI_ADAPTER_DESC1,
373    ) -> HRESULT,
374}}
375RIDL!{#[uuid(0x77db970f, 0x6276, 0x48ba, 0xba, 0x28, 0x07, 0x01, 0x43, 0xb4, 0x39, 0x2c)]
376interface IDXGIDevice1(IDXGIDevice1Vtbl): IDXGIDevice(IDXGIDeviceVtbl) {
377    fn SetMaximumFrameLatency(
378        MaxLatency: UINT,
379    ) -> HRESULT,
380    fn GetMaximumFrameLatency(
381        pMaxLatency: *mut UINT,
382    ) -> HRESULT,
383}}
384DEFINE_GUID!{IID_IDXGIObject,
385    0xaec22fb8, 0x76f3, 0x4639, 0x9b, 0xe0, 0x28, 0xeb, 0x43, 0xa6, 0x7a, 0x2e}
386DEFINE_GUID!{IID_IDXGIDeviceSubObject,
387    0x3d3e0379, 0xf9de, 0x4d58, 0xbb, 0x6c, 0x18, 0xd6, 0x29, 0x92, 0xf1, 0xa6}
388DEFINE_GUID!{IID_IDXGIResource,
389    0x035f3ab4, 0x482e, 0x4e50, 0xb4, 0x1f, 0x8a, 0x7f, 0x8b, 0xd8, 0x96, 0x0b}
390DEFINE_GUID!{IID_IDXGIKeyedMutex,
391    0x9d8e1289, 0xd7b3, 0x465f, 0x81, 0x26, 0x25, 0x0e, 0x34, 0x9a, 0xf8, 0x5d}
392DEFINE_GUID!{IID_IDXGISurface,
393    0xcafcb56c, 0x6ac3, 0x4889, 0xbf, 0x47, 0x9e, 0x23, 0xbb, 0xd2, 0x60, 0xec}
394DEFINE_GUID!{IID_IDXGISurface1,
395    0x4ae63092, 0x6327, 0x4c1b, 0x80, 0xae, 0xbf, 0xe1, 0x2e, 0xa3, 0x2b, 0x86}
396DEFINE_GUID!{IID_IDXGIAdapter,
397    0x2411e7e1, 0x12ac, 0x4ccf, 0xbd, 0x14, 0x97, 0x98, 0xe8, 0x53, 0x4d, 0xc0}
398DEFINE_GUID!{IID_IDXGIOutput,
399    0xae02eedb, 0xc735, 0x4690, 0x8d, 0x52, 0x5a, 0x8d, 0xc2, 0x02, 0x13, 0xaa}
400DEFINE_GUID!{IID_IDXGISwapChain,
401    0x310d36a0, 0xd2e7, 0x4c0a, 0xaa, 0x04, 0x6a, 0x9d, 0x23, 0xb8, 0x88, 0x6a}
402DEFINE_GUID!{IID_IDXGIFactory,
403    0x7b7166ec, 0x21c7, 0x44ae, 0xb2, 0x1a, 0xc9, 0xae, 0x32, 0x1a, 0xe3, 0x69}
404DEFINE_GUID!{IID_IDXGIDevice,
405    0x54ec77fa, 0x1377, 0x44e6, 0x8c, 0x32, 0x88, 0xfd, 0x5f, 0x44, 0xc8, 0x4c}
406DEFINE_GUID!{IID_IDXGIFactory1,
407    0x770aae78, 0xf26f, 0x4dba, 0xa8, 0x29, 0x25, 0x3c, 0x83, 0xd1, 0xb3, 0x87}
408DEFINE_GUID!{IID_IDXGIAdapter1,
409    0x29038f61, 0x3839, 0x4626, 0x91, 0xfd, 0x08, 0x68, 0x79, 0x01, 0x1a, 0x05}
410DEFINE_GUID!{IID_IDXGIDevice1,
411    0x77db970f, 0x6276, 0x48ba, 0xba, 0x28, 0x07, 0x01, 0x43, 0xb4, 0x39, 0x2c}