2017-10-11 15:31:36 +02:00
|
|
|
#pragma once
|
|
|
|
|
2017-12-04 11:33:04 +01:00
|
|
|
#include "../dxvk/dxvk_include.h"
|
|
|
|
|
2018-04-12 15:36:01 +02:00
|
|
|
#include "dxgi_format.h"
|
2017-10-11 15:31:36 +02:00
|
|
|
#include "dxgi_include.h"
|
|
|
|
|
|
|
|
namespace dxvk {
|
|
|
|
class DxgiAdapter;
|
|
|
|
class DxvkAdapter;
|
2017-11-29 15:16:07 +01:00
|
|
|
class DxvkBuffer;
|
2017-10-11 15:31:36 +02:00
|
|
|
class DxvkDevice;
|
2017-11-29 15:16:07 +01:00
|
|
|
class DxvkImage;
|
2017-10-11 15:31:36 +02:00
|
|
|
}
|
2018-03-28 18:58:53 +02:00
|
|
|
|
2018-07-21 12:43:33 +02:00
|
|
|
struct IDXGIVkInteropDevice;
|
2018-03-28 18:58:53 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Private DXGI device interface
|
|
|
|
*
|
|
|
|
* The implementation of \c IDXGIDevice stores a
|
|
|
|
* \ref DxvkDevice which can be retrieved using
|
|
|
|
* this interface.
|
|
|
|
*/
|
|
|
|
MIDL_INTERFACE("7a622cf6-627a-46b2-b52f-360ef3da831c")
|
2018-03-28 19:06:00 +02:00
|
|
|
IDXGIVkDevice : public IDXGIDevice2 {
|
2018-03-28 18:58:53 +02:00
|
|
|
static const GUID guid;
|
2017-10-11 15:31:36 +02:00
|
|
|
|
2018-03-28 21:24:52 +02:00
|
|
|
virtual ~IDXGIVkDevice() { }
|
2018-03-28 18:58:53 +02:00
|
|
|
|
|
|
|
virtual dxvk::Rc<dxvk::DxvkDevice> STDMETHODCALLTYPE GetDXVKDevice() = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2017-10-11 15:31:36 +02:00
|
|
|
/**
|
2017-11-29 07:55:44 +01:00
|
|
|
* \brief Private DXGI adapter interface
|
2017-10-11 15:31:36 +02:00
|
|
|
*
|
|
|
|
* The implementation of \c IDXGIAdapter holds a
|
|
|
|
* \ref DxvkAdapter which can be retrieved using
|
|
|
|
* this interface.
|
|
|
|
*/
|
|
|
|
MIDL_INTERFACE("907bf281-ea3c-43b4-a8e4-9f231107b4ff")
|
2018-05-22 23:48:07 +02:00
|
|
|
IDXGIVkAdapter : public IDXGIAdapter2 {
|
2017-10-11 15:31:36 +02:00
|
|
|
static const GUID guid;
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
virtual dxvk::Rc<dxvk::DxvkAdapter> STDMETHODCALLTYPE GetDXVKAdapter() = 0;
|
2017-12-04 11:33:04 +01:00
|
|
|
|
2018-03-28 18:58:53 +02:00
|
|
|
/**
|
|
|
|
* \brief Creates a DXGI device object
|
|
|
|
*
|
|
|
|
* \param [in] pAdapter The adapter
|
|
|
|
* \param [in] pFeatures Device features to enable
|
|
|
|
* \param [out] ppDevice The DXGI device object
|
|
|
|
* \returns \c S_OK on success, or an error code
|
|
|
|
*/
|
|
|
|
virtual HRESULT STDMETHODCALLTYPE CreateDevice(
|
2018-03-28 21:24:52 +02:00
|
|
|
IDXGIObject* pContainer,
|
2018-07-31 16:58:25 +02:00
|
|
|
const dxvk::DxvkDeviceFeatures* pFeatures,
|
2018-03-28 21:24:52 +02:00
|
|
|
IDXGIVkDevice** ppDevice) = 0;
|
2018-03-28 18:58:53 +02:00
|
|
|
|
2017-12-19 14:47:35 +01:00
|
|
|
/**
|
|
|
|
* \brief Maps a DXGI format to a compatible Vulkan format
|
|
|
|
*
|
|
|
|
* For color formats, the returned Vulkan format has the
|
|
|
|
* same memory layout as the DXGI format so that it can
|
|
|
|
* be mapped and copied to buffers. For depth-stencil
|
|
|
|
* formats, this is not guaranteed.
|
|
|
|
* \param [in] format The DXGI format
|
|
|
|
* \param [in] mode Format lookup mode
|
2018-07-03 12:42:17 +02:00
|
|
|
* \returns Vulkan format mapping
|
2017-12-19 14:47:35 +01:00
|
|
|
*/
|
2018-04-12 15:36:01 +02:00
|
|
|
virtual dxvk::DXGI_VK_FORMAT_INFO STDMETHODCALLTYPE LookupFormat(
|
2018-07-03 12:42:17 +02:00
|
|
|
DXGI_FORMAT Format,
|
|
|
|
dxvk::DXGI_VK_FORMAT_MODE Mode) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Queries the compatibility family of a given format
|
|
|
|
*
|
|
|
|
* \param [in] Format The DXGI format
|
|
|
|
* \param [in] Mode Format lookup mode
|
|
|
|
* \returns Format family
|
|
|
|
*/
|
|
|
|
virtual dxvk::DXGI_VK_FORMAT_FAMILY STDMETHODCALLTYPE LookupFormatFamily(
|
|
|
|
DXGI_FORMAT Format,
|
|
|
|
dxvk::DXGI_VK_FORMAT_MODE Mode) = 0;
|
2017-10-11 15:31:36 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2017-11-29 15:16:07 +01:00
|
|
|
/**
|
2017-12-19 16:01:50 +01:00
|
|
|
* \brief Swap chain back buffer interface
|
|
|
|
*
|
|
|
|
* Allows the swap chain and presenter to query
|
|
|
|
* the underlying image while it is embedded in
|
|
|
|
* a texture object specified by the client API.
|
2017-11-29 15:16:07 +01:00
|
|
|
*/
|
|
|
|
MIDL_INTERFACE("5679becd-8547-4d93-96a1-e61a1ce7ef37")
|
2018-03-28 19:06:00 +02:00
|
|
|
IDXGIVkBackBuffer : public IUnknown {
|
2017-11-29 15:16:07 +01:00
|
|
|
static const GUID guid;
|
|
|
|
|
2017-12-19 16:01:50 +01:00
|
|
|
virtual dxvk::Rc<dxvk::DxvkImage> GetDXVKImage() = 0;
|
2017-11-29 15:16:07 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2017-11-29 16:23:33 +01:00
|
|
|
/**
|
|
|
|
* \brief Private presentation device interface
|
|
|
|
*
|
|
|
|
* Allows a swap chain to communicate with the device
|
|
|
|
* in order to flush pending commands or create the
|
|
|
|
* back buffer interface.
|
|
|
|
*/
|
|
|
|
MIDL_INTERFACE("79352328-16f2-4f81-9746-9c2e2ccd43cf")
|
2018-03-28 19:06:00 +02:00
|
|
|
IDXGIVkPresenter : public IUnknown {
|
2017-11-29 16:23:33 +01:00
|
|
|
static const GUID guid;
|
|
|
|
|
|
|
|
/**
|
2017-12-19 16:01:50 +01:00
|
|
|
* \brief Creates a swap chain back buffer
|
2017-11-29 16:23:33 +01:00
|
|
|
*
|
2018-03-28 21:24:52 +02:00
|
|
|
* \param [in] pSwapChainDesc Swap chain description
|
|
|
|
* \param [out] ppBackBuffer The swap chain back buffer
|
2017-11-29 16:23:33 +01:00
|
|
|
* \returns \c S_OK on success
|
|
|
|
*/
|
2017-12-19 16:01:50 +01:00
|
|
|
virtual HRESULT STDMETHODCALLTYPE CreateSwapChainBackBuffer(
|
2018-05-23 01:06:34 +02:00
|
|
|
const DXGI_SWAP_CHAIN_DESC1* pSwapChainDesc,
|
2018-03-28 21:24:52 +02:00
|
|
|
IDXGIVkBackBuffer** ppBackBuffer) = 0;
|
2017-11-29 16:23:33 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Flushes the immediate context
|
|
|
|
*
|
|
|
|
* Used by the swap chain's \c Present method to
|
|
|
|
* ensure that all rendering commands get dispatched
|
|
|
|
* before presenting the swap chain's back buffer.
|
|
|
|
* \returns \c S_OK on success
|
|
|
|
*/
|
2017-12-12 12:50:52 +01:00
|
|
|
virtual HRESULT STDMETHODCALLTYPE FlushRenderingCommands() = 0;
|
2017-11-29 16:23:33 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Underlying DXVK device
|
|
|
|
*
|
|
|
|
* \param [in] riid Device type
|
|
|
|
* \param [in] ppDevice device
|
|
|
|
* \returns DXVK device handle
|
|
|
|
*/
|
2017-12-12 12:50:52 +01:00
|
|
|
virtual HRESULT STDMETHODCALLTYPE GetDevice(
|
2017-11-29 16:23:33 +01:00
|
|
|
REFGUID riid,
|
|
|
|
void** ppDevice) = 0;
|
|
|
|
};
|
|
|
|
|
2018-04-19 15:46:57 +02:00
|
|
|
|
2018-04-19 20:13:53 +02:00
|
|
|
/**
|
|
|
|
* \brief DXGI surface interface for Vulkan interop
|
|
|
|
*
|
|
|
|
* Provides access to the backing resource of a
|
|
|
|
* DXGI surface, which is typically a D3D texture.
|
|
|
|
*/
|
|
|
|
MIDL_INTERFACE("5546cf8c-77e7-4341-b05d-8d4d5000e77d")
|
|
|
|
IDXGIVkInteropSurface : public IUnknown {
|
|
|
|
static const GUID guid;
|
|
|
|
|
2018-05-01 23:30:39 +02:00
|
|
|
/**
|
|
|
|
* \brief Retrieves device interop interfaceSlots
|
|
|
|
*
|
|
|
|
* Queries the device that owns the surface for
|
|
|
|
* the \ref IDXGIVkInteropDevice interface.
|
|
|
|
* \param [out] ppDevice The device interface
|
|
|
|
* \returns \c S_OK on success
|
|
|
|
*/
|
|
|
|
virtual HRESULT STDMETHODCALLTYPE GetDevice(
|
|
|
|
IDXGIVkInteropDevice** ppDevice) = 0;
|
|
|
|
|
2018-04-19 20:13:53 +02:00
|
|
|
/**
|
|
|
|
* \brief Retrieves Vulkan image info
|
|
|
|
*
|
|
|
|
* Retrieves both the image handle as well as the image's
|
|
|
|
* properties. Any of the given pointers may be \c nullptr.
|
|
|
|
*
|
|
|
|
* If \c pInfo is not \c nullptr, the following rules apply:
|
|
|
|
* - \c pInfo->sType \e must be \c VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO
|
2018-04-20 10:38:39 +02:00
|
|
|
* - \c pInfo->pNext \e must be \c nullptr or point to a supported
|
2018-04-19 20:13:53 +02:00
|
|
|
* extension-specific structure (currently none)
|
|
|
|
* - \c pInfo->queueFamilyIndexCount must be the length of the
|
|
|
|
* \c pInfo->pQueueFamilyIndices array, in \c uint32_t units.
|
|
|
|
* - \c pInfo->pQueueFamilyIndices must point to a pre-allocated
|
|
|
|
* array of \c uint32_t of size \c pInfo->pQueueFamilyIndices.
|
|
|
|
*
|
2018-04-20 10:38:39 +02:00
|
|
|
* \note As of now, the sharing mode will always be
|
|
|
|
* \c VK_SHARING_MODE_EXCLUSIVE and no queue
|
|
|
|
* family indices will be written to the array.
|
|
|
|
*
|
2018-04-19 20:13:53 +02:00
|
|
|
* After the call, the structure pointed to by \c pInfo can
|
|
|
|
* be used to create an image with identical properties.
|
|
|
|
*
|
|
|
|
* If \c pLayout is not \c nullptr, it will receive the
|
|
|
|
* layout that the image will be in after flushing any
|
|
|
|
* outstanding commands on the device.
|
|
|
|
* \param [out] pHandle The image handle
|
|
|
|
* \param [out] pLayout Image layout
|
|
|
|
* \param [out] pInfo Image properties
|
|
|
|
* \returns \c S_OK on success, or \c E_INVALIDARG
|
|
|
|
*/
|
|
|
|
virtual HRESULT STDMETHODCALLTYPE GetVulkanImageInfo(
|
|
|
|
VkImage* pHandle,
|
|
|
|
VkImageLayout* pLayout,
|
|
|
|
VkImageCreateInfo* pInfo) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-04-19 15:46:57 +02:00
|
|
|
/**
|
|
|
|
* \brief DXGI device interface for Vulkan interop
|
|
|
|
*
|
|
|
|
* Provides access to the device and instance handles
|
|
|
|
* as well as the queue that is used for rendering.
|
|
|
|
*/
|
|
|
|
MIDL_INTERFACE("e2ef5fa5-dc21-4af7-90c4-f67ef6a09323")
|
|
|
|
IDXGIVkInteropDevice : public IUnknown {
|
|
|
|
static const GUID guid;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Queries Vulkan handles used by DXVK
|
|
|
|
*
|
|
|
|
* \param [out] pInstance The Vulkan instance
|
|
|
|
* \param [out] pPhysDev The physical device
|
|
|
|
* \param [out] pDevide The device handle
|
|
|
|
*/
|
|
|
|
virtual void STDMETHODCALLTYPE GetVulkanHandles(
|
|
|
|
VkInstance* pInstance,
|
|
|
|
VkPhysicalDevice* pPhysDev,
|
|
|
|
VkDevice* pDevice) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Queries the rendering queue used by DXVK
|
|
|
|
*
|
|
|
|
* \param [out] pQueue The Vulkan queue handle
|
|
|
|
* \param [out] pQueueFamilyIndex Queue family index
|
|
|
|
*/
|
|
|
|
virtual void STDMETHODCALLTYPE GetSubmissionQueue(
|
|
|
|
VkQueue* pQueue,
|
|
|
|
uint32_t* pQueueFamilyIndex) = 0;
|
|
|
|
|
2018-04-19 20:13:53 +02:00
|
|
|
/**
|
|
|
|
* \brief Transitions a surface to a given layout
|
|
|
|
*
|
|
|
|
* Executes an explicit image layout transition on the
|
|
|
|
* D3D device. Note that the image subresources \e must
|
|
|
|
* be transitioned back to its original layout before
|
|
|
|
* using it again from D3D11.
|
|
|
|
* \param [in] pSurface The image to transform
|
|
|
|
* \param [in] pSubresources Subresources to transform
|
|
|
|
* \param [in] OldLayout Current image layout
|
|
|
|
* \param [in] NewLayout Desired image layout
|
|
|
|
*/
|
2018-04-20 00:19:03 +02:00
|
|
|
virtual void STDMETHODCALLTYPE TransitionSurfaceLayout(
|
2018-04-19 20:13:53 +02:00
|
|
|
IDXGIVkInteropSurface* pSurface,
|
|
|
|
const VkImageSubresourceRange* pSubresources,
|
|
|
|
VkImageLayout OldLayout,
|
|
|
|
VkImageLayout NewLayout) = 0;
|
|
|
|
|
2018-04-19 15:46:57 +02:00
|
|
|
/**
|
|
|
|
* \brief Flushes outstanding D3D rendering commands
|
|
|
|
*
|
|
|
|
* Must be called before submitting Vulkan commands
|
|
|
|
* to the rendering queue if those commands use the
|
|
|
|
* backing resource of a D3D11 object.
|
|
|
|
*/
|
|
|
|
virtual void STDMETHODCALLTYPE FlushRenderingCommands() = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Locks submission queue
|
|
|
|
*
|
|
|
|
* Should be called immediately before submitting
|
|
|
|
* Vulkan commands to the rendering queue in order
|
|
|
|
* to prevent DXVK from using the queue.
|
2018-04-19 20:13:53 +02:00
|
|
|
*
|
|
|
|
* While the submission queue is locked, no D3D11
|
|
|
|
* methods must be called from the locking thread,
|
|
|
|
* or otherwise a deadlock might occur.
|
2018-04-19 15:46:57 +02:00
|
|
|
*/
|
|
|
|
virtual void STDMETHODCALLTYPE LockSubmissionQueue() = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Releases submission queue
|
|
|
|
*
|
|
|
|
* Should be called immediately after submitting
|
|
|
|
* Vulkan commands to the rendering queue in order
|
|
|
|
* to allow DXVK to submit new commands.
|
|
|
|
*/
|
|
|
|
virtual void STDMETHODCALLTYPE ReleaseSubmissionQueue() = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-03-06 18:34:34 +01:00
|
|
|
#ifdef _MSC_VER
|
2018-03-28 19:06:00 +02:00
|
|
|
struct __declspec(uuid("907bf281-ea3c-43b4-a8e4-9f231107b4ff")) IDXGIVkAdapter;
|
|
|
|
struct __declspec(uuid("7a622cf6-627a-46b2-b52f-360ef3da831c")) IDXGIVkDevice;
|
|
|
|
struct __declspec(uuid("5679becd-8547-4d93-96a1-e61a1ce7ef37")) IDXGIVkBackBuffer;
|
|
|
|
struct __declspec(uuid("79352328-16f2-4f81-9746-9c2e2ccd43cf")) IDXGIVkPresenter;
|
2018-04-19 15:46:57 +02:00
|
|
|
struct __declspec(uuid("e2ef5fa5-dc21-4af7-90c4-f67ef6a09323")) IDXGIVkInteropDevice;
|
2018-04-19 20:13:53 +02:00
|
|
|
struct __declspec(uuid("5546cf8c-77e7-4341-b05d-8d4d5000e77d")) IDXGIVkInteropSurface;
|
2018-03-06 18:34:34 +01:00
|
|
|
#else
|
2018-03-28 19:06:00 +02:00
|
|
|
DXVK_DEFINE_GUID(IDXGIVkAdapter);
|
|
|
|
DXVK_DEFINE_GUID(IDXGIVkDevice);
|
|
|
|
DXVK_DEFINE_GUID(IDXGIVkBackBuffer);
|
|
|
|
DXVK_DEFINE_GUID(IDXGIVkPresenter);
|
2018-04-19 15:46:57 +02:00
|
|
|
DXVK_DEFINE_GUID(IDXGIVkInteropDevice);
|
2018-04-19 20:13:53 +02:00
|
|
|
DXVK_DEFINE_GUID(IDXGIVkInteropSurface);
|
2018-03-06 18:34:34 +01:00
|
|
|
#endif
|