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