summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/GraphicsModSystem/Config/GraphicsTarget.cpp
diff options
context:
space:
mode:
authorAdmiral H. Curtiss <pikachu025@gmail.com>2024-01-26 18:52:52 +0100
committerGitHub <noreply@github.com>2024-01-26 18:52:52 +0100
commitc3652a7129d4cea2d79bf935ab972f6eb05803ba (patch)
tree750aed09ec23fd8ed723546df9d0a60688f9ca3e /Source/Core/VideoCommon/GraphicsModSystem/Config/GraphicsTarget.cpp
parenta5533087754b5bb7b031682ac59d231876134701 (diff)
parent7a59ecc39da9e61ae3c10342039e695a7d602f50 (diff)
Merge pull request #12532 from lioncash/json
GraphicsMod/ShaderAsset: Lessen object churn a little bit
Diffstat (limited to 'Source/Core/VideoCommon/GraphicsModSystem/Config/GraphicsTarget.cpp')
-rw-r--r--Source/Core/VideoCommon/GraphicsModSystem/Config/GraphicsTarget.cpp84
1 files changed, 41 insertions, 43 deletions
diff --git a/Source/Core/VideoCommon/GraphicsModSystem/Config/GraphicsTarget.cpp b/Source/Core/VideoCommon/GraphicsModSystem/Config/GraphicsTarget.cpp
index 575a318484..b9f5ef8f29 100644
--- a/Source/Core/VideoCommon/GraphicsModSystem/Config/GraphicsTarget.cpp
+++ b/Source/Core/VideoCommon/GraphicsModSystem/Config/GraphicsTarget.cpp
@@ -155,49 +155,47 @@ std::optional<std::string> ExtractTextureFilenameForConfig(const picojson::objec
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::visit(overloaded{
+ [&](const DrawStartedTextureTarget& the_target) {
+ json_obj.emplace("type", "draw_started");
+ json_obj.emplace("texture_filename", the_target.m_texture_info_string);
+ },
+ [&](const LoadTextureTarget& the_target) {
+ json_obj.emplace("type", "load_texture");
+ json_obj.emplace("texture_filename", the_target.m_texture_info_string);
+ },
+ [&](const CreateTextureTarget& the_target) {
+ json_obj.emplace("type", "create_texture");
+ json_obj.emplace("texture_filename", the_target.m_texture_info_string);
+ },
+ [&](const EFBTarget& the_target) {
+ json_obj.emplace("type", "efb");
+ json_obj.emplace("texture_filename",
+ 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.emplace("type", "xfb");
+ json_obj.emplace("texture_filename",
+ 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) {
+ const char* type_name = "3d";
+ if (the_target.m_projection_type == ProjectionType::Orthographic)
+ type_name = "2d";
+
+ json_obj.emplace("type", type_name);
+
+ if (the_target.m_texture_info_string)
+ {
+ json_obj.emplace("texture_filename", *the_target.m_texture_info_string);
+ }
+ },
+ },
+ target);
}
std::optional<GraphicsTargetConfig> DeserializeTargetFromConfig(const picojson::object& obj)