diff --git a/src/d3d11/d3d11_main.cpp b/src/d3d11/d3d11_main.cpp index dd2a97e6..2bc7eb58 100644 --- a/src/d3d11/d3d11_main.cpp +++ b/src/d3d11/d3d11_main.cpp @@ -115,7 +115,7 @@ extern "C" { const VkPhysicalDeviceFeatures deviceFeatures = D3D11Device::GetDeviceFeatures(adapter, fl); - if (FAILED(DXGICreateDevicePrivate(dxvkAdapter.ptr(), &deviceFeatures, &dxvkDevice))) { + if (FAILED(dxvkAdapter->CreateDevice(&deviceFeatures, &dxvkDevice))) { Logger::err("D3D11CreateDevice: Failed to create DXGI device"); return E_FAIL; } diff --git a/src/dxgi/dxgi.def b/src/dxgi/dxgi.def index 1ce103db..53710457 100644 --- a/src/dxgi/dxgi.def +++ b/src/dxgi/dxgi.def @@ -3,4 +3,3 @@ EXPORTS CreateDXGIFactory CreateDXGIFactory1 CreateDXGIFactory2 - DXGICreateDevicePrivate diff --git a/src/dxgi/dxgi_adapter.cpp b/src/dxgi/dxgi_adapter.cpp index 0bdbf836..7e3d2627 100644 --- a/src/dxgi/dxgi_adapter.cpp +++ b/src/dxgi/dxgi_adapter.cpp @@ -2,6 +2,7 @@ #include #include "dxgi_adapter.h" +#include "dxgi_device.h" #include "dxgi_enums.h" #include "dxgi_factory.h" #include "dxgi_output.h" @@ -155,6 +156,19 @@ namespace dxvk { } + HRESULT STDMETHODCALLTYPE DxgiAdapter::CreateDevice( + const VkPhysicalDeviceFeatures* pFeatures, + IDXGIDevicePrivate** ppDevice) { + try { + *ppDevice = ref(new dxvk::DxgiDevice(this, pFeatures)); + return S_OK; + } catch (const dxvk::DxvkError& e) { + dxvk::Logger::err(e.message()); + return DXGI_ERROR_UNSUPPORTED; + } + } + + DxgiFormatInfo STDMETHODCALLTYPE DxgiAdapter::LookupFormat(DXGI_FORMAT format, DxgiFormatMode mode) { // If the mode is 'Any', probe color formats first if (mode != DxgiFormatMode::Depth) { diff --git a/src/dxgi/dxgi_adapter.h b/src/dxgi/dxgi_adapter.h index 03854817..0add27c7 100644 --- a/src/dxgi/dxgi_adapter.h +++ b/src/dxgi/dxgi_adapter.h @@ -49,6 +49,10 @@ namespace dxvk { Rc STDMETHODCALLTYPE GetDXVKAdapter() final; + HRESULT STDMETHODCALLTYPE CreateDevice( + const VkPhysicalDeviceFeatures* pFeatures, + IDXGIDevicePrivate** ppDevice) final; + DxgiFormatInfo STDMETHODCALLTYPE LookupFormat( DXGI_FORMAT format, DxgiFormatMode mode) final; diff --git a/src/dxgi/dxgi_device.cpp b/src/dxgi/dxgi_device.cpp index 61ca5b99..f016841a 100644 --- a/src/dxgi/dxgi_device.cpp +++ b/src/dxgi/dxgi_device.cpp @@ -4,10 +4,10 @@ namespace dxvk { DxgiDevice::DxgiDevice( - IDXGIAdapterPrivate* adapter, - const VkPhysicalDeviceFeatures* features) - : m_adapter(adapter) { - m_device = m_adapter->GetDXVKAdapter()->createDevice(*features); + IDXGIAdapterPrivate* pAdapter, + const VkPhysicalDeviceFeatures* pFeatures) + : m_adapter(pAdapter) { + m_device = m_adapter->GetDXVKAdapter()->createDevice(*pFeatures); } @@ -135,21 +135,3 @@ namespace dxvk { } } - - -extern "C" { - - DLLEXPORT HRESULT __stdcall DXGICreateDevicePrivate( - IDXGIAdapterPrivate* pAdapter, - const VkPhysicalDeviceFeatures* features, - IDXGIDevicePrivate** ppDevice) { - try { - *ppDevice = dxvk::ref(new dxvk::DxgiDevice(pAdapter, features)); - return S_OK; - } catch (const dxvk::DxvkError& e) { - dxvk::Logger::err(e.message()); - return DXGI_ERROR_UNSUPPORTED; - } - } - -} \ No newline at end of file diff --git a/src/dxgi/dxgi_device.h b/src/dxgi/dxgi_device.h index 1e6f2d66..513246e4 100644 --- a/src/dxgi/dxgi_device.h +++ b/src/dxgi/dxgi_device.h @@ -14,8 +14,8 @@ namespace dxvk { public: DxgiDevice( - IDXGIAdapterPrivate* adapter, - const VkPhysicalDeviceFeatures* features); + IDXGIAdapterPrivate* pAdapter, + const VkPhysicalDeviceFeatures* pFeatures); ~DxgiDevice(); HRESULT STDMETHODCALLTYPE QueryInterface( @@ -81,13 +81,3 @@ namespace dxvk { }; } - - -extern "C" { - - HRESULT __stdcall DXGICreateDevicePrivate( - IDXGIAdapterPrivate* pAdapter, - const VkPhysicalDeviceFeatures* features, - IDXGIDevicePrivate** ppDevice); - -} \ No newline at end of file diff --git a/src/dxgi/dxgi_interfaces.h b/src/dxgi/dxgi_interfaces.h index 1f6f81ca..e2637071 100644 --- a/src/dxgi/dxgi_interfaces.h +++ b/src/dxgi/dxgi_interfaces.h @@ -49,35 +49,6 @@ namespace dxvk { Depth = 2, }; } - -/** - * \brief Private DXGI adapter interface - * - * The implementation of \c IDXGIAdapter holds a - * \ref DxvkAdapter which can be retrieved using - * this interface. - */ -MIDL_INTERFACE("907bf281-ea3c-43b4-a8e4-9f231107b4ff") -IDXGIAdapterPrivate : public IDXGIAdapter1 { - static const GUID guid; - - virtual dxvk::Rc STDMETHODCALLTYPE GetDXVKAdapter() = 0; - - /** - * \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 - * \returns Vulkan format pair - */ - virtual dxvk::DxgiFormatInfo STDMETHODCALLTYPE LookupFormat( - DXGI_FORMAT format, - dxvk::DxgiFormatMode mode) = 0; -}; /** @@ -98,6 +69,48 @@ IDXGIDevicePrivate : public IDXGIDevice2 { }; +/** + * \brief Private DXGI adapter interface + * + * The implementation of \c IDXGIAdapter holds a + * \ref DxvkAdapter which can be retrieved using + * this interface. + */ +MIDL_INTERFACE("907bf281-ea3c-43b4-a8e4-9f231107b4ff") +IDXGIAdapterPrivate : public IDXGIAdapter1 { + static const GUID guid; + + virtual dxvk::Rc STDMETHODCALLTYPE GetDXVKAdapter() = 0; + + /** + * \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( + const VkPhysicalDeviceFeatures* pFeatures, + IDXGIDevicePrivate** ppDevice) = 0; + + /** + * \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 + * \returns Vulkan format pair + */ + virtual dxvk::DxgiFormatInfo STDMETHODCALLTYPE LookupFormat( + DXGI_FORMAT format, + dxvk::DxgiFormatMode mode) = 0; +}; + + /** * \brief Swap chain back buffer interface *