diff --git a/src/dxgi/dxgi_adapter.cpp b/src/dxgi/dxgi_adapter.cpp index accef2ce..a587229b 100644 --- a/src/dxgi/dxgi_adapter.cpp +++ b/src/dxgi/dxgi_adapter.cpp @@ -12,6 +12,30 @@ namespace dxvk { + static LUID GetAdapterLUID(UINT Adapter) { + static std::mutex s_mutex; + static std::vector s_luids; + + std::lock_guard lock(s_mutex); + uint32_t newLuidCount = Adapter + 1; + + while (s_luids.size() < newLuidCount) { + LUID luid = { 0, 0 }; + + if (!AllocateLocallyUniqueId(&luid)) + Logger::err("DXGI: Failed to allocate LUID"); + + + Logger::info(str::format("DXGI: Adapter LUID ", s_luids.size(), ": ", + std::hex, luid.HighPart, ":", luid.LowPart, std::dec)); + + s_luids.push_back(luid); + } + + return s_luids[Adapter]; + } + + DxgiVkAdapter::DxgiVkAdapter(DxgiAdapter* pAdapter) : m_adapter(pAdapter) { @@ -53,10 +77,12 @@ namespace dxvk { DxgiAdapter::DxgiAdapter( DxgiFactory* factory, - const Rc& adapter) + const Rc& adapter, + UINT index) : m_factory (factory), m_adapter (adapter), - m_interop (this) { + m_interop (this), + m_index (index) { } @@ -271,6 +297,9 @@ namespace dxvk { if (deviceId.deviceLUIDValid) std::memcpy(&pDesc->AdapterLuid, deviceId.deviceLUID, VK_LUID_SIZE); + else + pDesc->AdapterLuid = GetAdapterLUID(m_index); + return S_OK; } diff --git a/src/dxgi/dxgi_adapter.h b/src/dxgi/dxgi_adapter.h index 08e06190..91af68af 100644 --- a/src/dxgi/dxgi_adapter.h +++ b/src/dxgi/dxgi_adapter.h @@ -44,8 +44,10 @@ namespace dxvk { public: DxgiAdapter( - DxgiFactory* factory, - const Rc& adapter); + DxgiFactory* factory, + const Rc& adapter, + UINT index); + ~DxgiAdapter(); HRESULT STDMETHODCALLTYPE QueryInterface( @@ -105,6 +107,7 @@ namespace dxvk { Rc m_adapter; DxgiVkAdapter m_interop; + UINT m_index; UINT64 m_memReservation[2] = { 0, 0 }; }; diff --git a/src/dxgi/dxgi_factory.cpp b/src/dxgi/dxgi_factory.cpp index 4da06672..061fbd75 100644 --- a/src/dxgi/dxgi_factory.cpp +++ b/src/dxgi/dxgi_factory.cpp @@ -2,7 +2,7 @@ #include "dxgi_swapchain.h" namespace dxvk { - + DxgiFactory::DxgiFactory(UINT Flags) : m_instance (new DxvkInstance()), m_monitorInfo (this), @@ -192,7 +192,7 @@ namespace dxvk { if (dxvkAdapter == nullptr) return DXGI_ERROR_NOT_FOUND; - *ppAdapter = ref(new DxgiAdapter(this, dxvkAdapter)); + *ppAdapter = ref(new DxgiAdapter(this, dxvkAdapter, Adapter)); return S_OK; }