75 lines
2.9 KiB
C++
75 lines
2.9 KiB
C++
#pragma once
|
|
|
|
#include "RuntimeJson.h"
|
|
|
|
#include <atomic>
|
|
#include <cstddef>
|
|
#include <string>
|
|
|
|
class RuntimeStore;
|
|
|
|
enum class RuntimeCoordinatorCommittedStateMode
|
|
{
|
|
Unchanged,
|
|
UseCommittedStates,
|
|
UseLiveSnapshots
|
|
};
|
|
|
|
enum class RuntimeCoordinatorRenderResetScope
|
|
{
|
|
None,
|
|
TemporalHistoryOnly,
|
|
TemporalHistoryAndFeedback
|
|
};
|
|
|
|
struct RuntimeCoordinatorResult
|
|
{
|
|
bool accepted = false;
|
|
bool runtimeStateBroadcastRequired = false;
|
|
bool shaderBuildRequested = false;
|
|
bool clearTransientOscState = false;
|
|
bool compileStatusChanged = false;
|
|
bool compileStatusSucceeded = false;
|
|
bool clearReloadRequest = false;
|
|
RuntimeCoordinatorCommittedStateMode committedStateMode = RuntimeCoordinatorCommittedStateMode::Unchanged;
|
|
RuntimeCoordinatorRenderResetScope renderResetScope = RuntimeCoordinatorRenderResetScope::None;
|
|
std::string compileStatusMessage;
|
|
std::string errorMessage;
|
|
};
|
|
|
|
class RuntimeCoordinator
|
|
{
|
|
public:
|
|
explicit RuntimeCoordinator(RuntimeStore& runtimeStore);
|
|
|
|
RuntimeCoordinatorResult AddLayer(const std::string& shaderId);
|
|
RuntimeCoordinatorResult RemoveLayer(const std::string& layerId);
|
|
RuntimeCoordinatorResult MoveLayer(const std::string& layerId, int direction);
|
|
RuntimeCoordinatorResult MoveLayerToIndex(const std::string& layerId, std::size_t targetIndex);
|
|
RuntimeCoordinatorResult SetLayerBypass(const std::string& layerId, bool bypassed);
|
|
RuntimeCoordinatorResult SetLayerShader(const std::string& layerId, const std::string& shaderId);
|
|
RuntimeCoordinatorResult UpdateLayerParameter(const std::string& layerId, const std::string& parameterId, const JsonValue& newValue);
|
|
RuntimeCoordinatorResult UpdateLayerParameterByControlKey(const std::string& layerKey, const std::string& parameterKey, const JsonValue& newValue);
|
|
RuntimeCoordinatorResult ResetLayerParameters(const std::string& layerId);
|
|
RuntimeCoordinatorResult SaveStackPreset(const std::string& presetName);
|
|
RuntimeCoordinatorResult LoadStackPreset(const std::string& presetName);
|
|
|
|
RuntimeCoordinatorResult RequestShaderReload(bool preserveFeedbackState = false);
|
|
RuntimeCoordinatorResult HandleRuntimePollFailure(const std::string& error);
|
|
RuntimeCoordinatorResult HandlePreparedShaderBuildFailure(const std::string& error);
|
|
RuntimeCoordinatorResult HandlePreparedShaderBuildSuccess();
|
|
RuntimeCoordinatorResult HandleRuntimeReloadRequest();
|
|
void ApplyCommittedStateMode(RuntimeCoordinatorCommittedStateMode mode);
|
|
bool UseCommittedLayerStates() const;
|
|
bool PreserveFeedbackOnNextShaderBuild() const;
|
|
|
|
private:
|
|
RuntimeCoordinatorResult ApplyStoreMutation(bool succeeded, const std::string& errorMessage, bool reloadRequired, bool preserveFeedbackState);
|
|
RuntimeCoordinatorResult BuildQueuedReloadResult(bool preserveFeedbackState);
|
|
RuntimeCoordinatorResult BuildAcceptedNoReloadResult() const;
|
|
|
|
RuntimeStore& mRuntimeStore;
|
|
bool mPreserveFeedbackOnNextShaderBuild = false;
|
|
std::atomic<bool> mUseCommittedLayerStates{ false };
|
|
};
|