/*
 * Copyright (C) 2024 Mohamad Al-Jaf
 *
 * 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
 */

cpp_quote("#include <d3d9.h>")
import "d3d12.idl";

interface IDirect3D9;
interface IDirect3DResource9;

#define MAX_D3D9ON12_QUEUES 2

typedef struct D3D9ON12_ARGS
{
    BOOL Enable9On12;
    IUnknown *pD3D12Device;
    IUnknown *ppD3D12Queues[MAX_D3D9ON12_QUEUES];
    UINT NumQueues;
    UINT NodeMask;
} D3D9ON12_ARGS;

typedef IDirect3D9 * (__stdcall *PFN_Direct3DCreate9On12)(UINT sdk_version, D3D9ON12_ARGS *d3d9on12_args, UINT d3d9on12_args_count);
IDirect3D9 * __stdcall Direct3DCreate9On12(UINT,D3D9ON12_ARGS *,UINT);

typedef struct IDirect3DDevice9On12 *LPDIRECT3DDEVICE9ON12, *PDIRECT3DDEVICE9ON12;

[
    local,
    object,
    uuid(e7fda234-b589-4049-940d-8878977531c8)
]
interface IDirect3DDevice9On12 : IUnknown
{
    HRESULT GetD3D12Device(REFIID riid, void **out);
    HRESULT UnwrapUnderlyingResource(IDirect3DResource9 *resource, ID3D12CommandQueue *queue, REFIID riid, void **out);
    HRESULT ReturnUnderlyingResource(IDirect3DResource9 *resource, UINT fence_count, UINT64 *signal_values, ID3D12Fence **fences);
}
