mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-15 07:29:17 +01:00
[util] Move GetAdapterLUID out of DXGI internals
This commit is contained in:
parent
8f00af556e
commit
85581bdace
@ -10,32 +10,10 @@
|
|||||||
#include "dxgi_options.h"
|
#include "dxgi_options.h"
|
||||||
#include "dxgi_output.h"
|
#include "dxgi_output.h"
|
||||||
|
|
||||||
|
#include "../util/util_luid.h"
|
||||||
|
|
||||||
namespace dxvk {
|
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)
|
DxgiVkAdapter::DxgiVkAdapter(DxgiAdapter* pAdapter)
|
||||||
: m_adapter(pAdapter) {
|
: m_adapter(pAdapter) {
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ util_src = files([
|
|||||||
'util_env.cpp',
|
'util_env.cpp',
|
||||||
'util_string.cpp',
|
'util_string.cpp',
|
||||||
'util_gdi.cpp',
|
'util_gdi.cpp',
|
||||||
|
'util_luid.cpp',
|
||||||
|
|
||||||
'com/com_guid.cpp',
|
'com/com_guid.cpp',
|
||||||
'com/com_private_data.cpp',
|
'com/com_private_data.cpp',
|
||||||
|
34
src/util/util_luid.cpp
Normal file
34
src/util/util_luid.cpp
Normal 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
15
src/util/util_luid.h
Normal 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);
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user