reload no longer can disrupt the renderer

This commit is contained in:
2026-05-21 17:30:09 +10:00
parent 5cf1a09e75
commit f9aac85e5f
6 changed files with 118 additions and 29 deletions

View File

@@ -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));
}