blob: 51c66da34bffae4a3494e90548bf3c9f1a2a2011 [file] [log] [blame]
José Fonsecaaf7d2312011-07-07 10:16:57 +01001##########################################################################
2#
3# Copyright 2011 Jose Fonseca
4# All Rights Reserved.
5#
6# Permission is hereby granted, free of charge, to any person obtaining a copy
7# of this software and associated documentation files (the "Software"), to deal
8# in the Software without restriction, including without limitation the rights
9# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10# copies of the Software, and to permit persons to whom the Software is
11# furnished to do so, subject to the following conditions:
12#
13# The above copyright notice and this permission notice shall be included in
14# all copies or substantial portions of the Software.
15#
16# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22# THE SOFTWARE.
23#
24##########################################################################/
25
José Fonsecaca55d162012-04-16 13:05:47 +010026
José Fonsecaaf7d2312011-07-07 10:16:57 +010027from dxgitype import *
28
José Fonsecaca55d162012-04-16 13:05:47 +010029
30IDXGIObject = Interface("IDXGIObject", IUnknown)
31IDXGIDeviceSubObject = Interface("IDXGIDeviceSubObject", IDXGIObject)
32IDXGIResource = Interface("IDXGIResource", IDXGIDeviceSubObject)
33IDXGIKeyedMutex = Interface("IDXGIKeyedMutex", IDXGIDeviceSubObject)
34IDXGISurface = Interface("IDXGISurface", IDXGIDeviceSubObject)
35IDXGISurface1 = Interface("IDXGISurface1", IDXGISurface)
36IDXGIAdapter = Interface("IDXGIAdapter", IDXGIObject)
37IDXGIOutput = Interface("IDXGIOutput", IDXGIObject)
38IDXGISwapChain = Interface("IDXGISwapChain", IDXGIDeviceSubObject)
39IDXGIFactory = Interface("IDXGIFactory", IDXGIObject)
40IDXGIDevice = Interface("IDXGIDevice", IDXGIObject)
41IDXGIFactory1 = Interface("IDXGIFactory1", IDXGIFactory)
42IDXGIAdapter1 = Interface("IDXGIAdapter1", IDXGIAdapter)
43IDXGIDevice1 = Interface("IDXGIDevice1", IDXGIDevice)
44
45
46DXGI_USAGE = Flags(UINT, [
José Fonseca467a42a2012-05-04 11:49:19 +010047 "DXGI_CPU_ACCESS_NONE", # 0
48 "DXGI_CPU_ACCESS_SCRATCH", # 3
49 "DXGI_CPU_ACCESS_DYNAMIC", # 1
50 "DXGI_CPU_ACCESS_READ_WRITE", # 2
José Fonsecaca55d162012-04-16 13:05:47 +010051 "DXGI_USAGE_SHADER_INPUT",
52 "DXGI_USAGE_RENDER_TARGET_OUTPUT",
53 "DXGI_USAGE_BACK_BUFFER",
54 "DXGI_USAGE_SHARED",
55 "DXGI_USAGE_READ_ONLY",
56 "DXGI_USAGE_DISCARD_ON_PRESENT",
57 "DXGI_USAGE_UNORDERED_ACCESS",
José Fonsecaaf7d2312011-07-07 10:16:57 +010058])
59
José Fonsecaca55d162012-04-16 13:05:47 +010060DXGI_FRAME_STATISTICS = Struct("DXGI_FRAME_STATISTICS", [
61 (UINT, "PresentCount"),
62 (UINT, "PresentRefreshCount"),
63 (UINT, "SyncRefreshCount"),
64 (LARGE_INTEGER, "SyncQPCTime"),
65 (LARGE_INTEGER, "SyncGPUTime"),
66])
67
68DXGI_MAPPED_RECT = Struct("DXGI_MAPPED_RECT", [
69 (INT, "Pitch"),
José Fonsecafc047bb2013-05-29 19:28:03 +010070 (LinearPointer(BYTE, "_MappedSize"), "pBits"),
José Fonsecaca55d162012-04-16 13:05:47 +010071])
72
73DXGI_ADAPTER_DESC = Struct("DXGI_ADAPTER_DESC", [
74 (WString, "Description"),
75 (UINT, "VendorId"),
76 (UINT, "DeviceId"),
77 (UINT, "SubSysId"),
78 (UINT, "Revision"),
79 (SIZE_T, "DedicatedVideoMemory"),
80 (SIZE_T, "DedicatedSystemMemory"),
81 (SIZE_T, "SharedSystemMemory"),
82 (LUID, "AdapterLuid"),
83])
84
85DXGI_OUTPUT_DESC = Struct("DXGI_OUTPUT_DESC", [
86 (WString, "DeviceName"),
87 (RECT, "DesktopCoordinates"),
88 (BOOL, "AttachedToDesktop"),
89 (DXGI_MODE_ROTATION, "Rotation"),
90 (HMONITOR, "Monitor"),
91])
92
93DXGI_SHARED_RESOURCE = Struct("DXGI_SHARED_RESOURCE", [
94 (HANDLE, "Handle"),
95])
96
97DXGI_RESOURCE_PRIORITY = FakeEnum(UINT, [
98 "DXGI_RESOURCE_PRIORITY_MINIMUM",
99 "DXGI_RESOURCE_PRIORITY_LOW",
100 "DXGI_RESOURCE_PRIORITY_NORMAL",
101 "DXGI_RESOURCE_PRIORITY_HIGH",
102 "DXGI_RESOURCE_PRIORITY_MAXIMUM",
José Fonsecaaf7d2312011-07-07 10:16:57 +0100103])
104
105DXGI_RESIDENCY = Enum("DXGI_RESIDENCY", [
106 "DXGI_RESIDENCY_FULLY_RESIDENT",
107 "DXGI_RESIDENCY_RESIDENT_IN_SHARED_MEMORY",
108 "DXGI_RESIDENCY_EVICTED_TO_DISK",
109])
110
111DXGI_SURFACE_DESC = Struct("DXGI_SURFACE_DESC", [
112 (UINT, "Width"),
113 (UINT, "Height"),
114 (DXGI_FORMAT, "Format"),
115 (DXGI_SAMPLE_DESC, "SampleDesc"),
116])
117
José Fonsecaca55d162012-04-16 13:05:47 +0100118DXGI_SWAP_EFFECT = Enum("DXGI_SWAP_EFFECT", [
119 "DXGI_SWAP_EFFECT_DISCARD",
120 "DXGI_SWAP_EFFECT_SEQUENTIAL",
José Fonsecaaf7d2312011-07-07 10:16:57 +0100121])
122
José Fonsecaca55d162012-04-16 13:05:47 +0100123DXGI_SWAP_CHAIN_FLAG = Flags(UINT, [
José Fonsecaaf7d2312011-07-07 10:16:57 +0100124 "DXGI_SWAP_CHAIN_FLAG_NONPREROTATED",
125 "DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH",
126 "DXGI_SWAP_CHAIN_FLAG_GDI_COMPATIBLE",
127])
128
129DXGI_SWAP_CHAIN_DESC = Struct("DXGI_SWAP_CHAIN_DESC", [
130 (DXGI_MODE_DESC, "BufferDesc"),
131 (DXGI_SAMPLE_DESC, "SampleDesc"),
132 (DXGI_USAGE, "BufferUsage"),
133 (UINT, "BufferCount"),
134 (HWND, "OutputWindow"),
135 (BOOL, "Windowed"),
136 (DXGI_SWAP_EFFECT, "SwapEffect"),
José Fonsecaca55d162012-04-16 13:05:47 +0100137 (DXGI_SWAP_CHAIN_FLAG, "Flags"),
138])
139
Jeff Muizelaar4d57f312013-11-19 15:18:31 -0500140
José Fonsecaca55d162012-04-16 13:05:47 +0100141IDXGIObject.methods += [
José Fonseca45fff9c2012-05-08 09:07:27 +0100142 StdMethod(HRESULT, "SetPrivateData", [(REFGUID, "Name"), (UINT, "DataSize"), (OpaqueBlob(Const(Void), "DataSize"), "pData")], sideeffects=False),
143 StdMethod(HRESULT, "SetPrivateDataInterface", [(REFGUID, "Name"), (OpaquePointer(Const(IUnknown)), "pUnknown")], sideeffects=False),
144 StdMethod(HRESULT, "GetPrivateData", [(REFGUID, "Name"), Out(Pointer(UINT), "pDataSize"), Out(OpaquePointer(Void), "pData")], sideeffects=False),
José Fonsecaca55d162012-04-16 13:05:47 +0100145 StdMethod(HRESULT, "GetParent", [(REFIID, "riid"), Out(Pointer(ObjPointer(Void)), "ppParent")]),
146]
147
148IDXGIDeviceSubObject.methods += [
149 StdMethod(HRESULT, "GetDevice", [(REFIID, "riid"), Out(Pointer(ObjPointer(Void)), "ppDevice")]),
150]
151
152IDXGIResource.methods += [
153 StdMethod(HRESULT, "GetSharedHandle", [Out(Pointer(HANDLE), "pSharedHandle")]),
José Fonseca45fff9c2012-05-08 09:07:27 +0100154 StdMethod(HRESULT, "GetUsage", [Out(Pointer(DXGI_USAGE), "pUsage")], sideeffects=False),
José Fonsecaca55d162012-04-16 13:05:47 +0100155 StdMethod(HRESULT, "SetEvictionPriority", [(DXGI_RESOURCE_PRIORITY, "EvictionPriority")]),
José Fonseca45fff9c2012-05-08 09:07:27 +0100156 StdMethod(HRESULT, "GetEvictionPriority", [Out(Pointer(DXGI_RESOURCE_PRIORITY), "pEvictionPriority")], sideeffects=False),
José Fonsecaca55d162012-04-16 13:05:47 +0100157]
158
159IDXGIKeyedMutex.methods += [
160 StdMethod(HRESULT, "AcquireSync", [(UINT64, "Key"), (DWORD, "dwMilliseconds")]),
161 StdMethod(HRESULT, "ReleaseSync", [(UINT64, "Key")]),
162]
163
164DXGI_MAP = Flags(UINT, [
165 "DXGI_MAP_READ",
166 "DXGI_MAP_WRITE",
167 "DXGI_MAP_DISCARD",
168])
169
170IDXGISurface.methods += [
José Fonseca3f174372012-05-08 12:09:42 +0100171 StdMethod(HRESULT, "GetDesc", [Out(Pointer(DXGI_SURFACE_DESC), "pDesc")], sideeffects=False),
José Fonsecaca55d162012-04-16 13:05:47 +0100172 StdMethod(HRESULT, "Map", [Out(Pointer(DXGI_MAPPED_RECT), "pLockedRect"), (DXGI_MAP, "MapFlags")]),
173 StdMethod(HRESULT, "Unmap", []),
174]
175
176IDXGISurface1.methods += [
177 StdMethod(HRESULT, "GetDC", [(BOOL, "Discard"), Out(Pointer(HDC), "phdc")]),
178 StdMethod(HRESULT, "ReleaseDC", [(Pointer(RECT), "pDirtyRect")]),
179]
180
181IDXGIAdapter.methods += [
182 StdMethod(HRESULT, "EnumOutputs", [(UINT, "Output"), Out(Pointer(ObjPointer(IDXGIOutput)), "ppOutput")]),
José Fonseca45fff9c2012-05-08 09:07:27 +0100183 StdMethod(HRESULT, "GetDesc", [Out(Pointer(DXGI_ADAPTER_DESC), "pDesc")], sideeffects=False),
184 StdMethod(HRESULT, "CheckInterfaceSupport", [(REFGUID, "InterfaceName"), Out(Pointer(LARGE_INTEGER), "pUMDVersion")], sideeffects=False),
José Fonsecaca55d162012-04-16 13:05:47 +0100185]
186
187DXGI_ENUM_MODES = Flags(UINT, [
188 "DXGI_ENUM_MODES_INTERLACED",
189 "DXGI_ENUM_MODES_SCALING",
José Fonsecafd9d01d2014-09-03 22:08:30 +0100190 "DXGI_ENUM_MODES_STEREO",
191 "DXGI_ENUM_MODES_DISABLED_STEREO",
José Fonsecaca55d162012-04-16 13:05:47 +0100192])
193
194IDXGIOutput.methods += [
José Fonseca45fff9c2012-05-08 09:07:27 +0100195 StdMethod(HRESULT, "GetDesc", [Out(Pointer(DXGI_OUTPUT_DESC), "pDesc")], sideeffects=False),
196 StdMethod(HRESULT, "GetDisplayModeList", [(DXGI_FORMAT, "EnumFormat"), (DXGI_ENUM_MODES, "Flags"), Out(Pointer(UINT), "pNumModes"), Out(Array(DXGI_MODE_DESC, "*pNumModes"), "pDesc")], sideeffects=False),
José Fonsecaca55d162012-04-16 13:05:47 +0100197 StdMethod(HRESULT, "FindClosestMatchingMode", [(Pointer(Const(DXGI_MODE_DESC)), "pModeToMatch"), Out(Pointer(DXGI_MODE_DESC), "pClosestMatch"), (ObjPointer(IUnknown), "pConcernedDevice")]),
198 StdMethod(HRESULT, "WaitForVBlank", []),
199 StdMethod(HRESULT, "TakeOwnership", [(ObjPointer(IUnknown), "pDevice"), (BOOL, "Exclusive")]),
200 StdMethod(Void, "ReleaseOwnership", []),
José Fonseca28829ec2014-08-19 20:41:41 +0100201 StdMethod(HRESULT, "GetGammaControlCapabilities", [Out(Pointer(DXGI_GAMMA_CONTROL_CAPABILITIES), "pGammaCaps")], sideeffects=False),
José Fonsecaca55d162012-04-16 13:05:47 +0100202 StdMethod(HRESULT, "SetGammaControl", [(Pointer(Const(DXGI_GAMMA_CONTROL)), "pArray")]),
José Fonseca45fff9c2012-05-08 09:07:27 +0100203 StdMethod(HRESULT, "GetGammaControl", [Out(Pointer(DXGI_GAMMA_CONTROL), "pArray")], sideeffects=False),
José Fonsecaca55d162012-04-16 13:05:47 +0100204 StdMethod(HRESULT, "SetDisplaySurface", [(ObjPointer(IDXGISurface), "pScanoutSurface")]),
205 StdMethod(HRESULT, "GetDisplaySurfaceData", [(ObjPointer(IDXGISurface), "pDestination")]),
José Fonseca45fff9c2012-05-08 09:07:27 +0100206 StdMethod(HRESULT, "GetFrameStatistics", [Out(Pointer(DXGI_FRAME_STATISTICS), "pStats")], sideeffects=False),
José Fonsecaca55d162012-04-16 13:05:47 +0100207]
208
209DXGI_PRESENT = Flags(UINT, [
210 "DXGI_PRESENT_TEST",
211 "DXGI_PRESENT_DO_NOT_SEQUENCE",
212 "DXGI_PRESENT_RESTART",
José Fonsecafd9d01d2014-09-03 22:08:30 +0100213 "DXGI_PRESENT_DO_NOT_WAIT",
214 "DXGI_PRESENT_STEREO_PREFER_RIGHT",
215 "DXGI_PRESENT_STEREO_TEMPORARY_MONO",
216 "DXGI_PRESENT_RESTRICT_TO_OUTPUT",
217 "DXGI_PRESENT_USE_DURATION",
José Fonsecaca55d162012-04-16 13:05:47 +0100218])
219
220IDXGISwapChain.methods += [
221 StdMethod(HRESULT, "Present", [(UINT, "SyncInterval"), (DXGI_PRESENT, "Flags")]),
222 StdMethod(HRESULT, "GetBuffer", [(UINT, "Buffer"), (REFIID, "riid"), Out(Pointer(ObjPointer(Void)), "ppSurface")]),
223 StdMethod(HRESULT, "SetFullscreenState", [(BOOL, "Fullscreen"), (ObjPointer(IDXGIOutput), "pTarget")]),
224 StdMethod(HRESULT, "GetFullscreenState", [Out(Pointer(BOOL), "pFullscreen"), Out(Pointer(ObjPointer(IDXGIOutput)), "ppTarget")]),
José Fonseca45fff9c2012-05-08 09:07:27 +0100225 StdMethod(HRESULT, "GetDesc", [Out(Pointer(DXGI_SWAP_CHAIN_DESC), "pDesc")], sideeffects=False),
José Fonsecaf450d8b2012-11-20 14:48:31 +0000226 StdMethod(HRESULT, "ResizeBuffers", [(UINT, "BufferCount"), (UINT, "Width"), (UINT, "Height"), (DXGI_FORMAT, "NewFormat"), (DXGI_SWAP_CHAIN_FLAG, "SwapChainFlags")]),
José Fonsecaca55d162012-04-16 13:05:47 +0100227 StdMethod(HRESULT, "ResizeTarget", [(Pointer(Const(DXGI_MODE_DESC)), "pNewTargetParameters")]),
228 StdMethod(HRESULT, "GetContainingOutput", [Out(Pointer(ObjPointer(IDXGIOutput)), "ppOutput")]),
José Fonseca45fff9c2012-05-08 09:07:27 +0100229 StdMethod(HRESULT, "GetFrameStatistics", [Out(Pointer(DXGI_FRAME_STATISTICS), "pStats")], sideeffects=False),
230 StdMethod(HRESULT, "GetLastPresentCount", [Out(Pointer(UINT), "pLastPresentCount")], sideeffects=False),
José Fonsecaca55d162012-04-16 13:05:47 +0100231]
232
233DXGI_MWA = Flags(UINT, [
234 "DXGI_MWA_NO_WINDOW_CHANGES",
235 "DXGI_MWA_NO_ALT_ENTER",
236 "DXGI_MWA_NO_PRINT_SCREEN",
237 "DXGI_MWA_VALID",
238])
239
240IDXGIFactory.methods += [
241 StdMethod(HRESULT, "EnumAdapters", [(UINT, "Adapter"), Out(Pointer(ObjPointer(IDXGIAdapter)), "ppAdapter")]),
242 StdMethod(HRESULT, "MakeWindowAssociation", [(HWND, "WindowHandle"), (DXGI_MWA, "Flags")]),
José Fonseca45fff9c2012-05-08 09:07:27 +0100243 StdMethod(HRESULT, "GetWindowAssociation", [Out(Pointer(HWND), "pWindowHandle")], sideeffects=False),
José Fonsecaca55d162012-04-16 13:05:47 +0100244 StdMethod(HRESULT, "CreateSwapChain", [(ObjPointer(IUnknown), "pDevice"), (Pointer(DXGI_SWAP_CHAIN_DESC), "pDesc"), Out(Pointer(ObjPointer(IDXGISwapChain)), "ppSwapChain")]),
245 StdMethod(HRESULT, "CreateSoftwareAdapter", [(HMODULE, "Module"), Out(Pointer(ObjPointer(IDXGIAdapter)), "ppAdapter")]),
246]
247
248IDXGIDevice.methods += [
249 StdMethod(HRESULT, "GetAdapter", [Out(Pointer(ObjPointer(IDXGIAdapter)), "pAdapter")]),
250 StdMethod(HRESULT, "CreateSurface", [(Pointer(Const(DXGI_SURFACE_DESC)), "pDesc"), (UINT, "NumSurfaces"), (DXGI_USAGE, "Usage"), (Pointer(Const(DXGI_SHARED_RESOURCE)), "pSharedResource"), Out(Pointer(ObjPointer(IDXGISurface)), "ppSurface")]),
José Fonseca45fff9c2012-05-08 09:07:27 +0100251 StdMethod(HRESULT, "QueryResourceResidency", [(Array(Const(ObjPointer(IUnknown)), "NumResources"), "ppResources"), Out(Array(DXGI_RESIDENCY, "NumResources"), "pResidencyStatus"), (UINT, "NumResources")], sideeffects=False),
José Fonsecaca55d162012-04-16 13:05:47 +0100252 StdMethod(HRESULT, "SetGPUThreadPriority", [(INT, "Priority")]),
José Fonseca45fff9c2012-05-08 09:07:27 +0100253 StdMethod(HRESULT, "GetGPUThreadPriority", [Out(Pointer(INT), "pPriority")], sideeffects=False),
José Fonsecaca55d162012-04-16 13:05:47 +0100254]
255
José Fonsecafd9d01d2014-09-03 22:08:30 +0100256DXGI_ADAPTER_FLAG = FakeEnum(UINT, [
José Fonsecaca55d162012-04-16 13:05:47 +0100257 "DXGI_ADAPTER_FLAG_NONE",
258 "DXGI_ADAPTER_FLAG_REMOTE",
José Fonsecafd9d01d2014-09-03 22:08:30 +0100259 "DXGI_ADAPTER_FLAG_SOFTWARE",
José Fonsecaca55d162012-04-16 13:05:47 +0100260])
261
262DXGI_ADAPTER_DESC1 = Struct("DXGI_ADAPTER_DESC1", [
263 (WString, "Description"),
264 (UINT, "VendorId"),
265 (UINT, "DeviceId"),
266 (UINT, "SubSysId"),
267 (UINT, "Revision"),
268 (SIZE_T, "DedicatedVideoMemory"),
269 (SIZE_T, "DedicatedSystemMemory"),
270 (SIZE_T, "SharedSystemMemory"),
271 (LUID, "AdapterLuid"),
José Fonsecafd9d01d2014-09-03 22:08:30 +0100272 (DXGI_SWAP_CHAIN_FLAG, "Flags"),
José Fonsecaaf7d2312011-07-07 10:16:57 +0100273])
274
José Fonsecaca55d162012-04-16 13:05:47 +0100275DXGI_DISPLAY_COLOR_SPACE = Struct("DXGI_DISPLAY_COLOR_SPACE", [
276 (Array(Array(FLOAT, 8), 2), "PrimaryCoordinates"),
277 (Array(Array(FLOAT, 16), 2), "WhitePoints"),
José Fonsecaaf7d2312011-07-07 10:16:57 +0100278])
279
José Fonsecaca55d162012-04-16 13:05:47 +0100280IDXGIFactory1.methods += [
281 StdMethod(HRESULT, "EnumAdapters1", [(UINT, "Adapter"), Out(Pointer(ObjPointer(IDXGIAdapter1)), "ppAdapter")]),
282 StdMethod(BOOL, "IsCurrent", []),
José Fonsecaaf7d2312011-07-07 10:16:57 +0100283]
284
José Fonsecaca55d162012-04-16 13:05:47 +0100285IDXGIAdapter1.methods += [
José Fonseca45fff9c2012-05-08 09:07:27 +0100286 StdMethod(HRESULT, "GetDesc1", [Out(Pointer(DXGI_ADAPTER_DESC1), "pDesc")], sideeffects=False),
José Fonsecaaf7d2312011-07-07 10:16:57 +0100287]
288
José Fonsecaca55d162012-04-16 13:05:47 +0100289IDXGIDevice1.methods += [
290 StdMethod(HRESULT, "SetMaximumFrameLatency", [(UINT, "MaxLatency")]),
José Fonseca45fff9c2012-05-08 09:07:27 +0100291 StdMethod(HRESULT, "GetMaximumFrameLatency", [Out(Pointer(UINT), "pMaxLatency")], sideeffects=False),
José Fonsecaaf7d2312011-07-07 10:16:57 +0100292]
293
José Fonsecaf450d8b2012-11-20 14:48:31 +0000294
295IDXGIFactoryDWM = Interface("IDXGIFactoryDWM", IUnknown)
296IDXGISwapChainDWM = Interface("IDXGISwapChainDWM", IDXGIDeviceSubObject)
297
298IDXGIFactoryDWM.methods += [
299 StdMethod(HRESULT, "CreateSwapChain", [(ObjPointer(IUnknown), "pDevice"), (Pointer(DXGI_SWAP_CHAIN_DESC), "pDesc"), (ObjPointer(IDXGIOutput), "pOutput"), Out(Pointer(ObjPointer(IDXGISwapChainDWM)), "ppSwapChain")]),
300]
301
José Fonsecab2f773d2014-02-28 14:46:23 +0000302# http://shchetinin.blogspot.co.uk/2012/04/dwm-graphics-directx-win8win7.html
José Fonsecaf450d8b2012-11-20 14:48:31 +0000303IDXGISwapChainDWM.methods += [
304 StdMethod(HRESULT, "Present", [(UINT, "SyncInterval"), (DXGI_PRESENT, "Flags")]),
305 StdMethod(HRESULT, "GetBuffer", [(UINT, "Buffer"), (REFIID, "riid"), Out(Pointer(ObjPointer(Void)), "ppSurface")]),
306 StdMethod(HRESULT, "GetDesc", [Out(Pointer(DXGI_SWAP_CHAIN_DESC), "pDesc")], sideeffects=False),
307 StdMethod(HRESULT, "ResizeBuffers", [(UINT, "BufferCount"), (UINT, "Width"), (UINT, "Height"), (DXGI_FORMAT, "NewFormat"), (DXGI_SWAP_CHAIN_FLAG, "SwapChainFlags")]),
308 StdMethod(HRESULT, "ResizeTarget", [(Pointer(Const(DXGI_MODE_DESC)), "pNewTargetParameters")]),
309 StdMethod(HRESULT, "GetContainingOutput", [Out(Pointer(ObjPointer(IDXGIOutput)), "ppOutput")]),
José Fonsecab2f773d2014-02-28 14:46:23 +0000310 StdMethod(HRESULT, "GetFrameStatistics", [Out(Pointer(DXGI_FRAME_STATISTICS), "pStats")], sideeffects=False),
311 StdMethod(HRESULT, "GetLastPresentCount", [Out(Pointer(UINT), "pLastPresentCount")], sideeffects=False),
José Fonsecaf450d8b2012-11-20 14:48:31 +0000312 StdMethod(HRESULT, "SetFullscreenState", [(BOOL, "Fullscreen"), (ObjPointer(IDXGIOutput), "pTarget")]),
313 StdMethod(HRESULT, "GetFullscreenState", [Out(Pointer(BOOL), "pFullscreen"), Out(Pointer(ObjPointer(IDXGIOutput)), "ppTarget")]),
314]
315
José Fonsecafd9d01d2014-09-03 22:08:30 +0100316
317dxgi = Module('dxgi')
318dxgi.addInterfaces([
319 IDXGIKeyedMutex,
320 IDXGIFactory1,
321 IDXGIFactoryDWM,
322 IDXGIDevice1,
323 IDXGIAdapter1,
324 IDXGIResource,
325])
326dxgi.addFunctions([
327 StdFunction(HRESULT, "CreateDXGIFactory", [(REFIID, "riid"), Out(Pointer(ObjPointer(Void)), "ppFactory")]),
328 StdFunction(HRESULT, "CreateDXGIFactory1", [(REFIID, "riid"), Out(Pointer(ObjPointer(Void)), "ppFactory")]),
329])
330
331
332
333#
334# DXGI 1.2
335#
336
337IDXGIDisplayControl = Interface("IDXGIDisplayControl", IUnknown)
338IDXGIDisplayControl.methods += [
339 StdMethod(BOOL, "IsStereoEnabled", [], sideeffects=False),
340 StdMethod(Void, "SetStereoEnabled", [(BOOL, "enabled")]),
Jeff Muizelaar4d57f312013-11-19 15:18:31 -0500341]
342
José Fonsecafd9d01d2014-09-03 22:08:30 +0100343DXGI_OUTDUPL_MOVE_RECT = Struct("DXGI_OUTDUPL_MOVE_RECT", [
344 (POINT, "SourcePoint"),
345 (RECT, "DestinationRect"),
346])
347
348DXGI_OUTDUPL_DESC = Struct("DXGI_OUTDUPL_DESC", [
349 (DXGI_MODE_DESC, "ModeDesc"),
350 (DXGI_MODE_ROTATION, "Rotation"),
351 (BOOL, "DesktopImageInSystemMemory"),
352])
353
354DXGI_OUTDUPL_POINTER_POSITION = Struct("DXGI_OUTDUPL_POINTER_POSITION", [
355 (POINT, "Position"),
356 (BOOL, "Visible"),
357])
358
359DXGI_OUTDUPL_POINTER_SHAPE_TYPE = Enum("DXGI_OUTDUPL_POINTER_SHAPE_TYPE", [
360 "DXGI_OUTDUPL_POINTER_SHAPE_TYPE_MONOCHROME",
361 "DXGI_OUTDUPL_POINTER_SHAPE_TYPE_COLOR",
362 "DXGI_OUTDUPL_POINTER_SHAPE_TYPE_MASKED_COLOR",
363])
364
365DXGI_OUTDUPL_POINTER_SHAPE_INFO = Struct("DXGI_OUTDUPL_POINTER_SHAPE_INFO", [
366 (UINT, "Type"),
367 (UINT, "Width"),
368 (UINT, "Height"),
369 (UINT, "Pitch"),
370 (POINT, "HotSpot"),
371])
372
373DXGI_OUTDUPL_FRAME_INFO = Struct("DXGI_OUTDUPL_FRAME_INFO", [
374 (LARGE_INTEGER, "LastPresentTime"),
375 (LARGE_INTEGER, "LastMouseUpdateTime"),
376 (UINT, "AccumulatedFrames"),
377 (BOOL, "RectsCoalesced"),
378 (BOOL, "ProtectedContentMaskedOut"),
379 (DXGI_OUTDUPL_POINTER_POSITION, "PointerPosition"),
380 (UINT, "TotalMetadataBufferSize"),
381 (UINT, "PointerShapeBufferSize"),
382])
383
384IDXGIOutputDuplication = Interface("IDXGIOutputDuplication", IDXGIObject)
385IDXGIOutputDuplication.methods += [
386 StdMethod(Void, "GetDesc", [Out(Pointer(DXGI_OUTDUPL_DESC), "pDesc")], sideeffects=False),
387 StdMethod(HRESULT, "AcquireNextFrame", [(UINT, "TimeoutInMilliseconds"), Out(Pointer(DXGI_OUTDUPL_FRAME_INFO), "pFrameInfo"), Out(Pointer(ObjPointer(IDXGIResource)), "ppDesktopResource")]),
388 StdMethod(HRESULT, "GetFrameDirtyRects", [(UINT, "DirtyRectsBufferSize"), Out(Array(RECT, "DirtyRectsBufferSize"), "pDirtyRectsBuffer"), Out(Pointer(UINT), "pDirtyRectsBufferSizeRequired")], sideeffects=False),
389 StdMethod(HRESULT, "GetFrameMoveRects", [(UINT, "MoveRectsBufferSize"), Out(Array(DXGI_OUTDUPL_MOVE_RECT, "MoveRectsBufferSize"), "pMoveRectBuffer"), Out(Pointer(UINT), "pMoveRectsBufferSizeRequired")], sideeffects=False),
390 StdMethod(HRESULT, "GetFramePointerShape", [(UINT, "PointerShapeBufferSize"), Out(OpaqueBlob(Void, "PointerShapeBufferSize"), "pPointerShapeBuffer"), Out(Pointer(UINT), "pPointerShapeBufferSizeRequired"), Out(Pointer(DXGI_OUTDUPL_POINTER_SHAPE_INFO), "pPointerShapeInfo")], sideeffects=False),
391 StdMethod(HRESULT, "MapDesktopSurface", [Out(Pointer(DXGI_MAPPED_RECT), "pLockedRect")], sideeffects=False),
392 StdMethod(HRESULT, "UnMapDesktopSurface", [], sideeffects=False),
393 StdMethod(HRESULT, "ReleaseFrame", []),
394]
395
396DXGI_ALPHA_MODE = Enum("DXGI_ALPHA_MODE", [
397 "DXGI_ALPHA_MODE_UNSPECIFIED",
398 "DXGI_ALPHA_MODE_PREMULTIPLIED",
399 "DXGI_ALPHA_MODE_STRAIGHT",
400 "DXGI_ALPHA_MODE_IGNORE",
401])
402
403IDXGISurface2 = Interface("IDXGISurface2", IDXGISurface1)
404IDXGISurface2.methods += [
405 StdMethod(HRESULT, "GetResource", [(REFIID, "riid"), Out(Pointer(ObjPointer(Void)), "ppParentResource"), Out(Pointer(UINT), "pSubresourceIndex")]),
406]
407
408DXGI_SHARED_RESOURCE_FLAG = Flags(DWORD, [
409 "DXGI_SHARED_RESOURCE_READ",
410 "DXGI_SHARED_RESOURCE_WRITE",
411])
412
413IDXGIResource1 = Interface("IDXGIResource1", IDXGIResource)
414IDXGIResource1.methods += [
415 StdMethod(HRESULT, "CreateSubresourceSurface", [(UINT, "index"), Out(Pointer(ObjPointer(IDXGISurface2)), "ppSurface")]),
416 StdMethod(HRESULT, "CreateSharedHandle", [(Pointer(Const(SECURITY_ATTRIBUTES)), "pAttributes"), (DXGI_SHARED_RESOURCE_FLAG, "dwAccess"), (LPCWSTR, "lpName"), Out(Pointer(HANDLE), "pHandle")]),
Jeff Muizelaar4d57f312013-11-19 15:18:31 -0500417]
418
419DXGI_OFFER_RESOURCE_PRIORITY = Enum("DXGI_OFFER_RESOURCE_PRIORITY", [
420 "DXGI_OFFER_RESOURCE_PRIORITY_LOW",
421 "DXGI_OFFER_RESOURCE_PRIORITY_NORMAL",
422 "DXGI_OFFER_RESOURCE_PRIORITY_HIGH",
423])
424
José Fonsecafd9d01d2014-09-03 22:08:30 +0100425IDXGIDevice2 = Interface("IDXGIDevice2", IDXGIDevice1)
Jeff Muizelaar4d57f312013-11-19 15:18:31 -0500426IDXGIDevice2.methods += [
427 StdMethod(HRESULT, "OfferResources", [(UINT, "NumResources"), (Array(Const(ObjPointer(IDXGIResource)), "NumResources"), "ppResources"), (DXGI_OFFER_RESOURCE_PRIORITY, "Priority")]),
428 StdMethod(HRESULT, "ReclaimResources", [(UINT, "NumResources"), (Array(Const(ObjPointer(IDXGIResource)), "NumResources"), "ppResources"), Out(Pointer(BOOL), "pDiscarded")]),
429 StdMethod(HRESULT, "EnqueueSetEvent", [(HANDLE, "hEvent")]),
430]
431
José Fonsecafd9d01d2014-09-03 22:08:30 +0100432DXGI_MODE_DESC1 = Struct("DXGI_MODE_DESC1", [
433 (UINT, "Width"),
434 (UINT, "Height"),
435 (DXGI_RATIONAL, "RefreshRate"),
436 (DXGI_FORMAT, "Format"),
437 (DXGI_MODE_SCANLINE_ORDER, "ScanlineOrdering"),
438 (DXGI_MODE_SCALING, "Scaling"),
439 (BOOL, "Stereo"),
440])
441
442DXGI_SCALING = Enum("DXGI_SCALING", [
443 "DXGI_SCALING_STRETCH",
444 "DXGI_SCALING_NONE",
445 "DXGI_SCALING_ASPECT_RATIO_STRETCH",
446])
447
448DXGI_SWAP_CHAIN_DESC1 = Struct("DXGI_SWAP_CHAIN_DESC1", [
449 (UINT, "Width"),
450 (UINT, "Height"),
451 (DXGI_FORMAT, "Format"),
452 (BOOL, "Stereo"),
453 (DXGI_SAMPLE_DESC, "SampleDesc"),
454 (DXGI_USAGE, "BufferUsage"),
455 (UINT, "BufferCount"),
456 (DXGI_SCALING, "Scaling"),
457 (DXGI_SWAP_EFFECT, "SwapEffect"),
458 (DXGI_ALPHA_MODE, "AlphaMode"),
459 (DXGI_SWAP_CHAIN_FLAG, "Flags"),
460])
461
462DXGI_SWAP_CHAIN_FULLSCREEN_DESC = Struct("DXGI_SWAP_CHAIN_FULLSCREEN_DESC", [
463 (DXGI_RATIONAL, "RefreshRate"),
464 (DXGI_MODE_SCANLINE_ORDER, "ScanlineOrdering"),
465 (DXGI_MODE_SCALING, "Scaling"),
466 (BOOL, "Windowed"),
467])
468
469DXGI_PRESENT_PARAMETERS = Struct("DXGI_PRESENT_PARAMETERS", [
470 (UINT, "DirtyRectsCount"),
471 (Array(RECT, "{self}.DirtyRectsCount"), "pDirtyRects"),
472 (Pointer(RECT), "pScrollRect"),
473 (Pointer(POINT), "pScrollOffset"),
474])
475
476IDXGISwapChain1 = Interface("IDXGISwapChain1", IDXGISwapChain)
477IDXGISwapChain1.methods += [
478 StdMethod(HRESULT, "GetDesc1", [(Out(Pointer(DXGI_SWAP_CHAIN_DESC1), "pDesc"))], sideeffects=False),
479 StdMethod(HRESULT, "GetFullscreenDesc", [(Out(Pointer(DXGI_SWAP_CHAIN_FULLSCREEN_DESC), "pDesc"))], sideeffects=False),
480 StdMethod(HRESULT, "GetHwnd", [(Out(Pointer(HWND), "pHwnd"))], sideeffects=False),
481 StdMethod(HRESULT, "GetCoreWindow", [(REFIID, "riid"), (Out(Pointer(ObjPointer(Void)), "ppUnk"))]),
482 StdMethod(HRESULT, "Present1", [(UINT, "SyncInterval"), (DXGI_PRESENT, "Flags"), (Pointer(Const(DXGI_PRESENT_PARAMETERS)), "pPresentParameters")]),
483 StdMethod(BOOL, "IsTemporaryMonoSupported", [], sideeffects=False),
484 StdMethod(HRESULT, "GetRestrictToOutput", [(Out(Pointer(ObjPointer(IDXGIOutput)), "ppRestrictToOutput"))]),
485 StdMethod(HRESULT, "SetBackgroundColor", [(Pointer(Const(DXGI_RGBA)), "pColor")]),
486 StdMethod(HRESULT, "GetBackgroundColor", [(Out(Pointer(DXGI_RGBA), "pColor"))], sideeffects=False),
487 StdMethod(HRESULT, "SetRotation", [(DXGI_MODE_ROTATION, "Rotation")]),
488 StdMethod(HRESULT, "GetRotation", [(Out(Pointer(DXGI_MODE_ROTATION), "pRotation"))], sideeffects=False),
489]
490
491IDXGIFactory2 = Interface("IDXGIFactory2", IDXGIFactory1)
492IDXGIFactory2.methods += [
493 StdMethod(BOOL, "IsWindowedStereoEnabled", [], sideeffects=False),
494 StdMethod(HRESULT, "CreateSwapChainForHwnd", [(ObjPointer(IUnknown), "pDevice"), (HWND, "WindowHandle"), (Pointer(Const(DXGI_SWAP_CHAIN_DESC1)), "pDesc"), (Pointer(Const(DXGI_SWAP_CHAIN_FULLSCREEN_DESC)), "pFullscreenDesc"), (ObjPointer(IDXGIOutput), "pRestrictToOutput"), Out(Pointer(ObjPointer(IDXGISwapChain1)), "ppSwapChain")]),
495 StdMethod(HRESULT, "CreateSwapChainForCoreWindow", [(ObjPointer(IUnknown), "pDevice"), (ObjPointer(IUnknown), "pWindow"), (Pointer(Const(DXGI_SWAP_CHAIN_DESC1)), "pDesc"), (ObjPointer(IDXGIOutput), "pRestrictToOutput"), Out(Pointer(ObjPointer(IDXGISwapChain1)), "ppSwapChain")]),
496 StdMethod(HRESULT, "GetSharedResourceAdapterLuid", [(HANDLE, "hResource"), Out(Pointer(LUID), "pLuid")], sideeffects=False),
497 StdMethod(HRESULT, "RegisterStereoStatusWindow", [(HWND, "WindowHandle"), (UINT, "wMsg"), Out(Pointer(DWORD), "pdwCookie")]),
498 StdMethod(HRESULT, "RegisterStereoStatusEvent", [(HANDLE, "hEvent"), Out(Pointer(DWORD), "pdwCookie")]),
499 StdMethod(Void, "UnregisterStereoStatus", [(DWORD, "dwCookie")]),
500 StdMethod(HRESULT, "RegisterOcclusionStatusWindow", [(HWND, "WindowHandle"), (UINT, "wMsg"), Out(Pointer(DWORD), "pdwCookie")]),
501 StdMethod(HRESULT, "RegisterOcclusionStatusEvent", [(HANDLE, "hEvent"), Out(Pointer(DWORD), "pdwCookie")]),
502 StdMethod(Void, "UnregisterOcclusionStatus", [(DWORD, "dwCookie")]),
503 StdMethod(HRESULT, "CreateSwapChainForComposition", [(ObjPointer(IUnknown), "pDevice"), (Pointer(Const(DXGI_SWAP_CHAIN_DESC1)), "pDesc"), (ObjPointer(IDXGIOutput), "pRestrictToOutput"), Out(Pointer(ObjPointer(IDXGISwapChain1)), "ppSwapChain")]),
504]
505
Jeff Muizelaar4d57f312013-11-19 15:18:31 -0500506DXGI_GRAPHICS_PREEMPTION_GRANULARITY = Enum("DXGI_GRAPHICS_PREEMPTION_GRANULARITY", [
507 "DXGI_GRAPHICS_PREEMPTION_DMA_BUFFER_BOUNDARY",
508 "DXGI_GRAPHICS_PREEMPTION_PRIMITIVE_BOUNDARY",
509 "DXGI_GRAPHICS_PREEMPTION_TRIANGLE_BOUNDARY",
510 "DXGI_GRAPHICS_PREEMPTION_PIXEL_BOUNDARY",
511 "DXGI_GRAPHICS_PREEMPTION_INSTRUCTION_BOUNDARY",
512])
513
514DXGI_COMPUTE_PREEMPTION_GRANULARITY = Enum("DXGI_COMPUTE_PREEMPTION_GRANULARITY", [
515 "DXGI_COMPUTE_PREEMPTION_DMA_BUFFER_BOUNDARY",
516 "DXGI_COMPUTE_PREEMPTION_DISPATCH_BOUNDARY",
517 "DXGI_COMPUTE_PREEMPTION_THREAD_GROUP_BOUNDARY",
518 "DXGI_COMPUTE_PREEMPTION_THREAD_BOUNDARY",
519 "DXGI_COMPUTE_PREEMPTION_INSTRUCTION_BOUNDARY",
520])
521
522DXGI_ADAPTER_DESC2 = Struct("DXGI_ADAPTER_DESC2", [
523 (WString, "Description"),
524 (UINT, "VendorId"),
525 (UINT, "DeviceId"),
526 (UINT, "SubSysId"),
527 (UINT, "Revision"),
528 (SIZE_T, "DedicatedVideoMemory"),
529 (SIZE_T, "DedicatedSystemMemory"),
530 (SIZE_T, "SharedSystemMemory"),
531 (LUID, "AdapterLuid"),
José Fonsecafd9d01d2014-09-03 22:08:30 +0100532 (DXGI_ADAPTER_FLAG, "Flags"),
Jeff Muizelaar4d57f312013-11-19 15:18:31 -0500533 (DXGI_GRAPHICS_PREEMPTION_GRANULARITY, "GraphicsPreemptionGranularity"),
534 (DXGI_COMPUTE_PREEMPTION_GRANULARITY, "ComputePreemptionGranularity"),
535])
536
José Fonsecafd9d01d2014-09-03 22:08:30 +0100537IDXGIAdapter2 = Interface("IDXGIAdapter2", IDXGIAdapter1)
Jeff Muizelaar4d57f312013-11-19 15:18:31 -0500538IDXGIAdapter2.methods += [
539 StdMethod(HRESULT, "GetDesc2", [Out(Pointer(DXGI_ADAPTER_DESC2), "pDesc")], sideeffects=False),
540]
José Fonsecaf450d8b2012-11-20 14:48:31 +0000541
José Fonsecafd9d01d2014-09-03 22:08:30 +0100542IDXGIOutput1 = Interface("IDXGIOutput1", IDXGIOutput)
543IDXGIOutput1.methods += [
544 StdMethod(HRESULT, "GetDisplayModeList1", [(DXGI_FORMAT, "EnumFormat"), (DXGI_ENUM_MODES, "Flags"), Out(Pointer(UINT), "pNumModes"), Out(Pointer(DXGI_MODE_DESC1), "pDesc")]),
545 StdMethod(HRESULT, "FindClosestMatchingMode1", [(Pointer(Const(DXGI_MODE_DESC1)), "pModeToMatch"), Out(Pointer(DXGI_MODE_DESC1), "pClosestMatch"), (ObjPointer(IUnknown), "pConcernedDevice")]),
546 StdMethod(HRESULT, "GetDisplaySurfaceData1", [(ObjPointer(IDXGIResource), "pDestination")]),
547 StdMethod(HRESULT, "DuplicateOutput", [(ObjPointer(IUnknown), "pDevice"), Out(Pointer(ObjPointer(IDXGIOutputDuplication)), "ppOutputDuplication")]),
José Fonseca2f439632014-08-27 14:15:44 +0100548]
549
José Fonsecacdefc482012-11-16 20:06:20 +0000550dxgi.addInterfaces([
José Fonseca818d9f02014-09-14 19:41:31 +0100551 IDXGIDisplayControl,
José Fonseca2f439632014-08-27 14:15:44 +0100552 IDXGIDevice2,
José Fonsecafd9d01d2014-09-03 22:08:30 +0100553 IDXGISwapChain1,
554 IDXGIFactory2,
José Fonseca2f439632014-08-27 14:15:44 +0100555 IDXGIResource1,
José Fonsecafd9d01d2014-09-03 22:08:30 +0100556 IDXGIAdapter2,
557 IDXGIOutput1,
José Fonsecaca55d162012-04-16 13:05:47 +0100558])