Skip to content

Plugin system for engine modules #5

Description

@PrograMistV1

Context

LightExtract is currently hardcoded into ExtractSchedule::default()
(engine-core/src/render/extract/mod.rs), which means it runs even for
pipelines with no scene concept (e.g. LoadingPipeline). See the TODO in
engine-core/src/render/gfx/light_buffer.rs:

DirectionalLightComponent/PointLightComponent, LightExtract,
DirectionalLight/GpuPointLight/ExtractedLights are a concrete lighting
implementation for a single pipeline, not a general core plumbing
abstraction (see README: "engine-core has no opinion about how you
render things"). Move it to engine-pipelines once a plugin/extension
system for ExtractSchedule exists.

This is a general problem, not just a lighting one: any future module
(physics, audio, particles, ...) will hit the same wall - engine-core
would otherwise need a growing list of App::register_x() methods, one
per subsystem.

Goal

Design and implement a plugin system for engine-core, so that modules
(engine-pipelines and future crates) register what they need
(extract systems, tick systems, asset loaders, ...) through one
consistent mechanism, instead of engine-core hardcoding them into
ExtractSchedule::default() / TickSchedule::default() / etc.

Scope

  • Add EnginePlugin trait to engine-core (fn build(&self, app: &mut EngineContext))
  • Add builder methods on EngineContext: add_extract_system,
    add_tick_system, add_plugin, add_plugins
  • Remove LightExtract from ExtractSchedule::default()
  • Add LightingPlugin in engine-pipelines that registers LightExtract
  • Update engine-demo (sponza_scene_demo.rs, interpolation_demo.rs)
    to call ctx.add_plugin(LightingPlugin) in on_start
  • Resolve the light_buffer.rs TODO (remove/update the comment once done)
  • Decide whether register_loaders (currently a separate App method)
    should be folded into the same plugin mechanism, or stay separate

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions