@drawcall/lod 0.3.0 → 0.4.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 +54 -0
- package/dist/instanced/clusters.js +151 -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 +26 -39
- package/dist/instanced/lists.js +42 -61
- 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 +15 -73
- package/dist/instanced/rows.js +16 -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 +32 -34
- package/dist/instanced/sort.js +162 -132
- package/dist/instanced/sort.js.map +1 -1
- package/dist/instanced/update.d.ts +16 -12
- package/dist/instanced/update.js +57 -84
- 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 +331 -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 +24 -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 +7 -7
- package/dist/three.js +4 -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
package/dist/instanced/sort.js
CHANGED
|
@@ -1,162 +1,192 @@
|
|
|
1
|
-
import { StorageInstancedBufferAttribute } from "three/webgpu";
|
|
2
|
-
import {
|
|
3
|
-
import { FLOATS_AT,
|
|
4
|
-
import { sortPasses } from "./update.js";
|
|
5
|
-
/**
|
|
1
|
+
import { StorageBufferAttribute, StorageInstancedBufferAttribute } from "three/webgpu";
|
|
2
|
+
import { MAX_LEVELS } from "../levels/draw.js";
|
|
3
|
+
import { FLOATS_AT, INTS_AT, 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);
|
|
15
16
|
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) {
|
|
17
|
+
/** `listed` tells, as a mask, which levels have an instance list: those that draw something. */
|
|
18
|
+
constructor(listed) {
|
|
19
|
+
this.listed = listed;
|
|
20
|
+
}
|
|
21
|
+
/** The meshes draw `draws` too, after those they have; where they start among the draws. */
|
|
22
|
+
appendDraws(draws) {
|
|
23
|
+
const first = this.draws.length;
|
|
24
|
+
this.draws.push(...draws);
|
|
25
|
+
this.drawBuffer.dispose();
|
|
26
|
+
this.drawBuffer = drawWords(this.draws);
|
|
27
|
+
for (const buffers of this.cameras.values()) {
|
|
28
|
+
buffers.args.dispose();
|
|
29
|
+
buffers.args = argsBuffer(this.draws.length);
|
|
30
|
+
this.place(buffers);
|
|
31
|
+
buffers.due = true;
|
|
32
|
+
}
|
|
33
|
+
return first;
|
|
34
|
+
}
|
|
35
|
+
/** Survivors' scaled matrices for `capacity` instances. */
|
|
36
|
+
scaledMatrices(capacity) {
|
|
37
|
+
if (this.scaled?.capacity !== capacity) {
|
|
38
|
+
this.scaled?.attribute.dispose();
|
|
39
|
+
this.scaled = { attribute: new StorageInstancedBufferAttribute(new Float32Array(capacity * 16), 16), capacity };
|
|
40
|
+
}
|
|
41
|
+
return this.scaled.attribute;
|
|
42
|
+
}
|
|
43
|
+
/** Where `camera`'s lists and indirect draws lie; null before a sort was written for it. */
|
|
44
|
+
slotsOf(camera) {
|
|
50
45
|
const buffers = this.cameras.get(camera);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return { indices, fades, args: { attribute: args, offset: this.layout.argsOffset(row) } };
|
|
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);
|
|
46
|
+
return buffers ? { indices: buffers.indices, fades: buffers.fades, args: { attribute: buffers.args, offset: 0 } } : null;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Write `values` as what `camera` sorts by, over the instances of `ranges` (start and count, flat), `instances` in
|
|
50
|
+
* all, sorted at the camera's next draw. Its lists grow to hold them, within `limit` bytes per buffer.
|
|
51
|
+
*/
|
|
52
|
+
write(camera, values, ranges, instances, limit) {
|
|
53
|
+
const buffers = this.cameras.get(camera) ?? this.makeBuffers();
|
|
54
|
+
this.cameras.set(camera, buffers);
|
|
55
|
+
if (instances > buffers.listSize)
|
|
56
|
+
this.grow(buffers, instances, limit);
|
|
57
|
+
this.writeBlocks(buffers, ranges);
|
|
69
58
|
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);
|
|
59
|
+
const words = buffers.words.array;
|
|
60
|
+
words.set([levels.count, levels.coarsest, forcedWord(levels.forced)], INTS_AT.levels * 4);
|
|
61
|
+
words.set([levels.empty, levels.fades, loaded, before], INTS_AT.masks * 4);
|
|
62
|
+
words.set([Number(ortho), Number(cull !== null), Number(cull?.survivors ?? false)], INTS_AT.flags * 4);
|
|
63
|
+
this.place(buffers);
|
|
64
|
+
const floats = buffers.floats.array;
|
|
65
|
+
floats.set(levels.maxPixels, FLOATS_AT.low * 4);
|
|
66
|
+
floats.set([eye.x, eye.y, eye.z, scale], FLOATS_AT.eye * 4);
|
|
67
|
+
floats.set([source.center.x, source.center.y, source.center.z, source.radius], FLOATS_AT.source * 4);
|
|
68
|
+
floats.set([progress, reach, cull?.near ?? 0, cull?.far ?? 1], FLOATS_AT.values * 4);
|
|
84
69
|
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);
|
|
70
|
+
floats.set([cull.eye.x, cull.eye.y, cull.eye.z, 0], FLOATS_AT.cullEye * 4);
|
|
71
|
+
frustum.planes.forEach(({ normal, constant }, i) => floats.set([normal.x, normal.y, normal.z, constant], (FLOATS_AT.planes + i) * 4));
|
|
88
72
|
buffers.floats.needsUpdate = true;
|
|
89
|
-
buffers.
|
|
90
|
-
buffers.due.add(row);
|
|
73
|
+
buffers.due = true;
|
|
91
74
|
}
|
|
92
|
-
/** Sort
|
|
93
|
-
run(camera) {
|
|
94
|
-
this.layOut();
|
|
75
|
+
/** Sort for `camera` on `renderer`, in one compute call, if due: before a level mesh draws for it. */
|
|
76
|
+
run(renderer, camera, matrices) {
|
|
95
77
|
const buffers = this.cameras.get(camera);
|
|
96
|
-
if (!buffers
|
|
78
|
+
if (!buffers?.due)
|
|
97
79
|
return;
|
|
98
|
-
const sort =
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
80
|
+
const sort = {
|
|
81
|
+
...buffers,
|
|
82
|
+
matrices,
|
|
83
|
+
scaled: this.scaled?.attribute ?? this.unscaled,
|
|
84
|
+
counts: this.counts,
|
|
85
|
+
draws: this.drawBuffer,
|
|
86
|
+
};
|
|
87
|
+
const passes = (this.passes ??= sortPasses(sort));
|
|
88
|
+
passes.point(sort, buffers.blockCount);
|
|
89
|
+
renderer.compute([passes.update, passes.indirect]);
|
|
90
|
+
buffers.due = false;
|
|
108
91
|
// The pass made the scaled matrices' buffer: only the GPU writes them.
|
|
109
|
-
if (scaled && scaled.array.length > 0)
|
|
110
|
-
|
|
92
|
+
if (this.scaled && this.scaled.attribute.array.length > 0)
|
|
93
|
+
this.scaled.attribute.array = new Float32Array(0);
|
|
111
94
|
}
|
|
112
|
-
/**
|
|
113
|
-
|
|
114
|
-
|
|
95
|
+
/** `camera` no longer draws the Lod: its buffers are freed. */
|
|
96
|
+
release(camera) {
|
|
97
|
+
const buffers = this.cameras.get(camera);
|
|
98
|
+
if (!buffers)
|
|
99
|
+
return;
|
|
100
|
+
this.cameras.delete(camera);
|
|
101
|
+
disposeBuffers(buffers);
|
|
115
102
|
}
|
|
116
103
|
dispose() {
|
|
117
|
-
this.isDisposed = true;
|
|
118
104
|
for (const buffers of this.cameras.values())
|
|
119
105
|
disposeBuffers(buffers);
|
|
120
106
|
this.cameras.clear();
|
|
121
|
-
this.
|
|
122
|
-
this.
|
|
107
|
+
this.drawBuffer.dispose();
|
|
108
|
+
this.counts.dispose();
|
|
109
|
+
this.scaled?.attribute.dispose();
|
|
123
110
|
this.unscaled.dispose();
|
|
124
111
|
this.passes?.dispose();
|
|
125
112
|
this.passes = null;
|
|
126
113
|
}
|
|
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 }) {
|
|
114
|
+
makeBuffers() {
|
|
141
115
|
return {
|
|
142
|
-
words,
|
|
143
|
-
floats,
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
draws: this.layout.draws,
|
|
116
|
+
words: wordsBuffer(),
|
|
117
|
+
floats: floatsBuffer(),
|
|
118
|
+
blocks: blocksBuffer(1),
|
|
119
|
+
blockCount: 1,
|
|
120
|
+
indices: new StorageBufferAttribute(new Uint32Array(1), 1),
|
|
121
|
+
fades: new StorageBufferAttribute(new Float32Array(1), 1),
|
|
122
|
+
listSize: 0,
|
|
123
|
+
args: argsBuffer(this.draws.length),
|
|
124
|
+
due: false,
|
|
152
125
|
};
|
|
153
126
|
}
|
|
127
|
+
/** Grow `buffers`' lists to hold `instances` per level, by doubling, each buffer within `limit` bytes. */
|
|
128
|
+
grow(buffers, instances, limit) {
|
|
129
|
+
let size = Math.max(buffers.listSize, 1);
|
|
130
|
+
while (size < instances)
|
|
131
|
+
size *= 2;
|
|
132
|
+
const slots = countBits(this.listed) * size;
|
|
133
|
+
if (slots * 4 > limit)
|
|
134
|
+
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`);
|
|
135
|
+
buffers.indices.dispose();
|
|
136
|
+
buffers.fades.dispose();
|
|
137
|
+
buffers.indices = new StorageBufferAttribute(new Uint32Array(slots), 1);
|
|
138
|
+
buffers.fades = new StorageBufferAttribute(new Float32Array(slots), 1);
|
|
139
|
+
buffers.listSize = size;
|
|
140
|
+
}
|
|
141
|
+
/** Write the blocks of `ranges` into `buffers`: one empty block for none, as a dispatch visits one at least. */
|
|
142
|
+
writeBlocks(buffers, ranges) {
|
|
143
|
+
let count = 0;
|
|
144
|
+
for (let i = 0; i < ranges.length; i += 2)
|
|
145
|
+
count += Math.ceil((ranges[i + 1] ?? 0) / BLOCK);
|
|
146
|
+
if (count > MAX_BLOCKS)
|
|
147
|
+
throw new RangeError(`Lod: a camera sees ${count} blocks of ${BLOCK} instances, more than one dispatch's ${MAX_BLOCKS}: split the instances across Lods`);
|
|
148
|
+
if (buffers.blocks.count < Math.max(count, 1)) {
|
|
149
|
+
buffers.blocks.dispose();
|
|
150
|
+
buffers.blocks = blocksBuffer(count);
|
|
151
|
+
}
|
|
152
|
+
const words = buffers.blocks.array;
|
|
153
|
+
let at = 0;
|
|
154
|
+
for (let i = 0; i < ranges.length; i += 2) {
|
|
155
|
+
const start = ranges[i] ?? 0;
|
|
156
|
+
const end = start + (ranges[i + 1] ?? 0);
|
|
157
|
+
for (let first = start; first < end; first += BLOCK)
|
|
158
|
+
words.set([first, end], 2 * at++);
|
|
159
|
+
}
|
|
160
|
+
if (count === 0)
|
|
161
|
+
words.set([0, 0], 0);
|
|
162
|
+
buffers.blockCount = Math.max(count, 1);
|
|
163
|
+
buffers.blocks.needsUpdate = true;
|
|
164
|
+
}
|
|
165
|
+
/** Write the layout of `buffers`' lists and the draw count into its row. */
|
|
166
|
+
place(buffers) {
|
|
167
|
+
const words = buffers.words.array;
|
|
168
|
+
words[INTS_AT.flags * 4 + 3] = this.draws.length;
|
|
169
|
+
words[INTS_AT.layout * 4] = buffers.listSize;
|
|
170
|
+
let next = 0;
|
|
171
|
+
for (let level = 0; level < MAX_LEVELS; level++) {
|
|
172
|
+
const on = (this.listed & (1 << level)) !== 0;
|
|
173
|
+
words[INTS_AT.starts * 4 + level] = on ? next : UNLISTED;
|
|
174
|
+
if (on)
|
|
175
|
+
next += buffers.listSize;
|
|
176
|
+
}
|
|
177
|
+
buffers.words.needsUpdate = true;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
function disposeBuffers({ words, floats, blocks, indices, fades, args }) {
|
|
181
|
+
for (const attribute of [words, floats, blocks, indices, fades, args])
|
|
182
|
+
attribute.dispose();
|
|
154
183
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
184
|
+
const blocksBuffer = (blocks) => new StorageBufferAttribute(new Uint32Array(Math.max(blocks, 1) * 2), 2);
|
|
185
|
+
/** Set bits of `mask`. */
|
|
186
|
+
function countBits(mask) {
|
|
187
|
+
let count = 0;
|
|
188
|
+
for (let bits = mask; bits !== 0; bits &= bits - 1)
|
|
189
|
+
count++;
|
|
190
|
+
return count;
|
|
161
191
|
}
|
|
162
192
|
//# 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;AAGhE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E;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,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAiB;IACpF,KAAK,MAAM,SAAS,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC;QAAE,SAAS,CAAC,OAAO,EAAE,CAAC;AAC7F,CAAC;AAED,MAAM,YAAY,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC,IAAI,sBAAsB,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAEjH,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,34 @@
|
|
|
1
1
|
import type { IndirectStorageBufferAttribute, StorageBufferAttribute, StorageInstancedBufferAttribute } from "three/webgpu";
|
|
2
|
-
/**
|
|
2
|
+
/** Instances per block of a range, one workgroup's lanes. */
|
|
3
|
+
export declare const BLOCK = 64;
|
|
4
|
+
/** WebGPU's guaranteed maxComputeWorkgroupsPerDimension: the most blocks one sort visits. */
|
|
5
|
+
export declare const MAX_BLOCKS = 65535;
|
|
6
|
+
/** The buffers the sort passes read and write: pointed at a camera's (row, blocks, lists, args) as it sorts. */
|
|
3
7
|
export interface SortBuffers {
|
|
4
|
-
/**
|
|
8
|
+
/** The camera's row: its u32s and its f32s (see rows.ts). */
|
|
5
9
|
words: StorageBufferAttribute;
|
|
6
10
|
floats: StorageBufferAttribute;
|
|
7
|
-
/**
|
|
11
|
+
/** Per block the camera sorts, its first instance and the end of its range. */
|
|
12
|
+
blocks: StorageBufferAttribute;
|
|
13
|
+
/** The instances' matrices, and survivors' scaled ones, which the level meshes draw while survivors scale. */
|
|
8
14
|
matrices: StorageInstancedBufferAttribute;
|
|
9
15
|
scaled: StorageInstancedBufferAttribute;
|
|
10
|
-
/** The camera's slots: per slot, the
|
|
16
|
+
/** The camera's slots: per slot, the instance it draws and its signed fade. */
|
|
11
17
|
indices: StorageBufferAttribute;
|
|
12
18
|
fades: StorageBufferAttribute;
|
|
13
|
-
/** Per
|
|
19
|
+
/** Per level, how many instances it holds for the camera: counted by updateInstance, cleared by the indirect pass. */
|
|
14
20
|
counts: StorageBufferAttribute;
|
|
15
|
-
/**
|
|
16
|
-
occupied: StorageBufferAttribute;
|
|
17
|
-
/** Every row's draws, from its first (see `drawWords` in rows.ts). */
|
|
21
|
+
/** The Lod's draws (see `drawWords` in rows.ts). */
|
|
18
22
|
draws: StorageBufferAttribute;
|
|
19
23
|
/** The camera's indirect draws, five words each, in the order of `draws`. */
|
|
20
24
|
args: IndirectStorageBufferAttribute;
|
|
21
25
|
}
|
|
22
|
-
/** The sort passes over `buffers`, their nodes pointed at other buffers by `point
|
|
23
|
-
export declare function sortPasses(buffers: SortBuffers
|
|
26
|
+
/** The sort passes over `buffers`, their nodes pointed at other buffers by `point`. */
|
|
27
|
+
export declare function sortPasses(buffers: SortBuffers): {
|
|
24
28
|
update: import("three/webgpu").ComputeNode;
|
|
25
29
|
indirect: import("three/webgpu").ComputeNode;
|
|
26
|
-
/** Point the passes at `
|
|
27
|
-
point(next: SortBuffers,
|
|
30
|
+
/** Point the passes at `next`, dispatching the update pass over its `blocks` blocks: before they run. */
|
|
31
|
+
point(next: SortBuffers, blocks: number): void;
|
|
28
32
|
dispose(): void;
|
|
29
33
|
};
|
|
30
34
|
export type SortPasses = ReturnType<typeof sortPasses>;
|