using System;
using System.Runtime.InteropServices;
namespace Vanara.PInvoke
{
// TODO: Move once DXGI lib is done
/// Items from the DXGI.dll
public static partial class DXGI
{
/// The IDXGIAdapter interface represents a display subsystem (including one or more GPUs, DACs and video memory).
///
///
/// A display subsystem is often referred to as a video card, however, on some machines the display subsystem is part of the motherboard.
///
/// To enumerate the display subsystems, use IDXGIFactory::EnumAdapters.
/// To get an interface to the adapter for a particular device, use IDXGIDevice::GetAdapter.
/// To create a software adapter, use IDXGIFactory::CreateSoftwareAdapter.
/// Windows Phone 8: This API is supported.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nn-dxgi-idxgiadapter
[PInvokeData("dxgi.h")]
[ComImport, Guid("2411e7e1-12ac-4ccf-bd14-9798e8534dc0"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IDXGIAdapter : IDXGIObject
{
/// Sets application-defined data to the object and associates that data with a GUID.
///
/// Type: REFGUID
/// A GUID that identifies the data. Use this GUID in a call to GetPrivateData to get the data.
///
///
/// Type: UINT
/// The size of the object's data.
///
///
/// Type: const void*
/// A pointer to the object's data.
///
///
/// Type: HRESULT
/// Returns one of the DXGI_ERROR values.
///
///
/// SetPrivateData makes a copy of the specified data and stores it with the object.
///
/// Private data that SetPrivateData stores in the object occupies the same storage space as private data that is stored
/// by associated Direct3D objects (for example, by a Microsoft Direct3D 11 device through ID3D11Device::SetPrivateData or by a
/// Direct3D 11 child device through ID3D11DeviceChild::SetPrivateData).
///
///
/// The debug layer reports memory leaks by outputting a list of object interface pointers along with their friendly names. The
/// default friendly name is "<unnamed>". You can set the friendly name so that you can determine if the corresponding
/// object interface pointer caused the leak. To set the friendly name, use the SetPrivateData method and the well-known
/// private data GUID ( WKPDID_D3DDebugObjectName) that is in D3Dcommon.h. For example, to give pContext a friendly name
/// of My name, use the following code:
///
///
/// You can use WKPDID_D3DDebugObjectName to track down memory leaks and understand performance characteristics of your
/// applications. This information is reflected in the output of the debug layer that is related to memory leaks
/// (ID3D11Debug::ReportLiveDeviceObjects) and with the event tracing for Windows events that we've added to Windows 8.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiobject-setprivatedata HRESULT SetPrivateData( REFGUID
// Name, UINT DataSize, const void *pData );
new void SetPrivateData(in Guid Name, uint DataSize, IntPtr pData);
/// Set an interface in the object's private data.
///
/// Type: REFGUID
/// A GUID identifying the interface.
///
///
/// Type: const IUnknown*
/// The interface to set.
///
///
/// Type: HRESULT
/// Returns one of the following DXGI_ERROR.
///
///
/// This API associates an interface pointer with the object.
///
/// When the interface is set its reference count is incremented. When the data are overwritten (by calling SPD or SPDI with the
/// same GUID) or the object is destroyed, ::Release() is called and the interface's reference count is decremented.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiobject-setprivatedatainterface HRESULT
// SetPrivateDataInterface( REFGUID Name, const IUnknown *pUnknown );
new void SetPrivateDataInterface(in Guid Name, [In, Optional, MarshalAs(UnmanagedType.IUnknown)] object pUnknown);
/// Get a pointer to the object's data.
///
/// Type: REFGUID
/// A GUID identifying the data.
///
///
/// Type: UINT*
/// The size of the data.
///
///
/// Type: void*
/// Pointer to the data.
///
///
/// Type: HRESULT
/// Returns one of the following DXGI_ERROR.
///
///
///
/// If the data returned is a pointer to an IUnknown, or one of its derivative classes, previously set by
/// IDXGIObject::SetPrivateDataInterface, you must call ::Release() on the pointer before the pointer is freed to decrement the
/// reference count.
///
///
/// You can pass GUID_DeviceType in the Name parameter of GetPrivateData to retrieve the device type from the
/// display adapter object (IDXGIAdapter, IDXGIAdapter1, IDXGIAdapter2).
///
/// To get the type of device on which the display adapter was created
///
/// -
/// Call IUnknown::QueryInterface on the ID3D11Device or ID3D10Device object to retrieve the IDXGIDevice object.
///
/// -
/// Call GetParent on the IDXGIDevice object to retrieve the IDXGIAdapter object.
///
/// -
///
/// Call GetPrivateData on the IDXGIAdapter object with GUID_DeviceType to retrieve the type of device on which
/// the display adapter was created. pData will point to a value from the driver-type enumeration (for example, a value from D3D_DRIVER_TYPE).
///
///
///
///
/// On Windows 7 or earlier, this type is either a value from D3D10_DRIVER_TYPE or D3D_DRIVER_TYPE depending on which kind of
/// device was created. On Windows 8, this type is always a value from D3D_DRIVER_TYPE. Don't use
/// IDXGIObject::SetPrivateData with GUID_DeviceType because the behavior when doing so is undefined.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiobject-getprivatedata HRESULT GetPrivateData( REFGUID
// Name, UINT *pDataSize, void *pData );
[PreserveSig]
new HRESULT GetPrivateData(in Guid Name, ref uint pDataSize, [Out] IntPtr pData);
/// Gets the parent of the object.
///
/// Type: REFIID
/// The ID of the requested interface.
///
///
/// Type: void**
/// The address of a pointer to the parent object.
///
///
/// Type: HRESULT
/// Returns one of the DXGI_ERROR values.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiobject-getparent HRESULT GetParent( REFIID riid, void
// **ppParent );
new void GetParent(in Guid riid, [MarshalAs(UnmanagedType.Interface)] out object ppParent);
/// Enumerate adapter (video card) outputs.
///
/// Type: UINT
/// The index of the output.
///
///
/// Type: IDXGIOutput**
/// The address of a pointer to an IDXGIOutput interface at the position specified by the Output parameter.
///
///
/// Note If you call this API in a Session 0 process, it returns DXGI_ERROR_NOT_CURRENTLY_AVAILABLE.
///
/// When the EnumOutputs method succeeds and fills the ppOutput parameter with the address of the pointer to the output
/// interface, EnumOutputs increments the output interface's reference count. To avoid a memory leak, when you finish
/// using the output interface, call the Release method to decrement the reference count.
///
///
/// EnumOutputs first returns the output on which the desktop primary is displayed. This output corresponds with an index
/// of zero. EnumOutputs then returns other outputs.
///
/// Examples
/// Enumerating Outputs
/// Here is an example of how to use EnumOutputs to enumerate all the outputs on an adapter:
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiadapter-enumoutputs HRESULT EnumOutputs( UINT Output,
// IDXGIOutput **ppOutput );
IDXGIOutput EnumOutputs(uint Output);
/// Gets a DXGI 1.0 description of an adapter (or video card).
///
/// Type: DXGI_ADAPTER_DESC*
///
/// A pointer to a DXGI_ADAPTER_DESC structure that describes the adapter. This parameter must not be NULL. On feature
/// level 9 graphics hardware, GetDesc returns zeros for the PCI ID in the VendorId, DeviceId,
/// SubSysId, and Revision members of DXGI_ADAPTER_DESC and “Software Adapter” for the description string
/// in the Description member.
///
///
///
///
/// Graphics apps can use the DXGI API to retrieve an accurate set of graphics memory values on systems that have Windows
/// Display Driver Model (WDDM) drivers. The following are the critical steps involved.
///
///
/// -
///
/// Graphics driver model determination —Because DXGI is only available on systems with WDDM drivers, the app must first confirm
/// the driver model by using the following API.
///
///
/// -
///
/// Retrieval of graphics memory values.—After the app determines the driver model to be WDDM, the app can use the Direct3D 10
/// or later API and DXGI to get the amount of graphics memory. After you create a Direct3D device, use this code to obtain a
/// DXGI_ADAPTER_DESC structure that contains the amount of available graphics memory.
///
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiadapter-getdesc HRESULT GetDesc( DXGI_ADAPTER_DESC
// *pDesc );
DXGI_ADAPTER_DESC GetDesc();
/// Checks whether the system supports a device interface for a graphics component.
///
/// Type: REFGUID
/// The GUID of the interface of the device version for which support is being checked. For example, __uuidof(ID3D10Device).
///
///
/// Type: LARGE_INTEGER*
///
/// The user mode driver version of InterfaceName. This is returned only if the interface is supported, otherwise this parameter
/// will be NULL.
///
///
///
/// Type: HRESULT
///
/// S_OK indicates that the interface is supported, otherwise DXGI_ERROR_UNSUPPORTED is returned (For more information, see DXGI_ERROR).
///
///
///
/// Note You can use CheckInterfaceSupport only to check whether a Direct3D 10.x interface is supported, and only
/// on Windows Vista SP1 and later versions of the operating system. If you try to use CheckInterfaceSupport to check
/// whether a Direct3D 11.x and later version interface is supported, CheckInterfaceSupport returns
/// DXGI_ERROR_UNSUPPORTED. Therefore, do not use CheckInterfaceSupport. Instead, to verify whether the operating system
/// supports a particular interface, try to create the interface. For example, if you call the ID3D11Device::CreateBlendState
/// method and it fails, the operating system does not support the ID3D11BlendState interface.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiadapter-checkinterfacesupport HRESULT
// CheckInterfaceSupport( REFGUID InterfaceName, LARGE_INTEGER *pUMDVersion );
[PreserveSig]
HRESULT CheckInterfaceSupport(in Guid InterfaceName, out long pUMDVersion);
}
///
/// The IDXGIAdapter1 interface represents a display sub-system (including one or more GPU's, DACs and video memory).
///
///
///
/// This interface is not supported by DXGI 1.0, which shipped in Windows Vista and Windows Server 2008. DXGI 1.1 support is
/// required, which is available on Windows 7, Windows Server 2008 R2, and as an update to Windows Vista with Service Pack 2 (SP2)
/// (KB 971644) and Windows Server 2008 (KB 971512).
///
///
/// A display sub-system is often referred to as a video card, however, on some machines the display sub-system is part of the
/// mother board.
///
///
/// To enumerate the display sub-systems, use IDXGIFactory1::EnumAdapters1. To get an interface to the adapter for a particular
/// device, use IDXGIDevice::GetAdapter. To create a software adapter, use IDXGIFactory::CreateSoftwareAdapter.
///
/// Windows Phone 8: This API is supported.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nn-dxgi-idxgiadapter1
[PInvokeData("dxgi.h", MSDNShortId = "003d5a10-e978-481f-8ca6-9e5ab69bfec0")]
[ComImport, Guid("29038f61-3839-4626-91fd-086879011a05"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IDXGIAdapter1 : IDXGIAdapter
{
/// Sets application-defined data to the object and associates that data with a GUID.
///
/// Type: REFGUID
/// A GUID that identifies the data. Use this GUID in a call to GetPrivateData to get the data.
///
///
/// Type: UINT
/// The size of the object's data.
///
///
/// Type: const void*
/// A pointer to the object's data.
///
///
/// Type: HRESULT
/// Returns one of the DXGI_ERROR values.
///
///
/// SetPrivateData makes a copy of the specified data and stores it with the object.
///
/// Private data that SetPrivateData stores in the object occupies the same storage space as private data that is stored
/// by associated Direct3D objects (for example, by a Microsoft Direct3D 11 device through ID3D11Device::SetPrivateData or by a
/// Direct3D 11 child device through ID3D11DeviceChild::SetPrivateData).
///
///
/// The debug layer reports memory leaks by outputting a list of object interface pointers along with their friendly names. The
/// default friendly name is "<unnamed>". You can set the friendly name so that you can determine if the corresponding
/// object interface pointer caused the leak. To set the friendly name, use the SetPrivateData method and the well-known
/// private data GUID ( WKPDID_D3DDebugObjectName) that is in D3Dcommon.h. For example, to give pContext a friendly name
/// of My name, use the following code:
///
///
/// You can use WKPDID_D3DDebugObjectName to track down memory leaks and understand performance characteristics of your
/// applications. This information is reflected in the output of the debug layer that is related to memory leaks
/// (ID3D11Debug::ReportLiveDeviceObjects) and with the event tracing for Windows events that we've added to Windows 8.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiobject-setprivatedata HRESULT SetPrivateData( REFGUID
// Name, UINT DataSize, const void *pData );
new void SetPrivateData(in Guid Name, uint DataSize, IntPtr pData);
/// Set an interface in the object's private data.
///
/// Type: REFGUID
/// A GUID identifying the interface.
///
///
/// Type: const IUnknown*
/// The interface to set.
///
///
/// Type: HRESULT
/// Returns one of the following DXGI_ERROR.
///
///
/// This API associates an interface pointer with the object.
///
/// When the interface is set its reference count is incremented. When the data are overwritten (by calling SPD or SPDI with the
/// same GUID) or the object is destroyed, ::Release() is called and the interface's reference count is decremented.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiobject-setprivatedatainterface HRESULT
// SetPrivateDataInterface( REFGUID Name, const IUnknown *pUnknown );
new void SetPrivateDataInterface(in Guid Name, [In, Optional, MarshalAs(UnmanagedType.IUnknown)] object pUnknown);
/// Get a pointer to the object's data.
///
/// Type: REFGUID
/// A GUID identifying the data.
///
///
/// Type: UINT*
/// The size of the data.
///
///
/// Type: void*
/// Pointer to the data.
///
///
/// Type: HRESULT
/// Returns one of the following DXGI_ERROR.
///
///
///
/// If the data returned is a pointer to an IUnknown, or one of its derivative classes, previously set by
/// IDXGIObject::SetPrivateDataInterface, you must call ::Release() on the pointer before the pointer is freed to decrement the
/// reference count.
///
///
/// You can pass GUID_DeviceType in the Name parameter of GetPrivateData to retrieve the device type from the
/// display adapter object (IDXGIAdapter, IDXGIAdapter1, IDXGIAdapter2).
///
/// To get the type of device on which the display adapter was created
///
/// -
/// Call IUnknown::QueryInterface on the ID3D11Device or ID3D10Device object to retrieve the IDXGIDevice object.
///
/// -
/// Call GetParent on the IDXGIDevice object to retrieve the IDXGIAdapter object.
///
/// -
///
/// Call GetPrivateData on the IDXGIAdapter object with GUID_DeviceType to retrieve the type of device on which
/// the display adapter was created. pData will point to a value from the driver-type enumeration (for example, a value from D3D_DRIVER_TYPE).
///
///
///
///
/// On Windows 7 or earlier, this type is either a value from D3D10_DRIVER_TYPE or D3D_DRIVER_TYPE depending on which kind of
/// device was created. On Windows 8, this type is always a value from D3D_DRIVER_TYPE. Don't use
/// IDXGIObject::SetPrivateData with GUID_DeviceType because the behavior when doing so is undefined.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiobject-getprivatedata HRESULT GetPrivateData( REFGUID
// Name, UINT *pDataSize, void *pData );
[PreserveSig]
new HRESULT GetPrivateData(in Guid Name, ref uint pDataSize, [Out] IntPtr pData);
/// Gets the parent of the object.
///
/// Type: REFIID
/// The ID of the requested interface.
///
///
/// Type: void**
/// The address of a pointer to the parent object.
///
///
/// Type: HRESULT
/// Returns one of the DXGI_ERROR values.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiobject-getparent HRESULT GetParent( REFIID riid, void
// **ppParent );
new void GetParent(in Guid riid, [MarshalAs(UnmanagedType.Interface)] out object ppParent);
/// Enumerate adapter (video card) outputs.
///
/// Type: UINT
/// The index of the output.
///
///
/// Type: IDXGIOutput**
/// The address of a pointer to an IDXGIOutput interface at the position specified by the Output parameter.
///
///
/// Note If you call this API in a Session 0 process, it returns DXGI_ERROR_NOT_CURRENTLY_AVAILABLE.
///
/// When the EnumOutputs method succeeds and fills the ppOutput parameter with the address of the pointer to the output
/// interface, EnumOutputs increments the output interface's reference count. To avoid a memory leak, when you finish
/// using the output interface, call the Release method to decrement the reference count.
///
///
/// EnumOutputs first returns the output on which the desktop primary is displayed. This output corresponds with an index
/// of zero. EnumOutputs then returns other outputs.
///
/// Examples
/// Enumerating Outputs
/// Here is an example of how to use EnumOutputs to enumerate all the outputs on an adapter:
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiadapter-enumoutputs HRESULT EnumOutputs( UINT Output,
// IDXGIOutput **ppOutput );
new IDXGIOutput EnumOutputs(uint Output);
/// Gets a DXGI 1.0 description of an adapter (or video card).
///
/// Type: DXGI_ADAPTER_DESC*
///
/// A pointer to a DXGI_ADAPTER_DESC structure that describes the adapter. This parameter must not be NULL. On feature
/// level 9 graphics hardware, GetDesc returns zeros for the PCI ID in the VendorId, DeviceId,
/// SubSysId, and Revision members of DXGI_ADAPTER_DESC and “Software Adapter” for the description string
/// in the Description member.
///
///
///
///
/// Graphics apps can use the DXGI API to retrieve an accurate set of graphics memory values on systems that have Windows
/// Display Driver Model (WDDM) drivers. The following are the critical steps involved.
///
///
/// -
///
/// Graphics driver model determination —Because DXGI is only available on systems with WDDM drivers, the app must first confirm
/// the driver model by using the following API.
///
///
/// -
///
/// Retrieval of graphics memory values.—After the app determines the driver model to be WDDM, the app can use the Direct3D 10
/// or later API and DXGI to get the amount of graphics memory. After you create a Direct3D device, use this code to obtain a
/// DXGI_ADAPTER_DESC structure that contains the amount of available graphics memory.
///
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiadapter-getdesc HRESULT GetDesc( DXGI_ADAPTER_DESC
// *pDesc );
new DXGI_ADAPTER_DESC GetDesc();
/// Checks whether the system supports a device interface for a graphics component.
///
/// Type: REFGUID
/// The GUID of the interface of the device version for which support is being checked. For example, __uuidof(ID3D10Device).
///
///
/// Type: LARGE_INTEGER*
///
/// The user mode driver version of InterfaceName. This is returned only if the interface is supported, otherwise this parameter
/// will be NULL.
///
///
///
/// Type: HRESULT
///
/// S_OK indicates that the interface is supported, otherwise DXGI_ERROR_UNSUPPORTED is returned (For more information, see DXGI_ERROR).
///
///
///
/// Note You can use CheckInterfaceSupport only to check whether a Direct3D 10.x interface is supported, and only
/// on Windows Vista SP1 and later versions of the operating system. If you try to use CheckInterfaceSupport to check
/// whether a Direct3D 11.x and later version interface is supported, CheckInterfaceSupport returns
/// DXGI_ERROR_UNSUPPORTED. Therefore, do not use CheckInterfaceSupport. Instead, to verify whether the operating system
/// supports a particular interface, try to create the interface. For example, if you call the ID3D11Device::CreateBlendState
/// method and it fails, the operating system does not support the ID3D11BlendState interface.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiadapter-checkinterfacesupport HRESULT
// CheckInterfaceSupport( REFGUID InterfaceName, LARGE_INTEGER *pUMDVersion );
[PreserveSig]
new HRESULT CheckInterfaceSupport(in Guid InterfaceName, out long pUMDVersion);
/// Gets a DXGI 1.1 description of an adapter (or video card).
///
/// Type: DXGI_ADAPTER_DESC1*
///
/// A pointer to a DXGI_ADAPTER_DESC1 structure that describes the adapter. This parameter must not be NULL. On feature
/// level 9 graphics hardware, GetDesc1 returns zeros for the PCI ID in the VendorId, DeviceId,
/// SubSysId, and Revision members of DXGI_ADAPTER_DESC1 and “Software Adapter” for the description string
/// in the Description member.
///
///
///
///
/// This method is not supported by DXGI 1.0, which shipped in Windows Vista and Windows Server 2008. DXGI 1.1 support is
/// required, which is available on Windows 7, Windows Server 2008 R2, and as an update to Windows Vista with Service Pack 2
/// (SP2) (KB 971644) and Windows Server 2008 (KB 971512).
///
///
/// Use the GetDesc1 method to get a DXGI 1.1 description of an adapter. To get a DXGI 1.0 description, use the
/// IDXGIAdapter method.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiadapter1-getdesc1 HRESULT GetDesc1( DXGI_ADAPTER_DESC1
// *pDesc );
DXGI_ADAPTER_DESC1 GetDesc1();
}
/// An IDXGIDevice interface implements a derived class for DXGI objects that produce image data.
///
///
/// The IDXGIDevice interface is designed for use by DXGI objects that need access to other DXGI objects. This interface is
/// useful to applications that do not use Direct3D to communicate with DXGI.
///
///
/// The Direct3D create device functions return a Direct3D device object. This Direct3D device object implements the IUnknown
/// interface. You can query this Direct3D device object for the device's corresponding IDXGIDevice interface. To retrieve
/// the IDXGIDevice interface of a Direct3D device, use the following code:
///
/// Windows Phone 8: This API is supported.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nn-dxgi-idxgidevice
[PInvokeData("dxgi.h")]
[ComImport, Guid("54ec77fa-1377-44e6-8c32-88fd5f44c84c"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IDXGIDevice : IDXGIObject
{
/// Sets application-defined data to the object and associates that data with a GUID.
///
/// Type: REFGUID
/// A GUID that identifies the data. Use this GUID in a call to GetPrivateData to get the data.
///
///
/// Type: UINT
/// The size of the object's data.
///
///
/// Type: const void*
/// A pointer to the object's data.
///
///
/// Type: HRESULT
/// Returns one of the DXGI_ERROR values.
///
///
/// SetPrivateData makes a copy of the specified data and stores it with the object.
///
/// Private data that SetPrivateData stores in the object occupies the same storage space as private data that is stored
/// by associated Direct3D objects (for example, by a Microsoft Direct3D 11 device through ID3D11Device::SetPrivateData or by a
/// Direct3D 11 child device through ID3D11DeviceChild::SetPrivateData).
///
///
/// The debug layer reports memory leaks by outputting a list of object interface pointers along with their friendly names. The
/// default friendly name is "<unnamed>". You can set the friendly name so that you can determine if the corresponding
/// object interface pointer caused the leak. To set the friendly name, use the SetPrivateData method and the well-known
/// private data GUID ( WKPDID_D3DDebugObjectName) that is in D3Dcommon.h. For example, to give pContext a friendly name
/// of My name, use the following code:
///
///
/// You can use WKPDID_D3DDebugObjectName to track down memory leaks and understand performance characteristics of your
/// applications. This information is reflected in the output of the debug layer that is related to memory leaks
/// (ID3D11Debug::ReportLiveDeviceObjects) and with the event tracing for Windows events that we've added to Windows 8.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiobject-setprivatedata HRESULT SetPrivateData( REFGUID
// Name, UINT DataSize, const void *pData );
new void SetPrivateData(in Guid Name, uint DataSize, IntPtr pData);
/// Set an interface in the object's private data.
///
/// Type: REFGUID
/// A GUID identifying the interface.
///
///
/// Type: const IUnknown*
/// The interface to set.
///
///
/// Type: HRESULT
/// Returns one of the following DXGI_ERROR.
///
///
/// This API associates an interface pointer with the object.
///
/// When the interface is set its reference count is incremented. When the data are overwritten (by calling SPD or SPDI with the
/// same GUID) or the object is destroyed, ::Release() is called and the interface's reference count is decremented.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiobject-setprivatedatainterface HRESULT
// SetPrivateDataInterface( REFGUID Name, const IUnknown *pUnknown );
new void SetPrivateDataInterface(in Guid Name, [In, Optional, MarshalAs(UnmanagedType.IUnknown)] object pUnknown);
/// Get a pointer to the object's data.
///
/// Type: REFGUID
/// A GUID identifying the data.
///
///
/// Type: UINT*
/// The size of the data.
///
///
/// Type: void*
/// Pointer to the data.
///
///
/// Type: HRESULT
/// Returns one of the following DXGI_ERROR.
///
///
///
/// If the data returned is a pointer to an IUnknown, or one of its derivative classes, previously set by
/// IDXGIObject::SetPrivateDataInterface, you must call ::Release() on the pointer before the pointer is freed to decrement the
/// reference count.
///
///
/// You can pass GUID_DeviceType in the Name parameter of GetPrivateData to retrieve the device type from the
/// display adapter object (IDXGIAdapter, IDXGIAdapter1, IDXGIAdapter2).
///
/// To get the type of device on which the display adapter was created
///
/// -
/// Call IUnknown::QueryInterface on the ID3D11Device or ID3D10Device object to retrieve the IDXGIDevice object.
///
/// -
/// Call GetParent on the IDXGIDevice object to retrieve the IDXGIAdapter object.
///
/// -
///
/// Call GetPrivateData on the IDXGIAdapter object with GUID_DeviceType to retrieve the type of device on which
/// the display adapter was created. pData will point to a value from the driver-type enumeration (for example, a value from D3D_DRIVER_TYPE).
///
///
///
///
/// On Windows 7 or earlier, this type is either a value from D3D10_DRIVER_TYPE or D3D_DRIVER_TYPE depending on which kind of
/// device was created. On Windows 8, this type is always a value from D3D_DRIVER_TYPE. Don't use
/// IDXGIObject::SetPrivateData with GUID_DeviceType because the behavior when doing so is undefined.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiobject-getprivatedata HRESULT GetPrivateData( REFGUID
// Name, UINT *pDataSize, void *pData );
[PreserveSig]
new HRESULT GetPrivateData(in Guid Name, ref uint pDataSize, [Out] IntPtr pData);
/// Gets the parent of the object.
///
/// Type: REFIID
/// The ID of the requested interface.
///
///
/// Type: void**
/// The address of a pointer to the parent object.
///
///
/// Type: HRESULT
/// Returns one of the DXGI_ERROR values.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiobject-getparent HRESULT GetParent( REFIID riid, void
// **ppParent );
new void GetParent(in Guid riid, [MarshalAs(UnmanagedType.Interface)] out object ppParent);
/// Returns the adapter for the specified device.
///
/// Type: IDXGIAdapter**
/// The address of an IDXGIAdapter interface pointer to the adapter. This parameter must not be NULL.
///
///
/// If the GetAdapter method succeeds, the reference count on the adapter interface will be incremented. To avoid a
/// memory leak, be sure to release the interface when you are finished using it.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgidevice-getadapter HRESULT GetAdapter( IDXGIAdapter
// **pAdapter );
IDXGIAdapter GetAdapter();
/// Returns a surface. This method is used internally and you should not call it directly in your application.
///
/// Type: const DXGI_SURFACE_DESC*
/// A pointer to a DXGI_SURFACE_DESC structure that describes the surface.
///
///
/// Type: UINT
/// The number of surfaces to create.
///
///
/// Type: DXGI_USAGE
/// A DXGI_USAGE flag that specifies how the surface is expected to be used.
///
///
/// Type: const *
///
/// An optional pointer to a DXGI_SHARED_RESOURCE structure that contains shared resource information for opening views of such resources.
///
///
///
/// Type: IDXGISurface**
/// The address of an IDXGISurface interface pointer to the first created surface.
///
///
///
/// The CreateSurface method creates a buffer to exchange data between one or more devices. It is used internally, and
/// you should not directly call it.
///
///
/// The runtime automatically creates an IDXGISurface interface when it creates a Direct3D resource object that represents a
/// surface. For example, the runtime creates an IDXGISurface interface when it calls ID3D11Device::CreateTexture2D or
/// ID3D10Device::CreateTexture2D to create a 2D texture. To retrieve the IDXGISurface interface that represents the 2D
/// texture surface, call ID3D11Texture2D::QueryInterface or ID3D10Texture2D::QueryInterface. In this call, you must pass
/// the identifier of IDXGISurface. If the 2D texture has only a single MIP-map level and does not consist of an array of
/// textures, QueryInterface succeeds and returns a pointer to the IDXGISurface interface pointer. Otherwise,
/// QueryInterface fails and does not return the pointer to IDXGISurface.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgidevice-createsurface HRESULT CreateSurface( const
// DXGI_SURFACE_DESC *pDesc, UINT NumSurfaces, DXGI_USAGE Usage, const DXGI_SHARED_RESOURCE *pSharedResource, IDXGISurface
// **ppSurface );
IDXGISurface CreateSurface(in DXGI_SURFACE_DESC pDesc, uint NumSurfaces, DXGI_USAGE Usage, [In, Optional] IntPtr pSharedResource);
/// Gets the residency status of an array of resources.
///
/// Type: IUnknown*
/// An array of IDXGIResource interfaces.
///
///
/// Type: DXGI_RESIDENCY*
///
/// An array of DXGI_RESIDENCY flags. Each element describes the residency status for corresponding element in the ppResources
/// argument array.
///
///
///
/// Type: UINT
/// The number of resources in the ppResources argument array and pResidencyStatus argument array.
///
///
/// Type: HRESULT
///
/// Returns S_OK if successful; otherwise, returns DXGI_ERROR_DEVICE_REMOVED, E_INVALIDARG, or E_POINTER (see Common HRESULT
/// Values and WinError.h for more information).
///
///
///
///
/// The information returned by the pResidencyStatus argument array describes the residency status at the time that the
/// QueryResourceResidency method was called.
///
/// Note The residency status will constantly change.
///
/// If you call the QueryResourceResidency method during a device removed state, the pResidencyStatus argument will
/// return the DXGI_RESIDENCY_RESIDENT_IN_SHARED_MEMORY flag.
///
/// Note This method should not be called every frame as it incurs a non-trivial amount of overhead.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgidevice-queryresourceresidency HRESULT
// QueryResourceResidency( IUnknown * const *ppResources, DXGI_RESIDENCY *pResidencyStatus, UINT NumResources );
void QueryResourceResidency([In] IntPtr[] ppResources, [Out] DXGI_RESIDENCY[] pResidencyStatus, uint NumResources);
/// Sets the GPU thread priority.
///
/// Type: INT
///
/// A value that specifies the required GPU thread priority. This value must be between -7 and 7, inclusive, where 0 represents
/// normal priority.
///
///
///
/// The values for the Priority parameter function as follows:
///
/// -
///
/// Positive values increase the likelihood that the GPU scheduler will grant GPU execution cycles to the device when rendering.
///
///
/// -
/// Negative values lessen the likelihood that the device will receive GPU execution cycles when devices compete for them.
///
/// -
/// The device is guaranteed to receive some GPU execution cycles at all settings.
///
///
///
/// To use the SetGPUThreadPriority method, you should have a comprehensive understanding of GPU scheduling. You should
/// profile your application to ensure that it behaves as intended. If used inappropriately, the SetGPUThreadPriority
/// method can impede rendering speed and result in a poor user experience.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgidevice-setgputhreadpriority HRESULT
// SetGPUThreadPriority( INT Priority );
void SetGPUThreadPriority(int Priority);
/// Gets the GPU thread priority.
///
/// Type: INT*
///
/// A pointer to a variable that receives a value that indicates the current GPU thread priority. The value will be between -7
/// and 7, inclusive, where 0 represents normal priority.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgidevice-getgputhreadpriority HRESULT
// GetGPUThreadPriority( INT *pPriority );
int GetGPUThreadPriority();
}
/// Inherited from objects that are tied to the device so that they can retrieve a pointer to it.
/// Windows Phone 8: This API is supported.
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nn-dxgi-idxgidevicesubobject
[ComImport, Guid("3d3e0379-f9de-4d58-bb6c-18d62992f1a6"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IDXGIDeviceSubObject : IDXGIObject
{
/// Sets application-defined data to the object and associates that data with a GUID.
///
/// Type: REFGUID
/// A GUID that identifies the data. Use this GUID in a call to GetPrivateData to get the data.
///
///
/// Type: UINT
/// The size of the object's data.
///
///
/// Type: const void*
/// A pointer to the object's data.
///
///
/// Type: HRESULT
/// Returns one of the DXGI_ERROR values.
///
///
/// SetPrivateData makes a copy of the specified data and stores it with the object.
///
/// Private data that SetPrivateData stores in the object occupies the same storage space as private data that is stored
/// by associated Direct3D objects (for example, by a Microsoft Direct3D 11 device through ID3D11Device::SetPrivateData or by a
/// Direct3D 11 child device through ID3D11DeviceChild::SetPrivateData).
///
///
/// The debug layer reports memory leaks by outputting a list of object interface pointers along with their friendly names. The
/// default friendly name is "<unnamed>". You can set the friendly name so that you can determine if the corresponding
/// object interface pointer caused the leak. To set the friendly name, use the SetPrivateData method and the well-known
/// private data GUID ( WKPDID_D3DDebugObjectName) that is in D3Dcommon.h. For example, to give pContext a friendly name
/// of My name, use the following code:
///
///
/// You can use WKPDID_D3DDebugObjectName to track down memory leaks and understand performance characteristics of your
/// applications. This information is reflected in the output of the debug layer that is related to memory leaks
/// (ID3D11Debug::ReportLiveDeviceObjects) and with the event tracing for Windows events that we've added to Windows 8.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiobject-setprivatedata HRESULT SetPrivateData( REFGUID
// Name, UINT DataSize, const void *pData );
new void SetPrivateData(in Guid Name, uint DataSize, IntPtr pData);
/// Set an interface in the object's private data.
///
/// Type: REFGUID
/// A GUID identifying the interface.
///
///
/// Type: const IUnknown*
/// The interface to set.
///
///
/// Type: HRESULT
/// Returns one of the following DXGI_ERROR.
///
///
/// This API associates an interface pointer with the object.
///
/// When the interface is set its reference count is incremented. When the data are overwritten (by calling SPD or SPDI with the
/// same GUID) or the object is destroyed, ::Release() is called and the interface's reference count is decremented.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiobject-setprivatedatainterface HRESULT
// SetPrivateDataInterface( REFGUID Name, const IUnknown *pUnknown );
new void SetPrivateDataInterface(in Guid Name, [In, Optional, MarshalAs(UnmanagedType.IUnknown)] object pUnknown);
/// Get a pointer to the object's data.
///
/// Type: REFGUID
/// A GUID identifying the data.
///
///
/// Type: UINT*
/// The size of the data.
///
///
/// Type: void*
/// Pointer to the data.
///
///
/// Type: HRESULT
/// Returns one of the following DXGI_ERROR.
///
///
///
/// If the data returned is a pointer to an IUnknown, or one of its derivative classes, previously set by
/// IDXGIObject::SetPrivateDataInterface, you must call ::Release() on the pointer before the pointer is freed to decrement the
/// reference count.
///
///
/// You can pass GUID_DeviceType in the Name parameter of GetPrivateData to retrieve the device type from the
/// display adapter object (IDXGIAdapter, IDXGIAdapter1, IDXGIAdapter2).
///
/// To get the type of device on which the display adapter was created
///
/// -
/// Call IUnknown::QueryInterface on the ID3D11Device or ID3D10Device object to retrieve the IDXGIDevice object.
///
/// -
/// Call GetParent on the IDXGIDevice object to retrieve the IDXGIAdapter object.
///
/// -
///
/// Call GetPrivateData on the IDXGIAdapter object with GUID_DeviceType to retrieve the type of device on which
/// the display adapter was created. pData will point to a value from the driver-type enumeration (for example, a value from D3D_DRIVER_TYPE).
///
///
///
///
/// On Windows 7 or earlier, this type is either a value from D3D10_DRIVER_TYPE or D3D_DRIVER_TYPE depending on which kind of
/// device was created. On Windows 8, this type is always a value from D3D_DRIVER_TYPE. Don't use
/// IDXGIObject::SetPrivateData with GUID_DeviceType because the behavior when doing so is undefined.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiobject-getprivatedata HRESULT GetPrivateData( REFGUID
// Name, UINT *pDataSize, void *pData );
[PreserveSig]
new HRESULT GetPrivateData(in Guid Name, ref uint pDataSize, [Out] IntPtr pData);
/// Gets the parent of the object.
///
/// Type: REFIID
/// The ID of the requested interface.
///
///
/// Type: void**
/// The address of a pointer to the parent object.
///
///
/// Type: HRESULT
/// Returns one of the DXGI_ERROR values.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiobject-getparent HRESULT GetParent( REFIID riid, void
// **ppParent );
new void GetParent(in Guid riid, [MarshalAs(UnmanagedType.Interface)] out object ppParent);
/// Retrieves the device.
///
/// Type: REFIID
/// The reference id for the device.
///
///
/// Type: void**
/// The address of a pointer to the device.
///
///
/// Type: HRESULT
/// A code that indicates success or failure (see DXGI_ERROR).
///
///
/// The type of interface that is returned can be any interface published by the device. For example, it could be an IDXGIDevice
/// * called pDevice, and therefore the REFIID would be obtained by calling __uuidof(pDevice).
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgidevicesubobject-getdevice HRESULT GetDevice( REFIID
// riid, void **ppDevice );
void GetDevice(in Guid riid, [MarshalAs(UnmanagedType.Interface)] out object ppDevice);
}
/// An IDXGIFactory interface implements methods for generating DXGI objects (which handle full screen transitions).
///
/// Create a factory by calling CreateDXGIFactory.
///
/// Because you can create a Direct3D device without creating a swap chain, you might need to retrieve the factory that is used to
/// create the device in order to create a swap chain. You can request the IDXGIDevice interface from the Direct3D device and then
/// use the IDXGIObject::GetParent method to locate the factory. The following code shows how.
///
/// Windows Phone 8: This API is supported.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nn-dxgi-idxgifactory
[PInvokeData("dxgi.h")]
[ComImport, Guid("7b7166ec-21c7-44ae-b21a-c9ae321ae369"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IDXGIFactory : IDXGIObject
{
/// Sets application-defined data to the object and associates that data with a GUID.
///
/// Type: REFGUID
/// A GUID that identifies the data. Use this GUID in a call to GetPrivateData to get the data.
///
///
/// Type: UINT
/// The size of the object's data.
///
///
/// Type: const void*
/// A pointer to the object's data.
///
///
/// Type: HRESULT
/// Returns one of the DXGI_ERROR values.
///
///
/// SetPrivateData makes a copy of the specified data and stores it with the object.
///
/// Private data that SetPrivateData stores in the object occupies the same storage space as private data that is stored
/// by associated Direct3D objects (for example, by a Microsoft Direct3D 11 device through ID3D11Device::SetPrivateData or by a
/// Direct3D 11 child device through ID3D11DeviceChild::SetPrivateData).
///
///
/// The debug layer reports memory leaks by outputting a list of object interface pointers along with their friendly names. The
/// default friendly name is "<unnamed>". You can set the friendly name so that you can determine if the corresponding
/// object interface pointer caused the leak. To set the friendly name, use the SetPrivateData method and the well-known
/// private data GUID ( WKPDID_D3DDebugObjectName) that is in D3Dcommon.h. For example, to give pContext a friendly name
/// of My name, use the following code:
///
///
/// You can use WKPDID_D3DDebugObjectName to track down memory leaks and understand performance characteristics of your
/// applications. This information is reflected in the output of the debug layer that is related to memory leaks
/// (ID3D11Debug::ReportLiveDeviceObjects) and with the event tracing for Windows events that we've added to Windows 8.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiobject-setprivatedata HRESULT SetPrivateData( REFGUID
// Name, UINT DataSize, const void *pData );
new void SetPrivateData(in Guid Name, uint DataSize, IntPtr pData);
/// Set an interface in the object's private data.
///
/// Type: REFGUID
/// A GUID identifying the interface.
///
///
/// Type: const IUnknown*
/// The interface to set.
///
///
/// Type: HRESULT
/// Returns one of the following DXGI_ERROR.
///
///
/// This API associates an interface pointer with the object.
///
/// When the interface is set its reference count is incremented. When the data are overwritten (by calling SPD or SPDI with the
/// same GUID) or the object is destroyed, ::Release() is called and the interface's reference count is decremented.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiobject-setprivatedatainterface HRESULT
// SetPrivateDataInterface( REFGUID Name, const IUnknown *pUnknown );
new void SetPrivateDataInterface(in Guid Name, [In, Optional, MarshalAs(UnmanagedType.IUnknown)] object pUnknown);
/// Get a pointer to the object's data.
///
/// Type: REFGUID
/// A GUID identifying the data.
///
///
/// Type: UINT*
/// The size of the data.
///
///
/// Type: void*
/// Pointer to the data.
///
///
/// Type: HRESULT
/// Returns one of the following DXGI_ERROR.
///
///
///
/// If the data returned is a pointer to an IUnknown, or one of its derivative classes, previously set by
/// IDXGIObject::SetPrivateDataInterface, you must call ::Release() on the pointer before the pointer is freed to decrement the
/// reference count.
///
///
/// You can pass GUID_DeviceType in the Name parameter of GetPrivateData to retrieve the device type from the
/// display adapter object (IDXGIAdapter, IDXGIAdapter1, IDXGIAdapter2).
///
/// To get the type of device on which the display adapter was created
///
/// -
/// Call IUnknown::QueryInterface on the ID3D11Device or ID3D10Device object to retrieve the IDXGIDevice object.
///
/// -
/// Call GetParent on the IDXGIDevice object to retrieve the IDXGIAdapter object.
///
/// -
///
/// Call GetPrivateData on the IDXGIAdapter object with GUID_DeviceType to retrieve the type of device on which
/// the display adapter was created. pData will point to a value from the driver-type enumeration (for example, a value from D3D_DRIVER_TYPE).
///
///
///
///
/// On Windows 7 or earlier, this type is either a value from D3D10_DRIVER_TYPE or D3D_DRIVER_TYPE depending on which kind of
/// device was created. On Windows 8, this type is always a value from D3D_DRIVER_TYPE. Don't use
/// IDXGIObject::SetPrivateData with GUID_DeviceType because the behavior when doing so is undefined.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiobject-getprivatedata HRESULT GetPrivateData( REFGUID
// Name, UINT *pDataSize, void *pData );
[PreserveSig]
new HRESULT GetPrivateData(in Guid Name, ref uint pDataSize, [Out] IntPtr pData);
/// Gets the parent of the object.
///
/// Type: REFIID
/// The ID of the requested interface.
///
///
/// Type: void**
/// The address of a pointer to the parent object.
///
///
/// Type: HRESULT
/// Returns one of the DXGI_ERROR values.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiobject-getparent HRESULT GetParent( REFIID riid, void
// **ppParent );
new void GetParent(in Guid riid, [MarshalAs(UnmanagedType.Interface)] out object ppParent);
/// Enumerates the adapters (video cards).
///
/// Type: UINT
/// The index of the adapter to enumerate.
///
///
/// Type: IDXGIAdapter**
///
/// The address of a pointer to an IDXGIAdapter interface at the position specified by the Adapter parameter. This parameter
/// must not be NULL.
///
///
///
///
/// When you create a factory, the factory enumerates the set of adapters that are available in the system. Therefore, if you
/// change the adapters in a system, you must destroy and recreate the IDXGIFactory object. The number of adapters in a system
/// changes when you add or remove a display card, or dock or undock a laptop.
///
///
/// When the EnumAdapters method succeeds and fills the ppAdapter parameter with the address of the pointer to the
/// adapter interface, EnumAdapters increments the adapter interface's reference count. When you finish using the adapter
/// interface, call the Release method to decrement the reference count before you destroy the pointer.
///
///
/// EnumAdapters first returns the adapter with the output on which the desktop primary is displayed. This adapter
/// corresponds with an index of zero. EnumAdapters next returns other adapters with outputs. EnumAdapters finally
/// returns adapters without outputs.
///
/// Examples
/// Enumerating Adapters
/// The following code example demonstrates how to enumerate adapters using the EnumAdapters method.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgifactory-enumadapters HRESULT EnumAdapters( UINT Adapter,
// IDXGIAdapter **ppAdapter );
IDXGIAdapter EnumAdapters(uint Adapter);
///
/// Allows DXGI to monitor an application's message queue for the alt-enter key sequence (which causes the application to switch
/// from windowed to full screen or vice versa).
///
///
/// Type: HWND
///
/// The handle of the window that is to be monitored. This parameter can be NULL; but only if the flags are also 0.
///
///
///
/// Type: UINT
/// One or more of the following values:
///
/// -
///
/// DXGI_MWA_NO_WINDOW_CHANGES - Prevent DXGI from monitoring an applications message queue; this makes DXGI unable to respond
/// to mode changes.
///
///
/// -
/// DXGI_MWA_NO_ALT_ENTER - Prevent DXGI from responding to an alt-enter sequence.
///
/// -
/// DXGI_MWA_NO_PRINT_SCREEN - Prevent DXGI from responding to a print-screen key.
///
///
///
///
/// Note If you call this API in a Session 0 process, it returns DXGI_ERROR_NOT_CURRENTLY_AVAILABLE.
///
/// The combination of WindowHandle and Flags informs DXGI to stop monitoring window messages for the previously-associated window.
///
///
/// If the application switches to full-screen mode, DXGI will choose a full-screen resolution to be the smallest supported
/// resolution that is larger or the same size as the current back buffer size.
///
///
/// Applications can make some changes to make the transition from windowed to full screen more efficient. For example, on a
/// WM_SIZE message, the application should release any outstanding swap-chain back buffers, call IDXGISwapChain::ResizeBuffers,
/// then re-acquire the back buffers from the swap chain(s). This gives the swap chain(s) an opportunity to resize the back
/// buffers, and/or recreate them to enable full-screen flipping operation. If the application does not perform this sequence,
/// DXGI will still make the full-screen/windowed transition, but may be forced to use a stretch operation (since the back
/// buffers may not be the correct size), which may be less efficient. Even if a stretch is not required, presentation may not
/// be optimal because the back buffers might not be directly interchangeable with the front buffer. Thus, a call to
/// ResizeBuffers on WM_SIZE is always recommended, since WM_SIZE is always sent during a fullscreen transition.
///
///
/// While windowed, the application can, if it chooses, restrict the size of its window's client area to sizes to which it is
/// comfortable rendering. A fully flexible application would make no such restriction, but UI elements or other design
/// considerations can, of course, make this flexibility untenable. If the application further chooses to restrict its window's
/// client area to just those that match supported full-screen resolutions, the application can field WM_SIZING, then check
/// against IDXGIOutput::FindClosestMatchingMode. If a matching mode is found, allow the resize. (The IDXGIOutput can be
/// retrieved from IDXGISwapChain::GetContainingOutput. Absent subsequent changes to desktop topology, this will be the same
/// output that will be chosen when alt-enter is fielded and fullscreen mode is begun for that swap chain.)
///
///
/// Applications that want to handle mode changes or Alt+Enter themselves should call MakeWindowAssociation with the
/// DXGI_MWA_NO_WINDOW_CHANGES flag after swap chain creation. The WindowHandle argument, if non- NULL, specifies that
/// the application message queues will not be handled by the DXGI runtime for all swap chains of a particular target HWND.
/// Calling MakeWindowAssociation with the DXGI_MWA_NO_WINDOW_CHANGES flag after swapchain creation ensures that DXGI
/// will not interfere with application's handling of window mode changes or Alt+Enter.
///
/// Notes for Windows Store apps
/// If a Windows Store app calls MakeWindowAssociation, it fails with DXGI_ERROR_NOT_CURRENTLY_AVAILABLE.
///
/// A Microsoft Win32 application can use MakeWindowAssociation to control full-screen transitions through the Alt+Enter
/// key combination and print screen behavior for full screen. For Windows Store apps, because DXGI can't perform full-screen
/// transitions, a Windows Store app has no way to control full-screen transitions.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgifactory-makewindowassociation HRESULT
// MakeWindowAssociation( HWND WindowHandle, UINT Flags );
void MakeWindowAssociation(HWND WindowHandle, DXGI_MWA Flags);
/// Get the window through which the user controls the transition to and from full screen.
///
/// Type: HWND*
/// A pointer to a window handle.
///
/// Note If you call this API in a Session 0 process, it returns DXGI_ERROR_NOT_CURRENTLY_AVAILABLE.
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgifactory-getwindowassociation HRESULT
// GetWindowAssociation( HWND *pWindowHandle );
HWND GetWindowAssociation();
///
///
/// [Starting with Direct3D 11.1, we recommend not to use CreateSwapChain anymore to create a swap chain. Instead, use
/// CreateSwapChainForHwnd, CreateSwapChainForCoreWindow, or CreateSwapChainForComposition depending on how you want to create
/// the swap chain.]
///
/// Creates a swap chain.
///
///
/// Type: IUnknown*
///
/// For Direct3D 11, and earlier versions of Direct3D, this is a pointer to the Direct3D device for the swap chain. For Direct3D
/// 12 this is a pointer to a direct command queue (refer to ID3D12CommandQueue) . This parameter cannot be NULL.
///
///
///
/// Type: DXGI_SWAP_CHAIN_DESC*
/// A pointer to a DXGI_SWAP_CHAIN_DESC structure for the swap-chain description. This parameter cannot be NULL.
///
///
/// Type: IDXGISwapChain**
///
/// A pointer to a variable that receives a pointer to the IDXGISwapChain interface for the swap chain that
/// CreateSwapChain creates.
///
///
///
/// Note If you call this API in a Session 0 process, it returns DXGI_ERROR_NOT_CURRENTLY_AVAILABLE.
///
/// If you attempt to create a swap chain in full-screen mode, and full-screen mode is unavailable, the swap chain will be
/// created in windowed mode and DXGI_STATUS_OCCLUDED will be returned.
///
///
/// If the buffer width or the buffer height is zero, the sizes will be inferred from the output window size in the swap-chain description.
///
///
/// Because the target output can't be chosen explicitly when the swap chain is created, we recommend not to create a
/// full-screen swap chain. This can reduce presentation performance if the swap chain size and the output window size do not
/// match. Here are two ways to ensure that the sizes match:
///
///
/// -
/// Create a windowed swap chain and then set it full-screen using IDXGISwapChain::SetFullscreenState.
///
/// -
///
/// Save a pointer to the swap chain immediately after creation, and use it to get the output window size during a WM_SIZE
/// event. Then resize the swap chain buffers (with IDXGISwapChain::ResizeBuffers) during the transition from windowed to full-screen.
///
///
///
///
/// If the swap chain is in full-screen mode, before you release it you must use SetFullscreenState to switch it to windowed
/// mode. For more information about releasing a swap chain, see the "Destroying a Swap Chain" section of DXGI Overview.
///
///
/// After the runtime renders the initial frame in full screen, the runtime might unexpectedly exit full screen during a call to
/// IDXGISwapChain::Present. To work around this issue, we recommend that you execute the following code right after you call
/// CreateSwapChain to create a full-screen swap chain ( Windowed member of DXGI_SWAP_CHAIN_DESC set to FALSE).
///
///
/// You can specify DXGI_SWAP_EFFECT and DXGI_SWAP_CHAIN_FLAG values in the swap-chain description that pDesc points to. These
/// values allow you to use features like flip-model presentation and content protection by using pre-Windows 8 APIs.
///
///
/// However, to use stereo presentation and to change resize behavior for the flip model, applications must use the
/// IDXGIFactory2::CreateSwapChainForHwnd method. Otherwise, the back-buffer contents implicitly scale to fit the presentation
/// target size; that is, you can't turn off scaling.
///
/// Notes for Windows Store apps
/// If a Windows Store app calls CreateSwapChain with full screen specified, CreateSwapChain fails.
/// Windows Store apps call the IDXGIFactory2::CreateSwapChainForCoreWindow method to create a swap chain.
/// For info about how to choose a format for the swap chain's back buffer, see Converting data for the color space.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgifactory-createswapchain HRESULT CreateSwapChain(
// IUnknown *pDevice, DXGI_SWAP_CHAIN_DESC *pDesc, IDXGISwapChain **ppSwapChain );
IDXGISwapChain CreateSwapChain([In, MarshalAs(UnmanagedType.IUnknown)] object pDevice, in DXGI_SWAP_CHAIN_DESC pDesc);
/// Create an adapter interface that represents a software adapter.
///
/// Type: HMODULE
/// Handle to the software adapter's dll. HMODULE can be obtained with GetModuleHandle or LoadLibrary.
///
///
/// Type: IDXGIAdapter**
/// Address of a pointer to an adapter (see IDXGIAdapter).
///
///
///
/// A software adapter is a DLL that implements the entirety of a device driver interface, plus emulation, if necessary, of
/// kernel-mode graphics components for Windows. Details on implementing a software adapter can be found in the Windows Vista
/// Driver Development Kit. This is a very complex development task, and is not recommended for general readers.
///
///
/// Calling this method will increment the module's reference count by one. The reference count can be decremented by calling FreeLibrary.
///
///
/// The typical calling scenario is to call LoadLibrary, pass the handle to CreateSoftwareAdapter, then immediately call
/// FreeLibrary on the DLL and forget the DLL's HMODULE. Since the software adapter calls FreeLibrary when it is
/// destroyed, the lifetime of the DLL will now be owned by the adapter, and the application is free of any further
/// consideration of its lifetime.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgifactory-createsoftwareadapter HRESULT
// CreateSoftwareAdapter( HMODULE Module, IDXGIAdapter **ppAdapter );
IDXGIAdapter CreateSoftwareAdapter(HINSTANCE Module);
}
/// The IDXGIFactory1 interface implements methods for generating DXGI objects.
///
///
/// This interface is not supported by DXGI 1.0, which shipped in Windows Vista and Windows Server 2008. DXGI 1.1 support is
/// required, which is available on Windows 7, Windows Server 2008 R2, and as an update to Windows Vista with Service Pack 2 (SP2)
/// (KB 971644) and Windows Server 2008 (KB 971512).
///
/// To create a factory, call the CreateDXGIFactory1 function.
///
/// Because you can create a Direct3D device without creating a swap chain, you might need to retrieve the factory that is used to
/// create the device in order to create a swap chain. You can request the IDXGIDevice or IDXGIDevice1 interface from the Direct3D
/// device and then use the IDXGIObject::GetParent method to locate the factory. The following code shows how.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nn-dxgi-idxgifactory1
[ComImport, Guid("770aae78-f26f-4dba-a829-253c83d1b387"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IDXGIFactory1 : IDXGIFactory
{
/// Sets application-defined data to the object and associates that data with a GUID.
///
/// Type: REFGUID
/// A GUID that identifies the data. Use this GUID in a call to GetPrivateData to get the data.
///
///
/// Type: UINT
/// The size of the object's data.
///
///
/// Type: const void*
/// A pointer to the object's data.
///
///
/// Type: HRESULT
/// Returns one of the DXGI_ERROR values.
///
///
/// SetPrivateData makes a copy of the specified data and stores it with the object.
///
/// Private data that SetPrivateData stores in the object occupies the same storage space as private data that is stored
/// by associated Direct3D objects (for example, by a Microsoft Direct3D 11 device through ID3D11Device::SetPrivateData or by a
/// Direct3D 11 child device through ID3D11DeviceChild::SetPrivateData).
///
///
/// The debug layer reports memory leaks by outputting a list of object interface pointers along with their friendly names. The
/// default friendly name is "<unnamed>". You can set the friendly name so that you can determine if the corresponding
/// object interface pointer caused the leak. To set the friendly name, use the SetPrivateData method and the well-known
/// private data GUID ( WKPDID_D3DDebugObjectName) that is in D3Dcommon.h. For example, to give pContext a friendly name
/// of My name, use the following code:
///
///
/// You can use WKPDID_D3DDebugObjectName to track down memory leaks and understand performance characteristics of your
/// applications. This information is reflected in the output of the debug layer that is related to memory leaks
/// (ID3D11Debug::ReportLiveDeviceObjects) and with the event tracing for Windows events that we've added to Windows 8.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiobject-setprivatedata HRESULT SetPrivateData( REFGUID
// Name, UINT DataSize, const void *pData );
new void SetPrivateData(in Guid Name, uint DataSize, IntPtr pData);
/// Set an interface in the object's private data.
///
/// Type: REFGUID
/// A GUID identifying the interface.
///
///
/// Type: const IUnknown*
/// The interface to set.
///
///
/// Type: HRESULT
/// Returns one of the following DXGI_ERROR.
///
///
/// This API associates an interface pointer with the object.
///
/// When the interface is set its reference count is incremented. When the data are overwritten (by calling SPD or SPDI with the
/// same GUID) or the object is destroyed, ::Release() is called and the interface's reference count is decremented.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiobject-setprivatedatainterface HRESULT
// SetPrivateDataInterface( REFGUID Name, const IUnknown *pUnknown );
new void SetPrivateDataInterface(in Guid Name, [In, Optional, MarshalAs(UnmanagedType.IUnknown)] object pUnknown);
/// Get a pointer to the object's data.
///
/// Type: REFGUID
/// A GUID identifying the data.
///
///
/// Type: UINT*
/// The size of the data.
///
///
/// Type: void*
/// Pointer to the data.
///
///
/// Type: HRESULT
/// Returns one of the following DXGI_ERROR.
///
///
///
/// If the data returned is a pointer to an IUnknown, or one of its derivative classes, previously set by
/// IDXGIObject::SetPrivateDataInterface, you must call ::Release() on the pointer before the pointer is freed to decrement the
/// reference count.
///
///
/// You can pass GUID_DeviceType in the Name parameter of GetPrivateData to retrieve the device type from the
/// display adapter object (IDXGIAdapter, IDXGIAdapter1, IDXGIAdapter2).
///
/// To get the type of device on which the display adapter was created
///
/// -
/// Call IUnknown::QueryInterface on the ID3D11Device or ID3D10Device object to retrieve the IDXGIDevice object.
///
/// -
/// Call GetParent on the IDXGIDevice object to retrieve the IDXGIAdapter object.
///
/// -
///
/// Call GetPrivateData on the IDXGIAdapter object with GUID_DeviceType to retrieve the type of device on which
/// the display adapter was created. pData will point to a value from the driver-type enumeration (for example, a value from D3D_DRIVER_TYPE).
///
///
///
///
/// On Windows 7 or earlier, this type is either a value from D3D10_DRIVER_TYPE or D3D_DRIVER_TYPE depending on which kind of
/// device was created. On Windows 8, this type is always a value from D3D_DRIVER_TYPE. Don't use
/// IDXGIObject::SetPrivateData with GUID_DeviceType because the behavior when doing so is undefined.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiobject-getprivatedata HRESULT GetPrivateData( REFGUID
// Name, UINT *pDataSize, void *pData );
[PreserveSig]
new HRESULT GetPrivateData(in Guid Name, ref uint pDataSize, [Out] IntPtr pData);
/// Gets the parent of the object.
///
/// Type: REFIID
/// The ID of the requested interface.
///
///
/// Type: void**
/// The address of a pointer to the parent object.
///
///
/// Type: HRESULT
/// Returns one of the DXGI_ERROR values.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiobject-getparent HRESULT GetParent( REFIID riid, void
// **ppParent );
new void GetParent(in Guid riid, [MarshalAs(UnmanagedType.Interface)] out object ppParent);
/// Enumerates the adapters (video cards).
///
/// Type: UINT
/// The index of the adapter to enumerate.
///
///
/// Type: IDXGIAdapter**
///
/// The address of a pointer to an IDXGIAdapter interface at the position specified by the Adapter parameter. This parameter
/// must not be NULL.
///
///
///
///
/// When you create a factory, the factory enumerates the set of adapters that are available in the system. Therefore, if you
/// change the adapters in a system, you must destroy and recreate the IDXGIFactory object. The number of adapters in a system
/// changes when you add or remove a display card, or dock or undock a laptop.
///
///
/// When the EnumAdapters method succeeds and fills the ppAdapter parameter with the address of the pointer to the
/// adapter interface, EnumAdapters increments the adapter interface's reference count. When you finish using the adapter
/// interface, call the Release method to decrement the reference count before you destroy the pointer.
///
///
/// EnumAdapters first returns the adapter with the output on which the desktop primary is displayed. This adapter
/// corresponds with an index of zero. EnumAdapters next returns other adapters with outputs. EnumAdapters finally
/// returns adapters without outputs.
///
/// Examples
/// Enumerating Adapters
/// The following code example demonstrates how to enumerate adapters using the EnumAdapters method.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgifactory-enumadapters HRESULT EnumAdapters( UINT Adapter,
// IDXGIAdapter **ppAdapter );
new IDXGIAdapter EnumAdapters(uint Adapter);
///
/// Allows DXGI to monitor an application's message queue for the alt-enter key sequence (which causes the application to switch
/// from windowed to full screen or vice versa).
///
///
/// Type: HWND
///
/// The handle of the window that is to be monitored. This parameter can be NULL; but only if the flags are also 0.
///
///
///
/// Type: UINT
/// One or more of the following values:
///
/// -
///
/// DXGI_MWA_NO_WINDOW_CHANGES - Prevent DXGI from monitoring an applications message queue; this makes DXGI unable to respond
/// to mode changes.
///
///
/// -
/// DXGI_MWA_NO_ALT_ENTER - Prevent DXGI from responding to an alt-enter sequence.
///
/// -
/// DXGI_MWA_NO_PRINT_SCREEN - Prevent DXGI from responding to a print-screen key.
///
///
///
///
/// Note If you call this API in a Session 0 process, it returns DXGI_ERROR_NOT_CURRENTLY_AVAILABLE.
///
/// The combination of WindowHandle and Flags informs DXGI to stop monitoring window messages for the previously-associated window.
///
///
/// If the application switches to full-screen mode, DXGI will choose a full-screen resolution to be the smallest supported
/// resolution that is larger or the same size as the current back buffer size.
///
///
/// Applications can make some changes to make the transition from windowed to full screen more efficient. For example, on a
/// WM_SIZE message, the application should release any outstanding swap-chain back buffers, call IDXGISwapChain::ResizeBuffers,
/// then re-acquire the back buffers from the swap chain(s). This gives the swap chain(s) an opportunity to resize the back
/// buffers, and/or recreate them to enable full-screen flipping operation. If the application does not perform this sequence,
/// DXGI will still make the full-screen/windowed transition, but may be forced to use a stretch operation (since the back
/// buffers may not be the correct size), which may be less efficient. Even if a stretch is not required, presentation may not
/// be optimal because the back buffers might not be directly interchangeable with the front buffer. Thus, a call to
/// ResizeBuffers on WM_SIZE is always recommended, since WM_SIZE is always sent during a fullscreen transition.
///
///
/// While windowed, the application can, if it chooses, restrict the size of its window's client area to sizes to which it is
/// comfortable rendering. A fully flexible application would make no such restriction, but UI elements or other design
/// considerations can, of course, make this flexibility untenable. If the application further chooses to restrict its window's
/// client area to just those that match supported full-screen resolutions, the application can field WM_SIZING, then check
/// against IDXGIOutput::FindClosestMatchingMode. If a matching mode is found, allow the resize. (The IDXGIOutput can be
/// retrieved from IDXGISwapChain::GetContainingOutput. Absent subsequent changes to desktop topology, this will be the same
/// output that will be chosen when alt-enter is fielded and fullscreen mode is begun for that swap chain.)
///
///
/// Applications that want to handle mode changes or Alt+Enter themselves should call MakeWindowAssociation with the
/// DXGI_MWA_NO_WINDOW_CHANGES flag after swap chain creation. The WindowHandle argument, if non- NULL, specifies that
/// the application message queues will not be handled by the DXGI runtime for all swap chains of a particular target HWND.
/// Calling MakeWindowAssociation with the DXGI_MWA_NO_WINDOW_CHANGES flag after swapchain creation ensures that DXGI
/// will not interfere with application's handling of window mode changes or Alt+Enter.
///
/// Notes for Windows Store apps
/// If a Windows Store app calls MakeWindowAssociation, it fails with DXGI_ERROR_NOT_CURRENTLY_AVAILABLE.
///
/// A Microsoft Win32 application can use MakeWindowAssociation to control full-screen transitions through the Alt+Enter
/// key combination and print screen behavior for full screen. For Windows Store apps, because DXGI can't perform full-screen
/// transitions, a Windows Store app has no way to control full-screen transitions.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgifactory-makewindowassociation HRESULT
// MakeWindowAssociation( HWND WindowHandle, UINT Flags );
new void MakeWindowAssociation(HWND WindowHandle, DXGI_MWA Flags);
/// Get the window through which the user controls the transition to and from full screen.
///
/// Type: HWND*
/// A pointer to a window handle.
///
/// Note If you call this API in a Session 0 process, it returns DXGI_ERROR_NOT_CURRENTLY_AVAILABLE.
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgifactory-getwindowassociation HRESULT
// GetWindowAssociation( HWND *pWindowHandle );
new HWND GetWindowAssociation();
///
///
/// [Starting with Direct3D 11.1, we recommend not to use CreateSwapChain anymore to create a swap chain. Instead, use
/// CreateSwapChainForHwnd, CreateSwapChainForCoreWindow, or CreateSwapChainForComposition depending on how you want to create
/// the swap chain.]
///
/// Creates a swap chain.
///
///
/// Type: IUnknown*
///
/// For Direct3D 11, and earlier versions of Direct3D, this is a pointer to the Direct3D device for the swap chain. For Direct3D
/// 12 this is a pointer to a direct command queue (refer to ID3D12CommandQueue) . This parameter cannot be NULL.
///
///
///
/// Type: DXGI_SWAP_CHAIN_DESC*
/// A pointer to a DXGI_SWAP_CHAIN_DESC structure for the swap-chain description. This parameter cannot be NULL.
///
///
/// Type: IDXGISwapChain**
///
/// A pointer to a variable that receives a pointer to the IDXGISwapChain interface for the swap chain that
/// CreateSwapChain creates.
///
///
///
/// Note If you call this API in a Session 0 process, it returns DXGI_ERROR_NOT_CURRENTLY_AVAILABLE.
///
/// If you attempt to create a swap chain in full-screen mode, and full-screen mode is unavailable, the swap chain will be
/// created in windowed mode and DXGI_STATUS_OCCLUDED will be returned.
///
///
/// If the buffer width or the buffer height is zero, the sizes will be inferred from the output window size in the swap-chain description.
///
///
/// Because the target output can't be chosen explicitly when the swap chain is created, we recommend not to create a
/// full-screen swap chain. This can reduce presentation performance if the swap chain size and the output window size do not
/// match. Here are two ways to ensure that the sizes match:
///
///
/// -
/// Create a windowed swap chain and then set it full-screen using IDXGISwapChain::SetFullscreenState.
///
/// -
///
/// Save a pointer to the swap chain immediately after creation, and use it to get the output window size during a WM_SIZE
/// event. Then resize the swap chain buffers (with IDXGISwapChain::ResizeBuffers) during the transition from windowed to full-screen.
///
///
///
///
/// If the swap chain is in full-screen mode, before you release it you must use SetFullscreenState to switch it to windowed
/// mode. For more information about releasing a swap chain, see the "Destroying a Swap Chain" section of DXGI Overview.
///
///
/// After the runtime renders the initial frame in full screen, the runtime might unexpectedly exit full screen during a call to
/// IDXGISwapChain::Present. To work around this issue, we recommend that you execute the following code right after you call
/// CreateSwapChain to create a full-screen swap chain ( Windowed member of DXGI_SWAP_CHAIN_DESC set to FALSE).
///
///
/// You can specify DXGI_SWAP_EFFECT and DXGI_SWAP_CHAIN_FLAG values in the swap-chain description that pDesc points to. These
/// values allow you to use features like flip-model presentation and content protection by using pre-Windows 8 APIs.
///
///
/// However, to use stereo presentation and to change resize behavior for the flip model, applications must use the
/// IDXGIFactory2::CreateSwapChainForHwnd method. Otherwise, the back-buffer contents implicitly scale to fit the presentation
/// target size; that is, you can't turn off scaling.
///
/// Notes for Windows Store apps
/// If a Windows Store app calls CreateSwapChain with full screen specified, CreateSwapChain fails.
/// Windows Store apps call the IDXGIFactory2::CreateSwapChainForCoreWindow method to create a swap chain.
/// For info about how to choose a format for the swap chain's back buffer, see Converting data for the color space.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgifactory-createswapchain HRESULT CreateSwapChain(
// IUnknown *pDevice, DXGI_SWAP_CHAIN_DESC *pDesc, IDXGISwapChain **ppSwapChain );
new IDXGISwapChain CreateSwapChain([In, MarshalAs(UnmanagedType.IUnknown)] object pDevice, in DXGI_SWAP_CHAIN_DESC pDesc);
/// Create an adapter interface that represents a software adapter.
///
/// Type: HMODULE
/// Handle to the software adapter's dll. HMODULE can be obtained with GetModuleHandle or LoadLibrary.
///
///
/// Type: IDXGIAdapter**
/// Address of a pointer to an adapter (see IDXGIAdapter).
///
///
///
/// A software adapter is a DLL that implements the entirety of a device driver interface, plus emulation, if necessary, of
/// kernel-mode graphics components for Windows. Details on implementing a software adapter can be found in the Windows Vista
/// Driver Development Kit. This is a very complex development task, and is not recommended for general readers.
///
///
/// Calling this method will increment the module's reference count by one. The reference count can be decremented by calling FreeLibrary.
///
///
/// The typical calling scenario is to call LoadLibrary, pass the handle to CreateSoftwareAdapter, then immediately call
/// FreeLibrary on the DLL and forget the DLL's HMODULE. Since the software adapter calls FreeLibrary when it is
/// destroyed, the lifetime of the DLL will now be owned by the adapter, and the application is free of any further
/// consideration of its lifetime.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgifactory-createsoftwareadapter HRESULT
// CreateSoftwareAdapter( HMODULE Module, IDXGIAdapter **ppAdapter );
new IDXGIAdapter CreateSoftwareAdapter(HINSTANCE Module);
/// Enumerates both adapters (video cards) with or without outputs.
///
/// Type: UINT
/// The index of the adapter to enumerate.
///
///
/// Type: IDXGIAdapter1**
///
/// The address of a pointer to an IDXGIAdapter1 interface at the position specified by the Adapter parameter. This parameter
/// must not be NULL.
///
///
///
///
/// This method is not supported by DXGI 1.0, which shipped in Windows Vista and Windows Server 2008. DXGI 1.1 support is
/// required, which is available on Windows 7, Windows Server 2008 R2, and as an update to Windows Vista with Service Pack 2
/// (SP2) (KB 971644) and Windows Server 2008 (KB 971512).
///
///
/// When you create a factory, the factory enumerates the set of adapters that are available in the system. Therefore, if you
/// change the adapters in a system, you must destroy and recreate the IDXGIFactory1 object. The number of adapters in a system
/// changes when you add or remove a display card, or dock or undock a laptop.
///
///
/// When the EnumAdapters1 method succeeds and fills the ppAdapter parameter with the address of the pointer to the
/// adapter interface, EnumAdapters1 increments the adapter interface's reference count. When you finish using the
/// adapter interface, call the Release method to decrement the reference count before you destroy the pointer.
///
///
/// EnumAdapters1 first returns the adapter with the output on which the desktop primary is displayed. This adapter
/// corresponds with an index of zero. EnumAdapters1 next returns other adapters with outputs. EnumAdapters1
/// finally returns adapters without outputs.
///
/// Examples
/// Enumerating Adapters
/// The following code example demonstrates how to enumerate adapters using the EnumAdapters1 method.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgifactory1-enumadapters1 HRESULT EnumAdapters1( UINT
// Adapter, IDXGIAdapter1 **ppAdapter );
IDXGIAdapter1 EnumAdapters1(uint Adapter);
/// Informs an application of the possible need to re-enumerate adapters.
///
/// Type: BOOL
///
/// FALSE, if a new adapter is becoming available or the current adapter is going away. TRUE, no adapter changes.
///
/// IsCurrent returns FALSE to inform the calling application to re-enumerate adapters.
///
///
/// This method is not supported by DXGI 1.0, which shipped in Windows Vista and Windows Server 2008. DXGI 1.1 support is
/// required, which is available on Windows 7, Windows Server 2008 R2, and as an update to Windows Vista with Service Pack 2
/// (SP2) (KB 971644) and Windows Server 2008 (KB 971512).
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgifactory1-iscurrent BOOL IsCurrent();
[PreserveSig]
[return: MarshalAs(UnmanagedType.Bool)]
bool IsCurrent();
}
///
/// An IDXGIObject interface is a base interface for all DXGI objects; IDXGIObject supports associating caller-defined
/// (private data) with an object and retrieval of an interface to the parent object.
///
///
/// IDXGIObject implements base-class functionality for the following interfaces:
///
/// -
/// IDXGIAdapter
///
/// -
/// IDXGIDevice
///
/// -
/// IDXGIFactory
///
/// -
/// IDXGIOutput
///
///
/// Windows Phone 8: This API is supported.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nn-dxgi-idxgiobject
[ComImport, Guid("aec22fb8-76f3-4639-9be0-28eb43a67a2e"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IDXGIObject
{
/// Sets application-defined data to the object and associates that data with a GUID.
///
/// Type: REFGUID
/// A GUID that identifies the data. Use this GUID in a call to GetPrivateData to get the data.
///
///
/// Type: UINT
/// The size of the object's data.
///
///
/// Type: const void*
/// A pointer to the object's data.
///
///
/// Type: HRESULT
/// Returns one of the DXGI_ERROR values.
///
///
/// SetPrivateData makes a copy of the specified data and stores it with the object.
///
/// Private data that SetPrivateData stores in the object occupies the same storage space as private data that is stored
/// by associated Direct3D objects (for example, by a Microsoft Direct3D 11 device through ID3D11Device::SetPrivateData or by a
/// Direct3D 11 child device through ID3D11DeviceChild::SetPrivateData).
///
///
/// The debug layer reports memory leaks by outputting a list of object interface pointers along with their friendly names. The
/// default friendly name is "<unnamed>". You can set the friendly name so that you can determine if the corresponding
/// object interface pointer caused the leak. To set the friendly name, use the SetPrivateData method and the well-known
/// private data GUID ( WKPDID_D3DDebugObjectName) that is in D3Dcommon.h. For example, to give pContext a friendly name
/// of My name, use the following code:
///
///
/// You can use WKPDID_D3DDebugObjectName to track down memory leaks and understand performance characteristics of your
/// applications. This information is reflected in the output of the debug layer that is related to memory leaks
/// (ID3D11Debug::ReportLiveDeviceObjects) and with the event tracing for Windows events that we've added to Windows 8.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiobject-setprivatedata HRESULT SetPrivateData( REFGUID
// Name, UINT DataSize, const void *pData );
void SetPrivateData(in Guid Name, uint DataSize, IntPtr pData);
/// Set an interface in the object's private data.
///
/// Type: REFGUID
/// A GUID identifying the interface.
///
///
/// Type: const IUnknown*
/// The interface to set.
///
///
/// Type: HRESULT
/// Returns one of the following DXGI_ERROR.
///
///
/// This API associates an interface pointer with the object.
///
/// When the interface is set its reference count is incremented. When the data are overwritten (by calling SPD or SPDI with the
/// same GUID) or the object is destroyed, ::Release() is called and the interface's reference count is decremented.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiobject-setprivatedatainterface HRESULT
// SetPrivateDataInterface( REFGUID Name, const IUnknown *pUnknown );
void SetPrivateDataInterface(in Guid Name, [In, Optional, MarshalAs(UnmanagedType.IUnknown)] object pUnknown);
/// Get a pointer to the object's data.
///
/// Type: REFGUID
/// A GUID identifying the data.
///
///
/// Type: UINT*
/// The size of the data.
///
///
/// Type: void*
/// Pointer to the data.
///
///
/// Type: HRESULT
/// Returns one of the following DXGI_ERROR.
///
///
///
/// If the data returned is a pointer to an IUnknown, or one of its derivative classes, previously set by
/// IDXGIObject::SetPrivateDataInterface, you must call ::Release() on the pointer before the pointer is freed to decrement the
/// reference count.
///
///
/// You can pass GUID_DeviceType in the Name parameter of GetPrivateData to retrieve the device type from the
/// display adapter object (IDXGIAdapter, IDXGIAdapter1, IDXGIAdapter2).
///
/// To get the type of device on which the display adapter was created
///
/// -
/// Call IUnknown::QueryInterface on the ID3D11Device or ID3D10Device object to retrieve the IDXGIDevice object.
///
/// -
/// Call GetParent on the IDXGIDevice object to retrieve the IDXGIAdapter object.
///
/// -
///
/// Call GetPrivateData on the IDXGIAdapter object with GUID_DeviceType to retrieve the type of device on which
/// the display adapter was created. pData will point to a value from the driver-type enumeration (for example, a value from D3D_DRIVER_TYPE).
///
///
///
///
/// On Windows 7 or earlier, this type is either a value from D3D10_DRIVER_TYPE or D3D_DRIVER_TYPE depending on which kind of
/// device was created. On Windows 8, this type is always a value from D3D_DRIVER_TYPE. Don't use
/// IDXGIObject::SetPrivateData with GUID_DeviceType because the behavior when doing so is undefined.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiobject-getprivatedata HRESULT GetPrivateData( REFGUID
// Name, UINT *pDataSize, void *pData );
[PreserveSig]
HRESULT GetPrivateData(in Guid Name, ref uint pDataSize, [Out] IntPtr pData);
/// Gets the parent of the object.
///
/// Type: REFIID
/// The ID of the requested interface.
///
///
/// Type: void**
/// The address of a pointer to the parent object.
///
///
/// Type: HRESULT
/// Returns one of the DXGI_ERROR values.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiobject-getparent HRESULT GetParent( REFIID riid, void
// **ppParent );
void GetParent(in Guid riid, [MarshalAs(UnmanagedType.Interface)] out object ppParent);
}
/// An IDXGIOutput interface represents an adapter output (such as a monitor).
///
/// To see the outputs available, use IDXGIAdapter::EnumOutputs. To see the specific output that the swap chain will update, use IDXGISwapChain::GetContainingOutput.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nn-dxgi-idxgioutput
[PInvokeData("dxgi.h")]
[ComImport, Guid("ae02eedb-c735-4690-8d52-5a8dc20213aa"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IDXGIOutput : IDXGIObject
{
/// Sets application-defined data to the object and associates that data with a GUID.
///
/// Type: REFGUID
/// A GUID that identifies the data. Use this GUID in a call to GetPrivateData to get the data.
///
///
/// Type: UINT
/// The size of the object's data.
///
///
/// Type: const void*
/// A pointer to the object's data.
///
///
/// Type: HRESULT
/// Returns one of the DXGI_ERROR values.
///
///
/// SetPrivateData makes a copy of the specified data and stores it with the object.
///
/// Private data that SetPrivateData stores in the object occupies the same storage space as private data that is stored
/// by associated Direct3D objects (for example, by a Microsoft Direct3D 11 device through ID3D11Device::SetPrivateData or by a
/// Direct3D 11 child device through ID3D11DeviceChild::SetPrivateData).
///
///
/// The debug layer reports memory leaks by outputting a list of object interface pointers along with their friendly names. The
/// default friendly name is "<unnamed>". You can set the friendly name so that you can determine if the corresponding
/// object interface pointer caused the leak. To set the friendly name, use the SetPrivateData method and the well-known
/// private data GUID ( WKPDID_D3DDebugObjectName) that is in D3Dcommon.h. For example, to give pContext a friendly name
/// of My name, use the following code:
///
///
/// You can use WKPDID_D3DDebugObjectName to track down memory leaks and understand performance characteristics of your
/// applications. This information is reflected in the output of the debug layer that is related to memory leaks
/// (ID3D11Debug::ReportLiveDeviceObjects) and with the event tracing for Windows events that we've added to Windows 8.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiobject-setprivatedata HRESULT SetPrivateData( REFGUID
// Name, UINT DataSize, const void *pData );
new void SetPrivateData(in Guid Name, uint DataSize, IntPtr pData);
/// Set an interface in the object's private data.
///
/// Type: REFGUID
/// A GUID identifying the interface.
///
///
/// Type: const IUnknown*
/// The interface to set.
///
///
/// Type: HRESULT
/// Returns one of the following DXGI_ERROR.
///
///
/// This API associates an interface pointer with the object.
///
/// When the interface is set its reference count is incremented. When the data are overwritten (by calling SPD or SPDI with the
/// same GUID) or the object is destroyed, ::Release() is called and the interface's reference count is decremented.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiobject-setprivatedatainterface HRESULT
// SetPrivateDataInterface( REFGUID Name, const IUnknown *pUnknown );
new void SetPrivateDataInterface(in Guid Name, [In, Optional, MarshalAs(UnmanagedType.IUnknown)] object pUnknown);
/// Get a pointer to the object's data.
///
/// Type: REFGUID
/// A GUID identifying the data.
///
///
/// Type: UINT*
/// The size of the data.
///
///
/// Type: void*
/// Pointer to the data.
///
///
/// Type: HRESULT
/// Returns one of the following DXGI_ERROR.
///
///
///
/// If the data returned is a pointer to an IUnknown, or one of its derivative classes, previously set by
/// IDXGIObject::SetPrivateDataInterface, you must call ::Release() on the pointer before the pointer is freed to decrement the
/// reference count.
///
///
/// You can pass GUID_DeviceType in the Name parameter of GetPrivateData to retrieve the device type from the
/// display adapter object (IDXGIAdapter, IDXGIAdapter1, IDXGIAdapter2).
///
/// To get the type of device on which the display adapter was created
///
/// -
/// Call IUnknown::QueryInterface on the ID3D11Device or ID3D10Device object to retrieve the IDXGIDevice object.
///
/// -
/// Call GetParent on the IDXGIDevice object to retrieve the IDXGIAdapter object.
///
/// -
///
/// Call GetPrivateData on the IDXGIAdapter object with GUID_DeviceType to retrieve the type of device on which
/// the display adapter was created. pData will point to a value from the driver-type enumeration (for example, a value from D3D_DRIVER_TYPE).
///
///
///
///
/// On Windows 7 or earlier, this type is either a value from D3D10_DRIVER_TYPE or D3D_DRIVER_TYPE depending on which kind of
/// device was created. On Windows 8, this type is always a value from D3D_DRIVER_TYPE. Don't use
/// IDXGIObject::SetPrivateData with GUID_DeviceType because the behavior when doing so is undefined.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiobject-getprivatedata HRESULT GetPrivateData( REFGUID
// Name, UINT *pDataSize, void *pData );
[PreserveSig]
new HRESULT GetPrivateData(in Guid Name, ref uint pDataSize, [Out] IntPtr pData);
/// Gets the parent of the object.
///
/// Type: REFIID
/// The ID of the requested interface.
///
///
/// Type: void**
/// The address of a pointer to the parent object.
///
///
/// Type: HRESULT
/// Returns one of the DXGI_ERROR values.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiobject-getparent HRESULT GetParent( REFIID riid, void
// **ppParent );
new void GetParent(in Guid riid, [MarshalAs(UnmanagedType.Interface)] out object ppParent);
/// Get a description of the output.
///
/// Type: DXGI_OUTPUT_DESC*
/// A pointer to the output description (see DXGI_OUTPUT_DESC).
///
///
/// On a high DPI desktop, GetDesc returns the visualized screen size unless the app is marked high DPI aware. For info
/// about writing DPI-aware Win32 apps, see High DPI.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgioutput-getdesc HRESULT GetDesc( DXGI_OUTPUT_DESC *pDesc );
DXGI_OUTPUT_DESC GetDesc();
///
///
/// [Starting with Direct3D 11.1, we recommend not to use GetDisplayModeList anymore to retrieve the matching display
/// mode. Instead, use IDXGIOutput1::GetDisplayModeList1, which supports stereo display mode.]
///
/// Gets the display modes that match the requested format and other input options.
///
///
/// Type: DXGI_FORMAT
/// The color format (see DXGI_FORMAT).
///
///
/// Type: UINT
///
/// Options for modes to include (see DXGI_ENUM_MODES). DXGI_ENUM_MODES_SCALING needs to be specified to expose the display
/// modes that require scaling. Centered modes, requiring no scaling and corresponding directly to the display output, are
/// enumerated by default.
///
///
///
/// Type: UINT*
///
/// Set pDesc to NULL so that pNumModes returns the number of display modes that match the format and the options.
/// Otherwise, pNumModes returns the number of display modes returned in pDesc.
///
///
///
/// Type: DXGI_MODE_DESC*
/// A pointer to a list of display modes (see DXGI_MODE_DESC); set to NULL to get the number of display modes.
///
///
///
/// In general, when switching from windowed to full-screen mode, a swap chain automatically chooses a display mode that meets
/// (or exceeds) the resolution, color depth and refresh rate of the swap chain. To exercise more control over the display mode,
/// use this API to poll the set of display modes that are validated against monitor capabilities, or all modes that match the
/// desktop (if the desktop settings are not validated against the monitor).
///
///
/// As shown, this API is designed to be called twice. First to get the number of modes available, and second to return a
/// description of the modes.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgioutput-getdisplaymodelist HRESULT GetDisplayModeList(
// DXGI_FORMAT EnumFormat, UINT Flags, UINT *pNumModes, DXGI_MODE_DESC *pDesc );
void GetDisplayModeList(DXGI_FORMAT EnumFormat, DXGI_ENUM_MODES Flags, ref uint pNumModes, [Out, Optional] DXGI_MODE_DESC[] pDesc);
///
///
/// [Starting with Direct3D 11.1, we recommend not to use FindClosestMatchingMode anymore to find the display mode that
/// most closely matches the requested display mode. Instead, use IDXGIOutput1::FindClosestMatchingMode1, which supports stereo
/// display mode.]
///
/// Finds the display mode that most closely matches the requested display mode.
///
///
/// Type: const DXGI_MODE_DESC*
///
/// The desired display mode (see DXGI_MODE_DESC). Members of DXGI_MODE_DESC can be unspecified indicating no preference
/// for that member. A value of 0 for Width or Height indicates the value is unspecified. If either Width
/// or Height are 0, both must be 0. A numerator and denominator of 0 in RefreshRate indicate it is unspecified.
/// Other members of DXGI_MODE_DESC have enumeration values indicating the member is unspecified. If pConcernedDevice is
/// NULL, Format cannot be DXGI_FORMAT_UNKNOWN.
///
///
///
/// Type: DXGI_MODE_DESC*
/// The mode that most closely matches pModeToMatch.
///
///
/// Type: IUnknown*
///
/// A pointer to the Direct3D device interface. If this parameter is NULL, only modes whose format matches that of
/// pModeToMatch will be returned; otherwise, only those formats that are supported for scan-out by the device are returned. For
/// info about the formats that are supported for scan-out by the device at each feature level:
///
///
/// -
/// DXGI Format Support for Direct3D Feature Level 12.1 Hardware
///
/// -
/// DXGI Format Support for Direct3D Feature Level 12.0 Hardware
///
/// -
/// DXGI Format Support for Direct3D Feature Level 11.1 Hardware
///
/// -
/// DXGI Format Support for Direct3D Feature Level 11.0 Hardware
///
/// -
/// Hardware Support for Direct3D 10Level9 Formats
///
/// -
/// Hardware Support for Direct3D 10.1 Formats
///
/// -
/// Hardware Support for Direct3D 10 Formats
///
///
///
///
///
/// FindClosestMatchingMode behaves similarly to the IDXGIOutput1::FindClosestMatchingMode1 except
/// FindClosestMatchingMode considers only the mono display modes. IDXGIOutput1::FindClosestMatchingMode1
/// considers only stereo modes if you set the Stereo member in the DXGI_MODE_DESC1 structure that pModeToMatch points
/// to, and considers only mono modes if Stereo is not set.
///
///
/// IDXGIOutput1::FindClosestMatchingMode1 returns a matched display-mode set with only stereo modes or only mono modes.
/// FindClosestMatchingMode behaves as though you specified the input mode as mono.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgioutput-findclosestmatchingmode HRESULT
// FindClosestMatchingMode( const DXGI_MODE_DESC *pModeToMatch, DXGI_MODE_DESC *pClosestMatch, IUnknown *pConcernedDevice );
void FindClosestMatchingMode(in DXGI_MODE_DESC pModeToMatch, out DXGI_MODE_DESC pClosestMatch, [In, Optional, MarshalAs(UnmanagedType.IUnknown)] object pConcernedDevice);
/// Halt a thread until the next vertical blank occurs.
///
/// A vertical blank occurs when the raster moves from the lower right corner to the upper left corner to begin drawing the next frame.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgioutput-waitforvblank HRESULT WaitForVBlank();
void WaitForVBlank();
/// Takes ownership of an output.
///
/// Type: IUnknown*
/// A pointer to the IUnknown interface of a device (such as an ID3D10Device).
///
///
/// Type: BOOL
/// Set to TRUE to enable other threads or applications to take ownership of the device; otherwise, set to FALSE.
///
///
/// When you are finished with the output, call IDXGIOutput::ReleaseOwnership.
///
/// TakeOwnership should not be called directly by applications, since results will be unpredictable. It is called
/// implicitly by the DXGI swap chain object during full-screen transitions, and should not be used as a substitute for
/// swap-chain methods.
///
/// Notes for Windows Store apps
/// If a Windows Store app uses TakeOwnership, it fails with DXGI_ERROR_NOT_CURRENTLY_AVAILABLE.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgioutput-takeownership HRESULT TakeOwnership( IUnknown
// *pDevice, BOOL Exclusive );
void TakeOwnership([In, MarshalAs(UnmanagedType.IUnknown)] object pDevice, [MarshalAs(UnmanagedType.Bool)] bool Exclusive);
/// Releases ownership of the output.
/// None
///
/// If you are not using a swap chain, get access to an output by calling IDXGIOutput::TakeOwnership and release it when you are
/// finished by calling IDXGIOutput::ReleaseOwnership. An application that uses a swap chain will typically not call
/// either of these methods.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgioutput-releaseownership void ReleaseOwnership();
[PreserveSig]
void ReleaseOwnership();
/// Gets a description of the gamma-control capabilities.
///
/// Type: DXGI_GAMMA_CONTROL_CAPABILITIES*
/// A pointer to a description of the gamma-control capabilities (see DXGI_GAMMA_CONTROL_CAPABILITIES).
///
///
/// Note Calling this method is only supported while in full-screen mode.
/// For info about using gamma correction, see Using gamma correction.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgioutput-getgammacontrolcapabilities HRESULT
// GetGammaControlCapabilities( DXGI_GAMMA_CONTROL_CAPABILITIES *pGammaCaps );
DXGI_GAMMA_CONTROL_CAPABILITIES GetGammaControlCapabilities();
/// Sets the gamma controls.
///
/// Type: const DXGI_GAMMA_CONTROL*
/// A pointer to a DXGI_GAMMA_CONTROL structure that describes the gamma curve to set.
///
///
/// Note Calling this method is only supported while in full-screen mode.
/// For info about using gamma correction, see Using gamma correction.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgioutput-setgammacontrol HRESULT SetGammaControl( const
// DXGI_GAMMA_CONTROL *pArray );
void SetGammaControl(in DXGI_GAMMA_CONTROL pArray);
/// Gets the gamma control settings.
///
/// Type: DXGI_GAMMA_CONTROL*
/// An array of gamma control settings (see DXGI_GAMMA_CONTROL).
///
///
/// Note Calling this method is only supported while in full-screen mode.
/// For info about using gamma correction, see Using gamma correction.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgioutput-getgammacontrol HRESULT GetGammaControl(
// DXGI_GAMMA_CONTROL *pArray );
DXGI_GAMMA_CONTROL GetGammaControl();
/// Changes the display mode.
///
/// Type: IDXGISurface*
///
/// A pointer to a surface (see IDXGISurface) used for rendering an image to the screen. The surface must have been created as a
/// back buffer (DXGI_USAGE_BACKBUFFER).
///
///
///
///
/// IDXGIOutput::SetDisplaySurface should not be called directly by applications, since results will be unpredictable. It
/// is called implicitly by the DXGI swap chain object during full-screen transitions, and should not be used as a substitute
/// for swap-chain methods.
///
/// This method should only be called between IDXGIOutput::TakeOwnership and IDXGIOutput::ReleaseOwnership calls.
/// Notes for Windows Store apps
/// If a Windows Store app uses SetDisplaySurface, it fails with DXGI_ERROR_NOT_CURRENTLY_AVAILABLE.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgioutput-setdisplaysurface HRESULT SetDisplaySurface(
// IDXGISurface *pScanoutSurface );
void SetDisplaySurface([In] IDXGISurface pScanoutSurface);
///
///
/// [Starting with Direct3D 11.1, we recommend not to use GetDisplaySurfaceData anymore to retrieve the current display
/// surface. Instead, use IDXGIOutput1::GetDisplaySurfaceData1, which supports stereo display mode.]
///
/// Gets a copy of the current display surface.
///
///
/// Type: IDXGISurface*
/// A pointer to a destination surface (see IDXGISurface).
///
///
///
/// IDXGIOutput::GetDisplaySurfaceData can only be called when an output is in full-screen mode. If the method succeeds,
/// DXGI fills the destination surface.
///
///
/// Use IDXGIOutput::GetDesc to determine the size (width and height) of the output when you want to allocate space for the
/// destination surface. This is true regardless of target monitor rotation. A destination surface created by a graphics
/// component (such as Direct3D 10) must be created with CPU-write permission (see D3D10_CPU_ACCESS_WRITE). Other surfaces
/// should be created with CPU read-write permission (see D3D10_CPU_ACCESS_READ_WRITE). This method will modify the surface data
/// to fit the destination surface (stretch, shrink, convert format, rotate). The stretch and shrink is performed with point-sampling.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgioutput-getdisplaysurfacedata HRESULT
// GetDisplaySurfaceData( IDXGISurface *pDestination );
void GetDisplaySurfaceData([In] IDXGISurface pDestination);
/// Gets statistics about recently rendered frames.
///
/// Type: DXGI_FRAME_STATISTICS*
/// A pointer to frame statistics (see DXGI_FRAME_STATISTICS).
///
///
/// This API is similar to IDXGISwapChain::GetFrameStatistics.
/// Note Calling this method is only supported while in full-screen mode.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgioutput-getframestatistics HRESULT GetFrameStatistics(
// DXGI_FRAME_STATISTICS *pStats );
DXGI_FRAME_STATISTICS GetFrameStatistics();
}
/// The IDXGISurface interface implements methods for image-data objects.
///
/// An image-data object is a 2D section of memory, commonly called a surface. To get the surface from an output, call IDXGIOutput::GetDisplaySurfaceData.
///
/// The runtime automatically creates an IDXGISurface interface when it creates a Direct3D resource object that represents a
/// surface. For example, the runtime creates an IDXGISurface interface when you call ID3D11Device::CreateTexture2D or
/// ID3D10Device::CreateTexture2D to create a 2D texture. To retrieve the IDXGISurface interface that represents the 2D
/// texture surface, call ID3D11Texture2D::QueryInterface or ID3D10Texture2D::QueryInterface. In this call, you must pass the
/// identifier of IDXGISurface. If the 2D texture has only a single MIP-map level and does not consist of an array of
/// textures, QueryInterface succeeds and returns a pointer to the IDXGISurface interface pointer. Otherwise,
/// QueryInterface fails and does not return the pointer to IDXGISurface.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nn-dxgi-idxgisurface
[PInvokeData("dxgi.h")]
[ComImport, Guid("cafcb56c-6ac3-4889-bf47-9e23bbd260ec"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IDXGISurface : IDXGIDeviceSubObject
{
/// Sets application-defined data to the object and associates that data with a GUID.
///
/// Type: REFGUID
/// A GUID that identifies the data. Use this GUID in a call to GetPrivateData to get the data.
///
///
/// Type: UINT
/// The size of the object's data.
///
///
/// Type: const void*
/// A pointer to the object's data.
///
///
/// Type: HRESULT
/// Returns one of the DXGI_ERROR values.
///
///
/// SetPrivateData makes a copy of the specified data and stores it with the object.
///
/// Private data that SetPrivateData stores in the object occupies the same storage space as private data that is stored
/// by associated Direct3D objects (for example, by a Microsoft Direct3D 11 device through ID3D11Device::SetPrivateData or by a
/// Direct3D 11 child device through ID3D11DeviceChild::SetPrivateData).
///
///
/// The debug layer reports memory leaks by outputting a list of object interface pointers along with their friendly names. The
/// default friendly name is "<unnamed>". You can set the friendly name so that you can determine if the corresponding
/// object interface pointer caused the leak. To set the friendly name, use the SetPrivateData method and the well-known
/// private data GUID ( WKPDID_D3DDebugObjectName) that is in D3Dcommon.h. For example, to give pContext a friendly name
/// of My name, use the following code:
///
///
/// You can use WKPDID_D3DDebugObjectName to track down memory leaks and understand performance characteristics of your
/// applications. This information is reflected in the output of the debug layer that is related to memory leaks
/// (ID3D11Debug::ReportLiveDeviceObjects) and with the event tracing for Windows events that we've added to Windows 8.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiobject-setprivatedata HRESULT SetPrivateData( REFGUID
// Name, UINT DataSize, const void *pData );
new void SetPrivateData(in Guid Name, uint DataSize, IntPtr pData);
/// Set an interface in the object's private data.
///
/// Type: REFGUID
/// A GUID identifying the interface.
///
///
/// Type: const IUnknown*
/// The interface to set.
///
///
/// Type: HRESULT
/// Returns one of the following DXGI_ERROR.
///
///
/// This API associates an interface pointer with the object.
///
/// When the interface is set its reference count is incremented. When the data are overwritten (by calling SPD or SPDI with the
/// same GUID) or the object is destroyed, ::Release() is called and the interface's reference count is decremented.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiobject-setprivatedatainterface HRESULT
// SetPrivateDataInterface( REFGUID Name, const IUnknown *pUnknown );
new void SetPrivateDataInterface(in Guid Name, [In, Optional, MarshalAs(UnmanagedType.IUnknown)] object pUnknown);
/// Get a pointer to the object's data.
///
/// Type: REFGUID
/// A GUID identifying the data.
///
///
/// Type: UINT*
/// The size of the data.
///
///
/// Type: void*
/// Pointer to the data.
///
///
/// Type: HRESULT
/// Returns one of the following DXGI_ERROR.
///
///
///
/// If the data returned is a pointer to an IUnknown, or one of its derivative classes, previously set by
/// IDXGIObject::SetPrivateDataInterface, you must call ::Release() on the pointer before the pointer is freed to decrement the
/// reference count.
///
///
/// You can pass GUID_DeviceType in the Name parameter of GetPrivateData to retrieve the device type from the
/// display adapter object (IDXGIAdapter, IDXGIAdapter1, IDXGIAdapter2).
///
/// To get the type of device on which the display adapter was created
///
/// -
/// Call IUnknown::QueryInterface on the ID3D11Device or ID3D10Device object to retrieve the IDXGIDevice object.
///
/// -
/// Call GetParent on the IDXGIDevice object to retrieve the IDXGIAdapter object.
///
/// -
///
/// Call GetPrivateData on the IDXGIAdapter object with GUID_DeviceType to retrieve the type of device on which
/// the display adapter was created. pData will point to a value from the driver-type enumeration (for example, a value from D3D_DRIVER_TYPE).
///
///
///
///
/// On Windows 7 or earlier, this type is either a value from D3D10_DRIVER_TYPE or D3D_DRIVER_TYPE depending on which kind of
/// device was created. On Windows 8, this type is always a value from D3D_DRIVER_TYPE. Don't use
/// IDXGIObject::SetPrivateData with GUID_DeviceType because the behavior when doing so is undefined.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiobject-getprivatedata HRESULT GetPrivateData( REFGUID
// Name, UINT *pDataSize, void *pData );
[PreserveSig]
new HRESULT GetPrivateData(in Guid Name, ref uint pDataSize, [Out] IntPtr pData);
/// Gets the parent of the object.
///
/// Type: REFIID
/// The ID of the requested interface.
///
///
/// Type: void**
/// The address of a pointer to the parent object.
///
///
/// Type: HRESULT
/// Returns one of the DXGI_ERROR values.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiobject-getparent HRESULT GetParent( REFIID riid, void
// **ppParent );
new void GetParent(in Guid riid, [MarshalAs(UnmanagedType.Interface)] out object ppParent);
/// Retrieves the device.
///
/// Type: REFIID
/// The reference id for the device.
///
///
/// Type: void**
/// The address of a pointer to the device.
///
///
/// Type: HRESULT
/// A code that indicates success or failure (see DXGI_ERROR).
///
///
/// The type of interface that is returned can be any interface published by the device. For example, it could be an IDXGIDevice
/// * called pDevice, and therefore the REFIID would be obtained by calling __uuidof(pDevice).
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgidevicesubobject-getdevice HRESULT GetDevice( REFIID
// riid, void **ppDevice );
new void GetDevice(in Guid riid, [MarshalAs(UnmanagedType.Interface)] out object ppDevice);
/// Get a description of the surface.
///
/// Type: DXGI_SURFACE_DESC*
/// A pointer to the surface description (see DXGI_SURFACE_DESC).
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgisurface-getdesc HRESULT GetDesc( DXGI_SURFACE_DESC
// *pDesc );
DXGI_SURFACE_DESC GetDesc();
/// Get a pointer to the data contained in the surface, and deny GPU access to the surface.
///
/// Type: DXGI_MAPPED_RECT*
/// A pointer to the surface data (see DXGI_MAPPED_RECT).
///
///
/// Type: UINT
/// CPU read-write flags. These flags can be combined with a logical OR.
///
/// -
/// DXGI_MAP_READ - Allow CPU read access.
///
/// -
/// DXGI_MAP_WRITE - Allow CPU write access.
///
/// -
/// DXGI_MAP_DISCARD - Discard the previous contents of a resource when it is mapped.
///
///
///
///
/// Use IDXGISurface::Map to access a surface from the CPU. To release a mapped surface (and allow GPU access) call IDXGISurface::Unmap.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgisurface-map HRESULT Map( DXGI_MAPPED_RECT *pLockedRect,
// UINT MapFlags );
void Map(out DXGI_MAPPED_RECT pLockedRect, DXGI_MAP MapFlags);
/// Invalidate the pointer to the surface retrieved by IDXGISurface::Map and re-enable GPU access to the resource.
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgisurface-unmap HRESULT Unmap();
void Unmap();
}
///
/// An IDXGISwapChain interface implements one or more surfaces for storing rendered data before presenting it to an output.
///
///
/// You can create a swap chain by calling IDXGIFactory2::CreateSwapChainForHwnd, IDXGIFactory2::CreateSwapChainForCoreWindow, or
/// IDXGIFactory2::CreateSwapChainForComposition. You can also create a swap chain when you call D3D11CreateDeviceAndSwapChain;
/// however, you can then only access the sub-set of swap-chain functionality that the IDXGISwapChain interface provides.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nn-dxgi-idxgiswapchain
[PInvokeData("dxgi.h")]
[ComImport, Guid("310d36a0-d2e7-4c0a-aa04-6a9d23b8886a"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IDXGISwapChain : IDXGIDeviceSubObject
{
/// Sets application-defined data to the object and associates that data with a GUID.
///
/// Type: REFGUID
/// A GUID that identifies the data. Use this GUID in a call to GetPrivateData to get the data.
///
///
/// Type: UINT
/// The size of the object's data.
///
///
/// Type: const void*
/// A pointer to the object's data.
///
///
/// Type: HRESULT
/// Returns one of the DXGI_ERROR values.
///
///
/// SetPrivateData makes a copy of the specified data and stores it with the object.
///
/// Private data that SetPrivateData stores in the object occupies the same storage space as private data that is stored
/// by associated Direct3D objects (for example, by a Microsoft Direct3D 11 device through ID3D11Device::SetPrivateData or by a
/// Direct3D 11 child device through ID3D11DeviceChild::SetPrivateData).
///
///
/// The debug layer reports memory leaks by outputting a list of object interface pointers along with their friendly names. The
/// default friendly name is "<unnamed>". You can set the friendly name so that you can determine if the corresponding
/// object interface pointer caused the leak. To set the friendly name, use the SetPrivateData method and the well-known
/// private data GUID ( WKPDID_D3DDebugObjectName) that is in D3Dcommon.h. For example, to give pContext a friendly name
/// of My name, use the following code:
///
///
/// You can use WKPDID_D3DDebugObjectName to track down memory leaks and understand performance characteristics of your
/// applications. This information is reflected in the output of the debug layer that is related to memory leaks
/// (ID3D11Debug::ReportLiveDeviceObjects) and with the event tracing for Windows events that we've added to Windows 8.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiobject-setprivatedata HRESULT SetPrivateData( REFGUID
// Name, UINT DataSize, const void *pData );
new void SetPrivateData(in Guid Name, uint DataSize, IntPtr pData);
/// Set an interface in the object's private data.
///
/// Type: REFGUID
/// A GUID identifying the interface.
///
///
/// Type: const IUnknown*
/// The interface to set.
///
///
/// Type: HRESULT
/// Returns one of the following DXGI_ERROR.
///
///
/// This API associates an interface pointer with the object.
///
/// When the interface is set its reference count is incremented. When the data are overwritten (by calling SPD or SPDI with the
/// same GUID) or the object is destroyed, ::Release() is called and the interface's reference count is decremented.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiobject-setprivatedatainterface HRESULT
// SetPrivateDataInterface( REFGUID Name, const IUnknown *pUnknown );
new void SetPrivateDataInterface(in Guid Name, [In, Optional, MarshalAs(UnmanagedType.IUnknown)] object pUnknown);
/// Get a pointer to the object's data.
///
/// Type: REFGUID
/// A GUID identifying the data.
///
///
/// Type: UINT*
/// The size of the data.
///
///
/// Type: void*
/// Pointer to the data.
///
///
/// Type: HRESULT
/// Returns one of the following DXGI_ERROR.
///
///
///
/// If the data returned is a pointer to an IUnknown, or one of its derivative classes, previously set by
/// IDXGIObject::SetPrivateDataInterface, you must call ::Release() on the pointer before the pointer is freed to decrement the
/// reference count.
///
///
/// You can pass GUID_DeviceType in the Name parameter of GetPrivateData to retrieve the device type from the
/// display adapter object (IDXGIAdapter, IDXGIAdapter1, IDXGIAdapter2).
///
/// To get the type of device on which the display adapter was created
///
/// -
/// Call IUnknown::QueryInterface on the ID3D11Device or ID3D10Device object to retrieve the IDXGIDevice object.
///
/// -
/// Call GetParent on the IDXGIDevice object to retrieve the IDXGIAdapter object.
///
/// -
///
/// Call GetPrivateData on the IDXGIAdapter object with GUID_DeviceType to retrieve the type of device on which
/// the display adapter was created. pData will point to a value from the driver-type enumeration (for example, a value from D3D_DRIVER_TYPE).
///
///
///
///
/// On Windows 7 or earlier, this type is either a value from D3D10_DRIVER_TYPE or D3D_DRIVER_TYPE depending on which kind of
/// device was created. On Windows 8, this type is always a value from D3D_DRIVER_TYPE. Don't use
/// IDXGIObject::SetPrivateData with GUID_DeviceType because the behavior when doing so is undefined.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiobject-getprivatedata HRESULT GetPrivateData( REFGUID
// Name, UINT *pDataSize, void *pData );
[PreserveSig]
new HRESULT GetPrivateData(in Guid Name, ref uint pDataSize, [Out] IntPtr pData);
/// Gets the parent of the object.
///
/// Type: REFIID
/// The ID of the requested interface.
///
///
/// Type: void**
/// The address of a pointer to the parent object.
///
///
/// Type: HRESULT
/// Returns one of the DXGI_ERROR values.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiobject-getparent HRESULT GetParent( REFIID riid, void
// **ppParent );
new void GetParent(in Guid riid, [MarshalAs(UnmanagedType.Interface)] out object ppParent);
/// Retrieves the device.
///
/// Type: REFIID
/// The reference id for the device.
///
///
/// Type: void**
/// The address of a pointer to the device.
///
///
/// Type: HRESULT
/// A code that indicates success or failure (see DXGI_ERROR).
///
///
/// The type of interface that is returned can be any interface published by the device. For example, it could be an IDXGIDevice
/// * called pDevice, and therefore the REFIID would be obtained by calling __uuidof(pDevice).
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgidevicesubobject-getdevice HRESULT GetDevice( REFIID
// riid, void **ppDevice );
new void GetDevice(in Guid riid, [MarshalAs(UnmanagedType.Interface)] out object ppDevice);
/// Presents a rendered image to the user.
///
/// Type: UINT
/// An integer that specifies how to synchronize presentation of a frame with the vertical blank.
/// For the bit-block transfer (bitblt) model (DXGI_SWAP_EFFECT_DISCARDor DXGI_SWAP_EFFECT_SEQUENTIAL), values are:
///
/// -
/// 0 - The presentation occurs immediately, there is no synchronization.
///
/// -
/// 1 through 4 - Synchronize presentation after the nth vertical blank.
///
///
/// For the flip model (
/// DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL
/// ), values are:
///
/// -
/// 0 - Cancel the remaining time on the previously presented frame and discard this frame if a newer frame is queued.
///
/// -
/// 1 through 4 - Synchronize presentation for at least n vertical blanks.
///
///
/// For an example that shows how sync-interval values affect a flip presentation queue, see Remarks.
///
/// If the update region straddles more than one output (each represented by IDXGIOutput), Present performs the
/// synchronization to the output that contains the largest sub-rectangle of the target window's client area.
///
///
///
/// Type: UINT
/// An integer value that contains swap-chain presentation options. These options are defined by the DXGI_PRESENT constants.
///
///
/// Type: HRESULT
///
/// Possible return values include: S_OK, DXGI_ERROR_DEVICE_RESET or DXGI_ERROR_DEVICE_REMOVED (see DXGI_ERROR),
/// DXGI_STATUS_OCCLUDED (see DXGI_STATUS), or D3DDDIERR_DEVICEREMOVED.
///
///
/// Note The Present method can return either DXGI_ERROR_DEVICE_REMOVED or D3DDDIERR_DEVICEREMOVED if a video card
/// has been physically removed from the computer, or a driver upgrade for the video card has occurred.
///
///
///
///
/// Starting with Direct3D 11.1, consider using IDXGISwapChain1::Present1 because you can then use dirty rectangles and the
/// scroll rectangle in the swap chain presentation and as such use less memory bandwidth and as a result less system power. For
/// more info about using dirty rectangles and the scroll rectangle in swap chain presentation, see Using dirty rectangles and
/// the scroll rectangle in swap chain presentation.
///
///
/// For the best performance when flipping swap-chain buffers in a full-screen application, see Full-Screen Application
/// Performance Hints.
///
///
/// Because calling Present might cause the render thread to wait on the message-pump thread, be careful when calling
/// this method in an application that uses multiple threads. For more details, see Multithreading Considerations.
///
///
///
///
/// Differences between Direct3D 9 and Direct3D 10: Specifying DXGI_PRESENT_TEST in the Flags parameter is analogous to
/// IDirect3DDevice9::TestCooperativeLevel in Direct3D 9.
///
///
///
///
/// For flip presentation model swap chains that you create with the DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL value set, a successful
/// presentation unbinds back buffer 0 from the graphics pipeline, except for when you pass the DXGI_PRESENT_DO_NOT_SEQUENCE
/// flag in the Flags parameter.
///
/// For info about how data values change when you present content to the screen, see Converting data for the color space.
/// Flip presentation model queue
/// Suppose the following frames with sync-interval values are queued from oldest (A) to newest (E) before you call Present.
/// A: 3, B: 0, C: 0, D: 1, E: 0
///
/// When you call Present, the runtime shows frame A for only 1 vertical blank interval. The runtime terminates frame A
/// early because of the sync interval 0 in frame B. Then the runtime shows frame D for 1 vertical blank interval, and then
/// frame E until you submit a new presentation. The runtime discards frames B and C.
///
/// Variable refresh rate displays
///
/// It is a requirement of variable refresh rate displays that tearing is enabled. The CheckFeatureSupport method can be used to
/// determine if this feature is available, and to set the required flags refer to the descriptions of
/// DXGI_PRESENT_ALLOW_TEARING and DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING, and the Variable refresh rate displays/Vsync off
/// section of DXGI 1.5 Improvements.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiswapchain-present HRESULT Present( UINT SyncInterval,
// UINT Flags );
void Present(uint SyncInterval, DXGI_PRESENT Flags);
/// Accesses one of the swap-chain's back buffers.
///
/// Type: UINT
/// A zero-based buffer index.
///
/// If the swap chain's swap effect is DXGI_SWAP_EFFECT_DISCARD, this method can only access the first buffer; for this
/// situation, set the index to zero.
///
///
/// If the swap chain's swap effect is either DXGI_SWAP_EFFECT_SEQUENTIAL or DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL, only the swap
/// chain's zero-index buffer can be read from and written to. The swap chain's buffers with indexes greater than zero can only
/// be read from; so if you call the IDXGIResource::GetUsage method for such buffers, they have the DXGI_USAGE_READ_ONLY flag set.
///
///
///
/// Type: REFIID
/// The type of interface used to manipulate the buffer.
///
///
/// Type: void**
/// A pointer to a back-buffer interface.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiswapchain-getbuffer HRESULT GetBuffer( UINT Buffer,
// REFIID riid, void **ppSurface );
[return: MarshalAs(UnmanagedType.IUnknown)] object GetBuffer(uint Buffer, in Guid riid);
/// Sets the display state to windowed or full screen.
///
/// Type: BOOL
///
/// A Boolean value that specifies whether to set the display state to windowed or full screen. TRUE for full screen, and
/// FALSE for windowed.
///
///
///
/// Type: IDXGIOutput*
///
/// If you pass TRUE to the Fullscreen parameter to set the display state to full screen, you can optionally set this
/// parameter to a pointer to an IDXGIOutput interface for the output target that contains the swap chain. If you set this
/// parameter to NULL, DXGI will choose the output based on the swap-chain's device and the output window's placement. If
/// you pass FALSE to Fullscreen, you must set this parameter to NULL.
///
///
///
/// DXGI may change the display state of a swap chain in response to end user or system requests.
///
/// We recommend that you create a windowed swap chain and allow the end user to change the swap chain to full screen through
/// SetFullscreenState; that is, do not set the Windowed member of DXGI_SWAP_CHAIN_DESC to FALSE to force the swap
/// chain to be full screen. However, if you create the swap chain as full screen, also provide the end user with a list of
/// supported display modes because a swap chain that is created with an unsupported display mode might cause the display to go
/// black and prevent the end user from seeing anything. Also, we recommend that you have a time-out confirmation screen or
/// other fallback mechanism when you allow the end user to change display modes.
///
/// Notes for Windows Store apps
///
/// If a Windows Store app calls SetFullscreenState to set the display state to full screen, SetFullscreenState
/// fails with DXGI_ERROR_NOT_CURRENTLY_AVAILABLE.
///
/// You cannot call SetFullscreenState on a swap chain that you created with IDXGIFactory2::CreateSwapChainForComposition.
///
/// For the flip presentation model, after you transition the display state to full screen, you must call ResizeBuffers to
/// ensure that your call to IDXGISwapChain1::Present1 succeeds.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiswapchain-setfullscreenstate HRESULT SetFullscreenState(
// BOOL Fullscreen, IDXGIOutput *pTarget );
void SetFullscreenState([MarshalAs(UnmanagedType.Bool)] bool Fullscreen, [In, Optional] IDXGIOutput pTarget);
/// Get the state associated with full-screen mode.
///
/// Type: BOOL*
/// A pointer to a boolean whose value is either:
///
/// -
/// TRUE if the swap chain is in full-screen mode
///
/// -
/// FALSE if the swap chain is in windowed mode
///
///
///
///
/// Type: IDXGIOutput**
/// A pointer to the output target (see IDXGIOutput) when the mode is full screen; otherwise NULL.
///
///
/// When the swap chain is in full-screen mode, a pointer to the target output will be returned and its reference count will be incremented.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiswapchain-getfullscreenstate HRESULT GetFullscreenState(
// BOOL *pFullscreen, IDXGIOutput **ppTarget );
IDXGIOutput GetFullscreenState([MarshalAs(UnmanagedType.Bool)] out bool pFullscreen);
///
///
/// [Starting with Direct3D 11.1, we recommend not to use GetDesc anymore to get a description of the swap chain.
/// Instead, use IDXGISwapChain1::GetDesc1.]
///
/// Get a description of the swap chain.
///
///
/// Type: DXGI_SWAP_CHAIN_DESC*
/// A pointer to the swap-chain description (see DXGI_SWAP_CHAIN_DESC).
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiswapchain-getdesc HRESULT GetDesc( DXGI_SWAP_CHAIN_DESC
// *pDesc );
DXGI_SWAP_CHAIN_DESC GetDesc();
///
/// Changes the swap chain's back buffer size, format, and number of buffers. This should be called when the application window
/// is resized.
///
///
/// Type: UINT
///
/// The number of buffers in the swap chain (including all back and front buffers). This number can be different from the number
/// of buffers with which you created the swap chain. This number can't be greater than DXGI_MAX_SWAP_CHAIN_BUFFERS. Set
/// this number to zero to preserve the existing number of buffers in the swap chain. You can't specify less than two buffers
/// for the flip presentation model.
///
///
///
/// Type: UINT
///
/// The new width of the back buffer. If you specify zero, DXGI will use the width of the client area of the target window. You
/// can't specify the width as zero if you called the IDXGIFactory2::CreateSwapChainForComposition method to create the swap
/// chain for a composition surface.
///
///
///
/// Type: UINT
///
/// The new height of the back buffer. If you specify zero, DXGI will use the height of the client area of the target window.
/// You can't specify the height as zero if you called the IDXGIFactory2::CreateSwapChainForComposition method to create the
/// swap chain for a composition surface.
///
///
///
/// Type: DXGI_FORMAT
///
/// A DXGI_FORMAT-typed value for the new format of the back buffer. Set this value to DXGI_FORMAT_UNKNOWN to preserve the
/// existing format of the back buffer. The flip presentation model supports a more restricted set of formats than the bit-block
/// transfer (bitblt) model.
///
///
///
/// Type: UINT
///
/// A combination of DXGI_SWAP_CHAIN_FLAG-typed values that are combined by using a bitwise OR operation. The resulting value
/// specifies options for swap-chain behavior.
///
///
///
///
/// You can't resize a swap chain unless you release all outstanding references to its back buffers. You must release all of its
/// direct and indirect references on the back buffers in order for ResizeBuffers to succeed.
///
/// Direct references are held by the application after it calls AddRef on a resource.
///
/// Indirect references are held by views to a resource, binding a view of the resource to a device context, a command list that
/// used the resource, a command list that used a view to that resource, a command list that executed another command list that
/// used the resource, and so on.
///
///
/// Before you call ResizeBuffers, ensure that the application releases all references (by calling the appropriate number
/// of Release invocations) on the resources, any views to the resource, and any command lists that use either the resources or
/// views, and ensure that neither the resource nor a view is still bound to a device context. You can use
/// ID3D11DeviceContext::ClearState to ensure that all references are released. If a view is bound to a deferred context, you
/// must discard the partially built command list as well (by calling ID3D11DeviceContext::ClearState, then
/// ID3D11DeviceContext::FinishCommandList, then Release on the command list). After you call ResizeBuffers, you
/// can re-query interfaces via IDXGISwapChain::GetBuffer.
///
///
/// For swap chains that you created with DXGI_SWAP_CHAIN_FLAG_GDI_COMPATIBLE, before you call ResizeBuffers, also call
/// IDXGISurface1::ReleaseDC on the swap chain's back-buffer surface to ensure that you have no outstanding GDI device contexts
/// (DCs) open.
///
///
/// We recommend that you call ResizeBuffers when a client window is resized (that is, when an application receives a
/// WM_SIZE message).
///
///
/// The only difference between IDXGISwapChain::ResizeBuffers in Windows 8 versus Windows 7 is with flip presentation
/// model swap chains that you create with the DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL or DXGI_SWAP_EFFECT_FLIP_DISCARD value set. In
/// Windows 8, you must call ResizeBuffers to realize a transition between full-screen mode and windowed mode; otherwise,
/// your next call to the IDXGISwapChain::Present method fails.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiswapchain-resizebuffers HRESULT ResizeBuffers( UINT
// BufferCount, UINT Width, UINT Height, DXGI_FORMAT NewFormat, UINT SwapChainFlags );
void ResizeBuffers(uint BufferCount, uint Width, uint Height, DXGI_FORMAT NewFormat, uint SwapChainFlags);
/// Resizes the output target.
///
/// Type: const DXGI_MODE_DESC*
///
/// A pointer to a DXGI_MODE_DESC structure that describes the mode, which specifies the new width, height, format, and refresh
/// rate of the target. If the format is DXGI_FORMAT_UNKNOWN, ResizeTarget uses the existing format. We only recommend
/// that you use DXGI_FORMAT_UNKNOWN when the swap chain is in full-screen mode as this method is not thread safe.
///
///
///
///
/// ResizeTarget resizes the target window when the swap chain is in windowed mode, and changes the display mode on the
/// target output when the swap chain is in full-screen mode. Therefore, apps can call ResizeTarget to resize the target
/// window (rather than a Microsoft Win32API such as SetWindowPos) without knowledge of the swap chain display mode.
///
/// If a Windows Store app calls ResizeTarget, it fails with DXGI_ERROR_NOT_CURRENTLY_AVAILABLE.
/// You cannot call ResizeTarget on a swap chain that you created with IDXGIFactory2::CreateSwapChainForComposition.
///
/// Apps must still call IDXGISwapChain::ResizeBuffers after they call ResizeTarget because only ResizeBuffers can
/// change the back buffers. But, if those apps have implemented window resize processing to call ResizeBuffers, they
/// don't need to explicitly call ResizeBuffers after they call ResizeTarget because the window resize processing
/// will achieve what the app requires.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiswapchain-resizetarget HRESULT ResizeTarget( const
// DXGI_MODE_DESC *pNewTargetParameters );
void ResizeTarget(in DXGI_MODE_DESC pNewTargetParameters);
/// Get the output (the display monitor) that contains the majority of the client area of the target window.
///
/// Type: IDXGIOutput**
/// A pointer to the output interface (see IDXGIOutput).
///
///
///
/// If the method succeeds, the output interface will be filled and its reference count incremented. When you are finished with
/// it, be sure to release the interface to avoid a memory leak.
///
/// The output is also owned by the adapter on which the swap chain's device was created.
/// You cannot call GetContainingOutput on a swap chain that you created with IDXGIFactory2::CreateSwapChainForComposition.
///
/// To determine the output corresponding to such a swap chain, you should call IDXGIFactory::EnumAdapters and then
/// IDXGIAdapter::EnumOutputs to enumerate over all of the available outputs. You should then intersect the bounds of your
/// CoreWindow::Bounds with the desktop coordinates of each output, as reported by DXGI_OUTPUT_DESC1::DesktopCoordinates or DXGI_OUTPUT_DESC::DesktopCoordinates.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiswapchain-getcontainingoutput HRESULT
// GetContainingOutput( IDXGIOutput **ppOutput );
IDXGIOutput GetContainingOutput();
/// Gets performance statistics about the last render frame.
///
/// Type: DXGI_FRAME_STATISTICS*
/// A pointer to a DXGI_FRAME_STATISTICS structure for the frame statistics.
///
///
///
/// You cannot use GetFrameStatistics for swap chains that both use the bit-block transfer (bitblt) presentation model
/// and draw in windowed mode.
///
///
/// You can only use GetFrameStatistics for swap chains that either use the flip presentation model or draw in
/// full-screen mode. You set the DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL value in the SwapEffect member of the
/// DXGI_SWAP_CHAIN_DESC1 structure to specify that the swap chain uses the flip presentation model.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiswapchain-getframestatistics HRESULT GetFrameStatistics(
// DXGI_FRAME_STATISTICS *pStats );
DXGI_FRAME_STATISTICS GetFrameStatistics();
/// Gets the number of times that IDXGISwapChain::Present or IDXGISwapChain1::Present1 has been called.
///
/// Type: UINT*
/// A pointer to a variable that receives the number of calls.
///
/// For info about presentation statistics for a frame, see DXGI_FRAME_STATISTICS.
// https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiswapchain-getlastpresentcount HRESULT
// GetLastPresentCount( UINT *pLastPresentCount );
uint GetLastPresentCount();
}
}
}