mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-11-30 04:24:11 +01:00
[dxvk] Check whether CS thread is busy before synchronizing with it
Reduces unnecessary locking overhead, which may be relevant if this function gets called frequently by GetData or WaitForResource.
This commit is contained in:
parent
f6dbf5bbf0
commit
2f64f5b4e7
@ -487,7 +487,8 @@ namespace dxvk {
|
||||
// recorded prior to this function will be run
|
||||
FlushCsChunk();
|
||||
|
||||
m_csThread.synchronize();
|
||||
if (m_csThread.isBusy())
|
||||
m_csThread.synchronize();
|
||||
}
|
||||
|
||||
|
||||
|
@ -127,7 +127,7 @@ namespace dxvk {
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
|
||||
m_condOnSync.wait(lock, [this] {
|
||||
return m_chunksPending == 0;
|
||||
return !m_chunksPending.load();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -407,6 +407,18 @@ namespace dxvk {
|
||||
*/
|
||||
void synchronize();
|
||||
|
||||
/**
|
||||
* \brief Checks whether the worker thread is busy
|
||||
*
|
||||
* Note that this information is only reliable if
|
||||
* only the calling thread dispatches jobs to the
|
||||
* worker queue and if the result is \c false.
|
||||
* \returns \c true if there is still work to do
|
||||
*/
|
||||
bool isBusy() const {
|
||||
return m_chunksPending.load() != 0;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
const Rc<DxvkContext> m_context;
|
||||
@ -416,10 +428,9 @@ namespace dxvk {
|
||||
std::condition_variable m_condOnAdd;
|
||||
std::condition_variable m_condOnSync;
|
||||
std::queue<DxvkCsChunkRef> m_chunksQueued;
|
||||
std::atomic<uint32_t> m_chunksPending = { 0u };
|
||||
dxvk::thread m_thread;
|
||||
|
||||
uint32_t m_chunksPending = 0;
|
||||
|
||||
void threadFunc();
|
||||
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user