mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-31 14:52:11 +01:00
[dxvk] Estimate GPU idle time based on cleanup thread activity
We'll assume that GPU idle time == time spent waiting for new command lists to be added to the queue of the cleanup thread. This isn't entirely accurate, especially if CPU load is very high, but should be good enough.
This commit is contained in:
parent
02d917c680
commit
3d86ecd94d
@ -137,9 +137,16 @@ namespace dxvk {
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
|
||||
while (!m_stopped.load()) {
|
||||
m_submitCond.wait(lock, [this] {
|
||||
return m_stopped.load() || !m_finishQueue.empty();
|
||||
});
|
||||
if (m_finishQueue.empty()) {
|
||||
auto t0 = std::chrono::high_resolution_clock::now();
|
||||
|
||||
m_submitCond.wait(lock, [this] {
|
||||
return m_stopped.load() || !m_finishQueue.empty();
|
||||
});
|
||||
|
||||
auto t1 = std::chrono::high_resolution_clock::now();
|
||||
m_gpuIdle += std::chrono::duration_cast<std::chrono::microseconds>(t1 - t0).count();
|
||||
}
|
||||
|
||||
if (m_stopped.load())
|
||||
return;
|
||||
|
@ -80,6 +80,18 @@ namespace dxvk {
|
||||
uint32_t pendingSubmissions() const {
|
||||
return m_pending.load();
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Retrieves estimated GPU idle time
|
||||
*
|
||||
* This is a monotonically increasing counter
|
||||
* which can be evaluated periodically in order
|
||||
* to calculate the GPU load.
|
||||
* \returns Accumulated GPU idle time, in us
|
||||
*/
|
||||
uint64_t gpuIdleTicks() const {
|
||||
return m_gpuIdle.load();
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Submits a command list asynchronously
|
||||
@ -147,6 +159,7 @@ namespace dxvk {
|
||||
|
||||
std::atomic<bool> m_stopped = { false };
|
||||
std::atomic<uint32_t> m_pending = { 0u };
|
||||
std::atomic<uint64_t> m_gpuIdle = { 0ull };
|
||||
|
||||
std::mutex m_mutex;
|
||||
std::mutex m_mutexQueue;
|
||||
|
Loading…
x
Reference in New Issue
Block a user