1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-03-13 19:29:14 +01:00

[util] Move GetAdapterLUID out of DXGI internals

This commit is contained in:
Philip Rebohle 2019-10-02 08:42:22 +02:00
parent 8f00af556e
commit 85581bdace
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
4 changed files with 52 additions and 24 deletions

View File

@ -10,32 +10,10 @@
#include "dxgi_options.h"
#include "dxgi_output.h"
#include "../util/util_luid.h"
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) {

View File

@ -2,6 +2,7 @@ util_src = files([
'util_env.cpp',
'util_string.cpp',
'util_gdi.cpp',
'util_luid.cpp',
'com/com_guid.cpp',
'com/com_private_data.cpp',

34
src/util/util_luid.cpp Normal file
View File

@ -0,0 +1,34 @@
#include "util_luid.h"
#include "util_string.h"
#include "./log/log.h"
#include <mutex>
#include <vector>
namespace dxvk {
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("Failed to allocate LUID");
Logger::info(str::format("Adapter LUID ", s_luids.size(), ": ",
std::hex, luid.HighPart, ":", luid.LowPart, std::dec));
s_luids.push_back(luid);
}
return s_luids[Adapter];
}
}

15
src/util/util_luid.h Normal file
View File

@ -0,0 +1,15 @@
#include "./com/com_include.h"
namespace dxvk {
/**
* \brief Retrieves an adapter LUID
*
* Note that this only works reliably within the
* module that this function was compiled into.
* \param [in] Adapter The adapter index
* \returns LUID An LUID for that adapter
*/
LUID GetAdapterLUID(UINT Adapter);
}