1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-31 05:52:11 +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:
Philip Rebohle 2020-03-14 11:01:53 +01:00 committed by Philip Rebohle
parent da506f5932
commit ba213c1fa0
3 changed files with 15 additions and 4 deletions

View File

@ -616,8 +616,7 @@ namespace dxvk {
Flush();
SynchronizeCsThread();
while (Resource->isInUse(access))
dxvk::this_thread::yield();
Resource->waitIdle(access);
}
}

View File

@ -3779,8 +3779,7 @@ namespace dxvk {
Flush();
SynchronizeCsThread();
while (Resource->isInUse(access))
dxvk::this_thread::yield();
Resource->waitIdle(access);
}
}

View File

@ -69,6 +69,19 @@ namespace dxvk {
: m_useCountW) -= 1;
}
}
/**
* \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: