1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-02-27 13:54:16 +01:00

[d3d11] Add COM interface for API-agnostic presenter

This commit is contained in:
Philip Rebohle 2018-10-22 22:42:28 +02:00
parent 64185d9be4
commit 967b276acb
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
6 changed files with 75 additions and 2 deletions

View File

@ -101,4 +101,21 @@ namespace dxvk {
return m_device->QueryInterface(riid, ppvDevice);
}
HRESULT STDMETHODCALLTYPE D3D11Presenter::CreateSwapChainForHwnd(
HWND hWnd,
const DXGI_SWAP_CHAIN_DESC1* pDesc,
IDXGIVkSwapChain** ppSwapChain) {
InitReturnPtr(ppSwapChain);
try {
*ppSwapChain = ref(new D3D11SwapChain(
static_cast<D3D11Device*>(m_device), hWnd, pDesc));
return S_OK;
} catch (const DxvkError& e) {
Logger::err(e.message());
return E_FAIL;
}
}
}

View File

@ -4,6 +4,7 @@
#include "../dxgi/dxgi_interfaces.h"
#include "d3d11_include.h"
#include "d3d11_swapchain.h"
#include "d3d11_texture.h"
namespace dxvk {
@ -63,6 +64,11 @@ namespace dxvk {
REFGUID riid,
void** ppvDevice);
HRESULT STDMETHODCALLTYPE CreateSwapChainForHwnd(
HWND hWnd,
const DXGI_SWAP_CHAIN_DESC1* pDesc,
IDXGIVkSwapChain** ppSwapChain);
private:
IDXGIObject* m_container;

View File

@ -39,6 +39,7 @@ d3d11_src = [
'd3d11_sampler.cpp',
'd3d11_shader.cpp',
'd3d11_state.cpp',
'd3d11_swapchain.cpp',
'd3d11_texture.cpp',
'd3d11_util.cpp',
'd3d11_view_dsv.cpp',
@ -47,7 +48,7 @@ d3d11_src = [
'd3d11_view_uav.cpp',
]
d3d11_dll = shared_library('d3d11'+dll_ext, d3d11_src + d3d10_src,
d3d11_dll = shared_library('d3d11'+dll_ext, d3d11_src + d3d10_src, glsl_generator.process(dxgi_shaders),
name_prefix : '',
dependencies : [ lib_dxgi, dxbc_dep, dxvk_dep ],
include_directories : dxvk_include_path,

View File

@ -89,7 +89,7 @@ namespace dxvk {
Rc<DxvkDevice> STDMETHODCALLTYPE GetDXVKDevice() final;
Rc<DxvkEvent> STDMETHODCALLTYPE GetFrameSyncEvent();
Rc<DxvkEvent> STDMETHODCALLTYPE GetFrameSyncEvent() final;
private:

View File

@ -10,11 +10,50 @@ namespace dxvk {
class DxvkAdapter;
class DxvkBuffer;
class DxvkDevice;
class DxvkEvent;
class DxvkImage;
}
struct IDXGIVkInteropDevice;
/**
* \brief Private DXGI presenter
*
* Presenter interface that allows the DXGI swap
* chain implementation to remain API-agnostic,
* so that common code can stay in one class.
*/
MIDL_INTERFACE("104001a6-7f36-4957-b932-86ade9567d91")
IDXGIVkSwapChain : public IUnknown {
static const GUID guid;
virtual HRESULT STDMETHODCALLTYPE GetDesc(
DXGI_SWAP_CHAIN_DESC1* pDesc) = 0;
virtual HRESULT STDMETHODCALLTYPE GetImage(
UINT BufferId,
REFIID riid,
void** ppBuffer) = 0;
virtual UINT STDMETHODCALLTYPE GetImageIndex() = 0;
virtual HRESULT STDMETHODCALLTYPE ChangeProperties(
const DXGI_SWAP_CHAIN_DESC1* pDesc) = 0;
virtual HRESULT STDMETHODCALLTYPE SetPresentRegion(
const RECT* pRegion) = 0;
virtual HRESULT STDMETHODCALLTYPE SetGammaControl(
UINT NumControlPoints,
const DXGI_RGB* pControlPoints) = 0;
virtual HRESULT STDMETHODCALLTYPE Present(
UINT SyncInterval,
UINT PresentFlags,
const DXGI_PRESENT_PARAMETERS* pPresentParameters) = 0;
};
/**
* \brief Private DXGI device interface
*
@ -29,6 +68,8 @@ IDXGIVkDevice : public IDXGIDevice2 {
virtual ~IDXGIVkDevice() { }
virtual dxvk::Rc<dxvk::DxvkDevice> STDMETHODCALLTYPE GetDXVKDevice() = 0;
virtual dxvk::Rc<dxvk::DxvkEvent> STDMETHODCALLTYPE GetFrameSyncEvent() = 0;
};
@ -143,6 +184,11 @@ IDXGIVkPresenter : public IUnknown {
virtual HRESULT STDMETHODCALLTYPE GetDevice(
REFGUID riid,
void** ppDevice) = 0;
virtual HRESULT STDMETHODCALLTYPE CreateSwapChainForHwnd(
HWND hWnd,
const DXGI_SWAP_CHAIN_DESC1* pDesc,
IDXGIVkSwapChain** ppSwapChain) = 0;
};
@ -294,6 +340,7 @@ struct __declspec(uuid("5679becd-8547-4d93-96a1-e61a1ce7ef37")) IDXGIVkBackBuffe
struct __declspec(uuid("79352328-16f2-4f81-9746-9c2e2ccd43cf")) IDXGIVkPresenter;
struct __declspec(uuid("e2ef5fa5-dc21-4af7-90c4-f67ef6a09323")) IDXGIVkInteropDevice;
struct __declspec(uuid("5546cf8c-77e7-4341-b05d-8d4d5000e77d")) IDXGIVkInteropSurface;
struct __declspec(uuid("104001a6-7f36-4957-b932-86ade9567d91")) IDXGIVkSwapChain;
#else
DXVK_DEFINE_GUID(IDXGIVkAdapter);
DXVK_DEFINE_GUID(IDXGIVkDevice);
@ -301,4 +348,5 @@ DXVK_DEFINE_GUID(IDXGIVkBackBuffer);
DXVK_DEFINE_GUID(IDXGIVkPresenter);
DXVK_DEFINE_GUID(IDXGIVkInteropDevice);
DXVK_DEFINE_GUID(IDXGIVkInteropSurface);
DXVK_DEFINE_GUID(IDXGIVkSwapChain);
#endif

View File

@ -10,6 +10,7 @@ const GUID IDXGIVkBackBuffer::guid = {0x5679becd,0x8547,0x4d93,{0x96,0xa1,0
const GUID IDXGIVkPresenter::guid = {0x79352328,0x16f2,0x4f81,{0x97,0x46,0x9c,0x2e,0x2c,0xcd,0x43,0xcf}};
const GUID IDXGIVkInteropDevice::guid = {0xe2ef5fa5,0xdc21,0x4af7,{0x90,0xc4,0xf6,0x7e,0xf6,0xa0,0x93,0x23}};
const GUID IDXGIVkInteropSurface::guid = {0x5546cf8c,0x77e7,0x4341,{0xb0,0x5d,0x8d,0x4d,0x50,0x00,0xe7,0x7d}};
const GUID IDXGIVkSwapChain::guid = {0x104001a6,0x7f36,0x4957,{0xb9,0x32,0x86,0xad,0xe9,0x56,0x7d,0x91}};
std::ostream& operator << (std::ostream& os, REFIID guid) {
os << std::hex << std::setfill('0')