mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
VideoCommon: add ability to serialize graphics mod to json object
This commit is contained in:
@ -5,6 +5,7 @@
|
||||
|
||||
#include "Common/Logging/Log.h"
|
||||
#include "Common/StringUtil.h"
|
||||
#include "Common/VariantUtil.h"
|
||||
#include "VideoCommon/TextureCacheBase.h"
|
||||
|
||||
namespace
|
||||
@ -152,6 +153,53 @@ std::optional<std::string> ExtractTextureFilenameForConfig(const picojson::objec
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void SerializeTargetToConfig(picojson::object& json_obj, const GraphicsTargetConfig& target)
|
||||
{
|
||||
std::visit(
|
||||
overloaded{
|
||||
[&](const DrawStartedTextureTarget& the_target) {
|
||||
json_obj["type"] = picojson::value{"draw_started"};
|
||||
json_obj["texture_filename"] = picojson::value{the_target.m_texture_info_string};
|
||||
},
|
||||
[&](const LoadTextureTarget& the_target) {
|
||||
json_obj["type"] = picojson::value{"load_texture"};
|
||||
json_obj["texture_filename"] = picojson::value{the_target.m_texture_info_string};
|
||||
},
|
||||
[&](const CreateTextureTarget& the_target) {
|
||||
json_obj["type"] = picojson::value{"create_texture"};
|
||||
json_obj["texture_filename"] = picojson::value{the_target.m_texture_info_string};
|
||||
},
|
||||
[&](const EFBTarget& the_target) {
|
||||
json_obj["type"] = picojson::value{"efb"};
|
||||
json_obj["texture_filename"] = picojson::value{
|
||||
fmt::format("{}_{}x{}_{}", EFB_DUMP_PREFIX, the_target.m_width, the_target.m_height,
|
||||
static_cast<int>(the_target.m_texture_format))};
|
||||
},
|
||||
[&](const XFBTarget& the_target) {
|
||||
json_obj["type"] = picojson::value{"xfb"};
|
||||
json_obj["texture_filename"] = picojson::value{
|
||||
fmt::format("{}_{}x{}_{}", XFB_DUMP_PREFIX, the_target.m_width, the_target.m_height,
|
||||
static_cast<int>(the_target.m_texture_format))};
|
||||
},
|
||||
[&](const ProjectionTarget& the_target) {
|
||||
json_obj["type"] = picojson::value{"projection"};
|
||||
if (the_target.m_projection_type == ProjectionType::Orthographic)
|
||||
{
|
||||
json_obj["type"] = picojson::value{"2d"};
|
||||
}
|
||||
else
|
||||
{
|
||||
json_obj["type"] = picojson::value{"3d"};
|
||||
}
|
||||
if (the_target.m_texture_info_string)
|
||||
{
|
||||
json_obj["texture_filename"] = picojson::value{*the_target.m_texture_info_string};
|
||||
}
|
||||
},
|
||||
},
|
||||
target);
|
||||
}
|
||||
|
||||
std::optional<GraphicsTargetConfig> DeserializeTargetFromConfig(const picojson::object& obj)
|
||||
{
|
||||
const auto type_iter = obj.find("type");
|
||||
|
Reference in New Issue
Block a user