blob: 2361c26c26a6cab111398f073fd77dfe6f53c5da [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]
313
José Fonsecafd9d01d2014-09-03 22:08:30 +0100314
315dxgi = Module('dxgi')
316dxgi.addInterfaces([
317 IDXGIKeyedMutex,
318 IDXGIFactory1,
319 IDXGIFactoryDWM,
320 IDXGIDevice1,
321 IDXGIAdapter1,
322 IDXGIResource,
323])
324dxgi.addFunctions([
325 StdFunction(HRESULT, "CreateDXGIFactory", [(REFIID, "riid"), Out(Pointer(ObjPointer(Void)), "ppFactory")]),
326 StdFunction(HRESULT, "CreateDXGIFactory1", [(REFIID, "riid"), Out(Pointer(ObjPointer(Void)), "ppFactory")]),
327])
328
329
330
331#
332# DXGI 1.2
333#
334
335IDXGIDisplayControl = Interface("IDXGIDisplayControl", IUnknown)
336IDXGIDisplayControl.methods += [
337 StdMethod(BOOL, "IsStereoEnabled", [], sideeffects=False),
338 StdMethod(Void, "SetStereoEnabled", [(BOOL, "enabled")]),
Jeff Muizelaar4d57f312013-11-19 15:18:31 -0500339]
340
José Fonsecafd9d01d2014-09-03 22:08:30 +0100341DXGI_OUTDUPL_MOVE_RECT = Struct("DXGI_OUTDUPL_MOVE_RECT", [
342 (POINT, "SourcePoint"),
343 (RECT, "DestinationRect"),
344])
345
346DXGI_OUTDUPL_DESC = Struct("DXGI_OUTDUPL_DESC", [
347 (DXGI_MODE_DESC, "ModeDesc"),
348 (DXGI_MODE_ROTATION, "Rotation"),
349 (BOOL, "DesktopImageInSystemMemory"),
350])
351
352DXGI_OUTDUPL_POINTER_POSITION = Struct("DXGI_OUTDUPL_POINTER_POSITION", [
353 (POINT, "Position"),
354 (BOOL, "Visible"),
355])
356
357DXGI_OUTDUPL_POINTER_SHAPE_TYPE = Enum("DXGI_OUTDUPL_POINTER_SHAPE_TYPE", [
358 "DXGI_OUTDUPL_POINTER_SHAPE_TYPE_MONOCHROME",
359 "DXGI_OUTDUPL_POINTER_SHAPE_TYPE_COLOR",
360 "DXGI_OUTDUPL_POINTER_SHAPE_TYPE_MASKED_COLOR",
361])
362
363DXGI_OUTDUPL_POINTER_SHAPE_INFO = Struct("DXGI_OUTDUPL_POINTER_SHAPE_INFO", [
364 (UINT, "Type"),
365 (UINT, "Width"),
366 (UINT, "Height"),
367 (UINT, "Pitch"),
368 (POINT, "HotSpot"),
369])
370
371DXGI_OUTDUPL_FRAME_INFO = Struct("DXGI_OUTDUPL_FRAME_INFO", [
372 (LARGE_INTEGER, "LastPresentTime"),
373 (LARGE_INTEGER, "LastMouseUpdateTime"),
374 (UINT, "AccumulatedFrames"),
375 (BOOL, "RectsCoalesced"),
376 (BOOL, "ProtectedContentMaskedOut"),
377 (DXGI_OUTDUPL_POINTER_POSITION, "PointerPosition"),
378 (UINT, "TotalMetadataBufferSize"),
379 (UINT, "PointerShapeBufferSize"),
380])
381
382IDXGIOutputDuplication = Interface("IDXGIOutputDuplication", IDXGIObject)
383IDXGIOutputDuplication.methods += [
384 StdMethod(Void, "GetDesc", [Out(Pointer(DXGI_OUTDUPL_DESC), "pDesc")], sideeffects=False),
385 StdMethod(HRESULT, "AcquireNextFrame", [(UINT, "TimeoutInMilliseconds"), Out(Pointer(DXGI_OUTDUPL_FRAME_INFO), "pFrameInfo"), Out(Pointer(ObjPointer(IDXGIResource)), "ppDesktopResource")]),
386 StdMethod(HRESULT, "GetFrameDirtyRects", [(UINT, "DirtyRectsBufferSize"), Out(Array(RECT, "DirtyRectsBufferSize"), "pDirtyRectsBuffer"), Out(Pointer(UINT), "pDirtyRectsBufferSizeRequired")], sideeffects=False),
387 StdMethod(HRESULT, "GetFrameMoveRects", [(UINT, "MoveRectsBufferSize"), Out(Array(DXGI_OUTDUPL_MOVE_RECT, "MoveRectsBufferSize"), "pMoveRectBuffer"), Out(Pointer(UINT), "pMoveRectsBufferSizeRequired")], sideeffects=False),
388 StdMethod(HRESULT, "GetFramePointerShape", [(UINT, "PointerShapeBufferSize"), Out(OpaqueBlob(Void, "PointerShapeBufferSize"), "pPointerShapeBuffer"), Out(Pointer(UINT), "pPointerShapeBufferSizeRequired"), Out(Pointer(DXGI_OUTDUPL_POINTER_SHAPE_INFO), "pPointerShapeInfo")], sideeffects=False),
389 StdMethod(HRESULT, "MapDesktopSurface", [Out(Pointer(DXGI_MAPPED_RECT), "pLockedRect")], sideeffects=False),
390 StdMethod(HRESULT, "UnMapDesktopSurface", [], sideeffects=False),
391 StdMethod(HRESULT, "ReleaseFrame", []),
392]
393
394DXGI_ALPHA_MODE = Enum("DXGI_ALPHA_MODE", [
395 "DXGI_ALPHA_MODE_UNSPECIFIED",
396 "DXGI_ALPHA_MODE_PREMULTIPLIED",
397 "DXGI_ALPHA_MODE_STRAIGHT",
398 "DXGI_ALPHA_MODE_IGNORE",
399])
400
401IDXGISurface2 = Interface("IDXGISurface2", IDXGISurface1)
402IDXGISurface2.methods += [
403 StdMethod(HRESULT, "GetResource", [(REFIID, "riid"), Out(Pointer(ObjPointer(Void)), "ppParentResource"), Out(Pointer(UINT), "pSubresourceIndex")]),
404]
405
406DXGI_SHARED_RESOURCE_FLAG = Flags(DWORD, [
407 "DXGI_SHARED_RESOURCE_READ",
408 "DXGI_SHARED_RESOURCE_WRITE",
409])
410
411IDXGIResource1 = Interface("IDXGIResource1", IDXGIResource)
412IDXGIResource1.methods += [
413 StdMethod(HRESULT, "CreateSubresourceSurface", [(UINT, "index"), Out(Pointer(ObjPointer(IDXGISurface2)), "ppSurface")]),
414 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 -0500415]
416
417DXGI_OFFER_RESOURCE_PRIORITY = Enum("DXGI_OFFER_RESOURCE_PRIORITY", [
418 "DXGI_OFFER_RESOURCE_PRIORITY_LOW",
419 "DXGI_OFFER_RESOURCE_PRIORITY_NORMAL",
420 "DXGI_OFFER_RESOURCE_PRIORITY_HIGH",
421])
422
José Fonsecafd9d01d2014-09-03 22:08:30 +0100423IDXGIDevice2 = Interface("IDXGIDevice2", IDXGIDevice1)
Jeff Muizelaar4d57f312013-11-19 15:18:31 -0500424IDXGIDevice2.methods += [
425 StdMethod(HRESULT, "OfferResources", [(UINT, "NumResources"), (Array(Const(ObjPointer(IDXGIResource)), "NumResources"), "ppResources"), (DXGI_OFFER_RESOURCE_PRIORITY, "Priority")]),
426 StdMethod(HRESULT, "ReclaimResources", [(UINT, "NumResources"), (Array(Const(ObjPointer(IDXGIResource)), "NumResources"), "ppResources"), Out(Pointer(BOOL), "pDiscarded")]),
427 StdMethod(HRESULT, "EnqueueSetEvent", [(HANDLE, "hEvent")]),
428]
429
José Fonsecafd9d01d2014-09-03 22:08:30 +0100430DXGI_MODE_DESC1 = Struct("DXGI_MODE_DESC1", [
431 (UINT, "Width"),
432 (UINT, "Height"),
433 (DXGI_RATIONAL, "RefreshRate"),
434 (DXGI_FORMAT, "Format"),
435 (DXGI_MODE_SCANLINE_ORDER, "ScanlineOrdering"),
436 (DXGI_MODE_SCALING, "Scaling"),
437 (BOOL, "Stereo"),
438])
439
440DXGI_SCALING = Enum("DXGI_SCALING", [
441 "DXGI_SCALING_STRETCH",
442 "DXGI_SCALING_NONE",
443 "DXGI_SCALING_ASPECT_RATIO_STRETCH",
444])
445
446DXGI_SWAP_CHAIN_DESC1 = Struct("DXGI_SWAP_CHAIN_DESC1", [
447 (UINT, "Width"),
448 (UINT, "Height"),
449 (DXGI_FORMAT, "Format"),
450 (BOOL, "Stereo"),
451 (DXGI_SAMPLE_DESC, "SampleDesc"),
452 (DXGI_USAGE, "BufferUsage"),
453 (UINT, "BufferCount"),
454 (DXGI_SCALING, "Scaling"),
455 (DXGI_SWAP_EFFECT, "SwapEffect"),
456 (DXGI_ALPHA_MODE, "AlphaMode"),
457 (DXGI_SWAP_CHAIN_FLAG, "Flags"),
458])
459
460DXGI_SWAP_CHAIN_FULLSCREEN_DESC = Struct("DXGI_SWAP_CHAIN_FULLSCREEN_DESC", [
461 (DXGI_RATIONAL, "RefreshRate"),
462 (DXGI_MODE_SCANLINE_ORDER, "ScanlineOrdering"),
463 (DXGI_MODE_SCALING, "Scaling"),
464 (BOOL, "Windowed"),
465])
466
467DXGI_PRESENT_PARAMETERS = Struct("DXGI_PRESENT_PARAMETERS", [
468 (UINT, "DirtyRectsCount"),
469 (Array(RECT, "{self}.DirtyRectsCount"), "pDirtyRects"),
470 (Pointer(RECT), "pScrollRect"),
471 (Pointer(POINT), "pScrollOffset"),
472])
473
474IDXGISwapChain1 = Interface("IDXGISwapChain1", IDXGISwapChain)
475IDXGISwapChain1.methods += [
476 StdMethod(HRESULT, "GetDesc1", [(Out(Pointer(DXGI_SWAP_CHAIN_DESC1), "pDesc"))], sideeffects=False),
477 StdMethod(HRESULT, "GetFullscreenDesc", [(Out(Pointer(DXGI_SWAP_CHAIN_FULLSCREEN_DESC), "pDesc"))], sideeffects=False),
478 StdMethod(HRESULT, "GetHwnd", [(Out(Pointer(HWND), "pHwnd"))], sideeffects=False),
479 StdMethod(HRESULT, "GetCoreWindow", [(REFIID, "riid"), (Out(Pointer(ObjPointer(Void)), "ppUnk"))]),
480 StdMethod(HRESULT, "Present1", [(UINT, "SyncInterval"), (DXGI_PRESENT, "Flags"), (Pointer(Const(DXGI_PRESENT_PARAMETERS)), "pPresentParameters")]),
481 StdMethod(BOOL, "IsTemporaryMonoSupported", [], sideeffects=False),
482 StdMethod(HRESULT, "GetRestrictToOutput", [(Out(Pointer(ObjPointer(IDXGIOutput)), "ppRestrictToOutput"))]),
483 StdMethod(HRESULT, "SetBackgroundColor", [(Pointer(Const(DXGI_RGBA)), "pColor")]),
484 StdMethod(HRESULT, "GetBackgroundColor", [(Out(Pointer(DXGI_RGBA), "pColor"))], sideeffects=False),
485 StdMethod(HRESULT, "SetRotation", [(DXGI_MODE_ROTATION, "Rotation")]),
486 StdMethod(HRESULT, "GetRotation", [(Out(Pointer(DXGI_MODE_ROTATION), "pRotation"))], sideeffects=False),
487]
488
489IDXGIFactory2 = Interface("IDXGIFactory2", IDXGIFactory1)
490IDXGIFactory2.methods += [
491 StdMethod(BOOL, "IsWindowedStereoEnabled", [], sideeffects=False),
492 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")]),
493 StdMethod(HRESULT, "CreateSwapChainForCoreWindow", [(ObjPointer(IUnknown), "pDevice"), (ObjPointer(IUnknown), "pWindow"), (Pointer(Const(DXGI_SWAP_CHAIN_DESC1)), "pDesc"), (ObjPointer(IDXGIOutput), "pRestrictToOutput"), Out(Pointer(ObjPointer(IDXGISwapChain1)), "ppSwapChain")]),
494 StdMethod(HRESULT, "GetSharedResourceAdapterLuid", [(HANDLE, "hResource"), Out(Pointer(LUID), "pLuid")], sideeffects=False),
José Fonseca40a9fe42014-09-17 19:04:55 +0100495 StdMethod(HRESULT, "RegisterStereoStatusWindow", [(HWND, "WindowHandle"), (UINT, "wMsg"), Out(Pointer(DWORD), "pdwCookie")], sideeffects=False),
496 StdMethod(HRESULT, "RegisterStereoStatusEvent", [(HANDLE, "hEvent"), Out(Pointer(DWORD), "pdwCookie")], sideeffects=False),
497 StdMethod(Void, "UnregisterStereoStatus", [(DWORD, "dwCookie")], sideeffects=False),
498 StdMethod(HRESULT, "RegisterOcclusionStatusWindow", [(HWND, "WindowHandle"), (UINT, "wMsg"), Out(Pointer(DWORD), "pdwCookie")], sideeffects=False),
499 StdMethod(HRESULT, "RegisterOcclusionStatusEvent", [(HANDLE, "hEvent"), Out(Pointer(DWORD), "pdwCookie")], sideeffects=False),
500 StdMethod(Void, "UnregisterOcclusionStatus", [(DWORD, "dwCookie")], sideeffects=False),
José Fonsecafd9d01d2014-09-03 22:08:30 +0100501 StdMethod(HRESULT, "CreateSwapChainForComposition", [(ObjPointer(IUnknown), "pDevice"), (Pointer(Const(DXGI_SWAP_CHAIN_DESC1)), "pDesc"), (ObjPointer(IDXGIOutput), "pRestrictToOutput"), Out(Pointer(ObjPointer(IDXGISwapChain1)), "ppSwapChain")]),
502]
503
Jeff Muizelaar4d57f312013-11-19 15:18:31 -0500504DXGI_GRAPHICS_PREEMPTION_GRANULARITY = Enum("DXGI_GRAPHICS_PREEMPTION_GRANULARITY", [
505 "DXGI_GRAPHICS_PREEMPTION_DMA_BUFFER_BOUNDARY",
506 "DXGI_GRAPHICS_PREEMPTION_PRIMITIVE_BOUNDARY",
507 "DXGI_GRAPHICS_PREEMPTION_TRIANGLE_BOUNDARY",
508 "DXGI_GRAPHICS_PREEMPTION_PIXEL_BOUNDARY",
509 "DXGI_GRAPHICS_PREEMPTION_INSTRUCTION_BOUNDARY",
510])
511
512DXGI_COMPUTE_PREEMPTION_GRANULARITY = Enum("DXGI_COMPUTE_PREEMPTION_GRANULARITY", [
513 "DXGI_COMPUTE_PREEMPTION_DMA_BUFFER_BOUNDARY",
514 "DXGI_COMPUTE_PREEMPTION_DISPATCH_BOUNDARY",
515 "DXGI_COMPUTE_PREEMPTION_THREAD_GROUP_BOUNDARY",
516 "DXGI_COMPUTE_PREEMPTION_THREAD_BOUNDARY",
517 "DXGI_COMPUTE_PREEMPTION_INSTRUCTION_BOUNDARY",
518])
519
520DXGI_ADAPTER_DESC2 = Struct("DXGI_ADAPTER_DESC2", [
521 (WString, "Description"),
522 (UINT, "VendorId"),
523 (UINT, "DeviceId"),
524 (UINT, "SubSysId"),
525 (UINT, "Revision"),
526 (SIZE_T, "DedicatedVideoMemory"),
527 (SIZE_T, "DedicatedSystemMemory"),
528 (SIZE_T, "SharedSystemMemory"),
529 (LUID, "AdapterLuid"),
José Fonsecafd9d01d2014-09-03 22:08:30 +0100530 (DXGI_ADAPTER_FLAG, "Flags"),
Jeff Muizelaar4d57f312013-11-19 15:18:31 -0500531 (DXGI_GRAPHICS_PREEMPTION_GRANULARITY, "GraphicsPreemptionGranularity"),
532 (DXGI_COMPUTE_PREEMPTION_GRANULARITY, "ComputePreemptionGranularity"),
533])
534
José Fonsecafd9d01d2014-09-03 22:08:30 +0100535IDXGIAdapter2 = Interface("IDXGIAdapter2", IDXGIAdapter1)
Jeff Muizelaar4d57f312013-11-19 15:18:31 -0500536IDXGIAdapter2.methods += [
537 StdMethod(HRESULT, "GetDesc2", [Out(Pointer(DXGI_ADAPTER_DESC2), "pDesc")], sideeffects=False),
538]
José Fonsecaf450d8b2012-11-20 14:48:31 +0000539
José Fonsecafd9d01d2014-09-03 22:08:30 +0100540IDXGIOutput1 = Interface("IDXGIOutput1", IDXGIOutput)
541IDXGIOutput1.methods += [
542 StdMethod(HRESULT, "GetDisplayModeList1", [(DXGI_FORMAT, "EnumFormat"), (DXGI_ENUM_MODES, "Flags"), Out(Pointer(UINT), "pNumModes"), Out(Pointer(DXGI_MODE_DESC1), "pDesc")]),
543 StdMethod(HRESULT, "FindClosestMatchingMode1", [(Pointer(Const(DXGI_MODE_DESC1)), "pModeToMatch"), Out(Pointer(DXGI_MODE_DESC1), "pClosestMatch"), (ObjPointer(IUnknown), "pConcernedDevice")]),
544 StdMethod(HRESULT, "GetDisplaySurfaceData1", [(ObjPointer(IDXGIResource), "pDestination")]),
545 StdMethod(HRESULT, "DuplicateOutput", [(ObjPointer(IUnknown), "pDevice"), Out(Pointer(ObjPointer(IDXGIOutputDuplication)), "ppOutputDuplication")]),
José Fonseca2f439632014-08-27 14:15:44 +0100546]
547
José Fonsecacdefc482012-11-16 20:06:20 +0000548dxgi.addInterfaces([
José Fonseca818d9f02014-09-14 19:41:31 +0100549 IDXGIDisplayControl,
José Fonseca2f439632014-08-27 14:15:44 +0100550 IDXGIDevice2,
José Fonsecafd9d01d2014-09-03 22:08:30 +0100551 IDXGISwapChain1,
552 IDXGIFactory2,
José Fonseca2f439632014-08-27 14:15:44 +0100553 IDXGIResource1,
José Fonsecafd9d01d2014-09-03 22:08:30 +0100554 IDXGIAdapter2,
555 IDXGIOutput1,
José Fonsecaca55d162012-04-16 13:05:47 +0100556])