API

Class WebGPUDrawContext

WebGPU implementation of the IDrawContext interface. This class manages the draw context for WebGPU, including buffers and indirect draw data.

Implements

Index
  • Creates a new WebGPUDrawContext.

    Parameters

    • bufferManager: WebGPUBufferManager

      The buffer manager used to manage WebGPU buffers.

    • _dummyIndexBuffer: WebGPUDataBuffer

      A dummy index buffer to be bound as the "indices" storage buffer when no index buffer is provided.

    Returns WebGPUDrawContext

bindGroups?: GPUBindGroup[]

Cache of the bind groups. Will be reused for the next draw if isDirty==false (and materialContext.isDirty==false)

buffers: { [name: string]: Nullable<WebGPUDataBuffer> }

Buffers (uniform / storage) used for the draw call

fastBundle?: GPURenderBundle

Bundle used in fast mode (when compatibilityMode==false)

indirectDrawBuffer?: GPUBuffer

Buffer used for the indirect draw call when enableIndirectDraw is true.

uniqueId: number

Unique identifier for the draw context.

  • Checks if the draw context is dirty.

    Parameters

    • materialContextUpdateId: number

      The update ID of the material context associated with the draw context.

    Returns boolean

    True if the draw or material context is dirty, false otherwise.

  • Data for the indirect draw call (only used when enableIndirectDraw is true).

    Parameters

    • indexOrVertexCount: number

      The number of indices (if indexed draw) or vertices (if non-indexed draw).

    • instanceCount: number

      The number of instances to draw.

    • firstIndexOrVertex: number

      The index (if indexed draw) or vertex (if non-indexed draw) offset to start drawing from.

    • forceUpdate: boolean = false

      If true, forces the update of the indirect draw data even if instanceCount is the same as in the previous call.

    Returns void