blob: 0830cab4709a20499d67893b52c032582a6e0427 [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"),
70 (OpaquePointer(BYTE), "pBits"),
71])
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
140IDXGIObject.methods += [
José Fonseca45fff9c2012-05-08 09:07:27 +0100141 StdMethod(HRESULT, "SetPrivateData", [(REFGUID, "Name"), (UINT, "DataSize"), (OpaqueBlob(Const(Void), "DataSize"), "pData")], sideeffects=False),
142 StdMethod(HRESULT, "SetPrivateDataInterface", [(REFGUID, "Name"), (OpaquePointer(Const(IUnknown)), "pUnknown")], sideeffects=False),
143 StdMethod(HRESULT, "GetPrivateData", [(REFGUID, "Name"), Out(Pointer(UINT), "pDataSize"), Out(OpaquePointer(Void), "pData")], sideeffects=False),
José Fonsecaca55d162012-04-16 13:05:47 +0100144 StdMethod(HRESULT, "GetParent", [(REFIID, "riid"), Out(Pointer(ObjPointer(Void)), "ppParent")]),
145]
146
147IDXGIDeviceSubObject.methods += [
148 StdMethod(HRESULT, "GetDevice", [(REFIID, "riid"), Out(Pointer(ObjPointer(Void)), "ppDevice")]),
149]
150
151IDXGIResource.methods += [
152 StdMethod(HRESULT, "GetSharedHandle", [Out(Pointer(HANDLE), "pSharedHandle")]),
José Fonseca45fff9c2012-05-08 09:07:27 +0100153 StdMethod(HRESULT, "GetUsage", [Out(Pointer(DXGI_USAGE), "pUsage")], sideeffects=False),
José Fonsecaca55d162012-04-16 13:05:47 +0100154 StdMethod(HRESULT, "SetEvictionPriority", [(DXGI_RESOURCE_PRIORITY, "EvictionPriority")]),
José Fonseca45fff9c2012-05-08 09:07:27 +0100155 StdMethod(HRESULT, "GetEvictionPriority", [Out(Pointer(DXGI_RESOURCE_PRIORITY), "pEvictionPriority")], sideeffects=False),
José Fonsecaca55d162012-04-16 13:05:47 +0100156]
157
158IDXGIKeyedMutex.methods += [
159 StdMethod(HRESULT, "AcquireSync", [(UINT64, "Key"), (DWORD, "dwMilliseconds")]),
160 StdMethod(HRESULT, "ReleaseSync", [(UINT64, "Key")]),
161]
162
163DXGI_MAP = Flags(UINT, [
164 "DXGI_MAP_READ",
165 "DXGI_MAP_WRITE",
166 "DXGI_MAP_DISCARD",
167])
168
169IDXGISurface.methods += [
José Fonseca45fff9c2012-05-08 09:07:27 +0100170 StdMethod(HRESULT, "GetDesc", [Out(Pointer(DXGI_SURFACE_DESC), "pDesc")]), sideeffects=False,
José Fonsecaca55d162012-04-16 13:05:47 +0100171 StdMethod(HRESULT, "Map", [Out(Pointer(DXGI_MAPPED_RECT), "pLockedRect"), (DXGI_MAP, "MapFlags")]),
172 StdMethod(HRESULT, "Unmap", []),
173]
174
175IDXGISurface1.methods += [
176 StdMethod(HRESULT, "GetDC", [(BOOL, "Discard"), Out(Pointer(HDC), "phdc")]),
177 StdMethod(HRESULT, "ReleaseDC", [(Pointer(RECT), "pDirtyRect")]),
178]
179
180IDXGIAdapter.methods += [
181 StdMethod(HRESULT, "EnumOutputs", [(UINT, "Output"), Out(Pointer(ObjPointer(IDXGIOutput)), "ppOutput")]),
José Fonseca45fff9c2012-05-08 09:07:27 +0100182 StdMethod(HRESULT, "GetDesc", [Out(Pointer(DXGI_ADAPTER_DESC), "pDesc")], sideeffects=False),
183 StdMethod(HRESULT, "CheckInterfaceSupport", [(REFGUID, "InterfaceName"), Out(Pointer(LARGE_INTEGER), "pUMDVersion")], sideeffects=False),
José Fonsecaca55d162012-04-16 13:05:47 +0100184]
185
186DXGI_ENUM_MODES = Flags(UINT, [
187 "DXGI_ENUM_MODES_INTERLACED",
188 "DXGI_ENUM_MODES_SCALING",
189])
190
191IDXGIOutput.methods += [
José Fonseca45fff9c2012-05-08 09:07:27 +0100192 StdMethod(HRESULT, "GetDesc", [Out(Pointer(DXGI_OUTPUT_DESC), "pDesc")], sideeffects=False),
193 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 +0100194 StdMethod(HRESULT, "FindClosestMatchingMode", [(Pointer(Const(DXGI_MODE_DESC)), "pModeToMatch"), Out(Pointer(DXGI_MODE_DESC), "pClosestMatch"), (ObjPointer(IUnknown), "pConcernedDevice")]),
195 StdMethod(HRESULT, "WaitForVBlank", []),
196 StdMethod(HRESULT, "TakeOwnership", [(ObjPointer(IUnknown), "pDevice"), (BOOL, "Exclusive")]),
197 StdMethod(Void, "ReleaseOwnership", []),
198 StdMethod(HRESULT, "GetGammaControlCapabilities", [Out(Pointer(DXGI_GAMMA_CONTROL_CAPABILITIES), "pGammaCaps")]),
199 StdMethod(HRESULT, "SetGammaControl", [(Pointer(Const(DXGI_GAMMA_CONTROL)), "pArray")]),
José Fonseca45fff9c2012-05-08 09:07:27 +0100200 StdMethod(HRESULT, "GetGammaControl", [Out(Pointer(DXGI_GAMMA_CONTROL), "pArray")], sideeffects=False),
José Fonsecaca55d162012-04-16 13:05:47 +0100201 StdMethod(HRESULT, "SetDisplaySurface", [(ObjPointer(IDXGISurface), "pScanoutSurface")]),
202 StdMethod(HRESULT, "GetDisplaySurfaceData", [(ObjPointer(IDXGISurface), "pDestination")]),
José Fonseca45fff9c2012-05-08 09:07:27 +0100203 StdMethod(HRESULT, "GetFrameStatistics", [Out(Pointer(DXGI_FRAME_STATISTICS), "pStats")], sideeffects=False),
José Fonsecaca55d162012-04-16 13:05:47 +0100204]
205
206DXGI_PRESENT = Flags(UINT, [
207 "DXGI_PRESENT_TEST",
208 "DXGI_PRESENT_DO_NOT_SEQUENCE",
209 "DXGI_PRESENT_RESTART",
210])
211
212IDXGISwapChain.methods += [
213 StdMethod(HRESULT, "Present", [(UINT, "SyncInterval"), (DXGI_PRESENT, "Flags")]),
214 StdMethod(HRESULT, "GetBuffer", [(UINT, "Buffer"), (REFIID, "riid"), Out(Pointer(ObjPointer(Void)), "ppSurface")]),
215 StdMethod(HRESULT, "SetFullscreenState", [(BOOL, "Fullscreen"), (ObjPointer(IDXGIOutput), "pTarget")]),
216 StdMethod(HRESULT, "GetFullscreenState", [Out(Pointer(BOOL), "pFullscreen"), Out(Pointer(ObjPointer(IDXGIOutput)), "ppTarget")]),
José Fonseca45fff9c2012-05-08 09:07:27 +0100217 StdMethod(HRESULT, "GetDesc", [Out(Pointer(DXGI_SWAP_CHAIN_DESC), "pDesc")], sideeffects=False),
José Fonsecaca55d162012-04-16 13:05:47 +0100218 StdMethod(HRESULT, "ResizeBuffers", [(UINT, "BufferCount"), (UINT, "Width"), (UINT, "Height"), (DXGI_FORMAT, "NewFormat"), (UINT, "SwapChainFlags")]),
219 StdMethod(HRESULT, "ResizeTarget", [(Pointer(Const(DXGI_MODE_DESC)), "pNewTargetParameters")]),
220 StdMethod(HRESULT, "GetContainingOutput", [Out(Pointer(ObjPointer(IDXGIOutput)), "ppOutput")]),
José Fonseca45fff9c2012-05-08 09:07:27 +0100221 StdMethod(HRESULT, "GetFrameStatistics", [Out(Pointer(DXGI_FRAME_STATISTICS), "pStats")], sideeffects=False),
222 StdMethod(HRESULT, "GetLastPresentCount", [Out(Pointer(UINT), "pLastPresentCount")], sideeffects=False),
José Fonsecaca55d162012-04-16 13:05:47 +0100223]
224
225DXGI_MWA = Flags(UINT, [
226 "DXGI_MWA_NO_WINDOW_CHANGES",
227 "DXGI_MWA_NO_ALT_ENTER",
228 "DXGI_MWA_NO_PRINT_SCREEN",
229 "DXGI_MWA_VALID",
230])
231
232IDXGIFactory.methods += [
233 StdMethod(HRESULT, "EnumAdapters", [(UINT, "Adapter"), Out(Pointer(ObjPointer(IDXGIAdapter)), "ppAdapter")]),
234 StdMethod(HRESULT, "MakeWindowAssociation", [(HWND, "WindowHandle"), (DXGI_MWA, "Flags")]),
José Fonseca45fff9c2012-05-08 09:07:27 +0100235 StdMethod(HRESULT, "GetWindowAssociation", [Out(Pointer(HWND), "pWindowHandle")], sideeffects=False),
José Fonsecaca55d162012-04-16 13:05:47 +0100236 StdMethod(HRESULT, "CreateSwapChain", [(ObjPointer(IUnknown), "pDevice"), (Pointer(DXGI_SWAP_CHAIN_DESC), "pDesc"), Out(Pointer(ObjPointer(IDXGISwapChain)), "ppSwapChain")]),
237 StdMethod(HRESULT, "CreateSoftwareAdapter", [(HMODULE, "Module"), Out(Pointer(ObjPointer(IDXGIAdapter)), "ppAdapter")]),
238]
239
240IDXGIDevice.methods += [
241 StdMethod(HRESULT, "GetAdapter", [Out(Pointer(ObjPointer(IDXGIAdapter)), "pAdapter")]),
242 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 +0100243 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 +0100244 StdMethod(HRESULT, "SetGPUThreadPriority", [(INT, "Priority")]),
José Fonseca45fff9c2012-05-08 09:07:27 +0100245 StdMethod(HRESULT, "GetGPUThreadPriority", [Out(Pointer(INT), "pPriority")], sideeffects=False),
José Fonsecaca55d162012-04-16 13:05:47 +0100246]
247
248DXGI_ADAPTER_FLAG = Enum("DXGI_ADAPTER_FLAG", [
249 "DXGI_ADAPTER_FLAG_NONE",
250 "DXGI_ADAPTER_FLAG_REMOTE",
251])
252
253DXGI_ADAPTER_DESC1 = Struct("DXGI_ADAPTER_DESC1", [
254 (WString, "Description"),
255 (UINT, "VendorId"),
256 (UINT, "DeviceId"),
257 (UINT, "SubSysId"),
258 (UINT, "Revision"),
259 (SIZE_T, "DedicatedVideoMemory"),
260 (SIZE_T, "DedicatedSystemMemory"),
261 (SIZE_T, "SharedSystemMemory"),
262 (LUID, "AdapterLuid"),
José Fonsecaaf7d2312011-07-07 10:16:57 +0100263 (UINT, "Flags"),
264])
265
José Fonsecaca55d162012-04-16 13:05:47 +0100266DXGI_DISPLAY_COLOR_SPACE = Struct("DXGI_DISPLAY_COLOR_SPACE", [
267 (Array(Array(FLOAT, 8), 2), "PrimaryCoordinates"),
268 (Array(Array(FLOAT, 16), 2), "WhitePoints"),
José Fonsecaaf7d2312011-07-07 10:16:57 +0100269])
270
José Fonsecaca55d162012-04-16 13:05:47 +0100271IDXGIFactory1.methods += [
272 StdMethod(HRESULT, "EnumAdapters1", [(UINT, "Adapter"), Out(Pointer(ObjPointer(IDXGIAdapter1)), "ppAdapter")]),
273 StdMethod(BOOL, "IsCurrent", []),
José Fonsecaaf7d2312011-07-07 10:16:57 +0100274]
275
José Fonsecaca55d162012-04-16 13:05:47 +0100276IDXGIAdapter1.methods += [
José Fonseca45fff9c2012-05-08 09:07:27 +0100277 StdMethod(HRESULT, "GetDesc1", [Out(Pointer(DXGI_ADAPTER_DESC1), "pDesc")], sideeffects=False),
José Fonsecaaf7d2312011-07-07 10:16:57 +0100278]
279
José Fonsecaca55d162012-04-16 13:05:47 +0100280IDXGIDevice1.methods += [
281 StdMethod(HRESULT, "SetMaximumFrameLatency", [(UINT, "MaxLatency")]),
José Fonseca45fff9c2012-05-08 09:07:27 +0100282 StdMethod(HRESULT, "GetMaximumFrameLatency", [Out(Pointer(UINT), "pMaxLatency")], sideeffects=False),
José Fonsecaaf7d2312011-07-07 10:16:57 +0100283]
284
José Fonsecaca55d162012-04-16 13:05:47 +0100285dxgi = API('dxgi')
286dxgi.addFunctions([
287 StdFunction(HRESULT, "CreateDXGIFactory", [(REFIID, "riid"), (Pointer(ObjPointer(Void)), "ppFactory")]),
288 StdFunction(HRESULT, "CreateDXGIFactory1", [(REFIID, "riid"), (Pointer(ObjPointer(Void)), "ppFactory")]),
289])