diff --git a/rpcs3/Emu/RSX/D3D12/D3D12Utils.h b/rpcs3/Emu/RSX/D3D12/D3D12Utils.h index 294b4b6ec7..70f4fd110a 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12Utils.h +++ b/rpcs3/Emu/RSX/D3D12/D3D12Utils.h @@ -5,11 +5,24 @@ #include #include "Emu/Memory/vm.h" #include "Emu/RSX/GCM.h" +#include +#include using namespace Microsoft::WRL; -#define CHECK_HRESULT(expr) { HRESULT hr = (expr); if (FAILED(hr)) throw EXCEPTION("HRESULT = 0x%x", hr); } +inline std::string get_hresult_message(HRESULT hr) +{ + _com_error error(hr); +#ifndef UNICODE + return error.ErrorMessage(); +#else + using convert_type = std::codecvt; + return std::wstring_convert().to_bytes(error.ErrorMessage()); +#endif +} + +#define CHECK_HRESULT(expr) { HRESULT hr = (expr); if (FAILED(hr)) throw EXCEPTION("HRESULT = %s", get_hresult_message(hr)); } /** * Send data to dst pointer without polluting cache.