Tests
All checks were successful
CI / React UI Build (push) Successful in 10s
CI / Native Windows Build And Tests (push) Successful in 2m26s
CI / Windows Release Package (push) Successful in 2m28s

This commit is contained in:
Aiden
2026-05-11 15:59:29 +10:00
parent a9b08f7f27
commit 6e600be112
14 changed files with 550 additions and 57 deletions

View File

@@ -34,12 +34,12 @@ RuntimeCoordinatorResult RuntimeCoordinator::AddLayer(const std::string& shaderI
std::string error;
if (!ValidateShaderExists(shaderId, error))
{
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false);
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false, false);
PublishCoordinatorResult("AddLayer", result);
return result;
}
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.CreateStoredLayer(shaderId, error), error, true, true);
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.CreateStoredLayer(shaderId, error), error, true, true, true);
PublishCoordinatorResult("AddLayer", result);
return result;
}
@@ -50,12 +50,12 @@ RuntimeCoordinatorResult RuntimeCoordinator::RemoveLayer(const std::string& laye
std::string error;
if (!ValidateLayerExists(layerId, error))
{
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false);
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false, false);
PublishCoordinatorResult("RemoveLayer", result);
return result;
}
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.DeleteStoredLayer(layerId, error), error, true, true);
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.DeleteStoredLayer(layerId, error), error, true, true, true);
PublishCoordinatorResult("RemoveLayer", result);
return result;
}
@@ -67,7 +67,7 @@ RuntimeCoordinatorResult RuntimeCoordinator::MoveLayer(const std::string& layerI
bool shouldMove = false;
if (!ResolveLayerMove(layerId, direction, shouldMove, error))
{
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false);
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false, false);
PublishCoordinatorResult("MoveLayer", result);
return result;
}
@@ -77,7 +77,7 @@ RuntimeCoordinatorResult RuntimeCoordinator::MoveLayer(const std::string& layerI
return result;
}
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.MoveStoredLayer(layerId, direction, error), error, true, true);
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.MoveStoredLayer(layerId, direction, error), error, true, true, true);
PublishCoordinatorResult("MoveLayer", result);
return result;
}
@@ -89,7 +89,7 @@ RuntimeCoordinatorResult RuntimeCoordinator::MoveLayerToIndex(const std::string&
bool shouldMove = false;
if (!ResolveLayerMoveToIndex(layerId, targetIndex, shouldMove, error))
{
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false);
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false, false);
PublishCoordinatorResult("MoveLayerToIndex", result);
return result;
}
@@ -99,7 +99,7 @@ RuntimeCoordinatorResult RuntimeCoordinator::MoveLayerToIndex(const std::string&
return result;
}
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.MoveStoredLayerToIndex(layerId, targetIndex, error), error, true, true);
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.MoveStoredLayerToIndex(layerId, targetIndex, error), error, true, true, true);
PublishCoordinatorResult("MoveLayerToIndex", result);
return result;
}
@@ -110,12 +110,12 @@ RuntimeCoordinatorResult RuntimeCoordinator::SetLayerBypass(const std::string& l
std::string error;
if (!ValidateLayerExists(layerId, error))
{
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false);
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false, false);
PublishCoordinatorResult("SetLayerBypass", result);
return result;
}
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.SetStoredLayerBypassState(layerId, bypassed, error), error, true, false);
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.SetStoredLayerBypassState(layerId, bypassed, error), error, true, false, true);
PublishCoordinatorResult("SetLayerBypass", result);
return result;
}
@@ -126,12 +126,12 @@ RuntimeCoordinatorResult RuntimeCoordinator::SetLayerShader(const std::string& l
std::string error;
if (!ValidateLayerExists(layerId, error) || !ValidateShaderExists(shaderId, error))
{
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false);
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false, false);
PublishCoordinatorResult("SetLayerShader", result);
return result;
}
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.SetStoredLayerShaderSelection(layerId, shaderId, error), error, true, false);
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.SetStoredLayerShaderSelection(layerId, shaderId, error), error, true, false, true);
PublishCoordinatorResult("SetLayerShader", result);
return result;
}
@@ -143,12 +143,12 @@ RuntimeCoordinatorResult RuntimeCoordinator::UpdateLayerParameter(const std::str
ResolvedParameterMutation mutation;
if (!BuildParameterMutationById(layerId, parameterId, newValue, true, mutation, error))
{
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false);
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false, false);
PublishCoordinatorResult("UpdateLayerParameter", result);
return result;
}
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.SetStoredParameterValue(mutation.layerId, mutation.parameterId, mutation.value, mutation.persistState, error), error, false, false);
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.SetStoredParameterValue(mutation.layerId, mutation.parameterId, mutation.value, mutation.persistState, error), error, false, false, mutation.persistState);
PublishCoordinatorResult("UpdateLayerParameter", result);
return result;
}
@@ -160,12 +160,12 @@ RuntimeCoordinatorResult RuntimeCoordinator::UpdateLayerParameterByControlKey(co
ResolvedParameterMutation mutation;
if (!BuildParameterMutationByControlKey(layerKey, parameterKey, newValue, true, mutation, error))
{
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false);
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false, false);
PublishCoordinatorResult("UpdateLayerParameterByControlKey", result);
return result;
}
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.SetStoredParameterValue(mutation.layerId, mutation.parameterId, mutation.value, mutation.persistState, error), error, false, false);
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.SetStoredParameterValue(mutation.layerId, mutation.parameterId, mutation.value, mutation.persistState, error), error, false, false, mutation.persistState);
PublishCoordinatorResult("UpdateLayerParameterByControlKey", result);
return result;
}
@@ -177,12 +177,12 @@ RuntimeCoordinatorResult RuntimeCoordinator::CommitOscParameterByControlKey(cons
ResolvedParameterMutation mutation;
if (!BuildParameterMutationByControlKey(layerKey, parameterKey, newValue, false, mutation, error))
{
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false);
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false, false);
PublishCoordinatorResult("CommitOscParameterByControlKey", result);
return result;
}
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.SetStoredParameterValue(mutation.layerId, mutation.parameterId, mutation.value, mutation.persistState, error), error, false, false);
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.SetStoredParameterValue(mutation.layerId, mutation.parameterId, mutation.value, mutation.persistState, error), error, false, false, mutation.persistState);
PublishCoordinatorResult("CommitOscParameterByControlKey", result);
return result;
}
@@ -193,12 +193,12 @@ RuntimeCoordinatorResult RuntimeCoordinator::ResetLayerParameters(const std::str
std::string error;
if (!ValidateLayerExists(layerId, error))
{
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false);
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false, false);
PublishCoordinatorResult("ResetLayerParameters", result);
return result;
}
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.ResetStoredLayerParameterValues(layerId, error), error, false, false);
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.ResetStoredLayerParameterValues(layerId, error), error, false, false, true);
if (!result.accepted)
{
PublishCoordinatorResult("ResetLayerParameters", result);
@@ -217,12 +217,12 @@ RuntimeCoordinatorResult RuntimeCoordinator::SaveStackPreset(const std::string&
std::string error;
if (!ValidatePresetName(presetName, error))
{
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false);
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false, false);
PublishCoordinatorResult("SaveStackPreset", result);
return result;
}
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.SaveStackPresetSnapshot(presetName, error), error, false, false);
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.SaveStackPresetSnapshot(presetName, error), error, false, false, true);
PublishCoordinatorResult("SaveStackPreset", result);
return result;
}
@@ -233,12 +233,12 @@ RuntimeCoordinatorResult RuntimeCoordinator::LoadStackPreset(const std::string&
std::string error;
if (!ValidatePresetName(presetName, error))
{
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false);
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false, false);
PublishCoordinatorResult("LoadStackPreset", result);
return result;
}
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.LoadStackPresetSnapshot(presetName, error), error, true, false);
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.LoadStackPresetSnapshot(presetName, error), error, true, false, true);
PublishCoordinatorResult("LoadStackPreset", result);
return result;
}
@@ -446,7 +446,7 @@ bool RuntimeCoordinator::ValidatePresetName(const std::string& presetName, std::
return false;
}
RuntimeCoordinatorResult RuntimeCoordinator::ApplyStoreMutation(bool succeeded, const std::string& errorMessage, bool reloadRequired, bool preserveFeedbackState)
RuntimeCoordinatorResult RuntimeCoordinator::ApplyStoreMutation(bool succeeded, const std::string& errorMessage, bool reloadRequired, bool preserveFeedbackState, bool persistenceRequested)
{
if (!succeeded)
{
@@ -457,9 +457,15 @@ RuntimeCoordinatorResult RuntimeCoordinator::ApplyStoreMutation(bool succeeded,
}
if (reloadRequired)
return BuildQueuedReloadResult(preserveFeedbackState);
{
RuntimeCoordinatorResult result = BuildQueuedReloadResult(preserveFeedbackState);
result.persistenceRequested = persistenceRequested;
return result;
}
return BuildAcceptedNoReloadResult();
RuntimeCoordinatorResult result = BuildAcceptedNoReloadResult();
result.persistenceRequested = persistenceRequested;
return result;
}
RuntimeCoordinatorResult RuntimeCoordinator::BuildQueuedReloadResult(bool preserveFeedbackState)
@@ -497,6 +503,7 @@ void RuntimeCoordinator::PublishCoordinatorResult(const std::string& action, con
mutation.runtimeStateChanged = result.accepted && result.runtimeStateBroadcastRequired;
mutation.runtimeStateBroadcastRequired = result.runtimeStateBroadcastRequired;
mutation.shaderBuildRequested = result.shaderBuildRequested;
mutation.persistenceRequested = result.persistenceRequested;
mutation.clearTransientOscState = result.clearTransientOscState;
mutation.renderResetScope = ToRuntimeEventRenderResetScope(result.renderResetScope);
mutation.errorMessage = result.errorMessage;
@@ -521,9 +528,18 @@ void RuntimeCoordinator::PublishCoordinatorFollowUpEvents(const std::string& act
RuntimeStateChangedEvent stateChanged;
stateChanged.reason = action;
stateChanged.renderVisible = result.renderResetScope != RuntimeCoordinatorRenderResetScope::None;
stateChanged.persistenceRequested = result.persistenceRequested;
mRuntimeEventDispatcher.PublishPayload(stateChanged, "RuntimeCoordinator");
}
if (result.persistenceRequested)
{
RuntimePersistenceRequestedEvent persistenceRequested;
persistenceRequested.reason = action;
persistenceRequested.debounceAllowed = true;
mRuntimeEventDispatcher.PublishPayload(persistenceRequested, "RuntimeCoordinator");
}
if (result.shaderBuildRequested)
{
RuntimeReloadRequestedEvent reloadRequested;

View File

@@ -30,6 +30,7 @@ struct RuntimeCoordinatorResult
bool accepted = false;
bool runtimeStateBroadcastRequired = false;
bool shaderBuildRequested = false;
bool persistenceRequested = false;
bool clearTransientOscState = false;
bool compileStatusChanged = false;
bool compileStatusSucceeded = false;
@@ -89,7 +90,7 @@ private:
bool ResolveLayerMove(const std::string& layerId, int direction, bool& shouldMove, std::string& error) const;
bool ResolveLayerMoveToIndex(const std::string& layerId, std::size_t targetIndex, bool& shouldMove, std::string& error) const;
bool ValidatePresetName(const std::string& presetName, std::string& error) const;
RuntimeCoordinatorResult ApplyStoreMutation(bool succeeded, const std::string& errorMessage, bool reloadRequired, bool preserveFeedbackState);
RuntimeCoordinatorResult ApplyStoreMutation(bool succeeded, const std::string& errorMessage, bool reloadRequired, bool preserveFeedbackState, bool persistenceRequested);
RuntimeCoordinatorResult BuildQueuedReloadResult(bool preserveFeedbackState);
RuntimeCoordinatorResult BuildAcceptedNoReloadResult() const;
void PublishCoordinatorResult(const std::string& action, const RuntimeCoordinatorResult& result) const;

View File

@@ -406,8 +406,12 @@ constexpr RuntimeEventType RuntimeEventPayloadType(const OutputFrameScheduledEve
return RuntimeEventType::OutputFrameScheduled;
}
constexpr RuntimeEventType RuntimeEventPayloadType(const OutputFrameCompletedEvent&)
inline RuntimeEventType RuntimeEventPayloadType(const OutputFrameCompletedEvent& event)
{
if (event.result == "DisplayedLate")
return RuntimeEventType::OutputLateFrameDetected;
if (event.result == "Dropped")
return RuntimeEventType::OutputDroppedFrameDetected;
return RuntimeEventType::OutputFrameCompleted;
}

View File

@@ -1,9 +1,14 @@
#include "RuntimeSnapshotProvider.h"
#include "RuntimeEventDispatcher.h"
#include <windows.h>
#include <utility>
RuntimeSnapshotProvider::RuntimeSnapshotProvider(RenderSnapshotBuilder& renderSnapshotBuilder) :
mRenderSnapshotBuilder(renderSnapshotBuilder)
RuntimeSnapshotProvider::RuntimeSnapshotProvider(RenderSnapshotBuilder& renderSnapshotBuilder, RuntimeEventDispatcher& runtimeEventDispatcher) :
mRenderSnapshotBuilder(renderSnapshotBuilder),
mRuntimeEventDispatcher(runtimeEventDispatcher)
{
}
@@ -42,12 +47,17 @@ void RuntimeSnapshotProvider::AdvanceFrame()
RuntimeRenderStateSnapshot RuntimeSnapshotProvider::PublishRenderStateSnapshot(unsigned outputWidth, unsigned outputHeight) const
{
PublishRenderSnapshotPublishRequested(outputWidth, outputHeight, "publish-render-state-snapshot");
for (;;)
{
const RuntimeSnapshotVersions versionsBefore = GetVersions();
RuntimeRenderStateSnapshot publishedSnapshot;
if (TryGetPublishedRenderStateSnapshot(outputWidth, outputHeight, versionsBefore, publishedSnapshot))
{
PublishRenderSnapshotPublished(publishedSnapshot);
return publishedSnapshot;
}
RuntimeRenderStateSnapshot snapshot;
snapshot.outputWidth = outputWidth;
@@ -60,6 +70,7 @@ RuntimeRenderStateSnapshot RuntimeSnapshotProvider::PublishRenderStateSnapshot(u
{
snapshot.versions = versionsAfter;
StorePublishedRenderStateSnapshot(snapshot);
PublishRenderSnapshotPublished(snapshot);
return snapshot;
}
}
@@ -67,9 +78,14 @@ RuntimeRenderStateSnapshot RuntimeSnapshotProvider::PublishRenderStateSnapshot(u
bool RuntimeSnapshotProvider::TryPublishRenderStateSnapshot(unsigned outputWidth, unsigned outputHeight, RuntimeRenderStateSnapshot& snapshot) const
{
PublishRenderSnapshotPublishRequested(outputWidth, outputHeight, "try-publish-render-state-snapshot");
const RuntimeSnapshotVersions versionsBefore = GetVersions();
if (TryGetPublishedRenderStateSnapshot(outputWidth, outputHeight, versionsBefore, snapshot))
{
PublishRenderSnapshotPublished(snapshot);
return true;
}
std::vector<RuntimeRenderState> states;
if (!mRenderSnapshotBuilder.TryBuildLayerRenderStates(outputWidth, outputHeight, states))
@@ -87,6 +103,7 @@ bool RuntimeSnapshotProvider::TryPublishRenderStateSnapshot(unsigned outputWidth
snapshot.versions = versionsAfter;
snapshot.states = std::move(states);
StorePublishedRenderStateSnapshot(snapshot);
PublishRenderSnapshotPublished(snapshot);
return true;
}
@@ -102,6 +119,7 @@ bool RuntimeSnapshotProvider::TryRefreshPublishedSnapshotParameters(RuntimeRende
snapshot.versions = versions;
StorePublishedRenderStateSnapshot(snapshot);
PublishRenderSnapshotPublished(snapshot);
return true;
}
@@ -139,3 +157,40 @@ bool RuntimeSnapshotProvider::SnapshotMatches(const RuntimeRenderStateSnapshot&
snapshot.versions.renderStateVersion == versions.renderStateVersion &&
snapshot.versions.parameterStateVersion == versions.parameterStateVersion;
}
void RuntimeSnapshotProvider::PublishRenderSnapshotPublishRequested(unsigned outputWidth, unsigned outputHeight, const std::string& reason) const
{
try
{
RenderSnapshotPublishRequestedEvent event;
event.outputWidth = outputWidth;
event.outputHeight = outputHeight;
event.reason = reason;
if (!mRuntimeEventDispatcher.PublishPayload(event, "RuntimeSnapshotProvider"))
OutputDebugStringA("RenderSnapshotPublishRequested event publish failed.\n");
}
catch (...)
{
OutputDebugStringA("RenderSnapshotPublishRequested event publish threw.\n");
}
}
void RuntimeSnapshotProvider::PublishRenderSnapshotPublished(const RuntimeRenderStateSnapshot& snapshot) const
{
try
{
RenderSnapshotPublishedEvent event;
event.snapshotVersion = snapshot.versions.renderStateVersion;
event.structureVersion = snapshot.versions.renderStateVersion;
event.parameterVersion = snapshot.versions.parameterStateVersion;
event.outputWidth = snapshot.outputWidth;
event.outputHeight = snapshot.outputHeight;
event.layerCount = snapshot.states.size();
if (!mRuntimeEventDispatcher.PublishPayload(event, "RuntimeSnapshotProvider"))
OutputDebugStringA("RenderSnapshotPublished event publish failed.\n");
}
catch (...)
{
OutputDebugStringA("RenderSnapshotPublished event publish threw.\n");
}
}

View File

@@ -6,6 +6,8 @@
#include <string>
#include <vector>
class RuntimeEventDispatcher;
struct RuntimeRenderStateSnapshot
{
RuntimeSnapshotVersions versions;
@@ -17,7 +19,7 @@ struct RuntimeRenderStateSnapshot
class RuntimeSnapshotProvider
{
public:
explicit RuntimeSnapshotProvider(RenderSnapshotBuilder& renderSnapshotBuilder);
RuntimeSnapshotProvider(RenderSnapshotBuilder& renderSnapshotBuilder, RuntimeEventDispatcher& runtimeEventDispatcher);
bool BuildLayerPassFragmentShaderSources(const std::string& layerId, std::vector<ShaderPassBuildSource>& passSources, std::string& error) const;
unsigned GetMaxTemporalHistoryFrames() const;
@@ -34,8 +36,11 @@ private:
void StorePublishedRenderStateSnapshot(const RuntimeRenderStateSnapshot& snapshot) const;
static bool SnapshotMatches(const RuntimeRenderStateSnapshot& snapshot, unsigned outputWidth, unsigned outputHeight,
const RuntimeSnapshotVersions& versions);
void PublishRenderSnapshotPublishRequested(unsigned outputWidth, unsigned outputHeight, const std::string& reason) const;
void PublishRenderSnapshotPublished(const RuntimeRenderStateSnapshot& snapshot) const;
RenderSnapshotBuilder& mRenderSnapshotBuilder;
RuntimeEventDispatcher& mRuntimeEventDispatcher;
mutable std::mutex mPublishedSnapshotMutex;
mutable bool mHasPublishedRenderStateSnapshot = false;
mutable RuntimeRenderStateSnapshot mPublishedRenderStateSnapshot;