mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-21 13:29:26 +01:00
[dxvk] Factor out waiting for resource to become idle
And use the new generic spin function to reduce syscall spam.
This commit is contained in:
parent
da506f5932
commit
ba213c1fa0
@ -616,8 +616,7 @@ namespace dxvk {
|
|||||||
Flush();
|
Flush();
|
||||||
SynchronizeCsThread();
|
SynchronizeCsThread();
|
||||||
|
|
||||||
while (Resource->isInUse(access))
|
Resource->waitIdle(access);
|
||||||
dxvk::this_thread::yield();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3779,8 +3779,7 @@ namespace dxvk {
|
|||||||
Flush();
|
Flush();
|
||||||
SynchronizeCsThread();
|
SynchronizeCsThread();
|
||||||
|
|
||||||
while (Resource->isInUse(access))
|
Resource->waitIdle(access);
|
||||||
dxvk::this_thread::yield();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,6 +70,19 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Waits for resource to become unused
|
||||||
|
*
|
||||||
|
* Blocks calling thread until the GPU finishes
|
||||||
|
* using the resource with the given access type.
|
||||||
|
* \param [in] access Access type to check for
|
||||||
|
*/
|
||||||
|
void waitIdle(DxvkAccess access = DxvkAccess::Read) const {
|
||||||
|
sync::spin(50000, [this, access] {
|
||||||
|
return !isInUse(access);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::atomic<uint32_t> m_useCountR = { 0u };
|
std::atomic<uint32_t> m_useCountR = { 0u };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user