diff --git a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/CustomPipelineAction.cpp b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/CustomPipelineAction.cpp index 4e22d5b3f8..35c8ce0a25 100644 --- a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/CustomPipelineAction.cpp +++ b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/CustomPipelineAction.cpp @@ -3,7 +3,11 @@ #include "VideoCommon/GraphicsModSystem/Runtime/Actions/CustomPipelineAction.h" +#include "Common/JsonUtil.h" #include "Common/Logging/Log.h" +#include "Core/System.h" + +#include "VideoCommon/Resources/CustomResourceManager.h" std::unique_ptr CustomPipelineAction::Create(std::shared_ptr library) @@ -15,58 +19,16 @@ std::unique_ptr CustomPipelineAction::Create(const picojson::value& json_data, std::shared_ptr library) { - std::vector pipeline_passes; + auto material_asset = ReadStringFromJson(json_data.get(), "material_asset"); - const auto& passes_json = json_data.get("passes"); - if (passes_json.is()) + if (!material_asset) { - for (const auto& passes_json_val : passes_json.get()) - { - CustomPipelineAction::PipelinePassPassDescription pipeline_pass; - if (!passes_json_val.is()) - { - ERROR_LOG_FMT(VIDEO, - "Failed to load custom pipeline action, 'passes' has an array value that " - "is not an object!"); - return nullptr; - } - - auto pass = passes_json_val.get(); - if (!pass.contains("pixel_material_asset")) - { - ERROR_LOG_FMT(VIDEO, - "Failed to load custom pipeline action, 'passes' value missing required " - "field 'pixel_material_asset'"); - return nullptr; - } - - auto pixel_material_asset_json = pass["pixel_material_asset"]; - if (!pixel_material_asset_json.is()) - { - ERROR_LOG_FMT(VIDEO, "Failed to load custom pipeline action, 'passes' field " - "'pixel_material_asset' is not a string!"); - return nullptr; - } - pipeline_pass.m_pixel_material_asset = pixel_material_asset_json.to_str(); - pipeline_passes.push_back(std::move(pipeline_pass)); - } - } - - if (pipeline_passes.empty()) - { - ERROR_LOG_FMT(VIDEO, "Failed to load custom pipeline action, must specify at least one pass"); + ERROR_LOG_FMT(VIDEO, + "Failed to load custom pipeline action, 'material_asset' does not have a value"); return nullptr; } - if (pipeline_passes.size() > 1) - { - ERROR_LOG_FMT( - VIDEO, - "Failed to load custom pipeline action, multiple passes are not currently supported"); - return nullptr; - } - - return std::make_unique(std::move(library), std::move(pipeline_passes)); + return std::make_unique(std::move(library), std::move(*material_asset)); } CustomPipelineAction::CustomPipelineAction(std::shared_ptr library) @@ -74,14 +36,26 @@ CustomPipelineAction::CustomPipelineAction(std::shared_ptr library, - std::vector pass_descriptions) - : m_library(std::move(library)), m_passes_config(std::move(pass_descriptions)) +CustomPipelineAction::CustomPipelineAction(std::shared_ptr library, + std::string material_asset) + : m_library(std::move(library)), m_material_asset(std::move(material_asset)) { - m_pipeline_passes.resize(m_passes_config.size()); } void CustomPipelineAction::OnDrawStarted(GraphicsModActionData::DrawStarted*) { + // TODO +} + +void CustomPipelineAction::AfterEFB(GraphicsModActionData::PostEFB* post_efb) +{ + if (!post_efb) [[unlikely]] + return; + + if (m_material_asset.empty()) + return; + + auto& resource_manager = Core::System::GetInstance().GetCustomResourceManager(); + post_efb->material = + resource_manager.GetPostProcessingMaterialFromAsset(m_material_asset, m_library); } diff --git a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/CustomPipelineAction.h b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/CustomPipelineAction.h index 99026b99ce..d03ccd4a6e 100644 --- a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/CustomPipelineAction.h +++ b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/CustomPipelineAction.h @@ -6,22 +6,15 @@ #include #include #include -#include #include #include "VideoCommon/Assets/CustomAssetLibrary.h" -#include "VideoCommon/GraphicsModSystem/Runtime/CustomPipeline.h" #include "VideoCommon/GraphicsModSystem/Runtime/GraphicsModAction.h" class CustomPipelineAction final : public GraphicsModAction { public: - struct PipelinePassPassDescription - { - std::string m_pixel_material_asset; - }; - static constexpr std::string_view factory_name = "custom_pipeline"; static std::unique_ptr Create(const picojson::value& json_data, @@ -30,11 +23,11 @@ public: Create(std::shared_ptr library); explicit CustomPipelineAction(std::shared_ptr library); CustomPipelineAction(std::shared_ptr library, - std::vector pass_descriptions); + std::string material_asset); void OnDrawStarted(GraphicsModActionData::DrawStarted*) override; + void AfterEFB(GraphicsModActionData::PostEFB*) override; private: std::shared_ptr m_library; - std::vector m_passes_config; - std::vector m_pipeline_passes; + std::string m_material_asset; };