reload no longer can disrupt the renderer
This commit is contained in:
@@ -47,7 +47,7 @@ private:
|
||||
void RequestRuntimeStatePersistence();
|
||||
void RequestRuntimeStatePersistenceLocked();
|
||||
std::filesystem::path ResolveRuntimeStatePath() const;
|
||||
void StartLayerShaderBuild(const std::string& layerId, const std::string& shaderId);
|
||||
void StartLayerShaderBuild(const std::string& layerId, const std::string& shaderId, bool preserveExistingRenderArtifact = false);
|
||||
void RetireLayerShaderBuild(const std::string& layerId);
|
||||
void CleanupRetiredShaderBuilds();
|
||||
void StopAllRuntimeShaderBuilds();
|
||||
|
||||
@@ -107,7 +107,7 @@ void RuntimeLayerController::RequestRuntimeStatePersistenceLocked()
|
||||
mPersistenceWriter.RequestSave(mRuntimeLayerModel.Snapshot());
|
||||
}
|
||||
|
||||
void RuntimeLayerController::StartLayerShaderBuild(const std::string& layerId, const std::string& shaderId)
|
||||
void RuntimeLayerController::StartLayerShaderBuild(const std::string& layerId, const std::string& shaderId, bool preserveExistingRenderArtifact)
|
||||
{
|
||||
CleanupRetiredShaderBuilds();
|
||||
RetireLayerShaderBuild(layerId);
|
||||
@@ -115,7 +115,7 @@ void RuntimeLayerController::StartLayerShaderBuild(const std::string& layerId, c
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mRuntimeLayerMutex);
|
||||
std::string error;
|
||||
mRuntimeLayerModel.MarkBuildStarted(layerId, "Runtime Slang build started for shader '" + shaderId + "'.", error);
|
||||
mRuntimeLayerModel.MarkBuildStarted(layerId, "Runtime Slang build started for shader '" + shaderId + "'.", error, preserveExistingRenderArtifact);
|
||||
}
|
||||
|
||||
auto bridge = std::make_unique<RuntimeShaderBridge>();
|
||||
|
||||
@@ -154,9 +154,8 @@ ControlActionResult RuntimeLayerController::HandleControlCommand(const RuntimeCo
|
||||
for (const auto& build : buildsToStart)
|
||||
{
|
||||
Log("runtime-shader", "Reload queued shader rebuild: " + build.first + " shader=" + build.second);
|
||||
StartLayerShaderBuild(build.first, build.second);
|
||||
StartLayerShaderBuild(build.first, build.second, true);
|
||||
}
|
||||
PublishRuntimeRenderLayers();
|
||||
return { true, std::string() };
|
||||
}
|
||||
case RuntimeControlCommandType::Unsupported:
|
||||
|
||||
@@ -402,12 +402,6 @@ bool RuntimeLayerModel::ReloadFromCatalog(const SupportedShaderCatalog& shaderCa
|
||||
layer.packageFingerprint = nextFingerprint;
|
||||
layer.parameterDefinitions = shaderPackage->parameters;
|
||||
layer.parameterValues = std::move(nextValues);
|
||||
if (layer.renderReady)
|
||||
{
|
||||
layer.artifact.parameterValues = layer.parameterValues;
|
||||
std::string prepareError;
|
||||
PrepareRuntimeTextTextures(layer.artifact, prepareError);
|
||||
}
|
||||
buildsToStart.push_back({ layer.id, layer.shaderId });
|
||||
}
|
||||
|
||||
@@ -420,7 +414,7 @@ void RuntimeLayerModel::Clear()
|
||||
mLayers.clear();
|
||||
}
|
||||
|
||||
bool RuntimeLayerModel::MarkBuildStarted(const std::string& layerId, const std::string& message, std::string& error)
|
||||
bool RuntimeLayerModel::MarkBuildStarted(const std::string& layerId, const std::string& message, std::string& error, bool preserveExistingRenderArtifact)
|
||||
{
|
||||
Layer* layer = FindLayer(layerId);
|
||||
if (!layer)
|
||||
@@ -431,8 +425,12 @@ bool RuntimeLayerModel::MarkBuildStarted(const std::string& layerId, const std::
|
||||
|
||||
layer->buildState = RuntimeLayerBuildState::Pending;
|
||||
layer->message = message;
|
||||
layer->renderReady = false;
|
||||
layer->artifact = RuntimeShaderArtifact();
|
||||
layer->preserveRenderDuringBuild = preserveExistingRenderArtifact && layer->renderReady;
|
||||
if (!layer->preserveRenderDuringBuild)
|
||||
{
|
||||
layer->renderReady = false;
|
||||
layer->artifact = RuntimeShaderArtifact();
|
||||
}
|
||||
error.clear();
|
||||
return true;
|
||||
}
|
||||
@@ -448,21 +446,28 @@ bool RuntimeLayerModel::MarkBuildReady(const RuntimeShaderArtifact& artifact, st
|
||||
return false;
|
||||
}
|
||||
|
||||
RuntimeShaderArtifact nextArtifact = artifact;
|
||||
nextArtifact.parameterValues = layer->parameterValues;
|
||||
if (!PrepareRuntimeTextTextures(nextArtifact, error))
|
||||
{
|
||||
layer->buildState = RuntimeLayerBuildState::Failed;
|
||||
layer->message = error;
|
||||
if (!layer->preserveRenderDuringBuild)
|
||||
{
|
||||
layer->renderReady = false;
|
||||
layer->artifact = RuntimeShaderArtifact();
|
||||
}
|
||||
layer->preserveRenderDuringBuild = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
layer->shaderName = artifact.displayName.empty() ? artifact.shaderId : artifact.displayName;
|
||||
layer->packageFingerprint = artifact.packageFingerprint;
|
||||
layer->buildState = RuntimeLayerBuildState::Ready;
|
||||
layer->message = artifact.message;
|
||||
layer->renderReady = true;
|
||||
layer->artifact = artifact;
|
||||
layer->artifact.parameterValues = layer->parameterValues;
|
||||
if (!PrepareRuntimeTextTextures(layer->artifact, error))
|
||||
{
|
||||
layer->buildState = RuntimeLayerBuildState::Failed;
|
||||
layer->message = error;
|
||||
layer->renderReady = false;
|
||||
layer->artifact = RuntimeShaderArtifact();
|
||||
return false;
|
||||
}
|
||||
layer->preserveRenderDuringBuild = false;
|
||||
layer->artifact = std::move(nextArtifact);
|
||||
error.clear();
|
||||
return true;
|
||||
}
|
||||
@@ -488,8 +493,12 @@ bool RuntimeLayerModel::MarkBuildFailed(const std::string& layerId, const std::s
|
||||
|
||||
layer->buildState = RuntimeLayerBuildState::Failed;
|
||||
layer->message = message;
|
||||
layer->renderReady = false;
|
||||
layer->artifact = RuntimeShaderArtifact();
|
||||
if (!layer->preserveRenderDuringBuild)
|
||||
{
|
||||
layer->renderReady = false;
|
||||
layer->artifact = RuntimeShaderArtifact();
|
||||
}
|
||||
layer->preserveRenderDuringBuild = false;
|
||||
error.clear();
|
||||
return true;
|
||||
}
|
||||
@@ -515,10 +524,11 @@ RuntimeLayerModelSnapshot RuntimeLayerModel::Snapshot() const
|
||||
{
|
||||
RuntimeRenderLayerModel renderLayer;
|
||||
renderLayer.id = layer.id;
|
||||
renderLayer.shaderId = layer.shaderId;
|
||||
renderLayer.bypass = layer.bypass;
|
||||
renderLayer.artifact = layer.artifact;
|
||||
renderLayer.artifact.parameterValues = layer.parameterValues;
|
||||
renderLayer.shaderId = renderLayer.artifact.shaderId.empty() ? layer.shaderId : renderLayer.artifact.shaderId;
|
||||
if (layer.buildState == RuntimeLayerBuildState::Ready)
|
||||
renderLayer.artifact.parameterValues = layer.parameterValues;
|
||||
renderLayer.artifact.fontAtlases.clear();
|
||||
snapshot.renderLayers.push_back(std::move(renderLayer));
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
bool UpdateParameter(const std::string& layerId, const std::string& parameterId, const JsonValue& value, std::string& error);
|
||||
bool ResetParameters(const std::string& layerId, std::string& error);
|
||||
bool ReloadFromCatalog(const SupportedShaderCatalog& shaderCatalog, std::vector<std::pair<std::string, std::string>>& buildsToStart, std::string& error);
|
||||
bool MarkBuildStarted(const std::string& layerId, const std::string& message, std::string& error);
|
||||
bool MarkBuildStarted(const std::string& layerId, const std::string& message, std::string& error, bool preserveExistingRenderArtifact = false);
|
||||
bool MarkBuildReady(const RuntimeShaderArtifact& artifact, std::string& error);
|
||||
bool MarkBuildFailedForShader(const std::string& shaderId, const std::string& message);
|
||||
bool MarkBuildFailed(const std::string& layerId, const std::string& message, std::string& error);
|
||||
@@ -85,6 +85,7 @@ private:
|
||||
RuntimeLayerBuildState buildState = RuntimeLayerBuildState::Pending;
|
||||
std::string message;
|
||||
bool renderReady = false;
|
||||
bool preserveRenderDuringBuild = false;
|
||||
std::vector<ShaderParameterDefinition> parameterDefinitions;
|
||||
std::map<std::string, ShaderParameterValue> parameterValues;
|
||||
RuntimeShaderArtifact artifact;
|
||||
|
||||
Reference in New Issue
Block a user