[util] Get rid of explicit wchar_t parameter

We shouldn't be catering to Windows' weird string encoding mechanisms.
This commit is contained in:
Philip Rebohle 2019-01-11 13:43:15 +01:00
parent 4f0da40afa
commit 3935d2540e
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
5 changed files with 17 additions and 7 deletions

View File

@ -133,7 +133,7 @@ namespace dxvk {
void DxvkCsThread::threadFunc() {
env::setThreadName(L"dxvk-cs");
env::setThreadName("dxvk-cs");
DxvkCsChunkRef chunk;

View File

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

View File

@ -360,7 +360,7 @@ namespace dxvk {
void DxvkStateCache::workerFunc() {
env::setThreadName(L"dxvk-shader");
env::setThreadName("dxvk-shader");
while (!m_stopThreads.load()) {
WorkerItem item;
@ -385,7 +385,7 @@ namespace dxvk {
void DxvkStateCache::writerFunc() {
env::setThreadName(L"dxvk-writer");
env::setThreadName("dxvk-writer");
std::ofstream file;

View File

@ -43,9 +43,19 @@ namespace dxvk::env {
}
void setThreadName(const wchar_t* name) {
void setThreadName(const std::string& name) {
using SetThreadDescriptionProc = void (WINAPI *) (HANDLE, PCWSTR);
int nameLen = ::MultiByteToWideChar(
CP_ACP, 0, name.c_str(), name.length() + 1,
nullptr, 0);
std::vector<WCHAR> wideName(nameLen);
::MultiByteToWideChar(
CP_ACP, 0, name.c_str(), name.length() + 1,
wideName.data(), nameLen);
HMODULE module = ::GetModuleHandleW(L"kernel32.dll");
if (module == nullptr)
@ -55,7 +65,7 @@ namespace dxvk::env {
::GetProcAddress(module, "SetThreadDescription"));
if (proc != nullptr)
(*proc)(::GetCurrentThread(), name);
(*proc)(::GetCurrentThread(), wideName.data());
}
}

View File

@ -29,6 +29,6 @@ namespace dxvk::env {
* \brief Sets name of the calling thread
* \param [in] name Thread name
*/
void setThreadName(const wchar_t* name);
void setThreadName(const std::string& name);
}