melonjs 19.9.1 → 20.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -14
- package/build/application/application.d.ts +70 -16
- package/build/application/application.d.ts.map +1 -1
- package/build/application/defaultApplicationSettings.d.ts +2 -2
- package/build/application/settings.d.ts +150 -53
- package/build/application/settings.d.ts.map +1 -1
- package/build/camera/camera2d.d.ts +1 -1
- package/build/camera/camera2d.d.ts.map +1 -1
- package/build/camera/camera3d.d.ts +13 -11
- package/build/camera/camera3d.d.ts.map +1 -1
- package/build/camera/effects/fade_effect.d.ts.map +1 -1
- package/build/camera/effects/mask_effect.d.ts.map +1 -1
- package/build/const.d.ts +55 -26
- package/build/const.d.ts.map +1 -1
- package/build/geometries/box3d.d.ts +156 -0
- package/build/geometries/box3d.d.ts.map +1 -0
- package/build/index.d.ts +34 -24
- package/build/index.d.ts.map +1 -1
- package/build/index.js +22171 -8029
- package/build/index.js.map +4 -4
- package/build/lang/deprecated.d.ts +4 -4
- package/build/lang/deprecated.d.ts.map +1 -1
- package/build/level/gltf/GLTFModel.d.ts +4 -0
- package/build/level/gltf/GLTFModel.d.ts.map +1 -1
- package/build/level/gltf/GLTFScene.d.ts +42 -6
- package/build/level/gltf/GLTFScene.d.ts.map +1 -1
- package/build/level/gltf/srgb.d.ts +20 -0
- package/build/level/gltf/srgb.d.ts.map +1 -0
- package/build/level/level.d.ts +21 -2
- package/build/level/level.d.ts.map +1 -1
- package/build/lighting/light3d.d.ts +61 -13
- package/build/lighting/light3d.d.ts.map +1 -1
- package/build/loader/loader.d.ts +49 -21
- package/build/loader/loader.d.ts.map +1 -1
- package/build/loader/parsers/gltf.d.ts.map +1 -1
- package/build/loader/parsers/mtl.d.ts +18 -0
- package/build/loader/parsers/mtl.d.ts.map +1 -1
- package/build/loader/parsers/obj.d.ts +49 -0
- package/build/loader/parsers/obj.d.ts.map +1 -1
- package/build/loader/parsers/pbr.d.ts +63 -0
- package/build/loader/parsers/pbr.d.ts.map +1 -0
- package/build/loader/parsers/shader.d.ts +32 -24
- package/build/loader/parsers/shader.d.ts.map +1 -1
- package/build/physics/adapter.d.ts +86 -1
- package/build/physics/adapter.d.ts.map +1 -1
- package/build/physics/broadphase/octree.d.ts +35 -0
- package/build/physics/broadphase/octree.d.ts.map +1 -1
- package/build/physics/builtin/body.d.ts +123 -15
- package/build/physics/builtin/body.d.ts.map +1 -1
- package/build/physics/builtin/builtin-adapter.d.ts.map +1 -1
- package/build/physics/builtin/detector.d.ts +186 -1
- package/build/physics/builtin/detector.d.ts.map +1 -1
- package/build/physics/builtin/raycast.d.ts.map +1 -1
- package/build/physics/builtin/sat3d.d.ts +59 -0
- package/build/physics/builtin/sat3d.d.ts.map +1 -0
- package/build/physics/response.d.ts +32 -0
- package/build/physics/response.d.ts.map +1 -1
- package/build/physics/world.d.ts +1 -0
- package/build/physics/world.d.ts.map +1 -1
- package/build/renderable/container.d.ts +1 -0
- package/build/renderable/container.d.ts.map +1 -1
- package/build/renderable/groundshadow.d.ts +92 -0
- package/build/renderable/groundshadow.d.ts.map +1 -0
- package/build/renderable/instanced_mesh.d.ts +286 -0
- package/build/renderable/instanced_mesh.d.ts.map +1 -0
- package/build/renderable/mesh.d.ts +242 -23
- package/build/renderable/mesh.d.ts.map +1 -1
- package/build/renderable/renderable.d.ts +6 -4
- package/build/renderable/renderable.d.ts.map +1 -1
- package/build/renderable/sprite3d.d.ts +17 -6
- package/build/renderable/sprite3d.d.ts.map +1 -1
- package/build/renderable/text/text.d.ts.map +1 -1
- package/build/system/device.d.ts +11 -40
- package/build/system/device.d.ts.map +1 -1
- package/build/system/platform.d.ts +0 -16
- package/build/system/platform.d.ts.map +1 -1
- package/build/utils/utils.d.ts +2 -0
- package/build/utils/utils.d.ts.map +1 -1
- package/build/video/canvas/canvas_renderer.d.ts +22 -16
- package/build/video/canvas/canvas_renderer.d.ts.map +1 -1
- package/build/video/{webgl/effects → effects}/blur.d.ts +2 -2
- package/build/video/effects/blur.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/chromaticAberration.d.ts +2 -2
- package/build/video/effects/chromaticAberration.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/colorMatrix.d.ts +3 -3
- package/build/video/effects/colorMatrix.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/desaturate.d.ts +1 -1
- package/build/video/effects/desaturate.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/dissolve.d.ts +2 -2
- package/build/video/effects/dissolve.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/dropShadow.d.ts +2 -2
- package/build/video/effects/dropShadow.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/flash.d.ts +2 -2
- package/build/video/effects/flash.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/glow.d.ts +2 -2
- package/build/video/effects/glow.d.ts.map +1 -0
- package/build/video/effects/glsl_realization.d.ts +18 -0
- package/build/video/effects/glsl_realization.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/hologram.d.ts +2 -2
- package/build/video/effects/hologram.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/invert.d.ts +1 -1
- package/build/video/effects/invert.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/outline.d.ts +2 -2
- package/build/video/effects/outline.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/pixelate.d.ts +2 -2
- package/build/video/effects/pixelate.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/radialGradient.d.ts +3 -4
- package/build/video/effects/radialGradient.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/scanline.d.ts +2 -2
- package/build/video/effects/scanline.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/sepia.d.ts +1 -1
- package/build/video/effects/sepia.d.ts.map +1 -0
- package/build/video/{webgl → effects}/shadereffect.d.ts +133 -25
- package/build/video/effects/shadereffect.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/shine.d.ts +2 -2
- package/build/video/effects/shine.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/tintPulse.d.ts +2 -2
- package/build/video/effects/tintPulse.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/vignette.d.ts +2 -2
- package/build/video/effects/vignette.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/wave.d.ts +2 -2
- package/build/video/effects/wave.d.ts.map +1 -0
- package/build/video/effects/wgsl/layout.d.ts +28 -0
- package/build/video/effects/wgsl/layout.d.ts.map +1 -0
- package/build/video/effects/wgsl/parse.d.ts +9 -0
- package/build/video/effects/wgsl/parse.d.ts.map +1 -0
- package/build/video/effects/wgsl/scaffold.d.ts +43 -0
- package/build/video/effects/wgsl/scaffold.d.ts.map +1 -0
- package/build/video/effects/wgsl_realization.d.ts +83 -0
- package/build/video/effects/wgsl_realization.d.ts.map +1 -0
- package/build/video/gpu/batcher.d.ts +71 -0
- package/build/video/gpu/batcher.d.ts.map +1 -0
- package/build/video/gpu/instancerecord.d.ts +164 -0
- package/build/video/gpu/instancerecord.d.ts.map +1 -0
- package/build/video/gpu/meshchunk.d.ts +49 -0
- package/build/video/gpu/meshchunk.d.ts.map +1 -0
- package/build/video/gpu/meshvertex.d.ts +54 -0
- package/build/video/gpu/meshvertex.d.ts.map +1 -0
- package/build/video/gpu/primitives.d.ts +60 -0
- package/build/video/gpu/primitives.d.ts.map +1 -0
- package/build/video/gpu/quadcorners.d.ts +11 -0
- package/build/video/gpu/quadcorners.d.ts.map +1 -0
- package/build/video/gpu/textureslots.d.ts +122 -0
- package/build/video/gpu/textureslots.d.ts.map +1 -0
- package/build/video/gpu/texturestore.d.ts +139 -0
- package/build/video/gpu/texturestore.d.ts.map +1 -0
- package/build/video/gpu/topology.d.ts +43 -0
- package/build/video/gpu/topology.d.ts.map +1 -0
- package/build/video/gpu/vertexformat.d.ts +72 -0
- package/build/video/gpu/vertexformat.d.ts.map +1 -0
- package/build/video/gradient.d.ts +14 -5
- package/build/video/gradient.d.ts.map +1 -1
- package/build/video/renderer.d.ts +153 -8
- package/build/video/renderer.d.ts.map +1 -1
- package/build/video/rendertarget/canvasrendertarget.d.ts +7 -6
- package/build/video/rendertarget/canvasrendertarget.d.ts.map +1 -1
- package/build/video/rendertarget/render_target_pool.d.ts +2 -2
- package/build/video/rendertarget/render_target_pool.d.ts.map +1 -1
- package/build/video/rendertarget/webglrendertarget.d.ts +38 -2
- package/build/video/rendertarget/webglrendertarget.d.ts.map +1 -1
- package/build/video/rendertarget/webgpurendertarget.d.ts +83 -0
- package/build/video/rendertarget/webgpurendertarget.d.ts.map +1 -0
- package/build/video/texture/atlas.d.ts.map +1 -1
- package/build/video/texture/cache.d.ts +20 -2
- package/build/video/texture/cache.d.ts.map +1 -1
- package/build/video/texture/noise_texture2d.d.ts +2 -2
- package/build/video/utils/autodetect.d.ts.map +1 -1
- package/build/video/video.d.ts +1 -55
- package/build/video/video.d.ts.map +1 -1
- package/build/video/webgl/batchers/batcher.d.ts +132 -35
- package/build/video/webgl/batchers/batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/lit_mesh_batcher.d.ts +14 -0
- package/build/video/webgl/batchers/lit_mesh_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/lit_quad_batcher.d.ts +63 -36
- package/build/video/webgl/batchers/lit_quad_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/material_batcher.d.ts +29 -20
- package/build/video/webgl/batchers/material_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/mesh_batcher.d.ts +308 -14
- package/build/video/webgl/batchers/mesh_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/primitive_batcher.d.ts +2 -2
- package/build/video/webgl/batchers/primitive_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/quad_batcher.d.ts +0 -2
- package/build/video/webgl/batchers/quad_batcher.d.ts.map +1 -1
- package/build/video/webgl/buffer/index.d.ts +1 -1
- package/build/video/webgl/buffer/instance_buffer.d.ts +54 -0
- package/build/video/webgl/buffer/instance_buffer.d.ts.map +1 -0
- package/build/video/webgl/buffer/retained_geometry.d.ts +83 -0
- package/build/video/webgl/buffer/retained_geometry.d.ts.map +1 -0
- package/build/video/webgl/buffer/uniformblock.d.ts +81 -0
- package/build/video/webgl/buffer/uniformblock.d.ts.map +1 -0
- package/build/video/webgl/buffer/vertexstate.d.ts +101 -0
- package/build/video/webgl/buffer/vertexstate.d.ts.map +1 -0
- package/build/video/webgl/glshader.d.ts +101 -8
- package/build/video/webgl/glshader.d.ts.map +1 -1
- package/build/video/webgl/lighting/constants.d.ts +20 -8
- package/build/video/webgl/lighting/constants.d.ts.map +1 -1
- package/build/video/webgl/lighting/pack.d.ts +1 -1
- package/build/video/webgl/lighting/pack3d.d.ts +27 -11
- package/build/video/webgl/lighting/pack3d.d.ts.map +1 -1
- package/build/video/webgl/lighting/std140.d.ts +110 -0
- package/build/video/webgl/lighting/std140.d.ts.map +1 -0
- package/build/video/webgl/shaders/multitexture-lit.d.ts +7 -3
- package/build/video/webgl/shaders/multitexture-lit.d.ts.map +1 -1
- package/build/video/webgl/texture/store.d.ts +52 -0
- package/build/video/webgl/texture/store.d.ts.map +1 -0
- package/build/video/webgl/utils/maxtextures.d.ts +37 -0
- package/build/video/webgl/utils/maxtextures.d.ts.map +1 -0
- package/build/video/webgl/utils/samplercache.d.ts +69 -0
- package/build/video/webgl/utils/samplercache.d.ts.map +1 -0
- package/build/video/webgl/utils/string.d.ts +16 -0
- package/build/video/webgl/utils/string.d.ts.map +1 -1
- package/build/video/webgl/utils/topology.d.ts +24 -0
- package/build/video/webgl/utils/topology.d.ts.map +1 -0
- package/build/video/webgl/utils/vertexformat.d.ts +27 -0
- package/build/video/webgl/utils/vertexformat.d.ts.map +1 -0
- package/build/video/webgl/webgl_renderer.d.ts +148 -30
- package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
- package/build/video/webgpu/batchers/lit_mesh_batcher.d.ts +40 -0
- package/build/video/webgpu/batchers/lit_mesh_batcher.d.ts.map +1 -0
- package/build/video/webgpu/batchers/lit_quad_batcher.d.ts +82 -0
- package/build/video/webgpu/batchers/lit_quad_batcher.d.ts.map +1 -0
- package/build/video/webgpu/batchers/mesh_batcher.d.ts +301 -0
- package/build/video/webgpu/batchers/mesh_batcher.d.ts.map +1 -0
- package/build/video/webgpu/batchers/primitive_batcher.d.ts +39 -0
- package/build/video/webgpu/batchers/primitive_batcher.d.ts.map +1 -0
- package/build/video/webgpu/batchers/quad_batcher.d.ts +143 -0
- package/build/video/webgpu/batchers/quad_batcher.d.ts.map +1 -0
- package/build/video/webgpu/batchers/webgpu_batcher.d.ts +70 -0
- package/build/video/webgpu/batchers/webgpu_batcher.d.ts.map +1 -0
- package/build/video/webgpu/buffer/arena.d.ts +64 -0
- package/build/video/webgpu/buffer/arena.d.ts.map +1 -0
- package/build/video/webgpu/buffer/instance_buffer.d.ts +65 -0
- package/build/video/webgpu/buffer/instance_buffer.d.ts.map +1 -0
- package/build/video/webgpu/buffer/retained_geometry.d.ts +55 -0
- package/build/video/webgpu/buffer/retained_geometry.d.ts.map +1 -0
- package/build/video/webgpu/buffer/uniformring.d.ts +68 -0
- package/build/video/webgpu/buffer/uniformring.d.ts.map +1 -0
- package/build/video/webgpu/effect_binding.d.ts +17 -0
- package/build/video/webgpu/effect_binding.d.ts.map +1 -0
- package/build/video/webgpu/pipeline/bindgroups.d.ts +36 -0
- package/build/video/webgpu/pipeline/bindgroups.d.ts.map +1 -0
- package/build/video/webgpu/pipeline/cache.d.ts +173 -0
- package/build/video/webgpu/pipeline/cache.d.ts.map +1 -0
- package/build/video/webgpu/renderers/tmxlayer/orthogonal.d.ts +90 -0
- package/build/video/webgpu/renderers/tmxlayer/orthogonal.d.ts.map +1 -0
- package/build/video/webgpu/shaders/mesh-instanced.d.ts +60 -0
- package/build/video/webgpu/shaders/mesh-instanced.d.ts.map +1 -0
- package/build/video/webgpu/texture/compressed.d.ts +33 -0
- package/build/video/webgpu/texture/compressed.d.ts.map +1 -0
- package/build/video/webgpu/texture/frametexture.d.ts +65 -0
- package/build/video/webgpu/texture/frametexture.d.ts.map +1 -0
- package/build/video/webgpu/texture/store.d.ts +149 -0
- package/build/video/webgpu/texture/store.d.ts.map +1 -0
- package/build/video/webgpu/webgpu_renderer.d.ts +536 -0
- package/build/video/webgpu/webgpu_renderer.d.ts.map +1 -0
- package/package.json +2 -2
- package/build/video/webgl/effects/blur.d.ts.map +0 -1
- package/build/video/webgl/effects/chromaticAberration.d.ts.map +0 -1
- package/build/video/webgl/effects/colorMatrix.d.ts.map +0 -1
- package/build/video/webgl/effects/desaturate.d.ts.map +0 -1
- package/build/video/webgl/effects/dissolve.d.ts.map +0 -1
- package/build/video/webgl/effects/dropShadow.d.ts.map +0 -1
- package/build/video/webgl/effects/flash.d.ts.map +0 -1
- package/build/video/webgl/effects/glow.d.ts.map +0 -1
- package/build/video/webgl/effects/hologram.d.ts.map +0 -1
- package/build/video/webgl/effects/invert.d.ts.map +0 -1
- package/build/video/webgl/effects/outline.d.ts.map +0 -1
- package/build/video/webgl/effects/pixelate.d.ts.map +0 -1
- package/build/video/webgl/effects/radialGradient.d.ts.map +0 -1
- package/build/video/webgl/effects/scanline.d.ts.map +0 -1
- package/build/video/webgl/effects/sepia.d.ts.map +0 -1
- package/build/video/webgl/effects/shine.d.ts.map +0 -1
- package/build/video/webgl/effects/tintPulse.d.ts.map +0 -1
- package/build/video/webgl/effects/vignette.d.ts.map +0 -1
- package/build/video/webgl/effects/wave.d.ts.map +0 -1
- package/build/video/webgl/shadereffect.d.ts.map +0 -1
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Byte size of the per-draw mesh uniform block:
|
|
3
|
+
* mat4x4 model (64) + mat4x4 view (64) + vec4 tint (16) + vec4 params
|
|
4
|
+
* (alphaCutoff, hasAlphaMap, reserved ×2) (16) + vec4 emissive (16) +
|
|
5
|
+
* vec4 specular (rgb + shininess) (16) + vec4 eye (camera world position;
|
|
6
|
+
* w reserved) (16) → 208.
|
|
7
|
+
* @ignore
|
|
8
|
+
*/
|
|
9
|
+
export const MESH_UNIFORM_SIZE: 208;
|
|
10
|
+
/**
|
|
11
|
+
* The WebGPU mesh batcher — textured triangle meshes with the same
|
|
12
|
+
* geometry contract as the WebGL `MeshBatcher` (36-byte unlit layout,
|
|
13
|
+
* model-space retained geometry, uniform-driven placement) realized on
|
|
14
|
+
* this backend's recording model:
|
|
15
|
+
*
|
|
16
|
+
* - mesh mode is PIPELINE state, not device state: every mesh flush looks
|
|
17
|
+
* its pipeline up with the mesh axes (depth write + LEQUAL, per-mesh
|
|
18
|
+
* cull/frontFace from `renderer.drawMesh`) and blend forced "none" —
|
|
19
|
+
* there is no `bind()`/`unbind()` state to own, and the depth clear is
|
|
20
|
+
* the pass's `depthLoadOp` (see `resolveDepthOps`), not a draw-time op
|
|
21
|
+
* - placement/tint/cutoff/emissive ride ONE per-draw uniform snapshot
|
|
22
|
+
* (group 3, dynamic offset into the effect uniform arena) — the
|
|
23
|
+
* queue-write law: a shared region would be retroactively clobbered for
|
|
24
|
+
* draws already recorded this frame
|
|
25
|
+
* - the accumulated path chunks through the shared versioned-remap dedup
|
|
26
|
+
* (`gpu/meshchunk.ts`) into the frame's vertex arena plus a per-frame
|
|
27
|
+
* INDEX arena (`renderer.indexArena`) — one `drawIndexed` per chunk
|
|
28
|
+
* @augments WebGPUBatcher
|
|
29
|
+
* @category Rendering
|
|
30
|
+
*/
|
|
31
|
+
export default class WebGPUMeshBatcher extends WebGPUBatcher {
|
|
32
|
+
/**
|
|
33
|
+
* @param {import("../webgpu_renderer.js").default} renderer - the owning renderer
|
|
34
|
+
* @override
|
|
35
|
+
*/
|
|
36
|
+
override init(renderer: import("../webgpu_renderer.js").default, settings: any): void;
|
|
37
|
+
meshLayout: GPUBindGroupLayout | undefined;
|
|
38
|
+
vertexLayoutKey: string | undefined;
|
|
39
|
+
customShader: any;
|
|
40
|
+
indexData: Uint32Array<ArrayBuffer> | undefined;
|
|
41
|
+
indexCount: any;
|
|
42
|
+
currentMaterial: any;
|
|
43
|
+
uniformBinding: {
|
|
44
|
+
bindGroup: any;
|
|
45
|
+
dynamicOffset: any;
|
|
46
|
+
} | null | undefined;
|
|
47
|
+
uniformBindGroups: Map<any, any> | undefined;
|
|
48
|
+
meshState: {
|
|
49
|
+
cullMode: string;
|
|
50
|
+
frontFace: string;
|
|
51
|
+
} | undefined;
|
|
52
|
+
retained: Map<any, any> | undefined;
|
|
53
|
+
instanced: Map<any, any> | undefined;
|
|
54
|
+
instancedKeys: Map<any, any> | undefined;
|
|
55
|
+
shadowFamilyKeys: Map<any, any> | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* The instanced variant options for this tier (unlit by default) — where
|
|
58
|
+
* its instance attributes start and how its vertex stage places them.
|
|
59
|
+
* @ignore
|
|
60
|
+
*/
|
|
61
|
+
instancedVariant(): {
|
|
62
|
+
baseLocation: number;
|
|
63
|
+
varyingLocation: number;
|
|
64
|
+
geometryInputs: string;
|
|
65
|
+
body: string;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* The pipeline-cache family for a given record layout, registered on
|
|
69
|
+
* first use.
|
|
70
|
+
*
|
|
71
|
+
* WGSL has no preprocessor, so the variant is a module DERIVED from this
|
|
72
|
+
* tier's ordinary source (see `buildInstancedMeshWGSL`) rather than the
|
|
73
|
+
* same text compiled with different defines. Its vertex layout is two
|
|
74
|
+
* groups: this batcher's geometry layout, plus the instance records
|
|
75
|
+
* stepping once per instance.
|
|
76
|
+
* @param {object} layout - the instance record layout
|
|
77
|
+
* @returns {string} the family key
|
|
78
|
+
* @ignore
|
|
79
|
+
*/
|
|
80
|
+
instancedFamilyFor(layout: object): string;
|
|
81
|
+
/**
|
|
82
|
+
* Get (creating on first use) the GPU instance buffer for one mesh, with
|
|
83
|
+
* its dirty span already uploaded.
|
|
84
|
+
* @param {InstancedMesh} mesh - the mesh being drawn
|
|
85
|
+
* @returns {WebGPUInstanceBuffer} the up-to-date buffer
|
|
86
|
+
* @ignore
|
|
87
|
+
*/
|
|
88
|
+
instanceBufferFor(mesh: InstancedMesh): WebGPUInstanceBuffer;
|
|
89
|
+
/**
|
|
90
|
+
* Draw every visible instance of a mesh in one recorded call.
|
|
91
|
+
* @param {InstancedMesh} mesh - the mesh to draw
|
|
92
|
+
* @param {Matrix3d} modelMatrix - where the group sits in the world
|
|
93
|
+
* @param {number} tint - tint colour in UINT32 (argb) format
|
|
94
|
+
* @ignore
|
|
95
|
+
*/
|
|
96
|
+
drawInstancedMesh(mesh: InstancedMesh, modelMatrix: Matrix3d, tint: number): void;
|
|
97
|
+
instancedShaderWarned: boolean | undefined;
|
|
98
|
+
/**
|
|
99
|
+
* The instanced ground-shadow family (#1515), registered on first use.
|
|
100
|
+
*
|
|
101
|
+
* ONE family, not one per record layout: the module reads only the three
|
|
102
|
+
* transform rows, so `hasColor` / `hasData` make no difference — and the
|
|
103
|
+
* vertex layout declares only those rows, leaving the instance buffer's
|
|
104
|
+
* stride and offsets exactly as the mesh pass uses them.
|
|
105
|
+
* @param {object} layout - the mesh's instance record layout
|
|
106
|
+
* @returns {string} the pipeline family key
|
|
107
|
+
* @ignore
|
|
108
|
+
*/
|
|
109
|
+
instancedShadowFamily(layout: object): string;
|
|
110
|
+
/**
|
|
111
|
+
* Record one flat blob per instance, in a single call, over the same
|
|
112
|
+
* instance buffer the mesh itself drew from (#1515).
|
|
113
|
+
* @param {InstancedMesh} mesh - the mesh casting the shadows
|
|
114
|
+
* @param {Matrix3d} shadowMatrix - the group matrix flattened onto the ground
|
|
115
|
+
* @param {number} tint - tint colour in UINT32 (argb) format
|
|
116
|
+
* @param {object} quad - the shared shadow quad
|
|
117
|
+
* @ignore
|
|
118
|
+
*/
|
|
119
|
+
drawInstancedShadow(mesh: InstancedMesh, shadowMatrix: Matrix3d, tint: number, quad: object): void;
|
|
120
|
+
/**
|
|
121
|
+
* Release the instance buffer held for one mesh, if any.
|
|
122
|
+
* @param {object} mesh - the mesh whose instance records should be freed
|
|
123
|
+
* @ignore
|
|
124
|
+
*/
|
|
125
|
+
releaseInstanced(mesh: object): void;
|
|
126
|
+
/**
|
|
127
|
+
* Release every instance buffer this batcher holds.
|
|
128
|
+
* @ignore
|
|
129
|
+
*/
|
|
130
|
+
releaseAllInstanced(): void;
|
|
131
|
+
/**
|
|
132
|
+
* the first-init settings — the lit subclass overrides the key and
|
|
133
|
+
* appends its normal attribute
|
|
134
|
+
* @ignore
|
|
135
|
+
*/
|
|
136
|
+
defaultSettings(): {
|
|
137
|
+
shaderKey: string;
|
|
138
|
+
topology: string;
|
|
139
|
+
attributes: {
|
|
140
|
+
name: string;
|
|
141
|
+
format: string;
|
|
142
|
+
offset: number;
|
|
143
|
+
}[];
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* the WGSL module text of this family
|
|
147
|
+
* @ignore
|
|
148
|
+
*/
|
|
149
|
+
shaderSource(): any;
|
|
150
|
+
/**
|
|
151
|
+
* The vertex attribute layout — identical to the WebGL mesh batcher's:
|
|
152
|
+
* `aVertex` (3) + `aRegion` (2) + `aColor` (4 floats, deliberately not
|
|
153
|
+
* unorm8x4 — the layout is shared with GL, where float colors dodge
|
|
154
|
+
* NaN-pattern canonicalization on Metal-backed drivers) = 9 floats.
|
|
155
|
+
* @ignore
|
|
156
|
+
*/
|
|
157
|
+
attributeLayout(): {
|
|
158
|
+
name: string;
|
|
159
|
+
format: string;
|
|
160
|
+
offset: number;
|
|
161
|
+
}[];
|
|
162
|
+
/**
|
|
163
|
+
* the shape signature keying the group-3 layout in the pipeline cache
|
|
164
|
+
* @ignore
|
|
165
|
+
*/
|
|
166
|
+
uniformSignature(): string;
|
|
167
|
+
/**
|
|
168
|
+
* The shader family for the next recorded draw: the built-in family,
|
|
169
|
+
* or the hosted custom module when `renderer.drawMesh` routed a
|
|
170
|
+
* WGSL-carrying {@link GLShader} here — registered lazily against
|
|
171
|
+
* THIS host's vertex layout and group list, so one instance serves
|
|
172
|
+
* the unlit and lit hosts as distinct families. An invalid module
|
|
173
|
+
* (failed async validation) falls back to the built-in family: the
|
|
174
|
+
* mesh keeps drawing, default-shaded — the ShaderEffect
|
|
175
|
+
* warn-and-degrade contract.
|
|
176
|
+
* @returns {string} the pipeline-cache family key
|
|
177
|
+
* @ignore
|
|
178
|
+
*/
|
|
179
|
+
activeShaderKey(): string;
|
|
180
|
+
/**
|
|
181
|
+
* the positional bind-group-layout list for this family — the lit
|
|
182
|
+
* subclass swaps the group-2 filler for its light-block layout
|
|
183
|
+
* @ignore
|
|
184
|
+
*/
|
|
185
|
+
bindGroupLayoutList(cache: any): any[];
|
|
186
|
+
/**
|
|
187
|
+
* Resolve the group-1 material for a mesh: its texture through the
|
|
188
|
+
* texture store, honouring the mesh's own `textureRepeat` wrap override
|
|
189
|
+
* (#1503 — sampler state per use, never a mutation of the shared
|
|
190
|
+
* per-image atlas). A material change with vertices pending flushes
|
|
191
|
+
* them under the previous binding.
|
|
192
|
+
* @param {object} mesh - the mesh whose material should be applied
|
|
193
|
+
* @param {TextureAtlas} [texture] - bind this texture instead of the mesh's
|
|
194
|
+
* own — how a multi-material model's per-material `map_Kd` reaches the
|
|
195
|
+
* sampler, one draw range at a time (#1573). The wrap override stays a
|
|
196
|
+
* property of the mesh, not of the material group.
|
|
197
|
+
* @ignore
|
|
198
|
+
*/
|
|
199
|
+
applyMeshMaterial(mesh: object, texture?: TextureAtlas): void;
|
|
200
|
+
/**
|
|
201
|
+
* Snapshot the per-draw uniforms — placement (`model`, `view`), tint,
|
|
202
|
+
* and the mesh's material scalars (alpha cutoff, emissive) — into a
|
|
203
|
+
* fresh dynamic-offset region of the effect uniform arena. The draws
|
|
204
|
+
* recorded after this bind against exactly these bytes.
|
|
205
|
+
* @param {Matrix3d} modelMatrix - the mesh's own placement, or identity
|
|
206
|
+
* when its vertices are already positioned
|
|
207
|
+
* @param {number} tint - tint colour in UINT32 (argb) format
|
|
208
|
+
* @param {object} mesh - the mesh (alphaCutoff / emissive source)
|
|
209
|
+
* @ignore
|
|
210
|
+
*/
|
|
211
|
+
setPlacementUniforms(modelMatrix: Matrix3d, tint: number, mesh: object): void;
|
|
212
|
+
/**
|
|
213
|
+
* Write one vertex into the staging buffer. The base (unlit) layout is
|
|
214
|
+
* `x, y, z, u, v, color` — subclasses override to append per-vertex
|
|
215
|
+
* data matching their attribute layout.
|
|
216
|
+
* @ignore
|
|
217
|
+
*/
|
|
218
|
+
pushVertex(vertexData: any, x: any, y: any, z: any, u: any, v: any, color: any, _mesh: any, _i3: any): void;
|
|
219
|
+
/**
|
|
220
|
+
* Add a textured mesh to the batch (the accumulated path: vertices
|
|
221
|
+
* already CPU-projected, identity model matrix). Chunks triangles
|
|
222
|
+
* across flushes through the shared versioned-remap dedup, exactly
|
|
223
|
+
* like the WebGL batcher. Multi-material vertex colors ride `aColor`;
|
|
224
|
+
* the runtime tint stays a uniform.
|
|
225
|
+
* @param {object} mesh - a Mesh with vertices, uvs, indices, texture
|
|
226
|
+
* @param {number} tint - tint color in UINT32 (argb) format
|
|
227
|
+
*/
|
|
228
|
+
addMesh(mesh: object, tint: number): void;
|
|
229
|
+
/**
|
|
230
|
+
* Accumulate one index range of a mesh into the batch, chunking triangles
|
|
231
|
+
* across flushes as the vertex / index staging arrays fill.
|
|
232
|
+
* @param {object} mesh - a Mesh with vertices, uvs, indices, texture
|
|
233
|
+
* @param {number} from - first index to accumulate
|
|
234
|
+
* @param {number} length - how many indices to accumulate
|
|
235
|
+
* @ignore
|
|
236
|
+
*/
|
|
237
|
+
accumulateRange(mesh: object, from: number, length: number): void;
|
|
238
|
+
/**
|
|
239
|
+
* Record the pending mesh vertices as one indexed draw: vertex bytes
|
|
240
|
+
* into the vertex arena, index bytes into the index arena, pipeline
|
|
241
|
+
* from the mesh family with the depth/cull axes and blend forced
|
|
242
|
+
* "none" (the GL mesh mode disables BLEND).
|
|
243
|
+
* @override
|
|
244
|
+
*/
|
|
245
|
+
override flush(): void;
|
|
246
|
+
/**
|
|
247
|
+
* bind group 2 — the unlit family interposes the shared empty group;
|
|
248
|
+
* the lit subclass overrides with its light block
|
|
249
|
+
* @ignore
|
|
250
|
+
*/
|
|
251
|
+
bindLights(pass: any): void;
|
|
252
|
+
/**
|
|
253
|
+
* Write one mesh's model-space geometry into `out` in this batcher's
|
|
254
|
+
* vertex layout, returning how many floats were written — the shared
|
|
255
|
+
* neutral builder (`gpu/meshvertex.ts`), one copy for both backends.
|
|
256
|
+
* @param {object} mesh - the mesh to read geometry from
|
|
257
|
+
* @param {Float32Array} out - destination scratch
|
|
258
|
+
* @returns {number} number of floats written
|
|
259
|
+
* @ignore
|
|
260
|
+
*/
|
|
261
|
+
buildRetainedVertexData(mesh: object, out: Float32Array): number;
|
|
262
|
+
/**
|
|
263
|
+
* Get this mesh's retained geometry, building or refreshing it when
|
|
264
|
+
* the mesh's geometry version has moved on.
|
|
265
|
+
* @param {object} mesh - the mesh whose geometry is wanted
|
|
266
|
+
* @returns {WebGPURetainedGeometry} up-to-date geometry for the mesh
|
|
267
|
+
* @ignore
|
|
268
|
+
*/
|
|
269
|
+
retainedGeometryFor(mesh: object): WebGPURetainedGeometry;
|
|
270
|
+
/**
|
|
271
|
+
* Draw a mesh from its retained geometry: bind the persistent buffers
|
|
272
|
+
* and record one indexed draw, with placement supplied entirely by the
|
|
273
|
+
* per-draw uniform snapshot. Unlike {@link WebGPUMeshBatcher#addMesh}
|
|
274
|
+
* this accumulates nothing and never chunks — the whole mesh is one
|
|
275
|
+
* draw regardless of size, except for a multi-material model whose
|
|
276
|
+
* materials carry different diffuse textures: that records one indexed
|
|
277
|
+
* range per entry in {@link Mesh#textureGroups} (#1573), over the same
|
|
278
|
+
* buffers, with only the group-1 material binding moving between them.
|
|
279
|
+
* @param {object} mesh - the mesh to draw
|
|
280
|
+
* @param {Matrix3d} modelMatrix - where the mesh sits in the world
|
|
281
|
+
* @param {number} tint - tint colour in UINT32 (argb) format
|
|
282
|
+
* @ignore
|
|
283
|
+
*/
|
|
284
|
+
drawRetainedMesh(mesh: object, modelMatrix: Matrix3d, tint: number): void;
|
|
285
|
+
/**
|
|
286
|
+
* Release the retained geometry held for one mesh, if any.
|
|
287
|
+
* @param {object} mesh - the mesh whose geometry should be freed
|
|
288
|
+
* @ignore
|
|
289
|
+
*/
|
|
290
|
+
releaseRetained(mesh: object): void;
|
|
291
|
+
/**
|
|
292
|
+
* Release every retained geometry this batcher holds.
|
|
293
|
+
* @ignore
|
|
294
|
+
*/
|
|
295
|
+
releaseAllRetained(): void;
|
|
296
|
+
}
|
|
297
|
+
import WebGPUBatcher from "./webgpu_batcher.js";
|
|
298
|
+
import WebGPUInstanceBuffer from "../buffer/instance_buffer.js";
|
|
299
|
+
import { Matrix3d } from "../../../math/matrix3d.ts";
|
|
300
|
+
import WebGPURetainedGeometry from "../buffer/retained_geometry.js";
|
|
301
|
+
//# sourceMappingURL=mesh_batcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mesh_batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgpu/batchers/mesh_batcher.js"],"names":[],"mappings":"AAmBA;;;;;;;GAOG;AACH,gCAAiC,GAAG,CAAC;AAUrC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH;IACC;;;OAGG;IACH,wBAHW,OAAO,uBAAuB,EAAE,OAAO,uBAmFjD;IAzEA,2CAUE;IAuBF,oCAAsC;IAItC,kBAAwB;IAIxB,gDAA+D;IAC/D,gBAAmB;IAGnB,qBAA2B;IAE3B;;;yBAA0B;IAE1B,6CAAkC;IAGlC;;;kBAAuD;IAQvD,oCAAyB;IAQzB,qCAA0B;IAC1B,yCAA8B;IAG9B,4CAAiC;IAGlC;;;;OAIG;IACH;;;;;MAEC;IAED;;;;;;;;;;;;OAYG;IACH,2BAJW,MAAM,GACJ,MAAM,CAmClB;IAED;;;;;;OAMG;IACH,wBAJW,aAAa,GACX,oBAAoB,CAuBhC;IAED;;;;;;OAMG;IACH,wBALW,aAAa,eACb,QAAQ,QACR,MAAM,QA4EhB;IAhDC,2CAAiC;IAkDnC;;;;;;;;;;OAUG;IACH,8BAJW,MAAM,GACJ,MAAM,CA4ClB;IAED;;;;;;;;OAQG;IACH,0BANW,aAAa,gBACb,QAAQ,QACR,MAAM,QACN,MAAM,QA0DhB;IAED;;;;OAIG;IACH,uBAHW,MAAM,QAShB;IAED;;;OAGG;IACH,4BAKC;IAED;;;;OAIG;IACH;;;;;;;;MAMC;IAED;;;OAGG;IACH,oBAEC;IAED;;;;;;OAMG;IACH;;;;QAkBC;IAED;;;OAGG;IACH,2BAEC;IAED;;;;;;;;;;;OAWG;IACH,mBAHa,MAAM,CAkBlB;IAED;;;;OAIG;IACH,uCAOC;IAED;;;;;;;;;;;;OAYG;IACH,wBAPW,MAAM,YACN,YAAY,QAkCtB;IAED;;;;;;;;;;OAUG;IACH,kCANW,QAAQ,QAER,MAAM,QACN,MAAM,QAiEhB;IAED;;;;;OAKG;IACH,4GAEC;IAED;;;;;;;;OAQG;IACH,cAHW,MAAM,QACN,MAAM,QAsBhB;IAED;;;;;;;OAOG;IACH,sBALW,MAAM,QACN,MAAM,UACN,MAAM,QAsEhB;IAED;;;;;;OAMG;IACH,uBAsEC;IAED;;;;OAIG;IACH,4BAEC;IAED;;;;;;;;OAQG;IACH,8BALW,MAAM,OACN,YAAY,GACV,MAAM,CAKlB;IAED;;;;;;OAMG;IACH,0BAJW,MAAM,GACJ,sBAAsB,CAgBlC;IAED;;;;;;;;;;;;;OAaG;IACH,uBALW,MAAM,eACN,QAAQ,QACR,MAAM,QAmEhB;IAED;;;;OAIG;IACH,sBAHW,MAAM,QAUhB;IAED;;;OAGG;IACH,2BAMC;CAsBD;0BA//ByB,qBAAqB;iCARd,8BAA8B;yBATtC,2BAA2B;mCAUjB,gCAAgC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* additional import for TypeScript
|
|
3
|
+
* @import {Point} from "./../../../geometries/point.ts";
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* The WebGPU primitive batcher — shape geometry accumulation with the same
|
|
7
|
+
* frozen 24-byte vertex layout and CPU tessellation as the WebGL
|
|
8
|
+
* `PrimitiveBatcher`, addressed purely in the portable topology vocabulary.
|
|
9
|
+
*
|
|
10
|
+
* `uLineWidth` lives in the shared frame-globals uniform block: a width
|
|
11
|
+
* change flushes pending vertices and pushes a fresh dynamic-offset slot,
|
|
12
|
+
* replacing the per-program uniform of the GL backend.
|
|
13
|
+
*
|
|
14
|
+
* The two non-portable engine topologies are emulated in this front end,
|
|
15
|
+
* as `PORTABLE_TOPOLOGIES` documents: `"line-loop"` draws as a strip with
|
|
16
|
+
* an explicit closing vertex, `"triangle-fan"` re-expands on the CPU into
|
|
17
|
+
* a triangle list. No engine path emits either — they only serve direct
|
|
18
|
+
* user calls.
|
|
19
|
+
* @augments WebGPUBatcher
|
|
20
|
+
* @category Rendering
|
|
21
|
+
*/
|
|
22
|
+
export default class WebGPUPrimitiveBatcher extends WebGPUBatcher {
|
|
23
|
+
/**
|
|
24
|
+
* @param {import("../webgpu_renderer.js").default} renderer - the owning renderer
|
|
25
|
+
* @override
|
|
26
|
+
*/
|
|
27
|
+
override init(renderer: import("../webgpu_renderer.js").default, settings: any): void;
|
|
28
|
+
/**
|
|
29
|
+
* Draw an array of vertices with the given topology.
|
|
30
|
+
* @param {string} topology - portable topology name ("point-list", "line-list", "line-strip", "triangle-list", "triangle-strip"; "line-loop" and "triangle-fan" are emulated)
|
|
31
|
+
* @param {Point[]} verts - an array of vertices
|
|
32
|
+
* @param {number} [vertexCount=verts.length] - amount of points defined in the points array
|
|
33
|
+
*/
|
|
34
|
+
drawVertices(topology: string, verts: Point[], vertexCount?: number): void;
|
|
35
|
+
#private;
|
|
36
|
+
}
|
|
37
|
+
import WebGPUBatcher from "./webgpu_batcher.js";
|
|
38
|
+
import type { Point } from "./../../../geometries/point.ts";
|
|
39
|
+
//# sourceMappingURL=primitive_batcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primitive_batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgpu/batchers/primitive_batcher.js"],"names":[],"mappings":"AAMA;;;GAGG;AAEH;;;;;;;;;;;;;;;;GAgBG;AACH;IACC;;;OAGG;IACH,wBAHW,OAAO,uBAAuB,EAAE,OAAO,uBA8BjD;IAED;;;;;OAKG;IACH,uBAJW,MAAM,SACN,KAAK,EAAE,gBACP,MAAM,QAyEhB;;CAsID;0BA7QyB,qBAAqB;2BAIvB,gCAAgC"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The WebGPU quad batcher — textured-quad accumulation with the same
|
|
3
|
+
* frozen 28-byte vertex layout as the WebGL `QuadBatcher` and the same
|
|
4
|
+
* static 6-indices-per-quad pattern.
|
|
5
|
+
*
|
|
6
|
+
* Texture batching is single-texture-per-draw-segment in this first
|
|
7
|
+
* version: a texture (bind group) change flushes the pending quads — the
|
|
8
|
+
* `aTextureId` attribute is written as 0 and kept in the layout so the
|
|
9
|
+
* later multi-texture upgrade (`binding_array` / texture arrays) changes
|
|
10
|
+
* only the group-1 layout and the fragment shader, never the vertex
|
|
11
|
+
* stream. A WebGPU flush is one `writeBuffer` of the pending bytes plus
|
|
12
|
+
* one `drawIndexed`, so the per-change cost is far below the GL
|
|
13
|
+
* full-buffer re-upload this design avoids there.
|
|
14
|
+
* @augments WebGPUBatcher
|
|
15
|
+
* @category Rendering
|
|
16
|
+
*/
|
|
17
|
+
export default class WebGPUQuadBatcher extends WebGPUBatcher {
|
|
18
|
+
/**
|
|
19
|
+
* @param {import("../webgpu_renderer.js").default} renderer - the owning renderer
|
|
20
|
+
* @override
|
|
21
|
+
*/
|
|
22
|
+
override init(renderer: import("../webgpu_renderer.js").default, settings: any): void;
|
|
23
|
+
currentMaterial: any;
|
|
24
|
+
currentEffect: any;
|
|
25
|
+
slotTable: TextureSlotTable | undefined;
|
|
26
|
+
/** @type {{view: GPUTextureView, sampler: GPUSampler}[]} indexed by slot */
|
|
27
|
+
segmentEntries: {
|
|
28
|
+
view: GPUTextureView;
|
|
29
|
+
sampler: GPUSampler;
|
|
30
|
+
}[] | undefined;
|
|
31
|
+
segmentGroup: GPUBindGroup | null | undefined;
|
|
32
|
+
/** @type {Map<string, GPUBindGroup>} */
|
|
33
|
+
composedGroups: Map<string, GPUBindGroup> | undefined;
|
|
34
|
+
resourceIds: WeakMap<object, any> | undefined;
|
|
35
|
+
nextResourceId: number | undefined;
|
|
36
|
+
indexBuffer: GPUBuffer | null | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Add a textured quad. Same contract as the WebGL `QuadBatcher.addQuad`
|
|
39
|
+
* — the CPU corner transform (view matrix + per-renderable depth) is
|
|
40
|
+
* identical, only the texture-binding mechanism differs.
|
|
41
|
+
* @param {object} texture - the texture atlas to draw with
|
|
42
|
+
* @param {number} x - destination x
|
|
43
|
+
* @param {number} y - destination y
|
|
44
|
+
* @param {number} w - destination width
|
|
45
|
+
* @param {number} h - destination height
|
|
46
|
+
* @param {number} u0 - texture UV (u0)
|
|
47
|
+
* @param {number} v0 - texture UV (v0)
|
|
48
|
+
* @param {number} u1 - texture UV (u1)
|
|
49
|
+
* @param {number} v1 - texture UV (v1)
|
|
50
|
+
* @param {number} tint - tint color in UINT32 (argb) format
|
|
51
|
+
* @param {boolean} [reupload=false] - force the source pixels to re-upload (video frames)
|
|
52
|
+
*/
|
|
53
|
+
addQuad(texture: object, x: number, y: number, w: number, h: number, u0: number, v0: number, u1: number, v1: number, tint: number, reupload?: boolean): void;
|
|
54
|
+
/**
|
|
55
|
+
* Resolve a texture to its slot in the pending segment, claiming a new
|
|
56
|
+
* slot (and flushing a full segment) when this (view, sampler) pair is
|
|
57
|
+
* new. The upload rules — same-frame content changes, recycled units,
|
|
58
|
+
* forced video re-uploads — all live in the store's resident-record
|
|
59
|
+
* path, exactly as before.
|
|
60
|
+
* @param {object} texture - the texture atlas to resolve
|
|
61
|
+
* @param {boolean} reupload - force the source pixels to re-upload
|
|
62
|
+
* @returns {number} the slot index written to aTextureId
|
|
63
|
+
* @ignore
|
|
64
|
+
*/
|
|
65
|
+
segmentSlotFor(texture: object, reupload: boolean): number;
|
|
66
|
+
/**
|
|
67
|
+
* a stable id for a GPU resource object (bind-group composition keys)
|
|
68
|
+
* @ignore
|
|
69
|
+
*/
|
|
70
|
+
resourceId(resource: any): any;
|
|
71
|
+
/**
|
|
72
|
+
* The composed group-1 bind group for the pending segment: the claimed
|
|
73
|
+
* slots, with empty slots padded by slot 0 (every declared binding
|
|
74
|
+
* needs a resource; the padding is never selected). Cached by the slot
|
|
75
|
+
* resources' identity, so steady-state segments re-use one group.
|
|
76
|
+
* @returns {GPUBindGroup} the segment's material bind group
|
|
77
|
+
* @ignore
|
|
78
|
+
*/
|
|
79
|
+
composeSegmentGroup(): GPUBindGroup;
|
|
80
|
+
/**
|
|
81
|
+
* start the next segment fresh (the pending one was just recorded)
|
|
82
|
+
* @ignore
|
|
83
|
+
*/
|
|
84
|
+
resetSegment(): void;
|
|
85
|
+
/**
|
|
86
|
+
* Drop every composed segment bind group — each embeds samplers
|
|
87
|
+
* resolved from the default texture filter, so a filter change must
|
|
88
|
+
* rebuild them (the multi-texture counterpart of the texture store's
|
|
89
|
+
* invalidateBindGroups).
|
|
90
|
+
*/
|
|
91
|
+
clearMaterialCache(): void;
|
|
92
|
+
/**
|
|
93
|
+
* Transform and queue the four corners of a quad — shared by the base
|
|
94
|
+
* and lit addQuad paths. Stamps per-sprite depth onto z BEFORE
|
|
95
|
+
* `m.apply` so Camera3d's view matrix (3D R⁻¹ ∘ T(-pos)) fully rotates
|
|
96
|
+
* the vertex; for 2D-only matrices the z column is identity, so the
|
|
97
|
+
* output (x, y) is bit-identical and z passes through. textureId is the
|
|
98
|
+
* quad's segment slot (constant across its four corners); the lit and
|
|
99
|
+
* fast paths pass 0 (single-texture bind groups).
|
|
100
|
+
* @ignore
|
|
101
|
+
*/
|
|
102
|
+
pushQuadVertices(x: any, y: any, w: any, h: any, u0: any, v0: any, u1: any, v1: any, tint: any, textureId?: number): void;
|
|
103
|
+
/**
|
|
104
|
+
* Composite a render target through an effect's pipeline as one
|
|
105
|
+
* screen-space quad — the WebGPU counterpart of the GL blitTexture.
|
|
106
|
+
* The caller ({@link WebGPURenderer#blitEffect}) has already set the
|
|
107
|
+
* screen-space projection; this records the draw with the effect's
|
|
108
|
+
* shader family and group-3 binding (uniforms snapshot-uploaded per
|
|
109
|
+
* bind). An effect without a WGSL realization composites as a plain
|
|
110
|
+
* un-effected blit, so the scene content is never lost.
|
|
111
|
+
* @param {import("../../rendertarget/webgpurendertarget.js").default} source - the render target to sample
|
|
112
|
+
* @param {number} x - destination x
|
|
113
|
+
* @param {number} y - destination y
|
|
114
|
+
* @param {number} w - destination width
|
|
115
|
+
* @param {number} h - destination height
|
|
116
|
+
* @param {ShaderEffect} [effect] - the effect to composite with
|
|
117
|
+
* @param {boolean} [keepBlend=false] - keep the current blend mode (else replace)
|
|
118
|
+
* @ignore
|
|
119
|
+
*/
|
|
120
|
+
blitTexture(source: import("../../rendertarget/webgpurendertarget.js").default, x: number, y: number, w: number, h: number, effect?: ShaderEffect, keepBlend?: boolean): void;
|
|
121
|
+
/**
|
|
122
|
+
* @override
|
|
123
|
+
*/
|
|
124
|
+
override flush(topology: any): void;
|
|
125
|
+
/**
|
|
126
|
+
* whether the pending vertices have a material to draw with — the lit
|
|
127
|
+
* subclass overrides (its material model is the combined color+normal
|
|
128
|
+
* group, not the segment slots)
|
|
129
|
+
* @ignore
|
|
130
|
+
*/
|
|
131
|
+
hasPendingMaterial(): boolean;
|
|
132
|
+
/**
|
|
133
|
+
* record the pending vertices through an effect's pipeline — blending
|
|
134
|
+
* KEPT (the sprite composites live against the backdrop, the defining
|
|
135
|
+
* semantic of the fast path vs the pooled blit)
|
|
136
|
+
* @param {object} binding - the prepared effect binding
|
|
137
|
+
* @ignore
|
|
138
|
+
*/
|
|
139
|
+
flushWithEffect(binding: object): void;
|
|
140
|
+
}
|
|
141
|
+
import WebGPUBatcher from "./webgpu_batcher.js";
|
|
142
|
+
import { TextureSlotTable } from "../../gpu/textureslots.js";
|
|
143
|
+
//# sourceMappingURL=quad_batcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quad_batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgpu/batchers/quad_batcher.js"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;GAeG;AACH;IACC;;;OAGG;IACH,wBAHW,OAAO,uBAAuB,EAAE,OAAO,uBA2FjD;IApDA,qBAA2B;IAM3B,mBAAyB;IASzB,wCASE;IACF,4EAA4E;IAC5E;cADkB,cAAc;iBAAW,UAAU;oBAC7B;IAExB,8CAAwB;IAIxB,wCAAwC;IACxC,sDAA+B;IAE/B,8CAAgC;IAChC,mCAAuB;IAQvB,0CAKE;IAKH;;;;;;;;;;;;;;;OAeG;IACH,iBAZW,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QACN,MAAM,aACN,OAAO,QAyEjB;IAED;;;;;;;;;;OAUG;IACH,wBALW,MAAM,YACN,OAAO,GACL,MAAM,CAyBlB;IAED;;;OAGG;IACH,+BAOC;IAED;;;;;;;OAOG;IACH,uBAHa,YAAY,CA+BxB;IAED;;;OAGG;IACH,qBAMC;IAED;;;;;OAKG;IACH,2BAGC;IAED;;;;;;;;;OASG;IACH,0HAgBC;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,oBATW,OAAO,0CAA0C,EAAE,OAAO,KAC1D,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,WACN,YAAY,cACZ,OAAO,QAyDjB;IAqBD;;OAEG;IACH,oCA6BC;IAED;;;;;OAKG;IACH,8BAEC;IAED;;;;;;OAMG;IACH,yBAHW,MAAM,QAuChB;CAwBD;0BA9hByB,qBAAqB;iCAHd,2BAA2B"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The base WebGPU Batcher — realizes the backend-neutral {@link Batcher}
|
|
3
|
+
* lifecycle (`init` / `bind` / `unbind` / `flush` / `reset` / `destroy`,
|
|
4
|
+
* driven by `renderer.addBatcher` / `setBatcher`) on a
|
|
5
|
+
* `GPURenderPassEncoder` instead of GL state. Custom WebGPU batchers
|
|
6
|
+
* extend this class.
|
|
7
|
+
*
|
|
8
|
+
* A "flush" here is one `queue.writeBuffer` of the pending vertex bytes
|
|
9
|
+
* into a fresh region of the renderer's per-frame buffer arena, plus one
|
|
10
|
+
* draw recorded into the frame's open pass — nothing is submitted until
|
|
11
|
+
* the frame ends. Attribute layouts are declared in the backend-neutral
|
|
12
|
+
* vocabulary of `src/video/gpu/vertexformat.ts` and consumed declaratively
|
|
13
|
+
* into the pipeline's `GPUVertexBufferLayout` (#1492) — no enum bridge.
|
|
14
|
+
* @augments Batcher
|
|
15
|
+
* @category Rendering
|
|
16
|
+
*/
|
|
17
|
+
export default class WebGPUBatcher extends Batcher {
|
|
18
|
+
/**
|
|
19
|
+
* @param {import("../webgpu_renderer.js").default} renderer - the owning renderer
|
|
20
|
+
* @param {object} [settings] - batcher settings (see {@link WebGPUBatcher#init})
|
|
21
|
+
*/
|
|
22
|
+
constructor(renderer: import("../webgpu_renderer.js").default, settings?: object);
|
|
23
|
+
/**
|
|
24
|
+
* Initialize (or re-initialize after device loss) this batcher.
|
|
25
|
+
* @param {import("../webgpu_renderer.js").default} renderer - the owning renderer
|
|
26
|
+
* @param {object} [settings] - batcher settings
|
|
27
|
+
* @param {object[]} [settings.attributes] - neutral attribute descriptors
|
|
28
|
+
* @param {string} [settings.shaderKey] - pipeline-cache shader family
|
|
29
|
+
* @param {string} [settings.topology] - default portable topology
|
|
30
|
+
* @param {number} [settings.maxVertices] - staging capacity in vertices
|
|
31
|
+
*/
|
|
32
|
+
init(renderer: import("../webgpu_renderer.js").default, settings?: {
|
|
33
|
+
attributes?: object[] | undefined;
|
|
34
|
+
shaderKey?: string | undefined;
|
|
35
|
+
topology?: string | undefined;
|
|
36
|
+
maxVertices?: number | undefined;
|
|
37
|
+
}): void;
|
|
38
|
+
device: GPUDevice | undefined;
|
|
39
|
+
shaderKey: string | undefined;
|
|
40
|
+
topology: string | undefined;
|
|
41
|
+
attributes: {
|
|
42
|
+
name: any;
|
|
43
|
+
format: any;
|
|
44
|
+
offset: any;
|
|
45
|
+
bytes: number;
|
|
46
|
+
}[] | undefined;
|
|
47
|
+
stride: any;
|
|
48
|
+
vertexSize: number | undefined;
|
|
49
|
+
vertexData: VertexArrayBuffer | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* per-draw refresh hook (pass-scoped state that `bind()` cannot own
|
|
52
|
+
* because `setBatcher` early-returns when already current)
|
|
53
|
+
*/
|
|
54
|
+
updatePassState(): void;
|
|
55
|
+
/**
|
|
56
|
+
* record the pending vertices as one draw in the frame's open pass
|
|
57
|
+
* @param {string} [topology] - override the batcher's default topology
|
|
58
|
+
*/
|
|
59
|
+
flush(topology?: string): void;
|
|
60
|
+
/**
|
|
61
|
+
* record the actual draw call — non-indexed by default; the quad
|
|
62
|
+
* batcher overrides with its indexed 6-per-quad pattern
|
|
63
|
+
* @param {GPURenderPassEncoder} pass - the open pass
|
|
64
|
+
* @param {number} vertexCount - pending vertex count
|
|
65
|
+
*/
|
|
66
|
+
recordDraw(pass: GPURenderPassEncoder, vertexCount: number): void;
|
|
67
|
+
}
|
|
68
|
+
import { Batcher } from "../../gpu/batcher.js";
|
|
69
|
+
import VertexArrayBuffer from "../../buffer/vertex.js";
|
|
70
|
+
//# sourceMappingURL=webgpu_batcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgpu_batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgpu/batchers/webgpu_batcher.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;GAeG;AACH;IACC;;;OAGG;IACH,sBAHW,OAAO,uBAAuB,EAAE,OAAO,aACvC,MAAM,EAKhB;IAED;;;;;;;;OAQG;IACH,eAPW,OAAO,uBAAuB,EAAE,OAAO,aAE/C;QAA4B,UAAU;QACZ,SAAS;QACT,QAAQ;QACR,WAAW;KACvC,QAqDA;IAlDA,8BAA6B;IAG5B,8BAAmC;IACnC,6BAAoD;IAKpD;;;;;oBAQE;IAEF,YAAsC;IACtC,+BAA8D;IAE9D,0CAGC;IAuCH;;;OAGG;IACH,wBAAoB;IAEpB;;;OAGG;IACH,iBAFW,MAAM,QAuChB;IAED;;;;;OAKG;IACH,iBAHW,oBAAoB,eACpB,MAAM,QAIhB;CAeD;wBAhL6C,sBAAsB;8BADtC,wBAAwB"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-frame GPU buffer arena — a bump allocator over a persistent list of
|
|
3
|
+
* fixed-size `GPUBuffer` pages.
|
|
4
|
+
*
|
|
5
|
+
* Why an arena: melonJS flushes many times per frame (texture change, blend
|
|
6
|
+
* change, scissor change, …). Under WebGL each flush re-uploads the shared
|
|
7
|
+
* vertex buffer; under WebGPU all draw commands of a frame are recorded
|
|
8
|
+
* first and execute at `queue.submit()` time, so every flush must write its
|
|
9
|
+
* vertices into a region **no later flush overwrites** — `queue.writeBuffer`
|
|
10
|
+
* data lands before the submitted commands run, and two flushes sharing one
|
|
11
|
+
* region would have the second write clobber the first before either draw
|
|
12
|
+
* executes.
|
|
13
|
+
*
|
|
14
|
+
* Why a page *list* rather than one growable buffer: draw commands already
|
|
15
|
+
* recorded against earlier pages must stay valid; replacing a buffer
|
|
16
|
+
* mid-frame would invalidate them. Pages persist across frames; `reset()`
|
|
17
|
+
* just rewinds the bump pointer.
|
|
18
|
+
* @ignore
|
|
19
|
+
*/
|
|
20
|
+
export default class WebGPUBufferArena {
|
|
21
|
+
/**
|
|
22
|
+
* @param {GPUDevice} device - the device to allocate pages on
|
|
23
|
+
* @param {object} [options] - arena options
|
|
24
|
+
* @param {number} [options.pageSize=1048576] - byte size of each page
|
|
25
|
+
* @param {number} [options.usage] - GPUBufferUsage flags for the pages
|
|
26
|
+
* @param {string} [options.label] - debug label prefix for the pages
|
|
27
|
+
*/
|
|
28
|
+
constructor(device: GPUDevice, options?: {
|
|
29
|
+
pageSize?: number | undefined;
|
|
30
|
+
usage?: number | undefined;
|
|
31
|
+
label?: string | undefined;
|
|
32
|
+
});
|
|
33
|
+
device: GPUDevice;
|
|
34
|
+
pageSize: number;
|
|
35
|
+
usage: number;
|
|
36
|
+
label: string;
|
|
37
|
+
/** @type {GPUBuffer[]} */
|
|
38
|
+
pages: GPUBuffer[];
|
|
39
|
+
pageIndex: number;
|
|
40
|
+
offset: number;
|
|
41
|
+
/**
|
|
42
|
+
* rewind the arena — called once per frame, before any allocation
|
|
43
|
+
*/
|
|
44
|
+
reset(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Reserve `byteLength` bytes and return where they live. The region is
|
|
47
|
+
* valid until the next `reset()`.
|
|
48
|
+
* @param {number} byteLength - bytes to reserve (must fit in one page)
|
|
49
|
+
* @param {number} [alignment=4] - required offset alignment (a power of
|
|
50
|
+
* two; effect uniform snapshots pass the device's
|
|
51
|
+
* `minUniformBufferOffsetAlignment` so the region can serve as a
|
|
52
|
+
* dynamic bind-group offset)
|
|
53
|
+
* @returns {{buffer: GPUBuffer, offset: number}} the reserved region
|
|
54
|
+
*/
|
|
55
|
+
alloc(byteLength: number, alignment?: number): {
|
|
56
|
+
buffer: GPUBuffer;
|
|
57
|
+
offset: number;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* release every page (device loss / renderer destroy)
|
|
61
|
+
*/
|
|
62
|
+
destroy(): void;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=arena.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arena.d.ts","sourceRoot":"","sources":["../../../../src/video/webgpu/buffer/arena.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH;IACC;;;;;;OAMG;IACH,oBANW,SAAS,YAEjB;QAAyB,QAAQ;QACR,KAAK;QACL,KAAK;KAChC,EAWA;IATA,kBAAoB;IACpB,iBAA2C;IAC3C,cACiE;IACjE,cAA6C;IAC7C,0BAA0B;IAC1B,OADW,SAAS,EAAE,CACP;IACf,kBAAkB;IAClB,eAAe;IAGhB;;OAEG;IACH,cAGC;IAED;;;;;;;;;OASG;IACH,kBAPW,MAAM,cACN,MAAM,GAIJ;QAAC,MAAM,EAAE,SAAS,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,CA8B/C;IAED;;OAEG;IACH,gBAOC;CACD"}
|