Owns GPU-resident, dynamically editable storage for tiles, geometry, and mesh attributes.

Owned by a ViewManager, used by MeshManager, RenderManager, and PickManager.

GPUMemoryManager implements a data-texture + batch based memory system to support rendering and picking for large scenes with frequent updates.

It is responsible for:

  • Allocating and managing the data textures that encode per-tile camera/pick matrices (per view).
  • Creating and tracking GPUMemoryBatch instances, which own GPU storage for geometry and mesh data.
  • Providing a stable handle (GPUMemoryMeshHandle) used by higher-level managers to update mesh state (transform, per-view visibility, render pass, color/opacity, etc.).
  • Uploading pending changes to the GPU via uploadChanges.
  • Tracking and reporting GPU memory usage statistics.

Tiled Coordinate System, RTC (Relative To Center), and GPU Matrix Textures

Large-scale 3D scenes require high-precision rendering, which is achieved by partitioning world space into "tiles". Each tile defines a local coordinate system centered at a specific world position, allowing geometry within the tile to be transformed relative to its center (RTC: Relative To Center). This approach minimizes floating-point precision errors when rendering large or distant objects.

  • GPUTile:

    • Represents a single tile in world space.
    • Stores its center position and per-view RTC matrices (for both camera and picking).
    • Tracks usage count for efficient allocation and reuse.
  • GPUTileManager:

    • Allocates, synchronizes, and manages the lifecycle of all tiles.
    • Computes and updates RTC view and pick matrices for each tile as cameras move.
    • Maintains a mapping from world positions to tiles, and manages tile indices for GPU data textures.
    • Uploads updated RTC matrices to MatrixTexture objects for use in shaders.
  • MatrixTexture:

    • Stores RTC matrices for all tiles and views in a GPU-friendly format.
    • Updated by the TileManager whenever camera/view state changes.
  • DataTextures.viewTileCameraMatrixTexture:

    • An array of MatrixTexture objects, one per view.
    • Each texture contains the RTC view matrices for all tiles in that view.
    • Automatically updated when a camera moves, ensuring the GPU always has the latest RTC transforms.
  • DataTextures.viewTilePickMatrixTexture:

    • An array of MatrixTexture objects, one per view.
    • Each texture contains the RTC pick matrices for all tiles in that view, used for accurate object picking.
    • Updated as needed before picking operations.
  • When a tile is created or a camera/view changes, the system computes an RTC view matrix for each tile and view.
  • The RTC view matrix is derived by combining the camera's view matrix with a translation that recenters the world origin at the tile's center.
  • These RTC matrices are packed into MatrixTexture objects and uploaded to the GPU as data textures.
  • Model matrices for objects are also converted to RTC form before upload, ensuring all transformations are relative to the tile center.
  • In the vertex shader, the RTC view and model matrices are fetched from the appropriate MatrixTexture using the tile and view indices.
  • Vertex positions are transformed using these RTC matrices, maintaining high precision even for large coordinates.
  • This enables accurate rendering and picking across vast scenes without floating-point artifacts.
  1. Geometry is assigned to a tile based on its world position.
  2. The tile's RTC matrices are computed and stored in MatrixTexture objects.
  3. When the camera moves, RTC view matrices are updated and re-uploaded to the GPU.
  4. Shaders use the RTC matrices to transform geometry, ensuring high-precision rendering and picking.
  • The manager currently assumes a maximum of 4 views for tile matrix tables.
  • GPUTile allocation/placement and per-view camera/pick matrices are coordinated by GPUTileManager.

Implements

Constructors

Properties

dataTextures: DataTextures = null

Data texture bundle exposed for internal consumers (eg. render passes/shaders).

Populated after init succeeds. Set back to null after destroy.

Accessors

Methods

  • Allocates GPU memory and initializes tile-related data textures for this manager.

    Creates:

    • viewTileCameraMatrixTexture[0..3] mapping tileIndex -> camera view matrix per view
    • viewTilePickMatrixTexture[0..3] mapping tileIndex -> pick matrix per view
    • A GPUTileManager for tile allocation and matrix updates
    • The dataTextures bundle used by render code

    Returns SDKResult<void>

    SDKResult that is ok:true when initialization succeeds, or ok:false when texture allocation fails (typically due to GPU memory limits).

    If allocation fails part-way through, already-allocated textures are destroyed before returning.

  • Sets per-view attributes for a mesh.

    Parameters

    • meshHandle: GPUMemoryMeshHandle

      Mesh handle returned by addMesh.

    • viewIndex: number

      Target view index.

    • params: { clippable?: boolean; color?: Vec3; opacity?: number; pickable?: boolean }

      Per-view attributes.

      • Optionalclippable?: boolean

        Whether the mesh participates in clipping.

      • Optionalcolor?: Vec3

        RGB color encoded as bytes 0..255 (packed on upload).

      • Optionalopacity?: number

        Opacity in range 0..1.

      • Optionalpickable?: boolean

        Whether the mesh can be picked.

    Returns void

    SDKInternalException If the mesh handle references an invalid batch.