Nano WebGPU API - v0.11.0
    Preparing search index...

    Class VRAMTracker

    VRAMTracker tracks GPU memory allocations (buffers and textures) created by the engine. WebGPU does not expose a native API for querying total VRAM, so this uses manual bookkeeping — every createBuffer/createTexture in the engine calls ctx.vramTracker.register(), and every .destroy() calls ctx.vramTracker.unregister(). An instance class stored on Context to support multiple canvases and testability.

    Index

    Constructors

    Methods

    • Extracts a concise summary count detailing active resource types and total byte sizes.

      Returns {
          buffers: number;
          textures: number;
          totalBytes: number;
          totalResources: number;
      }

      Metrics summary object.

    • Estimates the total VRAM consumption across all registered entries.

      Returns number

      Total estimated VRAM in bytes.

    • Registers a newly created GPU resource allocation, caching timing and size details.

      Parameters

      • resource: GPUBuffer | GPUTexture

        Native WebGPU buffer or texture object.

      • type: "buffer" | "texture"

        Resource classification category.

      • label: string

        Resource description label.

      • sizeBytes: number

        Resource size in bytes.

      • owner: string

        Name of the owning class.

      Returns void

    • Unregisters a GPU resource that has been released or destroyed.

      Parameters

      • resource: GPUBuffer | GPUTexture

        Native WebGPU buffer or texture reference.

      Returns void

    • Formats raw byte counts into human-readable strings (e.g. "4.25 MB").

      Parameters

      • bytes: number

        Size value in bytes.

      Returns string

      Formatted string.