1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-18 11:52:12 +01:00

[dxvk] Use custom sync primitives

This commit is contained in:
Philip Rebohle 2021-06-28 19:19:29 +02:00 committed by Philip Rebohle
parent 7305da6951
commit cd8a2bcfcd
52 changed files with 137 additions and 137 deletions

View File

@ -21,7 +21,7 @@ namespace dxvk {
void D3D11Initializer::Flush() { void D3D11Initializer::Flush() {
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<dxvk::mutex> lock(m_mutex);
if (m_transferCommands != 0) if (m_transferCommands != 0)
FlushInternal(); FlushInternal();
@ -54,7 +54,7 @@ namespace dxvk {
if (!counterBuffer.defined()) if (!counterBuffer.defined())
return; return;
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<dxvk::mutex> lock(m_mutex);
m_transferCommands += 1; m_transferCommands += 1;
const uint32_t zero = 0; const uint32_t zero = 0;
@ -69,7 +69,7 @@ namespace dxvk {
void D3D11Initializer::InitDeviceLocalBuffer( void D3D11Initializer::InitDeviceLocalBuffer(
D3D11Buffer* pBuffer, D3D11Buffer* pBuffer,
const D3D11_SUBRESOURCE_DATA* pInitialData) { const D3D11_SUBRESOURCE_DATA* pInitialData) {
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<dxvk::mutex> lock(m_mutex);
DxvkBufferSlice bufferSlice = pBuffer->GetBufferSlice(); DxvkBufferSlice bufferSlice = pBuffer->GetBufferSlice();
@ -118,7 +118,7 @@ namespace dxvk {
void D3D11Initializer::InitDeviceLocalTexture( void D3D11Initializer::InitDeviceLocalTexture(
D3D11CommonTexture* pTexture, D3D11CommonTexture* pTexture,
const D3D11_SUBRESOURCE_DATA* pInitialData) { const D3D11_SUBRESOURCE_DATA* pInitialData) {
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<dxvk::mutex> lock(m_mutex);
Rc<DxvkImage> image = pTexture->GetImage(); Rc<DxvkImage> image = pTexture->GetImage();
@ -262,7 +262,7 @@ namespace dxvk {
} }
// Initialize the image on the GPU // Initialize the image on the GPU
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<dxvk::mutex> lock(m_mutex);
VkImageSubresourceRange subresources; VkImageSubresourceRange subresources;
subresources.aspectMask = image->formatInfo()->aspectMask; subresources.aspectMask = image->formatInfo()->aspectMask;

View File

@ -40,7 +40,7 @@ namespace dxvk {
private: private:
std::mutex m_mutex; dxvk::mutex m_mutex;
D3D11Device* m_parent; D3D11Device* m_parent;
Rc<DxvkDevice> m_device; Rc<DxvkDevice> m_device;

View File

@ -89,7 +89,7 @@ namespace dxvk {
size_t BytecodeLength, size_t BytecodeLength,
D3D11CommonShader* pShader) { D3D11CommonShader* pShader) {
// Use the shader's unique key for the lookup // Use the shader's unique key for the lookup
{ std::unique_lock<std::mutex> lock(m_mutex); { std::unique_lock<dxvk::mutex> lock(m_mutex);
auto entry = m_modules.find(*pShaderKey); auto entry = m_modules.find(*pShaderKey);
if (entry != m_modules.end()) { if (entry != m_modules.end()) {
@ -113,7 +113,7 @@ namespace dxvk {
// Insert the new module into the lookup table. If another thread // Insert the new module into the lookup table. If another thread
// has compiled the same shader in the meantime, we should return // has compiled the same shader in the meantime, we should return
// that object instead and discard the newly created module. // that object instead and discard the newly created module.
{ std::unique_lock<std::mutex> lock(m_mutex); { std::unique_lock<dxvk::mutex> lock(m_mutex);
auto status = m_modules.insert({ *pShaderKey, module }); auto status = m_modules.insert({ *pShaderKey, module });
if (!status.second) { if (!status.second) {

View File

@ -146,7 +146,7 @@ namespace dxvk {
private: private:
std::mutex m_mutex; dxvk::mutex m_mutex;
std::unordered_map< std::unordered_map<
DxvkShaderKey, DxvkShaderKey,

View File

@ -54,7 +54,7 @@ namespace dxvk {
* \returns Pointer to the state object * \returns Pointer to the state object
*/ */
T* Create(D3D11Device* device, const DescType& desc) { T* Create(D3D11Device* device, const DescType& desc) {
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<dxvk::mutex> lock(m_mutex);
auto entry = m_objects.find(desc); auto entry = m_objects.find(desc);
@ -70,7 +70,7 @@ namespace dxvk {
private: private:
std::mutex m_mutex; dxvk::mutex m_mutex;
std::unordered_map<DescType, T, std::unordered_map<DescType, T,
D3D11StateDescHash, D3D11StateDescEqual> m_objects; D3D11StateDescHash, D3D11StateDescEqual> m_objects;

View File

@ -18,7 +18,7 @@ namespace dxvk {
void D3D9Initializer::Flush() { void D3D9Initializer::Flush() {
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<dxvk::mutex> lock(m_mutex);
if (m_transferCommands != 0) if (m_transferCommands != 0)
FlushInternal(); FlushInternal();
@ -52,7 +52,7 @@ namespace dxvk {
void D3D9Initializer::InitDeviceLocalBuffer( void D3D9Initializer::InitDeviceLocalBuffer(
DxvkBufferSlice Slice) { DxvkBufferSlice Slice) {
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<dxvk::mutex> lock(m_mutex);
m_transferCommands += 1; m_transferCommands += 1;
@ -79,7 +79,7 @@ namespace dxvk {
void D3D9Initializer::InitDeviceLocalTexture( void D3D9Initializer::InitDeviceLocalTexture(
D3D9CommonTexture* pTexture) { D3D9CommonTexture* pTexture) {
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<dxvk::mutex> lock(m_mutex);
auto InitImage = [&](Rc<DxvkImage> image) { auto InitImage = [&](Rc<DxvkImage> image) {
if (image == nullptr) if (image == nullptr)

View File

@ -33,7 +33,7 @@ namespace dxvk {
private: private:
std::mutex m_mutex; dxvk::mutex m_mutex;
Rc<DxvkDevice> m_device; Rc<DxvkDevice> m_device;
Rc<DxvkContext> m_context; Rc<DxvkContext> m_context;

View File

@ -117,7 +117,7 @@ namespace dxvk {
Sha1Hash::compute(pShaderBytecode, info.bytecodeByteLength)); Sha1Hash::compute(pShaderBytecode, info.bytecodeByteLength));
// Use the shader's unique key for the lookup // Use the shader's unique key for the lookup
{ std::unique_lock<std::mutex> lock(m_mutex); { std::unique_lock<dxvk::mutex> lock(m_mutex);
auto entry = m_modules.find(lookupKey); auto entry = m_modules.find(lookupKey);
if (entry != m_modules.end()) { if (entry != m_modules.end()) {
@ -136,7 +136,7 @@ namespace dxvk {
// Insert the new module into the lookup table. If another thread // Insert the new module into the lookup table. If another thread
// has compiled the same shader in the meantime, we should return // has compiled the same shader in the meantime, we should return
// that object instead and discard the newly created module. // that object instead and discard the newly created module.
{ std::unique_lock<std::mutex> lock(m_mutex); { std::unique_lock<dxvk::mutex> lock(m_mutex);
auto status = m_modules.insert({ lookupKey, *pShaderModule }); auto status = m_modules.insert({ lookupKey, *pShaderModule });
if (!status.second) { if (!status.second) {

View File

@ -179,7 +179,7 @@ namespace dxvk {
private: private:
std::mutex m_mutex; dxvk::mutex m_mutex;
std::unordered_map< std::unordered_map<
DxvkShaderKey, DxvkShaderKey,

View File

@ -15,7 +15,7 @@ namespace dxvk {
}; };
static std::recursive_mutex g_windowProcMapMutex; static dxvk::recursive_mutex g_windowProcMapMutex;
static std::unordered_map<HWND, D3D9WindowData> g_windowProcMap; static std::unordered_map<HWND, D3D9WindowData> g_windowProcMap;

View File

@ -311,7 +311,7 @@ namespace dxvk {
auto& elements = pDecl->GetElements(); auto& elements = pDecl->GetElements();
// Use the shader's unique key for the lookup // Use the shader's unique key for the lookup
{ std::unique_lock<std::mutex> lock(m_mutex); { std::unique_lock<dxvk::mutex> lock(m_mutex);
auto entry = m_modules.find(elements); auto entry = m_modules.find(elements);
if (entry != m_modules.end()) if (entry != m_modules.end())
@ -346,7 +346,7 @@ namespace dxvk {
// Insert the new module into the lookup table. If another thread // Insert the new module into the lookup table. If another thread
// has compiled the same shader in the meantime, we should return // has compiled the same shader in the meantime, we should return
// that object instead and discard the newly created module. // that object instead and discard the newly created module.
{ std::unique_lock<std::mutex> lock(m_mutex); { std::unique_lock<dxvk::mutex> lock(m_mutex);
auto status = m_modules.insert({ elements, shader }); auto status = m_modules.insert({ elements, shader });
if (!status.second) if (!status.second)

View File

@ -27,7 +27,7 @@ namespace dxvk {
private: private:
std::mutex m_mutex; dxvk::mutex m_mutex;
std::unordered_map< std::unordered_map<
D3D9VertexElements, Rc<DxvkShader>, D3D9VertexElements, Rc<DxvkShader>,

View File

@ -67,7 +67,7 @@ namespace dxvk {
DxgiAdapter::~DxgiAdapter() { DxgiAdapter::~DxgiAdapter() {
if (m_eventThread.joinable()) { if (m_eventThread.joinable()) {
std::unique_lock<std::mutex> lock(m_mutex); std::unique_lock<dxvk::mutex> lock(m_mutex);
m_eventCookie = ~0u; m_eventCookie = ~0u;
m_cond.notify_one(); m_cond.notify_one();
@ -406,7 +406,7 @@ namespace dxvk {
if (!hEvent || !pdwCookie) if (!hEvent || !pdwCookie)
return E_INVALIDARG; return E_INVALIDARG;
std::unique_lock<std::mutex> lock(m_mutex); std::unique_lock<dxvk::mutex> lock(m_mutex);
DWORD cookie = ++m_eventCookie; DWORD cookie = ++m_eventCookie;
m_eventMap.insert({ cookie, hEvent }); m_eventMap.insert({ cookie, hEvent });
@ -431,7 +431,7 @@ namespace dxvk {
void STDMETHODCALLTYPE DxgiAdapter::UnregisterVideoMemoryBudgetChangeNotification( void STDMETHODCALLTYPE DxgiAdapter::UnregisterVideoMemoryBudgetChangeNotification(
DWORD dwCookie) { DWORD dwCookie) {
std::unique_lock<std::mutex> lock(m_mutex); std::unique_lock<dxvk::mutex> lock(m_mutex);
m_eventMap.erase(dwCookie); m_eventMap.erase(dwCookie);
} }
@ -449,7 +449,7 @@ namespace dxvk {
void DxgiAdapter::runEventThread() { void DxgiAdapter::runEventThread() {
env::setThreadName(str::format("dxvk-adapter-", m_index)); env::setThreadName(str::format("dxvk-adapter-", m_index));
std::unique_lock<std::mutex> lock(m_mutex); std::unique_lock<dxvk::mutex> lock(m_mutex);
DxvkAdapterMemoryInfo memoryInfoOld = m_adapter->getMemoryHeapInfo(); DxvkAdapterMemoryInfo memoryInfoOld = m_adapter->getMemoryHeapInfo();
while (true) { while (true) {

View File

@ -115,8 +115,8 @@ namespace dxvk {
UINT m_index; UINT m_index;
UINT64 m_memReservation[2] = { 0, 0 }; UINT64 m_memReservation[2] = { 0, 0 };
std::mutex m_mutex; dxvk::mutex m_mutex;
std::condition_variable m_cond; dxvk::condition_variable m_cond;
DWORD m_eventCookie = 0; DWORD m_eventCookie = 0;
std::unordered_map<DWORD, HANDLE> m_eventMap; std::unordered_map<DWORD, HANDLE> m_eventMap;

View File

@ -36,7 +36,7 @@ namespace dxvk {
if (!hMonitor || !pData) if (!hMonitor || !pData)
return E_INVALIDARG; return E_INVALIDARG;
std::lock_guard<std::mutex> lock(m_monitorMutex); std::lock_guard<dxvk::mutex> lock(m_monitorMutex);
auto result = m_monitorData.insert({ hMonitor, *pData }); auto result = m_monitorData.insert({ hMonitor, *pData });
return result.second ? S_OK : E_INVALIDARG; return result.second ? S_OK : E_INVALIDARG;

View File

@ -39,7 +39,7 @@ namespace dxvk {
IUnknown* m_parent; IUnknown* m_parent;
std::mutex m_monitorMutex; dxvk::mutex m_monitorMutex;
std::unordered_map<HMONITOR, DXGI_VK_MONITOR_DATA> m_monitorData; std::unordered_map<HMONITOR, DXGI_VK_MONITOR_DATA> m_monitorData;
}; };

View File

@ -165,7 +165,7 @@ namespace dxvk {
HRESULT STDMETHODCALLTYPE DxgiSwapChain::GetFrameStatistics(DXGI_FRAME_STATISTICS* pStats) { HRESULT STDMETHODCALLTYPE DxgiSwapChain::GetFrameStatistics(DXGI_FRAME_STATISTICS* pStats) {
std::lock_guard<std::recursive_mutex> lock(m_lockWindow); std::lock_guard<dxvk::recursive_mutex> lock(m_lockWindow);
if (!pStats) if (!pStats)
return E_INVALIDARG; return E_INVALIDARG;
@ -261,8 +261,8 @@ namespace dxvk {
if (SyncInterval > 4) if (SyncInterval > 4)
return DXGI_ERROR_INVALID_CALL; return DXGI_ERROR_INVALID_CALL;
std::lock_guard<std::recursive_mutex> lockWin(m_lockWindow); std::lock_guard<dxvk::recursive_mutex> lockWin(m_lockWindow);
std::lock_guard<std::mutex> lockBuf(m_lockBuffer); std::lock_guard<dxvk::mutex> lockBuf(m_lockBuffer);
try { try {
HRESULT hr = m_presenter->Present(SyncInterval, PresentFlags, nullptr); HRESULT hr = m_presenter->Present(SyncInterval, PresentFlags, nullptr);
@ -290,7 +290,7 @@ namespace dxvk {
if ((m_desc.Flags & PreserveFlags) != (SwapChainFlags & PreserveFlags)) if ((m_desc.Flags & PreserveFlags) != (SwapChainFlags & PreserveFlags))
return DXGI_ERROR_INVALID_CALL; return DXGI_ERROR_INVALID_CALL;
std::lock_guard<std::mutex> lock(m_lockBuffer); std::lock_guard<dxvk::mutex> lock(m_lockBuffer);
m_desc.Width = Width; m_desc.Width = Width;
m_desc.Height = Height; m_desc.Height = Height;
@ -327,7 +327,7 @@ namespace dxvk {
HRESULT STDMETHODCALLTYPE DxgiSwapChain::ResizeTarget(const DXGI_MODE_DESC* pNewTargetParameters) { HRESULT STDMETHODCALLTYPE DxgiSwapChain::ResizeTarget(const DXGI_MODE_DESC* pNewTargetParameters) {
std::lock_guard<std::recursive_mutex> lock(m_lockWindow); std::lock_guard<dxvk::recursive_mutex> lock(m_lockWindow);
if (pNewTargetParameters == nullptr) if (pNewTargetParameters == nullptr)
return DXGI_ERROR_INVALID_CALL; return DXGI_ERROR_INVALID_CALL;
@ -387,7 +387,7 @@ namespace dxvk {
HRESULT STDMETHODCALLTYPE DxgiSwapChain::SetFullscreenState( HRESULT STDMETHODCALLTYPE DxgiSwapChain::SetFullscreenState(
BOOL Fullscreen, BOOL Fullscreen,
IDXGIOutput* pTarget) { IDXGIOutput* pTarget) {
std::lock_guard<std::recursive_mutex> lock(m_lockWindow); std::lock_guard<dxvk::recursive_mutex> lock(m_lockWindow);
if (!Fullscreen && pTarget) if (!Fullscreen && pTarget)
return DXGI_ERROR_INVALID_CALL; return DXGI_ERROR_INVALID_CALL;
@ -436,7 +436,7 @@ namespace dxvk {
if (!(m_desc.Flags & DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT)) if (!(m_desc.Flags & DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT))
return DXGI_ERROR_INVALID_CALL; return DXGI_ERROR_INVALID_CALL;
std::lock_guard<std::recursive_mutex> lock(m_lockWindow); std::lock_guard<dxvk::recursive_mutex> lock(m_lockWindow);
*pMaxLatency = m_presenter->GetFrameLatency(); *pMaxLatency = m_presenter->GetFrameLatency();
return S_OK; return S_OK;
} }
@ -465,7 +465,7 @@ namespace dxvk {
if (!(m_desc.Flags & DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT)) if (!(m_desc.Flags & DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT))
return DXGI_ERROR_INVALID_CALL; return DXGI_ERROR_INVALID_CALL;
std::lock_guard<std::recursive_mutex> lock(m_lockWindow); std::lock_guard<dxvk::recursive_mutex> lock(m_lockWindow);
return m_presenter->SetFrameLatency(MaxLatency); return m_presenter->SetFrameLatency(MaxLatency);
} }
@ -546,7 +546,7 @@ namespace dxvk {
HRESULT STDMETHODCALLTYPE DxgiSwapChain::SetGammaControl( HRESULT STDMETHODCALLTYPE DxgiSwapChain::SetGammaControl(
UINT NumPoints, UINT NumPoints,
const DXGI_RGB* pGammaCurve) { const DXGI_RGB* pGammaCurve) {
std::lock_guard<std::mutex> lockBuf(m_lockBuffer); std::lock_guard<dxvk::mutex> lockBuf(m_lockBuffer);
return m_presenter->SetGammaControl(NumPoints, pGammaCurve); return m_presenter->SetGammaControl(NumPoints, pGammaCurve);
} }

View File

@ -175,8 +175,8 @@ namespace dxvk {
RECT rect = { 0, 0, 0, 0 }; RECT rect = { 0, 0, 0, 0 };
}; };
std::recursive_mutex m_lockWindow; dxvk::recursive_mutex m_lockWindow;
std::mutex m_lockBuffer; dxvk::mutex m_lockBuffer;
Com<IDXGIFactory> m_factory; Com<IDXGIFactory> m_factory;
Com<IDXGIAdapter> m_adapter; Com<IDXGIAdapter> m_adapter;

View File

@ -37,14 +37,14 @@ namespace dxvk {
} }
std::mutex g_linkerSlotMutex; dxvk::mutex g_linkerSlotMutex;
uint32_t g_linkerSlotCount = 0; uint32_t g_linkerSlotCount = 0;
std::array<DxsoSemantic, 32> g_linkerSlots; std::array<DxsoSemantic, 32> g_linkerSlots;
uint32_t RegisterLinkerSlot(DxsoSemantic semantic) { uint32_t RegisterLinkerSlot(DxsoSemantic semantic) {
// Lock, because games could be trying // Lock, because games could be trying
// to make multiple shaders at a time. // to make multiple shaders at a time.
std::lock_guard<std::mutex> lock(g_linkerSlotMutex); std::lock_guard<dxvk::mutex> lock(g_linkerSlotMutex);
// Need to chose a slot that maps nicely and similarly // Need to chose a slot that maps nicely and similarly
// between vertex and pixel shaders // between vertex and pixel shaders

View File

@ -102,7 +102,7 @@ namespace dxvk {
DxvkCsThread::~DxvkCsThread() { DxvkCsThread::~DxvkCsThread() {
{ std::unique_lock<std::mutex> lock(m_mutex); { std::unique_lock<dxvk::mutex> lock(m_mutex);
m_stopped.store(true); m_stopped.store(true);
} }
@ -112,7 +112,7 @@ namespace dxvk {
void DxvkCsThread::dispatchChunk(DxvkCsChunkRef&& chunk) { void DxvkCsThread::dispatchChunk(DxvkCsChunkRef&& chunk) {
{ std::unique_lock<std::mutex> lock(m_mutex); { std::unique_lock<dxvk::mutex> lock(m_mutex);
m_chunksQueued.push(std::move(chunk)); m_chunksQueued.push(std::move(chunk));
m_chunksPending += 1; m_chunksPending += 1;
} }
@ -122,7 +122,7 @@ namespace dxvk {
void DxvkCsThread::synchronize() { void DxvkCsThread::synchronize() {
std::unique_lock<std::mutex> lock(m_mutex); std::unique_lock<dxvk::mutex> lock(m_mutex);
m_condOnSync.wait(lock, [this] { m_condOnSync.wait(lock, [this] {
return !m_chunksPending.load(); return !m_chunksPending.load();
@ -137,7 +137,7 @@ namespace dxvk {
try { try {
while (!m_stopped.load()) { while (!m_stopped.load()) {
{ std::unique_lock<std::mutex> lock(m_mutex); { std::unique_lock<dxvk::mutex> lock(m_mutex);
if (chunk) { if (chunk) {
if (--m_chunksPending == 0) if (--m_chunksPending == 0)
m_condOnSync.notify_one(); m_condOnSync.notify_one();

View File

@ -419,9 +419,9 @@ namespace dxvk {
const Rc<DxvkContext> m_context; const Rc<DxvkContext> m_context;
std::atomic<bool> m_stopped = { false }; std::atomic<bool> m_stopped = { false };
std::mutex m_mutex; dxvk::mutex m_mutex;
std::condition_variable m_condOnAdd; dxvk::condition_variable m_condOnAdd;
std::condition_variable m_condOnSync; dxvk::condition_variable m_condOnSync;
std::queue<DxvkCsChunkRef> m_chunksQueued; std::queue<DxvkCsChunkRef> m_chunksQueued;
std::atomic<uint32_t> m_chunksPending = { 0u }; std::atomic<uint32_t> m_chunksPending = { 0u };
dxvk::thread m_thread; dxvk::thread m_thread;

View File

@ -180,7 +180,7 @@ namespace dxvk {
DxvkGpuQueryHandle DxvkGpuQueryAllocator::allocQuery() { DxvkGpuQueryHandle DxvkGpuQueryAllocator::allocQuery() {
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<dxvk::mutex> lock(m_mutex);
if (m_handles.size() == 0) if (m_handles.size() == 0)
this->createQueryPool(); this->createQueryPool();
@ -195,7 +195,7 @@ namespace dxvk {
void DxvkGpuQueryAllocator::freeQuery(DxvkGpuQueryHandle handle) { void DxvkGpuQueryAllocator::freeQuery(DxvkGpuQueryHandle handle) {
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<dxvk::mutex> lock(m_mutex);
m_handles.push_back(handle); m_handles.push_back(handle);
} }

View File

@ -280,7 +280,7 @@ namespace dxvk {
VkQueryType m_queryType; VkQueryType m_queryType;
uint32_t m_queryPoolSize; uint32_t m_queryPoolSize;
std::mutex m_mutex; dxvk::mutex m_mutex;
std::vector<DxvkGpuQueryHandle> m_handles; std::vector<DxvkGpuQueryHandle> m_handles;
std::vector<VkQueryPool> m_pools; std::vector<VkQueryPool> m_pools;

View File

@ -215,7 +215,7 @@ namespace dxvk {
const VkMemoryDedicatedAllocateInfo& dedAllocInfo, const VkMemoryDedicatedAllocateInfo& dedAllocInfo,
VkMemoryPropertyFlags flags, VkMemoryPropertyFlags flags,
float priority) { float priority) {
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<dxvk::mutex> lock(m_mutex);
// Try to allocate from a memory type which supports the given flags exactly // Try to allocate from a memory type which supports the given flags exactly
auto dedAllocPtr = dedAllocReq.prefersDedicatedAllocation ? &dedAllocInfo : nullptr; auto dedAllocPtr = dedAllocReq.prefersDedicatedAllocation ? &dedAllocInfo : nullptr;
@ -386,7 +386,7 @@ namespace dxvk {
void DxvkMemoryAllocator::free( void DxvkMemoryAllocator::free(
const DxvkMemory& memory) { const DxvkMemory& memory) {
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<dxvk::mutex> lock(m_mutex);
memory.m_type->heap->stats.memoryUsed -= memory.m_length; memory.m_type->heap->stats.memoryUsed -= memory.m_length;
if (memory.m_chunk != nullptr) { if (memory.m_chunk != nullptr) {

View File

@ -282,7 +282,7 @@ namespace dxvk {
const VkPhysicalDeviceProperties m_devProps; const VkPhysicalDeviceProperties m_devProps;
const VkPhysicalDeviceMemoryProperties m_memProps; const VkPhysicalDeviceMemoryProperties m_memProps;
std::mutex m_mutex; dxvk::mutex m_mutex;
std::array<DxvkMemoryHeap, VK_MAX_MEMORY_HEAPS> m_memHeaps; std::array<DxvkMemoryHeap, VK_MAX_MEMORY_HEAPS> m_memHeaps;
std::array<DxvkMemoryType, VK_MAX_MEMORY_TYPES> m_memTypes; std::array<DxvkMemoryType, VK_MAX_MEMORY_TYPES> m_memTypes;

View File

@ -248,7 +248,7 @@ namespace dxvk {
VkImageViewType viewType, VkImageViewType viewType,
VkFormat viewFormat, VkFormat viewFormat,
VkSampleCountFlagBits samples) { VkSampleCountFlagBits samples) {
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<dxvk::mutex> lock(m_mutex);
DxvkMetaBlitPipelineKey key; DxvkMetaBlitPipelineKey key;
key.viewType = viewType; key.viewType = viewType;

View File

@ -199,7 +199,7 @@ namespace dxvk {
VkShaderModule m_shaderFrag2D = VK_NULL_HANDLE; VkShaderModule m_shaderFrag2D = VK_NULL_HANDLE;
VkShaderModule m_shaderFrag3D = VK_NULL_HANDLE; VkShaderModule m_shaderFrag3D = VK_NULL_HANDLE;
std::mutex m_mutex; dxvk::mutex m_mutex;
std::unordered_map< std::unordered_map<
DxvkMetaBlitRenderPassKey, DxvkMetaBlitRenderPassKey,

View File

@ -240,7 +240,7 @@ namespace dxvk {
VkImageViewType viewType, VkImageViewType viewType,
VkFormat dstFormat, VkFormat dstFormat,
VkSampleCountFlagBits dstSamples) { VkSampleCountFlagBits dstSamples) {
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<dxvk::mutex> lock(m_mutex);
DxvkMetaCopyPipelineKey key; DxvkMetaCopyPipelineKey key;
key.viewType = viewType; key.viewType = viewType;
@ -258,7 +258,7 @@ namespace dxvk {
DxvkMetaCopyPipeline DxvkMetaCopyObjects::getCopyBufferImagePipeline() { DxvkMetaCopyPipeline DxvkMetaCopyObjects::getCopyBufferImagePipeline() {
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<dxvk::mutex> lock(m_mutex);
if (!m_copyBufferImagePipeline.pipeHandle) if (!m_copyBufferImagePipeline.pipeHandle)
m_copyBufferImagePipeline = createCopyBufferImagePipeline(); m_copyBufferImagePipeline = createCopyBufferImagePipeline();

View File

@ -171,7 +171,7 @@ namespace dxvk {
FragShaders m_depth; FragShaders m_depth;
FragShaders m_depthStencil; FragShaders m_depthStencil;
std::mutex m_mutex; dxvk::mutex m_mutex;
std::unordered_map< std::unordered_map<
DxvkMetaCopyPipelineKey, DxvkMetaCopyPipelineKey,

View File

@ -330,7 +330,7 @@ namespace dxvk {
VkSampleCountFlagBits samples, VkSampleCountFlagBits samples,
VkResolveModeFlagBitsKHR depthResolveMode, VkResolveModeFlagBitsKHR depthResolveMode,
VkResolveModeFlagBitsKHR stencilResolveMode) { VkResolveModeFlagBitsKHR stencilResolveMode) {
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<dxvk::mutex> lock(m_mutex);
DxvkMetaResolvePipelineKey key; DxvkMetaResolvePipelineKey key;
key.format = format; key.format = format;

View File

@ -151,7 +151,7 @@ namespace dxvk {
VkShaderModule m_shaderFragD = VK_NULL_HANDLE; VkShaderModule m_shaderFragD = VK_NULL_HANDLE;
VkShaderModule m_shaderFragDS = VK_NULL_HANDLE; VkShaderModule m_shaderFragDS = VK_NULL_HANDLE;
std::mutex m_mutex; dxvk::mutex m_mutex;
std::unordered_map< std::unordered_map<
DxvkMetaResolvePipelineKey, DxvkMetaResolvePipelineKey,

View File

@ -46,13 +46,13 @@ namespace dxvk {
DxvkNameSet VrInstance::getInstanceExtensions() { DxvkNameSet VrInstance::getInstanceExtensions() {
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<dxvk::mutex> lock(m_mutex);
return m_insExtensions; return m_insExtensions;
} }
DxvkNameSet VrInstance::getDeviceExtensions(uint32_t adapterId) { DxvkNameSet VrInstance::getDeviceExtensions(uint32_t adapterId) {
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<dxvk::mutex> lock(m_mutex);
if (adapterId < m_devExtensions.size()) if (adapterId < m_devExtensions.size())
return m_devExtensions[adapterId]; return m_devExtensions[adapterId];
@ -62,7 +62,7 @@ namespace dxvk {
void VrInstance::initInstanceExtensions() { void VrInstance::initInstanceExtensions() {
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<dxvk::mutex> lock(m_mutex);
if (m_no_vr || m_initializedDevExt) if (m_no_vr || m_initializedDevExt)
return; return;
@ -87,7 +87,7 @@ namespace dxvk {
void VrInstance::initDeviceExtensions(const DxvkInstance* instance) { void VrInstance::initDeviceExtensions(const DxvkInstance* instance) {
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<dxvk::mutex> lock(m_mutex);
if (m_no_vr || (!m_vr_key && !m_compositor) || m_initializedDevExt) if (m_no_vr || (!m_vr_key && !m_compositor) || m_initializedDevExt)
return; return;

View File

@ -49,7 +49,7 @@ namespace dxvk {
private: private:
std::mutex m_mutex; dxvk::mutex m_mutex;
HKEY m_vr_key = nullptr; HKEY m_vr_key = nullptr;
vr::IVRCompositor* m_compositor = nullptr; vr::IVRCompositor* m_compositor = nullptr;
SoHandle m_ovrApi = nullptr; SoHandle m_ovrApi = nullptr;

View File

@ -29,19 +29,19 @@ namespace dxvk {
DxvkNameSet DxvkXrProvider::getInstanceExtensions() { DxvkNameSet DxvkXrProvider::getInstanceExtensions() {
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<dxvk::mutex> lock(m_mutex);
return m_insExtensions; return m_insExtensions;
} }
DxvkNameSet DxvkXrProvider::getDeviceExtensions(uint32_t adapterId) { DxvkNameSet DxvkXrProvider::getDeviceExtensions(uint32_t adapterId) {
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<dxvk::mutex> lock(m_mutex);
return m_devExtensions; return m_devExtensions;
} }
void DxvkXrProvider::initInstanceExtensions() { void DxvkXrProvider::initInstanceExtensions() {
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<dxvk::mutex> lock(m_mutex);
if (!m_wineOxr) if (!m_wineOxr)
m_wineOxr = this->loadLibrary(); m_wineOxr = this->loadLibrary();
@ -70,7 +70,7 @@ namespace dxvk {
void DxvkXrProvider::initDeviceExtensions(const DxvkInstance* instance) { void DxvkXrProvider::initDeviceExtensions(const DxvkInstance* instance) {
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<dxvk::mutex> lock(m_mutex);
if (!m_wineOxr || m_initializedDevExt) if (!m_wineOxr || m_initializedDevExt)
return; return;

View File

@ -43,7 +43,7 @@ namespace dxvk {
private: private:
std::mutex m_mutex; dxvk::mutex m_mutex;
SoHandle m_wineOxr = nullptr; SoHandle m_wineOxr = nullptr;
bool m_loadedOxrApi = false; bool m_loadedOxrApi = false;

View File

@ -26,7 +26,7 @@ namespace dxvk {
if (shaders.cs == nullptr) if (shaders.cs == nullptr)
return nullptr; return nullptr;
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<dxvk::mutex> lock(m_mutex);
auto pair = m_computePipelines.find(shaders); auto pair = m_computePipelines.find(shaders);
if (pair != m_computePipelines.end()) if (pair != m_computePipelines.end())
@ -45,7 +45,7 @@ namespace dxvk {
if (shaders.vs == nullptr) if (shaders.vs == nullptr)
return nullptr; return nullptr;
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<dxvk::mutex> lock(m_mutex);
auto pair = m_graphicsPipelines.find(shaders); auto pair = m_graphicsPipelines.find(shaders);
if (pair != m_graphicsPipelines.end()) if (pair != m_graphicsPipelines.end())

View File

@ -99,7 +99,7 @@ namespace dxvk {
std::atomic<uint32_t> m_numComputePipelines = { 0 }; std::atomic<uint32_t> m_numComputePipelines = { 0 };
std::atomic<uint32_t> m_numGraphicsPipelines = { 0 }; std::atomic<uint32_t> m_numGraphicsPipelines = { 0 };
std::mutex m_mutex; dxvk::mutex m_mutex;
std::unordered_map< std::unordered_map<
DxvkComputePipelineShaders, DxvkComputePipelineShaders,

View File

@ -12,7 +12,7 @@ namespace dxvk {
DxvkSubmissionQueue::~DxvkSubmissionQueue() { DxvkSubmissionQueue::~DxvkSubmissionQueue() {
{ std::unique_lock<std::mutex> lock(m_mutex); { std::unique_lock<dxvk::mutex> lock(m_mutex);
m_stopped.store(true); m_stopped.store(true);
} }
@ -25,7 +25,7 @@ namespace dxvk {
void DxvkSubmissionQueue::submit(DxvkSubmitInfo submitInfo) { void DxvkSubmissionQueue::submit(DxvkSubmitInfo submitInfo) {
std::unique_lock<std::mutex> lock(m_mutex); std::unique_lock<dxvk::mutex> lock(m_mutex);
m_finishCond.wait(lock, [this] { m_finishCond.wait(lock, [this] {
return m_submitQueue.size() + m_finishQueue.size() <= MaxNumQueuedCommandBuffers; return m_submitQueue.size() + m_finishQueue.size() <= MaxNumQueuedCommandBuffers;
@ -41,7 +41,7 @@ namespace dxvk {
void DxvkSubmissionQueue::present(DxvkPresentInfo presentInfo, DxvkSubmitStatus* status) { void DxvkSubmissionQueue::present(DxvkPresentInfo presentInfo, DxvkSubmitStatus* status) {
std::unique_lock<std::mutex> lock(m_mutex); std::unique_lock<dxvk::mutex> lock(m_mutex);
DxvkSubmitEntry entry = { }; DxvkSubmitEntry entry = { };
entry.status = status; entry.status = status;
@ -54,7 +54,7 @@ namespace dxvk {
void DxvkSubmissionQueue::synchronizeSubmission( void DxvkSubmissionQueue::synchronizeSubmission(
DxvkSubmitStatus* status) { DxvkSubmitStatus* status) {
std::unique_lock<std::mutex> lock(m_mutex); std::unique_lock<dxvk::mutex> lock(m_mutex);
m_submitCond.wait(lock, [status] { m_submitCond.wait(lock, [status] {
return status->result.load() != VK_NOT_READY; return status->result.load() != VK_NOT_READY;
@ -63,7 +63,7 @@ namespace dxvk {
void DxvkSubmissionQueue::synchronize() { void DxvkSubmissionQueue::synchronize() {
std::unique_lock<std::mutex> lock(m_mutex); std::unique_lock<dxvk::mutex> lock(m_mutex);
m_submitCond.wait(lock, [this] { m_submitCond.wait(lock, [this] {
return m_submitQueue.empty(); return m_submitQueue.empty();
@ -84,7 +84,7 @@ namespace dxvk {
void DxvkSubmissionQueue::submitCmdLists() { void DxvkSubmissionQueue::submitCmdLists() {
env::setThreadName("dxvk-submit"); env::setThreadName("dxvk-submit");
std::unique_lock<std::mutex> lock(m_mutex); std::unique_lock<dxvk::mutex> lock(m_mutex);
while (!m_stopped.load()) { while (!m_stopped.load()) {
m_appendCond.wait(lock, [this] { m_appendCond.wait(lock, [this] {
@ -101,7 +101,7 @@ namespace dxvk {
VkResult status = VK_NOT_READY; VkResult status = VK_NOT_READY;
if (m_lastError != VK_ERROR_DEVICE_LOST) { if (m_lastError != VK_ERROR_DEVICE_LOST) {
std::lock_guard<std::mutex> lock(m_mutexQueue); std::lock_guard<dxvk::mutex> lock(m_mutexQueue);
if (entry.submit.cmdList != nullptr) { if (entry.submit.cmdList != nullptr) {
status = entry.submit.cmdList->submit( status = entry.submit.cmdList->submit(
@ -120,7 +120,7 @@ namespace dxvk {
entry.status->result = status; entry.status->result = status;
// On success, pass it on to the queue thread // On success, pass it on to the queue thread
lock = std::unique_lock<std::mutex>(m_mutex); lock = std::unique_lock<dxvk::mutex>(m_mutex);
if (status == VK_SUCCESS) { if (status == VK_SUCCESS) {
if (entry.submit.cmdList != nullptr) if (entry.submit.cmdList != nullptr)
@ -140,7 +140,7 @@ namespace dxvk {
void DxvkSubmissionQueue::finishCmdLists() { void DxvkSubmissionQueue::finishCmdLists() {
env::setThreadName("dxvk-queue"); env::setThreadName("dxvk-queue");
std::unique_lock<std::mutex> lock(m_mutex); std::unique_lock<dxvk::mutex> lock(m_mutex);
while (!m_stopped.load()) { while (!m_stopped.load()) {
if (m_finishQueue.empty()) { if (m_finishQueue.empty()) {
@ -176,7 +176,7 @@ namespace dxvk {
m_device->recycleCommandList(entry.submit.cmdList); m_device->recycleCommandList(entry.submit.cmdList);
lock = std::unique_lock<std::mutex>(m_mutex); lock = std::unique_lock<dxvk::mutex>(m_mutex);
m_pending -= 1; m_pending -= 1;
m_finishQueue.pop(); m_finishQueue.pop();

View File

@ -173,18 +173,18 @@ namespace dxvk {
std::atomic<uint32_t> m_pending = { 0u }; std::atomic<uint32_t> m_pending = { 0u };
std::atomic<uint64_t> m_gpuIdle = { 0ull }; std::atomic<uint64_t> m_gpuIdle = { 0ull };
std::mutex m_mutex; dxvk::mutex m_mutex;
std::mutex m_mutexQueue; dxvk::mutex m_mutexQueue;
std::condition_variable m_appendCond; dxvk::condition_variable m_appendCond;
std::condition_variable m_submitCond; dxvk::condition_variable m_submitCond;
std::condition_variable m_finishCond; dxvk::condition_variable m_finishCond;
std::queue<DxvkSubmitEntry> m_submitQueue; std::queue<DxvkSubmitEntry> m_submitQueue;
std::queue<DxvkSubmitEntry> m_finishQueue; std::queue<DxvkSubmitEntry> m_finishQueue;
dxvk::thread m_submitThread; dxvk::thread m_submitThread;
dxvk::thread m_finishThread; dxvk::thread m_finishThread;
VkResult submitToQueue( VkResult submitToQueue(
const DxvkSubmitInfo& submission); const DxvkSubmitInfo& submission);

View File

@ -29,7 +29,7 @@ namespace dxvk {
* \return An object, or \c nullptr * \return An object, or \c nullptr
*/ */
Rc<T> retrieveObject() { Rc<T> retrieveObject() {
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<dxvk::mutex> lock(m_mutex);
if (m_objectId == 0) if (m_objectId == 0)
return nullptr; return nullptr;
@ -46,7 +46,7 @@ namespace dxvk {
* \param [in] object The object to return * \param [in] object The object to return
*/ */
void returnObject(const Rc<T>& object) { void returnObject(const Rc<T>& object) {
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<dxvk::mutex> lock(m_mutex);
if (m_objectId < N) if (m_objectId < N)
m_objects.at(m_objectId++) = object; m_objects.at(m_objectId++) = object;
@ -54,7 +54,7 @@ namespace dxvk {
private: private:
std::mutex m_mutex; dxvk::mutex m_mutex;
std::array<Rc<T>, N> m_objects; std::array<Rc<T>, N> m_objects;
size_t m_objectId = 0; size_t m_objectId = 0;

View File

@ -278,7 +278,7 @@ namespace dxvk {
DxvkRenderPass* DxvkRenderPassPool::getRenderPass(const DxvkRenderPassFormat& fmt) { DxvkRenderPass* DxvkRenderPassPool::getRenderPass(const DxvkRenderPassFormat& fmt) {
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<dxvk::mutex> lock(m_mutex);
auto entry = m_renderPasses.find(fmt); auto entry = m_renderPasses.find(fmt);
if (entry != m_renderPasses.end()) if (entry != m_renderPasses.end())

View File

@ -219,7 +219,7 @@ namespace dxvk {
const Rc<vk::DeviceFn> m_vkd; const Rc<vk::DeviceFn> m_vkd;
std::mutex m_mutex; dxvk::mutex m_mutex;
std::unordered_map< std::unordered_map<
DxvkRenderPassFormat, DxvkRenderPassFormat,
DxvkRenderPass, DxvkRenderPass,

View File

@ -210,8 +210,8 @@ namespace dxvk {
DxvkStateCache::~DxvkStateCache() { DxvkStateCache::~DxvkStateCache() {
{ std::lock_guard<std::mutex> workerLock(m_workerLock); { std::lock_guard<dxvk::mutex> workerLock(m_workerLock);
std::lock_guard<std::mutex> writerLock(m_writerLock); std::lock_guard<dxvk::mutex> writerLock(m_writerLock);
m_stopThreads.store(true); m_stopThreads.store(true);
@ -244,7 +244,7 @@ namespace dxvk {
} }
// Queue a job to write this pipeline to the cache // Queue a job to write this pipeline to the cache
std::unique_lock<std::mutex> lock(m_writerLock); std::unique_lock<dxvk::mutex> lock(m_writerLock);
m_writerQueue.push({ shaders, state, m_writerQueue.push({ shaders, state,
DxvkComputePipelineStateInfo(), DxvkComputePipelineStateInfo(),
@ -268,7 +268,7 @@ namespace dxvk {
} }
// Queue a job to write this pipeline to the cache // Queue a job to write this pipeline to the cache
std::unique_lock<std::mutex> lock(m_writerLock); std::unique_lock<dxvk::mutex> lock(m_writerLock);
m_writerQueue.push({ shaders, m_writerQueue.push({ shaders,
DxvkGraphicsPipelineStateInfo(), state, DxvkGraphicsPipelineStateInfo(), state,
@ -284,11 +284,11 @@ namespace dxvk {
return; return;
// Add the shader so we can look it up by its key // Add the shader so we can look it up by its key
std::unique_lock<std::mutex> entryLock(m_entryLock); std::unique_lock<dxvk::mutex> entryLock(m_entryLock);
m_shaderMap.insert({ key, shader }); m_shaderMap.insert({ key, shader });
// Deferred lock, don't stall workers unless we have to // Deferred lock, don't stall workers unless we have to
std::unique_lock<std::mutex> workerLock; std::unique_lock<dxvk::mutex> workerLock;
auto pipelines = m_pipelineMap.equal_range(key); auto pipelines = m_pipelineMap.equal_range(key);
@ -304,7 +304,7 @@ namespace dxvk {
continue; continue;
if (!workerLock) if (!workerLock)
workerLock = std::unique_lock<std::mutex>(m_workerLock); workerLock = std::unique_lock<dxvk::mutex>(m_workerLock);
m_workerQueue.push(item); m_workerQueue.push(item);
} }
@ -921,7 +921,7 @@ namespace dxvk {
while (!m_stopThreads.load()) { while (!m_stopThreads.load()) {
WorkerItem item; WorkerItem item;
{ std::unique_lock<std::mutex> lock(m_workerLock); { std::unique_lock<dxvk::mutex> lock(m_workerLock);
if (m_workerQueue.empty()) { if (m_workerQueue.empty()) {
m_workerBusy -= 1; m_workerBusy -= 1;
@ -954,7 +954,7 @@ namespace dxvk {
while (!m_stopThreads.load()) { while (!m_stopThreads.load()) {
DxvkStateCacheEntry entry; DxvkStateCacheEntry entry;
{ std::unique_lock<std::mutex> lock(m_writerLock); { std::unique_lock<dxvk::mutex> lock(m_writerLock);
m_writerCond.wait(lock, [this] () { m_writerCond.wait(lock, [this] () {
return m_writerQueue.size() return m_writerQueue.size()

View File

@ -94,7 +94,7 @@ namespace dxvk {
std::vector<DxvkStateCacheEntry> m_entries; std::vector<DxvkStateCacheEntry> m_entries;
std::atomic<bool> m_stopThreads = { false }; std::atomic<bool> m_stopThreads = { false };
std::mutex m_entryLock; dxvk::mutex m_entryLock;
std::unordered_multimap< std::unordered_multimap<
DxvkStateCacheKey, size_t, DxvkStateCacheKey, size_t,
@ -108,14 +108,14 @@ namespace dxvk {
DxvkShaderKey, Rc<DxvkShader>, DxvkShaderKey, Rc<DxvkShader>,
DxvkHash, DxvkEq> m_shaderMap; DxvkHash, DxvkEq> m_shaderMap;
std::mutex m_workerLock; dxvk::mutex m_workerLock;
std::condition_variable m_workerCond; dxvk::condition_variable m_workerCond;
std::queue<WorkerItem> m_workerQueue; std::queue<WorkerItem> m_workerQueue;
std::atomic<uint32_t> m_workerBusy; std::atomic<uint32_t> m_workerBusy;
std::vector<dxvk::thread> m_workerThreads; std::vector<dxvk::thread> m_workerThreads;
std::mutex m_writerLock; dxvk::mutex m_writerLock;
std::condition_variable m_writerCond; dxvk::condition_variable m_writerCond;
std::queue<WriterItem> m_writerQueue; std::queue<WriterItem> m_writerQueue;
dxvk::thread m_writerThread; dxvk::thread m_writerThread;

View File

@ -50,7 +50,7 @@ namespace dxvk {
void Logger::emitMsg(LogLevel level, const std::string& message) { void Logger::emitMsg(LogLevel level, const std::string& message) {
if (level >= m_minLevel) { if (level >= m_minLevel) {
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<dxvk::mutex> lock(m_mutex);
static std::array<const char*, 5> s_prefixes static std::array<const char*, 5> s_prefixes
= {{ "trace: ", "debug: ", "info: ", "warn: ", "err: " }}; = {{ "trace: ", "debug: ", "info: ", "warn: ", "err: " }};

View File

@ -3,9 +3,10 @@
#include <array> #include <array>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <mutex>
#include <string> #include <string>
#include "../thread.h"
namespace dxvk { namespace dxvk {
enum class LogLevel : uint32_t { enum class LogLevel : uint32_t {
@ -47,7 +48,7 @@ namespace dxvk {
const LogLevel m_minLevel; const LogLevel m_minLevel;
std::mutex m_mutex; dxvk::mutex m_mutex;
std::ofstream m_fileStream; std::ofstream m_fileStream;
void emitMsg(LogLevel level, const std::string& message); void emitMsg(LogLevel level, const std::string& message);

View File

@ -1,11 +1,11 @@
#pragma once #pragma once
#include <atomic> #include <atomic>
#include <condition_variable>
#include <mutex>
#include "../rc/util_rc.h" #include "../rc/util_rc.h"
#include "../thread.h"
namespace dxvk::sync { namespace dxvk::sync {
/** /**
@ -70,13 +70,13 @@ namespace dxvk::sync {
} }
void signal(uint64_t value) { void signal(uint64_t value) {
std::unique_lock<std::mutex> lock(m_mutex); std::unique_lock<dxvk::mutex> lock(m_mutex);
m_value.store(value, std::memory_order_release); m_value.store(value, std::memory_order_release);
m_cond.notify_all(); m_cond.notify_all();
} }
void wait(uint64_t value) { void wait(uint64_t value) {
std::unique_lock<std::mutex> lock(m_mutex); std::unique_lock<dxvk::mutex> lock(m_mutex);
m_cond.wait(lock, [this, value] { m_cond.wait(lock, [this, value] {
return value <= m_value.load(std::memory_order_acquire); return value <= m_value.load(std::memory_order_acquire);
}); });
@ -84,9 +84,9 @@ namespace dxvk::sync {
private: private:
std::atomic<uint64_t> m_value; std::atomic<uint64_t> m_value;
std::mutex m_mutex; dxvk::mutex m_mutex;
std::condition_variable m_cond; dxvk::condition_variable m_cond;
}; };

View File

@ -41,7 +41,7 @@ namespace dxvk::sync {
* \param [in] value Value to set signal to * \param [in] value Value to set signal to
*/ */
void signal(uint64_t value) { void signal(uint64_t value) {
std::unique_lock<std::mutex> lock(m_mutex); std::unique_lock<dxvk::mutex> lock(m_mutex);
m_value.store(value, std::memory_order_release); m_value.store(value, std::memory_order_release);
m_cond.notify_all(); m_cond.notify_all();
@ -60,7 +60,7 @@ namespace dxvk::sync {
* \param [in] value The value to wait for * \param [in] value The value to wait for
*/ */
void wait(uint64_t value) { void wait(uint64_t value) {
std::unique_lock<std::mutex> lock(m_mutex); std::unique_lock<dxvk::mutex> lock(m_mutex);
m_cond.wait(lock, [this, value] { m_cond.wait(lock, [this, value] {
return value <= m_value.load(std::memory_order_acquire); return value <= m_value.load(std::memory_order_acquire);
}); });
@ -77,7 +77,7 @@ namespace dxvk::sync {
* \param [in] value Requested signal value * \param [in] value Requested signal value
*/ */
void setEvent(HANDLE event, uint64_t value) { void setEvent(HANDLE event, uint64_t value) {
std::unique_lock<std::mutex> lock(m_mutex); std::unique_lock<dxvk::mutex> lock(m_mutex);
if (value > this->value()) if (value > this->value())
m_events.push_back({ event, value }); m_events.push_back({ event, value });
@ -87,9 +87,9 @@ namespace dxvk::sync {
private: private:
std::atomic<uint64_t> m_value; std::atomic<uint64_t> m_value;
std::mutex m_mutex; dxvk::mutex m_mutex;
std::condition_variable m_cond; dxvk::condition_variable m_cond;
std::list<std::pair<HANDLE, uint64_t>> m_events; std::list<std::pair<HANDLE, uint64_t>> m_events;

View File

@ -29,7 +29,7 @@ namespace dxvk {
void FpsLimiter::setTargetFrameRate(double frameRate) { void FpsLimiter::setTargetFrameRate(double frameRate) {
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<dxvk::mutex> lock(m_mutex);
if (!m_envOverride) { if (!m_envOverride) {
m_targetInterval = frameRate > 0.0 m_targetInterval = frameRate > 0.0
@ -43,7 +43,7 @@ namespace dxvk {
void FpsLimiter::setDisplayRefreshRate(double refreshRate) { void FpsLimiter::setDisplayRefreshRate(double refreshRate) {
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<dxvk::mutex> lock(m_mutex);
m_refreshInterval = refreshRate > 0.0 m_refreshInterval = refreshRate > 0.0
? NtTimerDuration(int64_t(double(NtTimerDuration::period::den) / refreshRate)) ? NtTimerDuration(int64_t(double(NtTimerDuration::period::den) / refreshRate))
@ -52,7 +52,7 @@ namespace dxvk {
void FpsLimiter::delay(bool vsyncEnabled) { void FpsLimiter::delay(bool vsyncEnabled) {
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<dxvk::mutex> lock(m_mutex);
if (!isEnabled()) if (!isEnabled())
return; return;

View File

@ -1,7 +1,6 @@
#pragma once #pragma once
#include <mutex> #include "thread.h"
#include "util_time.h" #include "util_time.h"
namespace dxvk { namespace dxvk {
@ -66,7 +65,7 @@ namespace dxvk {
using NtSetTimerResolutionProc = UINT (WINAPI *) (ULONG, BOOL, ULONG*); using NtSetTimerResolutionProc = UINT (WINAPI *) (ULONG, BOOL, ULONG*);
using NtDelayExecutionProc = UINT (WINAPI *) (BOOL, LARGE_INTEGER*); using NtDelayExecutionProc = UINT (WINAPI *) (BOOL, LARGE_INTEGER*);
std::mutex m_mutex; dxvk::mutex m_mutex;
NtTimerDuration m_targetInterval = NtTimerDuration::zero(); NtTimerDuration m_targetInterval = NtTimerDuration::zero();
NtTimerDuration m_refreshInterval = NtTimerDuration::zero(); NtTimerDuration m_refreshInterval = NtTimerDuration::zero();

View File

@ -32,7 +32,7 @@ namespace dxvk {
private: private:
std::mutex m_mutex; dxvk::mutex m_mutex;
std::unique_ptr<T> m_object; std::unique_ptr<T> m_object;
}; };

View File

@ -9,10 +9,10 @@
namespace dxvk { namespace dxvk {
LUID GetAdapterLUID(UINT Adapter) { LUID GetAdapterLUID(UINT Adapter) {
static std::mutex s_mutex; static dxvk::mutex s_mutex;
static std::vector<LUID> s_luids; static std::vector<LUID> s_luids;
std::lock_guard<std::mutex> lock(s_mutex); std::lock_guard<dxvk::mutex> lock(s_mutex);
uint32_t newLuidCount = Adapter + 1; uint32_t newLuidCount = Adapter + 1;
while (s_luids.size() < newLuidCount) { while (s_luids.size() < newLuidCount) {