mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-01 19:29:16 +01:00
[dxgi] Move device creation to DxgiAdapter
This is better than exporting new functions.
This commit is contained in:
parent
6babc22ec0
commit
410cde3f17
@ -115,7 +115,7 @@ extern "C" {
|
|||||||
const VkPhysicalDeviceFeatures deviceFeatures
|
const VkPhysicalDeviceFeatures deviceFeatures
|
||||||
= D3D11Device::GetDeviceFeatures(adapter, fl);
|
= 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");
|
Logger::err("D3D11CreateDevice: Failed to create DXGI device");
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
|
@ -3,4 +3,3 @@ EXPORTS
|
|||||||
CreateDXGIFactory
|
CreateDXGIFactory
|
||||||
CreateDXGIFactory1
|
CreateDXGIFactory1
|
||||||
CreateDXGIFactory2
|
CreateDXGIFactory2
|
||||||
DXGICreateDevicePrivate
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#include "dxgi_adapter.h"
|
#include "dxgi_adapter.h"
|
||||||
|
#include "dxgi_device.h"
|
||||||
#include "dxgi_enums.h"
|
#include "dxgi_enums.h"
|
||||||
#include "dxgi_factory.h"
|
#include "dxgi_factory.h"
|
||||||
#include "dxgi_output.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) {
|
DxgiFormatInfo STDMETHODCALLTYPE DxgiAdapter::LookupFormat(DXGI_FORMAT format, DxgiFormatMode mode) {
|
||||||
// If the mode is 'Any', probe color formats first
|
// If the mode is 'Any', probe color formats first
|
||||||
if (mode != DxgiFormatMode::Depth) {
|
if (mode != DxgiFormatMode::Depth) {
|
||||||
|
@ -49,6 +49,10 @@ namespace dxvk {
|
|||||||
|
|
||||||
Rc<DxvkAdapter> STDMETHODCALLTYPE GetDXVKAdapter() final;
|
Rc<DxvkAdapter> STDMETHODCALLTYPE GetDXVKAdapter() final;
|
||||||
|
|
||||||
|
HRESULT STDMETHODCALLTYPE CreateDevice(
|
||||||
|
const VkPhysicalDeviceFeatures* pFeatures,
|
||||||
|
IDXGIDevicePrivate** ppDevice) final;
|
||||||
|
|
||||||
DxgiFormatInfo STDMETHODCALLTYPE LookupFormat(
|
DxgiFormatInfo STDMETHODCALLTYPE LookupFormat(
|
||||||
DXGI_FORMAT format, DxgiFormatMode mode) final;
|
DXGI_FORMAT format, DxgiFormatMode mode) final;
|
||||||
|
|
||||||
|
@ -4,10 +4,10 @@
|
|||||||
namespace dxvk {
|
namespace dxvk {
|
||||||
|
|
||||||
DxgiDevice::DxgiDevice(
|
DxgiDevice::DxgiDevice(
|
||||||
IDXGIAdapterPrivate* adapter,
|
IDXGIAdapterPrivate* pAdapter,
|
||||||
const VkPhysicalDeviceFeatures* features)
|
const VkPhysicalDeviceFeatures* pFeatures)
|
||||||
: m_adapter(adapter) {
|
: m_adapter(pAdapter) {
|
||||||
m_device = m_adapter->GetDXVKAdapter()->createDevice(*features);
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -14,8 +14,8 @@ namespace dxvk {
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
DxgiDevice(
|
DxgiDevice(
|
||||||
IDXGIAdapterPrivate* adapter,
|
IDXGIAdapterPrivate* pAdapter,
|
||||||
const VkPhysicalDeviceFeatures* features);
|
const VkPhysicalDeviceFeatures* pFeatures);
|
||||||
~DxgiDevice();
|
~DxgiDevice();
|
||||||
|
|
||||||
HRESULT STDMETHODCALLTYPE QueryInterface(
|
HRESULT STDMETHODCALLTYPE QueryInterface(
|
||||||
@ -81,13 +81,3 @@ namespace dxvk {
|
|||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
|
|
||||||
HRESULT __stdcall DXGICreateDevicePrivate(
|
|
||||||
IDXGIAdapterPrivate* pAdapter,
|
|
||||||
const VkPhysicalDeviceFeatures* features,
|
|
||||||
IDXGIDevicePrivate** ppDevice);
|
|
||||||
|
|
||||||
}
|
|
@ -50,35 +50,6 @@ namespace dxvk {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* \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;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Private DXGI device interface
|
* \brief Private DXGI device interface
|
||||||
@ -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
|
* \brief Swap chain back buffer interface
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user