From 4b54d7ece1e94e67b0c1018801770a3170c3bd85 Mon Sep 17 00:00:00 2001 From: Vincent Lejeune Date: Mon, 15 Feb 2016 22:34:20 +0100 Subject: [PATCH] d3d12: Pretty printing of error messages. --- rpcs3/Emu/RSX/D3D12/D3D12Utils.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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.