1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-21 02:52:10 +01:00
dxvk/src/dxgi/dxgi_device.cpp

125 lines
3.1 KiB
C++
Raw Normal View History

2017-10-11 15:31:36 +02:00
#include "dxgi_device.h"
#include "dxgi_factory.h"
namespace dxvk {
DxgiDevice::DxgiDevice(
IDXGIAdapterPrivate* adapter,
const VkPhysicalDeviceFeatures* features)
2017-10-11 15:31:36 +02:00
: m_adapter(adapter) {
m_device = m_adapter->GetDXVKAdapter()->createDevice(*features);
2017-10-11 15:31:36 +02:00
}
DxgiDevice::~DxgiDevice() {
2017-11-26 14:01:41 +01:00
2017-10-11 15:31:36 +02:00
}
HRESULT DxgiDevice::QueryInterface(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 15:31:36 +02:00
COM_QUERY_IFACE(riid, ppvObject, IDXGIDevice);
COM_QUERY_IFACE(riid, ppvObject, IDXGIDevice1);
2017-11-27 15:51:53 +01:00
COM_QUERY_IFACE(riid, ppvObject, IDXGIDevicePrivate);
2017-10-11 15:31:36 +02:00
if (m_layer != nullptr)
return m_layer->QueryInterface(riid, ppvObject);
Logger::warn("DxgiDevice::QueryInterface: Unknown interface query");
return E_NOINTERFACE;
}
HRESULT DxgiDevice::GetParent(REFIID riid, void** ppParent) {
return m_adapter->QueryInterface(riid, ppParent);
}
HRESULT DxgiDevice::CreateSurface(
const DXGI_SURFACE_DESC* pDesc,
UINT NumSurfaces,
DXGI_USAGE Usage,
const DXGI_SHARED_RESOURCE* pSharedResource,
IDXGISurface** ppSurface) {
Logger::err("DxgiDevice::CreateSurface: Not implemented");
return E_NOTIMPL;
}
HRESULT DxgiDevice::GetAdapter(
IDXGIAdapter** pAdapter) {
*pAdapter = static_cast<IDXGIAdapter*>(m_adapter.ref());
return S_OK;
}
HRESULT DxgiDevice::GetGPUThreadPriority(
INT* pPriority) {
*pPriority = 0;
return S_OK;
}
HRESULT DxgiDevice::QueryResourceResidency(
IUnknown* const* ppResources,
DXGI_RESIDENCY* pResidencyStatus,
UINT NumResources) {
Logger::err("DxgiDevice::QueryResourceResidency: Not implemented");
return E_NOTIMPL;
}
HRESULT DxgiDevice::SetGPUThreadPriority(
INT Priority) {
if (Priority < -7 || Priority > 7)
return E_INVALIDARG;
Logger::err("DxgiDevice::SetGPUThreadPriority: Ignoring");
return S_OK;
}
HRESULT DxgiDevice::GetMaximumFrameLatency(
UINT* pMaxLatency) {
Logger::warn("DxgiDevice::GetMaximumFrameLatency: Stub");
*pMaxLatency = 1;
return S_OK;
}
HRESULT DxgiDevice::SetMaximumFrameLatency(
UINT MaxLatency) {
Logger::warn("DxgiDevice::SetMaximumFrameLatency: Stub");
return S_OK;
}
2017-10-11 15:31:36 +02:00
void DxgiDevice::SetDeviceLayer(IUnknown* layer) {
m_layer = layer;
}
Rc<DxvkDevice> DxgiDevice::GetDXVKDevice() {
return m_device;
}
}
extern "C" {
DLLEXPORT HRESULT __stdcall DXGICreateDevicePrivate(
IDXGIAdapterPrivate* pAdapter,
const VkPhysicalDeviceFeatures* features,
IDXGIDevicePrivate** ppDevice) {
2017-10-11 15:31:36 +02:00
try {
*ppDevice = dxvk::ref(new dxvk::DxgiDevice(pAdapter, features));
2017-10-11 15:31:36 +02:00
return S_OK;
} catch (const dxvk::DxvkError& e) {
dxvk::Logger::err(e.message());
return DXGI_ERROR_UNSUPPORTED;
}
}
}