[util] Set thread names for DXVK's own threads

Makes it easier to identify the command stream thread and the
queue processing thread easier when using a wine build that
supports SetThreadDescription.
This commit is contained in:
Philip Rebohle 2018-06-21 15:12:04 +02:00
parent 432708c15f
commit 79a1703aea
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
5 changed files with 27 additions and 5 deletions

View File

@ -72,6 +72,8 @@ namespace dxvk {
void DxvkCsThread::threadFunc() {
env::setThreadName(L"dxvk-cs");
Rc<DxvkCsChunk> chunk;
while (!m_stopped.load()) {

View File

@ -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"));
}
}

View File

@ -35,6 +35,8 @@ namespace dxvk {
void DxvkSubmissionQueue::threadFunc() {
env::setThreadName(L"dxvk-queue");
while (!m_stopped.load()) {
Rc<DxvkCommandList> cmdList;

View File

@ -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<SetThreadDescriptionProc>(
::GetProcAddress(module, "SetThreadDescription"));
if (proc != nullptr)
(*proc)(::GetCurrentThread(), name);
}
}

View File

@ -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);
}