// Licensed under the Apache License, Version 2.0
// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0 > or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT >, at your option.
// All files in the project carrying such notice may not be copied, modified, or distributed
// except according to those terms.
//! Mappings for the contents of dxgi.h
use ctypes::c_void;
use shared::basetsd::{SIZE_T, UINT64};
use shared::dxgiformat::DXGI_FORMAT;
use shared::dxgitype::{
DXGI_GAMMA_CONTROL, DXGI_GAMMA_CONTROL_CAPABILITIES, DXGI_MODE_DESC, DXGI_MODE_ROTA
TION,
DXGI_SAMPLE_DESC, DXGI_USAGE,
};
use shared::guiddef::{REFGUID, REFIID};
use shared::minwindef::{BOOL, BYTE, DWORD, FLOAT, HMODULE, UINT};
use shared::windef::{HDC, HMONITOR, HWND, RECT};
use um::unknwnbase::{IUnknown, IUnknownVtbl};
use um::winnt::{HANDLE, HRESULT, INT, LARGE_INTEGER, LUID, WCHAR};
STRUCT !{struct DXGI_FRAME_STATISTICS {
PresentCount: UINT,
PresentRefreshCount: UINT,
SyncRefreshCount: UINT,
SyncQPCTime: LARGE_INTEGER,
SyncGPUTime: LARGE_INTEGER,
}}
STRUCT !{struct DXGI_MAPPED_RECT {
Pitch: INT,
pBits: *mut BYTE,
}}
STRUCT !{struct DXGI_ADAPTER_DESC {
Description: [WCHAR; 128 ],
VendorId: UINT,
DeviceId: UINT,
SubSysId: UINT,
Revision: UINT,
DedicatedVideoMemory: SIZE_T,
DedicatedSystemMemory: SIZE_T,
SharedSystemMemory: SIZE_T,
AdapterLuid: LUID,
}}
STRUCT !{struct DXGI_OUTPUT_DESC {
DeviceName: [WCHAR; 32 ],
DesktopCoordinates: RECT,
AttachedToDesktop: BOOL,
Rotation: DXGI_MODE_ROTATION,
Monitor: HMONITOR,
}}
STRUCT !{struct DXGI_SHARED_RESOURCE {
Handle: HANDLE,
}}
pub const DXGI_RESOURCE_PRIORITY_MINIMUM: DWORD = 0 x28000000;
pub const DXGI_RESOURCE_PRIORITY_LOW: DWORD = 0 x50000000;
pub const DXGI_RESOURCE_PRIORITY_NORMAL: DWORD = 0 x78000000;
pub const DXGI_RESOURCE_PRIORITY_HIGH: DWORD = 0 xa0000000;
pub const DXGI_RESOURCE_PRIORITY_MAXIMUM: DWORD = 0 xc8000000;
ENUM !{enum DXGI_RESIDENCY {
DXGI_RESIDENCY_FULLY_RESIDENT = 1 ,
DXGI_RESIDENCY_RESIDENT_IN_SHARED_MEMORY = 2 ,
DXGI_RESIDENCY_EVICTED_TO_DISK = 3 ,
}}
STRUCT !{struct DXGI_SURFACE_DESC {
Width: UINT,
Height: UINT,
Format: DXGI_FORMAT,
SampleDesc: DXGI_SAMPLE_DESC,
}}
ENUM !{enum DXGI_SWAP_EFFECT {
DXGI_SWAP_EFFECT_DISCARD = 0 ,
DXGI_SWAP_EFFECT_SEQUENTIAL = 1 ,
DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL = 3 ,
DXGI_SWAP_EFFECT_FLIP_DISCARD = 4 ,
}}
ENUM !{enum DXGI_SWAP_CHAIN_FLAG {
DXGI_SWAP_CHAIN_FLAG_NONPREROTATED = 1 ,
DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH = 2 ,
DXGI_SWAP_CHAIN_FLAG_GDI_COMPATIBLE = 4 ,
DXGI_SWAP_CHAIN_FLAG_RESTRICTED_CONTENT = 8 ,
DXGI_SWAP_CHAIN_FLAG_RESTRICT_SHARED_RESOURCE_DRIVER = 16 ,
DXGI_SWAP_CHAIN_FLAG_DISPLAY_ONLY = 32 ,
DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT = 64 ,
DXGI_SWAP_CHAIN_FLAG_FOREGROUND_LAYER = 128 ,
DXGI_SWAP_CHAIN_FLAG_FULLSCREEN_VIDEO = 256 ,
DXGI_SWAP_CHAIN_FLAG_YUV_VIDEO = 512 ,
DXGI_SWAP_CHAIN_FLAG_HW_PROTECTED = 1024 ,
DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING = 2048 ,
}}
STRUCT !{struct DXGI_SWAP_CHAIN_DESC {
BufferDesc: DXGI_MODE_DESC,
SampleDesc: DXGI_SAMPLE_DESC,
BufferUsage: DXGI_USAGE,
BufferCount: UINT,
OutputWindow: HWND,
Windowed: BOOL,
SwapEffect: DXGI_SWAP_EFFECT,
Flags: UINT,
}}
RIDL!{#[ uuid(0 xaec22fb8, 0 x76f3, 0 x4639, 0 x9b, 0 xe0, 0 x28, 0 xeb, 0 x43, 0 xa6, 0 x7a, 0 x2e)]
interface IDXGIObject(IDXGIObjectVtbl): IUnknown(IUnknownVtbl) {
fn SetPrivateData(
Name: REFGUID,
DataSize: UINT,
pData: *const c_void,
) -> HRESULT,
fn SetPrivateDataInterface(
Name: REFGUID,
pUnknown: *const IUnknown,
) -> HRESULT,
fn GetPrivateData(
Name: REFGUID,
pDataSize: *mut UINT,
pData: *mut c_void,
) -> HRESULT,
fn GetParent(
riid: REFIID,
ppParent: *mut *mut c_void,
) -> HRESULT,
}}
RIDL!{#[ uuid(0 x3d3e0379, 0 xf9de, 0 x4d58, 0 xbb, 0 x6c, 0 x18, 0 xd6, 0 x29, 0 x92, 0 xf1, 0 xa6)]
interface IDXGIDeviceSubObject(IDXGIDeviceSubObjectVtbl): IDXGIObject(IDXGIObjectVtbl) {
fn GetDevice(
riid: REFIID,
ppDevice: *mut *mut c_void,
) -> HRESULT,
}}
RIDL!{#[ uuid(0 x035f3ab4, 0 x482e, 0 x4e50, 0 xb4, 0 x1f, 0 x8a, 0 x7f, 0 x8b, 0 xd8, 0 x96, 0 x0b)]
interface IDXGIResource(IDXGIResourceVtbl): IDXGIDeviceSubObject(IDXGIDeviceSubObjectVtbl) {
fn GetSharedHandle(
pSharedHandle: *mut HANDLE,
) -> HRESULT,
fn GetUsage(
pUsage: *mut DXGI_USAGE,
) -> HRESULT,
fn SetEvictionPriority(
EvictionPriority: UINT,
) -> HRESULT,
fn GetEvictionPriority(
pEvictionPriority: *mut UINT,
) -> HRESULT,
}}
RIDL!{#[ uuid(0 x9d8e1289, 0 xd7b3, 0 x465f, 0 x81, 0 x26, 0 x25, 0 x0e, 0 x34, 0 x9a, 0 xf8, 0 x5d)]
interface IDXGIKeyedMutex(IDXGIKeyedMutexVtbl): IDXGIDeviceSubObject(IDXGIDeviceSubObjectVtbl) {
fn AcquireSync(
Key: UINT64,
dwMilliseconds: DWORD,
) -> HRESULT,
fn ReleaseSync(
Key: UINT64,
) -> HRESULT,
}}
pub const DXGI_MAP_READ: UINT = 1 ;
pub const DXGI_MAP_WRITE: UINT = 2 ;
pub const DXGI_MAP_DISCARD: UINT = 4 ;
RIDL!{#[ uuid(0 xcafcb56c, 0 x6ac3, 0 x4889, 0 xbf, 0 x47, 0 x9e, 0 x23, 0 xbb, 0 xd2, 0 x60, 0 xec)]
interface IDXGISurface(IDXGISurfaceVtbl): IDXGIDeviceSubObject(IDXGIDeviceSubObjectVtbl) {
fn GetDesc(
pDesc: *mut DXGI_SURFACE_DESC,
) -> HRESULT,
fn Map(
pLockedRect: *mut DXGI_MAPPED_RECT,
MapFlags: UINT,
) -> HRESULT,
fn Unmap() -> HRESULT,
}}
RIDL!{#[ uuid(0 x4ae63092, 0 x6327, 0 x4c1b, 0 x80, 0 xae, 0 xbf, 0 xe1, 0 x2e, 0 xa3, 0 x2b, 0 x86)]
interface IDXGISurface1(IDXGISurface1Vtbl): IDXGISurface(IDXGISurfaceVtbl) {
fn GetDC(
Discard: BOOL,
phdc: *mut HDC,
) -> HRESULT,
fn ReleaseDC(
pDirtyRect: *mut RECT,
) -> HRESULT,
}}
RIDL!{#[ uuid(0 x2411e7e1, 0 x12ac, 0 x4ccf, 0 xbd, 0 x14, 0 x97, 0 x98, 0 xe8, 0 x53, 0 x4d, 0 xc0)]
interface IDXGIAdapter(IDXGIAdapterVtbl): IDXGIObject(IDXGIObjectVtbl) {
fn EnumOutputs(
Output: UINT,
ppOutput: *mut *mut IDXGIOutput,
) -> HRESULT,
fn GetDesc(
pDesc: *mut DXGI_ADAPTER_DESC,
) -> HRESULT,
fn CheckInterfaceSupport(
InterfaceName: REFGUID,
pUMDVersion: *mut LARGE_INTEGER,
) -> HRESULT,
}}
RIDL!{#[ uuid(0 xae02eedb, 0 xc735, 0 x4690, 0 x8d, 0 x52, 0 x5a, 0 x8d, 0 xc2, 0 x02, 0 x13, 0 xaa)]
interface IDXGIOutput(IDXGIOutputVtbl): IDXGIObject(IDXGIObjectVtbl) {
fn GetDesc(
pDesc: *mut DXGI_OUTPUT_DESC,
) -> HRESULT,
fn GetDisplayModeList(
EnumFormat: DXGI_FORMAT,
Flags: UINT,
pNumModes: *mut UINT,
pDesc: *mut DXGI_MODE_DESC,
) -> HRESULT,
fn FindClosestMatchingMode(
pModeToMatch: *const DXGI_MODE_DESC,
pClosestMatch: *mut DXGI_MODE_DESC,
pConcernedDevice: *mut IUnknown,
) -> HRESULT,
fn WaitForVBlank() -> HRESULT,
fn TakeOwnership(
pDevice: *mut IUnknown,
Exclusive: BOOL,
) -> HRESULT,
fn ReleaseOwnership() -> (),
fn GetGammaControlCapabilities(
pGammaCaps: *mut DXGI_GAMMA_CONTROL_CAPABILITIES,
) -> HRESULT,
fn SetGammaControl(
pArray: *const DXGI_GAMMA_CONTROL,
) -> HRESULT,
fn GetGammaControl(
pArray: *mut DXGI_GAMMA_CONTROL,
) -> HRESULT,
fn SetDisplaySurface(
pScanoutSurface: *mut IDXGISurface,
) -> HRESULT,
fn GetDisplaySurfaceData(
pDestination: *mut IDXGISurface,
) -> HRESULT,
fn GetFrameStatistics(
pStats: *mut DXGI_FRAME_STATISTICS,
) -> HRESULT,
}}
pub const DXGI_MAX_SWAP_CHAIN_BUFFERS: DWORD = 16 ;
pub const DXGI_PRESENT_TEST: DWORD = 0 x00000001;
pub const DXGI_PRESENT_DO_NOT_SEQUENCE: DWORD = 0 x00000002;
pub const DXGI_PRESENT_RESTART: DWORD = 0 x00000004;
pub const DXGI_PRESENT_DO_NOT_WAIT: DWORD = 0 x00000008;
pub const DXGI_PRESENT_STEREO_PREFER_RIGHT: DWORD = 0 x00000010;
pub const DXGI_PRESENT_STEREO_TEMPORARY_MONO: DWORD = 0 x00000020;
pub const DXGI_PRESENT_RESTRICT_TO_OUTPUT: DWORD = 0 x00000040;
pub const DXGI_PRESENT_USE_DURATION: DWORD = 0 x00000100;
pub const DXGI_PRESENT_ALLOW_TEARING: DWORD = 0 x00000200;
pub const DXGI_ENUM_MODES_INTERLACED: UINT = 1 ;
pub const DXGI_ENUM_MODES_SCALING: UINT = 2 ;
RIDL!{#[ uuid(0 x310d36a0, 0 xd2e7, 0 x4c0a, 0 xaa, 0 x04, 0 x6a, 0 x9d, 0 x23, 0 xb8, 0 x88, 0 x6a)]
interface IDXGISwapChain(IDXGISwapChainVtbl): IDXGIDeviceSubObject(IDXGIDeviceSubObjectVtbl) {
fn Present(
SyncInterval: UINT,
Flags: UINT,
) -> HRESULT,
fn GetBuffer(
Buffer: UINT,
riid: REFIID,
ppSurface: *mut *mut c_void,
) -> HRESULT,
fn SetFullscreenState(
Fullscreen: BOOL,
pTarget: *mut IDXGIOutput,
) -> HRESULT,
fn GetFullscreenState(
pFullscreen: *mut BOOL,
ppTarget: *mut *mut IDXGIOutput,
) -> HRESULT,
fn GetDesc(
pDesc: *mut DXGI_SWAP_CHAIN_DESC,
) -> HRESULT,
fn ResizeBuffers(
BufferCount: UINT,
Width: UINT,
Height: UINT,
NewFormat: DXGI_FORMAT,
SwapChainFlags: UINT,
) -> HRESULT,
fn ResizeTarget(
pNewTargetParameters: *const DXGI_MODE_DESC,
) -> HRESULT,
fn GetContainingOutput(
ppOutput: *mut *mut IDXGIOutput,
) -> HRESULT,
fn GetFrameStatistics(
pStats: *mut DXGI_FRAME_STATISTICS,
) -> HRESULT,
fn GetLastPresentCount(
pLastPresentCount: *mut UINT,
) -> HRESULT,
}}
RIDL!{#[ uuid(0 x7b7166ec, 0 x21c7, 0 x44ae, 0 xb2, 0 x1a, 0 xc9, 0 xae, 0 x32, 0 x1a, 0 xe3, 0 x69)]
interface IDXGIFactory(IDXGIFactoryVtbl): IDXGIObject(IDXGIObjectVtbl) {
fn EnumAdapters(
Adapter: UINT,
ppAdapter: *mut *mut IDXGIAdapter,
) -> HRESULT,
fn MakeWindowAssociation(
WindowHandle: HWND,
Flags: UINT,
) -> HRESULT,
fn GetWindowAssociation(
pWindowHandle: *mut HWND,
) -> HRESULT,
fn CreateSwapChain(
pDevice: *mut IUnknown,
pDesc: *mut DXGI_SWAP_CHAIN_DESC,
ppSwapChain: *mut *mut IDXGISwapChain,
) -> HRESULT,
fn CreateSoftwareAdapter(
Module: HMODULE,
ppAdapter: *mut *mut IDXGIAdapter,
) -> HRESULT,
}}
extern "system" {
pub fn CreateDXGIFactory(
riid: REFIID,
ppFactory: *mut *mut c_void,
) -> HRESULT;
pub fn CreateDXGIFactory1(
riid: REFIID,
ppFactory: *mut *mut c_void,
) -> HRESULT;
}
RIDL!{#[ uuid(0 x54ec77fa, 0 x1377, 0 x44e6, 0 x8c, 0 x32, 0 x88, 0 xfd, 0 x5f, 0 x44, 0 xc8, 0 x4c)]
interface IDXGIDevice(IDXGIDeviceVtbl): IDXGIObject(IDXGIObjectVtbl) {
fn GetAdapter(
pAdapter: *mut *mut IDXGIAdapter,
) -> HRESULT,
fn CreateSurface(
pDesc: *const DXGI_SURFACE_DESC,
NumSurfaces: UINT,
Usage: DXGI_USAGE,
pSharedResource: *const DXGI_SHARED_RESOURCE,
ppSurface: *mut *mut IDXGISurface,
) -> HRESULT,
fn QueryResourceResidency(
ppResources: *const *mut IUnknown,
pResidencyStatus: *mut DXGI_RESIDENCY,
NumResources: UINT,
) -> HRESULT,
fn SetGPUThreadPriority(
Priority: INT,
) -> HRESULT,
fn GetGPUThreadPriority(
pPriority: *mut INT,
) -> HRESULT,
}}
ENUM !{enum DXGI_ADAPTER_FLAG {
DXGI_ADAPTER_FLAG_NONE,
DXGI_ADAPTER_FLAG_REMOTE,
DXGI_ADAPTER_FLAG_SOFTWARE,
}}
STRUCT !{struct DXGI_ADAPTER_DESC1 {
Description: [WCHAR; 128 ],
VendorId: UINT,
DeviceId: UINT,
SubSysId: UINT,
Revision: UINT,
DedicatedVideoMemory: SIZE_T,
DedicatedSystemMemory: SIZE_T,
SharedSystemMemory: SIZE_T,
AdapterLuid: LUID,
Flags: UINT,
}}
STRUCT !{struct DXGI_DISPLAY_COLOR_SPACE {
PrimaryCoordinates: [[FLOAT; 2 ]; 8 ],
WhitePoints: [[FLOAT; 2 ]; 16 ],
}}
RIDL!{#[ uuid(0 x770aae78, 0 xf26f, 0 x4dba, 0 xa8, 0 x29, 0 x25, 0 x3c, 0 x83, 0 xd1, 0 xb3, 0 x87)]
interface IDXGIFactory1(IDXGIFactory1Vtbl): IDXGIFactory(IDXGIFactoryVtbl) {
fn EnumAdapters1(
Adapter: UINT,
ppAdapter: *mut *mut IDXGIAdapter1,
) -> HRESULT,
fn IsCurrent() -> BOOL,
}}
RIDL!{#[ uuid(0 x29038f61, 0 x3839, 0 x4626, 0 x91, 0 xfd, 0 x08, 0 x68, 0 x79, 0 x01, 0 x1a, 0 x05)]
interface IDXGIAdapter1(IDXGIAdapter1Vtbl): IDXGIAdapter(IDXGIAdapterVtbl) {
fn GetDesc1(
pDesc: *mut DXGI_ADAPTER_DESC1,
) -> HRESULT,
}}
RIDL!{#[ uuid(0 x77db970f, 0 x6276, 0 x48ba, 0 xba, 0 x28, 0 x07, 0 x01, 0 x43, 0 xb4, 0 x39, 0 x2c)]
interface IDXGIDevice1(IDXGIDevice1Vtbl): IDXGIDevice(IDXGIDeviceVtbl) {
fn SetMaximumFrameLatency(
MaxLatency: UINT,
) -> HRESULT,
fn GetMaximumFrameLatency(
pMaxLatency: *mut UINT,
) -> HRESULT,
}}
DEFINE_GUID!{IID_IDXGIObject,
0 xaec22fb8, 0 x76f3, 0 x4639, 0 x9b, 0 xe0, 0 x28, 0 xeb, 0 x43, 0 xa6, 0 x7a, 0 x2e}
DEFINE_GUID!{IID_IDXGIDeviceSubObject,
0 x3d3e0379, 0 xf9de, 0 x4d58, 0 xbb, 0 x6c, 0 x18, 0 xd6, 0 x29, 0 x92, 0 xf1, 0 xa6}
DEFINE_GUID!{IID_IDXGIResource,
0 x035f3ab4, 0 x482e, 0 x4e50, 0 xb4, 0 x1f, 0 x8a, 0 x7f, 0 x8b, 0 xd8, 0 x96, 0 x0b}
DEFINE_GUID!{IID_IDXGIKeyedMutex,
0 x9d8e1289, 0 xd7b3, 0 x465f, 0 x81, 0 x26, 0 x25, 0 x0e, 0 x34, 0 x9a, 0 xf8, 0 x5d}
DEFINE_GUID!{IID_IDXGISurface,
0 xcafcb56c, 0 x6ac3, 0 x4889, 0 xbf, 0 x47, 0 x9e, 0 x23, 0 xbb, 0 xd2, 0 x60, 0 xec}
DEFINE_GUID!{IID_IDXGISurface1,
0 x4ae63092, 0 x6327, 0 x4c1b, 0 x80, 0 xae, 0 xbf, 0 xe1, 0 x2e, 0 xa3, 0 x2b, 0 x86}
DEFINE_GUID!{IID_IDXGIAdapter,
0 x2411e7e1, 0 x12ac, 0 x4ccf, 0 xbd, 0 x14, 0 x97, 0 x98, 0 xe8, 0 x53, 0 x4d, 0 xc0}
DEFINE_GUID!{IID_IDXGIOutput,
0 xae02eedb, 0 xc735, 0 x4690, 0 x8d, 0 x52, 0 x5a, 0 x8d, 0 xc2, 0 x02, 0 x13, 0 xaa}
DEFINE_GUID!{IID_IDXGISwapChain,
0 x310d36a0, 0 xd2e7, 0 x4c0a, 0 xaa, 0 x04, 0 x6a, 0 x9d, 0 x23, 0 xb8, 0 x88, 0 x6a}
DEFINE_GUID!{IID_IDXGIFactory,
0 x7b7166ec, 0 x21c7, 0 x44ae, 0 xb2, 0 x1a, 0 xc9, 0 xae, 0 x32, 0 x1a, 0 xe3, 0 x69}
DEFINE_GUID!{IID_IDXGIDevice,
0 x54ec77fa, 0 x1377, 0 x44e6, 0 x8c, 0 x32, 0 x88, 0 xfd, 0 x5f, 0 x44, 0 xc8, 0 x4c}
DEFINE_GUID!{IID_IDXGIFactory1,
0 x770aae78, 0 xf26f, 0 x4dba, 0 xa8, 0 x29, 0 x25, 0 x3c, 0 x83, 0 xd1, 0 xb3, 0 x87}
DEFINE_GUID!{IID_IDXGIAdapter1,
0 x29038f61, 0 x3839, 0 x4626, 0 x91, 0 xfd, 0 x08, 0 x68, 0 x79, 0 x01, 0 x1a, 0 x05}
DEFINE_GUID!{IID_IDXGIDevice1,
0 x77db970f, 0 x6276, 0 x48ba, 0 xba, 0 x28, 0 x07, 0 x01, 0 x43, 0 xb4, 0 x39, 0 x2c}
Messung V0.5 in Prozent C=95 H=100 G=97
¤ Dauer der Verarbeitung: 0.14 Sekunden
(vorverarbeitet am 2026-06-18)
¤
*© Formatika GbR, Deutschland