mini cleanup
This commit is contained in:
@@ -51,7 +51,7 @@ bool OpenGLRenderPipeline::RenderFrame(const RenderPipelineFrameContext& context
|
||||
const auto renderEndTime = std::chrono::steady_clock::now();
|
||||
const double renderMilliseconds = std::chrono::duration_cast<std::chrono::duration<double, std::milli>>(renderEndTime - renderStartTime).count();
|
||||
mHealthTelemetry.TryRecordPerformanceStats(state.frameBudgetMilliseconds, renderMilliseconds);
|
||||
mRuntimeSnapshotProvider.TryAdvanceFrame();
|
||||
mRuntimeSnapshotProvider.AdvanceFrame();
|
||||
|
||||
ReadOutputFrame(state, outputFrame);
|
||||
if (mPaint)
|
||||
|
||||
@@ -80,32 +80,11 @@ RuntimeSnapshotVersions RuntimeSnapshotProvider::GetVersions() const
|
||||
return versions;
|
||||
}
|
||||
|
||||
RuntimeRenderFrameContext RuntimeSnapshotProvider::GetFrameContext() const
|
||||
{
|
||||
std::vector<RuntimeRenderState> stateScratch(1);
|
||||
RefreshDynamicRenderStateFields(stateScratch);
|
||||
|
||||
RuntimeRenderFrameContext frameContext;
|
||||
const RuntimeRenderState& state = stateScratch.front();
|
||||
frameContext.timeSeconds = state.timeSeconds;
|
||||
frameContext.utcTimeSeconds = state.utcTimeSeconds;
|
||||
frameContext.utcOffsetSeconds = state.utcOffsetSeconds;
|
||||
frameContext.startupRandom = state.startupRandom;
|
||||
frameContext.frameCount = state.frameCount;
|
||||
return frameContext;
|
||||
}
|
||||
|
||||
void RuntimeSnapshotProvider::AdvanceFrame()
|
||||
{
|
||||
++mRuntimeHost.mFrameCounter;
|
||||
}
|
||||
|
||||
bool RuntimeSnapshotProvider::TryAdvanceFrame()
|
||||
{
|
||||
++mRuntimeHost.mFrameCounter;
|
||||
return true;
|
||||
}
|
||||
|
||||
RuntimeRenderStateSnapshot RuntimeSnapshotProvider::GetRenderStateSnapshot(unsigned outputWidth, unsigned outputHeight) const
|
||||
{
|
||||
for (;;)
|
||||
@@ -115,7 +94,10 @@ RuntimeRenderStateSnapshot RuntimeSnapshotProvider::GetRenderStateSnapshot(unsig
|
||||
RuntimeRenderStateSnapshot snapshot;
|
||||
snapshot.outputWidth = outputWidth;
|
||||
snapshot.outputHeight = outputHeight;
|
||||
snapshot.states = GetLayerRenderStates(outputWidth, outputHeight);
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mRuntimeHost.mMutex);
|
||||
BuildLayerRenderStatesLocked(outputWidth, outputHeight, snapshot.states);
|
||||
}
|
||||
|
||||
const RuntimeSnapshotVersions versionsAfter = GetVersions();
|
||||
if (versionsBefore.renderStateVersion == versionsAfter.renderStateVersion &&
|
||||
@@ -132,8 +114,13 @@ bool RuntimeSnapshotProvider::TryGetRenderStateSnapshot(unsigned outputWidth, un
|
||||
const RuntimeSnapshotVersions versionsBefore = GetVersions();
|
||||
|
||||
std::vector<RuntimeRenderState> states;
|
||||
if (!TryGetLayerRenderStates(outputWidth, outputHeight, states))
|
||||
return false;
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mRuntimeHost.mMutex, std::try_to_lock);
|
||||
if (!lock.owns_lock())
|
||||
return false;
|
||||
|
||||
BuildLayerRenderStatesLocked(outputWidth, outputHeight, states);
|
||||
}
|
||||
|
||||
const RuntimeSnapshotVersions versionsAfter = GetVersions();
|
||||
if (versionsBefore.renderStateVersion != versionsAfter.renderStateVersion ||
|
||||
@@ -152,8 +139,13 @@ bool RuntimeSnapshotProvider::TryGetRenderStateSnapshot(unsigned outputWidth, un
|
||||
bool RuntimeSnapshotProvider::TryRefreshSnapshotParameters(RuntimeRenderStateSnapshot& snapshot) const
|
||||
{
|
||||
const uint64_t expectedRenderStateVersion = snapshot.versions.renderStateVersion;
|
||||
if (!TryRefreshCachedLayerStates(snapshot.states))
|
||||
return false;
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mRuntimeHost.mMutex, std::try_to_lock);
|
||||
if (!lock.owns_lock())
|
||||
return false;
|
||||
|
||||
RefreshCachedLayerStatesLocked(snapshot.states);
|
||||
}
|
||||
|
||||
const RuntimeSnapshotVersions versions = GetVersions();
|
||||
if (versions.renderStateVersion != expectedRenderStateVersion)
|
||||
@@ -163,68 +155,12 @@ bool RuntimeSnapshotProvider::TryRefreshSnapshotParameters(RuntimeRenderStateSna
|
||||
return true;
|
||||
}
|
||||
|
||||
void RuntimeSnapshotProvider::ApplyFrameContext(std::vector<RuntimeRenderState>& states, const RuntimeRenderFrameContext& frameContext) const
|
||||
{
|
||||
for (RuntimeRenderState& state : states)
|
||||
{
|
||||
state.timeSeconds = frameContext.timeSeconds;
|
||||
state.utcTimeSeconds = frameContext.utcTimeSeconds;
|
||||
state.utcOffsetSeconds = frameContext.utcOffsetSeconds;
|
||||
state.startupRandom = frameContext.startupRandom;
|
||||
state.frameCount = frameContext.frameCount;
|
||||
}
|
||||
}
|
||||
|
||||
void RuntimeSnapshotProvider::ApplyFrameContext(RuntimeRenderStateSnapshot& snapshot, const RuntimeRenderFrameContext& frameContext) const
|
||||
{
|
||||
ApplyFrameContext(snapshot.states, frameContext);
|
||||
}
|
||||
|
||||
std::vector<RuntimeRenderState> RuntimeSnapshotProvider::GetLayerRenderStates(unsigned outputWidth, unsigned outputHeight) const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mRuntimeHost.mMutex);
|
||||
std::vector<RuntimeRenderState> states;
|
||||
BuildLayerRenderStatesLocked(outputWidth, outputHeight, states);
|
||||
return states;
|
||||
}
|
||||
|
||||
bool RuntimeSnapshotProvider::TryGetLayerRenderStates(unsigned outputWidth, unsigned outputHeight, std::vector<RuntimeRenderState>& states) const
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mRuntimeHost.mMutex, std::try_to_lock);
|
||||
if (!lock.owns_lock())
|
||||
return false;
|
||||
|
||||
states.clear();
|
||||
BuildLayerRenderStatesLocked(outputWidth, outputHeight, states);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RuntimeSnapshotProvider::TryRefreshCachedLayerStates(std::vector<RuntimeRenderState>& states) const
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mRuntimeHost.mMutex, std::try_to_lock);
|
||||
if (!lock.owns_lock())
|
||||
return false;
|
||||
|
||||
RefreshCachedLayerStatesLocked(states);
|
||||
return true;
|
||||
}
|
||||
|
||||
void RuntimeSnapshotProvider::RefreshDynamicRenderStateFields(std::vector<RuntimeRenderState>& states) const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mRuntimeHost.mMutex);
|
||||
RefreshDynamicRenderStateFieldsLocked(states);
|
||||
}
|
||||
|
||||
uint64_t RuntimeSnapshotProvider::GetRenderStateVersion() const
|
||||
{
|
||||
return GetVersions().renderStateVersion;
|
||||
}
|
||||
|
||||
uint64_t RuntimeSnapshotProvider::GetParameterStateVersion() const
|
||||
{
|
||||
return GetVersions().parameterStateVersion;
|
||||
}
|
||||
|
||||
void RuntimeSnapshotProvider::BuildLayerRenderStatesLocked(unsigned outputWidth, unsigned outputHeight, std::vector<RuntimeRenderState>& states) const
|
||||
{
|
||||
const HealthTelemetry::SignalStatusSnapshot signalStatus = mRuntimeHost.mHealthTelemetry.GetSignalStatusSnapshot();
|
||||
|
||||
@@ -12,15 +12,6 @@ struct RuntimeSnapshotVersions
|
||||
uint64_t parameterStateVersion = 0;
|
||||
};
|
||||
|
||||
struct RuntimeRenderFrameContext
|
||||
{
|
||||
double timeSeconds = 0.0;
|
||||
double utcTimeSeconds = 0.0;
|
||||
double utcOffsetSeconds = 0.0;
|
||||
double startupRandom = 0.0;
|
||||
double frameCount = 0.0;
|
||||
};
|
||||
|
||||
struct RuntimeRenderStateSnapshot
|
||||
{
|
||||
RuntimeSnapshotVersions versions;
|
||||
@@ -37,21 +28,11 @@ public:
|
||||
bool BuildLayerPassFragmentShaderSources(const std::string& layerId, std::vector<ShaderPassBuildSource>& passSources, std::string& error) const;
|
||||
unsigned GetMaxTemporalHistoryFrames() const;
|
||||
RuntimeSnapshotVersions GetVersions() const;
|
||||
RuntimeRenderFrameContext GetFrameContext() const;
|
||||
void AdvanceFrame();
|
||||
bool TryAdvanceFrame();
|
||||
RuntimeRenderStateSnapshot GetRenderStateSnapshot(unsigned outputWidth, unsigned outputHeight) const;
|
||||
bool TryGetRenderStateSnapshot(unsigned outputWidth, unsigned outputHeight, RuntimeRenderStateSnapshot& snapshot) const;
|
||||
bool TryRefreshSnapshotParameters(RuntimeRenderStateSnapshot& snapshot) const;
|
||||
void ApplyFrameContext(std::vector<RuntimeRenderState>& states, const RuntimeRenderFrameContext& frameContext) const;
|
||||
void ApplyFrameContext(RuntimeRenderStateSnapshot& snapshot, const RuntimeRenderFrameContext& frameContext) const;
|
||||
|
||||
std::vector<RuntimeRenderState> GetLayerRenderStates(unsigned outputWidth, unsigned outputHeight) const;
|
||||
bool TryGetLayerRenderStates(unsigned outputWidth, unsigned outputHeight, std::vector<RuntimeRenderState>& states) const;
|
||||
bool TryRefreshCachedLayerStates(std::vector<RuntimeRenderState>& states) const;
|
||||
void RefreshDynamicRenderStateFields(std::vector<RuntimeRenderState>& states) const;
|
||||
uint64_t GetRenderStateVersion() const;
|
||||
uint64_t GetParameterStateVersion() const;
|
||||
|
||||
private:
|
||||
void BuildLayerRenderStatesLocked(unsigned outputWidth, unsigned outputHeight, std::vector<RuntimeRenderState>& states) const;
|
||||
|
||||
Reference in New Issue
Block a user