mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-21 21:57:39 +01:00
[dxvk] Add stat counter for shader compiler activity
This commit is contained in:
parent
522fa8d777
commit
bb01318984
@ -236,7 +236,8 @@ namespace dxvk {
|
||||
result.setCtr(DxvkStatCounter::MemoryUsed, mem.memoryUsed);
|
||||
result.setCtr(DxvkStatCounter::PipeCountGraphics, pipe.numGraphicsPipelines);
|
||||
result.setCtr(DxvkStatCounter::PipeCountCompute, pipe.numComputePipelines);
|
||||
|
||||
result.setCtr(DxvkStatCounter::PipeCompilerBusy, m_pipelineManager->isCompilingShaders());
|
||||
|
||||
std::lock_guard<sync::Spinlock> lock(m_statLock);
|
||||
result.merge(m_statCounters);
|
||||
return result;
|
||||
|
@ -121,5 +121,11 @@ namespace dxvk {
|
||||
result.numGraphicsPipelines = m_numGraphicsPipelines.load();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
bool DxvkPipelineManager::isCompilingShaders() const {
|
||||
return m_stateCache != nullptr
|
||||
&& m_stateCache->isCompilingShaders();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -127,6 +127,13 @@ namespace dxvk {
|
||||
* \returns Number of compute/graphics pipelines
|
||||
*/
|
||||
DxvkPipelineCount getPipelineCount() const;
|
||||
|
||||
/**
|
||||
* \brief Checks whether async compiler is busy
|
||||
* \returns \c true if shaders are being compiled
|
||||
*/
|
||||
bool isCompilingShaders() const;
|
||||
|
||||
private:
|
||||
|
||||
const DxvkDevice* m_device;
|
||||
|
@ -80,6 +80,8 @@ namespace dxvk {
|
||||
Logger::info(str::format("DXVK: Using ", numWorkers, " compiler threads"));
|
||||
|
||||
// Start the worker threads and the file writer
|
||||
m_workerBusy.store(numWorkers);
|
||||
|
||||
for (uint32_t i = 0; i < numWorkers; i++) {
|
||||
m_workerThreads.emplace_back([this] () { workerFunc(); });
|
||||
m_workerThreads[i].set_priority(ThreadPriority::Lowest);
|
||||
@ -410,12 +412,18 @@ namespace dxvk {
|
||||
|
||||
{ std::unique_lock<std::mutex> lock(m_workerLock);
|
||||
|
||||
m_workerCond.wait(lock, [this] () {
|
||||
return m_workerQueue.size()
|
||||
|| m_stopThreads.load();
|
||||
});
|
||||
if (m_workerQueue.empty()) {
|
||||
m_workerBusy -= 1;
|
||||
m_workerCond.wait(lock, [this] () {
|
||||
return m_workerQueue.size()
|
||||
|| m_stopThreads.load();
|
||||
});
|
||||
|
||||
if (m_workerQueue.size() == 0)
|
||||
if (!m_workerQueue.empty())
|
||||
m_workerBusy += 1;
|
||||
}
|
||||
|
||||
if (m_workerQueue.empty())
|
||||
break;
|
||||
|
||||
item = m_workerQueue.front();
|
||||
|
@ -125,6 +125,14 @@ namespace dxvk {
|
||||
*/
|
||||
void registerShader(
|
||||
const Rc<DxvkShader>& shader);
|
||||
|
||||
/**
|
||||
* \brief Checks whether compiler threads are busy
|
||||
* \returns \c true if we're compiling shaders
|
||||
*/
|
||||
bool isCompilingShaders() {
|
||||
return m_workerBusy.load() > 0;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@ -162,6 +170,7 @@ namespace dxvk {
|
||||
std::mutex m_workerLock;
|
||||
std::condition_variable m_workerCond;
|
||||
std::queue<WorkerItem> m_workerQueue;
|
||||
std::atomic<uint32_t> m_workerBusy;
|
||||
std::vector<dxvk::thread> m_workerThreads;
|
||||
|
||||
std::mutex m_writerLock;
|
||||
|
@ -19,6 +19,7 @@ namespace dxvk {
|
||||
MemoryUsed, ///< Amount of memory used
|
||||
PipeCountGraphics, ///< Number of graphics pipelines
|
||||
PipeCountCompute, ///< Number of compute pipelines
|
||||
PipeCompilerBusy, ///< Boolean indicating compiler activity
|
||||
QueueSubmitCount, ///< Number of command buffer submissions
|
||||
QueuePresentCount, ///< Number of present calls / frames
|
||||
NumCounters, ///< Number of counters available
|
||||
|
Loading…
x
Reference in New Issue
Block a user