1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-11-30 13:24:10 +01:00

[dxgi] Move device creation to DxgiAdapter

This is better than exporting new functions.
This commit is contained in:
Philip Rebohle 2018-03-28 18:58:53 +02:00
parent 6babc22ec0
commit 410cde3f17
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
7 changed files with 67 additions and 65 deletions

View File

@ -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;
}

View File

@ -3,4 +3,3 @@ EXPORTS
CreateDXGIFactory
CreateDXGIFactory1
CreateDXGIFactory2
DXGICreateDevicePrivate

View File

@ -2,6 +2,7 @@
#include <cstring>
#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) {

View File

@ -49,6 +49,10 @@ namespace dxvk {
Rc<DxvkAdapter> STDMETHODCALLTYPE GetDXVKAdapter() final;
HRESULT STDMETHODCALLTYPE CreateDevice(
const VkPhysicalDeviceFeatures* pFeatures,
IDXGIDevicePrivate** ppDevice) final;
DxgiFormatInfo STDMETHODCALLTYPE LookupFormat(
DXGI_FORMAT format, DxgiFormatMode mode) final;

View File

@ -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;
}
}
}

View File

@ -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);
}

View File

@ -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<dxvk::DxvkAdapter> 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<dxvk::DxvkAdapter> 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
*