end point adjsutments
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include "AppConfigProvider.h"
|
||||
#include "../logging/Logger.h"
|
||||
#include "../runtime/RuntimeShaderBridge.h"
|
||||
#include "../runtime/SupportedShaderCatalog.h"
|
||||
#include "../control/RuntimeStateJson.h"
|
||||
#include "../telemetry/TelemetryHealthMonitor.h"
|
||||
#include "../video/DeckLinkOutput.h"
|
||||
@@ -11,6 +12,7 @@
|
||||
|
||||
#include <chrono>
|
||||
#include <filesystem>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <type_traits>
|
||||
@@ -68,6 +70,8 @@ public:
|
||||
|
||||
bool Start(std::string& error)
|
||||
{
|
||||
LoadSupportedShaderCatalog();
|
||||
|
||||
Log("app", "Starting render thread.");
|
||||
if (!detail::StartRenderThread(mRenderThread, error, 0))
|
||||
{
|
||||
@@ -187,12 +191,17 @@ private:
|
||||
std::string BuildStateJson()
|
||||
{
|
||||
CadenceTelemetrySnapshot telemetry = mHttpTelemetry.Sample(mFrameExchange, mOutput, mOutputThread, mRenderThread);
|
||||
RuntimeDisplayState runtimeState = CopyRuntimeDisplayState(telemetry);
|
||||
return RuntimeStateToJson(RuntimeStateJsonInput{
|
||||
mConfig,
|
||||
telemetry,
|
||||
mHttpServer.Port(),
|
||||
mVideoOutputEnabled,
|
||||
mVideoOutputStatus
|
||||
mVideoOutputStatus,
|
||||
mShaderCatalog.Shaders(),
|
||||
runtimeState.compileSucceeded,
|
||||
runtimeState.compileMessage,
|
||||
runtimeState.activeShaderPackage
|
||||
});
|
||||
}
|
||||
|
||||
@@ -217,21 +226,69 @@ private:
|
||||
}
|
||||
|
||||
Log("runtime-shader", "Starting background Slang build for shader '" + mConfig.runtimeShaderId + "'.");
|
||||
SetRuntimeDisplayState(true, "Runtime Slang build started for shader '" + mConfig.runtimeShaderId + "'.", mConfig.runtimeShaderId);
|
||||
mShaderBridge.Start(
|
||||
mConfig.runtimeShaderId,
|
||||
[this](const RuntimeShaderArtifact& artifact) {
|
||||
SetRuntimeDisplayState(true, artifact.message.empty() ? "Runtime shader artifact is ready." : artifact.message, artifact.shaderId);
|
||||
mRenderThread.SubmitRuntimeShaderArtifact(artifact);
|
||||
},
|
||||
[](const std::string& message) {
|
||||
[this](const std::string& message) {
|
||||
SetRuntimeDisplayState(false, message);
|
||||
LogError("runtime-shader", "Runtime Slang build failed: " + message);
|
||||
});
|
||||
}
|
||||
|
||||
void LoadSupportedShaderCatalog()
|
||||
{
|
||||
const std::filesystem::path shaderRoot = FindRepoPath(mConfig.shaderLibrary);
|
||||
std::string error;
|
||||
if (!mShaderCatalog.Load(shaderRoot, static_cast<unsigned>(mConfig.maxTemporalHistoryFrames), error))
|
||||
{
|
||||
LogWarning("runtime-shader", "Supported shader catalog is empty: " + error);
|
||||
return;
|
||||
}
|
||||
|
||||
Log("runtime-shader", "Supported shader catalog loaded with " + std::to_string(mShaderCatalog.Shaders().size()) + " shader(s).");
|
||||
}
|
||||
|
||||
void StopRuntimeShaderBuild()
|
||||
{
|
||||
mShaderBridge.Stop();
|
||||
}
|
||||
|
||||
struct RuntimeDisplayState
|
||||
{
|
||||
bool compileSucceeded = true;
|
||||
std::string compileMessage;
|
||||
const ShaderPackage* activeShaderPackage = nullptr;
|
||||
};
|
||||
|
||||
void SetRuntimeDisplayState(bool compileSucceeded, const std::string& compileMessage, const std::string& activeShaderId = std::string())
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mRuntimeDisplayMutex);
|
||||
mRuntimeCompileSucceeded = compileSucceeded;
|
||||
mRuntimeCompileMessage = compileMessage;
|
||||
if (!activeShaderId.empty())
|
||||
mActiveShaderId = activeShaderId;
|
||||
}
|
||||
|
||||
RuntimeDisplayState CopyRuntimeDisplayState(const CadenceTelemetrySnapshot& telemetry) const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mRuntimeDisplayMutex);
|
||||
RuntimeDisplayState state;
|
||||
state.compileSucceeded = mRuntimeCompileSucceeded && telemetry.shaderBuildFailures == 0;
|
||||
state.compileMessage = mRuntimeCompileMessage;
|
||||
if (telemetry.shaderBuildFailures > 0)
|
||||
state.compileMessage = "Runtime shader GL commit failed; see logs for details.";
|
||||
if (state.compileMessage.empty())
|
||||
state.compileMessage = mConfig.runtimeShaderId.empty()
|
||||
? "Runtime shader build disabled."
|
||||
: "Runtime shader build has not completed yet.";
|
||||
state.activeShaderPackage = mShaderCatalog.FindPackage(mActiveShaderId);
|
||||
return state;
|
||||
}
|
||||
|
||||
RenderThread& mRenderThread;
|
||||
SystemFrameExchange& mFrameExchange;
|
||||
AppConfig mConfig;
|
||||
@@ -241,6 +298,11 @@ private:
|
||||
CadenceTelemetry mHttpTelemetry;
|
||||
HttpControlServer mHttpServer;
|
||||
RuntimeShaderBridge mShaderBridge;
|
||||
SupportedShaderCatalog mShaderCatalog;
|
||||
mutable std::mutex mRuntimeDisplayMutex;
|
||||
bool mRuntimeCompileSucceeded = true;
|
||||
std::string mRuntimeCompileMessage;
|
||||
std::string mActiveShaderId;
|
||||
bool mStarted = false;
|
||||
bool mVideoOutputEnabled = false;
|
||||
std::string mVideoOutputStatus = "DeckLink output not started.";
|
||||
|
||||
Reference in New Issue
Block a user