[D3D12] Don't drain PSO preload creation queue if not queueing at all

This commit is contained in:
Triang3l 2022-01-30 12:37:14 +03:00
parent 4b8740d94f
commit 50cf96ff36
1 changed files with 32 additions and 30 deletions

View File

@ -703,37 +703,39 @@ void PipelineCache::InitializeShaderStorage(
++pipelines_created; ++pipelines_created;
} }
CreateQueuedPipelinesOnProcessorThread(); if (!creation_threads_.empty()) {
if (creation_threads_.size() > creation_thread_original_count) { CreateQueuedPipelinesOnProcessorThread();
{ if (creation_threads_.size() > creation_thread_original_count) {
std::lock_guard<std::mutex> lock(creation_request_lock_); {
creation_threads_shutdown_from_ = creation_thread_original_count; std::lock_guard<std::mutex> lock(creation_request_lock_);
// Assuming the queue is empty because of creation_threads_shutdown_from_ = creation_thread_original_count;
// CreateQueuedPipelinesOnProcessorThread. // Assuming the queue is empty because of
} // CreateQueuedPipelinesOnProcessorThread.
creation_request_cond_.notify_all(); }
while (creation_threads_.size() > creation_thread_original_count) { creation_request_cond_.notify_all();
xe::threading::Wait(creation_threads_.back().get(), false); while (creation_threads_.size() > creation_thread_original_count) {
creation_threads_.pop_back(); xe::threading::Wait(creation_threads_.back().get(), false);
} creation_threads_.pop_back();
bool await_creation_completion_event; }
{ bool await_creation_completion_event;
// Cleanup so additional threads can be created later again. {
std::lock_guard<std::mutex> lock(creation_request_lock_); // Cleanup so additional threads can be created later again.
creation_threads_shutdown_from_ = SIZE_MAX; std::lock_guard<std::mutex> lock(creation_request_lock_);
// If the invocation is blocking, all the shader storage initialization creation_threads_shutdown_from_ = SIZE_MAX;
// is expected to be done before proceeding, to avoid latency in the // If the invocation is blocking, all the shader storage
// command processor after the invocation. // initialization is expected to be done before proceeding, to avoid
await_creation_completion_event = // latency in the command processor after the invocation.
blocking && creation_threads_busy_ != 0; await_creation_completion_event =
if (await_creation_completion_event) { blocking && creation_threads_busy_ != 0;
creation_completion_event_->Reset(); if (await_creation_completion_event) {
creation_completion_set_event_ = true; creation_completion_event_->Reset();
creation_completion_set_event_ = true;
}
}
if (await_creation_completion_event) {
creation_request_cond_.notify_one();
xe::threading::Wait(creation_completion_event_.get(), false);
} }
}
if (await_creation_completion_event) {
creation_request_cond_.notify_one();
xe::threading::Wait(creation_completion_event_.get(), false);
} }
} }