Class SlangParamsBlock

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

public final class SlangParamsBlock extends Object
Generates Slang interface + implementation blocks for shader parameter access.

Two creation modes:

  • fromKeys(String, Set) — dynamic params from PropertyKeys (materials). Generates an interface for generic specialization: shaders declare <M : IMaterialParams> and the concrete type is injected.
  • fromRecord(String, Class) — static params from a Java record (camera, engine). Generates interface + implementation + a static global instance (e.g., camera.get_viewProjection()).

The upload strategy (UBO or SSBO) determines the generated implementation.

  • Method Details

    • withBinding

      public SlangParamsBlock withBinding(int bindingIndex)
      Returns a copy with an explicit binding index. The generated cbuffer will include register(bN).
    • fromKeys

      public static SlangParamsBlock fromKeys(String name, Set<? extends PropertyKey<?,?>> keys)
      Creates a params block from PropertyKeys (for materials). Generates interface + implementation + static global instance.
    • fromRecord

      public static SlangParamsBlock fromRecord(String name, Class<?> recordType)
      Creates a params block from a Java record (for camera, engine, etc.). Generates interface + implementation + static global instance.

      Uses RecordRegistry first (populated by @NativeStruct processor), falling back to native reflection for unregistered types (desktop only).

    • generateUbo

      public String generateUbo()
      Generates the full UBO-backed block with a static global instance.
    • generateUbo

      public String generateUbo(boolean includeGlobal)
      Generates the full UBO-backed block (interface + struct + cbuffer + impl).
      Parameters:
      includeGlobal - if true, adds a static global instance (e.g., static UboMaterialParams material;). Set to false when using generic specialization (the shader creates the instance via M material;).
    • generateSsbo

      public String generateSsbo()
      Generates the full SSBO-backed block with a static global instance.
    • generateSsbo

      public String generateSsbo(boolean includeGlobal)
      Generates the full SSBO-backed block (interface + struct + buffer + impl).
      Parameters:
      includeGlobal - if true, adds a static global instance.
    • interfaceName

      public String interfaceName()
      The interface name, e.g. "IMaterialParams".
    • uboTypeName

      public String uboTypeName()
      The concrete UBO type name, e.g. "UboMaterialParams".
    • ssboTypeName

      public String ssboTypeName()
      The concrete SSBO type name, e.g. "SsboMaterialParams".
    • createFromEntries

      public static SlangParamsBlock createFromEntries(String name, List<SlangParamsBlock.FieldEntry> entries)
      Factory for
      invalid reference
      ReflectiveSlangHelper
      .