@drawcall/lod 0.3.0 → 0.5.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 +5 -8
- package/dist/bake.d.ts +16 -2
- package/dist/bake.js +92 -4
- package/dist/bake.js.map +1 -1
- package/dist/baked/index.d.ts +2 -2
- package/dist/baked/index.js +2 -2
- package/dist/baked/interior/faces.js +4 -2
- package/dist/baked/interior/faces.js.map +1 -1
- package/dist/baked/interior/material.js +1 -1
- package/dist/baked/interior/material.js.map +1 -1
- package/dist/baked/interior/rooms.d.ts +1 -1
- package/dist/baked/interior/rooms.js +1 -1
- package/dist/dispose.d.ts +3 -3
- package/dist/dispose.js +6 -6
- package/dist/dispose.js.map +1 -1
- package/dist/foliage.d.ts +32 -0
- package/dist/foliage.js +137 -0
- package/dist/foliage.js.map +1 -0
- package/dist/impostor/bake/index.d.ts +3 -3
- package/dist/impostor/bake/index.js +12 -3
- package/dist/impostor/bake/index.js.map +1 -1
- package/dist/impostor/bake/source.d.ts +2 -1
- package/dist/impostor/bake/source.js +2 -2
- package/dist/impostor/bake/source.js.map +1 -1
- package/dist/impostor/impostor.d.ts +1 -1
- package/dist/impostor/impostor.js +1 -1
- package/dist/impostor/ktx2/encode.js +5 -2
- package/dist/impostor/ktx2/encode.js.map +1 -1
- package/dist/impostor/ktx2/uastc.js +3 -2
- package/dist/impostor/ktx2/uastc.js.map +1 -1
- package/dist/impostor/ktx2/worker.js +0 -2
- package/dist/impostor/ktx2/worker.js.map +1 -1
- package/dist/impostor/mesh/card.d.ts +1 -1
- package/dist/impostor/mesh/index.d.ts +2 -2
- package/dist/impostor/mesh/index.js +3 -3
- package/dist/impostor/mesh/index.js.map +1 -1
- package/dist/index.d.ts +3 -6
- package/dist/index.js +3 -6
- package/dist/index.js.map +1 -1
- package/dist/instanced/camera.d.ts +13 -25
- package/dist/instanced/camera.js +17 -42
- package/dist/instanced/camera.js.map +1 -1
- package/dist/instanced/clusters.d.ts +68 -0
- package/dist/instanced/clusters.js +172 -0
- package/dist/instanced/clusters.js.map +1 -0
- package/dist/instanced/cull.d.ts +3 -3
- package/dist/instanced/cull.js +2 -2
- package/dist/instanced/cull.js.map +1 -1
- package/dist/instanced/instances.d.ts +39 -0
- package/dist/instanced/instances.js +104 -0
- package/dist/instanced/instances.js.map +1 -0
- package/dist/instanced/key.d.ts +1 -1
- package/dist/instanced/key.js +1 -1
- package/dist/instanced/key.js.map +1 -1
- package/dist/instanced/levels.d.ts +9 -9
- package/dist/instanced/levels.js +7 -6
- package/dist/instanced/levels.js.map +1 -1
- package/dist/instanced/lists.d.ts +29 -39
- package/dist/instanced/lists.js +45 -62
- package/dist/instanced/lists.js.map +1 -1
- package/dist/instanced/measure.d.ts +2 -2
- package/dist/instanced/measure.js +2 -2
- package/dist/instanced/meshes.d.ts +11 -9
- package/dist/instanced/meshes.js +26 -16
- package/dist/instanced/meshes.js.map +1 -1
- package/dist/instanced/mirror.d.ts +16 -12
- package/dist/instanced/mirror.js +51 -12
- package/dist/instanced/mirror.js.map +1 -1
- package/dist/instanced/raycast.d.ts +6 -9
- package/dist/instanced/raycast.js +15 -18
- package/dist/instanced/raycast.js.map +1 -1
- package/dist/instanced/rows.d.ts +22 -73
- package/dist/instanced/rows.js +24 -189
- package/dist/instanced/rows.js.map +1 -1
- package/dist/instanced/shape.d.ts +3 -1
- package/dist/instanced/shape.js +6 -3
- package/dist/instanced/shape.js.map +1 -1
- package/dist/instanced/sort.d.ts +36 -34
- package/dist/instanced/sort.js +168 -132
- package/dist/instanced/sort.js.map +1 -1
- package/dist/instanced/update.d.ts +17 -12
- package/dist/instanced/update.js +64 -85
- package/dist/instanced/update.js.map +1 -1
- package/dist/levels/compile/index.d.ts +4 -2
- package/dist/levels/compile/index.js +10 -2
- package/dist/levels/compile/index.js.map +1 -1
- package/dist/levels/compile/pipelines.d.ts +1 -1
- package/dist/levels/compile/pipelines.js +1 -6
- package/dist/levels/compile/pipelines.js.map +1 -1
- package/dist/levels/draw.d.ts +1 -1
- package/dist/levels/draw.js +3 -3
- package/dist/levels/fade.d.ts +13 -22
- package/dist/levels/fade.js +17 -38
- package/dist/levels/fade.js.map +1 -1
- package/dist/levels/index.d.ts +7 -7
- package/dist/levels/index.js +1 -1
- package/dist/levels/item.d.ts +10 -10
- package/dist/levels/item.js +15 -23
- package/dist/levels/item.js.map +1 -1
- package/dist/levels/load.d.ts +1 -1
- package/dist/levels/load.js +5 -3
- package/dist/levels/load.js.map +1 -1
- package/dist/levels/manager.d.ts +30 -31
- package/dist/levels/manager.js +75 -62
- package/dist/levels/manager.js.map +1 -1
- package/dist/levels/material.d.ts +2 -2
- package/dist/levels/material.js +2 -2
- package/dist/levels/renderer.d.ts +8 -5
- package/dist/levels/renderer.js +20 -4
- package/dist/levels/renderer.js.map +1 -1
- package/dist/levels/requests.d.ts +4 -1
- package/dist/levels/requests.js +3 -1
- package/dist/levels/requests.js.map +1 -1
- package/dist/loader/context.d.ts +9 -11
- package/dist/loader/context.js +12 -7
- package/dist/loader/context.js.map +1 -1
- package/dist/loader/entry.d.ts +4 -0
- package/dist/loader/entry.js +43 -0
- package/dist/loader/entry.js.map +1 -0
- package/dist/loader/index.d.ts +49 -35
- package/dist/loader/index.js +123 -135
- package/dist/loader/index.js.map +1 -1
- package/dist/loader/level.js +5 -5
- package/dist/loader/level.js.map +1 -1
- package/dist/loader/node.d.ts +26 -0
- package/dist/loader/node.js +199 -0
- package/dist/loader/node.js.map +1 -0
- package/dist/loader/request.d.ts +11 -44
- package/dist/loader/request.js +7 -47
- package/dist/loader/request.js.map +1 -1
- package/dist/loader/url.d.ts +10 -9
- package/dist/loader/url.js +21 -17
- package/dist/loader/url.js.map +1 -1
- package/dist/lod.d.ts +122 -62
- package/dist/lod.js +332 -187
- package/dist/lod.js.map +1 -1
- package/dist/meshopt.d.ts +1 -1
- package/dist/meshopt.js +3 -2
- package/dist/meshopt.js.map +1 -1
- package/dist/node-process.d.ts +5 -0
- package/dist/node-process.js +6 -0
- package/dist/node-process.js.map +1 -0
- package/dist/node.d.ts +2 -0
- package/dist/node.js +5 -0
- package/dist/node.js.map +1 -0
- package/dist/simplify/index.d.ts +2 -2
- package/dist/simplify/index.js +7 -7
- package/dist/simplify/index.js.map +1 -1
- package/dist/source/detail.d.ts +7 -2
- package/dist/source/detail.js +26 -22
- package/dist/source/detail.js.map +1 -1
- package/dist/source/sampler.js +5 -2
- package/dist/source/sampler.js.map +1 -1
- package/dist/three.d.ts +8 -7
- package/dist/three.js +5 -4
- package/dist/three.js.map +1 -1
- package/dist/wind/bounds.js +1 -1
- package/dist/wind/bounds.js.map +1 -1
- package/dist/wind/hooks.d.ts +1 -1
- package/dist/wind/hooks.js +1 -1
- package/dist/wind/index.d.ts +3 -3
- package/dist/wind/index.js +11 -9
- package/dist/wind/index.js.map +1 -1
- package/package.json +10 -6
- package/skills/lod/SKILL.md +65 -54
- package/dist/gpu.d.ts +0 -39
- package/dist/gpu.js +0 -41
- package/dist/gpu.js.map +0 -1
- package/dist/instanced/chunk.d.ts +0 -97
- package/dist/instanced/chunk.js +0 -156
- package/dist/instanced/chunk.js.map +0 -1
- package/dist/instanced/chunks.d.ts +0 -60
- package/dist/instanced/chunks.js +0 -208
- package/dist/instanced/chunks.js.map +0 -1
- package/dist/instanced/index.d.ts +0 -120
- package/dist/instanced/index.js +0 -290
- package/dist/instanced/index.js.map +0 -1
- package/dist/instanced/pages/buffers.d.ts +0 -37
- package/dist/instanced/pages/buffers.js +0 -15
- package/dist/instanced/pages/buffers.js.map +0 -1
- package/dist/instanced/pages/chunk.d.ts +0 -51
- package/dist/instanced/pages/chunk.js +0 -81
- package/dist/instanced/pages/chunk.js.map +0 -1
- package/dist/instanced/pages/index.d.ts +0 -74
- package/dist/instanced/pages/index.js +0 -269
- package/dist/instanced/pages/index.js.map +0 -1
- package/dist/instanced/pages/passes.d.ts +0 -21
- package/dist/instanced/pages/passes.js +0 -52
- package/dist/instanced/pages/passes.js.map +0 -1
- package/dist/instanced/pages/slots.d.ts +0 -11
- package/dist/instanced/pages/slots.js +0 -90
- package/dist/instanced/pages/slots.js.map +0 -1
- package/dist/instanced/pages/workgroup.d.ts +0 -14
- package/dist/instanced/pages/workgroup.js +0 -38
- package/dist/instanced/pages/workgroup.js.map +0 -1
- package/dist/levels/wait.d.ts +0 -27
- package/dist/levels/wait.js +0 -61
- package/dist/levels/wait.js.map +0 -1
- package/dist/loader/cache.d.ts +0 -12
- package/dist/loader/cache.js +0 -68
- package/dist/loader/cache.js.map +0 -1
- package/dist/loader/dependencies.d.ts +0 -32
- package/dist/loader/dependencies.js +0 -113
- package/dist/loader/dependencies.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shape.js","sourceRoot":"","sources":["../../src/instanced/shape.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"shape.js","sourceRoot":"","sources":["../../src/instanced/shape.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAG9D,wHAAwH;AACxH,MAAM,OAAO,aAAa;IACxB,0DAA0D;IACjD,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;IAC/B,kDAAkD;IACzC,IAAI,GAAG,IAAI,MAAM,EAAE,CAAC;IAC7B,wFAAwF;IAC/E,SAAS,GAAW,CAAC,CAAC;IAC/B,oGAAoG;IACpG,UAAU,GAAG,CAAC,CAAC;IACf,iGAAiG;IACxF,MAAM,GAAW,CAAC,CAAC;IAC5B,yBAAyB;IACR,QAAQ,GAAG,IAAI,IAAI,EAAE,CAAC;IACvC,yDAAyD;IACjD,IAAI,GAAG,CAAC,CAAC;IAEjB,oEAAoE;IACpE,YAAY,MAA2B;QACrC,IAAI,MAAM,CAAC,MAA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type Sphere, type Vector3 } from "three/webgpu";
|
|
2
2
|
import type { d } from "typegpu";
|
|
3
|
-
import type
|
|
3
|
+
import { type DrawLevels } from "../levels/draw.js";
|
|
4
4
|
import type { InstanceSlots } from "../levels/fade.js";
|
|
5
|
+
import type { LodLiveCount } from "./clusters.js";
|
|
5
6
|
import type { Cull } from "./cull.js";
|
|
6
|
-
import { type InstancePagePool } from "./pages/index.js";
|
|
7
7
|
import { type IndirectDraw } from "./rows.js";
|
|
8
|
-
/** What
|
|
8
|
+
/** What a Lod sorts by for a camera, everything in its space. */
|
|
9
9
|
export interface RowValues {
|
|
10
10
|
levels: d.Infer<typeof DrawLevels>;
|
|
11
11
|
/** The level loading state levelsToDraw reads (see LodLevelLoadManager). */
|
|
@@ -22,42 +22,44 @@ export interface RowValues {
|
|
|
22
22
|
reach: number;
|
|
23
23
|
frustum: Frustum;
|
|
24
24
|
}
|
|
25
|
-
/**
|
|
25
|
+
/** One Lod's sorts: every camera's buffers, and the passes sorting into them. */
|
|
26
26
|
export declare class Sorter {
|
|
27
|
-
private readonly
|
|
28
|
-
private readonly pool;
|
|
29
|
-
private readonly layout;
|
|
27
|
+
private readonly listed;
|
|
30
28
|
private readonly cameras;
|
|
31
|
-
|
|
29
|
+
private readonly draws;
|
|
30
|
+
private drawBuffer;
|
|
31
|
+
private readonly counts;
|
|
32
|
+
/** Survivors' scaled matrices, made once survivors scale; their CPU array is dropped once a pass wrote them. */
|
|
32
33
|
private scaled;
|
|
33
34
|
/** Where survivors' scaled matrices go while none scale: never written, as no survivor scales. */
|
|
34
35
|
private readonly unscaled;
|
|
36
|
+
/** What the sort reads as live counts while no range has one: never read. */
|
|
37
|
+
private readonly noLiveCounts;
|
|
35
38
|
private passes;
|
|
36
|
-
|
|
37
|
-
constructor(
|
|
38
|
-
/**
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
|
|
54
|
-
/** Sort every row due for `camera`, in one compute call: before a level mesh draws for it. */
|
|
55
|
-
run(camera: Camera): void;
|
|
56
|
-
/** Whether it was disposed: then it takes no InstancedLod and no camera. */
|
|
57
|
-
get disposed(): boolean;
|
|
39
|
+
/** `listed` tells, as a mask, which levels have an instance list: those that draw something. */
|
|
40
|
+
constructor(listed: number);
|
|
41
|
+
/** The meshes draw `draws` too, after those they have; where they start among the draws. */
|
|
42
|
+
appendDraws(draws: readonly IndirectDraw[]): number;
|
|
43
|
+
/** Survivors' scaled matrices for `capacity` instances. */
|
|
44
|
+
scaledMatrices(capacity: number): StorageInstancedBufferAttribute;
|
|
45
|
+
/** Where `camera`'s lists and indirect draws lie; null before a sort was written for it. */
|
|
46
|
+
slotsOf(camera: Camera): InstanceSlots | null;
|
|
47
|
+
/**
|
|
48
|
+
* Write `values` as what `camera` sorts by, over the instances of `ranges` (start, count and item of `liveCounts`,
|
|
49
|
+
* flat), `instances` in all, sorted at the camera's next draw. Its lists grow to hold them, within `limit` bytes per
|
|
50
|
+
* buffer.
|
|
51
|
+
*/
|
|
52
|
+
write(camera: Camera, values: RowValues, ranges: readonly number[], liveCounts: LodLiveCount["attribute"] | null, instances: number, limit: number): void;
|
|
53
|
+
/** Sort for `camera` on `renderer`, in one compute call, if due: before a level mesh draws for it. */
|
|
54
|
+
run(renderer: Renderer, camera: Camera, matrices: StorageInstancedBufferAttribute): void;
|
|
55
|
+
/** `camera` no longer draws the Lod: its buffers are freed. */
|
|
56
|
+
release(camera: Camera): void;
|
|
58
57
|
dispose(): void;
|
|
59
|
-
private
|
|
60
|
-
|
|
61
|
-
private
|
|
62
|
-
|
|
58
|
+
private makeBuffers;
|
|
59
|
+
/** Grow `buffers`' lists to hold `instances` per level, by doubling, each buffer within `limit` bytes. */
|
|
60
|
+
private grow;
|
|
61
|
+
/** Write the blocks of `ranges` into `buffers`, growing its words: one empty block for none, as a dispatch visits one at least. */
|
|
62
|
+
private writeBlocks;
|
|
63
|
+
/** Write the layout of `buffers`' lists and the draw count into its row. */
|
|
64
|
+
private place;
|
|
63
65
|
}
|
package/dist/instanced/sort.js
CHANGED
|
@@ -1,162 +1,198 @@
|
|
|
1
|
-
import { StorageInstancedBufferAttribute } from "three/webgpu";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { sortPasses } from "./update.js";
|
|
5
|
-
/**
|
|
1
|
+
import { StorageBufferAttribute, StorageInstancedBufferAttribute } from "three/webgpu";
|
|
2
|
+
import { MAX_LEVELS } from "../levels/draw.js";
|
|
3
|
+
import { BLOCKS_AT, FLOATS_AT, INTS_AT, NO_LIVE_COUNT, UNLISTED, argsBuffer, countsBuffer, drawWords, floatsBuffer, forcedWord, wordsBuffer } from "./rows.js";
|
|
4
|
+
import { BLOCK, MAX_BLOCKS, sortPasses } from "./update.js";
|
|
5
|
+
/** One Lod's sorts: every camera's buffers, and the passes sorting into them. */
|
|
6
6
|
export class Sorter {
|
|
7
|
-
|
|
8
|
-
pool;
|
|
9
|
-
layout = new RowLayout();
|
|
7
|
+
listed;
|
|
10
8
|
cameras = new Map();
|
|
11
|
-
|
|
9
|
+
draws = [];
|
|
10
|
+
drawBuffer = drawWords([]);
|
|
11
|
+
counts = countsBuffer();
|
|
12
|
+
/** Survivors' scaled matrices, made once survivors scale; their CPU array is dropped once a pass wrote them. */
|
|
12
13
|
scaled = null;
|
|
13
14
|
/** Where survivors' scaled matrices go while none scale: never written, as no survivor scales. */
|
|
14
15
|
unscaled = new StorageInstancedBufferAttribute(new Float32Array(16), 16);
|
|
16
|
+
/** What the sort reads as live counts while no range has one: never read. */
|
|
17
|
+
noLiveCounts = new StorageBufferAttribute(new Uint32Array(1), 1);
|
|
15
18
|
passes = null;
|
|
16
|
-
|
|
17
|
-
constructor(
|
|
18
|
-
this.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
this.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const buffers = this.cameras.get(camera) ?? this.layout.makeBuffers();
|
|
45
|
-
buffers.users++;
|
|
46
|
-
this.cameras.set(camera, buffers);
|
|
47
|
-
}
|
|
48
|
-
/** An InstancedLod stops drawing for `camera`, its row `row` dropped from it; the last frees its buffers. */
|
|
49
|
-
release(camera, row) {
|
|
19
|
+
/** `listed` tells, as a mask, which levels have an instance list: those that draw something. */
|
|
20
|
+
constructor(listed) {
|
|
21
|
+
this.listed = listed;
|
|
22
|
+
}
|
|
23
|
+
/** The meshes draw `draws` too, after those they have; where they start among the draws. */
|
|
24
|
+
appendDraws(draws) {
|
|
25
|
+
const first = this.draws.length;
|
|
26
|
+
this.draws.push(...draws);
|
|
27
|
+
this.drawBuffer.dispose();
|
|
28
|
+
this.drawBuffer = drawWords(this.draws);
|
|
29
|
+
for (const buffers of this.cameras.values()) {
|
|
30
|
+
buffers.args.dispose();
|
|
31
|
+
buffers.args = argsBuffer(this.draws.length);
|
|
32
|
+
this.place(buffers);
|
|
33
|
+
buffers.due = true;
|
|
34
|
+
}
|
|
35
|
+
return first;
|
|
36
|
+
}
|
|
37
|
+
/** Survivors' scaled matrices for `capacity` instances. */
|
|
38
|
+
scaledMatrices(capacity) {
|
|
39
|
+
if (this.scaled?.capacity !== capacity) {
|
|
40
|
+
this.scaled?.attribute.dispose();
|
|
41
|
+
this.scaled = { attribute: new StorageInstancedBufferAttribute(new Float32Array(capacity * 16), 16), capacity };
|
|
42
|
+
}
|
|
43
|
+
return this.scaled.attribute;
|
|
44
|
+
}
|
|
45
|
+
/** Where `camera`'s lists and indirect draws lie; null before a sort was written for it. */
|
|
46
|
+
slotsOf(camera) {
|
|
50
47
|
const buffers = this.cameras.get(camera);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
/** Write `values` as what `row` sorts by for `camera`, sorted at the camera's next draw. */
|
|
66
|
-
write(camera, row, values) {
|
|
67
|
-
this.layOut();
|
|
68
|
-
const buffers = this.buffersOf(camera);
|
|
48
|
+
return buffers ? { indices: buffers.indices, fades: buffers.fades, args: { attribute: buffers.args, offset: 0 } } : null;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Write `values` as what `camera` sorts by, over the instances of `ranges` (start, count and item of `liveCounts`,
|
|
52
|
+
* flat), `instances` in all, sorted at the camera's next draw. Its lists grow to hold them, within `limit` bytes per
|
|
53
|
+
* buffer.
|
|
54
|
+
*/
|
|
55
|
+
write(camera, values, ranges, liveCounts, instances, limit) {
|
|
56
|
+
const buffers = this.cameras.get(camera) ?? this.makeBuffers();
|
|
57
|
+
this.cameras.set(camera, buffers);
|
|
58
|
+
if (instances > buffers.listSize)
|
|
59
|
+
this.grow(buffers, instances, limit);
|
|
60
|
+
this.writeBlocks(buffers, ranges);
|
|
61
|
+
buffers.liveCounts = liveCounts;
|
|
69
62
|
const { levels, loaded, before, progress, eye, scale, ortho, cull, source, reach, frustum } = values;
|
|
70
|
-
const words =
|
|
71
|
-
|
|
72
|
-
words.set([levels.
|
|
73
|
-
words.set([
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
floats.set(levels.maxPixels, at + FLOATS_AT.low * 4);
|
|
81
|
-
floats.set([eye.x, eye.y, eye.z, scale], at + FLOATS_AT.eye * 4);
|
|
82
|
-
floats.set([source.center.x, source.center.y, source.center.z, source.radius], at + FLOATS_AT.source * 4);
|
|
83
|
-
floats.set([progress, reach, cull?.near ?? 0, cull?.far ?? 1], at + FLOATS_AT.values * 4);
|
|
63
|
+
const words = buffers.words.array;
|
|
64
|
+
words.set([levels.count, levels.coarsest, forcedWord(levels.forced)], INTS_AT.levels * 4);
|
|
65
|
+
words.set([levels.empty, levels.fades, loaded, before], INTS_AT.masks * 4);
|
|
66
|
+
words.set([Number(ortho), Number(cull !== null), Number(cull?.survivors ?? false)], INTS_AT.flags * 4);
|
|
67
|
+
this.place(buffers);
|
|
68
|
+
const floats = buffers.floats.array;
|
|
69
|
+
floats.set(levels.maxPixels, FLOATS_AT.low * 4);
|
|
70
|
+
floats.set([eye.x, eye.y, eye.z, scale], FLOATS_AT.eye * 4);
|
|
71
|
+
floats.set([source.center.x, source.center.y, source.center.z, source.radius], FLOATS_AT.source * 4);
|
|
72
|
+
floats.set([progress, reach, cull?.near ?? 0, cull?.far ?? 1], FLOATS_AT.values * 4);
|
|
84
73
|
if (cull)
|
|
85
|
-
floats.set([cull.eye.x, cull.eye.y, cull.eye.z, 0],
|
|
86
|
-
frustum.planes.forEach(({ normal, constant }, i) => floats.set([normal.x, normal.y, normal.z, constant],
|
|
87
|
-
buffers.floats.addUpdateRange(at, FLOAT_ROW * 4);
|
|
74
|
+
floats.set([cull.eye.x, cull.eye.y, cull.eye.z, 0], FLOATS_AT.cullEye * 4);
|
|
75
|
+
frustum.planes.forEach(({ normal, constant }, i) => floats.set([normal.x, normal.y, normal.z, constant], (FLOATS_AT.planes + i) * 4));
|
|
88
76
|
buffers.floats.needsUpdate = true;
|
|
89
|
-
buffers.
|
|
90
|
-
buffers.due.add(row);
|
|
77
|
+
buffers.due = true;
|
|
91
78
|
}
|
|
92
|
-
/** Sort
|
|
93
|
-
run(camera) {
|
|
94
|
-
this.layOut();
|
|
79
|
+
/** Sort for `camera` on `renderer`, in one compute call, if due: before a level mesh draws for it. */
|
|
80
|
+
run(renderer, camera, matrices) {
|
|
95
81
|
const buffers = this.cameras.get(camera);
|
|
96
|
-
if (!buffers
|
|
82
|
+
if (!buffers?.due)
|
|
97
83
|
return;
|
|
98
|
-
const sort =
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
buffers.
|
|
84
|
+
const sort = {
|
|
85
|
+
...buffers,
|
|
86
|
+
matrices,
|
|
87
|
+
liveCounts: buffers.liveCounts ?? this.noLiveCounts,
|
|
88
|
+
scaled: this.scaled?.attribute ?? this.unscaled,
|
|
89
|
+
counts: this.counts,
|
|
90
|
+
draws: this.drawBuffer,
|
|
91
|
+
};
|
|
92
|
+
const passes = (this.passes ??= sortPasses(sort));
|
|
93
|
+
passes.point(sort, buffers.blockCount);
|
|
94
|
+
renderer.compute([passes.update, passes.indirect]);
|
|
95
|
+
buffers.due = false;
|
|
108
96
|
// The pass made the scaled matrices' buffer: only the GPU writes them.
|
|
109
|
-
if (scaled && scaled.array.length > 0)
|
|
110
|
-
|
|
97
|
+
if (this.scaled && this.scaled.attribute.array.length > 0)
|
|
98
|
+
this.scaled.attribute.array = new Float32Array(0);
|
|
111
99
|
}
|
|
112
|
-
/**
|
|
113
|
-
|
|
114
|
-
|
|
100
|
+
/** `camera` no longer draws the Lod: its buffers are freed. */
|
|
101
|
+
release(camera) {
|
|
102
|
+
const buffers = this.cameras.get(camera);
|
|
103
|
+
if (!buffers)
|
|
104
|
+
return;
|
|
105
|
+
this.cameras.delete(camera);
|
|
106
|
+
disposeBuffers(buffers);
|
|
115
107
|
}
|
|
116
108
|
dispose() {
|
|
117
|
-
this.isDisposed = true;
|
|
118
109
|
for (const buffers of this.cameras.values())
|
|
119
110
|
disposeBuffers(buffers);
|
|
120
111
|
this.cameras.clear();
|
|
121
|
-
this.
|
|
122
|
-
this.
|
|
112
|
+
this.drawBuffer.dispose();
|
|
113
|
+
this.counts.dispose();
|
|
114
|
+
this.scaled?.attribute.dispose();
|
|
123
115
|
this.unscaled.dispose();
|
|
116
|
+
this.noLiveCounts.dispose();
|
|
124
117
|
this.passes?.dispose();
|
|
125
118
|
this.passes = null;
|
|
126
119
|
}
|
|
127
|
-
|
|
128
|
-
if (this.isDisposed)
|
|
129
|
-
throw new Error("LodGpu: disposed");
|
|
130
|
-
}
|
|
131
|
-
layOut() {
|
|
132
|
-
this.layout.layOut(this.cameras.values());
|
|
133
|
-
}
|
|
134
|
-
buffersOf(camera) {
|
|
135
|
-
const buffers = this.cameras.get(camera);
|
|
136
|
-
if (!buffers)
|
|
137
|
-
throw new Error("LodGpu: no buffers for the camera");
|
|
138
|
-
return buffers;
|
|
139
|
-
}
|
|
140
|
-
sortBuffers({ words, floats, indices, fades, args }) {
|
|
120
|
+
makeBuffers() {
|
|
141
121
|
return {
|
|
142
|
-
words,
|
|
143
|
-
floats,
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
draws: this.layout.draws,
|
|
122
|
+
words: wordsBuffer(1),
|
|
123
|
+
floats: floatsBuffer(),
|
|
124
|
+
blockCount: 1,
|
|
125
|
+
liveCounts: null,
|
|
126
|
+
indices: new StorageBufferAttribute(new Uint32Array(1), 1),
|
|
127
|
+
fades: new StorageBufferAttribute(new Float32Array(1), 1),
|
|
128
|
+
listSize: 0,
|
|
129
|
+
args: argsBuffer(this.draws.length),
|
|
130
|
+
due: false,
|
|
152
131
|
};
|
|
153
132
|
}
|
|
133
|
+
/** Grow `buffers`' lists to hold `instances` per level, by doubling, each buffer within `limit` bytes. */
|
|
134
|
+
grow(buffers, instances, limit) {
|
|
135
|
+
let size = Math.max(buffers.listSize, 1);
|
|
136
|
+
while (size < instances)
|
|
137
|
+
size *= 2;
|
|
138
|
+
const slots = countBits(this.listed) * size;
|
|
139
|
+
if (slots * 4 > limit)
|
|
140
|
+
throw new RangeError(`Lod: lists of ${size} instances for each of its ${countBits(this.listed)} levels take ${slots * 4} bytes, more than the device's storage binding of ${limit} bytes: draw fewer instances in view of one camera per Lod, or raise maxStorageBufferBindingSize in the renderer's requiredLimits`);
|
|
141
|
+
buffers.indices.dispose();
|
|
142
|
+
buffers.fades.dispose();
|
|
143
|
+
buffers.indices = new StorageBufferAttribute(new Uint32Array(slots), 1);
|
|
144
|
+
buffers.fades = new StorageBufferAttribute(new Float32Array(slots), 1);
|
|
145
|
+
buffers.listSize = size;
|
|
146
|
+
}
|
|
147
|
+
/** Write the blocks of `ranges` into `buffers`, growing its words: one empty block for none, as a dispatch visits one at least. */
|
|
148
|
+
writeBlocks(buffers, ranges) {
|
|
149
|
+
let count = 0;
|
|
150
|
+
for (let i = 0; i < ranges.length; i += 3)
|
|
151
|
+
count += Math.ceil((ranges[i + 1] ?? 0) / BLOCK);
|
|
152
|
+
if (count > MAX_BLOCKS)
|
|
153
|
+
throw new RangeError(`Lod: a camera sees ${count} blocks of ${BLOCK} instances, more than one dispatch's ${MAX_BLOCKS}: split the instances across Lods`);
|
|
154
|
+
if (buffers.words.array.length < BLOCKS_AT + Math.max(count, 1) * 4) {
|
|
155
|
+
buffers.words.dispose();
|
|
156
|
+
buffers.words = wordsBuffer(count);
|
|
157
|
+
}
|
|
158
|
+
const words = buffers.words.array;
|
|
159
|
+
let at = BLOCKS_AT;
|
|
160
|
+
for (let i = 0; i < ranges.length; i += 3) {
|
|
161
|
+
const start = ranges[i] ?? 0;
|
|
162
|
+
const end = start + (ranges[i + 1] ?? 0);
|
|
163
|
+
const live = ranges[i + 2] ?? NO_LIVE_COUNT;
|
|
164
|
+
for (let first = start; first < end; first += BLOCK, at += 4)
|
|
165
|
+
words.set([first, end, start, live], at);
|
|
166
|
+
}
|
|
167
|
+
if (count === 0)
|
|
168
|
+
words.set([0, 0, 0, NO_LIVE_COUNT], at);
|
|
169
|
+
buffers.blockCount = Math.max(count, 1);
|
|
170
|
+
buffers.words.needsUpdate = true;
|
|
171
|
+
}
|
|
172
|
+
/** Write the layout of `buffers`' lists and the draw count into its row. */
|
|
173
|
+
place(buffers) {
|
|
174
|
+
const words = buffers.words.array;
|
|
175
|
+
words[INTS_AT.flags * 4 + 3] = this.draws.length;
|
|
176
|
+
words[INTS_AT.layout * 4] = buffers.listSize;
|
|
177
|
+
let next = 0;
|
|
178
|
+
for (let level = 0; level < MAX_LEVELS; level++) {
|
|
179
|
+
const on = (this.listed & (1 << level)) !== 0;
|
|
180
|
+
words[INTS_AT.starts * 4 + level] = on ? next : UNLISTED;
|
|
181
|
+
if (on)
|
|
182
|
+
next += buffers.listSize;
|
|
183
|
+
}
|
|
184
|
+
buffers.words.needsUpdate = true;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
function disposeBuffers({ words, floats, indices, fades, args }) {
|
|
188
|
+
for (const attribute of [words, floats, indices, fades, args])
|
|
189
|
+
attribute.dispose();
|
|
154
190
|
}
|
|
155
|
-
/**
|
|
156
|
-
function
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
191
|
+
/** Set bits of `mask`. */
|
|
192
|
+
function countBits(mask) {
|
|
193
|
+
let count = 0;
|
|
194
|
+
for (let bits = mask; bits !== 0; bits &= bits - 1)
|
|
195
|
+
count++;
|
|
196
|
+
return count;
|
|
161
197
|
}
|
|
162
198
|
//# sourceMappingURL=sort.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sort.js","sourceRoot":"","sources":["../../src/instanced/sort.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,
|
|
1
|
+
{"version":3,"file":"sort.js","sourceRoot":"","sources":["../../src/instanced/sort.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,+BAA+B,EAA4G,MAAM,cAAc,CAAC;AAEjM,OAAO,EAAE,UAAU,EAAmB,MAAM,mBAAmB,CAAC;AAIhE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,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CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC;QAC7C,IAAI,IAAI,GAAG,CAAC,CAAC;QACb,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,UAAU,EAAE,KAAK,EAAE,EAAE,CAAC;YAChD,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC;YAC9C,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC;YACzD,IAAI,EAAE;gBAAE,IAAI,IAAI,OAAO,CAAC,QAAQ,CAAC;QACnC,CAAC;QACD,OAAO,CAAC,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC;IACnC,CAAC;CACF;AAED,SAAS,cAAc,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAiB;IAC5E,KAAK,MAAM,SAAS,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC;QAAE,SAAS,CAAC,OAAO,EAAE,CAAC;AACrF,CAAC;AAED,0BAA0B;AAC1B,SAAS,SAAS,CAAC,IAAY;IAC7B,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,IAAI,IAAI,GAAG,IAAI,EAAE,IAAI,KAAK,CAAC,EAAE,IAAI,IAAI,IAAI,GAAG,CAAC;QAAE,KAAK,EAAE,CAAC;IAC5D,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1,30 +1,35 @@
|
|
|
1
1
|
import type { IndirectStorageBufferAttribute, StorageBufferAttribute, StorageInstancedBufferAttribute } from "three/webgpu";
|
|
2
|
-
|
|
2
|
+
import type { LodLiveCount } from "./clusters.js";
|
|
3
|
+
/** Instances per block of a range, one workgroup's lanes. */
|
|
4
|
+
export declare const BLOCK = 64;
|
|
5
|
+
/** WebGPU's guaranteed maxComputeWorkgroupsPerDimension: the most blocks one sort visits. */
|
|
6
|
+
export declare const MAX_BLOCKS = 65535;
|
|
7
|
+
/** The buffers the sort passes read and write: pointed at a camera's (row, blocks, lists, args) as it sorts. */
|
|
3
8
|
export interface SortBuffers {
|
|
4
|
-
/**
|
|
9
|
+
/** The camera's row, its u32s followed by its blocks, and its f32s (see rows.ts). */
|
|
5
10
|
words: StorageBufferAttribute;
|
|
6
11
|
floats: StorageBufferAttribute;
|
|
7
|
-
/** The
|
|
12
|
+
/** The live counts of the ranges the camera sorts (see `LodCluster.liveCount`). */
|
|
13
|
+
liveCounts: LodLiveCount["attribute"];
|
|
14
|
+
/** The instances' matrices, and survivors' scaled ones, which the level meshes draw while survivors scale. */
|
|
8
15
|
matrices: StorageInstancedBufferAttribute;
|
|
9
16
|
scaled: StorageInstancedBufferAttribute;
|
|
10
|
-
/** The camera's slots: per slot, the
|
|
17
|
+
/** The camera's slots: per slot, the instance it draws and its signed fade. */
|
|
11
18
|
indices: StorageBufferAttribute;
|
|
12
19
|
fades: StorageBufferAttribute;
|
|
13
|
-
/** Per
|
|
20
|
+
/** Per level, how many instances it holds for the camera: counted by updateInstance, cleared by the indirect pass. */
|
|
14
21
|
counts: StorageBufferAttribute;
|
|
15
|
-
/**
|
|
16
|
-
occupied: StorageBufferAttribute;
|
|
17
|
-
/** Every row's draws, from its first (see `drawWords` in rows.ts). */
|
|
22
|
+
/** The Lod's draws (see `drawWords` in rows.ts). */
|
|
18
23
|
draws: StorageBufferAttribute;
|
|
19
24
|
/** The camera's indirect draws, five words each, in the order of `draws`. */
|
|
20
25
|
args: IndirectStorageBufferAttribute;
|
|
21
26
|
}
|
|
22
|
-
/** The sort passes over `buffers`, their nodes pointed at other buffers by `point
|
|
23
|
-
export declare function sortPasses(buffers: SortBuffers
|
|
27
|
+
/** The sort passes over `buffers`, their nodes pointed at other buffers by `point`. */
|
|
28
|
+
export declare function sortPasses(buffers: SortBuffers): {
|
|
24
29
|
update: import("three/webgpu").ComputeNode;
|
|
25
30
|
indirect: import("three/webgpu").ComputeNode;
|
|
26
|
-
/** Point the passes at `
|
|
27
|
-
point(next: SortBuffers,
|
|
31
|
+
/** Point the passes at `next`, dispatching the update pass over its `blocks` blocks: before they run. */
|
|
32
|
+
point(next: SortBuffers, blocks: number): void;
|
|
28
33
|
dispose(): void;
|
|
29
34
|
};
|
|
30
35
|
export type SortPasses = ReturnType<typeof sortPasses>;
|