@null3d/engine 0.1.2 → 0.1.3
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/wasm/single/null3d.js +4 -4
- package/dist/wasm/single/null3d_bg.wasm +0 -0
- package/dist/wasm/threaded/null3d.js +4 -4
- package/dist/wasm/threaded/null3d_bg.wasm +0 -0
- package/docs/api/reference/engine.md +1 -1
- package/docs/cli/null3d.md +60 -4
- package/docs/concepts/quality-presets.md +2 -0
- package/docs/errors/E1404.md +5 -1
- package/docs/getting-started/cdn.md +1 -1
- package/docs/getting-started/first-scene.md +3 -1
- package/docs/getting-started/hosting.md +11 -3
- package/docs/getting-started/install.md +20 -0
- package/docs/getting-started/project-structure.md +1 -1
- package/docs/guides/agents.md +1 -1
- package/docs/guides/assets-pipeline.md +31 -6
- package/docs/guides/debugging.md +2 -0
- package/docs/guides/deploying.md +1 -1
- package/docs/guides/deterministic-simulation.md +5 -2
- package/docs/guides/performance.md +2 -0
- package/docs/guides/start-time.md +2 -0
- package/docs/guides/testing.md +20 -0
- package/docs/pages.md +1 -1
- package/docs/porting/verification.md +1 -1
- package/lib/errors/codes.js +6 -0
- package/lib/errors/fixes.js +1 -1
- package/lib/gpu/device-shaders.d.ts +5 -0
- package/lib/gpu/device-shaders.js +10 -1
- package/lib/gpu/variants.d.ts +25 -0
- package/lib/gpu/variants.js +75 -5
- package/lib/gpu/webgl2/backend.d.ts +22 -3
- package/lib/gpu/webgl2/backend.js +108 -22
- package/lib/gpu/webgl2/programs.d.ts +5 -0
- package/lib/gpu/webgl2/programs.js +25 -2
- package/lib/gpu/webgpu/backend.d.ts +34 -1
- package/lib/gpu/webgpu/backend.js +173 -27
- package/lib/gpu/webgpu/pipelines.d.ts +2 -2
- package/lib/gpu/webgpu/pipelines.js +15 -15
- package/lib/page/engine.js +62 -3
- package/lib/page/permutation-recording.d.ts +5 -3
- package/lib/page/permutation-recording.js +13 -7
- package/lib/quality/chooser.d.ts +2 -0
- package/lib/quality/chooser.js +4 -0
- package/lib/shader-artifact.json +1 -1
- package/lib/shared/version.d.ts +1 -1
- package/lib/shared/version.js +1 -1
- package/lib/workers/protocol.d.ts +29 -0
- package/lib/workers/render-worker.js +6 -3
- package/lib/workers/sketch-worker.js +6 -3
- package/package.json +1 -1
|
@@ -3754,13 +3754,13 @@ export function writeParticleRecords(id, count, first) {
|
|
|
3754
3754
|
function __wbg_get_imports() {
|
|
3755
3755
|
const import0 = {
|
|
3756
3756
|
__proto__: null,
|
|
3757
|
-
|
|
3757
|
+
__wbg___null3dWantJobWorkers_fb79ee3a7793eeaf: function() {
|
|
3758
3758
|
globalThis.__null3dWantJobWorkers();
|
|
3759
3759
|
},
|
|
3760
|
-
|
|
3760
|
+
__wbg_error_75431c505258125f: function(arg0, arg1) {
|
|
3761
3761
|
console.error(getStringFromWasm0(arg0, arg1));
|
|
3762
3762
|
},
|
|
3763
|
-
|
|
3763
|
+
__wbg_now_cba0f5047a8baddf: function() {
|
|
3764
3764
|
const ret = performance.now();
|
|
3765
3765
|
return ret;
|
|
3766
3766
|
},
|
|
@@ -3971,4 +3971,4 @@ async function __wbg_init(module_or_path) {
|
|
|
3971
3971
|
|
|
3972
3972
|
export { initSync, __wbg_init as default };
|
|
3973
3973
|
|
|
3974
|
-
export const coreSources = "
|
|
3974
|
+
export const coreSources = "98d22e5dcf6e2cb8";
|
|
Binary file
|
|
@@ -3754,13 +3754,13 @@ export function writeParticleRecords(id, count, first) {
|
|
|
3754
3754
|
function __wbg_get_imports(memory) {
|
|
3755
3755
|
const import0 = {
|
|
3756
3756
|
__proto__: null,
|
|
3757
|
-
|
|
3757
|
+
__wbg___null3dWantJobWorkers_fb79ee3a7793eeaf: function() {
|
|
3758
3758
|
globalThis.__null3dWantJobWorkers();
|
|
3759
3759
|
},
|
|
3760
|
-
|
|
3760
|
+
__wbg_error_75431c505258125f: function(arg0, arg1) {
|
|
3761
3761
|
console.error(getStringFromWasm0(arg0, arg1));
|
|
3762
3762
|
},
|
|
3763
|
-
|
|
3763
|
+
__wbg_now_cba0f5047a8baddf: function() {
|
|
3764
3764
|
const ret = performance.now();
|
|
3765
3765
|
return ret;
|
|
3766
3766
|
},
|
|
@@ -3987,4 +3987,4 @@ export function releaseInstance() {
|
|
|
3987
3987
|
dropMemoryViews();
|
|
3988
3988
|
}
|
|
3989
3989
|
|
|
3990
|
-
export const coreSources = "
|
|
3990
|
+
export const coreSources = "98d22e5dcf6e2cb8";
|
|
Binary file
|
|
@@ -591,7 +591,7 @@ The GPU path the engine draws with: core WebGPU, WebGPU in compatibility mode on
|
|
|
591
591
|
## `VERSION`
|
|
592
592
|
|
|
593
593
|
```ts
|
|
594
|
-
const VERSION: '0.1.
|
|
594
|
+
const VERSION: '0.1.3'
|
|
595
595
|
```
|
|
596
596
|
|
|
597
597
|
The engine version, which the WebAssembly core and this package always share.
|
package/docs/cli/null3d.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: cli/null3d
|
|
3
3
|
title: "The `null3d` command"
|
|
4
|
-
summary: "create, test, bench, check-addon, shot, upgrade, assets, mcp, shaders record."
|
|
4
|
+
summary: "create, test, bench, check-addon, shot, upgrade, assets, mcp, shaders record, shaders verify."
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# The `null3d` command
|
|
@@ -30,6 +30,8 @@ The command needs Node 20.19 or later, or Node 22.12 or later, as Vite 8 does.
|
|
|
30
30
|
| [`mcp`](#mcp) | Connect a coding agent to the live scene. |
|
|
31
31
|
| [`check-addon`](#check-addon) | Run the engine's checks for add-ons on a package. |
|
|
32
32
|
| [`assets`](#assets) | Optimize and convert models and textures. |
|
|
33
|
+
| [`shaders record`](#shaders-record) | Record the shader words that your pages draw with. |
|
|
34
|
+
| [`shaders verify`](#shaders-verify) | Check a production build against its shader list. |
|
|
33
35
|
| [`upgrade`](#upgrade) | Update a project's packages to one version. |
|
|
34
36
|
| [Where the commands draw](#where-the-commands-draw) | Which GPU and browser each command uses. |
|
|
35
37
|
|
|
@@ -581,6 +583,7 @@ flowchart LR
|
|
|
581
583
|
bunx @null3d/cli shaders record
|
|
582
584
|
bunx @null3d/cli shaders record --page / --page /level-2.html --live /
|
|
583
585
|
bunx @null3d/cli shaders record --live / --scroll
|
|
586
|
+
bunx @null3d/cli shaders record --live / --live-ms 60000
|
|
584
587
|
bunx @null3d/cli shaders record --base http://localhost:8080 --live /game.html --click "#play"
|
|
585
588
|
bunx @null3d/cli shaders record --manual --gpu webgl2 --preset low
|
|
586
589
|
```
|
|
@@ -589,9 +592,14 @@ bunx @null3d/cli shaders record --manual --gpu webgl2 --preset low
|
|
|
589
592
|
| --- | --- | --- |
|
|
590
593
|
| `--base <url>` | The address of a server that serves the pages with a development build of the engine | The command starts the project's own Vite dev server in the current folder |
|
|
591
594
|
| `--page <path>` | A page to record in hold mode, at the low and high presets on WebGPU and on WebGL2. Repeat it for each page. A path that names its own `hold=` time keeps it | `/`, when no `--live` page is named either |
|
|
592
|
-
| `--live <path>` | A page to record live on both GPU paths. It draws
|
|
595
|
+
| `--live <path>` | A page to record live on both GPU paths. It draws until its word set stops growing, and the recorder presses every button of its controls HUD. Repeat it for each page | `/`, when no `--page` is named either |
|
|
596
|
+
| `--live-ms <ms>` | The least time each live page draws, in milliseconds. A state that arrives with time, such as an idle camera turning a mesh into a fading band, needs a longer time. It does not reach a state that waits for a visitor's action, which `--manual`, `--steps` or a browser test does | 15000 |
|
|
597
|
+
| `--settle-ms <ms>` | How long the word set must stay unchanged before the recorder stops the page | 5000 |
|
|
598
|
+
| `--max-ms <ms>` | The longest time a live page draws before the recorder stops it. It is at least `--live-ms` | 60000 |
|
|
593
599
|
| `--scroll` | Scrolls each live page down to its end, one window's height at a time. After each step it waits until the page has asked for nothing for half a second, at least one second and at most fifteen | The live pages stay at their top |
|
|
600
|
+
| `--scroll-dwell <ms>` | Rests after each scroll step, for a state that arrives with time | 0 |
|
|
594
601
|
| `--click <selector>` | An element to press after each page loads, for a page whose engine starts on a click | No element is pressed |
|
|
602
|
+
| `--steps <file>` | A module whose default export, or `steps` export, is a function of `{ page, log, path }` that drives the page through its states. Use it for action-gated and time-based states | The recorder presses the controls HUD instead |
|
|
595
603
|
| `--extra <words>` | Words to add by hand, as hexadecimal numbers joined by commas, such as `0x10,0x14` | Only the recorded words |
|
|
596
604
|
| `--out <file>` | The list to write | `shader-permutations.txt` |
|
|
597
605
|
| `--replace` | Writes the run's words alone | The words join those that the list holds |
|
|
@@ -613,7 +621,53 @@ A page that fails gets a second try. A second failure stops the run with the pag
|
|
|
613
621
|
|
|
614
622
|
With `--manual`, the command opens one page in a window on your screen. Play through its menus, settings and levels, then press Enter in the terminal. Run it on both GPU paths at the low and high presets, as the automatic run records them. A reload starts a new recording, so record each page in a run of its own. A project's browser tests can write the list too, with `saveRecordedWords` from `@null3d/cli/shaders`, as [Record from your browser tests](../guides/assets-pipeline.md#record-from-your-browser-tests) shows.
|
|
615
623
|
|
|
616
|
-
A production build ignores the recording switch, so a page that `--base` names must come from a development build: the dev server, or `vite build --mode development`. The plugin's `urlSwitches` option also lets a production build read it.
|
|
624
|
+
A production build ignores the recording switch, so a page that `--base` names must come from a development build: the dev server, or `vite build --mode development`. The plugin's `urlSwitches` option also lets a production build read it.
|
|
625
|
+
|
|
626
|
+
Record again after the project gains a feature that draws with a new word, or a state that arrives later. A build whose list lacks a word skips the pipeline or pass that asks for it and reports the word. Check the build with [`shaders verify`](#shaders-verify).
|
|
627
|
+
|
|
628
|
+
A `--steps` module drives the page in the recorder's own browser. Its function takes the Playwright page, so it can press, wait and read the page as a browser test does:
|
|
629
|
+
|
|
630
|
+
```js
|
|
631
|
+
// steps.mjs
|
|
632
|
+
export default async function steps({ page }) {
|
|
633
|
+
await page.getByRole('button', { name: 'Play' }).click();
|
|
634
|
+
await page.waitForTimeout(20_000); // a state that arrives with time
|
|
635
|
+
}
|
|
636
|
+
```
|
|
637
|
+
|
|
638
|
+
## shaders verify
|
|
639
|
+
|
|
640
|
+
```mermaid
|
|
641
|
+
flowchart LR
|
|
642
|
+
verify["bunx @null3d/cli<br/>shaders verify"] --> build["A production build<br/>with the shader list"]
|
|
643
|
+
build --> pages["Each page on both<br/>GPU paths, driven<br/>through its states"]
|
|
644
|
+
pages --> word["A missing word fails<br/>the check, with its page<br/>and path"]
|
|
645
|
+
```
|
|
646
|
+
|
|
647
|
+
`shaders verify` builds your project for production with the shader list that the Vite plugin names. It serves the build and drives each page on both GPU paths. The engine reports each word that the list lacks, and the command fails when a page asks for one. A missed word then fails in CI, not in front of a player.
|
|
648
|
+
|
|
649
|
+
A pipeline or pass whose word is missing is skipped, so the rest of the page still draws.
|
|
650
|
+
|
|
651
|
+
```sh
|
|
652
|
+
bunx @null3d/cli shaders verify
|
|
653
|
+
bunx @null3d/cli shaders verify --live / --live /game.html --steps ./steps.mjs
|
|
654
|
+
bunx @null3d/cli shaders verify --base https://preview.example.com --live /
|
|
655
|
+
```
|
|
656
|
+
|
|
657
|
+
| Option | Effect | Without it |
|
|
658
|
+
| --- | --- | --- |
|
|
659
|
+
| `--base <url>` | The address of a server that serves a production build with the project's list | The command builds the project and serves the build |
|
|
660
|
+
| `--live <path>` | A page to drive. Repeat it for each page | `/` |
|
|
661
|
+
| `--click <selector>` | An element to press after each page loads | No element is pressed |
|
|
662
|
+
| `--steps <file>` | A module whose default export, or `steps` export, is a function of `{ page, log, path }` that drives the page through its states | The recorder presses the controls HUD and scrolls, if `--scroll` |
|
|
663
|
+
| `--scroll` | Scrolls each live page down to its end | The live pages stay at their top |
|
|
664
|
+
| `--scroll-dwell <ms>` | Rests after each scroll step, for a state that arrives with time | 0 |
|
|
665
|
+
| `--gpu <path>` | Checks `webgpu` or `webgl2` alone, or both joined by a comma | `webgpu,webgl2` |
|
|
666
|
+
| `--settle-ms <ms>` | Rests after the states are driven, so a late pipeline reports its word | 5000 |
|
|
667
|
+
| `--max-ms <ms>` | The longest a page may draw before the check reads its words | 60000 |
|
|
668
|
+
| `--timeout-ms <ms>` | The longest a page may take to load and start | 120000 |
|
|
669
|
+
|
|
670
|
+
The command prints one line for each page and path, and exits with 1 when any lacks a word. A page that the device cannot start on a path is reported as skipped, and the other pages and paths still run. Run it after the build that ships, with the same list. [When the list lacks a word](../guides/assets-pipeline.md#when-the-list-lacks-a-word) explains what a page does without a word.
|
|
617
671
|
|
|
618
672
|
## upgrade
|
|
619
673
|
|
|
@@ -653,13 +707,15 @@ Run it after you upgrade the engine alone, or when a page stops with [E1432](../
|
|
|
653
707
|
|
|
654
708
|
## Where the commands draw
|
|
655
709
|
|
|
656
|
-
`shot`, `test`, `bench`, `check-addon` and `shaders
|
|
710
|
+
`shot`, `test`, `bench`, `check-addon`, `shaders record` and `shaders verify` draw with Chrome for Testing on your computer's GPU. So does `mcp`, unless `--connect` drives your own Chrome. When the `CI` variable is set, they draw with Playwright's Chromium on SwiftShader, a GPU in software. Most CI machines have no GPU. Set `CI=1` to draw the software GPU's images on your own computer:
|
|
657
711
|
|
|
658
712
|
```sh
|
|
659
713
|
CI=1 bunx @null3d/cli shot --out ci-shot.png
|
|
660
714
|
CI=1 bunx @null3d/cli test --update-references
|
|
661
715
|
```
|
|
662
716
|
|
|
717
|
+
Both browsers draw the WebGPU path where the device offers it. A test browser of your own needs `--enable-unsafe-webgpu` ([Testing your sketch](../guides/testing.md#the-browser-must-take-the-webgpu-path)).
|
|
718
|
+
|
|
663
719
|
The two draw the edges of objects a little differently, so keep reference images for each. When Playwright's Chromium is missing, the command prints the command that installs it.
|
|
664
720
|
|
|
665
721
|
### Chrome for Testing
|
|
@@ -71,6 +71,8 @@ In the S4 benchmark, an 11-inch iPad Pro held 60 frames per second at Medium whi
|
|
|
71
71
|
|
|
72
72
|
The GPU path then caps the preset, because WebGL2 and WebGPU's compatibility mode lack features that the heavier presets use. For example, compatibility mode cannot draw multisampled float targets.
|
|
73
73
|
|
|
74
|
+
High and Ultra need WebGPU. A WebGL2 page runs Medium at most.
|
|
75
|
+
|
|
74
76
|
The [highest preset of each GPU path](quality-preset-tables.md#highest-preset-of-each-gpu-path) gives each cap.
|
|
75
77
|
|
|
76
78
|
A page can name a preset instead, such as a preset that a player picked in a menu. The GPU path still caps it:
|
package/docs/errors/E1404.md
CHANGED
|
@@ -11,12 +11,16 @@ summary: "An engine thread, or the drawing on the page, hit an error it could no
|
|
|
11
11
|
|
|
12
12
|
An engine thread, or the drawing on the page, hit an error it could not handle, such as a trap in the engine core. After the start, the thread stops its loop: the engine draws no new frames, and engine.onFailure receives this error. During the start, createEngine() stops the engine and rejects with this error.
|
|
13
13
|
|
|
14
|
+
- The message may quote a failed import of a table of shared shader paragraphs. An older build's module names a fixed table file, so a deploy that mixes builds can pair it with a table from another build. The browser reports that the module does not provide an export that it imports, such as AREA_LIGHTS_SHARED_126.
|
|
15
|
+
|
|
14
16
|
## How to fix it
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
When the message quotes a failed import of a shader table, rebuild the page with this version of the plugin. Or purge the host's cache. Otherwise this is an engine bug: report it with the message and the browser, then destroy the engine and start it again.
|
|
17
19
|
|
|
18
20
|
Report engine bugs on [GitHub Issues](https://github.com/null3d-engine/null3d/issues). Add the full message and [engine.report](../guides/debugging.md#how-the-engine-runs-on-this-device).
|
|
19
21
|
|
|
22
|
+
- If an older build's page shows this, rebuild it with this version of the plugin. That version names each table after its content, so the page cannot ask for an old table. A cache purge also removes the old files.
|
|
23
|
+
|
|
20
24
|
[Where problems appear](../guides/debugging.md#where-problems-appear) says where each kind of error reaches your code.
|
|
21
25
|
|
|
22
26
|
## Example message
|
|
@@ -71,7 +71,7 @@ A benchmark page may time a production build and still set switches, such as `?g
|
|
|
71
71
|
|
|
72
72
|
## One HTML file
|
|
73
73
|
|
|
74
|
-
Save this page, change the CDN address to your own, and serve it from a web server. A browser refuses the modules and workers of a page opened from a file on disk.
|
|
74
|
+
Save this page, change the CDN address to your own, and serve it from a web server. A browser refuses the modules and workers of a page opened from a file on disk. Serve it over HTTPS or open it as `localhost`; a browser that drives a test needs `--enable-unsafe-webgpu` ([Testing your sketch](../guides/testing.md#the-browser-must-take-the-webgpu-path)).
|
|
75
75
|
|
|
76
76
|
```html
|
|
77
77
|
<!doctype html>
|
|
@@ -122,7 +122,9 @@ The plugin sends the two headers that let the engine's threads share memory, and
|
|
|
122
122
|
bunx vite
|
|
123
123
|
```
|
|
124
124
|
|
|
125
|
-
Open the address that Vite prints.
|
|
125
|
+
Open the address that Vite prints. Serve the page over HTTPS or open it as `localhost`, and give the browser WebGPU.
|
|
126
|
+
|
|
127
|
+
[Hosting and cross-origin isolation](hosting.md#during-development) gives the certificate, and [Testing your sketch](../guides/testing.md#the-browser-must-take-the-webgpu-path) gives the browser switch. `bunx vite build` writes the production files, and `bunx vite preview` serves them with the same headers.
|
|
126
128
|
|
|
127
129
|
## Next steps
|
|
128
130
|
|
|
@@ -260,7 +260,11 @@ Over HTTP/1.1 a browser opens at most six connections to one server, and each la
|
|
|
260
260
|
|
|
261
261
|
</details>
|
|
262
262
|
|
|
263
|
-
Vite names
|
|
263
|
+
Vite names its own files in `assets/` with a hash of their content. The null3D plugin does the same for the shader copies and the tables of shared shader paragraphs that it emits. Such a file under a given name never changes, and a changed file has a new name.
|
|
264
|
+
|
|
265
|
+
Vite names a page or worker chunk before the plugin edits a copy name inside it. A chunk may therefore keep its name when only a copy changes. A browser that kept an old chunk can then ask for a copy that the new build removed. The engine warns and draws without that shader.
|
|
266
|
+
|
|
267
|
+
Serve one build's files together. Serve them with a long cache lifetime, and serve the HTML page so that browsers check it each time:
|
|
264
268
|
|
|
265
269
|
```text
|
|
266
270
|
/assets/*
|
|
@@ -412,9 +416,13 @@ The dev server compresses its answers to every request from another device, and
|
|
|
412
416
|
|
|
413
417
|
</details>
|
|
414
418
|
|
|
415
|
-
|
|
419
|
+
Serve every development page and every preview over HTTPS. The exception is a page on `localhost` or `127.0.0.1`, which is a secure context already. A phone or tablet reaches the page over a network address, and that address needs HTTPS. Without a secure context the engine runs single-threaded and falls back to WebGL2 at Medium, with no error.
|
|
420
|
+
|
|
421
|
+
A browser that drives a test must also start with `--enable-unsafe-webgpu`. Playwright's Chromium reports `navigator.gpu` but offers no adapter without that switch, so the engine draws WebGL2. HTTPS alone does not give a test suite WebGPU. [Testing your sketch](../guides/testing.md#the-browser-must-take-the-webgpu-path) gives the browser setup.
|
|
422
|
+
|
|
423
|
+
An Android phone connected by USB can reach your computer's `localhost` through `adb reverse tcp:5173 tcp:5173`.
|
|
416
424
|
|
|
417
|
-
To test on a phone or tablet over your local network,
|
|
425
|
+
To test on a phone or tablet over your local network, add a local certificate. Make one with [mkcert](https://github.com/FiloSottile/mkcert), for `localhost` and your computer's network name:
|
|
418
426
|
|
|
419
427
|
```sh
|
|
420
428
|
mkdir certs
|
|
@@ -68,6 +68,26 @@ The built file of your sketch, and of each add-on's task, names every file that
|
|
|
68
68
|
|
|
69
69
|
The build's files may come from a CDN, with the HTML page on your own origin. [The engine's files on a CDN](hosting.md#the-engines-files-on-a-cdn) gives the headers and the policy that this needs.
|
|
70
70
|
|
|
71
|
+
## Serve over HTTPS
|
|
72
|
+
|
|
73
|
+
WebGPU and the High and Ultra presets need a secure page. `localhost` and `127.0.0.1` are secure already. A phone or tablet on your network is not, so serve it over HTTPS with a local certificate.
|
|
74
|
+
|
|
75
|
+
Make a certificate for `localhost` and your computer's network name:
|
|
76
|
+
|
|
77
|
+
```sh
|
|
78
|
+
mkdir certs
|
|
79
|
+
mkcert -cert-file certs/cert.pem -key-file certs/key.pem localhost my-computer.local
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Turn on the plugin's `https` option, and keep `certs` out of version control because it holds a private key:
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
// vite.config.ts
|
|
86
|
+
export default defineConfig({ plugins: [null3d({ https: true, certDir: 'certs' })] });
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Install mkcert's root certificate on every device that opens the page. A browser that drives a test must also start with `--enable-unsafe-webgpu`, or it draws WebGL2. [Hosting and cross-origin isolation](hosting.md#during-development) gives the certificate steps, and [Testing your sketch](../guides/testing.md#the-browser-must-take-the-webgpu-path) gives the browser setup.
|
|
90
|
+
|
|
71
91
|
## Run the sketch
|
|
72
92
|
|
|
73
93
|
Write `page.ts` and `sketch.ts` as [Your first scene](first-scene.md) shows, then start Vite:
|
|
@@ -35,7 +35,7 @@ bun install
|
|
|
35
35
|
bunx vite
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
`create` writes the template's files, and it writes the version of the command into each package pin. It installs nothing, so run `bun install` in the new folder.
|
|
38
|
+
`create` writes the template's files, and it writes the version of the command into each package pin. It installs nothing, so run `bun install` in the new folder. `bunx vite` serves the project on `localhost`, which is a secure context, so WebGPU is available. A browser that drives a test needs `--enable-unsafe-webgpu` ([Testing your sketch](../guides/testing.md#the-browser-must-take-the-webgpu-path)).
|
|
39
39
|
|
|
40
40
|
| Option | Effect | Without it |
|
|
41
41
|
| --- | --- | --- |
|
package/docs/guides/agents.md
CHANGED
|
@@ -57,7 +57,7 @@ An agent checks its work with the `null3d` command, which prints short lines of
|
|
|
57
57
|
3. Read the lines that it prints: pass or fail for each check, the reason, and the image files.
|
|
58
58
|
4. When an image test fails, open the image and its diff. Fix the code, or keep the new image with `bunx @null3d/cli test --update-references` when the change was on purpose.
|
|
59
59
|
|
|
60
|
-
`bunx @null3d/cli shot` draws one frame of a page, to look at a change that has no test yet.
|
|
60
|
+
`bunx @null3d/cli shot` draws one frame of a page, to look at a change that has no test yet. The command's browser draws the WebGPU path where the device offers it. A browser of your own needs `--enable-unsafe-webgpu` ([Testing your sketch](testing.md#the-browser-must-take-the-webgpu-path)).
|
|
61
61
|
|
|
62
62
|
## The MCP server
|
|
63
63
|
|
|
@@ -536,7 +536,8 @@ Build such an app without a list. The build copies the whole set, and each page
|
|
|
536
536
|
|
|
537
537
|
An app whose content is all in the build can ship a list. Keep the list complete:
|
|
538
538
|
|
|
539
|
-
- Run
|
|
539
|
+
- Run `bunx @null3d/cli shaders verify` against the production build with the list. It drives every page on both GPU paths and fails when the engine reports a missing word. [Check the production build](#check-the-production-build) shows the command.
|
|
540
|
+
- Run your browser tests against the production build with the list too. A missing word leaves the pipeline or pass without its shader, and the engine reports the word. [Record from your browser tests](#record-from-your-browser-tests) shows how the same tests can write the list.
|
|
540
541
|
- Record again after you add a feature, a material or a level. The dev server also warns about a word that the list lacks, as [When the list lacks a word](#when-the-list-lacks-a-word) says.
|
|
541
542
|
|
|
542
543
|
### Record the list
|
|
@@ -549,9 +550,13 @@ bunx @null3d/cli shaders record --page / --live /
|
|
|
549
550
|
|
|
550
551
|
A held page (`--page`) loads in hold mode at the low and high quality presets, on WebGPU and on WebGL2. A preset turns on a few bits, and each GPU path lists bits of its own. WebGL2 has the morph targets, and WebGPU has the instance index.
|
|
551
552
|
|
|
552
|
-
A live page (`--live`) loads on both GPU paths and draws
|
|
553
|
+
A live page (`--live`) loads on both GPU paths and draws until its word set stops growing. It draws at least fifteen seconds, then until five seconds pass with no new word, and at most sixty seconds. `--live-ms`, `--settle-ms` and `--max-ms` set those times. The recorder presses every button of the page's controls HUD, when it has one, so the words of those states reach the list. Without either option, the command records `/` both ways. It writes `shader-permutations.txt`, or the file that `--out` names. [The `null3d` command](../cli/null3d.md#shaders-record) lists every option.
|
|
553
554
|
|
|
554
|
-
|
|
555
|
+
Some states arrive only after the page has drawn for a while. An idle camera can turn a mesh into a level of detail's fading band. A day and night cycle can change the look. A stage can load after the first frame. Give such a page a longer `--live-ms`, and a longer `--max-ms`, so the recorder is still drawing when the state arrives.
|
|
556
|
+
|
|
557
|
+
A state that waits for a visitor's action needs a person or a test. Play it with `--manual`, or drive it from a browser test, as [Record by hand](#record-by-hand) and [Record from your browser tests](#record-from-your-browser-tests) show. A project can also give the recorder its own steps with `--steps <file>`: a module whose function of `{ page, log, path }` drives the page, so the same steps record and verify its states.
|
|
558
|
+
|
|
559
|
+
A page that builds more of its scene as the visitor scrolls needs `--scroll`. The recorder then scrolls each live page down to its end, one window's height at a time. After each step, it waits until the page has asked for nothing for half a second. `--scroll-dwell <ms>` also rests each step for a state that arrives with time. So each stage that a scroll reveals has loaded its shaders, and its pipelines have asked for their words.
|
|
555
560
|
|
|
556
561
|
A game page that starts its engine on a click needs `--live` pages and `--click <selector>`, such as `--click "#play"`. Pages that another server serves take `--base <url>`. That server must serve a development build, because a production build ignores the recording switch. The [deterministic simulation guide](deterministic-simulation.md#a-production-build-of-a-games-engine-files) gives the full sequence for a game.
|
|
557
562
|
|
|
@@ -602,6 +607,8 @@ test('plays the first level', async ({ page }) => {
|
|
|
602
607
|
|
|
603
608
|
The `saveRecordedWords` call ends the page's recording, waits until the engine publishes its words, and adds them to the list. With `{ replace: true }` it writes them alone. The page must run a development build, such as the dev server. A production build ignores the recording switch, unless the plugin's `urlSwitches` option is on. Run the tests on both GPU paths at the low and high presets, as the switches in the address above do for one of them.
|
|
604
609
|
|
|
610
|
+
The test browser must take the WebGPU path, or the WebGPU words never reach the list. [Testing your sketch](testing.md#the-browser-must-take-the-webgpu-path) gives the setup.
|
|
611
|
+
|
|
605
612
|
### Build with the list
|
|
606
613
|
|
|
607
614
|
Name the list in the plugin's options. The path is relative to Vite's root:
|
|
@@ -642,16 +649,34 @@ With null3D 0.1.0's shader set, the builds copied these shader files:
|
|
|
642
649
|
|
|
643
650
|
A listed word that no shader build of the project holds stops the build, and the message names the word. The builds are those of the engine's set and of the project's own shaders, such as its custom materials and its add-ons' shaders. Such a word comes from a typing mistake, or from a list that another version of the engine recorded. Record the list again.
|
|
644
651
|
|
|
645
|
-
A page that asks for a word that the list lacks
|
|
652
|
+
A page that asks for a word that the list lacks draws without it. A pipeline whose word is missing draws nothing, and an engine pass whose shader is missing does nothing. A later pass that reads a skipped pass's target draws from a blank target, so that part of the scene can be lost. The engine reports the word once and keeps drawing.
|
|
653
|
+
|
|
654
|
+
A shader file that fails to load leaves the pipeline or pass without its shader. The engine warns once and draws without it.
|
|
655
|
+
|
|
656
|
+
A table of shared shader paragraphs can also fail to load, and that fault is not a missing word. The browser reports that the module "does not provide an export named ...". This happens to a page that an older version of the plugin built: its modules name a fixed table file. A mixed deploy can then pair that page with a table from another build.
|
|
657
|
+
|
|
658
|
+
Recording the list again does not fix it. Rebuild the page with this version of the plugin, or purge those files from the host's cache. Each table's name carries a hash of its content, so a current build never asks for an old table.
|
|
659
|
+
|
|
660
|
+
The engine publishes each missing word on `window.__null3dMissingWords`, and logs it once:
|
|
646
661
|
|
|
647
662
|
```text
|
|
648
|
-
|
|
663
|
+
null3D: engine template 7 asks for the permutation word 0x00000010, which the shader list lacks. The engine draws without it. Record the pages again with bunx @null3d/cli shaders record.
|
|
649
664
|
```
|
|
650
665
|
|
|
666
|
+
### Check the production build
|
|
667
|
+
|
|
668
|
+
`shaders verify` builds your project for production with its shader list, serves the build, and drives each page on both GPU paths. It fails when the engine reports a word that the list lacks:
|
|
669
|
+
|
|
670
|
+
```sh
|
|
671
|
+
bunx @null3d/cli shaders verify --live / --live /game.html --steps ./steps.mjs
|
|
672
|
+
```
|
|
673
|
+
|
|
674
|
+
`--base <url>` checks a build that another server holds. `--gpu` narrows the paths, and `--click`, `--scroll` and `--steps` drive a page's states. The command names each missing word, the page and the path. Run it in CI after the build that ships, so a missed word fails there and not in front of a player. [The null3D command](../cli/null3d.md#shaders-verify) lists every option.
|
|
675
|
+
|
|
651
676
|
The dev server names such a word before a build ships the page. It still draws with the whole set. When a page first draws with a word that the list lacks, the terminal and the browser's console show a warning:
|
|
652
677
|
|
|
653
678
|
```text
|
|
654
|
-
null3D: /level.html draws with the permutation word 0x00000010, which the shader list shader-permutations.txt lacks. The dev server draws it, but a production build with this list
|
|
679
|
+
null3D: /level.html draws with the permutation word 0x00000010, which the shader list shader-permutations.txt lacks. The dev server draws it, but a production build with this list skips the pipeline or pass that asks for the word and reports it. Record the page again with bunx @null3d/cli shaders record, add the word by hand with bunx @null3d/cli shaders record --extra 0x00000010, or check the build with bunx @null3d/cli shaders verify.
|
|
655
680
|
```
|
|
656
681
|
|
|
657
682
|
The terminal shows each word once, until the list changes. The dev server reads the list again after each change, so a word that a new recording adds stops the warning at once. A recording run shows no warning, because it adds its words to the list.
|
package/docs/guides/debugging.md
CHANGED
|
@@ -139,6 +139,8 @@ A bug that shows at one moment is easier to fix when every run reaches it. Hold
|
|
|
139
139
|
Drew no frame of /: E1408: hold mode stopped at 1 seconds, in frame 61: E1203: setPosition() got NaN for x on an object (slot 2). ...
|
|
140
140
|
```
|
|
141
141
|
|
|
142
|
+
The command's browser draws the WebGPU path where the device offers it. [Testing your sketch](testing.md#the-browser-must-take-the-webgpu-path) gives the setup for a browser of your own.
|
|
143
|
+
|
|
142
144
|
It also saves the errors and warnings that the page logged, with their stacks, in a JSON file. [Testing your sketch](testing.md) explains hold mode.
|
|
143
145
|
|
|
144
146
|
## Measure
|
package/docs/guides/deploying.md
CHANGED
|
@@ -50,7 +50,7 @@ Cross-Origin-Embedder-Policy: require-corp
|
|
|
50
50
|
|
|
51
51
|
[Headers on common hosts](../getting-started/hosting.md#headers-on-common-hosts) gives each file. Without the headers, the engine loads its single-threaded build. The page still runs, with the same API and features, on one thread. Files from other sites need CORS or `Cross-Origin-Resource-Policy` headers under isolation ([Files from other sites](../getting-started/hosting.md#files-from-other-sites)).
|
|
52
52
|
|
|
53
|
-
Serve the page over HTTPS. WebGPU and shared memory need a secure page. Over plain HTTP, the engine draws with WebGL2.
|
|
53
|
+
Serve the page over HTTPS. WebGPU and shared memory need a secure page. Over plain HTTP, the engine draws with WebGL2. A browser that drives a test must also start with `--enable-unsafe-webgpu`: [Testing your sketch](testing.md#the-browser-must-take-the-webgpu-path) gives the setup.
|
|
54
54
|
|
|
55
55
|
## Let browsers keep the files
|
|
56
56
|
|
|
@@ -221,12 +221,15 @@ The game's module then imports `createEngine` and `SKETCH` from the folder's `en
|
|
|
221
221
|
The shader modules decide most of the folder's size. Copy only the builds of the shader permutation words that the game draws with:
|
|
222
222
|
|
|
223
223
|
1. Build a development copy of the folder (`bunx vite build --mode development`). A production build ignores `?permutations`, `?gpu` and `?preset`, so a recording of it holds nothing.
|
|
224
|
-
2. Record the words from a run of the game's page, as [Build only the shader permutations you draw with](assets-pipeline.md#build-only-the-shader-permutations-you-draw-with) shows. The game's engine starts on a click, so name its page with `--live` and give the recorder the start control. Serve the game with its development folder, and give the recorder its address: `bunx @null3d/cli shaders record --base http://localhost:8080 --live /game.html --click "#play"`.
|
|
224
|
+
2. Record the words from a run of the game's page, as [Build only the shader permutations you draw with](assets-pipeline.md#build-only-the-shader-permutations-you-draw-with) shows. The game's engine starts on a click, so name its page with `--live` and give the recorder the start control. Serve the game with its development folder, and give the recorder its address: `bunx @null3d/cli shaders record --base http://localhost:8080 --live /game.html --click "#play"`. The recorder's browser takes the WebGPU path where the device offers it.
|
|
225
225
|
3. Name the list in the engine folder's config, as `null3d({ shaders: { list: 'shader-permutations.txt' } })`, and build the folder in production again. The build copies only the listed builds, from the release asset, and compiles nothing.
|
|
226
|
+
4. Record the states that a player opens, such as each level and menu. Use `--steps` with the game's own steps, `--manual`, or a browser test, as the assets guide shows. A single load of the game reaches only its first state.
|
|
226
227
|
|
|
227
228
|
With null3D 0.1.0's shader set, a small scene drew with 6 words. Its build copied 218 shader files and 17 MB, against 7,597 files and 4,115 MB without a list. Build the set again after each engine upgrade.
|
|
228
229
|
|
|
229
|
-
The shader modules in a release asset are the full set. A game that builds against that asset without a list copies every module into its files folder. The build then warns with the size that it copied. That can exceed the folder's file and byte limits.
|
|
230
|
+
The shader modules in a release asset are the full set. A game that builds against that asset without a list copies every module into its files folder. The build then warns with the size that it copied. That can exceed the folder's file and byte limits.
|
|
231
|
+
|
|
232
|
+
Record again after the game gains a feature that turns on a new word. Check the production build with `bunx @null3d/cli shaders verify`, which drives the pages on both GPU paths and fails on a word that the list lacks. The engine skips the pipeline or pass whose word is missing, and reports the word.
|
|
230
233
|
|
|
231
234
|
## API reference
|
|
232
235
|
|
|
@@ -14,6 +14,8 @@ This guide covers the frames. [A fast start](start-time.md) covers the wait befo
|
|
|
14
14
|
|
|
15
15
|
Measure before you change anything, so you know which cost matters. Add `?stats` to the page's address for a live overlay, or call `debug.stats(true)` in the sketch. Call `engine.measure(5)` for figures over a window. Run `bunx @null3d/cli bench` to measure a production build with no test code. Measure in every rendering mode and preset, over the whole camera path, with repeats: [Testing your sketch](testing.md#check-every-rendering-mode) says how. [Measure](#measure) below gives each figure.
|
|
16
16
|
|
|
17
|
+
The figures here name the path and preset that each one measured. On a page that fell back to WebGL2 they mean nothing: that path runs different code at Medium at most. [Testing your sketch](testing.md#the-browser-must-take-the-webgpu-path) keeps a test browser on the WebGPU path.
|
|
18
|
+
|
|
17
19
|
## Where frame time goes
|
|
18
20
|
|
|
19
21
|
```mermaid
|
|
@@ -329,6 +329,8 @@ Judge a start only on a production build that a host serves as above. The Vite d
|
|
|
329
329
|
|
|
330
330
|
A phone or tablet that tests the page must trust its certificate. Chrome keeps no file in its cache from a site whose certificate it accepted after a warning. Every load then downloads every file again: a reload of the dev server took 30 seconds instead of 15. Install the certificate's root on the device, as [During development](../getting-started/hosting.md#during-development) shows.
|
|
331
331
|
|
|
332
|
+
A browser that drives the test must also start with `--enable-unsafe-webgpu`, or it measures WebGL2. [Testing your sketch](testing.md#the-browser-must-take-the-webgpu-path) gives the browser setup.
|
|
333
|
+
|
|
332
334
|
## Measure a start
|
|
333
335
|
|
|
334
336
|
`engine.measure()` gives the start's times in its `load` figures ([Performance guide](performance.md#measure)):
|
package/docs/guides/testing.md
CHANGED
|
@@ -235,6 +235,26 @@ The engine reads these switches from the page's address in development builds: t
|
|
|
235
235
|
|
|
236
236
|
To use them in a production build of test pages, turn on the Vite plugin's `urlSwitches` option: `null3d({ urlSwitches: true })`. For a benchmark page that loads the CDN build, `bun run build:cdn --url-switches` does the same ([Try null3D from a CDN](../getting-started/cdn.md#production-and-development-entries)).
|
|
237
237
|
|
|
238
|
+
### The browser must take the WebGPU path
|
|
239
|
+
|
|
240
|
+
A browser that drives a test must start with `--enable-unsafe-webgpu`. Playwright's Chromium reports `navigator.gpu`, but its adapter request resolves to null without that switch. The engine then draws WebGL2 at Medium.
|
|
241
|
+
|
|
242
|
+
```ts
|
|
243
|
+
// playwright.config.ts
|
|
244
|
+
import { defineConfig } from '@playwright/test';
|
|
245
|
+
|
|
246
|
+
export default defineConfig({
|
|
247
|
+
use: {
|
|
248
|
+
ignoreHTTPSErrors: true,
|
|
249
|
+
launchOptions: { args: ['--enable-unsafe-webgpu'] },
|
|
250
|
+
},
|
|
251
|
+
});
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
`ignoreHTTPSErrors` lets the test browser open a page on a local certificate. It does not turn on WebGPU: the switch does that, and a plain `http://localhost` page is a secure context already.
|
|
255
|
+
|
|
256
|
+
A suite on WebGL2 at Medium passes while the shipped WebGPU path stays untested. High and Ultra exist only on WebGPU, with their larger shadow settings and higher render scale. Read `engine.capabilities.tier` in the page, or the `tier` field of `window.__null3dHold`, to prove which path drew the frame.
|
|
257
|
+
|
|
238
258
|
### Common switches
|
|
239
259
|
|
|
240
260
|
| Switch | Effect |
|
package/docs/pages.md
CHANGED
|
@@ -251,7 +251,7 @@ summary: The docs pages of each area and group.
|
|
|
251
251
|
|
|
252
252
|
| Page | What it covers |
|
|
253
253
|
| --- | --- |
|
|
254
|
-
| [The `null3d` command](cli/null3d.md) | create, test, bench, check-addon, shot, upgrade, assets, mcp, shaders record. |
|
|
254
|
+
| [The `null3d` command](cli/null3d.md) | create, test, bench, check-addon, shot, upgrade, assets, mcp, shaders record, shaders verify. |
|
|
255
255
|
|
|
256
256
|
## Errors
|
|
257
257
|
|
|
@@ -118,7 +118,7 @@ Write each accepted difference down, with its reason.
|
|
|
118
118
|
|
|
119
119
|
## Compare performance
|
|
120
120
|
|
|
121
|
-
Measure both apps on the same device, browser, window size and pixel ratio, with the display at 60 Hz. Time a production build of each app: `bunx vite build`, then `bunx vite preview`. Never time null3D on the dev server. The dev server runs the engine's development checks in every frame, so the port looks slower than it ships.
|
|
121
|
+
Measure both apps on the same device, browser, window size and pixel ratio, with the display at 60 Hz. Time a production build of each app: `bunx vite build`, then `bunx vite preview`. Never time null3D on the dev server. The dev server runs the engine's development checks in every frame, so the port looks slower than it ships. Give the browser WebGPU, as [Testing your sketch](../guides/testing.md#the-browser-must-take-the-webgpu-path) shows, or both apps run their WebGL2 path.
|
|
122
122
|
|
|
123
123
|
`bunx @null3d/cli bench` makes a production build of the null3D app, and measures it ([The `null3d` command](../cli/null3d.md#bench)):
|
|
124
124
|
|
package/lib/errors/codes.js
CHANGED
|
@@ -277,6 +277,12 @@ const DOCS = {
|
|
|
277
277
|
title: 'Engine thread failed',
|
|
278
278
|
cause: 'An engine thread, or the drawing on the page, hit an error it could not handle, such as a trap in the engine core. After the start, the thread stops its loop: the engine draws no new frames, and engine.onFailure receives this error. During the start, createEngine() stops the engine and rejects with this error.',
|
|
279
279
|
example: 'E1404: the render worker failed: out of memory.',
|
|
280
|
+
cases: [
|
|
281
|
+
"The message may quote a failed import of a table of shared shader paragraphs. An older build's module names a fixed table file, so a deploy that mixes builds can pair it with a table from another build. The browser reports that the module does not provide an export that it imports, such as AREA_LIGHTS_SHARED_126.",
|
|
282
|
+
],
|
|
283
|
+
fixCases: [
|
|
284
|
+
"If an older build's page shows this, rebuild it with this version of the plugin. That version names each table after its content, so the page cannot ask for an old table. A cache purge also removes the old files.",
|
|
285
|
+
],
|
|
280
286
|
},
|
|
281
287
|
E1405: {
|
|
282
288
|
title: 'Engine thread did not start',
|
package/lib/errors/fixes.js
CHANGED
|
@@ -47,7 +47,7 @@ export const ERROR_FIXES = {
|
|
|
47
47
|
E1401: 'End the sketch module with export default defineSketch(...), and pass that module to createEngine.',
|
|
48
48
|
E1402: 'Reinstall the engine package so all of its parts come from one version. If you build the engine from source, run bun run build again.',
|
|
49
49
|
E1403: 'Create objects in the setup function you pass to defineSketch, or later, never when the sketch module loads.',
|
|
50
|
-
E1404: '
|
|
50
|
+
E1404: "When the message quotes a failed import of a shader table, rebuild the page with this version of the plugin. Or purge the host's cache. Otherwise this is an engine bug: report it with the message and the browser, then destroy the engine and start it again.",
|
|
51
51
|
E1405: "Read the message: it names the worker that did not start, and why. The sketch worker also reports an error that your sketch's setup function threw: fix the setup function. Otherwise, check that the page is served with the isolation headers and that the engine files load. Allow the workers in the `worker-src` of a Content-Security-Policy, and report the error if it repeats.",
|
|
52
52
|
E1406: "Check that the host serves every file that the build wrote, at the paths that the build gave them. The engine's .wasm files, the KTX2 transcoder's files, the glTF loader's files, the meshopt decoder and the level planner's simplifier are among them. If the page loads at other times, the network dropped: reload the page.",
|
|
53
53
|
E1407: 'Give the sketch time to hold at in seconds, such as ?hold=1.5 or hold: 1.5. A bare ?hold holds at the time of the hold option, or at 0 without one.',
|
|
@@ -5,6 +5,11 @@ import { type DeviceShaders, type FirstUseShaders, type ShaderVariants } from '.
|
|
|
5
5
|
* gives it, for a device with those bits.
|
|
6
6
|
*/
|
|
7
7
|
export type DeviceModuleLoader = (bits: number, file: string | undefined) => Promise<FirstUseShaders>;
|
|
8
|
+
/** The error for a shader file that did not load, which a pipeline needs. Its cause is the load's. */
|
|
9
|
+
export declare class ShaderLoadError extends Error {
|
|
10
|
+
readonly reason: unknown;
|
|
11
|
+
constructor(reason: unknown, message: string);
|
|
12
|
+
}
|
|
8
13
|
/** The device shaders that a backend reads, which grow by another module when a pipeline needs it. */
|
|
9
14
|
export declare class DeviceShaderSet {
|
|
10
15
|
readonly shaders: DeviceShaders;
|
|
@@ -32,6 +32,15 @@ const HDR_FEATURES = new Set([
|
|
|
32
32
|
'fog_volume',
|
|
33
33
|
'taa',
|
|
34
34
|
]);
|
|
35
|
+
/** The error for a shader file that did not load, which a pipeline needs. Its cause is the load's. */
|
|
36
|
+
export class ShaderLoadError extends Error {
|
|
37
|
+
reason;
|
|
38
|
+
constructor(reason, message) {
|
|
39
|
+
super(message, { cause: reason });
|
|
40
|
+
this.reason = reason;
|
|
41
|
+
this.name = 'ShaderLoadError';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
35
44
|
/** The device shaders that a backend reads, which grow by another module when a pipeline needs it. */
|
|
36
45
|
export class DeviceShaderSet {
|
|
37
46
|
shaders;
|
|
@@ -88,7 +97,7 @@ export class DeviceShaderSet {
|
|
|
88
97
|
const key = this.loadModule(file, bits);
|
|
89
98
|
if (this.failures.has(key)) {
|
|
90
99
|
const reason = this.failures.get(key);
|
|
91
|
-
throw new
|
|
100
|
+
throw new ShaderLoadError(reason, `the engine could not download the shaders that a pipeline needs: ${reason instanceof Error ? reason.message : String(reason)}. Check the network, and that the page's build is deployed whole`);
|
|
92
101
|
}
|
|
93
102
|
return this.settled.has(key);
|
|
94
103
|
}
|
package/lib/gpu/variants.d.ts
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
import type { ShaderVariant, ShaderVariants } from '../generated/shaders.js';
|
|
2
|
+
/** The word as a list writes it: without the bits that a device fixes. */
|
|
3
|
+
export declare function listedWord(permutation: number): number;
|
|
4
|
+
/**
|
|
5
|
+
* The error for a pipeline whose loaded shader set has no variant that it asks for. Its `word` is
|
|
6
|
+
* the word as a list writes it, which names the entry to add.
|
|
7
|
+
*/
|
|
8
|
+
export declare class MissingVariantError extends Error {
|
|
9
|
+
readonly word: number;
|
|
10
|
+
constructor(word: number, message: string);
|
|
11
|
+
}
|
|
12
|
+
/** Reports a pipeline or pass whose shader variant the loaded set lacks, for it to skip. */
|
|
13
|
+
export declare function reportMissingVariant(pipeline: string, word: number): void;
|
|
14
|
+
/** Reports a pipeline or pass whose shader file failed to load, for it to skip. */
|
|
15
|
+
export declare function reportUnavailableShader(pipeline: string, reason: string): void;
|
|
2
16
|
/**
|
|
3
17
|
* The variant of a shader for a pipeline's permutation word, with output for `target`, or
|
|
4
18
|
* undefined when the shader has none. The word never holds the half precision bit, which the
|
|
@@ -20,3 +34,14 @@ export declare function missingVariant(permutation: number, listed?: boolean): s
|
|
|
20
34
|
* that the list lacks, as `missingVariant` does.
|
|
21
35
|
*/
|
|
22
36
|
export declare function missingShader(name: string, permutation: number, listed?: boolean): string;
|
|
37
|
+
/**
|
|
38
|
+
* The error for an engine pass whose shader the loaded set lacks. Its `word` is the word as a list
|
|
39
|
+
* writes it, and `shader` names the pass's shader for a report.
|
|
40
|
+
*/
|
|
41
|
+
export declare class MissingShaderError extends Error {
|
|
42
|
+
readonly shader: string;
|
|
43
|
+
readonly word: number;
|
|
44
|
+
constructor(shader: string, word: number, message: string);
|
|
45
|
+
}
|
|
46
|
+
/** The error for the engine pass of `name` whose shader the loaded set lacks. */
|
|
47
|
+
export declare function missingShaderError(name: string, permutation: number, listed?: boolean): MissingShaderError;
|