60 lines
2.2 KiB
C++
60 lines
2.2 KiB
C++
#pragma once
|
|
|
|
#include "../control/ControlActionResult.h"
|
|
#include "../runtime/RuntimeLayerModel.h"
|
|
#include "../runtime/RuntimeShaderBridge.h"
|
|
#include "../runtime/SupportedShaderCatalog.h"
|
|
#include "../telemetry/CadenceTelemetry.h"
|
|
|
|
#include <functional>
|
|
#include <map>
|
|
#include <memory>
|
|
#include <mutex>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace RenderCadenceCompositor
|
|
{
|
|
class RuntimeLayerController
|
|
{
|
|
public:
|
|
using RenderLayerPublisher = std::function<void(const std::vector<RuntimeRenderLayerModel>&)>;
|
|
|
|
explicit RuntimeLayerController(RenderLayerPublisher publisher = RenderLayerPublisher());
|
|
RuntimeLayerController(const RuntimeLayerController&) = delete;
|
|
RuntimeLayerController& operator=(const RuntimeLayerController&) = delete;
|
|
~RuntimeLayerController();
|
|
|
|
void SetPublisher(RenderLayerPublisher publisher);
|
|
void Initialize(const std::string& shaderLibrary, unsigned maxTemporalHistoryFrames, std::string& runtimeShaderId);
|
|
void StartStartupBuild(const std::string& runtimeShaderId);
|
|
void Stop();
|
|
|
|
ControlActionResult HandleAddLayer(const std::string& body);
|
|
ControlActionResult HandleRemoveLayer(const std::string& body);
|
|
|
|
RuntimeLayerModelSnapshot Snapshot(const CadenceTelemetrySnapshot& telemetry) const;
|
|
const SupportedShaderCatalog& ShaderCatalog() const { return mShaderCatalog; }
|
|
|
|
private:
|
|
void LoadSupportedShaderCatalog(const std::string& shaderLibrary, unsigned maxTemporalHistoryFrames);
|
|
void InitializeLayerModel(std::string& runtimeShaderId);
|
|
void StartLayerShaderBuild(const std::string& layerId, const std::string& shaderId);
|
|
void StopLayerShaderBuild(const std::string& layerId);
|
|
void StopAllRuntimeShaderBuilds();
|
|
void PublishRuntimeRenderLayers();
|
|
bool MarkRuntimeBuildReady(const RuntimeShaderArtifact& artifact);
|
|
void MarkRuntimeBuildFailedForLayer(const std::string& layerId, const std::string& message);
|
|
|
|
std::string FirstRuntimeLayerId() const;
|
|
static bool ExtractStringField(const std::string& body, const char* fieldName, std::string& value, std::string& error);
|
|
|
|
RenderLayerPublisher mPublisher;
|
|
SupportedShaderCatalog mShaderCatalog;
|
|
mutable std::mutex mRuntimeLayerMutex;
|
|
RuntimeLayerModel mRuntimeLayerModel;
|
|
std::mutex mShaderBuildMutex;
|
|
std::map<std::string, std::unique_ptr<RuntimeShaderBridge>> mShaderBuilds;
|
|
};
|
|
}
|