Refresh rate driven rendering tick logic (#3375)
* Implement sync interval and refresh rate API for RenderViewportWidget Signed-off-by: nvsickle <nvsickle@amazon.com> * Measure actual frame timings in the viewport info overlay. Takes the median of the sum of (frame end - frame begin) to provide more a more representative view of when frames begin and end. Note: Until VSync is internally supported by the event loop, this will produce nearly identical frame timings as the frame will spend as much time as needed synchronously waiting on a vblank. Signed-off-by: nvsickle <nvsickle@amazon.com> * Make frame timing per-pipeline, wire up refresh rate info to ViewportContext Signed-off-by: nvsickle <nvsickle@amazon.com> * POC: Frame limit pipeline rendering Signed-off-by: nvsickle <nvsickle@amazon.com> * Switch Editor tick to every 0ms to allow better tick accumulation behavior Signed-off-by: nvsickle <nvsickle@amazon.com> * Move RPISystemComponent to the tick bus, remove tick accumulation logic Signed-off-by: nvsickle <nvsickle@amazon.com> * Add `AddToRenderTickAtInterval` to RenderPipeline API This allows a pipeline to update at a set cadence, instead of rendering every frame or being directly told when to tick. Signed-off-by: nvsickle <nvsickle@amazon.com> * Make ViewportContext enforce a target framerate -Adds GetFpsLimit/SetFpsLimit for actively limiting FPS -Calculates a render tick interval based on vsync and the vps limit and updates the current pipeline Signed-off-by: nvsickle <nvsickle@amazon.com> * Add r_fps_limit and ed_inactive_viewport_fps_limit cvars Signed-off-by: nvsickle <nvsickle@amazon.com> * Quick null check from a crash I bumped into Signed-off-by: nvsickle <nvsickle@amazon.com> * Fix off-by-one on FPS calculation (shouldn't include the not-yet-rendered frame) Signed-off-by: nvsickle <nvsickle@amazon.com> * Clarify frame time begin initialization Signed-off-by: nvsickle <nvsickle@amazon.com> * Fix TrackView export. Signed-off-by: nvsickle <nvsickle@amazon.com> * Address some reviewer feedback, revert RPISystem API change, fix CPU profiler. Signed-off-by: nvsickle <nvsickle@amazon.com> * Add g_simulation_tick_rate Signed-off-by: nvsickle <nvsickle@amazon.com> * Address review feedback, make frame limit updates event driven Signed-off-by: nvsickle <nvsickle@amazon.com> * Remove timestamp update from ComponentApplication::Tick Signed-off-by: nvsickle <nvsickle@amazon.com>
This commit is contained in:
committed by
GitHub
parent
b2963f2bc1
commit
db63dcbcd9
@@ -420,7 +420,7 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
|
||||
void Scene::PrepareRender(const TickTimeInfo& tickInfo, RHI::JobPolicy jobPolicy)
|
||||
void Scene::PrepareRender([[maybe_unused]]const TickTimeInfo& tickInfo, RHI::JobPolicy jobPolicy)
|
||||
{
|
||||
AZ_ATOM_PROFILE_FUNCTION("RPI", "Scene: PrepareRender");
|
||||
|
||||
@@ -432,20 +432,27 @@ namespace AZ
|
||||
|
||||
SceneNotificationBus::Event(GetId(), &SceneNotification::OnBeginPrepareRender);
|
||||
|
||||
// Get active pipelines which need to be rendered and notify them frame started
|
||||
// Get active pipelines which need to be rendered and notify them of an impending frame.
|
||||
AZStd::vector<RenderPipelinePtr> activePipelines;
|
||||
{
|
||||
AZ_ATOM_PROFILE_TIME_GROUP_REGION("RPI", "Scene: OnStartFrame");
|
||||
AZ_ATOM_PROFILE_TIME_GROUP_REGION("RPI", "Scene: OnPrepareFrame");
|
||||
for (auto& pipeline : m_pipelines)
|
||||
{
|
||||
pipeline->OnPrepareFrame();
|
||||
if (pipeline->NeedsRender())
|
||||
{
|
||||
activePipelines.push_back(pipeline);
|
||||
pipeline->OnStartFrame(tickInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get active pipelines which need to be rendered and notify them frame started
|
||||
for (const auto& pipeline : activePipelines)
|
||||
{
|
||||
AZ_ATOM_PROFILE_TIME_GROUP_REGION("RPI", "Scene: OnStartFrame");
|
||||
pipeline->OnStartFrame();
|
||||
}
|
||||
|
||||
// Return if there is no active render pipeline
|
||||
if (activePipelines.empty())
|
||||
{
|
||||
@@ -587,10 +594,12 @@ namespace AZ
|
||||
void Scene::OnFrameEnd()
|
||||
{
|
||||
AZ_ATOM_PROFILE_FUNCTION("RPI", "Scene: OnFrameEnd");
|
||||
bool didRender = false;
|
||||
for (auto& pipeline : m_pipelines)
|
||||
{
|
||||
if (pipeline->NeedsRender())
|
||||
{
|
||||
didRender = true;
|
||||
pipeline->OnFrameEnd();
|
||||
}
|
||||
}
|
||||
@@ -598,6 +607,10 @@ namespace AZ
|
||||
{
|
||||
fp->OnRenderEnd();
|
||||
}
|
||||
if (didRender)
|
||||
{
|
||||
SceneNotificationBus::Event(GetId(), &SceneNotification::OnFrameEnd);
|
||||
}
|
||||
}
|
||||
|
||||
void Scene::UpdateSrgs()
|
||||
|
||||
Reference in New Issue
Block a user