summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/VertexManagerBase.cpp
diff options
context:
space:
mode:
authoriwubcode <iwubcode@users.noreply.github.com>2023-01-07 12:30:29 -0600
committeriwubcode <iwubcode@users.noreply.github.com>2023-08-20 18:53:27 -0500
commit931a8aa4139bddbc59a9cf94ca8e15f05000960c (patch)
treee43aab9761999f50ac9b50598f5d1a4f9394d6a0 /Source/Core/VideoCommon/VertexManagerBase.cpp
parent675544ec2beb6ba8c3d766b3dfe52e6e8cc30c0d (diff)
VideoCommon: add milliseconds elapsed time value to pixel shaders as a uniform to be able to support animation effects in custom shaders
Diffstat (limited to 'Source/Core/VideoCommon/VertexManagerBase.cpp')
-rw-r--r--Source/Core/VideoCommon/VertexManagerBase.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/Source/Core/VideoCommon/VertexManagerBase.cpp b/Source/Core/VideoCommon/VertexManagerBase.cpp
index 92e5be9952..564eb684dc 100644
--- a/Source/Core/VideoCommon/VertexManagerBase.cpp
+++ b/Source/Core/VideoCommon/VertexManagerBase.cpp
@@ -15,6 +15,7 @@
#include "Core/ConfigManager.h"
#include "Core/DolphinAnalytics.h"
+#include "Core/HW/SystemTimers.h"
#include "Core/System.h"
#include "VideoCommon/AbstractGfx.h"
@@ -107,6 +108,8 @@ VertexManagerBase::~VertexManagerBase() = default;
bool VertexManagerBase::Initialize()
{
m_frame_end_event = AfterFrameEvent::Register([this] { OnEndFrame(); }, "VertexManagerBase");
+ m_after_present_event = AfterPresentEvent::Register(
+ [this](PresentInfo& pi) { m_ticks_elapsed = pi.emulated_timestamp; }, "VertexManagerBase");
m_index_generator.Init();
m_custom_shader_cache = std::make_unique<CustomShaderCache>();
m_cpu_cull.Init();
@@ -526,6 +529,13 @@ void VertexManagerBase::Flush()
auto& geometry_shader_manager = system.GetGeometryShaderManager();
auto& vertex_shader_manager = system.GetVertexShaderManager();
+ if (g_ActiveConfig.bGraphicMods)
+ {
+ const double seconds_elapsed =
+ static_cast<double>(m_ticks_elapsed) / SystemTimers::GetTicksPerSecond();
+ pixel_shader_manager.constants.time_ms = seconds_elapsed * 1000;
+ }
+
CalculateBinormals(VertexLoaderManager::GetCurrentVertexFormat());
// Calculate ZSlope for zfreeze
const auto used_textures = UsedTextures();