1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-12 04:08:52 +01:00

[d3d11] Implement IWineDXGISwapChainFactory

See #822.
This commit is contained in:
Philip Rebohle 2018-12-21 12:23:45 +01:00
parent dc2cde3395
commit 1e393bf24d
5 changed files with 115 additions and 1 deletions

View File

@ -1,6 +1,8 @@
#include <algorithm> #include <algorithm>
#include <cstring> #include <cstring>
#include "../dxgi/dxgi_swapchain.h"
#include "../dxvk/dxvk_adapter.h" #include "../dxvk/dxvk_adapter.h"
#include "../dxvk/dxvk_instance.h" #include "../dxvk/dxvk_instance.h"
@ -1669,6 +1671,52 @@ namespace dxvk {
WineDXGISwapChainFactory::WineDXGISwapChainFactory(IUnknown* pContainer)
: m_container(pContainer) {
}
ULONG STDMETHODCALLTYPE WineDXGISwapChainFactory::AddRef() {
return m_container->AddRef();
}
ULONG STDMETHODCALLTYPE WineDXGISwapChainFactory::Release() {
return m_container->Release();
}
HRESULT STDMETHODCALLTYPE WineDXGISwapChainFactory::QueryInterface(
REFIID riid,
void** ppvObject) {
return m_container->QueryInterface(riid, ppvObject);
}
HRESULT STDMETHODCALLTYPE WineDXGISwapChainFactory::CreateSwapChainForHwnd(
IDXGIFactory* pFactory,
HWND hWnd,
const DXGI_SWAP_CHAIN_DESC1* pDesc,
const DXGI_SWAP_CHAIN_FULLSCREEN_DESC* pFullscreenDesc,
IDXGIOutput* pRestrictToOutput,
IDXGISwapChain1** ppSwapChain) {
InitReturnPtr(ppSwapChain);
try {
*ppSwapChain = ref(new DxgiSwapChain(
pFactory, m_container, hWnd,
pDesc, pFullscreenDesc));
return S_OK;
} catch (const DxvkError& e) {
Logger::err(e.message());
return DXGI_ERROR_INVALID_CALL;
}
}
D3D11DXGIDevice::D3D11DXGIDevice( D3D11DXGIDevice::D3D11DXGIDevice(
IDXGIAdapter* pAdapter, IDXGIAdapter* pAdapter,
DxvkAdapter* pDxvkAdapter, DxvkAdapter* pDxvkAdapter,
@ -1679,7 +1727,8 @@ namespace dxvk {
m_dxvkDevice (CreateDevice(FeatureLevel)), m_dxvkDevice (CreateDevice(FeatureLevel)),
m_d3d11Device (this, FeatureLevel, FeatureFlags), m_d3d11Device (this, FeatureLevel, FeatureFlags),
m_d3d11Presenter(this, &m_d3d11Device), m_d3d11Presenter(this, &m_d3d11Device),
m_d3d11Interop (this, &m_d3d11Device) { m_d3d11Interop (this, &m_d3d11Device),
m_wineFactory (this) {
for (uint32_t i = 0; i < m_frameEvents.size(); i++) for (uint32_t i = 0; i < m_frameEvents.size(); i++)
m_frameEvents[i] = new DxvkEvent(); m_frameEvents[i] = new DxvkEvent();
} }
@ -1725,6 +1774,11 @@ namespace dxvk {
return S_OK; return S_OK;
} }
if (riid == __uuidof(IWineDXGISwapChainFactory)) {
*ppvObject = ref(&m_wineFactory);
return S_OK;
}
if (riid == __uuidof(ID3D10Multithread)) { if (riid == __uuidof(ID3D10Multithread)) {
*ppvObject = ref(m_d3d11Device.GetD3D10Multithread()); *ppvObject = ref(m_d3d11Device.GetD3D10Multithread());
return S_OK; return S_OK;

View File

@ -6,6 +6,7 @@
#include "../dxbc/dxbc_options.h" #include "../dxbc/dxbc_options.h"
#include "../dxgi/dxgi_object.h" #include "../dxgi/dxgi_object.h"
#include "../dxgi/dxgi_interfaces.h"
#include "../dxvk/dxvk_cs.h" #include "../dxvk/dxvk_cs.h"
@ -391,6 +392,38 @@ namespace dxvk {
}; };
/**
* \brief DXGI swap chain factory
*/
class WineDXGISwapChainFactory : public IWineDXGISwapChainFactory {
public:
WineDXGISwapChainFactory(IUnknown* pContainer);
ULONG STDMETHODCALLTYPE AddRef();
ULONG STDMETHODCALLTYPE Release();
HRESULT STDMETHODCALLTYPE QueryInterface(
REFIID riid,
void** ppvObject);
HRESULT STDMETHODCALLTYPE CreateSwapChainForHwnd(
IDXGIFactory* pFactory,
HWND hWnd,
const DXGI_SWAP_CHAIN_DESC1* pDesc,
const DXGI_SWAP_CHAIN_FULLSCREEN_DESC* pFullscreenDesc,
IDXGIOutput* pRestrictToOutput,
IDXGISwapChain1** ppSwapChain);
private:
IUnknown* m_container;
};
/** /**
* \brief D3D11 device container * \brief D3D11 device container
* *
@ -474,6 +507,8 @@ namespace dxvk {
D3D11PresentDevice m_d3d11Presenter; D3D11PresentDevice m_d3d11Presenter;
D3D11VkInterop m_d3d11Interop; D3D11VkInterop m_d3d11Interop;
WineDXGISwapChainFactory m_wineFactory;
uint32_t m_frameLatencyCap = 0; uint32_t m_frameLatencyCap = 0;
uint32_t m_frameLatency = DefaultFrameLatency; uint32_t m_frameLatency = DefaultFrameLatency;
uint32_t m_frameId = 0; uint32_t m_frameId = 0;

View File

@ -1,5 +1,7 @@
dxgi_common_src = [ dxgi_common_src = [
'../dxgi/dxgi_format.cpp', '../dxgi/dxgi_format.cpp',
'../dxgi/dxgi_monitor.cpp',
'../dxgi/dxgi_swapchain.cpp',
] ]
d3d10_src = [ d3d10_src = [

View File

@ -237,16 +237,38 @@ IDXGIVkInteropDevice : public IUnknown {
}; };
/**
* \brief IWineDXGISwapChainFactory device interface
*
* Allows a swap chain to be created from a device.
* See include/wine/winedxgi.idl for definition.
*/
MIDL_INTERFACE("53cb4ff0-c25a-4164-a891-0e83db0a7aac")
IWineDXGISwapChainFactory : public IUnknown {
static const GUID guid;
virtual HRESULT STDMETHODCALLTYPE CreateSwapChainForHwnd(
IDXGIFactory* pFactory,
HWND hWnd,
const DXGI_SWAP_CHAIN_DESC1* pDesc,
const DXGI_SWAP_CHAIN_FULLSCREEN_DESC* pFullscreenDesc,
IDXGIOutput* pRestrictToOutput,
IDXGISwapChain1** ppSwapChain) = 0;
};
#ifdef _MSC_VER #ifdef _MSC_VER
struct __declspec(uuid("907bf281-ea3c-43b4-a8e4-9f231107b4ff")) IDXGIVkAdapter; struct __declspec(uuid("907bf281-ea3c-43b4-a8e4-9f231107b4ff")) IDXGIVkAdapter;
struct __declspec(uuid("79352328-16f2-4f81-9746-9c2e2ccd43cf")) IDXGIVkPresentDevice; struct __declspec(uuid("79352328-16f2-4f81-9746-9c2e2ccd43cf")) IDXGIVkPresentDevice;
struct __declspec(uuid("e2ef5fa5-dc21-4af7-90c4-f67ef6a09323")) IDXGIVkInteropDevice; struct __declspec(uuid("e2ef5fa5-dc21-4af7-90c4-f67ef6a09323")) IDXGIVkInteropDevice;
struct __declspec(uuid("5546cf8c-77e7-4341-b05d-8d4d5000e77d")) IDXGIVkInteropSurface; struct __declspec(uuid("5546cf8c-77e7-4341-b05d-8d4d5000e77d")) IDXGIVkInteropSurface;
struct __declspec(uuid("104001a6-7f36-4957-b932-86ade9567d91")) IDXGIVkSwapChain; struct __declspec(uuid("104001a6-7f36-4957-b932-86ade9567d91")) IDXGIVkSwapChain;
struct __declspec(uuid("53cb4ff0-c25a-4164-a891-0e83db0a7aac")) IWineDXGISwapChainFactory;
#else #else
DXVK_DEFINE_GUID(IDXGIVkAdapter); DXVK_DEFINE_GUID(IDXGIVkAdapter);
DXVK_DEFINE_GUID(IDXGIVkPresentDevice); DXVK_DEFINE_GUID(IDXGIVkPresentDevice);
DXVK_DEFINE_GUID(IDXGIVkInteropDevice); DXVK_DEFINE_GUID(IDXGIVkInteropDevice);
DXVK_DEFINE_GUID(IDXGIVkInteropSurface); DXVK_DEFINE_GUID(IDXGIVkInteropSurface);
DXVK_DEFINE_GUID(IDXGIVkSwapChain); DXVK_DEFINE_GUID(IDXGIVkSwapChain);
DXVK_DEFINE_GUID(IWineDXGISwapChainFactory);
#endif #endif

View File

@ -9,6 +9,7 @@ const GUID IDXGIVkPresentDevice::guid = {0x79352328,0x16f2,0x4f81,{0x97,0x46,0
const GUID IDXGIVkInteropDevice::guid = {0xe2ef5fa5,0xdc21,0x4af7,{0x90,0xc4,0xf6,0x7e,0xf6,0xa0,0x93,0x23}}; 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 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}}; const GUID IDXGIVkSwapChain::guid = {0x104001a6,0x7f36,0x4957,{0xb9,0x32,0x86,0xad,0xe9,0x56,0x7d,0x91}};
const GUID IWineDXGISwapChainFactory::guid = {0x53cb4ff0,0xc25a,0x4164,{0xa8,0x91,0x0e,0x83,0xdb,0x0a,0x7a,0xac}};
std::ostream& operator << (std::ostream& os, REFIID guid) { std::ostream& operator << (std::ostream& os, REFIID guid) {
os << std::hex << std::setfill('0') os << std::hex << std::setfill('0')