@yali-engine/render 0.0.0-stage → 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/dist/bvh.d.ts +66 -0
- package/dist/bvh.js +493 -0
- package/dist/bvh.js.map +1 -0
- package/dist/camera.d.ts +34 -0
- package/dist/camera.js +66 -0
- package/dist/camera.js.map +1 -0
- package/dist/cluster-build.d.ts +46 -0
- package/dist/cluster-build.js +179 -0
- package/dist/cluster-build.js.map +1 -0
- package/dist/cluster-pages.d.ts +70 -0
- package/dist/cluster-pages.js +203 -0
- package/dist/cluster-pages.js.map +1 -0
- package/dist/cluster-stream.d.ts +83 -0
- package/dist/cluster-stream.js +226 -0
- package/dist/cluster-stream.js.map +1 -0
- package/dist/culled-draws.d.ts +30 -0
- package/dist/culled-draws.js +103 -0
- package/dist/culled-draws.js.map +1 -0
- package/dist/debug-lines.d.ts +51 -0
- package/dist/debug-lines.js +158 -0
- package/dist/debug-lines.js.map +1 -0
- package/dist/device-profile.d.ts +100 -0
- package/dist/device-profile.js +131 -0
- package/dist/device-profile.js.map +1 -0
- package/dist/device.d.ts +39 -0
- package/dist/device.js +79 -0
- package/dist/device.js.map +1 -0
- package/dist/environment.d.ts +60 -0
- package/dist/environment.js +204 -0
- package/dist/environment.js.map +1 -0
- package/dist/extract.d.ts +74 -0
- package/dist/extract.js +194 -0
- package/dist/extract.js.map +1 -0
- package/dist/frame-graph.d.ts +112 -0
- package/dist/frame-graph.js +226 -0
- package/dist/frame-graph.js.map +1 -0
- package/dist/gpu-health.d.ts +74 -0
- package/dist/gpu-health.js +106 -0
- package/dist/gpu-health.js.map +1 -0
- package/dist/gpu-timer.d.ts +26 -0
- package/dist/gpu-timer.js +93 -0
- package/dist/gpu-timer.js.map +1 -0
- package/dist/headless.d.ts +28 -0
- package/dist/headless.js +91 -0
- package/dist/headless.js.map +1 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/lights.d.ts +81 -0
- package/dist/lights.js +247 -0
- package/dist/lights.js.map +1 -0
- package/dist/matrix.d.ts +6 -0
- package/dist/matrix.js +59 -0
- package/dist/matrix.js.map +1 -0
- package/dist/meshes.d.ts +411 -0
- package/dist/meshes.js +545 -0
- package/dist/meshes.js.map +1 -0
- package/dist/meshlets-decoder.d.ts +20 -0
- package/dist/meshlets-decoder.js +47 -0
- package/dist/meshlets-decoder.js.map +1 -0
- package/dist/meshlets.d.ts +186 -0
- package/dist/meshlets.js +1040 -0
- package/dist/meshlets.js.map +1 -0
- package/dist/occlusion.d.ts +51 -0
- package/dist/occlusion.js +188 -0
- package/dist/occlusion.js.map +1 -0
- package/dist/pick-decoder.d.ts +19 -0
- package/dist/pick-decoder.js +45 -0
- package/dist/pick-decoder.js.map +1 -0
- package/dist/pick.d.ts +86 -0
- package/dist/pick.js +452 -0
- package/dist/pick.js.map +1 -0
- package/dist/pipeline-cache.d.ts +53 -0
- package/dist/pipeline-cache.js +96 -0
- package/dist/pipeline-cache.js.map +1 -0
- package/dist/post-options.d.ts +109 -0
- package/dist/post-options.js +23 -0
- package/dist/post-options.js.map +1 -0
- package/dist/post-shaders.gen.d.ts +40 -0
- package/dist/post-shaders.gen.js +43 -0
- package/dist/post-shaders.gen.js.map +1 -0
- package/dist/post.d.ts +101 -0
- package/dist/post.js +555 -0
- package/dist/post.js.map +1 -0
- package/dist/render-plugin.d.ts +239 -0
- package/dist/render-plugin.js +633 -0
- package/dist/render-plugin.js.map +1 -0
- package/dist/scene.d.ts +406 -0
- package/dist/scene.js +2005 -0
- package/dist/scene.js.map +1 -0
- package/dist/shaders.gen.d.ts +40 -0
- package/dist/shaders.gen.js +43 -0
- package/dist/shaders.gen.js.map +1 -0
- package/dist/shadows.d.ts +104 -0
- package/dist/shadows.js +227 -0
- package/dist/shadows.js.map +1 -0
- package/dist/staging-ring.d.ts +41 -0
- package/dist/staging-ring.js +125 -0
- package/dist/staging-ring.js.map +1 -0
- package/dist/textures.d.ts +165 -0
- package/dist/textures.js +361 -0
- package/dist/textures.js.map +1 -0
- package/dist/tonemap.d.ts +45 -0
- package/dist/tonemap.js +141 -0
- package/dist/tonemap.js.map +1 -0
- package/dist/viewport.d.ts +78 -0
- package/dist/viewport.js +130 -0
- package/dist/viewport.js.map +1 -0
- package/dist/webgl2/plugin.d.ts +40 -0
- package/dist/webgl2/plugin.js +190 -0
- package/dist/webgl2/plugin.js.map +1 -0
- package/dist/webgl2/program.d.ts +27 -0
- package/dist/webgl2/program.js +74 -0
- package/dist/webgl2/program.js.map +1 -0
- package/dist/webgl2/renderer.d.ts +128 -0
- package/dist/webgl2/renderer.js +976 -0
- package/dist/webgl2/renderer.js.map +1 -0
- package/dist/webgl2/shaders.glsl.gen.d.ts +27 -0
- package/dist/webgl2/shaders.glsl.gen.js +20 -0
- package/dist/webgl2/shaders.glsl.gen.js.map +1 -0
- package/dist/webgl2/textures.d.ts +11 -0
- package/dist/webgl2/textures.js +82 -0
- package/dist/webgl2/textures.js.map +1 -0
- package/dist/webgl2/webgl2.d.ts +1 -0
- package/dist/webgl2/webgl2.js +4 -0
- package/dist/webgl2/webgl2.js.map +1 -0
- package/dist/worker-mode.d.ts +85 -0
- package/dist/worker-mode.js +204 -0
- package/dist/worker-mode.js.map +1 -0
- package/package.json +47 -3
- package/README.md +0 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meshlets-decoder.js","sourceRoot":"","sources":["../src/meshlets-decoder.ts"],"names":[],"mappings":"AAAA,sGAAsG;AACtG,6FAA6F;AAC7F,0FAA0F;AAC1F,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,EAAE,YAAY,EAAuB,MAAM,oBAAoB,CAAC;AAEvE,2HAA2H;AAC3H,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AAExC;;;GAGG;AACH,MA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GAAG,IAAI,WAAW,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;IAC/D,MAAM,kBAAkB,CAAC,KAAK,CAAC;IAC/B,IAAI,GAAG;QAAE,MAAM,iBAAiB,CAAC,KAAK,CAAC;IACvC,OAAO,YAAY,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;AAC9C,CAAC;AAED,oGAAoG;AACpG,OAAO,EAAE,iBAAiB,EAA8C,iBAAiB,EAAoB,UAAU,EAAkD,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { type PackedClusters } from './cluster-build.ts';
|
|
2
|
+
import { ClusterResidency } from './cluster-stream.ts';
|
|
3
|
+
/** The hierarchy builder (ADR-0111), now in `cluster-build.ts` (ADR-0113). */
|
|
4
|
+
export { buildClusterLod, packClusters, type PackedClusters } from './cluster-build.ts';
|
|
5
|
+
import type { FrameGraph } from './frame-graph.ts';
|
|
6
|
+
import type { MeshStore } from './meshes.ts';
|
|
7
|
+
import type { LinkedShader, PipelineCache } from './pipeline-cache.ts';
|
|
8
|
+
import type { ClusterHook, ClusterMotion, SceneRenderer } from './scene.ts';
|
|
9
|
+
/** What `renderPlugin({ meshlets })` takes (ADR-0100). */
|
|
10
|
+
export interface MeshletOptions {
|
|
11
|
+
/** Meshes with at least this many triangles in their finest LOD are clustered (default 4096). */
|
|
12
|
+
readonly minTriangles?: number;
|
|
13
|
+
/** The most cluster entries one frame may list (default 4M, 32 MB); a mesh whose instances could need more is drawn whole. */
|
|
14
|
+
readonly maxEntries?: number;
|
|
15
|
+
/**
|
|
16
|
+
* A cluster LOD hierarchy per mesh (ADR-0111, opt-in): groups of clusters simplified with their
|
|
17
|
+
* borders locked, level by level, and each instance draws the cut whose projected error is under
|
|
18
|
+
* the scene's `errorPx` (the instance LODs' threshold, `render.lodBias` included). Builds take
|
|
19
|
+
* ~8 ms per 1k triangles: give `pool` to make them on a decode worker.
|
|
20
|
+
*/
|
|
21
|
+
readonly lod?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Build the clusters on these decode workers (ADR-0113): a pool whose workers serve the
|
|
24
|
+
* `cluster-lod` decoder (`decodeClusterLod` from `@yali-engine/render/meshlets-decoder`). A mesh draws
|
|
25
|
+
* whole until its clusters arrive. Without it they are built on the main thread, as the mesh
|
|
26
|
+
* first appears.
|
|
27
|
+
*/
|
|
28
|
+
readonly pool?: ClusterBuildPool;
|
|
29
|
+
/**
|
|
30
|
+
* Streamed cluster pages (ADR-0134): a mesh converted with `yali convert --clusters --stream` draws
|
|
31
|
+
* its root pages at once and fetches the rest by HTTP `Range` as the view's cut asks for them (with
|
|
32
|
+
* `lod`). `inFlight` caps concurrent fetches (default 8); `fetch` replaces the HTTP fetch (a cache, tests).
|
|
33
|
+
*/
|
|
34
|
+
readonly stream?: {
|
|
35
|
+
readonly inFlight?: number;
|
|
36
|
+
readonly fetch?: PageFetch;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/** Fetches `length` bytes of `url` from `offset` (an HTTP `Range` request by default). */
|
|
40
|
+
export type PageFetch = (url: string, offset: number, length: number) => Promise<Uint8Array>;
|
|
41
|
+
/** The cluster cull without the page bits (devices with 8 storage buffers a stage): `note_pages` emptied, so the binding is unused. */
|
|
42
|
+
export declare function withoutPageBits(s: LinkedShader): LinkedShader;
|
|
43
|
+
/** What `meshlets({ pool })` needs of a decode pool (`DecodePool` from `@yali-engine/core` is one). */
|
|
44
|
+
export interface ClusterBuildPool {
|
|
45
|
+
decode<T>(name: string, bytes: Uint8Array): Promise<T>;
|
|
46
|
+
}
|
|
47
|
+
/** The meshlet support `renderPlugin` builds when given it. */
|
|
48
|
+
export interface MeshletSupport {
|
|
49
|
+
readonly options: MeshletOptions;
|
|
50
|
+
create(device: GPUDevice, scene: SceneRenderer, store: MeshStore): Promise<ClusterRenderer>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Cluster culling for big meshes (ADR-0100): pass it as `renderPlugin({ meshlets: meshlets() })`.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* import { meshlets } from '@yali-engine/render/meshlets';
|
|
57
|
+
* renderPlugin({ canvas, meshlets: meshlets({ minTriangles: 8192 }) });
|
|
58
|
+
*/
|
|
59
|
+
export declare function meshlets(options?: MeshletOptions): MeshletSupport;
|
|
60
|
+
export interface Clustered {
|
|
61
|
+
first: number;
|
|
62
|
+
count: number;
|
|
63
|
+
doubleSided: boolean;
|
|
64
|
+
/** Indices of all its clusters (an instance's most). */
|
|
65
|
+
indices: number;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Clusters on the CPU, in the layout the shaders read (ADR-0100, ADR-0111): 32 words per cluster
|
|
69
|
+
* (bounding sphere, normal cone, base vertex, where its vertices and triangle bytes start, its
|
|
70
|
+
* triangle count, flags, then its own and its parent's error spheres and errors, both 0 without a
|
|
71
|
+
* hierarchy), the clusters' local vertex indices, and their triangle bytes (each cluster's start
|
|
72
|
+
* rounded to 4). Pure: tested in Node.
|
|
73
|
+
*/
|
|
74
|
+
export declare class ClusterData {
|
|
75
|
+
words: Uint32Array<ArrayBuffer>;
|
|
76
|
+
f32: Float32Array<ArrayBuffer>;
|
|
77
|
+
count: number;
|
|
78
|
+
vertices: Uint32Array<ArrayBuffer>;
|
|
79
|
+
vertexCount: number;
|
|
80
|
+
triangles: Uint8Array<ArrayBuffer>;
|
|
81
|
+
triangleBytes: number;
|
|
82
|
+
meshes: number;
|
|
83
|
+
/**
|
|
84
|
+
* Clusters a mesh (interleaved vertices, 8 floats each; its finest LOD's indices) on this thread and
|
|
85
|
+
* appends them; with `lod`, its whole hierarchy (ADR-0111). Needs `MeshoptClusterizer.ready` (and
|
|
86
|
+
* the simplifier's for `lod`).
|
|
87
|
+
*/
|
|
88
|
+
build(vertices: Float32Array, indices: Uint32Array, baseVertex: number, doubleSided: boolean, lod?: boolean): Clustered;
|
|
89
|
+
/**
|
|
90
|
+
* Appends one mesh's packed clusters (`packClusters`, here or on a decode worker, ADR-0113): moves
|
|
91
|
+
* their vertex and triangle offsets to where they land and sets the mesh's base vertex and side.
|
|
92
|
+
*/
|
|
93
|
+
append(p: PackedClusters, baseVertex: number, doubleSided: boolean): Clustered;
|
|
94
|
+
}
|
|
95
|
+
/** The clustered meshes' data on the GPU, the cull passes and the draw. */
|
|
96
|
+
export declare class ClusterRenderer implements ClusterHook {
|
|
97
|
+
#private;
|
|
98
|
+
readonly device: GPUDevice;
|
|
99
|
+
version: number;
|
|
100
|
+
/** The clusters on the CPU (uploaded when they grow). */
|
|
101
|
+
readonly data: ClusterData;
|
|
102
|
+
/** Occlusion for clusters (ADR-0109; live): off culls them once, after both instance passes, as ADR-0100 did. */
|
|
103
|
+
occlusion: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Clustered shadow casters (ADR-0112; live): with a hierarchy (`lod`), casters at the view's cut, culled
|
|
106
|
+
* per cascade and pulled; without one the cascades draw clustered meshes whole (pulled costs more there).
|
|
107
|
+
* Off, they draw whole always. (ADR-0122's indexed casters were removed: slower whole frames, ADR-0139.)
|
|
108
|
+
*/
|
|
109
|
+
shadows: boolean;
|
|
110
|
+
/** Clustered motion (ADR-0112; live): off, the motion pass draws clustered meshes whole, as before. */
|
|
111
|
+
motion: boolean;
|
|
112
|
+
/** Streamed pages' residency (ADR-0134). */
|
|
113
|
+
readonly residency: ClusterResidency;
|
|
114
|
+
/** Pages fetched, their bytes, fetches that failed (ADR-0134). */
|
|
115
|
+
readonly streamStats: {
|
|
116
|
+
fetched: number;
|
|
117
|
+
bytes: number;
|
|
118
|
+
failed: number;
|
|
119
|
+
};
|
|
120
|
+
/** Meshes clustered and their clusters (for the counters). */
|
|
121
|
+
get stats(): {
|
|
122
|
+
meshes: number;
|
|
123
|
+
clusters: number;
|
|
124
|
+
};
|
|
125
|
+
constructor(device: GPUDevice, scene: SceneRenderer, store: MeshStore, o: MeshletOptions);
|
|
126
|
+
init(cache: PipelineCache): Promise<void>;
|
|
127
|
+
/** Whether mesh `mesh`'s finest LOD is drawn as clusters (the main view's slot then skips it). */
|
|
128
|
+
covers(mesh: number): boolean;
|
|
129
|
+
/** Meshes clustered on the pool and the milliseconds from request to arrival, summed (ADR-0113); meshes whose file carried their clusters (ADR-0121). */
|
|
130
|
+
readonly buildStats: {
|
|
131
|
+
meshes: number;
|
|
132
|
+
ms: number;
|
|
133
|
+
prebuilt: number;
|
|
134
|
+
};
|
|
135
|
+
/** Cluster builds still on the pool. */
|
|
136
|
+
get pending(): number;
|
|
137
|
+
/**
|
|
138
|
+
* Resolves when the clustered draw's pipelines for the current draw shader are built, and every
|
|
139
|
+
* mesh the store holds now has its clusters (the pool's builds arrived, ADR-0113).
|
|
140
|
+
*/
|
|
141
|
+
ready(): Promise<void>;
|
|
142
|
+
/**
|
|
143
|
+
* Draws frames until streamed pages stop arriving (ADR-0134): calls `frame` (one frame drawn) until no
|
|
144
|
+
* page is in flight or being asked for and none arrived for 8 frames in a row, at most `most` frames.
|
|
145
|
+
* For golden images, whose frame must not depend on when pages came. Immediate with nothing streamed.
|
|
146
|
+
*/
|
|
147
|
+
settled(frame: () => void, most?: number): Promise<void>;
|
|
148
|
+
/**
|
|
149
|
+
* Adds a cluster cull, reading the instance cull's `after` (ADR-0100, ADR-0109): `phase` 0 without
|
|
150
|
+
* occlusion; under occlusion 1 (after the first instance cull, drawn in the view's first pass) and
|
|
151
|
+
* 2 (after the recheck, drawn in the second).
|
|
152
|
+
*/
|
|
153
|
+
addCull(graph: FrameGraph, after: string, phase?: 0 | 1 | 2): void;
|
|
154
|
+
/** Draws phase `phase`'s visible clusters (in the scene's opaque pass it is called from). */
|
|
155
|
+
encodeDraw(pass: GPURenderPassEncoder, phase?: 0 | 1 | 2): void;
|
|
156
|
+
/**
|
|
157
|
+
* Adds the shadow casters' cluster cull after `after` (the instance cull, whose slot set 0 holds the
|
|
158
|
+
* casters): every cascade at once, read by `scene.shadow` (ADR-0112).
|
|
159
|
+
*/
|
|
160
|
+
addShadowCull(graph: FrameGraph, after: string): void;
|
|
161
|
+
/** Whether this frame's casters of mesh `mesh` are drawn as clusters (the cascades' slots then skip it). */
|
|
162
|
+
shadowCovers(mesh: number): boolean;
|
|
163
|
+
/** Draws cascade `cascade`'s clustered casters into the shadow pass (its viewport already set). */
|
|
164
|
+
encodeShadow(pass: GPURenderPassEncoder, cascade: number): void;
|
|
165
|
+
/**
|
|
166
|
+
* Whether the motion pass may skip the clustered meshes' slots: the clustered motion pipeline over
|
|
167
|
+
* `m`'s shader is built (it starts building on the first call).
|
|
168
|
+
*/
|
|
169
|
+
motionCovers(m: ClusterMotion): boolean;
|
|
170
|
+
/** Starts building the clustered motion pipeline over the motion pass's shader (`ready()` then awaits it). */
|
|
171
|
+
prepareMotion(motionShader: LinkedShader, format: GPUTextureFormat): void;
|
|
172
|
+
/** Draws the clusters this frame's view drew (every phase that ran) with the motion pipeline. */
|
|
173
|
+
encodeMotion(pass: GPURenderPassEncoder, m: ClusterMotion): void;
|
|
174
|
+
/** Clusters the last frame drew, over its phases: single- and double-sided (a diagnostic; reads back from the GPU). */
|
|
175
|
+
readCounts(): Promise<{
|
|
176
|
+
single: number;
|
|
177
|
+
double: number;
|
|
178
|
+
triangles: number;
|
|
179
|
+
drawReady: boolean;
|
|
180
|
+
jobs: number;
|
|
181
|
+
perPhase: number[];
|
|
182
|
+
shadow: number[];
|
|
183
|
+
motionReady: boolean;
|
|
184
|
+
}>;
|
|
185
|
+
destroy(): void;
|
|
186
|
+
}
|