1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-02 01:24:11 +01:00

[dxgi] Generate adapter LUIDs if Vulkan does not provide them

Needed because winevulkan does not provide adapter LUIDs.
Fixes various wine test failures, and will be required to
get D3D12 (vkd3d) to work on top of our DXGI implementation.
This commit is contained in:
Philip Rebohle 2019-10-02 01:07:18 +02:00
parent 73b9846c4f
commit 1366fce0f8
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
3 changed files with 38 additions and 6 deletions

View File

@ -12,6 +12,30 @@
namespace dxvk {
static LUID GetAdapterLUID(UINT Adapter) {
static std::mutex s_mutex;
static std::vector<LUID> s_luids;
std::lock_guard<std::mutex> 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<DxvkAdapter>& adapter)
const Rc<DxvkAdapter>& 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;
}

View File

@ -44,8 +44,10 @@ namespace dxvk {
public:
DxgiAdapter(
DxgiFactory* factory,
const Rc<DxvkAdapter>& adapter);
DxgiFactory* factory,
const Rc<DxvkAdapter>& adapter,
UINT index);
~DxgiAdapter();
HRESULT STDMETHODCALLTYPE QueryInterface(
@ -105,6 +107,7 @@ namespace dxvk {
Rc<DxvkAdapter> m_adapter;
DxgiVkAdapter m_interop;
UINT m_index;
UINT64 m_memReservation[2] = { 0, 0 };
};

View File

@ -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;
}