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 dxgi1_2.h 7 use ctypes::c_void; 8 use shared::basetsd::SIZE_T; 9 use shared::dxgi::{ 10 DXGI_MAPPED_RECT, DXGI_SWAP_EFFECT, IDXGIAdapter1, IDXGIAdapter1Vtbl, IDXGIDevice1, 11 IDXGIDevice1Vtbl, IDXGIFactory1, IDXGIFactory1Vtbl, IDXGIObject, IDXGIObjectVtbl, IDXGIOutput, 12 IDXGIOutputVtbl, IDXGIResource, IDXGIResourceVtbl, IDXGISurface1, IDXGISurface1Vtbl, 13 IDXGISwapChain, IDXGISwapChainVtbl, 14 }; 15 use shared::dxgiformat::DXGI_FORMAT; 16 use shared::dxgitype::{ 17 DXGI_MODE_DESC, DXGI_MODE_ROTATION, DXGI_MODE_SCALING, DXGI_MODE_SCANLINE_ORDER, DXGI_RATIONAL, 18 DXGI_RGBA, DXGI_SAMPLE_DESC, DXGI_USAGE, 19 }; 20 use shared::guiddef::REFGUID; 21 use shared::minwindef::{BOOL, DWORD, UINT}; 22 use shared::windef::{HWND, POINT, RECT}; 23 use um::minwinbase::SECURITY_ATTRIBUTES; 24 use um::unknwnbase::{IUnknown, IUnknownVtbl}; 25 use um::winnt::{HANDLE, HRESULT, LARGE_INTEGER, LPCWSTR, LUID, WCHAR}; 26 ENUM!{enum DXGI_ALPHA_MODE { 27 DXGI_ALPHA_MODE_UNSPECIFIED = 0, 28 DXGI_ALPHA_MODE_PREMULTIPLIED = 1, 29 DXGI_ALPHA_MODE_STRAIGHT = 2, 30 DXGI_ALPHA_MODE_IGNORE = 3, 31 DXGI_ALPHA_MODE_FORCE_DWORD = 0xFFFFFFFF, 32 }} 33 ENUM!{enum DXGI_COMPUTE_PREEMPTION_GRANULARITY { 34 DXGI_COMPUTE_PREEMPTION_DMA_BUFFER_BOUNDARY = 0, 35 DXGI_COMPUTE_PREEMPTION_DISPATCH_BOUNDARY = 1, 36 DXGI_COMPUTE_PREEMPTION_THREAD_GROUP_BOUNDARY = 2, 37 DXGI_COMPUTE_PREEMPTION_THREAD_BOUNDARY = 3, 38 DXGI_COMPUTE_PREEMPTION_INSTRUCTION_BOUNDARY = 4, 39 }} 40 ENUM!{enum DXGI_GRAPHICS_PREEMPTION_GRANULARITY { 41 DXGI_GRAPHICS_PREEMPTION_DMA_BUFFER_BOUNDARY = 0, 42 DXGI_GRAPHICS_PREEMPTION_PRIMITIVE_BOUNDARY = 1, 43 DXGI_GRAPHICS_PREEMPTION_TRIANGLE_BOUNDARY = 2, 44 DXGI_GRAPHICS_PREEMPTION_PIXEL_BOUNDARY = 3, 45 DXGI_GRAPHICS_PREEMPTION_INSTRUCTION_BOUNDARY = 4, 46 }} 47 ENUM!{enum DXGI_OUTDUPL_POINTER_SHAPE_TYPE { 48 DXGI_OUTDUPL_POINTER_SHAPE_TYPE_MONOCHROME = 1, 49 DXGI_OUTDUPL_POINTER_SHAPE_TYPE_COLOR = 2, 50 DXGI_OUTDUPL_POINTER_SHAPE_TYPE_MASKED_COLOR = 4, 51 }} 52 ENUM!{enum DXGI_SCALING { 53 DXGI_SCALING_STRETCH = 0, 54 DXGI_SCALING_NONE = 1, 55 DXGI_SCALING_ASPECT_RATIO_STRETCH = 2, 56 }} 57 ENUM!{enum _DXGI_OFFER_RESOURCE_PRIORITY { 58 DXGI_OFFER_RESOURCE_PRIORITY_LOW = 1, 59 DXGI_OFFER_RESOURCE_PRIORITY_NORMAL = 2, 60 DXGI_OFFER_RESOURCE_PRIORITY_HIGH = 3, 61 }} 62 STRUCT!{struct DXGI_ADAPTER_DESC2 { 63 Description: [WCHAR; 128], 64 VendorId: UINT, 65 DeviceId: UINT, 66 SubSysId: UINT, 67 Revision: UINT, 68 DedicatedVideoMemory: SIZE_T, 69 DedicatedSystemMemory: SIZE_T, 70 SharedSystemMemory: SIZE_T, 71 AdapterLuid: LUID, 72 Flags: UINT, 73 GraphicsPreemptionGranularity: DXGI_GRAPHICS_PREEMPTION_GRANULARITY, 74 ComputePreemptionGranularity: DXGI_COMPUTE_PREEMPTION_GRANULARITY, 75 }} 76 STRUCT!{struct DXGI_MODE_DESC1 { 77 Width: UINT, 78 Height: UINT, 79 RefreshRate: DXGI_RATIONAL, 80 Format: DXGI_FORMAT, 81 ScanlineOrdering: DXGI_MODE_SCANLINE_ORDER, 82 Scaling: DXGI_MODE_SCALING, 83 Stereo: BOOL, 84 }} 85 STRUCT!{struct DXGI_OUTDUPL_DESC { 86 ModeDesc: DXGI_MODE_DESC, 87 Rotation: DXGI_MODE_ROTATION, 88 DesktopImageInSystemMemory: BOOL, 89 }} 90 STRUCT!{struct DXGI_OUTDUPL_FRAME_INFO { 91 LastPresentTime: LARGE_INTEGER, 92 LastMouseUpdateTime: LARGE_INTEGER, 93 AccumulatedFrames: UINT, 94 RectsCoalesced: BOOL, 95 ProtectedContentMaskedOut: BOOL, 96 PointerPosition: DXGI_OUTDUPL_POINTER_POSITION, 97 TotalMetadataBufferSize: UINT, 98 PointerShapeBufferSize: UINT, 99 }} 100 STRUCT!{struct DXGI_OUTDUPL_MOVE_RECT { 101 SourcePoint: POINT, 102 DestinationRect: RECT, 103 }} 104 STRUCT!{struct DXGI_OUTDUPL_POINTER_POSITION { 105 Position: POINT, 106 Visible: BOOL, 107 }} 108 STRUCT!{struct DXGI_OUTDUPL_POINTER_SHAPE_INFO { 109 Type: UINT, 110 Width: UINT, 111 Height: UINT, 112 Pitch: UINT, 113 HotSpot: POINT, 114 }} 115 STRUCT!{struct DXGI_PRESENT_PARAMETERS { 116 DirtyRectsCount: UINT, 117 pDirtyRects: *mut RECT, 118 pScrollRect: *mut RECT, 119 pScrollOffset: *mut POINT, 120 }} 121 STRUCT!{struct DXGI_SWAP_CHAIN_DESC1 { 122 Width: UINT, 123 Height: UINT, 124 Format: DXGI_FORMAT, 125 Stereo: BOOL, 126 SampleDesc: DXGI_SAMPLE_DESC, 127 BufferUsage: DXGI_USAGE, 128 BufferCount: UINT, 129 Scaling: DXGI_SCALING, 130 SwapEffect: DXGI_SWAP_EFFECT, 131 AlphaMode: DXGI_ALPHA_MODE, 132 Flags: UINT, 133 }} 134 STRUCT!{struct DXGI_SWAP_CHAIN_FULLSCREEN_DESC { 135 RefreshRate: DXGI_RATIONAL, 136 ScanlineOrdering: DXGI_MODE_SCANLINE_ORDER, 137 Scaling: DXGI_MODE_SCALING, 138 Windowed: BOOL, 139 }} 140 RIDL!{#[uuid(0x0aa1ae0a, 0xfa0e, 0x4b84, 0x86, 0x44, 0xe0, 0x5f, 0xf8, 0xe5, 0xac, 0xb5)] 141 interface IDXGIAdapter2(IDXGIAdapter2Vtbl): IDXGIAdapter1(IDXGIAdapter1Vtbl) { 142 fn GetDesc2( 143 pDesc: *mut DXGI_ADAPTER_DESC2, 144 ) -> HRESULT, 145 }} 146 RIDL!{#[uuid(0x05008617, 0xfbfd, 0x4051, 0xa7, 0x90, 0x14, 0x48, 0x84, 0xb4, 0xf6, 0xa9)] 147 interface IDXGIDevice2(IDXGIDevice2Vtbl): IDXGIDevice1(IDXGIDevice1Vtbl) { 148 fn OfferResources( 149 NumResources: UINT, 150 ppResources: *mut *mut IDXGIResource, 151 Priority: DXGI_OFFER_RESOURCE_PRIORITY, 152 ) -> HRESULT, 153 fn ReclaimResources( 154 NumResources: UINT, 155 ppResources: *mut *mut IDXGIResource, 156 pDiscarded: *mut BOOL, 157 ) -> HRESULT, 158 fn EnqueueSetEvent( 159 hEvent: HANDLE, 160 ) -> HRESULT, 161 }} 162 RIDL!{#[uuid(0xea9dbf1a, 0xc88e, 0x4486, 0x85, 0x4a, 0x98, 0xaa, 0x01, 0x38, 0xf3, 0x0c)] 163 interface IDXGIDisplayControl(IDXGIDisplayControlVtbl): IUnknown(IUnknownVtbl) { 164 fn IsStereoEnabled() -> BOOL, 165 fn SetStereoEnabled( 166 enabled: BOOL, 167 ) -> (), 168 }} 169 RIDL!{#[uuid(0x50c83a1c, 0xe072, 0x4c48, 0x87, 0xb0, 0x36, 0x30, 0xfa, 0x36, 0xa6, 0xd0)] 170 interface IDXGIFactory2(IDXGIFactory2Vtbl): IDXGIFactory1(IDXGIFactory1Vtbl) { 171 fn IsWindowedStereoEnabled() -> BOOL, 172 fn CreateSwapChainForHwnd( 173 pDevice: *mut IUnknown, 174 hWnd: HWND, 175 pDesc: *const DXGI_SWAP_CHAIN_DESC1, 176 pFullscreenDesc: *const DXGI_SWAP_CHAIN_FULLSCREEN_DESC, 177 pRestrictToOutput: *mut IDXGIOutput, 178 ppSwapChain: *mut *mut IDXGISwapChain1, 179 ) -> HRESULT, 180 fn CreateSwapChainForCoreWindow( 181 pDevice: *mut IUnknown, 182 pWindow: *mut IUnknown, 183 pDesc: *const DXGI_SWAP_CHAIN_DESC1, 184 pRestrictToOutput: *mut IDXGIOutput, 185 ppSwapChain: *mut *mut IDXGISwapChain1, 186 ) -> HRESULT, 187 fn GetSharedResourceAdapterLuid( 188 hResource: HANDLE, 189 pLuid: *mut LUID, 190 ) -> HRESULT, 191 fn RegisterStereoStatusWindow( 192 WindowHandle: HWND, 193 wMsg: UINT, 194 pdwCookie: *mut DWORD, 195 ) -> HRESULT, 196 fn RegisterStereoStatusEvent( 197 hEvent: HANDLE, 198 pdwCookie: *mut DWORD, 199 ) -> HRESULT, 200 fn UnregisterStereoStatus( 201 dwCookie: DWORD, 202 ) -> (), 203 fn RegisterOcclusionStatusWindow( 204 WindowHandle: HWND, 205 wMsg: UINT, 206 pdwCookie: *mut DWORD, 207 ) -> HRESULT, 208 fn RegisterOcclusionStatusEvent( 209 hEvent: HANDLE, 210 pdwCookie: *mut DWORD, 211 ) -> HRESULT, 212 fn UnregisterOcclusionStatus( 213 dwCookie: DWORD, 214 ) -> (), 215 fn CreateSwapChainForComposition( 216 pDevice: *mut IUnknown, 217 pDesc: *const DXGI_SWAP_CHAIN_DESC1, 218 pRestrictToOutput: *mut IDXGIOutput, 219 ppSwapChain: *mut *mut IDXGISwapChain1, 220 ) -> HRESULT, 221 }} 222 RIDL!{#[uuid(0x00cddea8, 0x939b, 0x4b83, 0xa3, 0x40, 0xa6, 0x85, 0x22, 0x66, 0x66, 0xcc)] 223 interface IDXGIOutput1(IDXGIOutput1Vtbl): IDXGIOutput(IDXGIOutputVtbl) { 224 fn GetDisplayModeList1( 225 EnumFormat: DXGI_FORMAT, 226 Flags: UINT, 227 pNumModes: *mut UINT, 228 pDesc: *mut DXGI_MODE_DESC1, 229 ) -> HRESULT, 230 fn FindClosestMatchingMode1( 231 pModeToMatch: *const DXGI_MODE_DESC1, 232 pClosestMatch: *mut DXGI_MODE_DESC1, 233 pConcernedDevice: *mut IUnknown, 234 ) -> HRESULT, 235 fn GetDisplaySurfaceData1( 236 pDestination: *mut IDXGIResource, 237 ) -> HRESULT, 238 fn DuplicateOutput( 239 pDevice: *mut IUnknown, 240 ppOutputDuplication: *mut *mut IDXGIOutputDuplication, 241 ) -> HRESULT, 242 }} 243 RIDL!{#[uuid(0x191cfac3, 0xa341, 0x470d, 0xb2, 0x6e, 0xa8, 0x64, 0xf4, 0x28, 0x31, 0x9c)] 244 interface IDXGIOutputDuplication(IDXGIOutputDuplicationVtbl): IDXGIObject(IDXGIObjectVtbl) { 245 fn GetDesc( 246 pDesc: *mut DXGI_OUTDUPL_DESC, 247 ) -> (), 248 fn AcquireNextFrame( 249 TimeoutInMilliseconds: UINT, 250 pFrameInfo: *mut DXGI_OUTDUPL_FRAME_INFO, 251 ppDesktopResource: *mut *mut IDXGIResource, 252 ) -> HRESULT, 253 fn GetFrameDirtyRects( 254 DirtyRectsBufferSize: UINT, 255 pDirtyRectsBuffer: *mut RECT, 256 pDirtyRectsBufferSizeRequired: *mut UINT, 257 ) -> HRESULT, 258 fn GetFrameMoveRects( 259 MoveRectsBufferSize: UINT, 260 pMoveRectBuffer: *mut DXGI_OUTDUPL_MOVE_RECT, 261 pMoveRectsBufferSizeRequired: *mut UINT, 262 ) -> HRESULT, 263 fn GetFramePointerShape( 264 PointerShapeBufferSize: UINT, 265 pPointerShapeBuffer: *mut c_void, 266 pPointerShapeBufferSizeRequired: *mut UINT, 267 pPointerShapeInfo: *mut DXGI_OUTDUPL_POINTER_SHAPE_INFO, 268 ) -> HRESULT, 269 fn MapDesktopSurface( 270 pLockedRect: *mut DXGI_MAPPED_RECT, 271 ) -> HRESULT, 272 fn UnMapDesktopSurface() -> HRESULT, 273 fn ReleaseFrame() -> HRESULT, 274 }} 275 RIDL!{#[uuid(0x30961379, 0x4609, 0x4a41, 0x99, 0x8e, 0x54, 0xfe, 0x56, 0x7e, 0xe0, 0xc1)] 276 interface IDXGIResource1(IDXGIResource1Vtbl): IDXGIResource(IDXGIResourceVtbl) { 277 fn CreateSubresourceSurface( 278 index: UINT, 279 ppSurface: *mut *mut IDXGISurface2, 280 ) -> HRESULT, 281 fn CreateSharedHandle( 282 pAttributes: *const SECURITY_ATTRIBUTES, 283 dwAccess: DWORD, 284 lpName: LPCWSTR, 285 pHandle: *mut HANDLE, 286 ) -> HRESULT, 287 }} 288 RIDL!{#[uuid(0xaba496dd, 0xb617, 0x4cb8, 0xa8, 0x66, 0xbc, 0x44, 0xd7, 0xeb, 0x1f, 0xa2)] 289 interface IDXGISurface2(IDXGISurface2Vtbl): IDXGISurface1(IDXGISurface1Vtbl) { 290 fn GetResource( 291 riid: REFGUID, 292 ppParentResource: *mut *mut c_void, 293 pSubresourceIndex: *mut UINT, 294 ) -> HRESULT, 295 }} 296 RIDL!{#[uuid(0x790a45f7, 0x0d42, 0x4876, 0x98, 0x3a, 0x0a, 0x55, 0xcf, 0xe6, 0xf4, 0xaa)] 297 interface IDXGISwapChain1(IDXGISwapChain1Vtbl): IDXGISwapChain(IDXGISwapChainVtbl) { 298 fn GetDesc1( 299 pDesc: *mut DXGI_SWAP_CHAIN_DESC1, 300 ) -> HRESULT, 301 fn GetFullscreenDesc( 302 pDesc: *mut DXGI_SWAP_CHAIN_FULLSCREEN_DESC, 303 ) -> HRESULT, 304 fn GetHwnd( 305 pHwnd: *mut HWND, 306 ) -> HRESULT, 307 fn GetCoreWindow( 308 refiid: REFGUID, 309 ppUnk: *mut *mut c_void, 310 ) -> HRESULT, 311 fn Present1( 312 SyncInterval: UINT, 313 PresentFlags: UINT, 314 pPresentParameters: *const DXGI_PRESENT_PARAMETERS, 315 ) -> HRESULT, 316 fn IsTemporaryMonoSupported() -> BOOL, 317 fn GetRestrictToOutput( 318 ppRestrictToOutput: *mut *mut IDXGIOutput, 319 ) -> HRESULT, 320 fn SetBackgroundColor( 321 pColor: *const DXGI_RGBA, 322 ) -> HRESULT, 323 fn GetBackgroundColor( 324 pColor: *mut DXGI_RGBA, 325 ) -> HRESULT, 326 fn SetRotation( 327 Rotation: DXGI_MODE_ROTATION, 328 ) -> HRESULT, 329 fn GetRotation( 330 pRotation: *mut DXGI_MODE_ROTATION, 331 ) -> HRESULT, 332 }} 333 pub type DXGI_OFFER_RESOURCE_PRIORITY = _DXGI_OFFER_RESOURCE_PRIORITY; 334 pub const DXGI_ENUM_MODES_DISABLED_STEREO: UINT = 8; 335 pub const DXGI_ENUM_MODES_STEREO: UINT = 4; 336 pub const DXGI_SHARED_RESOURCE_READ: UINT = 0x80000000; 337 pub const DXGI_SHARED_RESOURCE_WRITE: UINT = 1; 338 DEFINE_GUID!{IID_IDXGIDisplayControl, 339 0xea9dbf1a, 0xc88e, 0x4486, 0x85, 0x4a, 0x98, 0xaa, 0x01, 0x38, 0xf3, 0x0c} 340 DEFINE_GUID!{IID_IDXGIOutputDuplication, 341 0x191cfac3, 0xa341, 0x470d, 0xb2, 0x6e, 0xa8, 0x64, 0xf4, 0x28, 0x31, 0x9c} 342 DEFINE_GUID!{IID_IDXGISurface2, 343 0xaba496dd, 0xb617, 0x4cb8, 0xa8, 0x66, 0xbc, 0x44, 0xd7, 0xeb, 0x1f, 0xa2} 344 DEFINE_GUID!{IID_IDXGIResource1, 345 0x30961379, 0x4609, 0x4a41, 0x99, 0x8e, 0x54, 0xfe, 0x56, 0x7e, 0xe0, 0xc1} 346 DEFINE_GUID!{IID_IDXGIDevice2, 347 0x05008617, 0xfbfd, 0x4051, 0xa7, 0x90, 0x14, 0x48, 0x84, 0xb4, 0xf6, 0xa9} 348 DEFINE_GUID!{IID_IDXGISwapChain1, 349 0x790a45f7, 0x0d42, 0x4876, 0x98, 0x3a, 0x0a, 0x55, 0xcf, 0xe6, 0xf4, 0xaa} 350 DEFINE_GUID!{IID_IDXGIFactory2, 351 0x50c83a1c, 0xe072, 0x4c48, 0x87, 0xb0, 0x36, 0x30, 0xfa, 0x36, 0xa6, 0xd0} 352 DEFINE_GUID!{IID_IDXGIAdapter2, 353 0x0aa1ae0a, 0xfa0e, 0x4b84, 0x86, 0x44, 0xe0, 0x5f, 0xf8, 0xe5, 0xac, 0xb5} 354 DEFINE_GUID!{IID_IDXGIOutput1, 355 0x00cddea8, 0x939b, 0x4b83, 0xa3, 0x40, 0xa6, 0x85, 0x22, 0x66, 0x66, 0xcc} 356