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