Debian Codegraph @

Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/CustomPipelineAction.cpp

raw symbols SCIP
1 // Copyright 2022 Dolphin Emulator Project
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #include "VideoCommon/GraphicsModSystem/Runtime/Actions/CustomPipelineAction.h"
5
6 #include "Common/JsonUtil.h"
7 #include "Common/Logging/Log.h"
8 #include "Core/System.h"
9
10 #include "VideoCommon/Resources/CustomResourceManager.h"
11
12 std::unique_ptr<CustomPipelineAction>
13 CustomPipelineAction::Create(std::shared_ptr<VideoCommon::CustomAssetLibrary> library)
14 {
15 return std::make_unique<CustomPipelineAction>(std::move(library));
16 }
17
18 std::unique_ptr<CustomPipelineAction>
19 CustomPipelineAction::Create(const picojson::value& json_data,
20 std::shared_ptr<VideoCommon::CustomAssetLibrary> library)
21 {
22 auto material_asset = ReadStringFromJson(json_data.get<picojson::object>(), "material_asset");
23
24 if (!material_asset)
25 {
26 ERROR_LOG_FMT(VIDEO,
27 "Failed to load custom pipeline action, 'material_asset' does not have a value");
28 return nullptr;
29 }
30
31 return std::make_unique<CustomPipelineAction>(std::move(library), std::move(*material_asset));
32 }
33
34 CustomPipelineAction::CustomPipelineAction(std::shared_ptr<VideoCommon::CustomAssetLibrary> library)
35 : m_library(std::move(library))
36 {
37 }
38
39 CustomPipelineAction::CustomPipelineAction(std::shared_ptr<VideoCommon::CustomAssetLibrary> library,
40 std::string material_asset)
41 : m_library(std::move(library)), m_material_asset(std::move(material_asset))
42 {
43 }
44
45 void CustomPipelineAction::OnDrawStarted(GraphicsModActionData::DrawStarted*)
46 {
47 // TODO
48 }
49
50 void CustomPipelineAction::AfterEFB(GraphicsModActionData::PostEFB* post_efb)
51 {
52 if (!post_efb) [[unlikely]]
53 return;
54
55 if (m_material_asset.empty())
56 return;
57
58 auto& resource_manager = Core::System::GetInstance().GetCustomResourceManager();
59 post_efb->material =
60 resource_manager.GetPostProcessingMaterialFromAsset(m_material_asset, m_library);
61 }