[D3D12] Use WideCharToMultiByte for graphics adapter name

This commit is contained in:
Triang3l 2018-12-11 09:41:06 +03:00
parent 7698944673
commit 19d7e0ce3d
1 changed files with 12 additions and 8 deletions

View File

@ -168,14 +168,18 @@ D3D12Provider::InitializationResult D3D12Provider::Initialize() {
return InitializationResult::kDeviceInitializationFailed;
}
adapter_vendor_id_ = adapter_desc.VendorId;
size_t adapter_name_length =
std::wcstombs(nullptr, adapter_desc.Description, 0);
char* adapter_name_mbcs =
reinterpret_cast<char*>(alloca((adapter_name_length + 1) * sizeof(char)));
std::wcstombs(adapter_name_mbcs, adapter_desc.Description,
adapter_name_length + 1);
XELOGD3D("DXGI adapter: %s (vendor %.4X, device %.4X)", adapter_name_mbcs,
int adapter_name_mb_size = WideCharToMultiByte(
CP_UTF8, 0, adapter_desc.Description, -1, nullptr, 0, nullptr, nullptr);
if (adapter_name_mb_size != 0) {
char* adapter_name_mb =
reinterpret_cast<char*>(alloca(adapter_name_mb_size));
if (WideCharToMultiByte(CP_UTF8, 0, adapter_desc.Description, -1,
adapter_name_mb, adapter_name_mb_size, nullptr,
nullptr) != 0) {
XELOGD3D("DXGI adapter: %s (vendor %.4X, device %.4X)", adapter_name_mb,
adapter_desc.VendorId, adapter_desc.DeviceId);
}
}
// Create the Direct3D 12 device.
ID3D12Device* device;