Class PipelineVariantCache<K>

java.lang.Object
dev.engine.graphics.pipeline.PipelineVariantCache<K>
Type Parameters:
K - the variant key type (must implement equals/hashCode)

public final class PipelineVariantCache<K> extends Object
Frame-based pipeline variant cache with automatic eviction.

Backends that bake render state into pipeline objects (Vulkan, WebGPU) use this to cache pipeline variants keyed by render state. Variants unused for a configurable number of frames are evicted automatically.

  • Constructor Details

    • PipelineVariantCache

      public PipelineVariantCache(long evictionFrames, int checkInterval)
    • PipelineVariantCache

      public PipelineVariantCache()
  • Method Details

    • getOrCreate

      public long getOrCreate(K key, long currentFrame, Function<K,Long> factory)
      Gets or creates a variant for the given key.
    • evict

      public void evict(long currentFrame, Consumer<Long> destroyer)
      Evicts variants not used for evictionFrames. Call from endFrame(). The destroyer callback receives the native pipeline handle to release.
    • removeIf

      public void removeIf(Predicate<K> predicate, Consumer<Long> destroyer)
      Removes all variants matching a predicate (e.g., when a base pipeline is destroyed).
    • clear

      public void clear(Consumer<Long> destroyer)
      Destroys all cached variants.
    • size

      public int size()