mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-23 18:59:19 +00:00
VideoCommon: custom pipeline, add serialize/imgui/factory logic
This commit is contained in:
parent
04785bffb8
commit
e80d78adae
2 changed files with 72 additions and 0 deletions
|
@ -8,6 +8,8 @@
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
#include <imgui.h>
|
||||||
|
#include <misc/cpp/imgui_stdlib.h>
|
||||||
|
|
||||||
#include "Common/FileUtil.h"
|
#include "Common/FileUtil.h"
|
||||||
#include "Common/Logging/Log.h"
|
#include "Common/Logging/Log.h"
|
||||||
|
@ -18,6 +20,9 @@
|
||||||
#include "VideoCommon/AbstractGfx.h"
|
#include "VideoCommon/AbstractGfx.h"
|
||||||
#include "VideoCommon/Assets/CustomAssetLoader.h"
|
#include "VideoCommon/Assets/CustomAssetLoader.h"
|
||||||
#include "VideoCommon/Assets/DirectFilesystemAssetLibrary.h"
|
#include "VideoCommon/Assets/DirectFilesystemAssetLibrary.h"
|
||||||
|
#include "VideoCommon/GraphicsModEditor/Controls/AssetDisplay.h"
|
||||||
|
#include "VideoCommon/GraphicsModEditor/EditorEvents.h"
|
||||||
|
#include "VideoCommon/GraphicsModEditor/EditorMain.h"
|
||||||
#include "VideoCommon/ShaderGenCommon.h"
|
#include "VideoCommon/ShaderGenCommon.h"
|
||||||
#include "VideoCommon/TextureCacheBase.h"
|
#include "VideoCommon/TextureCacheBase.h"
|
||||||
|
|
||||||
|
@ -123,3 +128,66 @@ void CustomPipelineAction::OnDrawStarted(GraphicsModActionData::DrawStarted* dra
|
||||||
*draw_started->custom_pixel_shader = custom_pixel_shader;
|
*draw_started->custom_pixel_shader = custom_pixel_shader;
|
||||||
*draw_started->material_uniform_buffer = pass.m_material_data;
|
*draw_started->material_uniform_buffer = pass.m_material_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CustomPipelineAction::DrawImGui()
|
||||||
|
{
|
||||||
|
auto& editor = Core::System::GetInstance().GetGraphicsModEditor();
|
||||||
|
if (ImGui::CollapsingHeader("Custom pipeline", ImGuiTreeNodeFlags_DefaultOpen))
|
||||||
|
{
|
||||||
|
if (m_passes_config.size() == 1)
|
||||||
|
{
|
||||||
|
if (ImGui::BeginTable("CustomPipelineForm", 2))
|
||||||
|
{
|
||||||
|
ImGui::TableNextRow();
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::Text("Material");
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
if (GraphicsModEditor::Controls::AssetDisplay(
|
||||||
|
"CustomPipelineActionMaterial", editor.GetEditorState(),
|
||||||
|
&m_passes_config[0].m_pixel_material_asset, GraphicsModEditor::Material))
|
||||||
|
{
|
||||||
|
GraphicsModEditor::EditorEvents::ChangeOccurredEvent::Trigger();
|
||||||
|
}
|
||||||
|
ImGui::EndTable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_passes_config.empty())
|
||||||
|
{
|
||||||
|
if (ImGui::Button("Add pass"))
|
||||||
|
{
|
||||||
|
m_passes_config.emplace_back();
|
||||||
|
m_pipeline_passes.emplace_back();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Disable pass adding for now
|
||||||
|
ImGui::BeginDisabled();
|
||||||
|
ImGui::Button("Add pass");
|
||||||
|
ImGui::EndDisabled();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CustomPipelineAction::SerializeToConfig(picojson::object* obj)
|
||||||
|
{
|
||||||
|
if (!obj) [[unlikely]]
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto& json_obj = *obj;
|
||||||
|
|
||||||
|
picojson::array serialized_passes;
|
||||||
|
for (const auto& pass : m_passes_config)
|
||||||
|
{
|
||||||
|
picojson::object serialized_pass;
|
||||||
|
serialized_pass["pixel_material_asset"] = picojson::value{pass.m_pixel_material_asset};
|
||||||
|
serialized_passes.push_back(picojson::value{serialized_pass});
|
||||||
|
}
|
||||||
|
json_obj["passes"] = picojson::value{serialized_passes};
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string CustomPipelineAction::GetFactoryName() const
|
||||||
|
{
|
||||||
|
return "custom_pipeline";
|
||||||
|
}
|
||||||
|
|
|
@ -33,6 +33,10 @@ public:
|
||||||
std::vector<PipelinePassPassDescription> pass_descriptions);
|
std::vector<PipelinePassPassDescription> pass_descriptions);
|
||||||
void OnDrawStarted(GraphicsModActionData::DrawStarted*) override;
|
void OnDrawStarted(GraphicsModActionData::DrawStarted*) override;
|
||||||
|
|
||||||
|
void DrawImGui() override;
|
||||||
|
void SerializeToConfig(picojson::object* obj) override;
|
||||||
|
std::string GetFactoryName() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<VideoCommon::CustomAssetLibrary> m_library;
|
std::shared_ptr<VideoCommon::CustomAssetLibrary> m_library;
|
||||||
std::vector<PipelinePassPassDescription> m_passes_config;
|
std::vector<PipelinePassPassDescription> m_passes_config;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue