/*
 * Copyright 2020 Joshua Ashton for Valve Software
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 *
 */

import "vkd3d_windows.h";
import "vkd3d_dxgibase.idl";
import "vkd3d_dxgi1_5.idl";
import "vkd3d_vk_includes.h";

typedef struct DXGI_VK_HDR_METADATA
{
    DXGI_HDR_METADATA_TYPE Type;
    union
    {
        DXGI_HDR_METADATA_HDR10 HDR10;
    };
} DXGI_VK_HDR_METADATA;

typedef struct DXGI_VK_FRAME_STATISTICS
{
    UINT64 PresentCount;
    UINT64 PresentQPCTime;
} DXGI_VK_FRAME_STATISTICS;

[
    object,
    local,
    uuid(1e7895a1-1bc3-4f9c-a670-290a4bc9581a)
]
interface IDXGIVkSurfaceFactory : IUnknown {
    VkResult CreateSurface(
        VkInstance instance,
        VkPhysicalDevice adapter,
        VkSurfaceKHR *pSurface);
};

[
    object,
    local,
    uuid(e4a9059e-b569-46ab-8de7-501bd2bc7f7a)
]
interface IDXGIVkSwapChain : IUnknown {
    HRESULT GetDesc(
            DXGI_SWAP_CHAIN_DESC1*    pDesc);

    HRESULT GetAdapter(
            REFIID                    riid,
            void**                    ppvObject);

    HRESULT GetDevice(
            REFIID                    riid,
            void**                    ppDevice);

    HRESULT GetImage(
            UINT                      BufferId,
            REFIID                    riid,
            void**                    ppBuffer);

    UINT GetImageIndex();

    UINT GetFrameLatency();

    HANDLE GetFrameLatencyEvent();

    HRESULT ChangeProperties(
      const DXGI_SWAP_CHAIN_DESC1*    pDesc,
      const UINT*                     pNodeMasks,
            IUnknown* const*          ppPresentQueues);

    HRESULT SetPresentRegion(
      const RECT*                     pRegion);

    HRESULT SetGammaControl(
            UINT                      NumControlPoints,
      const DXGI_RGB*                 pControlPoints);

    HRESULT SetFrameLatency(
            UINT                      MaxLatency);

    HRESULT Present(
            UINT                      SyncInterval,
            UINT                      PresentFlags,
      const DXGI_PRESENT_PARAMETERS*  pPresentParameters);

    UINT CheckColorSpaceSupport(
            DXGI_COLOR_SPACE_TYPE     ColorSpace);

    HRESULT SetColorSpace(
            DXGI_COLOR_SPACE_TYPE     ColorSpace);

    HRESULT SetHDRMetaData(
      const DXGI_VK_HDR_METADATA*     pMetaData);
}

[
    object,
    local,
    uuid(785326d4-b77b-4826-ae70-8d08308ee6d1)
]
interface IDXGIVkSwapChain1 : IDXGIVkSwapChain
{
    void GetLastPresentCount(
        UINT64*                   pLastPresentCount);

    void GetFrameStatistics(
        DXGI_VK_FRAME_STATISTICS* pFrameStatistics);
}

[
    object,
    local,
    uuid(aed91093-e02e-458c-bdef-a97da1a7e6d2)
]
interface IDXGIVkSwapChain2 : IDXGIVkSwapChain1
{
    void SetTargetFrameRate(
        double                    FrameRate);
}

[
    object,
    local,
    uuid(e7d6c3ca-23a0-4e08-9f2f-ea5231df6633)
]
interface IDXGIVkSwapChainFactory : IUnknown {
  HRESULT CreateSwapChain(
    IDXGIVkSurfaceFactory*          pSurfaceFactory,
    const DXGI_SWAP_CHAIN_DESC1*    pDesc,
          IDXGIVkSwapChain**        ppSwapChain);
}

