mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
Merge pull request #10804 from iwubcode/graphics-mod-input-output-structs
VideoCommon: add structures to graphics mods internal API
This commit is contained in:
commit
1647fa350b
@ -650,6 +650,7 @@
|
||||
<ClInclude Include="VideoCommon\GraphicsModSystem\Runtime\Actions\SkipAction.h" />
|
||||
<ClInclude Include="VideoCommon\GraphicsModSystem\Runtime\FBInfo.h" />
|
||||
<ClInclude Include="VideoCommon\GraphicsModSystem\Runtime\GraphicsModAction.h" />
|
||||
<ClInclude Include="VideoCommon\GraphicsModSystem\Runtime\GraphicsModActionData.h" />
|
||||
<ClInclude Include="VideoCommon\GraphicsModSystem\Runtime\GraphicsModActionFactory.h" />
|
||||
<ClInclude Include="VideoCommon\GraphicsModSystem\Runtime\GraphicsModGroup.h" />
|
||||
<ClInclude Include="VideoCommon\GraphicsModSystem\Runtime\GraphicsModManager.h" />
|
||||
|
@ -61,6 +61,7 @@ add_library(videocommon
|
||||
GraphicsModSystem/Runtime/FBInfo.cpp
|
||||
GraphicsModSystem/Runtime/FBInfo.h
|
||||
GraphicsModSystem/Runtime/GraphicsModAction.h
|
||||
GraphicsModSystem/Runtime/GraphicsModActionData.h
|
||||
GraphicsModSystem/Runtime/GraphicsModActionFactory.cpp
|
||||
GraphicsModSystem/Runtime/GraphicsModActionFactory.h
|
||||
GraphicsModSystem/Runtime/GraphicsModManager.cpp
|
||||
|
@ -30,18 +30,26 @@ MoveAction::MoveAction(Common::Vec3 position_offset) : m_position_offset(positio
|
||||
{
|
||||
}
|
||||
|
||||
void MoveAction::OnProjection(Common::Matrix44* matrix)
|
||||
void MoveAction::OnProjection(GraphicsModActionData::Projection* projection)
|
||||
{
|
||||
if (!matrix)
|
||||
if (!projection) [[unlikely]]
|
||||
return;
|
||||
|
||||
*matrix *= Common::Matrix44::Translate(m_position_offset);
|
||||
}
|
||||
|
||||
void MoveAction::OnProjectionAndTexture(Common::Matrix44* matrix)
|
||||
{
|
||||
if (!matrix)
|
||||
if (!projection->matrix) [[unlikely]]
|
||||
return;
|
||||
|
||||
*matrix *= Common::Matrix44::Translate(m_position_offset);
|
||||
auto& matrix = *projection->matrix;
|
||||
matrix = matrix * Common::Matrix44::Translate(m_position_offset);
|
||||
}
|
||||
|
||||
void MoveAction::OnProjectionAndTexture(GraphicsModActionData::Projection* projection)
|
||||
{
|
||||
if (!projection) [[unlikely]]
|
||||
return;
|
||||
|
||||
if (!projection->matrix) [[unlikely]]
|
||||
return;
|
||||
|
||||
auto& matrix = *projection->matrix;
|
||||
matrix = matrix * Common::Matrix44::Translate(m_position_offset);
|
||||
}
|
||||
|
@ -14,8 +14,8 @@ class MoveAction final : public GraphicsModAction
|
||||
public:
|
||||
static std::unique_ptr<MoveAction> Create(const picojson::value& json_data);
|
||||
explicit MoveAction(Common::Vec3 position_offset);
|
||||
void OnProjection(Common::Matrix44* matrix) override;
|
||||
void OnProjectionAndTexture(Common::Matrix44* matrix) override;
|
||||
void OnProjection(GraphicsModActionData::Projection* projection) override;
|
||||
void OnProjectionAndTexture(GraphicsModActionData::Projection* projection) override;
|
||||
|
||||
private:
|
||||
Common::Vec3 m_position_offset;
|
||||
|
@ -5,27 +5,32 @@
|
||||
|
||||
#include "Common/Logging/Log.h"
|
||||
|
||||
void PrintAction::OnDrawStarted(bool*)
|
||||
void PrintAction::OnDrawStarted(GraphicsModActionData::DrawStarted*)
|
||||
{
|
||||
INFO_LOG_FMT(VIDEO, "OnDrawStarted Called");
|
||||
}
|
||||
|
||||
void PrintAction::OnEFB(bool*, u32 texture_width, u32 texture_height, u32* scaled_width,
|
||||
u32* scaled_height)
|
||||
void PrintAction::OnEFB(GraphicsModActionData::EFB* efb)
|
||||
{
|
||||
if (!scaled_width || !scaled_height)
|
||||
if (!efb) [[unlikely]]
|
||||
return;
|
||||
|
||||
INFO_LOG_FMT(VIDEO, "OnEFB Called. Original [{}, {}], Scaled [{}, {}]", texture_width,
|
||||
texture_height, *scaled_width, *scaled_height);
|
||||
if (!efb->scaled_width) [[unlikely]]
|
||||
return;
|
||||
|
||||
if (!efb->scaled_height) [[unlikely]]
|
||||
return;
|
||||
|
||||
INFO_LOG_FMT(VIDEO, "OnEFB Called. Original [{}, {}], Scaled [{}, {}]", efb->texture_width,
|
||||
efb->texture_height, *efb->scaled_width, *efb->scaled_height);
|
||||
}
|
||||
|
||||
void PrintAction::OnProjection(Common::Matrix44*)
|
||||
void PrintAction::OnProjection(GraphicsModActionData::Projection*)
|
||||
{
|
||||
INFO_LOG_FMT(VIDEO, "OnProjection Called");
|
||||
}
|
||||
|
||||
void PrintAction::OnProjectionAndTexture(Common::Matrix44*)
|
||||
void PrintAction::OnProjectionAndTexture(GraphicsModActionData::Projection*)
|
||||
{
|
||||
INFO_LOG_FMT(VIDEO, "OnProjectionAndTexture Called");
|
||||
}
|
||||
|
@ -8,10 +8,9 @@
|
||||
class PrintAction final : public GraphicsModAction
|
||||
{
|
||||
public:
|
||||
void OnDrawStarted(bool* skip) override;
|
||||
void OnEFB(bool* skip, u32 texture_width, u32 texture_height, u32* scaled_width,
|
||||
u32* scaled_height) override;
|
||||
void OnProjection(Common::Matrix44* matrix) override;
|
||||
void OnProjectionAndTexture(Common::Matrix44* matrix) override;
|
||||
void OnDrawStarted(GraphicsModActionData::DrawStarted*) override;
|
||||
void OnEFB(GraphicsModActionData::EFB*) override;
|
||||
void OnProjection(GraphicsModActionData::Projection*) override;
|
||||
void OnProjectionAndTexture(GraphicsModActionData::Projection*) override;
|
||||
void OnTextureLoad() override;
|
||||
};
|
||||
|
@ -30,30 +30,46 @@ ScaleAction::ScaleAction(Common::Vec3 scale) : m_scale(scale)
|
||||
{
|
||||
}
|
||||
|
||||
void ScaleAction::OnEFB(bool*, u32 texture_width, u32 texture_height, u32* scaled_width,
|
||||
u32* scaled_height)
|
||||
void ScaleAction::OnEFB(GraphicsModActionData::EFB* efb)
|
||||
{
|
||||
if (scaled_width && m_scale.x > 0)
|
||||
*scaled_width = texture_width * m_scale.x;
|
||||
|
||||
if (scaled_height && m_scale.y > 0)
|
||||
*scaled_height = texture_height * m_scale.y;
|
||||
}
|
||||
|
||||
void ScaleAction::OnProjection(Common::Matrix44* matrix)
|
||||
{
|
||||
if (!matrix)
|
||||
if (!efb) [[unlikely]]
|
||||
return;
|
||||
auto& the_matrix = *matrix;
|
||||
the_matrix.data[0] = the_matrix.data[0] * m_scale.x;
|
||||
the_matrix.data[5] = the_matrix.data[5] * m_scale.y;
|
||||
|
||||
if (!efb->scaled_width) [[unlikely]]
|
||||
return;
|
||||
|
||||
if (!efb->scaled_height) [[unlikely]]
|
||||
return;
|
||||
|
||||
if (m_scale.x > 0)
|
||||
*efb->scaled_width = efb->texture_width * m_scale.x;
|
||||
|
||||
if (m_scale.y > 0)
|
||||
*efb->scaled_height = efb->texture_height * m_scale.y;
|
||||
}
|
||||
|
||||
void ScaleAction::OnProjectionAndTexture(Common::Matrix44* matrix)
|
||||
void ScaleAction::OnProjection(GraphicsModActionData::Projection* projection)
|
||||
{
|
||||
if (!matrix)
|
||||
if (!projection) [[unlikely]]
|
||||
return;
|
||||
auto& the_matrix = *matrix;
|
||||
the_matrix.data[0] = the_matrix.data[0] * m_scale.x;
|
||||
the_matrix.data[5] = the_matrix.data[5] * m_scale.y;
|
||||
|
||||
if (!projection->matrix) [[unlikely]]
|
||||
return;
|
||||
|
||||
auto& matrix = *projection->matrix;
|
||||
matrix.data[0] = matrix.data[0] * m_scale.x;
|
||||
matrix.data[5] = matrix.data[5] * m_scale.y;
|
||||
}
|
||||
|
||||
void ScaleAction::OnProjectionAndTexture(GraphicsModActionData::Projection* projection)
|
||||
{
|
||||
if (!projection) [[unlikely]]
|
||||
return;
|
||||
|
||||
if (!projection->matrix) [[unlikely]]
|
||||
return;
|
||||
|
||||
auto& matrix = *projection->matrix;
|
||||
matrix.data[0] = matrix.data[0] * m_scale.x;
|
||||
matrix.data[5] = matrix.data[5] * m_scale.y;
|
||||
}
|
||||
|
@ -14,10 +14,9 @@ class ScaleAction final : public GraphicsModAction
|
||||
public:
|
||||
static std::unique_ptr<ScaleAction> Create(const picojson::value& json_data);
|
||||
explicit ScaleAction(Common::Vec3 scale);
|
||||
void OnEFB(bool* skip, u32 texture_width, u32 texture_height, u32* scaled_width,
|
||||
u32* scaled_height) override;
|
||||
void OnProjection(Common::Matrix44* matrix) override;
|
||||
void OnProjectionAndTexture(Common::Matrix44* matrix) override;
|
||||
void OnEFB(GraphicsModActionData::EFB*) override;
|
||||
void OnProjection(GraphicsModActionData::Projection*) override;
|
||||
void OnProjectionAndTexture(GraphicsModActionData::Projection*) override;
|
||||
|
||||
private:
|
||||
Common::Vec3 m_scale;
|
||||
|
@ -3,18 +3,24 @@
|
||||
|
||||
#include "VideoCommon/GraphicsModSystem/Runtime/Actions/SkipAction.h"
|
||||
|
||||
void SkipAction::OnDrawStarted(bool* skip)
|
||||
void SkipAction::OnDrawStarted(GraphicsModActionData::DrawStarted* draw_started)
|
||||
{
|
||||
if (!skip)
|
||||
if (!draw_started) [[unlikely]]
|
||||
return;
|
||||
|
||||
*skip = true;
|
||||
}
|
||||
|
||||
void SkipAction::OnEFB(bool* skip, u32, u32, u32*, u32*)
|
||||
{
|
||||
if (!skip)
|
||||
if (!draw_started->skip) [[unlikely]]
|
||||
return;
|
||||
|
||||
*skip = true;
|
||||
*draw_started->skip = true;
|
||||
}
|
||||
|
||||
void SkipAction::OnEFB(GraphicsModActionData::EFB* efb)
|
||||
{
|
||||
if (!efb) [[unlikely]]
|
||||
return;
|
||||
|
||||
if (!efb->skip) [[unlikely]]
|
||||
return;
|
||||
|
||||
*efb->skip = true;
|
||||
}
|
||||
|
@ -8,7 +8,6 @@
|
||||
class SkipAction final : public GraphicsModAction
|
||||
{
|
||||
public:
|
||||
void OnDrawStarted(bool* skip) override;
|
||||
void OnEFB(bool* skip, u32 texture_width, u32 texture_height, u32* scaled_width,
|
||||
u32* scaled_height) override;
|
||||
void OnDrawStarted(GraphicsModActionData::DrawStarted*) override;
|
||||
void OnEFB(GraphicsModActionData::EFB*) override;
|
||||
};
|
||||
|
@ -3,8 +3,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/Matrix.h"
|
||||
#include "VideoCommon/GraphicsModSystem/Runtime/GraphicsModActionData.h"
|
||||
|
||||
class GraphicsModAction
|
||||
{
|
||||
@ -16,14 +15,11 @@ public:
|
||||
GraphicsModAction& operator=(const GraphicsModAction&) = default;
|
||||
GraphicsModAction& operator=(GraphicsModAction&&) = default;
|
||||
|
||||
virtual void OnDrawStarted(bool* skip) {}
|
||||
virtual void OnEFB(bool* skip, u32 texture_width, u32 texture_height, u32* scaled_width,
|
||||
u32* scaled_height)
|
||||
{
|
||||
}
|
||||
virtual void OnDrawStarted(GraphicsModActionData::DrawStarted*) {}
|
||||
virtual void OnEFB(GraphicsModActionData::EFB*) {}
|
||||
virtual void OnXFB() {}
|
||||
virtual void OnProjection(Common::Matrix44* matrix) {}
|
||||
virtual void OnProjectionAndTexture(Common::Matrix44* matrix) {}
|
||||
virtual void OnProjection(GraphicsModActionData::Projection*) {}
|
||||
virtual void OnProjectionAndTexture(GraphicsModActionData::Projection*) {}
|
||||
virtual void OnTextureLoad() {}
|
||||
virtual void OnFrameEnd() {}
|
||||
};
|
||||
|
@ -0,0 +1,29 @@
|
||||
// Copyright 2022 Dolphin Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/Matrix.h"
|
||||
|
||||
namespace GraphicsModActionData
|
||||
{
|
||||
struct DrawStarted
|
||||
{
|
||||
bool* skip;
|
||||
};
|
||||
|
||||
struct EFB
|
||||
{
|
||||
u32 texture_width;
|
||||
u32 texture_height;
|
||||
bool* skip;
|
||||
u32* scaled_width;
|
||||
u32* scaled_height;
|
||||
};
|
||||
|
||||
struct Projection
|
||||
{
|
||||
Common::Matrix44* matrix;
|
||||
};
|
||||
} // namespace GraphicsModActionData
|
@ -22,30 +22,29 @@ public:
|
||||
: m_action_impl(std::move(action)), m_mod(std::move(mod))
|
||||
{
|
||||
}
|
||||
void OnDrawStarted(bool* skip) override
|
||||
void OnDrawStarted(GraphicsModActionData::DrawStarted* draw_started) override
|
||||
{
|
||||
if (!m_mod.m_enabled)
|
||||
return;
|
||||
m_action_impl->OnDrawStarted(skip);
|
||||
m_action_impl->OnDrawStarted(draw_started);
|
||||
}
|
||||
void OnEFB(bool* skip, u32 texture_width, u32 texture_height, u32* scaled_width,
|
||||
u32* scaled_height) override
|
||||
void OnEFB(GraphicsModActionData::EFB* efb) override
|
||||
{
|
||||
if (!m_mod.m_enabled)
|
||||
return;
|
||||
m_action_impl->OnEFB(skip, texture_width, texture_height, scaled_width, scaled_height);
|
||||
m_action_impl->OnEFB(efb);
|
||||
}
|
||||
void OnProjection(Common::Matrix44* matrix) override
|
||||
void OnProjection(GraphicsModActionData::Projection* projection) override
|
||||
{
|
||||
if (!m_mod.m_enabled)
|
||||
return;
|
||||
m_action_impl->OnProjection(matrix);
|
||||
m_action_impl->OnProjection(projection);
|
||||
}
|
||||
void OnProjectionAndTexture(Common::Matrix44* matrix) override
|
||||
void OnProjectionAndTexture(GraphicsModActionData::Projection* projection) override
|
||||
{
|
||||
if (!m_mod.m_enabled)
|
||||
return;
|
||||
m_action_impl->OnProjectionAndTexture(matrix);
|
||||
m_action_impl->OnProjectionAndTexture(projection);
|
||||
}
|
||||
void OnTextureLoad() override
|
||||
{
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "VideoCommon/BPMemory.h"
|
||||
#include "VideoCommon/FramebufferManager.h"
|
||||
#include "VideoCommon/GraphicsModSystem/Runtime/FBInfo.h"
|
||||
#include "VideoCommon/GraphicsModSystem/Runtime/GraphicsModActionData.h"
|
||||
#include "VideoCommon/HiresTextures.h"
|
||||
#include "VideoCommon/OpcodeDecoding.h"
|
||||
#include "VideoCommon/PixelShaderManager.h"
|
||||
@ -2158,9 +2159,10 @@ void TextureCacheBase::CopyRenderTargetToTexture(
|
||||
else
|
||||
{
|
||||
bool skip = false;
|
||||
GraphicsModActionData::EFB efb{tex_w, tex_h, &skip, &scaled_tex_w, &scaled_tex_h};
|
||||
for (const auto action : g_renderer->GetGraphicsModManager().GetEFBActions(info))
|
||||
{
|
||||
action->OnEFB(&skip, tex_w, tex_h, &scaled_tex_w, &scaled_tex_h);
|
||||
action->OnEFB(&efb);
|
||||
}
|
||||
if (skip == true)
|
||||
{
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "VideoCommon/DataReader.h"
|
||||
#include "VideoCommon/FramebufferManager.h"
|
||||
#include "VideoCommon/GeometryShaderManager.h"
|
||||
#include "VideoCommon/GraphicsModSystem/Runtime/GraphicsModActionData.h"
|
||||
#include "VideoCommon/IndexGenerator.h"
|
||||
#include "VideoCommon/NativeVertexFormat.h"
|
||||
#include "VideoCommon/OpcodeDecoding.h"
|
||||
@ -492,10 +493,11 @@ void VertexManagerBase::Flush()
|
||||
for (const auto& texture_name : texture_names)
|
||||
{
|
||||
bool skip = false;
|
||||
GraphicsModActionData::DrawStarted draw_started{&skip};
|
||||
for (const auto action :
|
||||
g_renderer->GetGraphicsModManager().GetDrawStartedActions(texture_name))
|
||||
{
|
||||
action->OnDrawStarted(&skip);
|
||||
action->OnDrawStarted(&draw_started);
|
||||
}
|
||||
if (skip == true)
|
||||
return;
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "VideoCommon/BPMemory.h"
|
||||
#include "VideoCommon/CPMemory.h"
|
||||
#include "VideoCommon/FreeLookCamera.h"
|
||||
#include "VideoCommon/GraphicsModSystem/Runtime/GraphicsModActionData.h"
|
||||
#include "VideoCommon/RenderBase.h"
|
||||
#include "VideoCommon/Statistics.h"
|
||||
#include "VideoCommon/VertexLoaderManager.h"
|
||||
@ -415,9 +416,10 @@ void VertexShaderManager::SetConstants(const std::vector<std::string>& textures)
|
||||
if (g_freelook_camera.IsActive() && xfmem.projection.type == ProjectionType::Perspective)
|
||||
corrected_matrix *= g_freelook_camera.GetView();
|
||||
|
||||
GraphicsModActionData::Projection projection{&corrected_matrix};
|
||||
for (auto action : projection_actions)
|
||||
{
|
||||
action->OnProjection(&corrected_matrix);
|
||||
action->OnProjection(&projection);
|
||||
}
|
||||
|
||||
memcpy(constants.projection.data(), corrected_matrix.data.data(), 4 * sizeof(float4));
|
||||
|
Loading…
Reference in New Issue
Block a user