Fixed potential render scene time precision issues.
The timestamp was simply converted from GetTimeAtCurrentTick to a float. Since this value is backed by QueryPerformanceCounter which is 0 at boot, you could see broken animations on the GPU when your system has been on for a long time. So I simplified the RPI's time API (removed unused code), and subtracted the application start time each frame before converting the time value to a float.
Also moved FindShaderInputConstantIndex("m_time") to be called only once, instead of every frame.
Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
This commit is contained in:
@@ -96,8 +96,7 @@ namespace AZ
|
||||
// SystemTickBus::OnTick
|
||||
void OnSystemTick() override;
|
||||
|
||||
// Fill system time and game time information for simulation or rendering
|
||||
void FillTickTimeInfo();
|
||||
float GetCurrentTime();
|
||||
|
||||
// The set of core asset handlers registered by the system.
|
||||
AZStd::vector<AZStd::unique_ptr<Data::AssetHandler>> m_assetHandlers;
|
||||
@@ -123,8 +122,9 @@ namespace AZ
|
||||
// The job policy used for feature processor's rendering prepare
|
||||
RHI::JobPolicy m_prepareRenderJobPolicy = RHI::JobPolicy::Parallel;
|
||||
|
||||
TickTimeInfo m_tickTime;
|
||||
|
||||
ScriptTimePoint m_startTime;
|
||||
float m_currentSimulationTime = 0.0f;
|
||||
|
||||
RPISystemDescriptor m_descriptor;
|
||||
|
||||
// Reference to the shader asset that is used
|
||||
|
||||
@@ -32,7 +32,6 @@ namespace AZ
|
||||
namespace RPI
|
||||
{
|
||||
class Scene;
|
||||
struct TickTimeInfo;
|
||||
class ShaderResourceGroup;
|
||||
class AnyAsset;
|
||||
class WindowContext;
|
||||
@@ -203,7 +202,7 @@ namespace AZ
|
||||
void OnRemovedFromScene(Scene* scene);
|
||||
|
||||
// Called when this pipeline is about to be rendered
|
||||
void OnStartFrame(const TickTimeInfo& tick);
|
||||
void OnStartFrame(float time);
|
||||
|
||||
// Called when the rendering of current frame is finished.
|
||||
void OnFrameEnd();
|
||||
|
||||
@@ -47,14 +47,6 @@ namespace AZ
|
||||
// Callback function to modify values of a ShaderResourceGroup
|
||||
using ShaderResourceGroupCallback = AZStd::function<void(ShaderResourceGroup*)>;
|
||||
|
||||
//! A structure for ticks which contains system time and game time.
|
||||
struct TickTimeInfo
|
||||
{
|
||||
float m_currentGameTime;
|
||||
float m_gameDeltaTime = 0;
|
||||
};
|
||||
|
||||
|
||||
class Scene final
|
||||
: public SceneRequestBus::Handler
|
||||
{
|
||||
@@ -173,12 +165,14 @@ namespace AZ
|
||||
|
||||
// Cpu simulation which runs all active FeatureProcessor Simulate() functions.
|
||||
// @param jobPolicy if it's JobPolicy::Parallel, the function will spawn a job thread for each FeatureProcessor's simulation.
|
||||
void Simulate(const TickTimeInfo& tickInfo, RHI::JobPolicy jobPolicy);
|
||||
// @param simulationTime the number of seconds since the application started
|
||||
void Simulate(RHI::JobPolicy jobPolicy, float simulationTime);
|
||||
|
||||
// Collect DrawPackets from FeatureProcessors
|
||||
// @param jobPolicy if it's JobPolicy::Parallel, the function will spawn a job thread for each FeatureProcessor's
|
||||
// PrepareRender.
|
||||
void PrepareRender(const TickTimeInfo& tickInfo, RHI::JobPolicy jobPolicy);
|
||||
// @param simulationTime the number of seconds since the application started; this is the same time value that was passed to Simulate()
|
||||
void PrepareRender(RHI::JobPolicy jobPolicy, float simulationTime);
|
||||
|
||||
// Function called when the current frame is finished rendering.
|
||||
void OnFrameEnd();
|
||||
@@ -240,6 +234,7 @@ namespace AZ
|
||||
// Registry which allocates draw filter tag for RenderPipeline
|
||||
RHI::Ptr<RHI::DrawFilterTagRegistry> m_drawFilterTagRegistry;
|
||||
|
||||
RHI::ShaderInputConstantIndex m_timeInputIndex;
|
||||
float m_simulationTime;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user