2017-10-11 03:09:04 +02:00
|
|
|
#include <cstdlib>
|
|
|
|
#include <cstring>
|
|
|
|
|
|
|
|
#include "dxgi_adapter.h"
|
|
|
|
#include "dxgi_factory.h"
|
|
|
|
#include "dxgi_output.h"
|
|
|
|
|
|
|
|
namespace dxvk {
|
|
|
|
|
|
|
|
DxgiAdapter::DxgiAdapter(
|
|
|
|
DxgiFactory* factory,
|
|
|
|
const Rc<DxvkAdapter>& adapter)
|
|
|
|
: m_factory (factory),
|
|
|
|
m_adapter (adapter) {
|
2017-11-26 14:01:41 +01:00
|
|
|
|
2017-10-11 03:09:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DxgiAdapter::~DxgiAdapter() {
|
2017-11-26 14:01:41 +01:00
|
|
|
|
2017-10-11 03:09:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HRESULT DxgiAdapter::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 03:09:04 +02:00
|
|
|
COM_QUERY_IFACE(riid, ppvObject, IDXGIAdapter);
|
2017-10-15 21:50:45 +02:00
|
|
|
COM_QUERY_IFACE(riid, ppvObject, IDXVKAdapter);
|
2017-10-11 03:09:04 +02:00
|
|
|
|
|
|
|
Logger::warn("DxgiAdapter::QueryInterface: Unknown interface query");
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HRESULT DxgiAdapter::GetParent(
|
|
|
|
REFIID riid,
|
|
|
|
void **ppParent) {
|
|
|
|
return m_factory->QueryInterface(riid, ppParent);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HRESULT DxgiAdapter::CheckInterfaceSupport(
|
|
|
|
REFGUID InterfaceName,
|
|
|
|
LARGE_INTEGER *pUMDVersion) {
|
|
|
|
Logger::err("DxgiAdapter::CheckInterfaceSupport: No D3D10 support");
|
|
|
|
return DXGI_ERROR_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HRESULT DxgiAdapter::EnumOutputs(
|
|
|
|
UINT Output,
|
|
|
|
IDXGIOutput **ppOutput) {
|
|
|
|
if (ppOutput == nullptr)
|
|
|
|
return DXGI_ERROR_INVALID_CALL;
|
|
|
|
|
|
|
|
int numDisplays = SDL_GetNumVideoDisplays();
|
|
|
|
|
|
|
|
if (numDisplays < 0) {
|
|
|
|
Logger::err("DxgiAdapter::EnumOutputs: Failed to query display count");
|
|
|
|
return DXGI_ERROR_DRIVER_INTERNAL_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Output >= static_cast<uint32_t>(numDisplays))
|
|
|
|
return DXGI_ERROR_NOT_FOUND;
|
|
|
|
|
|
|
|
*ppOutput = ref(new DxgiOutput(this, Output));
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HRESULT DxgiAdapter::GetDesc(DXGI_ADAPTER_DESC* pDesc) {
|
|
|
|
if (pDesc == nullptr)
|
|
|
|
return DXGI_ERROR_INVALID_CALL;
|
|
|
|
|
|
|
|
const auto deviceProp = m_adapter->deviceProperties();
|
|
|
|
const auto memoryProp = m_adapter->memoryProperties();
|
|
|
|
|
|
|
|
std::memset(pDesc->Description, 0, sizeof(pDesc->Description));
|
|
|
|
std::mbstowcs(pDesc->Description, deviceProp.deviceName, _countof(pDesc->Description) - 1);
|
|
|
|
|
|
|
|
VkDeviceSize deviceMemory = 0;
|
|
|
|
VkDeviceSize sharedMemory = 0;
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < memoryProp.memoryHeapCount; i++) {
|
|
|
|
VkMemoryHeap heap = memoryProp.memoryHeaps[i];
|
|
|
|
|
|
|
|
if (heap.flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT)
|
|
|
|
deviceMemory += heap.size;
|
|
|
|
else
|
|
|
|
sharedMemory += heap.size;
|
|
|
|
}
|
|
|
|
|
|
|
|
pDesc->VendorId = deviceProp.vendorID;
|
|
|
|
pDesc->DeviceId = deviceProp.deviceID;
|
|
|
|
pDesc->SubSysId = 0;
|
|
|
|
pDesc->Revision = 0;
|
|
|
|
pDesc->DedicatedVideoMemory = deviceMemory;
|
|
|
|
pDesc->DedicatedSystemMemory = 0;
|
|
|
|
pDesc->SharedSystemMemory = sharedMemory;
|
|
|
|
pDesc->AdapterLuid = LUID { 0, 0 }; // TODO implement
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2017-10-11 15:31:36 +02:00
|
|
|
|
|
|
|
Rc<DxvkAdapter> DxgiAdapter::GetDXVKAdapter() {
|
|
|
|
return m_adapter;
|
|
|
|
}
|
|
|
|
|
2017-10-11 03:09:04 +02:00
|
|
|
}
|