mini cleanup
All checks were successful
CI / React UI Build (push) Successful in 11s
CI / Native Windows Build And Tests (push) Successful in 2m38s
CI / Windows Release Package (push) Successful in 2m41s

This commit is contained in:
Aiden
2026-05-11 00:41:51 +10:00
parent ba4643dfa3
commit 36b398ea95
3 changed files with 19 additions and 102 deletions

View File

@@ -51,7 +51,7 @@ bool OpenGLRenderPipeline::RenderFrame(const RenderPipelineFrameContext& context
const auto renderEndTime = std::chrono::steady_clock::now(); const auto renderEndTime = std::chrono::steady_clock::now();
const double renderMilliseconds = std::chrono::duration_cast<std::chrono::duration<double, std::milli>>(renderEndTime - renderStartTime).count(); const double renderMilliseconds = std::chrono::duration_cast<std::chrono::duration<double, std::milli>>(renderEndTime - renderStartTime).count();
mHealthTelemetry.TryRecordPerformanceStats(state.frameBudgetMilliseconds, renderMilliseconds); mHealthTelemetry.TryRecordPerformanceStats(state.frameBudgetMilliseconds, renderMilliseconds);
mRuntimeSnapshotProvider.TryAdvanceFrame(); mRuntimeSnapshotProvider.AdvanceFrame();
ReadOutputFrame(state, outputFrame); ReadOutputFrame(state, outputFrame);
if (mPaint) if (mPaint)

View File

@@ -80,32 +80,11 @@ RuntimeSnapshotVersions RuntimeSnapshotProvider::GetVersions() const
return versions; 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() void RuntimeSnapshotProvider::AdvanceFrame()
{ {
++mRuntimeHost.mFrameCounter; ++mRuntimeHost.mFrameCounter;
} }
bool RuntimeSnapshotProvider::TryAdvanceFrame()
{
++mRuntimeHost.mFrameCounter;
return true;
}
RuntimeRenderStateSnapshot RuntimeSnapshotProvider::GetRenderStateSnapshot(unsigned outputWidth, unsigned outputHeight) const RuntimeRenderStateSnapshot RuntimeSnapshotProvider::GetRenderStateSnapshot(unsigned outputWidth, unsigned outputHeight) const
{ {
for (;;) for (;;)
@@ -115,7 +94,10 @@ RuntimeRenderStateSnapshot RuntimeSnapshotProvider::GetRenderStateSnapshot(unsig
RuntimeRenderStateSnapshot snapshot; RuntimeRenderStateSnapshot snapshot;
snapshot.outputWidth = outputWidth; snapshot.outputWidth = outputWidth;
snapshot.outputHeight = outputHeight; 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(); const RuntimeSnapshotVersions versionsAfter = GetVersions();
if (versionsBefore.renderStateVersion == versionsAfter.renderStateVersion && if (versionsBefore.renderStateVersion == versionsAfter.renderStateVersion &&
@@ -132,8 +114,13 @@ bool RuntimeSnapshotProvider::TryGetRenderStateSnapshot(unsigned outputWidth, un
const RuntimeSnapshotVersions versionsBefore = GetVersions(); const RuntimeSnapshotVersions versionsBefore = GetVersions();
std::vector<RuntimeRenderState> states; 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(); const RuntimeSnapshotVersions versionsAfter = GetVersions();
if (versionsBefore.renderStateVersion != versionsAfter.renderStateVersion || if (versionsBefore.renderStateVersion != versionsAfter.renderStateVersion ||
@@ -152,8 +139,13 @@ bool RuntimeSnapshotProvider::TryGetRenderStateSnapshot(unsigned outputWidth, un
bool RuntimeSnapshotProvider::TryRefreshSnapshotParameters(RuntimeRenderStateSnapshot& snapshot) const bool RuntimeSnapshotProvider::TryRefreshSnapshotParameters(RuntimeRenderStateSnapshot& snapshot) const
{ {
const uint64_t expectedRenderStateVersion = snapshot.versions.renderStateVersion; 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(); const RuntimeSnapshotVersions versions = GetVersions();
if (versions.renderStateVersion != expectedRenderStateVersion) if (versions.renderStateVersion != expectedRenderStateVersion)
@@ -163,68 +155,12 @@ bool RuntimeSnapshotProvider::TryRefreshSnapshotParameters(RuntimeRenderStateSna
return true; 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 void RuntimeSnapshotProvider::RefreshDynamicRenderStateFields(std::vector<RuntimeRenderState>& states) const
{ {
std::lock_guard<std::mutex> lock(mRuntimeHost.mMutex); std::lock_guard<std::mutex> lock(mRuntimeHost.mMutex);
RefreshDynamicRenderStateFieldsLocked(states); 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 void RuntimeSnapshotProvider::BuildLayerRenderStatesLocked(unsigned outputWidth, unsigned outputHeight, std::vector<RuntimeRenderState>& states) const
{ {
const HealthTelemetry::SignalStatusSnapshot signalStatus = mRuntimeHost.mHealthTelemetry.GetSignalStatusSnapshot(); const HealthTelemetry::SignalStatusSnapshot signalStatus = mRuntimeHost.mHealthTelemetry.GetSignalStatusSnapshot();

View File

@@ -12,15 +12,6 @@ struct RuntimeSnapshotVersions
uint64_t parameterStateVersion = 0; 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 struct RuntimeRenderStateSnapshot
{ {
RuntimeSnapshotVersions versions; RuntimeSnapshotVersions versions;
@@ -37,21 +28,11 @@ public:
bool BuildLayerPassFragmentShaderSources(const std::string& layerId, std::vector<ShaderPassBuildSource>& passSources, std::string& error) const; bool BuildLayerPassFragmentShaderSources(const std::string& layerId, std::vector<ShaderPassBuildSource>& passSources, std::string& error) const;
unsigned GetMaxTemporalHistoryFrames() const; unsigned GetMaxTemporalHistoryFrames() const;
RuntimeSnapshotVersions GetVersions() const; RuntimeSnapshotVersions GetVersions() const;
RuntimeRenderFrameContext GetFrameContext() const;
void AdvanceFrame(); void AdvanceFrame();
bool TryAdvanceFrame();
RuntimeRenderStateSnapshot GetRenderStateSnapshot(unsigned outputWidth, unsigned outputHeight) const; RuntimeRenderStateSnapshot GetRenderStateSnapshot(unsigned outputWidth, unsigned outputHeight) const;
bool TryGetRenderStateSnapshot(unsigned outputWidth, unsigned outputHeight, RuntimeRenderStateSnapshot& snapshot) const; bool TryGetRenderStateSnapshot(unsigned outputWidth, unsigned outputHeight, RuntimeRenderStateSnapshot& snapshot) const;
bool TryRefreshSnapshotParameters(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; void RefreshDynamicRenderStateFields(std::vector<RuntimeRenderState>& states) const;
uint64_t GetRenderStateVersion() const;
uint64_t GetParameterStateVersion() const;
private: private:
void BuildLayerRenderStatesLocked(unsigned outputWidth, unsigned outputHeight, std::vector<RuntimeRenderState>& states) const; void BuildLayerRenderStatesLocked(unsigned outputWidth, unsigned outputHeight, std::vector<RuntimeRenderState>& states) const;