Revert "Refresh rate driven rendering tick logic (#3375)"
This reverts commit db63dcbcd9.
Signed-off-by: nvsickle <nvsickle@amazon.com>
This commit is contained in:
@@ -161,25 +161,19 @@ namespace AZ
|
||||
|
||||
//! Add this RenderPipeline to RPI system's RenderTick and it will be rendered whenever
|
||||
//! the RPI system's RenderTick is called.
|
||||
//! The RenderPipeline is rendered per RenderTick by default.
|
||||
//! The RenderPipeline is rendered per RenderTick by default unless AddToRenderTickOnce() was called.
|
||||
void AddToRenderTick();
|
||||
|
||||
//! Add this RenderPipeline to RPI system's RenderTick and it will be rendered every RenderTick
|
||||
//! after the specified interval has elapsed since the last rendered frame.
|
||||
//! @param renderInterval The desired time between rendered frames, in seconds.
|
||||
void AddToRenderTickAtInterval(AZStd::chrono::duration<float> renderInterval);
|
||||
|
||||
//! Disable render for this RenderPipeline
|
||||
void RemoveFromRenderTick();
|
||||
|
||||
~RenderPipeline();
|
||||
|
||||
|
||||
enum class RenderMode : uint8_t
|
||||
{
|
||||
RenderEveryTick, //!< Render at each RPI system render tick.
|
||||
RenderAtTargetRate, //!< Render on RPI system render tick after a target refresh rate interval has passed.
|
||||
RenderOnce, //!< Render once in next RPI system render tick.
|
||||
NoRender //!< Render disabled.
|
||||
RenderEveryTick, // Render at each RPI system render tick
|
||||
RenderOnce, // Render once in next RPI system render tick
|
||||
NoRender // Render disabled.
|
||||
};
|
||||
|
||||
//! Get current render mode
|
||||
@@ -191,12 +185,6 @@ namespace AZ
|
||||
//! Get draw filter mask
|
||||
RHI::DrawFilterMask GetDrawFilterMask() const;
|
||||
|
||||
using FrameNotificationEvent = AZ::Event<>;
|
||||
//! Notifies a listener when a frame is about to be prepared for render, before SRGs are bound.
|
||||
void ConnectPrepareFrameHandler(FrameNotificationEvent::Handler& handler);
|
||||
//! Notifies a listener when the rendering of a frame has finished
|
||||
void ConnectEndFrameHandler(FrameNotificationEvent::Handler& handler);
|
||||
|
||||
private:
|
||||
RenderPipeline() = default;
|
||||
|
||||
@@ -214,11 +202,8 @@ namespace AZ
|
||||
void OnAddedToScene(Scene* scene);
|
||||
void OnRemovedFromScene(Scene* scene);
|
||||
|
||||
// Called before this pipeline is about to be rendered and before SRGs are bound.
|
||||
void OnPrepareFrame();
|
||||
|
||||
// Called when this pipeline is about to be rendered
|
||||
void OnStartFrame();
|
||||
void OnStartFrame(const TickTimeInfo& tick);
|
||||
|
||||
// Called when the rendering of current frame is finished.
|
||||
void OnFrameEnd();
|
||||
@@ -243,14 +228,8 @@ namespace AZ
|
||||
|
||||
PipelineViewMap m_pipelineViewsByTag;
|
||||
|
||||
// The system time when the last time this pipeline render was started
|
||||
AZStd::chrono::system_clock::time_point m_lastRenderStartTime;
|
||||
|
||||
// The current system time, as of OnPrepareFrame's execution.
|
||||
AZStd::chrono::system_clock::time_point m_lastRenderRequestTime;
|
||||
|
||||
// The target time between renders when m_renderMode is RenderMode::RenderAtTargetRate
|
||||
AZStd::chrono::duration<float> m_targetRefreshRate;
|
||||
/// The system time when the last time this pipeline render was started
|
||||
float m_lastRenderStartTime = 0;
|
||||
|
||||
// RenderPipeline's name id, it will be used to identify the render pipeline when it's added to a Scene
|
||||
RenderPipelineId m_nameId;
|
||||
@@ -280,11 +259,7 @@ namespace AZ
|
||||
RHI::DrawFilterTag m_drawFilterTag;
|
||||
// A mask to filter draw items submitted by passes of this render pipeline.
|
||||
// This mask is created from the value of m_drawFilterTag.
|
||||
RHI::DrawFilterMask m_drawFilterMask = 0;
|
||||
|
||||
// Events for notification on render state
|
||||
FrameNotificationEvent m_prepareFrameEvent;
|
||||
FrameNotificationEvent m_endFrameEvent;
|
||||
RHI::DrawFilterMask m_drawFilterMask = 0;
|
||||
};
|
||||
|
||||
} // namespace RPI
|
||||
|
||||
@@ -67,9 +67,6 @@ namespace AZ
|
||||
|
||||
//! Notifies when the PrepareRender phase is ending
|
||||
virtual void OnEndPrepareRender() {}
|
||||
|
||||
//! Notifies when the render tick for a given frame has finished.
|
||||
virtual void OnFrameEnd() {}
|
||||
};
|
||||
|
||||
using SceneNotificationBus = AZ::EBus<SceneNotification>;
|
||||
|
||||
@@ -51,21 +51,9 @@ namespace AZ
|
||||
//! Sets the root scene associated with this viewport.
|
||||
//! This does not provide a default render pipeline, one must be provided to enable rendering.
|
||||
void SetRenderScene(ScenePtr scene);
|
||||
|
||||
//! Gets the maximum frame rate this viewport context's pipeline can render at, 0 for unlimited.
|
||||
//! The target framerate for the pipeline will be determined by this frame limit and the
|
||||
//! vsync settings for the current window.
|
||||
float GetFpsLimit() const;
|
||||
|
||||
//! Sets the maximum frame rate this viewport context's pipeline can render at, 0 for unlimited.
|
||||
//! The target framerate for the pipeline will be determined by this frame limit and the
|
||||
//! vsync settings for the current window.
|
||||
void SetFpsLimit(float fpsLimit);
|
||||
|
||||
//! Gets the target frame rate for this viewport context.
|
||||
//! This returns the lowest of either the current VSync refresh rate
|
||||
//! or 0 for an unlimited frame rate (if there's no FPS limit and vsync is off).
|
||||
float GetTargetFrameRate() const;
|
||||
//! Runs one simulation and render tick and renders a frame to this viewport's window.
|
||||
//! @note This is likely to be replaced by a tick management system in the RPI.
|
||||
void RenderTick();
|
||||
|
||||
//! Gets the current name of this ViewportContext.
|
||||
//! This name is used to tie this ViewportContext to its View stack, and ViewportContexts may be
|
||||
@@ -86,28 +74,19 @@ namespace AZ
|
||||
//! \see AzFramework::WindowRequests::GetDpiScaleFactor
|
||||
float GetDpiScalingFactor() const;
|
||||
|
||||
//! Gets the current vsync interval, as a divisor of the current refresh rate.
|
||||
//! A value of 0 indicates that vsync is disabled.
|
||||
uint32_t GetVsyncInterval() const;
|
||||
|
||||
//! Gets the current display refresh rate, in frames per second.
|
||||
uint32_t GetRefreshRate() const;
|
||||
|
||||
// SceneNotificationBus interface overrides...
|
||||
//! Ensures our default view remains set when our scene's render pipelines are modified.
|
||||
void OnRenderPipelineAdded(RenderPipelinePtr pipeline) override;
|
||||
//! Ensures our default view remains set when our scene's render pipelines are modified.
|
||||
void OnRenderPipelineRemoved(RenderPipeline* pipeline) override;
|
||||
//! OnBeginPrepareRender is forwarded to our RenderTick notification to allow subscribers to do rendering.
|
||||
void OnBeginPrepareRender() override;
|
||||
|
||||
// WindowNotificationBus interface overrides...
|
||||
//! Used to fire a notification when our window resizes.
|
||||
void OnWindowResized(uint32_t width, uint32_t height) override;
|
||||
//! Used to fire a notification when our window DPI changes.
|
||||
void OnDpiScaleFactorChanged(float dpiScaleFactor) override;
|
||||
//! Used to fire a notification when our vsync interval changes.
|
||||
void OnVsyncIntervalChanged(uint32_t interval) override;
|
||||
//! Used to fire a notification when our refresh rate changes.
|
||||
void OnRefreshRateChanged(uint32_t refreshRate) override;
|
||||
|
||||
using SizeChangedEvent = AZ::Event<AzFramework::WindowSize>;
|
||||
//! Notifies consumers when the viewport size has changed.
|
||||
@@ -119,12 +98,6 @@ namespace AZ
|
||||
//! Alternatively, connect to ViewportContextNotificationsBus and listen to ViewportContextNotifications::OnViewportDpiScalingChanged.
|
||||
void ConnectDpiScalingFactorChangedHandler(ScalarChangedEvent::Handler& handler);
|
||||
|
||||
using UintChangedEvent = AZ::Event<uint32_t>;
|
||||
//! Notifies consumers when the vsync interval has changed.
|
||||
void ConnectVsyncIntervalChangedHandler(UintChangedEvent::Handler& handler);
|
||||
//! Notifies consumers when the refresh rate has changed.
|
||||
void ConnectRefreshRateChangedHandler(UintChangedEvent::Handler& handler);
|
||||
|
||||
using MatrixChangedEvent = AZ::Event<const AZ::Matrix4x4&>;
|
||||
//! Notifies consumers when the view matrix has changed.
|
||||
void ConnectViewMatrixChangedHandler(MatrixChangedEvent::Handler& handler);
|
||||
@@ -166,24 +139,15 @@ namespace AZ
|
||||
void SetDefaultView(ViewPtr view);
|
||||
// Ensures our render pipeline's default camera matches ours.
|
||||
void UpdatePipelineView();
|
||||
// Ensures our render pipeline refresh rate matches our refresh rate.
|
||||
void UpdatePipelineRefreshRate();
|
||||
// Resets the current pipeline reference and ensures pipeline events are disconnected.
|
||||
void ResetCurrentPipeline();
|
||||
|
||||
ScenePtr m_rootScene;
|
||||
WindowContextSharedPtr m_windowContext;
|
||||
ViewPtr m_defaultView;
|
||||
AzFramework::WindowSize m_viewportSize;
|
||||
float m_viewportDpiScaleFactor = 1.0f;
|
||||
uint32_t m_vsyncInterval = 1;
|
||||
uint32_t m_refreshRate = 60;
|
||||
float m_fpsLimit = 0.f;
|
||||
|
||||
SizeChangedEvent m_sizeChangedEvent;
|
||||
ScalarChangedEvent m_dpiScalingFactorChangedEvent;
|
||||
UintChangedEvent m_vsyncIntervalChangedEvent;
|
||||
UintChangedEvent m_refreshRateChangedEvent;
|
||||
MatrixChangedEvent m_viewMatrixChangedEvent;
|
||||
MatrixChangedEvent::Handler m_onViewMatrixChangedHandler;
|
||||
MatrixChangedEvent m_projectionMatrixChangedEvent;
|
||||
@@ -193,9 +157,6 @@ namespace AZ
|
||||
ViewChangedEvent m_defaultViewChangedEvent;
|
||||
ViewportIdEvent m_aboutToBeDestroyedEvent;
|
||||
|
||||
AZ::Event<>::Handler m_prepareFrameHandler;
|
||||
AZ::Event<>::Handler m_endFrameHandler;
|
||||
|
||||
ViewportContextManager* m_manager;
|
||||
RenderPipelinePtr m_currentPipeline;
|
||||
Name m_name;
|
||||
|
||||
@@ -110,13 +110,11 @@ namespace AZ
|
||||
virtual void OnViewportSizeChanged(AzFramework::WindowSize size){AZ_UNUSED(size);}
|
||||
//! Called when the window DPI scaling changes for a given viewport context.
|
||||
virtual void OnViewportDpiScalingChanged(float dpiScale){AZ_UNUSED(dpiScale);}
|
||||
//! Called when the active view changes for a given viewport context.
|
||||
//! Called when the active view for a given viewport context name changes.
|
||||
virtual void OnViewportDefaultViewChanged(AZ::RPI::ViewPtr view){AZ_UNUSED(view);}
|
||||
//! Called when the viewport is to be rendered.
|
||||
//! Add draws to this function if they only need to be rendered to this viewport.
|
||||
virtual void OnRenderTick(){}
|
||||
//! Called when the viewport finishes rendering a frame.
|
||||
virtual void OnFrameEnd(){}
|
||||
//! Add draws to this functions if they only need to be rendered to this viewport.
|
||||
virtual void OnRenderTick(){};
|
||||
|
||||
protected:
|
||||
~ViewportContextNotifications() = default;
|
||||
|
||||
Reference in New Issue
Block a user