#include "dxgi_factory.h" #include "dxgi_swapchain.h" namespace dxvk { DxgiFactory::DxgiFactory() : m_instance(new DxvkInstance()), m_adapters(m_instance->enumAdapters()) { } DxgiFactory::~DxgiFactory() { } HRESULT STDMETHODCALLTYPE DxgiFactory::QueryInterface( REFIID riid, void** ppvObject) { COM_QUERY_IFACE(riid, ppvObject, IUnknown); COM_QUERY_IFACE(riid, ppvObject, IDXGIObject); COM_QUERY_IFACE(riid, ppvObject, IDXGIFactory); COM_QUERY_IFACE(riid, ppvObject, IDXGIFactory1); Logger::warn("DxgiFactory::QueryInterface: Unknown interface query"); return E_NOINTERFACE; } HRESULT STDMETHODCALLTYPE DxgiFactory::GetParent( REFIID riid, void** ppParent) { Logger::warn("DxgiFactory::GetParent: Unknown interface query"); return E_NOINTERFACE; } HRESULT STDMETHODCALLTYPE DxgiFactory::CreateSoftwareAdapter( HMODULE Module, IDXGIAdapter** ppAdapter) { Logger::err("DxgiFactory::CreateSoftwareAdapter: Software adapters not supported"); return DXGI_ERROR_UNSUPPORTED; } HRESULT STDMETHODCALLTYPE DxgiFactory::CreateSwapChain( IUnknown* pDevice, DXGI_SWAP_CHAIN_DESC* pDesc, IDXGISwapChain** ppSwapChain) { 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; } } HRESULT STDMETHODCALLTYPE DxgiFactory::EnumAdapters( 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; } HRESULT STDMETHODCALLTYPE DxgiFactory::EnumAdapters1( UINT Adapter, IDXGIAdapter1** ppAdapter) { if (ppAdapter == nullptr) return DXGI_ERROR_INVALID_CALL; if (Adapter >= m_adapters.size()) return DXGI_ERROR_NOT_FOUND; *ppAdapter = ref(new DxgiAdapter( this, m_adapters.at(Adapter))); return S_OK; } HRESULT STDMETHODCALLTYPE DxgiFactory::GetWindowAssociation(HWND *pWindowHandle) { if (pWindowHandle == nullptr) return DXGI_ERROR_INVALID_CALL; *pWindowHandle = m_associatedWindow; return S_OK; } HRESULT STDMETHODCALLTYPE DxgiFactory::MakeWindowAssociation(HWND WindowHandle, UINT Flags) { Logger::warn("DxgiFactory::MakeWindowAssociation: Ignoring flags"); m_associatedWindow = WindowHandle; return S_OK; } BOOL STDMETHODCALLTYPE DxgiFactory::IsCurrent() { Logger::warn("DxgiFactory::IsCurrent: Stub"); return TRUE; } }