melonJS
    Preparing search index...

    Class WebGPUQuadBatcher

    The WebGPU quad batcher — textured-quad accumulation with the same frozen 28-byte vertex layout as the WebGL QuadBatcher and the same static 6-indices-per-quad pattern.

    Texture batching is single-texture-per-draw-segment in this first version: a texture (bind group) change flushes the pending quads — the aTextureId attribute is written as 0 and kept in the layout so the later multi-texture upgrade (binding_array / texture arrays) changes only the group-1 layout and the fragment shader, never the vertex stream. A WebGPU flush is one writeBuffer of the pending bytes plus one drawIndexed, so the per-change cost is far below the GL full-buffer re-upload this design avoids there.

    Hierarchy (View Summary)

    Index
    attributes: { bytes: number; format: any; name: any; offset: any }[] | undefined
    composedGroups: Map<string, GPUBindGroup> | undefined
    currentEffect: any
    currentMaterial: any
    device: GPUDevice | undefined
    indexBuffer: GPUBuffer | null | undefined
    nextResourceId: number | undefined
    renderer: Renderer | undefined

    the renderer this batcher is bound to

    resourceIds: WeakMap<object, any> | undefined
    segmentEntries: { sampler: GPUSampler; view: GPUTextureView }[] | undefined
    segmentGroup: GPUBindGroup | null | undefined
    shaderKey: string | undefined
    slotTable: TextureSlotTable | undefined
    stride: any
    topology: string | undefined
    vertexData: VertexArrayBuffer | undefined
    vertexSize: number | undefined
    • Add a textured quad. Same contract as the WebGL QuadBatcher.addQuad — the CPU corner transform (view matrix + per-renderable depth) is identical, only the texture-binding mechanism differs.

      Parameters

      • texture: object

        the texture atlas to draw with

      • x: number

        destination x

      • y: number

        destination y

      • w: number

        destination width

      • h: number

        destination height

      • u0: number

        texture UV (u0)

      • v0: number

        texture UV (v0)

      • u1: number

        texture UV (u1)

      • v1: number

        texture UV (v1)

      • tint: number

        tint color in UINT32 (argb) format

      • Optionalreupload: boolean = false

        force the source pixels to re-upload (video frames)

      Returns void

    • Drop every composed segment bind group — each embeds samplers resolved from the default texture filter, so a filter change must rebuild them (the multi-texture counterpart of the texture store's invalidateBindGroups).

      Returns void

    • indexed draw: 6 indices per 4 queued vertices, region-relative. The fast path binds its single-source material; the normal path binds the composed segment (up to eight textures).

      Parameters

      • pass: GPURenderPassEncoder

        the open pass

      • vertexCount: number

        pending vertex count

      Returns void