Class GlobalParamsRegistry

java.lang.Object
dev.engine.graphics.shader.GlobalParamsRegistry

public final class GlobalParamsRegistry extends Object
Registry of global shader parameter blocks.

Each entry maps a name (e.g., "Engine", "Camera", "Light") to a Java record type and a fixed binding index. The registry generates Slang code for all registered blocks and holds per-frame data for upload.

Engine registers defaults; users add their own without modifying engine code:

registry.register("Light", LightParams.class, 2);
registry.update("Light", new LightParams(dir, color, 1.0f));
  • Constructor Details

    • GlobalParamsRegistry

      public GlobalParamsRegistry()
  • Method Details

    • register

      public void register(String name, Class<?> recordType, int binding)
      Registers a global param block.
      Parameters:
      name - the block name (e.g., "Camera") — used for Slang naming and lookup
      recordType - the Java record defining the fields
      binding - the fixed UBO binding index (register(bN))
    • update

      public void update(String name, Object data)
      Updates the per-frame data for a registered param block.
    • entries

      public List<GlobalParamsRegistry.Entry> entries()
      Returns all registered entries in registration order.
    • generateSlang

      public String generateSlang()
      Generates the combined Slang source for all registered global param blocks. Each block gets interface + struct + cbuffer (with register) + impl + static global.
    • generateSlang

      public String generateSlang(boolean includeGlobals)
      Generates the combined Slang source for all registered global param blocks.
      Parameters:
      includeGlobals - if true, emits static global instances (for process compiler fallback). If false, omits globals — shader uses generic specialization instead.
    • specializationArgs

      public String[] specializationArgs()
      Returns the concrete UBO type names for all registered blocks, in registration order. Used as specialization arguments when compiling with the native Slang compiler. E.g., ["UboEngineParams", "UboCameraParams", "UboObjectParams"]
    • nextBinding

      public int nextBinding()
      Returns the next available binding index (one past the highest registered).