Skip to content

Effect keys: register and unregister per assembly (assembly reload, plugin unload) #3735

Open

Description

@xen2

Since #3584, parameter keys are named by source generators (EffectKeysGenerator for hand-written key classes, the shader generator for sdsl/sdfx keys). Both emit a module initializer that calls ParameterKeys.Merge for each key.

ParameterKeys keeps one global table (keyByNames, keys, the composed key cache) that nothing ever clears. Effects work the same way: ShaderMixinManager.Register per effect, and only UnRegisterAll.

So when the editor reloads game assemblies (ReloadAssembliesOperation, and its undo/redo) or a plugin is unloaded, the keys and effect builders of the old assembly stay registered. They stay reachable by name, and they keep the old assembly alive, which blocks unloading a collectible load context.

Proposal, same shape as DataSerializerFactory:

  • The generators output a list of the assembly's keys (and effect builders) instead of calling Merge.
  • ParameterKeys and ShaderMixinManager get RegisterAssembly(Assembly) / UnregisterAssembly(Assembly).
  • Hosts call them where they already call DataSerializerFactory.Register/UnregisterSerializationAssembly (PackageSession, ReloadAssembliesOperation, UnloadAssembliesOperation, LiveAssemblyReloader).
  • Games keep registering at module init, so user code doesn't change.

Open questions:

  • Composed and indexed keys made from an unloaded key (ComposeWith, IndexedKey): drop them too?
  • ParameterCollections that still hold old keys after a reload.

Activity

  1. added
    area-Plugins
    enhancement
    on Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-Pluginsarea-Shadersenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions