Clean up
This commit is contained in:
92
src/app/RuntimeLayerController.cpp
Normal file
92
src/app/RuntimeLayerController.cpp
Normal file
@@ -0,0 +1,92 @@
|
||||
#include "RuntimeLayerController.h"
|
||||
|
||||
#include "../logging/Logger.h"
|
||||
|
||||
namespace RenderCadenceCompositor
|
||||
{
|
||||
RuntimeLayerController::RuntimeLayerController(RenderLayerPublisher publisher) :
|
||||
mPublisher(std::move(publisher))
|
||||
{
|
||||
}
|
||||
|
||||
RuntimeLayerController::~RuntimeLayerController()
|
||||
{
|
||||
Stop();
|
||||
}
|
||||
|
||||
void RuntimeLayerController::SetPublisher(RenderLayerPublisher publisher)
|
||||
{
|
||||
mPublisher = std::move(publisher);
|
||||
}
|
||||
|
||||
void RuntimeLayerController::Initialize(const std::string& shaderLibrary, unsigned maxTemporalHistoryFrames, std::string& runtimeShaderId)
|
||||
{
|
||||
LoadSupportedShaderCatalog(shaderLibrary, maxTemporalHistoryFrames);
|
||||
InitializeLayerModel(runtimeShaderId);
|
||||
}
|
||||
|
||||
void RuntimeLayerController::StartStartupBuild(const std::string& runtimeShaderId)
|
||||
{
|
||||
if (runtimeShaderId.empty())
|
||||
{
|
||||
Log("runtime-shader", "Runtime shader build disabled.");
|
||||
return;
|
||||
}
|
||||
|
||||
Log("runtime-shader", "Starting background Slang build for shader '" + runtimeShaderId + "'.");
|
||||
const std::string layerId = FirstRuntimeLayerId();
|
||||
if (!layerId.empty())
|
||||
StartLayerShaderBuild(layerId, runtimeShaderId);
|
||||
}
|
||||
|
||||
void RuntimeLayerController::Stop()
|
||||
{
|
||||
StopAllRuntimeShaderBuilds();
|
||||
}
|
||||
|
||||
RuntimeLayerModelSnapshot RuntimeLayerController::Snapshot(const CadenceTelemetrySnapshot& telemetry) const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mRuntimeLayerMutex);
|
||||
RuntimeLayerModelSnapshot snapshot = mRuntimeLayerModel.Snapshot();
|
||||
if (telemetry.shaderBuildFailures > 0)
|
||||
{
|
||||
snapshot.compileSucceeded = false;
|
||||
snapshot.compileMessage = "Runtime shader GL commit failed; see logs for details.";
|
||||
}
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
void RuntimeLayerController::PublishRuntimeRenderLayers()
|
||||
{
|
||||
if (!mPublisher)
|
||||
return;
|
||||
|
||||
std::vector<RuntimeRenderLayerModel> renderLayers;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mRuntimeLayerMutex);
|
||||
renderLayers = mRuntimeLayerModel.Snapshot().renderLayers;
|
||||
}
|
||||
mPublisher(renderLayers);
|
||||
}
|
||||
|
||||
bool RuntimeLayerController::MarkRuntimeBuildReady(const RuntimeShaderArtifact& artifact)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mRuntimeLayerMutex);
|
||||
std::string error;
|
||||
if (!mRuntimeLayerModel.MarkBuildReady(artifact, error))
|
||||
{
|
||||
LogWarning("runtime-shader", error);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void RuntimeLayerController::MarkRuntimeBuildFailedForLayer(const std::string& layerId, const std::string& message)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mRuntimeLayerMutex);
|
||||
std::string error;
|
||||
if (!mRuntimeLayerModel.MarkBuildFailed(layerId, message, error))
|
||||
LogWarning("runtime-shader", error);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user