mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-02-21 22:54:16 +01:00
[util] Implement LUID helpers for non-Windows platforms Initial commit
This commit is contained in:
parent
3733590756
commit
2bd062f9d6
@ -5,9 +5,20 @@
|
|||||||
|
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
namespace dxvk {
|
namespace dxvk {
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
static BOOL AllocateLocallyUniqueId(LUID* luid) {
|
||||||
|
static std::atomic<uint32_t> counter = { 0u };
|
||||||
|
// Unsigned bottom part is actually the first
|
||||||
|
// member of the struct.
|
||||||
|
*luid = LUID{ ++counter, 0 };
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
LUID GetAdapterLUID(UINT Adapter) {
|
LUID GetAdapterLUID(UINT Adapter) {
|
||||||
static dxvk::mutex s_mutex;
|
static dxvk::mutex s_mutex;
|
||||||
static std::vector<LUID> s_luids;
|
static std::vector<LUID> s_luids;
|
||||||
@ -18,7 +29,7 @@ namespace dxvk {
|
|||||||
while (s_luids.size() < newLuidCount) {
|
while (s_luids.size() < newLuidCount) {
|
||||||
LUID luid = { 0, 0 };
|
LUID luid = { 0, 0 };
|
||||||
|
|
||||||
if (!::AllocateLocallyUniqueId(&luid))
|
if (!AllocateLocallyUniqueId(&luid))
|
||||||
Logger::err("Failed to allocate LUID");
|
Logger::err("Failed to allocate LUID");
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user