// Copyright (c) Microsoft Corporation.  All Rights Reserved
cpp_quote("// Copyright (c) Microsoft Corporation.  All Rights Reserved")

import "dxgi1_5.idl";

cpp_quote("#include <winapifamily.h>")

#pragma region App Family
cpp_quote("#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_GAMES)")

cpp_quote( "HRESULT WINAPI DXGIDeclareAdapterRemovalSupport();" )

typedef enum DXGI_ADAPTER_FLAG3
{
    DXGI_ADAPTER_FLAG3_NONE                         = 0,
    DXGI_ADAPTER_FLAG3_REMOTE                       = 1,
    DXGI_ADAPTER_FLAG3_SOFTWARE                     = 2,
    DXGI_ADAPTER_FLAG3_ACG_COMPATIBLE               = 4,
    DXGI_ADAPTER_FLAG3_SUPPORT_MONITORED_FENCES     = 8,
    DXGI_ADAPTER_FLAG3_SUPPORT_NON_MONITORED_FENCES = 0x10,
    DXGI_ADAPTER_FLAG3_KEYED_MUTEX_CONFORMANCE      = 0x20,
    DXGI_ADAPTER_FLAG3_FORCE_DWORD                  = 0xFFFFFFFF,
} DXGI_ADAPTER_FLAG3;
cpp_quote( "DEFINE_ENUM_FLAG_OPERATORS( DXGI_ADAPTER_FLAG3 );" )

typedef struct DXGI_ADAPTER_DESC3
{
    WCHAR Description[128];

    UINT VendorId;
    UINT DeviceId;
    UINT SubSysId;
    UINT Revision;

    SIZE_T DedicatedVideoMemory;
    SIZE_T DedicatedSystemMemory;
    SIZE_T SharedSystemMemory;

    LUID AdapterLuid;

    DXGI_ADAPTER_FLAG3 Flags;

    DXGI_GRAPHICS_PREEMPTION_GRANULARITY GraphicsPreemptionGranularity;
    DXGI_COMPUTE_PREEMPTION_GRANULARITY ComputePreemptionGranularity;
} DXGI_ADAPTER_DESC3;

//--------------------------------------------------------------------------------------------------------
// IDXGIAdapter4 interface
//--------------------------------------------------------------------------------------------------------
[
    object,
    uuid(3c8d99d1-4fbf-4181-a82c-af66bf7bd24e),
    local,
    pointer_default(unique)
]
interface IDXGIAdapter4 :
    IDXGIAdapter3
{
    HRESULT GetDesc3( [out, annotation("_Out_")] DXGI_ADAPTER_DESC3 *pDesc);
};

//--------------------------------------------------------------------------------------------------------
typedef struct DXGI_OUTPUT_DESC1
{
    // Device name for GDI (ex. \\.\DISPLAY1)
    WCHAR DeviceName[32];
    RECT DesktopCoordinates;
    BOOL AttachedToDesktop;
    DXGI_MODE_ROTATION Rotation;
    HMONITOR Monitor;

    // Number of bits per color channel being
    // used for scanout on this output
    UINT BitsPerColor;

    // Represents whether the current OS state can take
    // advantage of color values larger than sRGB and also
    // specifies if there is any headroom
    DXGI_COLOR_SPACE_TYPE ColorSpace;

    // Color primaries of this output in xy coordinates
    FLOAT RedPrimary[2];
    FLOAT GreenPrimary[2];
    FLOAT BluePrimary[2];

    // White point of this output in xy coordinates
    FLOAT WhitePoint[2];

    // Minimum luminance supported on this output in nits
    FLOAT MinLuminance;

    // Maximum peak luminance supported on this output
    // in nits; usually only possible on a small fraction
    // of the display
    FLOAT MaxLuminance;

    // Maximum average luminance supported on this
    // output in nits; valid for the full frame of the
    // display
    FLOAT MaxFullFrameLuminance;
} DXGI_OUTPUT_DESC1;

//--------------------------------------------------------------------------------------------------------
typedef enum DXGI_HARDWARE_COMPOSITION_SUPPORT_FLAGS
{
    DXGI_HARDWARE_COMPOSITION_SUPPORT_FLAG_FULLSCREEN = 1,
    DXGI_HARDWARE_COMPOSITION_SUPPORT_FLAG_WINDOWED = 2,
    DXGI_HARDWARE_COMPOSITION_SUPPORT_FLAG_CURSOR_STRETCHED = 4,
} DXGI_HARDWARE_COMPOSITION_SUPPORT_FLAGS;
cpp_quote("DEFINE_ENUM_FLAG_OPERATORS( DXGI_HARDWARE_COMPOSITION_SUPPORT_FLAGS );")

//--------------------------------------------------------------------------------------------------------
// IDXGIOutput6 interface
//--------------------------------------------------------------------------------------------------------
[
    object,
    uuid(068346e8-aaec-4b84-add7-137f513f77a1),
    local,
    pointer_default(unique)
]
interface IDXGIOutput6 :
    IDXGIOutput5
{
    HRESULT GetDesc1([out, annotation("_Out_")] DXGI_OUTPUT_DESC1 *pDesc);
    HRESULT CheckHardwareCompositionSupport([out, annotation("_Out_")] UINT* pFlags);
};

//+-----------------------------------------------------------------------------
//
//  Enum for GPU Preference categories
//
//------------------------------------------------------------------------------
typedef enum DXGI_GPU_PREFERENCE
{
    DXGI_GPU_PREFERENCE_UNSPECIFIED = 0,
    DXGI_GPU_PREFERENCE_MINIMUM_POWER,
    DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE,

} DXGI_GPU_PREFERENCE;

//--------------------------------------------------------------------------------------------------------
// IDXGIFactory6 interface
//--------------------------------------------------------------------------------------------------------
[
    object,
    uuid(c1b6694f-ff09-44a9-b03c-77900a0a1d17),
    local,
    pointer_default(unique)
]
interface IDXGIFactory6 :
    IDXGIFactory5
{
    HRESULT EnumAdapterByGpuPreference(
        [annotation("_In_")] UINT Adapter,
        [annotation("_In_")] DXGI_GPU_PREFERENCE GpuPreference,
        [annotation("_In_")] REFIID riid,
        [annotation("_COM_Outptr_")] void** ppvAdapter
    );
};

//--------------------------------------------------------------------------------------------------------
// IDXGIFactory7 interface
//--------------------------------------------------------------------------------------------------------
[
    object,
    uuid(a4966eed-76db-44da-84c1-ee9a7afb20a8),
    local,
    pointer_default(unique)
]
interface IDXGIFactory7 :
    IDXGIFactory6
{
    HRESULT RegisterAdaptersChangedEvent(
        [in, annotation("_In_")] HANDLE hEvent,
        [out, annotation("_Out_")] DWORD *pdwCookie
    );

    HRESULT UnregisterAdaptersChangedEvent([in, annotation("_In_")] DWORD dwCookie);
};

//--------------------------------------------------------------------------------------------------------

cpp_quote("#if (NTDDI_VERSION >= NTDDI_WIN10_NI)" )
cpp_quote( "HRESULT WINAPI DXGIDisableVBlankVirtualization();" )
cpp_quote("#endif" )

cpp_quote("#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_GAMES) */")
#pragma endregion

cpp_quote( "DEFINE_GUID(IID_IDXGIAdapter4,0x3c8d99d1,0x4fbf,0x4181,0xa8,0x2c,0xaf,0x66,0xbf,0x7b,0xd2,0x4e);" )
cpp_quote( "DEFINE_GUID(IID_IDXGIOutput6,0x068346e8,0xaaec,0x4b84,0xad,0xd7,0x13,0x7f,0x51,0x3f,0x77,0xa1);" )
cpp_quote( "DEFINE_GUID(IID_IDXGIFactory6,0xc1b6694f,0xff09,0x44a9,0xb0,0x3c,0x77,0x90,0x0a,0x0a,0x1d,0x17);" )
cpp_quote( "DEFINE_GUID(IID_IDXGIFactory7,0xa4966eed,0x76db,0x44da,0x84,0xc1,0xee,0x9a,0x7a,0xfb,0x20,0xa8);" )
