rsx: Fix printing of expected values

This commit is contained in:
kd-11 2023-01-07 22:51:02 +03:00 committed by kd-11
parent c7fed20f3c
commit 439bdde849
5 changed files with 66 additions and 3 deletions

View File

@ -237,6 +237,29 @@ struct fmt_class_string<wchar_t*, void> : fmt_class_string<const wchar_t*>
{
};
namespace fmt
{
template <typename T>
concept StringConvertible = requires (T & t)
{
{ t.to_string() } -> std::convertible_to<std::string>;
};
}
template <fmt::StringConvertible T>
struct fmt_class_string<T, void>
{
static FORCE_INLINE SAFE_BUFFERS(const T&) get_object(u64 arg)
{
return *reinterpret_cast<const T*>(static_cast<uptr>(arg));
}
static void format(std::string& out, u64 arg)
{
out += get_object(arg).to_string();
}
};
namespace fmt
{
// Both uchar and std::byte are allowed

View File

@ -3,6 +3,12 @@
#include <concepts>
#include <utility>
namespace fmt
{
template <typename CharT, usz N, typename... Args>
static std::string format(const CharT(&)[N], const Args&...);
}
namespace rsx
{
namespace exception_utils
@ -26,6 +32,21 @@ namespace rsx
{
return error == soft_exception_error_code::none;
}
std::string to_string() const
{
switch (error)
{
case soft_exception_error_code::none:
return "No error";
case soft_exception_error_code::range_exception:
return "Bad Range";
case soft_exception_error_code::invalid_enum:
return "Invalid enum";
default:
return "Unknown Error";
}
}
};
}
@ -79,5 +100,20 @@ namespace rsx
{
return error.empty() && value == other;
}
std::string to_string() const
{
if (error.empty())
{
return fmt::format("%s", value);
}
if constexpr (std::is_same_v<E, exception_utils::soft_exception_t>)
{
return error.to_string();
}
return fmt::format("%s", error);
}
};
}

View File

@ -2820,7 +2820,7 @@ struct registers_decoder<NV3089_SET_COLOR_FORMAT>
static std::string dump(const decoded_type& decoded)
{
return fmt::format("NV3089: source fmt: %s", *decoded.transfer_source_fmt());
return fmt::format("NV3089: source fmt: %s", decoded.transfer_source_fmt());
}
};
@ -2866,7 +2866,7 @@ struct registers_decoder<NV3062_SET_COLOR_FORMAT>
static std::string dump(const decoded_type& decoded)
{
return fmt::format("NV3062: output fmt: %s", *decoded.transfer_dest_fmt());
return fmt::format("NV3062: output fmt: %s", decoded.transfer_dest_fmt());
}
};
@ -3759,7 +3759,7 @@ struct registers_decoder<NV309E_SET_FORMAT>
static std::string dump(const decoded_type& decoded)
{
return fmt::format("NV309E: output fmt: %s log2-width: %u log2-height: %u", *decoded.format(),
return fmt::format("NV309E: output fmt: %s log2-width: %u log2-height: %u", decoded.format(),
decoded.sw_width_log2(), decoded.sw_height_log2());
}
};

View File

@ -520,6 +520,7 @@
<ClInclude Include="Emu\perf_monitor.hpp" />
<ClInclude Include="Emu\RSX\Common\bitfield.hpp" />
<ClInclude Include="Emu\RSX\Common\buffer_stream.hpp" />
<ClInclude Include="Emu\RSX\Common\expected.hpp" />
<ClInclude Include="Emu\RSX\Common\profiling_timer.hpp" />
<ClInclude Include="Emu\RSX\Common\ranged_map.hpp" />
<ClInclude Include="Emu\RSX\Common\simple_array.hpp" />

View File

@ -2227,6 +2227,9 @@
<ClInclude Include="Emu\RSX\Core\RSXEngLock.hpp">
<Filter>Emu\GPU\RSX\Core</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\Common\expected.hpp">
<Filter>Emu\GPU\RSX\Common</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="Emu\RSX\Program\GLSLSnippets\GPUDeswizzle.glsl">