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,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The WebGPU twin of the GL `WebGLInstanceBuffer`: one `InstancedMesh`'s
|
|
3
|
+
* per-instance records resident on the GPU, bound as a second vertex buffer
|
|
4
|
+
* whose layout steps once per instance.
|
|
5
|
+
*
|
|
6
|
+
* The same two queue-ordering laws that shape `WebGPURetainedGeometry`
|
|
7
|
+
* apply, and matter more here because instance records change far more often
|
|
8
|
+
* than geometry does:
|
|
9
|
+
*
|
|
10
|
+
* 1. `queue.writeBuffer` executes before **every** draw recorded this frame.
|
|
11
|
+
* So editing an instance on a mesh that has already drawn this frame — a
|
|
12
|
+
* second camera, a mid-frame animation step — must land in a FRESH
|
|
13
|
+
* buffer, or the earlier draw would retroactively show the new placement.
|
|
14
|
+
* 2. Destroying a buffer referenced by recorded draws fails the whole
|
|
15
|
+
* submit, so a replaced buffer retires through `renderer.retireBuffer`
|
|
16
|
+
* and dies after the frame's submit.
|
|
17
|
+
*
|
|
18
|
+
* Within a frame that has not yet drawn, an edit is a partial
|
|
19
|
+
* `writeBuffer` covering only the dirty span — moving one tree in a forest
|
|
20
|
+
* of five thousand writes 48 bytes.
|
|
21
|
+
* @ignore
|
|
22
|
+
*/
|
|
23
|
+
export default class WebGPUInstanceBuffer {
|
|
24
|
+
/**
|
|
25
|
+
* @param {import("../webgpu_renderer.js").default} renderer - the owning renderer
|
|
26
|
+
*/
|
|
27
|
+
constructor(renderer: import("../webgpu_renderer.js").default);
|
|
28
|
+
renderer: import("../webgpu_renderer.js").default;
|
|
29
|
+
/** @type {GPUBuffer|null} */
|
|
30
|
+
buffer: GPUBuffer | null;
|
|
31
|
+
/** allocated capacity in bytes @type {number} */
|
|
32
|
+
capacity: number;
|
|
33
|
+
/** the frame a draw was last recorded against this buffer @type {number} */
|
|
34
|
+
lastDrawnFrameId: number;
|
|
35
|
+
/**
|
|
36
|
+
* Push the dirty span of `data` to the GPU, reallocating when the record
|
|
37
|
+
* set outgrew the allocation or when this buffer has already been drawn
|
|
38
|
+
* from this frame.
|
|
39
|
+
* @param {Float32Array} data - the CPU-side instance records
|
|
40
|
+
* @param {number} firstFloat - first dirty float offset (inclusive)
|
|
41
|
+
* @param {number} floatCount - number of dirty floats, 0 when clean
|
|
42
|
+
* @param {number} usedBytes - bytes of `data` actually in use
|
|
43
|
+
*/
|
|
44
|
+
upload(data: Float32Array, firstFloat: number, floatCount: number, usedBytes: number): void;
|
|
45
|
+
/**
|
|
46
|
+
* One `queue.writeBuffer`, in BYTES throughout.
|
|
47
|
+
*
|
|
48
|
+
* `writeBuffer`'s `dataOffset` and `size` are counted in *elements* when
|
|
49
|
+
* `data` is a TypedArray and in *bytes* otherwise — an ambiguity that
|
|
50
|
+
* silently changes meaning if the staging array's type ever changes. The
|
|
51
|
+
* engine's other GPU uploads all pass a `Uint8Array` view with byte
|
|
52
|
+
* counts, so this does too: one convention, no element/byte confusion.
|
|
53
|
+
* @param {number} bufferOffset - destination byte offset
|
|
54
|
+
* @param {number} byteOffset - source byte offset into `data`
|
|
55
|
+
* @param {number} byteLength - bytes to copy
|
|
56
|
+
* @param {Float32Array} data - the CPU-side instance records
|
|
57
|
+
* @ignore
|
|
58
|
+
*/
|
|
59
|
+
write(bufferOffset: number, byteOffset: number, byteLength: number, data: Float32Array): void;
|
|
60
|
+
/**
|
|
61
|
+
* Release the GPU buffer (retired when a frame is recording).
|
|
62
|
+
*/
|
|
63
|
+
destroy(): void;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=instance_buffer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instance_buffer.d.ts","sourceRoot":"","sources":["../../../../src/video/webgpu/buffer/instance_buffer.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;IACC;;OAEG;IACH,sBAFW,OAAO,uBAAuB,EAAE,OAAO,EAUjD;IAPA,kDAAwB;IACxB,6BAA6B;IAC7B,QADW,SAAS,GAAC,IAAI,CACP;IAClB,iDAAiD;IACjD,UADuC,MAAM,CAC5B;IACjB,4EAA4E;IAC5E,kBADkE,MAAM,CAC9C;IAG3B;;;;;;;;OAQG;IACH,aALW,YAAY,cACZ,MAAM,cACN,MAAM,aACN,MAAM,QA0ChB;IAED;;;;;;;;;;;;;OAaG;IACH,oBANW,MAAM,cACN,MAAM,cACN,MAAM,QACN,YAAY,QAWtB;IAED;;OAEG;IACH,gBAOC;CACD"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The WebGPU twin of the GL `RetainedGeometry`: one mesh's model-space
|
|
3
|
+
* geometry resident on the GPU — a vertex buffer and an index buffer,
|
|
4
|
+
* uploaded on geometry-version change and bound per draw (`setVertexBuffer`
|
|
5
|
+
* / `setIndexBuffer`; there is no VAO to capture, binding is explicit and
|
|
6
|
+
* cheap under this backend).
|
|
7
|
+
*
|
|
8
|
+
* The two queue-ordering laws shape the upload rules:
|
|
9
|
+
* 1. `queue.writeBuffer` executes before EVERY draw recorded this frame —
|
|
10
|
+
* so a version bump on a mesh that has already drawn this frame
|
|
11
|
+
* (Sprite3d animation UVs, a second camera) must land in FRESH buffers,
|
|
12
|
+
* or the earlier draw would retroactively show the new geometry.
|
|
13
|
+
* 2. destroying a buffer referenced by recorded draws fails the whole
|
|
14
|
+
* submit — replaced buffers retire through `renderer.retireBuffer` and
|
|
15
|
+
* die after the frame's submit.
|
|
16
|
+
* @ignore
|
|
17
|
+
*/
|
|
18
|
+
export default class WebGPURetainedGeometry {
|
|
19
|
+
/**
|
|
20
|
+
* @param {import("../webgpu_renderer.js").default} renderer - the owning renderer
|
|
21
|
+
*/
|
|
22
|
+
constructor(renderer: import("../webgpu_renderer.js").default);
|
|
23
|
+
renderer: import("../webgpu_renderer.js").default;
|
|
24
|
+
/** @type {GPUBuffer|null} */
|
|
25
|
+
vertexBuffer: GPUBuffer | null;
|
|
26
|
+
/** @type {GPUBuffer|null} */
|
|
27
|
+
indexBuffer: GPUBuffer | null;
|
|
28
|
+
/** @type {"uint16"|"uint32"} */
|
|
29
|
+
indexFormat: "uint16" | "uint32";
|
|
30
|
+
indexCount: number;
|
|
31
|
+
uploadedVersion: number;
|
|
32
|
+
lastDrawnFrameId: number;
|
|
33
|
+
vertexCapacity: number;
|
|
34
|
+
indexCapacity: number;
|
|
35
|
+
/**
|
|
36
|
+
* Upload (or re-upload) the interleaved vertex data and indices.
|
|
37
|
+
* @param {Float32Array} vertexData - interleaved data scratch
|
|
38
|
+
* @param {number} floatCount - number of floats to upload
|
|
39
|
+
* @param {Uint16Array|Uint32Array} indices - the mesh's authored indices
|
|
40
|
+
* @param {number} version - the mesh's geometry version being uploaded
|
|
41
|
+
*/
|
|
42
|
+
upload(vertexData: Float32Array, floatCount: number, indices: Uint16Array | Uint32Array, version: number): void;
|
|
43
|
+
/**
|
|
44
|
+
* retire both buffers (frame-safe) without resetting the version — the
|
|
45
|
+
* shared tail of re-allocation and destruction
|
|
46
|
+
* @ignore
|
|
47
|
+
*/
|
|
48
|
+
releaseBuffers(): void;
|
|
49
|
+
/**
|
|
50
|
+
* Release the GPU buffers. Idempotent — a destroyed geometry object
|
|
51
|
+
* simply re-uploads if ever used again.
|
|
52
|
+
*/
|
|
53
|
+
destroy(): void;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=retained_geometry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retained_geometry.d.ts","sourceRoot":"","sources":["../../../../src/video/webgpu/buffer/retained_geometry.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;GAgBG;AACH;IACC;;OAEG;IACH,sBAFW,OAAO,uBAAuB,EAAE,OAAO,EAmBjD;IAhBA,kDAAwB;IACxB,6BAA6B;IAC7B,cADW,SAAS,GAAC,IAAI,CACD;IACxB,6BAA6B;IAC7B,aADW,SAAS,GAAC,IAAI,CACF;IACvB,gCAAgC;IAChC,aADW,QAAQ,GAAC,QAAQ,CACD;IAC3B,mBAAmB;IAEnB,wBAAyB;IAGzB,yBAA0B;IAE1B,uBAAuB;IACvB,sBAAsB;IAGvB;;;;;;OAMG;IACH,mBALW,YAAY,cACZ,MAAM,WACN,WAAW,GAAC,WAAW,WACvB,MAAM,QA+DhB;IAED;;;;OAIG;IACH,uBAWC;IAED;;;OAGG;IACH,gBAKC;CACD"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-frame uniform ring — slot-granular bump allocation over persistent
|
|
3
|
+
* uniform-buffer pages, with one cached dynamic-offset bind group per page
|
|
4
|
+
* and per layout.
|
|
5
|
+
*
|
|
6
|
+
* This is the WebGPU realization of the "frame globals in one uniform
|
|
7
|
+
* buffer, bound once" shape (#1555): projection and line width live in
|
|
8
|
+
* group 0, and a *new slot* is pushed whenever either changes mid-frame
|
|
9
|
+
* (floating containers swap the projection around their children), so every
|
|
10
|
+
* recorded draw keeps the dynamic offset that was current when its vertices
|
|
11
|
+
* were queued. The mid-frame `clearColor` pipeline shares the same pages
|
|
12
|
+
* through its own layout/bind-group pair.
|
|
13
|
+
* @ignore
|
|
14
|
+
*/
|
|
15
|
+
export default class WebGPUUniformRing {
|
|
16
|
+
/**
|
|
17
|
+
* @param {GPUDevice} device - the device to allocate on
|
|
18
|
+
* @param {GPUBindGroupLayout} frameLayout - group-0 layout of the draw pipelines
|
|
19
|
+
* @param {GPUBindGroupLayout} clearLayout - group-0 layout of the clear pipeline
|
|
20
|
+
*/
|
|
21
|
+
constructor(device: GPUDevice, frameLayout: GPUBindGroupLayout, clearLayout: GPUBindGroupLayout);
|
|
22
|
+
device: GPUDevice;
|
|
23
|
+
frameLayout: GPUBindGroupLayout;
|
|
24
|
+
clearLayout: GPUBindGroupLayout;
|
|
25
|
+
slotSize: number;
|
|
26
|
+
slotsPerPage: number;
|
|
27
|
+
pageSize: number;
|
|
28
|
+
/** @type {{buffer: GPUBuffer, frameGroup: GPUBindGroup, clearGroup: GPUBindGroup}[]} */
|
|
29
|
+
pages: {
|
|
30
|
+
buffer: GPUBuffer;
|
|
31
|
+
frameGroup: GPUBindGroup;
|
|
32
|
+
clearGroup: GPUBindGroup;
|
|
33
|
+
}[];
|
|
34
|
+
slot: number;
|
|
35
|
+
scratch: Float32Array<ArrayBuffer>;
|
|
36
|
+
/**
|
|
37
|
+
* rewind the ring — called once per frame
|
|
38
|
+
*/
|
|
39
|
+
reset(): void;
|
|
40
|
+
/**
|
|
41
|
+
* Write a frame-globals slot (projection matrix + line width).
|
|
42
|
+
* @param {import("../../math/matrix3d.ts").Matrix3d} projection - the projection matrix
|
|
43
|
+
* @param {number} lineWidth - current stroke line width
|
|
44
|
+
* @returns {{bindGroup: GPUBindGroup, dynamicOffset: number}} the binding for subsequent draws
|
|
45
|
+
*/
|
|
46
|
+
pushFrameGlobals(projection: any, lineWidth: number): {
|
|
47
|
+
bindGroup: GPUBindGroup;
|
|
48
|
+
dynamicOffset: number;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Write a clear-color slot.
|
|
52
|
+
* @param {number} r - red (0..1)
|
|
53
|
+
* @param {number} g - green (0..1)
|
|
54
|
+
* @param {number} b - blue (0..1)
|
|
55
|
+
* @param {number} a - alpha (0..1)
|
|
56
|
+
* @returns {{bindGroup: GPUBindGroup, dynamicOffset: number}} the binding for the clear draw
|
|
57
|
+
*/
|
|
58
|
+
pushClearColor(r: number, g: number, b: number, a: number): {
|
|
59
|
+
bindGroup: GPUBindGroup;
|
|
60
|
+
dynamicOffset: number;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* release every page (device loss / renderer destroy)
|
|
64
|
+
*/
|
|
65
|
+
destroy(): void;
|
|
66
|
+
#private;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=uniformring.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uniformring.d.ts","sourceRoot":"","sources":["../../../../src/video/webgpu/buffer/uniformring.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;GAaG;AACH;IACC;;;;OAIG;IACH,oBAJW,SAAS,eACT,kBAAkB,eAClB,kBAAkB,EAiB5B;IAdA,kBAAoB;IACpB,gCAA8B;IAC9B,gCAA8B;IAC9B,iBAGC;IACD,qBAAsB;IACtB,iBAAiD;IACjD,wFAAwF;IACxF,OADW;QAAC,MAAM,EAAE,SAAS,CAAC;QAAC,UAAU,EAAE,YAAY,CAAC;QAAC,UAAU,EAAE,YAAY,CAAA;KAAC,EAAE,CACrE;IACf,aAAa;IAEb,mCAAuD;IAGxD;;OAEG;IACH,cAEC;IAyCD;;;;;OAKG;IACH,6CAHW,MAAM,GACJ;QAAC,SAAS,EAAE,YAAY,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAC,CAe5D;IAED;;;;;;;OAOG;IACH,kBANW,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,GACJ;QAAC,SAAS,EAAE,YAAY,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAC,CAiB5D;IAED;;OAEG;IACH,gBAMC;;CACD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prepare an effect for a draw: ensure device state, snapshot the uniform
|
|
3
|
+
* mirror(s) into the effect uniform arena, and return the pipeline family
|
|
4
|
+
* key plus the group-3 binding for the pass.
|
|
5
|
+
* @param {import("./webgpu_renderer.js").default} renderer - the renderer
|
|
6
|
+
* @param {import("../effects/shadereffect.js").default} effect - the effect to bind
|
|
7
|
+
* @returns {{key: string, hasEffectGroup: boolean, bindGroup: GPUBindGroup|null, dynamicOffsets: number[]}|null}
|
|
8
|
+
* the binding, or null when the effect has no WGSL realization
|
|
9
|
+
* @ignore
|
|
10
|
+
*/
|
|
11
|
+
export function prepareEffectBinding(renderer: import("./webgpu_renderer.js").default, effect: import("../effects/shadereffect.js").default): {
|
|
12
|
+
key: string;
|
|
13
|
+
hasEffectGroup: boolean;
|
|
14
|
+
bindGroup: GPUBindGroup | null;
|
|
15
|
+
dynamicOffsets: number[];
|
|
16
|
+
} | null;
|
|
17
|
+
//# sourceMappingURL=effect_binding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effect_binding.d.ts","sourceRoot":"","sources":["../../../src/video/webgpu/effect_binding.js"],"names":[],"mappings":"AA6OA;;;;;;;;;GASG;AACH,+CANW,OAAO,sBAAsB,EAAE,OAAO,UACtC,OAAO,4BAA4B,EAAE,OAAO,GAC1C;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,YAAY,GAAC,IAAI,CAAC;IAAC,cAAc,EAAE,MAAM,EAAE,CAAA;CAAC,GAAC,IAAI,CA+I/G"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Frozen bind-group conventions for the WebGPU backend.
|
|
3
|
+
*
|
|
4
|
+
* WebGPU bind-group indices are a per-pipeline-layout namespace with a hard
|
|
5
|
+
* cap of four groups, so — unlike WebGL's context-wide uniform-buffer
|
|
6
|
+
* binding points, which the renderer hands out from a monotonic counter
|
|
7
|
+
* (`reserveUniformBindingPoint`) — the collision-proofing here is a frozen
|
|
8
|
+
* convention: every pipeline in the backend agrees on what each group index
|
|
9
|
+
* means, and additions claim the reserved slots below instead of inventing
|
|
10
|
+
* their own.
|
|
11
|
+
*
|
|
12
|
+
* - group 0 — frame globals: one dynamic-offset uniform binding shared by
|
|
13
|
+
* every draw (projection matrix + line width), served by the uniform
|
|
14
|
+
* ring. The clear pipeline substitutes its own group-0 layout (a bare
|
|
15
|
+
* color) over the same ring.
|
|
16
|
+
* - group 1 — material: texture view + sampler (quad pipeline).
|
|
17
|
+
* - group 2 — reserved: lights (the std140 light block ports here).
|
|
18
|
+
* - group 3 — reserved: per-effect extras (ShaderEffect-WGSL, post FX).
|
|
19
|
+
* @ignore
|
|
20
|
+
*/
|
|
21
|
+
export const GROUP_FRAME: 0;
|
|
22
|
+
export const GROUP_MATERIAL: 1;
|
|
23
|
+
export const GROUP_LIGHTS: 2;
|
|
24
|
+
export const GROUP_EFFECT: 3;
|
|
25
|
+
/**
|
|
26
|
+
* Byte size of the frame-globals uniform block:
|
|
27
|
+
* mat4x4<f32> projection (64) + f32 lineWidth (4) + pad to 16 → 80.
|
|
28
|
+
* @ignore
|
|
29
|
+
*/
|
|
30
|
+
export const FRAME_UNIFORM_SIZE: 80;
|
|
31
|
+
/**
|
|
32
|
+
* Byte size of the clear-color uniform block: vec4<f32> → 16.
|
|
33
|
+
* @ignore
|
|
34
|
+
*/
|
|
35
|
+
export const CLEAR_UNIFORM_SIZE: 16;
|
|
36
|
+
//# sourceMappingURL=bindgroups.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bindgroups.d.ts","sourceRoot":"","sources":["../../../../src/video/webgpu/pipeline/bindgroups.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,0BAA2B,CAAC,CAAC;AAC7B,6BAA8B,CAAC,CAAC;AAChC,2BAA4B,CAAC,CAAC;AAC9B,2BAA4B,CAAC,CAAC;AAE9B;;;;GAIG;AACH,iCAAkC,EAAE,CAAC;AAErC;;;GAGG;AACH,iCAAkC,EAAE,CAAC"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalize a user-facing blend-mode string to a cache-key token — the
|
|
3
|
+
* same collapsing the WebGL backend applies ("add"/"lighter" → additive,
|
|
4
|
+
* unknown → normal).
|
|
5
|
+
* @param {string} mode - blend mode as set through `setBlendMode`
|
|
6
|
+
* @returns {string} normalized token
|
|
7
|
+
* @ignore
|
|
8
|
+
*/
|
|
9
|
+
export function normalizeBlendMode(mode: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Texture slots per quad draw segment — the quad family batches quads
|
|
12
|
+
* across up to this many distinct textures before a flush is forced (the
|
|
13
|
+
* GL sampler-ladder equivalent). 8 texture + 8 sampler bindings stays
|
|
14
|
+
* comfortably inside WebGPU's base limits (16 sampled textures / 16
|
|
15
|
+
* samplers per stage) with headroom for the effect families' samplers.
|
|
16
|
+
* @ignore
|
|
17
|
+
*/
|
|
18
|
+
export const MAX_QUAD_TEXTURES: 8;
|
|
19
|
+
/**
|
|
20
|
+
* The depth-stencil attachment format every pass and every pipeline of this
|
|
21
|
+
* backend declares. Attached from day one — masks use the stencil half now,
|
|
22
|
+
* meshes will use the depth half — because a pipeline's depthStencil state
|
|
23
|
+
* must match the pass attachment, and adding it later would invalidate
|
|
24
|
+
* every cached pipeline.
|
|
25
|
+
* @ignore
|
|
26
|
+
*/
|
|
27
|
+
export const DEPTH_STENCIL_FORMAT: "depth24plus-stencil8";
|
|
28
|
+
/**
|
|
29
|
+
* Lazily-built cache of `GPURenderPipeline`s for the WebGPU backend, keyed
|
|
30
|
+
* by everything that is pipeline state under WebGPU but dynamic state under
|
|
31
|
+
* GL: shader family, topology, blend mode, premultiplied-alpha flag,
|
|
32
|
+
* stencil mode (and, held constant today, the canvas format and sample
|
|
33
|
+
* count — both stay in the key so render targets and MSAA slot in later
|
|
34
|
+
* without a reshape).
|
|
35
|
+
*
|
|
36
|
+
* Also owns the shader modules, bind-group layouts and pipeline layouts —
|
|
37
|
+
* the objects every pipeline shares and the uniform ring / texture store
|
|
38
|
+
* build their bind groups against.
|
|
39
|
+
* @ignore
|
|
40
|
+
*/
|
|
41
|
+
export default class WebGPUPipelineCache {
|
|
42
|
+
/**
|
|
43
|
+
* monotonic construction counter backing {@link WebGPUPipelineCache#epoch}
|
|
44
|
+
* @ignore
|
|
45
|
+
*/
|
|
46
|
+
static epochCounter: number;
|
|
47
|
+
/**
|
|
48
|
+
* @param {GPUDevice} device - the device to build pipelines on
|
|
49
|
+
* @param {string} format - the canvas color format (preferredFormat)
|
|
50
|
+
*/
|
|
51
|
+
constructor(device: GPUDevice, format: string);
|
|
52
|
+
device: GPUDevice;
|
|
53
|
+
format: string;
|
|
54
|
+
sampleCount: number;
|
|
55
|
+
/** @type {Map<string, GPURenderPipeline>} */
|
|
56
|
+
pipelines: Map<string, GPURenderPipeline>;
|
|
57
|
+
/** @type {Map<string, {stride: number, attributes: object[]}>} */
|
|
58
|
+
vertexLayouts: Map<string, {
|
|
59
|
+
stride: number;
|
|
60
|
+
attributes: object[];
|
|
61
|
+
}>;
|
|
62
|
+
frameLayout: GPUBindGroupLayout;
|
|
63
|
+
clearFrameLayout: GPUBindGroupLayout;
|
|
64
|
+
materialLayout: GPUBindGroupLayout;
|
|
65
|
+
meshMaterialLayout: GPUBindGroupLayout;
|
|
66
|
+
multiMaterialLayout: GPUBindGroupLayout;
|
|
67
|
+
modules: {
|
|
68
|
+
quad: GPUShaderModule;
|
|
69
|
+
blit: GPUShaderModule;
|
|
70
|
+
primitive: GPUShaderModule;
|
|
71
|
+
clear: GPUShaderModule;
|
|
72
|
+
};
|
|
73
|
+
pipelineLayouts: {
|
|
74
|
+
quad: GPUPipelineLayout;
|
|
75
|
+
blit: GPUPipelineLayout;
|
|
76
|
+
primitive: GPUPipelineLayout;
|
|
77
|
+
clear: GPUPipelineLayout;
|
|
78
|
+
};
|
|
79
|
+
/** @type {Map<string, string>} moduleText → family key */
|
|
80
|
+
registeredModules: Map<string, string>;
|
|
81
|
+
modulesBySource: Map<any, any>;
|
|
82
|
+
/** @type {Map<string, {stride: number, attributes: object[]}>} family key → vertex-layout alias */
|
|
83
|
+
vertexLayoutAliases: Map<string, {
|
|
84
|
+
stride: number;
|
|
85
|
+
attributes: object[];
|
|
86
|
+
}>;
|
|
87
|
+
/** @type {Map<string, GPUBindGroupLayout>} shape signature → group-3 layout */
|
|
88
|
+
effectLayouts: Map<string, GPUBindGroupLayout>;
|
|
89
|
+
emptyLayout: GPUBindGroupLayout;
|
|
90
|
+
emptyBindGroup: GPUBindGroup;
|
|
91
|
+
/**
|
|
92
|
+
* Device generation this cache belongs to — bumped once per cache
|
|
93
|
+
* construction. Consumers holding device-scoped objects built
|
|
94
|
+
* against this cache (effect modules, bind groups) compare their
|
|
95
|
+
* recorded epoch and lazily rebuild after a device loss.
|
|
96
|
+
* @type {number}
|
|
97
|
+
*/
|
|
98
|
+
epoch: number;
|
|
99
|
+
/**
|
|
100
|
+
* Register a shader family beyond the built-in three, routing it through
|
|
101
|
+
* the same keyed {@link WebGPUPipelineCache#get} lookup. Identical module
|
|
102
|
+
* text registers once — the returned key is stable per text, so clones
|
|
103
|
+
* and same-body effects share the module and every pipeline built on it.
|
|
104
|
+
* @param {string} code - the complete WGSL module text
|
|
105
|
+
* @param {object} [options] - family options
|
|
106
|
+
* @param {GPUBindGroupLayout[]} [options.bindGroupLayouts] - full positional
|
|
107
|
+
* bind-group-layout list (defaults to `[frameLayout, materialLayout]`)
|
|
108
|
+
* @param {string} [options.vertexLayoutKey="quad"] - reuse a registered
|
|
109
|
+
* vertex layout under this family (the effect blit rides the quad layout)
|
|
110
|
+
* @param {string} [options.label] - debug label for the shader module
|
|
111
|
+
* @returns {string} the family key to pass to {@link WebGPUPipelineCache#get}
|
|
112
|
+
*/
|
|
113
|
+
registerShader(code: string, options?: {
|
|
114
|
+
bindGroupLayouts?: GPUBindGroupLayout[] | undefined;
|
|
115
|
+
vertexLayoutKey?: string | undefined;
|
|
116
|
+
label?: string | undefined;
|
|
117
|
+
}): string;
|
|
118
|
+
/**
|
|
119
|
+
* Fetch (building on first use) the group-3 bind-group layout for an
|
|
120
|
+
* effect shape. Effects with the same shape — same uniform block size,
|
|
121
|
+
* same texture/sampler bindings, same builtins — share one layout, so
|
|
122
|
+
* their pipeline layouts (and pipelines) are shareable too.
|
|
123
|
+
* @param {string} signature - the shape signature (caller-composed)
|
|
124
|
+
* @param {GPUBindGroupLayoutEntry[]} entries - the layout entries
|
|
125
|
+
* @returns {GPUBindGroupLayout} the cached layout
|
|
126
|
+
*/
|
|
127
|
+
getEffectLayout(signature: string, entries: GPUBindGroupLayoutEntry[]): GPUBindGroupLayout;
|
|
128
|
+
/**
|
|
129
|
+
* Register a shader family's vertex buffer layout from a batcher's
|
|
130
|
+
* frozen attribute records — the declarative consumption of the
|
|
131
|
+
* backend-neutral vertex formats (#1492): the records already carry
|
|
132
|
+
* `format` and `offset` in WebGPU vocabulary, shader locations are
|
|
133
|
+
* declaration order.
|
|
134
|
+
* Accepts either the single-buffer form `(key, stride, attributes)` or a
|
|
135
|
+
* list of buffer groups `(key, [{stride, stepMode, attributes}, …])` —
|
|
136
|
+
* the latter is what an instanced family registers, with the geometry
|
|
137
|
+
* group at index 0 and a `stepMode: "instance"` group after it. Shader
|
|
138
|
+
* locations are assigned in declaration order and continue **across**
|
|
139
|
+
* groups, since WGSL locations are a single namespace.
|
|
140
|
+
* @param {string} shaderKey - "quad" | "primitive"
|
|
141
|
+
* @param {number|object[]} stride - vertex byte stride, or the buffer-group list
|
|
142
|
+
* @param {{format: string, offset: number}[]} [attributes] - frozen records (single-buffer form)
|
|
143
|
+
*/
|
|
144
|
+
registerVertexLayout(shaderKey: string, stride: number | object[], attributes?: {
|
|
145
|
+
format: string;
|
|
146
|
+
offset: number;
|
|
147
|
+
}[]): void;
|
|
148
|
+
/**
|
|
149
|
+
* Fetch (building on first use) the pipeline for the given state tuple.
|
|
150
|
+
* @param {string} shaderKey - "quad" | "primitive" | "clear"
|
|
151
|
+
* @param {string} topology - portable topology name ("triangle-list", …)
|
|
152
|
+
* @param {string} blendMode - blend mode (normalized internally)
|
|
153
|
+
* @param {boolean} premultipliedAlpha - source premultiplication flag
|
|
154
|
+
* @param {string} [stencilMode="none"] - "none" | "write" | "test" | "tag" | "mark"
|
|
155
|
+
* @param {{cullMode: string, frontFace: string}} [meshState] - mesh pass
|
|
156
|
+
* state: its presence switches the depth half of the attachment on —
|
|
157
|
+
* depth writes enabled, "less-equal" testing (the GL mesh mode's
|
|
158
|
+
* LEQUAL, keeping coplanar geometry stable) — and sets the per-mesh
|
|
159
|
+
* face-culling axes. Omitted by the whole 2D tier, whose keys and
|
|
160
|
+
* descriptors stay byte-identical to a build without a mesh path.
|
|
161
|
+
* @returns {GPURenderPipeline} the pipeline
|
|
162
|
+
*/
|
|
163
|
+
get(shaderKey: string, topology: string, blendMode: string, premultipliedAlpha: boolean, stencilMode?: string, meshState?: {
|
|
164
|
+
cullMode: string;
|
|
165
|
+
frontFace: string;
|
|
166
|
+
}): GPURenderPipeline;
|
|
167
|
+
/**
|
|
168
|
+
* drop every cached pipeline (device loss — the whole cache object is
|
|
169
|
+
* rebuilt by the renderer's restore path, this exists for symmetry)
|
|
170
|
+
*/
|
|
171
|
+
clear(): void;
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../../src/video/webgpu/pipeline/cache.js"],"names":[],"mappings":"AAuFA;;;;;;;GAOG;AACH,yCAJW,MAAM,GACJ,MAAM,CAoBlB;AA1GD;;;;;;;GAOG;AACH,gCAAiC,CAAC,CAAC;AAEnC;;;;;;;GAOG;AACH,mCAAoC,sBAAsB,CAAC;AAqK3D;;;;;;;;;;;;GAYG;AACH;IAwKC;;;OAGG;IACH,4BAAwB;IA3KxB;;;OAGG;IACH,oBAHW,SAAS,UACT,MAAM,EAmKhB;IAhKA,kBAAoB;IACpB,eAAoB;IACpB,oBAAoB;IACpB,6CAA6C;IAC7C,WADW,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,CACf;IAC1B,kEAAkE;IAClE,eADW,GAAG,CAAC,MAAM,EAAE;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,EAAE,CAAA;KAAC,CAAC,CAChC;IAG9B,gCAaE;IACF,qCAaE;IACF,mCAME;IAYF,uCAQE;IAiBF,wCAGE;IAGF;;;;;MAmBC;IAGD;;;;;MAaC;IAKD,0DAA0D;IAC1D,mBADW,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CACI;IAGlC,+BAAgC;IAChC,mGAAmG;IACnG,qBADW,GAAG,CAAC,MAAM,EAAE;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,EAAE,CAAA;KAAC,CAAC,CAC1B;IAGpC,+EAA+E;IAC/E,eADW,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,CACZ;IAM9B,gCAGE;IACF,6BAIE;IAEF;;;;;;OAMG;IACH,OAFU,MAAM,CAE+B;IAShD;;;;;;;;;;;;;OAaG;IACH,qBATW,MAAM,YAEd;QAAuC,gBAAgB;QAE9B,eAAe;QAEf,KAAK;KAC9B,GAAU,MAAM,CAsClB;IAED;;;;;;;;OAQG;IACH,2BAJW,MAAM,WACN,uBAAuB,EAAE,GACvB,kBAAkB,CAY9B;IAED;;;;;;;;;;;;;;;OAeG;IACH,gCAJW,MAAM,UACN,MAAM,GAAC,MAAM,EAAE,eACf;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,EAAE,QAqC5C;IAED;;;;;;;;;;;;;;OAcG;IACH,eAbW,MAAM,YACN,MAAM,aACN,MAAM,sBACN,OAAO,gBACP,MAAM,cACN;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAC,GAMnC,iBAAiB,CA4E7B;IAED;;;OAGG;IACH,cAEC;CACD"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GPU-accelerated renderer for orthogonal TMX tile layers on the WebGPU
|
|
3
|
+
* backend — the WGSL realization of the WebGL shader tile path: the
|
|
4
|
+
* visible region draws as ONE quad per tileset, with the fragment shader
|
|
5
|
+
* sampling a per-layer GID index texture and the tileset atlas.
|
|
6
|
+
*
|
|
7
|
+
* Structure mirrors the WebGL twin; the mechanisms are the backend's:
|
|
8
|
+
* - the GID index / animation lookup are renderer-owned `rgba8unorm`
|
|
9
|
+
* textures written with `queue.writeTexture` (byte-exact `textureLoad`
|
|
10
|
+
* reads, no sampler needed) — re-uploaded only when `layer.dataVersion`
|
|
11
|
+
* moves or an animation frame advances
|
|
12
|
+
* - the per-draw uniforms snapshot into the effect uniform arena with a
|
|
13
|
+
* dynamic offset (each tileset pass gets its own region, per the
|
|
14
|
+
* queue-write-before-draws ordering)
|
|
15
|
+
* - the tileset atlas rides the standard texture-store material path
|
|
16
|
+
* - pipelines flow through the registered `tmxlayer.wgsl` family, keyed
|
|
17
|
+
* on the frame's blend/stencil state like every other draw
|
|
18
|
+
* @ignore
|
|
19
|
+
*/
|
|
20
|
+
export default class OrthogonalTMXLayerGPURenderer {
|
|
21
|
+
/**
|
|
22
|
+
* @param {WebGPURenderer} renderer - the WebGPU renderer instance
|
|
23
|
+
*/
|
|
24
|
+
constructor(renderer: WebGPURenderer);
|
|
25
|
+
renderer: WebGPURenderer;
|
|
26
|
+
tmxLayout: GPUBindGroupLayout;
|
|
27
|
+
key: string;
|
|
28
|
+
epoch: number;
|
|
29
|
+
/**
|
|
30
|
+
* per-layer GID index texture: layer → {texture, view, version}
|
|
31
|
+
* @type {Map<TMXLayer, object>}
|
|
32
|
+
*/
|
|
33
|
+
resources: Map<TMXLayer, object>;
|
|
34
|
+
/**
|
|
35
|
+
* per-tileset animation lookup: tileset → {texture, view, data, tileCount}
|
|
36
|
+
* @type {Map<object, object>}
|
|
37
|
+
*/
|
|
38
|
+
animLookups: Map<object, object>;
|
|
39
|
+
/**
|
|
40
|
+
* per-(layer, tileset) cached group-3 bind group, keyed on the
|
|
41
|
+
* uniform arena page it binds
|
|
42
|
+
* @type {Map<TMXLayer, Map<object, {bindGroup: GPUBindGroup, pageLabel: string, animView: object}>>}
|
|
43
|
+
*/
|
|
44
|
+
bindGroups: Map<TMXLayer, Map<object, {
|
|
45
|
+
bindGroup: GPUBindGroup;
|
|
46
|
+
pageLabel: string;
|
|
47
|
+
animView: object;
|
|
48
|
+
}>>;
|
|
49
|
+
uniformScratch: Float32Array<ArrayBuffer>;
|
|
50
|
+
vertexScratch: ArrayBuffer;
|
|
51
|
+
vertexF32: Float32Array<ArrayBuffer>;
|
|
52
|
+
vertexU32: Uint32Array<ArrayBuffer>;
|
|
53
|
+
/**
|
|
54
|
+
* Retire every lookup texture and empty the local maps — called from
|
|
55
|
+
* `WebGPURenderer.reset()` (GAME_RESET) so each level starts clean.
|
|
56
|
+
* @ignore
|
|
57
|
+
*/
|
|
58
|
+
reset(): void;
|
|
59
|
+
/**
|
|
60
|
+
* Get-or-create the per-layer GID index texture, re-uploading when the
|
|
61
|
+
* layer's data version moved (`setTile`/`clearTile` mutations).
|
|
62
|
+
* @param {TMXLayer} layer - the layer
|
|
63
|
+
* @returns {{texture: GPUTexture, view: GPUTextureView, version: number}}
|
|
64
|
+
* @ignore
|
|
65
|
+
*/
|
|
66
|
+
getResource(layer: TMXLayer): {
|
|
67
|
+
texture: GPUTexture;
|
|
68
|
+
view: GPUTextureView;
|
|
69
|
+
version: number;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Get-or-update the per-tileset animation lookup (undefined for
|
|
73
|
+
* tilesets without animated tiles). Texel `localId` encodes the
|
|
74
|
+
* CURRENT frame's local id as (R = lo byte, G = hi byte).
|
|
75
|
+
* @param {object} tileset - the tileset
|
|
76
|
+
* @param {number} tileCount - atlas grid tile count
|
|
77
|
+
* @returns {object|undefined} the lookup entry
|
|
78
|
+
* @ignore
|
|
79
|
+
*/
|
|
80
|
+
getOrUpdateAnimLookup(tileset: object, tileCount: number): object | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* Draw an orthogonal TMX layer through the shader path.
|
|
83
|
+
* @param {TMXLayer} layer - the layer to draw
|
|
84
|
+
* @param {object} rect - the visible viewport rect (world coords)
|
|
85
|
+
*/
|
|
86
|
+
draw(layer: TMXLayer, rect: object): void;
|
|
87
|
+
}
|
|
88
|
+
import type { default as WebGPURenderer } from "../../webgpu_renderer.js";
|
|
89
|
+
import type { default as TMXLayer } from "../../../../level/tiled/TMXLayer.js";
|
|
90
|
+
//# sourceMappingURL=orthogonal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orthogonal.d.ts","sourceRoot":"","sources":["../../../../../src/video/webgpu/renderers/tmxlayer/orthogonal.js"],"names":[],"mappings":"AAiBA;;;;;;;;;;;;;;;;;;GAkBG;AACH;IACC;;OAEG;IACH,sBAFW,cAAc,EAwDxB;IArDA,yBAAwB;IAIxB,8BAYE;IACF,YASE;IAGF,cAAwB;IAExB;;;OAGG;IACH,WAFU,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAEL;IAC1B;;;OAGG;IACH,aAFU,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAED;IAC5B;;;;OAIG;IACH,YAFU,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE;QAAC,SAAS,EAAE,YAAY,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAC,CAAC,CAAC,CAEzE;IAG3B,0CAA4D;IAC5D,2BAA4C;IAC5C,qCAAqD;IACrD,oCAAoD;IAGrD;;;;OAIG;IACH,cAUC;IAED;;;;;;OAMG;IACH,mBAJW,QAAQ,GACN;QAAC,OAAO,EAAE,UAAU,CAAC;QAAC,IAAI,EAAE,cAAc,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAC,CA4BxE;IAED;;;;;;;;OAQG;IACH,+BALW,MAAM,aACN,MAAM,GACJ,MAAM,GAAC,SAAS,CA2D5B;IAED;;;;OAIG;IACH,YAHW,QAAQ,QACR,MAAM,QA2MhB;CACD;+CA/Z6C,0BAA0B;yCADhC,qCAAqC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Derive an instanced mesh WGSL module from the ordinary one (#1508).
|
|
3
|
+
*
|
|
4
|
+
* WGSL has no preprocessor, and a module carries **both** entry points in
|
|
5
|
+
* one file — so an instanced variant cannot be a second vertex file the way
|
|
6
|
+
* it is on the WebGL side. Rather than copy the module (which for the lit
|
|
7
|
+
* tier would duplicate the whole lighting loop, and the `Light3dBlock`
|
|
8
|
+
* layout that must agree byte-for-byte with the uniform packer), this
|
|
9
|
+
* rewrites the shared source:
|
|
10
|
+
*
|
|
11
|
+
* - everything before `@vertex` is kept — structs, bindings, `VSOut` —
|
|
12
|
+
* with one extra inter-stage field when the custom slot is in play;
|
|
13
|
+
* - the vertex stage is replaced with one that reads the per-instance
|
|
14
|
+
* attributes and applies them;
|
|
15
|
+
* - the fragment stage is kept **verbatim**, apart from one substitution
|
|
16
|
+
* that folds the per-instance slot into the emissive term.
|
|
17
|
+
*
|
|
18
|
+
* So the lighting loop, the light block and the alpha-cutout rule exist in
|
|
19
|
+
* exactly one place, and an instanced mesh shades identically to its
|
|
20
|
+
* uninstanced twin by construction rather than by review.
|
|
21
|
+
*
|
|
22
|
+
* Shader locations for the instance slots are **pinned**
|
|
23
|
+
* (`INSTANCE_SLOT_OFFSETS`), so a variant that omits the colour slot does
|
|
24
|
+
* not renumber the data slot.
|
|
25
|
+
* @param {string} source - the ordinary module (`mesh.wgsl` / `mesh-lit.wgsl`)
|
|
26
|
+
* @param {object} options - variant options
|
|
27
|
+
* @param {number} options.baseLocation - first vertex location after the tier's geometry attributes
|
|
28
|
+
* @param {number} options.varyingLocation - first free inter-stage location in `VSOut`
|
|
29
|
+
* @param {boolean} options.hasColor - whether the per-instance colour slot is present
|
|
30
|
+
* @param {boolean} options.hasData - whether the per-instance custom slot is present
|
|
31
|
+
* @param {string} options.geometryInputs - the tier's geometry attribute declarations
|
|
32
|
+
* @param {string} options.body - the tier's placement body, which reads the `instance` matrix the generated preamble declares and must leave a `clip` value for the shared tail
|
|
33
|
+
* @returns {string} the instanced module text
|
|
34
|
+
* @ignore
|
|
35
|
+
*/
|
|
36
|
+
export function buildInstancedMeshWGSL(source: string, options: {
|
|
37
|
+
baseLocation: number;
|
|
38
|
+
varyingLocation: number;
|
|
39
|
+
hasColor: boolean;
|
|
40
|
+
hasData: boolean;
|
|
41
|
+
geometryInputs: string;
|
|
42
|
+
body: string;
|
|
43
|
+
}): string;
|
|
44
|
+
export namespace UNLIT_INSTANCED {
|
|
45
|
+
let baseLocation: number;
|
|
46
|
+
let varyingLocation: number;
|
|
47
|
+
let geometryInputs: string;
|
|
48
|
+
let body: string;
|
|
49
|
+
}
|
|
50
|
+
export namespace LIT_INSTANCED {
|
|
51
|
+
let baseLocation_1: number;
|
|
52
|
+
export { baseLocation_1 as baseLocation };
|
|
53
|
+
let varyingLocation_1: number;
|
|
54
|
+
export { varyingLocation_1 as varyingLocation };
|
|
55
|
+
let geometryInputs_1: string;
|
|
56
|
+
export { geometryInputs_1 as geometryInputs };
|
|
57
|
+
let body_1: string;
|
|
58
|
+
export { body_1 as body };
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=mesh-instanced.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mesh-instanced.d.ts","sourceRoot":"","sources":["../../../../src/video/webgpu/shaders/mesh-instanced.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,+CAXW,MAAM,WAEd;IAAwB,YAAY,EAA5B,MAAM;IACU,eAAe,EAA/B,MAAM;IACW,QAAQ,EAAzB,OAAO;IACU,OAAO,EAAxB,OAAO;IACS,cAAc,EAA9B,MAAM;IACU,IAAI,EAApB,MAAM;CACd,GAAU,MAAM,CAkIlB"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Upload every mip level of a parsed CompressedImage into a GPUTexture
|
|
3
|
+
* via queue.writeTexture (block-aligned rows, largest mip first — the
|
|
4
|
+
* parser contract).
|
|
5
|
+
* @param {GPUDevice} device - the device
|
|
6
|
+
* @param {GPUTexture} texture - destination created with the mapped format
|
|
7
|
+
* @param {object} image - the parsed CompressedImage ({mipmaps, format})
|
|
8
|
+
* @param {object} metrics - the COMPRESSED_FORMATS entry for image.format
|
|
9
|
+
* @ignore
|
|
10
|
+
*/
|
|
11
|
+
export function uploadCompressedTexture(device: GPUDevice, texture: GPUTexture, image: object, metrics: object): void;
|
|
12
|
+
/**
|
|
13
|
+
* WebGL compressed-format constant → WebGPU texture format + block
|
|
14
|
+
* metrics. The loader parsers (dds/pvr/pkm/ktx/ktx2) are backend-neutral
|
|
15
|
+
* and emit WebGL enum constants; this table is the WebGPU side of that
|
|
16
|
+
* contract. Families gate on the device features requested at init:
|
|
17
|
+
* "texture-compression-bc", "texture-compression-etc2",
|
|
18
|
+
* "texture-compression-astc" (PVRTC has no WebGPU equivalent).
|
|
19
|
+
* @ignore
|
|
20
|
+
*/
|
|
21
|
+
export const COMPRESSED_FORMATS: Map<number, {
|
|
22
|
+
format: string;
|
|
23
|
+
blockW: number;
|
|
24
|
+
blockH: number;
|
|
25
|
+
bytes: number;
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* the optional device features the renderer requests when the adapter
|
|
29
|
+
* offers them
|
|
30
|
+
* @ignore
|
|
31
|
+
*/
|
|
32
|
+
export const COMPRESSION_FEATURES: string[];
|
|
33
|
+
//# sourceMappingURL=compressed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compressed.d.ts","sourceRoot":"","sources":["../../../../src/video/webgpu/texture/compressed.js"],"names":[],"mappings":"AA+DA;;;;;;;;;GASG;AACH,gDANW,SAAS,WACT,UAAU,SACV,MAAM,WACN,MAAM,QAoBhB;AA1FD;;;;;;;;GAQG;AACH;;;;;GAyCG;AAEH;;;;GAIG;AACH,4CAIE"}
|