diff --git a/src/dxvk/dxvk_cs.cpp b/src/dxvk/dxvk_cs.cpp index c6428a9f..6a4fe6d8 100644 --- a/src/dxvk/dxvk_cs.cpp +++ b/src/dxvk/dxvk_cs.cpp @@ -72,6 +72,8 @@ namespace dxvk { void DxvkCsThread::threadFunc() { + env::setThreadName(L"dxvk-cs"); + Rc chunk; while (!m_stopped.load()) { diff --git a/src/dxvk/dxvk_pipecompiler.cpp b/src/dxvk/dxvk_pipecompiler.cpp index 6d41a59d..f25bdbbf 100644 --- a/src/dxvk/dxvk_pipecompiler.cpp +++ b/src/dxvk/dxvk_pipecompiler.cpp @@ -40,8 +40,7 @@ namespace dxvk { void DxvkPipelineCompiler::runCompilerThread(uint32_t workerId) { - Logger::debug(str::format( - "DxvkPipelineCompiler: Worker #", workerId, " started")); + env::setThreadName(L"dxvk-pcompiler"); while (!m_compilerStop.load()) { PipelineEntry entry; @@ -62,9 +61,6 @@ namespace dxvk { if (entry.pipeline != nullptr && entry.instance != nullptr) entry.pipeline->compileInstance(entry.instance); } - - Logger::debug(str::format( - "DxvkPipelineCompiler: Worker #", workerId, " stopped")); } } \ No newline at end of file diff --git a/src/dxvk/dxvk_queue.cpp b/src/dxvk/dxvk_queue.cpp index 571c5072..9dc6b315 100644 --- a/src/dxvk/dxvk_queue.cpp +++ b/src/dxvk/dxvk_queue.cpp @@ -35,6 +35,8 @@ namespace dxvk { void DxvkSubmissionQueue::threadFunc() { + env::setThreadName(L"dxvk-queue"); + while (!m_stopped.load()) { Rc cmdList; diff --git a/src/util/util_env.cpp b/src/util/util_env.cpp index dfac0d44..cd151958 100644 --- a/src/util/util_env.cpp +++ b/src/util/util_env.cpp @@ -50,5 +50,21 @@ namespace dxvk::env { return str::fromws(dxvkTempDir); } + + + void setThreadName(const wchar_t* name) { + using SetThreadDescriptionProc = void (WINAPI *) (HANDLE, PCWSTR); + + HMODULE module = ::GetModuleHandleW(L"kernel32.dll"); + + if (module == nullptr) + return; + + auto proc = reinterpret_cast( + ::GetProcAddress(module, "SetThreadDescription")); + + if (proc != nullptr) + (*proc)(::GetCurrentThread(), name); + } } diff --git a/src/util/util_env.h b/src/util/util_env.h index 7ecf12c9..0a9ca388 100644 --- a/src/util/util_env.h +++ b/src/util/util_env.h @@ -33,5 +33,11 @@ namespace dxvk::env { * \returns Temporary directory */ std::string getTempDirectory(); + + /** + * \brief Sets name of the calling thread + * \param [in] name Thread name + */ + void setThreadName(const wchar_t* name); }