1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-14 00:48:44 +01:00
dxvk/src/dxgi/dxgi_factory.cpp

115 lines
2.9 KiB
C++
Raw Normal View History

2017-10-11 03:09:04 +02:00
#include "dxgi_factory.h"
#include "dxgi_swapchain.h"
namespace dxvk {
DxgiFactory::DxgiFactory()
2017-10-11 15:31:36 +02:00
: m_instance(new DxvkInstance()),
m_adapters(m_instance->enumAdapters()) {
2017-11-26 14:01:41 +01:00
2017-10-11 03:09:04 +02:00
}
DxgiFactory::~DxgiFactory() {
2017-11-26 14:01:41 +01:00
2017-10-11 03:09:04 +02:00
}
2017-12-12 12:50:52 +01:00
HRESULT STDMETHODCALLTYPE DxgiFactory::QueryInterface(
2017-10-11 03:09:04 +02:00
REFIID riid,
void** ppvObject) {
2017-10-15 21:50:45 +02:00
COM_QUERY_IFACE(riid, ppvObject, IUnknown);
COM_QUERY_IFACE(riid, ppvObject, IDXGIObject);
2017-10-11 03:09:04 +02:00
COM_QUERY_IFACE(riid, ppvObject, IDXGIFactory);
COM_QUERY_IFACE(riid, ppvObject, IDXGIFactory1);
2017-10-11 03:09:04 +02:00
Logger::warn("DxgiFactory::QueryInterface: Unknown interface query");
return E_NOINTERFACE;
}
2017-12-12 12:50:52 +01:00
HRESULT STDMETHODCALLTYPE DxgiFactory::GetParent(
2017-10-11 03:09:04 +02:00
REFIID riid,
void** ppParent) {
Logger::warn("DxgiFactory::GetParent: Unknown interface query");
return E_NOINTERFACE;
}
2017-12-12 12:50:52 +01:00
HRESULT STDMETHODCALLTYPE DxgiFactory::CreateSoftwareAdapter(
2017-10-11 03:09:04 +02:00
HMODULE Module,
IDXGIAdapter** ppAdapter) {
Logger::err("DxgiFactory::CreateSoftwareAdapter: Software adapters not supported");
return DXGI_ERROR_UNSUPPORTED;
}
2017-12-12 12:50:52 +01:00
HRESULT STDMETHODCALLTYPE DxgiFactory::CreateSwapChain(
2017-10-11 03:09:04 +02:00
IUnknown* pDevice,
DXGI_SWAP_CHAIN_DESC* pDesc,
IDXGISwapChain** ppSwapChain) {
2017-10-11 16:22:13 +02:00
if (ppSwapChain == nullptr || pDesc == nullptr)
return E_INVALIDARG;
try {
*ppSwapChain = ref(new DxgiSwapChain(this, pDevice, pDesc));
return S_OK;
} catch (const DxvkError& e) {
Logger::err(e.message());
return E_FAIL;
}
2017-10-11 03:09:04 +02:00
}
2017-12-12 12:50:52 +01:00
HRESULT STDMETHODCALLTYPE DxgiFactory::EnumAdapters(
2017-10-11 03:09:04 +02:00
UINT Adapter,
IDXGIAdapter** ppAdapter) {
if (ppAdapter == nullptr)
return DXGI_ERROR_INVALID_CALL;
IDXGIAdapter1* handle = nullptr;
HRESULT hr = this->EnumAdapters1(Adapter, &handle);
if (SUCCEEDED(hr))
*ppAdapter = handle;
return hr;
}
2017-12-12 12:50:52 +01:00
HRESULT STDMETHODCALLTYPE DxgiFactory::EnumAdapters1(
UINT Adapter,
IDXGIAdapter1** ppAdapter) {
if (ppAdapter == nullptr)
return DXGI_ERROR_INVALID_CALL;
2017-10-11 03:09:04 +02:00
if (Adapter >= m_adapters.size())
return DXGI_ERROR_NOT_FOUND;
2017-10-11 15:31:36 +02:00
*ppAdapter = ref(new DxgiAdapter(
this, m_adapters.at(Adapter)));
2017-10-11 03:09:04 +02:00
return S_OK;
}
2017-12-12 12:50:52 +01:00
HRESULT STDMETHODCALLTYPE DxgiFactory::GetWindowAssociation(HWND *pWindowHandle) {
2017-10-11 03:09:04 +02:00
if (pWindowHandle == nullptr)
return DXGI_ERROR_INVALID_CALL;
*pWindowHandle = m_associatedWindow;
return S_OK;
}
2017-12-12 12:50:52 +01:00
HRESULT STDMETHODCALLTYPE DxgiFactory::MakeWindowAssociation(HWND WindowHandle, UINT Flags) {
2017-10-11 03:09:04 +02:00
Logger::warn("DxgiFactory::MakeWindowAssociation: Ignoring flags");
m_associatedWindow = WindowHandle;
return S_OK;
}
2017-12-12 12:50:52 +01:00
BOOL STDMETHODCALLTYPE DxgiFactory::IsCurrent() {
Logger::warn("DxgiFactory::IsCurrent: Stub");
return TRUE;
}
2017-10-11 03:09:04 +02:00
}