mirror of
https://github.com/Eragon-Brisingr/UShaderLab.git
synced 2026-09-15 14:54:36 +00:00
Fix cook/runtime error
This commit is contained in:
@@ -16,12 +16,14 @@
|
||||
#include "ShaderLabDiscovery.h"
|
||||
#include "ShaderLabGraphBuilder.h"
|
||||
#include "ShaderLabImportResolver.h"
|
||||
#include "ShaderLabMaterialInstanceConstant.h"
|
||||
#include "ShaderLabMaterialRegistry.h"
|
||||
#include "ShaderLabModel.h"
|
||||
#include "ShaderLabParser.h"
|
||||
#include "ShaderLabSubsystem.h"
|
||||
#include "ShaderLabVSCodeButton.h"
|
||||
#include "UObject/Package.h"
|
||||
#include "UObject/UObjectIterator.h"
|
||||
|
||||
DEFINE_LOG_CATEGORY_STATIC(LogShaderLabEditor, Log, All);
|
||||
|
||||
@@ -74,6 +76,29 @@ namespace
|
||||
Material.PostEditChange();
|
||||
}
|
||||
|
||||
// Re-derive the cook-inclusion data (CachedExpressionData copy + profile overrides) on every ROOT
|
||||
// UShaderLabMaterialInstanceConstant of this base. The FMaterialUpdateContext above recompiles the
|
||||
// dependent shader maps but does NOT refresh that derived data (it's built once at PostLoad and pinned by
|
||||
// bLoadedCachedExpressionData=true), so a hot-reload that added/removed an MPC or profile would otherwise
|
||||
// leave a resident MIC stale — and an in-editor iterative cook would serialize the stale references.
|
||||
//
|
||||
// Inheritance chain: only a ROOT (immediate parent == this base) carries the derived data; CHILD instances
|
||||
// (parent is another instance, however deep) hold none and resolve up the chain to the root at query time,
|
||||
// and their shared shader maps were just recompiled by FMaterialUpdateContext — so refreshing the roots is
|
||||
// sufficient and children need no separate pass. RefreshShaderLabDerivedData self-guards via
|
||||
// GetShaderLabRootBase(), so it is a safe no-op on anything that isn't a root of this base. Skip CDOs and
|
||||
// objects being GC'd.
|
||||
for (TObjectIterator<UShaderLabMaterialInstanceConstant> It(
|
||||
/*AdditionalExclusionFlags*/ RF_ClassDefaultObject,
|
||||
/*bIncludeDerivedClasses*/ true,
|
||||
/*InternalExclusionFlags*/ EInternalObjectFlags::Garbage); It; ++It)
|
||||
{
|
||||
if (It->Parent == &Material)
|
||||
{
|
||||
It->RefreshShaderLabDerivedData();
|
||||
}
|
||||
}
|
||||
|
||||
// Refresh any open Material Instance editors built on this base so newly added/removed parameters
|
||||
// (scalars, textures, static-bool switches) appear without reopening the editor. RegenerateArrays
|
||||
// pulls the parameter set from the freshly rebuilt parent; mirrors what the stock material editor
|
||||
|
||||
Reference in New Issue
Block a user