From a5b0cf9920aa5cae71c468171fb760924acd021e Mon Sep 17 00:00:00 2001 From: Davide Cappellini Date: Sun, 1 Nov 2026 20:25:09 +0100 Subject: [PATCH] Add throwaway PixiJS v8 perf prototype (VTT scene + benchmark) Co-Authored-By: Claude Sonnet 5.5 --- prototype-pixi-perf/.gitignore | 3 + prototype-pixi-perf/README.md | 103 ++ prototype-pixi-perf/bench.mjs | 16 + prototype-pixi-perf/devbox.json | 17 + prototype-pixi-perf/devbox.lock | 84 ++ prototype-pixi-perf/index.html | 23 + prototype-pixi-perf/package-lock.json | 1323 +++++++++++++++++++++++++ prototype-pixi-perf/package.json | 19 + prototype-pixi-perf/src/main.ts | 464 +++++++++ prototype-pixi-perf/tsconfig.json | 13 + 10 files changed, 2065 insertions(+) create mode 100644 prototype-pixi-perf/.gitignore create mode 100644 prototype-pixi-perf/README.md create mode 100644 prototype-pixi-perf/bench.mjs create mode 100644 prototype-pixi-perf/devbox.json create mode 100644 prototype-pixi-perf/devbox.lock create mode 100644 prototype-pixi-perf/index.html create mode 100644 prototype-pixi-perf/package-lock.json create mode 100644 prototype-pixi-perf/package.json create mode 100644 prototype-pixi-perf/src/main.ts create mode 100644 prototype-pixi-perf/tsconfig.json diff --git a/prototype-pixi-perf/.gitignore b/prototype-pixi-perf/.gitignore new file mode 100644 index 0000000..425355e --- /dev/null +++ b/prototype-pixi-perf/.gitignore @@ -0,0 +1,3 @@ +node_modules +dist +.devbox diff --git a/prototype-pixi-perf/README.md b/prototype-pixi-perf/README.md new file mode 100644 index 0000000..b35c218 --- /dev/null +++ b/prototype-pixi-perf/README.md @@ -0,0 +1,103 @@ +# Pixi v8 VTT perf prototype (THROWAWAY) + +Question: can PixiJS v8 (8.22) render a VTT-sized scene smoothly on modest hardware? Measurement tool, not the product. + +## Run + +All commands through devbox (NixOS, nothing global): + +```sh +devbox run -- npm install +devbox run -- npm run dev # http://localhost:5173 +devbox run -- npm run dev -- --host # reachable from LAN +devbox run -- npm run build # tsc + vite build +``` + +URL params: `?renderer=webgl|webgpu` (force; overlay shows the renderer actually used), `?res=1` (canvas resolution, default min(dpr,2)), +`?bench=1` (auto-run benchmark on load), `?benchMs=5000&warmMs=700`. + +Controls (top right): map size, tile size override (auto = GPU max texture), local map image, grid on/off + cell size, token count, +chaos, HP churn, culling, tool (move / pen), +200 random strokes, Run benchmark (markdown table in the textarea; copy button). +Mouse: wheel = zoom, drag = pan / drag a token, pen tool: LMB draws, RMB/MMB pans. Touch: 1 finger = drag token / pan / draw, 2 fingers = pinch zoom + pan. + +## Test on mobile + +`devbox run -- npm run dev -- --host`, open `http://:5173` on the phone/tablet (same network; open the firewall for 5173 on NixOS if needed: +`networking.firewall.allowedTCPPorts`). Then use the on-screen overlay and the benchmark button. Not done in this session (no device available). + +## Headless benchmark (what produced the table below) + +`bench.mjs` drives chromium (from devbox) via playwright-core with SwiftShader (software GL): + +```sh +devbox run -- npm run build && devbox run -- npx vite preview --port 4173 & +devbox run -- bash -c 'CHROMIUM=$(which chromium) node bench.mjs http://localhost:4173/' +``` + +## Benchmark (headless Chromium 155, SwiftShader SOFTWARE GL, 1280x720, res 1, WebGL2, maxTex 8192) + +**CAVEAT: this is CPU-emulated GPU. Absolute numbers are NOT representative of any real GPU. Only the relative shape is informative. +No real-GPU, WebGPU or mobile numbers were collected; run the in-page button on target hardware and replace this table.** +fps is capped at 60 (rAF). `js ms` = JS time per frame measured after Pixi's render call; with software GL the driver blocks inside draw calls so it is inflated at high token counts. +Scenario = view fitted to whole map (so small maps show all tokens on screen, large maps show only a fraction), chaos on, grid on, cull on, 5 s each after warmup. + +| map | map path | tokens | strokes | fps | avg ms | p99 ms | worst ms | js ms | frames | +|---|---|---|---|---|---|---|---|---|---| +| 2048 | single | 50 | 0 | 59.8 | 16.7 | 29.9 | 30.3 | 0.9 | 299 | +| 2048 | single | 200 | 0 | 48.4 | 20.6 | 41.2 | 43.1 | 1.7 | 242 | +| 2048 | single | 500 | 0 | 31.0 | 32.3 | 36.3 | 38.0 | 4.2 | 154 | +| 2048 | single | 1000 | 0 | 20.1 | 49.9 | 54.6 | 54.6 | 7.8 | 100 | +| 2048 | single | 2000 | 0 | 11.5 | 86.9 | 94.2 | 94.2 | 85.7 | 59 | +| 4096 | single | 50 | 0 | 60.0 | 16.7 | 27.1 | 33.6 | 0.7 | 300 | +| 4096 | single | 200 | 0 | 56.5 | 17.7 | 33.3 | 34.5 | 1.7 | 282 | +| 4096 | single | 500 | 0 | 43.2 | 23.2 | 49.3 | 51.3 | 3.9 | 216 | +| 4096 | single | 1000 | 0 | 30.1 | 33.2 | 38.0 | 39.2 | 7.0 | 150 | +| 4096 | single | 2000 | 0 | 18.8 | 53.2 | 58.5 | 58.5 | 52.3 | 96 | +| 8192 | single | 50 | 0 | 60.1 | 16.6 | 26.1 | 29.3 | 0.7 | 300 | +| 8192 | single | 200 | 0 | 58.4 | 17.1 | 32.9 | 40.8 | 1.7 | 291 | +| 8192 | single | 500 | 0 | 48.0 | 20.8 | 40.2 | 41.0 | 3.9 | 240 | +| 8192 | single | 1000 | 0 | 36.4 | 27.5 | 33.2 | 39.8 | 7.3 | 182 | +| 8192 | single | 2000 | 0 | 23.4 | 42.8 | 48.5 | 49.1 | 42.2 | 118 | +| 16384 | 4 tiles | 50 | 0 | 59.7 | 16.8 | 28.0 | 33.0 | 0.7 | 298 | +| 16384 | 4 tiles | 200 | 0 | 58.1 | 17.2 | 32.2 | 34.2 | 2.2 | 290 | +| 16384 | 4 tiles | 500 | 0 | 48.1 | 20.8 | 38.3 | 40.6 | 4.8 | 240 | +| 16384 | 4 tiles | 1000 | 0 | 37.8 | 26.5 | 44.9 | 52.2 | 8.2 | 189 | +| 16384 | 4 tiles | 2000 | 0 | 25.4 | 39.3 | 45.4 | 46.0 | 38.7 | 129 | +| 4096 | single | 50 | 200 | 38.2 | 26.1 | 49.1 | 49.7 | 0.7 | 191 | +| 4096 | single | 500 | 200 | 28.2 | 35.4 | 45.5 | 111.9 | 4.7 | 141 | + +## Techniques used (v8) + +- **Map larger than max texture**: max texture read from the backend (`gl.getParameter(MAX_TEXTURE_SIZE)` / `device.limits.maxTextureDimension2D`); + if map > that (or > the "tile size" override) it is sliced into square tiles, each its own canvas -> `Texture.from(canvas)` -> `Sprite` at an integer position. + Overlay says SINGLE vs TILED. Here 16384 on a maxTex 8192 device = 2x2 tiles of 8192. +- **Culling**: manual `Culler.shared.cull(world, screen, false)` each frame (not the plugin, so it can be toggled); map tiles and stroke sprites are `cullable` + with bounds; tokens use a fixed `cullArea` rectangle (no per-frame bounds calc) and `cullableChildren = false`. +- **Token labels under HP churn**: `BitmapText` with a pre-installed `BitmapFont` (`BitmapFont.install`), not `Text`: changing `.text` only rebuilds quads, no canvas raster or GPU upload. + Circle bodies: one shared `GraphicsContext` per colour (6), tessellated once, reused by all tokens. Tokens are pooled (removed/added, never destroyed). +- **Grid**: one `TilingSprite` over a small cell texture (1 quad regardless of map size) rather than thousands of `Graphics` lines. +- **Stroke baking**: live stroke = `Graphics` chunks of <=48 points (only the last chunk is re-tessellated per move, older chunks frozen). On pointer up the chunks are rendered once with + `renderer.textureGenerator.generateTexture({target, frame, resolution, antialias})` into a `Sprite` and the Graphics are destroyed. + Bake resolution follows zoom (1..2), capped so no side exceeds 4096 px. +- **Input**: DOM pointer events on the canvas with a hand-rolled pan/zoom/pinch (pixi-viewport 6.0.3 declares `pixi.js >=8` peer, but token drag + pen + pinch needed custom handling anyway). + Pixi's federated event features are disabled; token hit test is an O(N) scan on press only. + +## Findings + +Measured (software GL only): +- Token count dominates. With a 4096 map at fit zoom: 50 tokens 60 fps, 500 ~43 fps, 2000 ~19 fps. On SwiftShader that is largely fill/raster of BitmapText glyph quads and circle geometry, so it says little about real GPUs. +- Map size alone barely matters (2048 vs 16384 comparable at equal on-screen token count); the 2048 rows are *slower* only because all tokens are on screen at once while larger maps cull most of them. So culling works and tiling (2x2) cost no visible fps. +- Worst-frame spikes of ~30-50 ms show up at 99th percentile even at 50 tokens (likely software rasteriser/GC; unverified). +- **200 baked strokes did cost FPS here** (4096/50 tokens: 60 -> 38 fps; 4096/500: ~43 -> 28 fps). It does not meet the "no noticeable drop" criterion on this renderer. JS time per frame did not change, and a draw-call counter showed only ~4-7 draws/frame with strokes present, so it is not batching/CPU; hiding the stroke layer restored 60 fps. + Hypothesis (NOT verified): SwiftShader sampling of 200 distinct, large (e.g. 380x550) un-mipmapped textures minified at zoom 0.16 is slow in software, and a real GPU would not show it. Candidate fixes to try on real hardware if it reproduces: bake into shared atlas / merge strokes into per-region tiles, mipmaps on stroke textures, or smaller bake resolution when zoomed out. +- Live drawing of a 400-point stroke (checked with scripted mouse, visual only, no timing) rendered and baked to a correctly-aligned sprite. + +Not measured / hypotheses: +- Everything on real GPUs, WebGPU (`?renderer=webgpu` untested), mobile/tablet, touch/pinch behaviour, HP churn and the Run-benchmark under churn (benchmark runs churn OFF; toggle is manual). +- Chaos at 2000 tokens costs per-frame `position.set` on 2000 containers: hypothesis that it is cheap on CPU; the `js ms` column is inflated by software GL blocking so it can't confirm. + +Worries for a real VTT: +- BitmapText atlas is rasterised at one font size: labels go blurry when zoomed in (needs MSDF or a zoom-dependent font), and the installed glyph set is Latin/digits only; non-Latin names need `Text`/HTMLText or a bigger atlas. +- 16384 px maps on a device with maxTex 16384 take the single-texture path = ~1 GB of GPU memory; on mobile (maxTex often 4096-8192, small VRAM) tiling is required and memory, not fps, is the limit. Use the tile-size override to force tiling and check memory on a device. Tile seams at fractional zoom were not inspected. +- Per-stroke textures: 200 strokes = 200 separate GPU textures (see above); a real session with thousands of strokes needs atlasing/merging and texture GC planning. Very long single strokes are baked at reduced resolution (4096 cap) and will look soft. +- Tokens are one Container + 2 children each; 2000 tokens = 6000 scene nodes touched per frame in chaos mode. diff --git a/prototype-pixi-perf/bench.mjs b/prototype-pixi-perf/bench.mjs new file mode 100644 index 0000000..183f410 --- /dev/null +++ b/prototype-pixi-perf/bench.mjs @@ -0,0 +1,16 @@ +// Headless benchmark runner: `devbox run -- npm run bench -- "http://localhost:5173/?benchMs=5000&renderer=webgl"` +// needs the dev/preview server running. Chromium from devbox ($CHROMIUM or `chromium` on PATH). SOFTWARE GL => not representative. +import { chromium } from 'playwright-core'; +const url = process.argv[2] ?? 'http://localhost:5173/'; +const b = await chromium.launch({ + executablePath: process.env.CHROMIUM ?? 'chromium', + args: ['--use-angle=swiftshader', '--enable-unsafe-swiftshader', '--ignore-gpu-blocklist', '--enable-unsafe-webgpu', '--no-sandbox'], +}); +const p = await b.newPage({ viewport: { width: 1280, height: 720 } }); +p.on('console', (m) => console.error('[page]', m.text())); +p.on('pageerror', (e) => console.error('[pageerror]', e.message)); +await p.goto(url); +await p.waitForFunction('window.__ready', null, { timeout: 60000 }); +if (process.env.SHOT) await p.screenshot({ path: process.env.SHOT }); +console.log(await p.evaluate('window.__app.runBench()')); +await b.close(); diff --git a/prototype-pixi-perf/devbox.json b/prototype-pixi-perf/devbox.json new file mode 100644 index 0000000..5424485 --- /dev/null +++ b/prototype-pixi-perf/devbox.json @@ -0,0 +1,17 @@ +{ + "$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.17.2/.schema/devbox.schema.json", + "packages": [ + "nodejs@latest", + "chromium@latest" + ], + "shell": { + "init_hook": [ + "echo 'Welcome to devbox!' > /dev/null" + ], + "scripts": { + "test": [ + "echo \"Error: no test specified\" && exit 1" + ] + } + } +} diff --git a/prototype-pixi-perf/devbox.lock b/prototype-pixi-perf/devbox.lock new file mode 100644 index 0000000..5291a38 --- /dev/null +++ b/prototype-pixi-perf/devbox.lock @@ -0,0 +1,84 @@ +{ + "lockfile_version": "1", + "packages": { + "chromium@latest": { + "last_modified": "2026-10-08T19:21:32Z", + "resolved": "github:NixOS/nixpkgs/8edc0c72e3a38faf5434e40d1f19431125fe4b30#chromium", + "source": "devbox-search", + "version": "155.0.8059.39", + "systems": { + "aarch64-linux": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/q56ri55nzhpwzhisgb2r0kilb61k4f5a-chromium-155.0.8059.39", + "default": true + }, + { + "name": "sandbox", + "path": "/nix/store/a1w34yg08mvma03xps5dsy8vw5hrdy9w-chromium-155.0.8059.39-sandbox" + } + ], + "store_path": "/nix/store/q56ri55nzhpwzhisgb2r0kilb61k4f5a-chromium-155.0.8059.39" + }, + "x86_64-linux": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/ky199ji3a5drs6rm3wr5zidamx9dhz56-chromium-155.0.8059.39", + "default": true + }, + { + "name": "sandbox", + "path": "/nix/store/5hpd396v5byrfp1vnw7zmpfscqd3b1zv-chromium-155.0.8059.39-sandbox" + } + ], + "store_path": "/nix/store/ky199ji3a5drs6rm3wr5zidamx9dhz56-chromium-155.0.8059.39" + } + } + }, + "github:NixOS/nixpkgs/nixpkgs-unstable": { + "last_modified": "2026-10-20T14:23:57Z", + "resolved": "github:NixOS/nixpkgs/5adc50831c259f87faeb09ddf930d43597197473?lastModified=1792506237&narHash=sha256-Q%2F8KLB6jNfpaUN1HAedE%2Fu%2FEt9feE%2FzYSsutBLKrCFk%3D" + }, + "nodejs@latest": { + "last_modified": "2026-10-08T19:21:32Z", + "plugin_version": "0.0.2", + "resolved": "github:NixOS/nixpkgs/8edc0c72e3a38faf5434e40d1f19431125fe4b30#nodejs_26", + "source": "devbox-search", + "version": "26.11.1", + "systems": { + "aarch64-darwin": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/42hvw959dvc16w7p79xns4p4sgfx2wiv-nodejs-26.11.1", + "default": true + } + ], + "store_path": "/nix/store/42hvw959dvc16w7p79xns4p4sgfx2wiv-nodejs-26.11.1" + }, + "aarch64-linux": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/zzx8zal1hmjkamrp8y9k6mjim08pzwz8-nodejs-26.11.1", + "default": true + } + ], + "store_path": "/nix/store/zzx8zal1hmjkamrp8y9k6mjim08pzwz8-nodejs-26.11.1" + }, + "x86_64-linux": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/m7vfpzl1rjwjpwlcsqs166jn3lywzpq1-nodejs-26.11.1", + "default": true + } + ], + "store_path": "/nix/store/m7vfpzl1rjwjpwlcsqs166jn3lywzpq1-nodejs-26.11.1" + } + } + } + } +} diff --git a/prototype-pixi-perf/index.html b/prototype-pixi-perf/index.html new file mode 100644 index 0000000..e11555b --- /dev/null +++ b/prototype-pixi-perf/index.html @@ -0,0 +1,23 @@ + + + + + +Pixi v8 VTT perf prototype (throwaway) + + + +
+
+ + + diff --git a/prototype-pixi-perf/package-lock.json b/prototype-pixi-perf/package-lock.json new file mode 100644 index 0000000..fdda3a4 --- /dev/null +++ b/prototype-pixi-perf/package-lock.json @@ -0,0 +1,1323 @@ +{ + "name": "prototype-pixi-perf", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "prototype-pixi-perf", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "pixi.js": "^8.22.0" + }, + "devDependencies": { + "playwright-core": "^1.64.1", + "typescript": "^7.0.2", + "vite": "^8.3.5" + } + }, + "node_modules/@oxc-project/types": { + "version": "0.156.0", + "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.156.0.tgz", + "integrity": "sha512-1Duyg48TdJNdyhEB8Xn1L36bT9Pv6GUtlKjHxOys8xkaF/rQq3XJE+bAurSK/AgIz5mGFsb77cn9Pb20+WCScw==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/oxc-project" + } + }, + "node_modules/@pixi/colord": { + "version": "2.9.6", + "resolved": "https://registry.npmjs.org/@pixi/colord/-/colord-2.9.6.tgz", + "integrity": "sha512-nezytU2pw587fQstUu1AsJZDVEynjskwOL+kibwcdxsMBFqPsFFNA7xl0ii/gXuDi6M0xj3mfRJj8pBSc2jCfA==", + "license": "MIT" + }, + "node_modules/@rolldown/binding-android-arm-eabi": { + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm-eabi/-/binding-android-arm-eabi-1.2.16.tgz", + "integrity": "sha512-ia3DwAs0OsMGS7+IConptSiyk9pEXkOx/AbJ2n/lAGxH3QkWQus1t8d7gnAT38FCU2sQu8lUbeR6AiZFv4JxaA==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-android-arm64": { + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.2.16.tgz", + "integrity": "sha512-kx5wBiMB6E7TEvpl2B9gjLU004BkvEm2Dr941BFjx/SontPwSzNuQUIoVKxHHoSjpFIfHMmcguyLOtyn0hObRg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-darwin-arm64": { + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.2.16.tgz", + "integrity": "sha512-qslZrXnKJU4cUpjoAmtAo/KQM9e2IRMlmpig6Zpwj+8KWxW8v+nkAf9216Bsek9lOC1jvg2yCjygCFo2f83msQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-darwin-x64": { + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.2.16.tgz", + "integrity": "sha512-FdF+y48ND13eAyM2mQn+85kvAqNlvRWROy2rhgA463X/0Gv4vGtazZtfaF1mRBLscYvtOlh4QnLjOWiFzX69OQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-freebsd-x64": { + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.2.16.tgz", + "integrity": "sha512-ddjqFM5e95AgLbUPtKIS7V1KTVlA0RUgCVr5mn+/IEhsdy3pr+Vuj/HZ7nlMN2FyxIwUktOH1LEPIQXO1v9y1Q==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm-gnueabihf": { + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.2.16.tgz", + "integrity": "sha512-tHdKWbFkFBI687iim3LIyIvyL7j66VvQYkDPss5Stn/qyE2tWkR1YD0dXmXPFKKqT/o5ZEJVsaRsWS2meQwGOA==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm64-gnu": { + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.2.16.tgz", + "integrity": "sha512-FJiLGAblPBMlBEdbOqw6kW6QcXDWAf/oJu7gYs9ZJZwmg+K+/zjFLxPTIY9izJUzxzc24FHvmseyA0IvJSl17w==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm64-musl": { + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.2.16.tgz", + "integrity": "sha512-hrJpblMsrQ58U9veWpbXzkhV5zStunds6HWLprqq1qauvgBr1E6P+24kLj6lSLI9vjRn/RYpjprhkHQPKGWpNg==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-ppc64-gnu": { + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.2.16.tgz", + "integrity": "sha512-qJd/dC6j6CwLG9/s/RP2nb1RZ0GIgj7Ioj7x/SYa3RzjVrlzrmH0fhIOpfvqQDeIsdP0loi+kHaMhJzY1PBIaA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-s390x-gnu": { + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.2.16.tgz", + "integrity": "sha512-Vx7Xg5uUJuNcujJjI70OICaH0EYj80BtOLZTSN7uOYg8QOLlyKnaG0IW7Fn/J0IpJsaKzmDKMhOQv1JBM9m9vg==", + "cpu": [ + "s390x" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-x64-gnu": { + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.2.16.tgz", + "integrity": "sha512-TNKhgE3uJTsTzatUSSYt0Kgo+Oa2uSlSjz4r1aEIea7HX6ULBym4fAlYUhG1i6pjNf2njfCUAfKwr6C3E9Xg1w==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-x64-musl": { + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.2.16.tgz", + "integrity": "sha512-7chXdpjXZ8qG0+mIxECN3cT9kvhZ3/oZhMX6Pp876P7CDrIy8nJswva6Mq357JR7eYXfuskwZxMeV1SzoZdHrA==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-openharmony-arm64": { + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.2.16.tgz", + "integrity": "sha512-Kwjt+7uNTJK5/MDkGWGVO2KQPnj8yAV75dMpfwyHZrJSXWHrniOB0aUEWlVYf3H1hOqFLIStLdM5QXq6bnKmOQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-win32-arm64-msvc": { + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.2.16.tgz", + "integrity": "sha512-/LH6WfjDRXXJz/p5xl4TmU+jpcnwcxbKEQBW/GZE0JHfN0lGIyTtsUEGaQ/q/GikkGJ2yLKe6pwm7AnEWO8pdw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-win32-x64-msvc": { + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.2.16.tgz", + "integrity": "sha512-1lv1KvX0Z871zfk7vw+dnXMMnHNyDwMzWG8Kv3HxDXMOhzCX4SHc7HK319fInP0i+0p9D8brkfzL7pJOaGl+tw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/pluginutils": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.1.tgz", + "integrity": "sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/earcut": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@types/earcut/-/earcut-3.0.0.tgz", + "integrity": "sha512-k/9fOUGO39yd2sCjrbAJvGDEQvRwRnQIZlBz43roGwUZo5SHAmyVvSFyaVVZkicRVCaDXPKlbxrUcBuJoSWunQ==", + "license": "MIT" + }, + "node_modules/@typescript/typescript-aix-ppc64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-aix-ppc64/-/typescript-aix-ppc64-7.0.2.tgz", + "integrity": "sha512-MTKKkWB7p/0E9xi1d1tHtZ5PiLkGEMIq88pK2CubZjOsLtYTLqhgIgi6zepFa+9GHZ6h05NMCkQxGKiPXMxXtQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-darwin-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-darwin-arm64/-/typescript-darwin-arm64-7.0.2.tgz", + "integrity": "sha512-gowzar9MwS/aRWp6f3a4KUqzRjAZjOsmGNCM6LcTgXum+dBfgsBVMN+AgvOCCbguXyick6LJhpBszxMebJ8syA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-darwin-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-darwin-x64/-/typescript-darwin-x64-7.0.2.tgz", + "integrity": "sha512-SZ9xZInqApNlNGc9s0W1VSsktYSOe9cFqNOIqmN1Gs8SmkjKZYFt017G4VwPxASInODuAdbTW7sXiFUf893RgA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-freebsd-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-freebsd-arm64/-/typescript-freebsd-arm64-7.0.2.tgz", + "integrity": "sha512-W5NH4y/J0plIIS5b2xvTEkU7JFxyqdMAOgf+Ilhl0vHQXKO5dZoxd+C/jEtq56c4F3wk71RB4BMRQ2XdI+bwYQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-freebsd-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-freebsd-x64/-/typescript-freebsd-x64-7.0.2.tgz", + "integrity": "sha512-UMGDx5sTpzNw3WiPebH7l90IWfJggEd+egHt/q6p7/Cm3zqoV7VxkGXt+3DxPIw8CcmvAB0j3sVVfbhX+M4Tpw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-arm": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-arm/-/typescript-linux-arm-7.0.2.tgz", + "integrity": "sha512-gffT3xPz9sR7j/YJExkyPntrI0P2EP9XbOyWzth2/Gs0RstK+90RBcO0ncXoXy/beYll1SXw846Nf2zdnEz0QQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-arm64/-/typescript-linux-arm64-7.0.2.tgz", + "integrity": "sha512-Qh4eU4/y3yDjnfjjyPYihMj5/ODIlmt+Bzu17OI+fiSRDW57QmU5SiN63exPRNJPKUzcc1INa1NXdrJ+MqHjUQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-loong64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-loong64/-/typescript-linux-loong64-7.0.2.tgz", + "integrity": "sha512-uEHck9i8hoAzXPiYRib1O7miOnz23SxIeVl6F4LXox+qov1K35jHcEW6VHKvZI+pyvl7fZEP4MCU5LYvIq1GuQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-mips64el": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-mips64el/-/typescript-linux-mips64el-7.0.2.tgz", + "integrity": "sha512-R4KvAMnE43W5Qeqb0Ly56O3mWMWIAgsMyz36DCaycd5nbg/9kzm0liw3JocfRqyJY0KPmzFjbswozXyW0DnIYA==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-ppc64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-ppc64/-/typescript-linux-ppc64-7.0.2.tgz", + "integrity": "sha512-DORx5b3sd/4S7eayxm4FQv+A7CrkUIGRaHiwI8oiHTAI1fAPWhF4J0vAlkC8biAlHSVVwxMQ3tjZ2/DVbnQiiA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-riscv64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-riscv64/-/typescript-linux-riscv64-7.0.2.tgz", + "integrity": "sha512-wf0jqEDOjrPRnKwYRyyJDRo11KMbvMFrU+q4zqKyChODBzvlkbhNQfKvLxQCcwTpdDaXSHZTVuh0JoCrKCUMHQ==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-s390x": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-s390x/-/typescript-linux-s390x-7.0.2.tgz", + "integrity": "sha512-IkwJc3L7yhytWd/ewjyxNDfOmswCm9GWMJT/ue/dU4aZNbwZeYAetq42VyLmsmSjvoX7z74X6ZaYCtzAr0EuGw==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-x64/-/typescript-linux-x64-7.0.2.tgz", + "integrity": "sha512-EYdf2cNg7rgCWJnxCdJ+F3V39O8ihb37eHAu1LK8oAFizgTQbPOK7zHHXbPt8rX24COqODXeI3sIf0fCXG7H/A==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-netbsd-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-netbsd-arm64/-/typescript-netbsd-arm64-7.0.2.tgz", + "integrity": "sha512-+polYF4MF04aPpO5FTkHran9yUQDSXqy5GiSDKpsll5jy3l3+g9QLhpf39T+ePtefhXLOGrLl0QIjkQP6VnelA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-netbsd-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-netbsd-x64/-/typescript-netbsd-x64-7.0.2.tgz", + "integrity": "sha512-8YIT0EHM/3dq10ZOVF/A7pc/YSMtbcecct4rWtexrnSCHOPcpC2KTLXfTCR6vDpnSiY12heNb1GiN/wu+T/FyA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-openbsd-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-openbsd-arm64/-/typescript-openbsd-arm64-7.0.2.tgz", + "integrity": "sha512-APT8+ClYnuYm1u9+kgGXoMj2VzWzcymwh2gNSQVySHfkRDGOTVkoWLjCmOQSaO+PoqQ57B0flRp9SA+7GnnkzQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-openbsd-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-openbsd-x64/-/typescript-openbsd-x64-7.0.2.tgz", + "integrity": "sha512-yX7s+Q0Dln0Dt9tEzZsAjXXR/+ytBM7AlglaqyeMPxQszJ1JhlJdZ6jLA+IzldHtflX81em7lDao1xXu+aRRkg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-sunos-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-sunos-x64/-/typescript-sunos-x64-7.0.2.tgz", + "integrity": "sha512-dLJDGaLZ1D4HPQn62u1n8mBDkJREwMsAkCdkwd4Ieqw+x3TUyTsqY0YiBCtE6H6OzzgGk3iuZ3vFWRS+E8/d1g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-win32-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-win32-arm64/-/typescript-win32-arm64-7.0.2.tgz", + "integrity": "sha512-Gyl1Vy6OsWesLzmq+EP0Fb7b4Nid5232AvcA2SFcdYreldpNtYFFofPjnt62y9hQy7VTaZp65ICJjuAQRaVcIQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-win32-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-win32-x64/-/typescript-win32-x64-7.0.2.tgz", + "integrity": "sha512-0BQ3HkAHHlKLSp1qRvf3SUhGpGsDuhB/jgFw75guyqbxJqEaS0Cw/VFO8i2nHglJUzQCRtMMR/IBAKE3ETMC4g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@webgpu/types": { + "version": "0.1.74", + "resolved": "https://registry.npmjs.org/@webgpu/types/-/types-0.1.74.tgz", + "integrity": "sha512-lgiI4hbuLcI9unnm2cL/tvCaQU45dp0xcLWJh5uB/9MBGvIA4F8XIk7nSiBeg+K4xWGYwgZKn80LmERI5CxoTA==", + "license": "BSD-3-Clause" + }, + "node_modules/@xmldom/xmldom": { + "version": "0.8.15", + "resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.8.15.tgz", + "integrity": "sha512-/5NV/vDALVFDXgLmfsy9TRCBlKwO2LNBFzpzvb9iIj+jR+eSc6DLYYvVOdivT/jm7MtU6TebYuRmzEOI7w40UA==", + "license": "MIT", + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/detect-libc": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", + "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=8" + } + }, + "node_modules/earcut": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/earcut/-/earcut-3.2.4.tgz", + "integrity": "sha512-FHc6yNpnTORB0tM5kmZ03iD2mDuNakDE2lvf4Hw1XkfxtEHIGVi01B/GqUSwx+NcC1WGjidAfpTXzeALtPtfpg==", + "license": "ISC" + }, + "node_modules/eventemitter3": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.4.tgz", + "integrity": "sha512-mlsTRyGaPBjPedk6Bvw+aqbsXDtoAyAzm5MO7JgU+yVRyMQ5O8bD4Kcci7BS85f93veegeCPkL8R4GLClnjLFw==", + "license": "MIT" + }, + "node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/gifuct-js": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/gifuct-js/-/gifuct-js-2.1.2.tgz", + "integrity": "sha512-rI2asw77u0mGgwhV3qA+OEgYqaDn5UNqgs+Bx0FGwSpuqfYn+Ir6RQY5ENNQ8SbIiG/m5gVa7CD5RriO4f4Lsg==", + "license": "MIT", + "dependencies": { + "js-binary-schema-parser": "^2.0.3" + } + }, + "node_modules/ismobilejs": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ismobilejs/-/ismobilejs-1.1.1.tgz", + "integrity": "sha512-VaFW53yt8QO61k2WJui0dHf4SlL8lxBofUuUmwBo0ljPk0Drz2TiuDW4jo3wDcv41qy/SxrJ+VAzJ/qYqsmzRw==", + "license": "MIT" + }, + "node_modules/js-binary-schema-parser": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/js-binary-schema-parser/-/js-binary-schema-parser-2.0.3.tgz", + "integrity": "sha512-xezGJmOb4lk/M1ZZLTR/jaBHQ4gG/lqQnJqdIv4721DMggsa1bDVlHXNeHYogaIEHD9vCRv0fcL4hMA+Coarkg==", + "license": "MIT" + }, + "node_modules/lightningcss": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.33.0.tgz", + "integrity": "sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==", + "dev": true, + "license": "MPL-2.0", + "dependencies": { + "detect-libc": "^2.0.3" + }, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + }, + "optionalDependencies": { + "lightningcss-android-arm64": "1.33.0", + "lightningcss-darwin-arm64": "1.33.0", + "lightningcss-darwin-x64": "1.33.0", + "lightningcss-freebsd-x64": "1.33.0", + "lightningcss-linux-arm-gnueabihf": "1.33.0", + "lightningcss-linux-arm64-gnu": "1.33.0", + "lightningcss-linux-arm64-musl": "1.33.0", + "lightningcss-linux-x64-gnu": "1.33.0", + "lightningcss-linux-x64-musl": "1.33.0", + "lightningcss-win32-arm64-msvc": "1.33.0", + "lightningcss-win32-x64-msvc": "1.33.0" + } + }, + "node_modules/lightningcss-android-arm64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-android-arm64/-/lightningcss-android-arm64-1.33.0.tgz", + "integrity": "sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-darwin-arm64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.33.0.tgz", + "integrity": "sha512-Sciaz8eenNTKn9b3t7+xr0ipTp9YxKQY4npwQ3mrRuL0BAVHBLyZxofhaKBAVtzmtRZ/zTyo0/to4B1uWG/Djg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-darwin-x64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.33.0.tgz", + "integrity": "sha512-Z5UPAxzrjlWNNyGy6i65cJzzvgJ5D3T6wMvs+gWpY9d7qRhANrxqAp6LhxIgZhWEw18RfJTGcRxjuLIBr+m8XQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-freebsd-x64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.33.0.tgz", + "integrity": "sha512-QQM/Ti/hQajJwCY+RiWuCZ9sdtI/XQk7nDK5vC8kkdwixezOlDgvDx7+RT+QjK6FcFT4MpsuoBnHIo/O3StRRg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm-gnueabihf": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.33.0.tgz", + "integrity": "sha512-N7FVBe6iS24MlM6R/4RBTxGhQheZGs7tiQ9U32UtF75NzP5Q7xWPRqLBCKxlRQRk3rY1jCIPLzx7WzOhuUIRLQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-gnu": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.33.0.tgz", + "integrity": "sha512-j2v/itmy4HlNxlc6voKXYgBqNi0Ng2LShg4z7GufpEgs05P+2suBVyi9I6YHq5uoVFx9ETin3eCEhLVyXGQnKg==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-musl": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.33.0.tgz", + "integrity": "sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-gnu": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.33.0.tgz", + "integrity": "sha512-ar+Ju7LmcN0Jo4FpL4hpFybwNG9/3A/Br5KW2n2jyODg3MEZXaDYADdemoNS+BDNfMgKvylJLj4S5tyRActuAg==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-musl": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.33.0.tgz", + "integrity": "sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-win32-arm64-msvc": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.33.0.tgz", + "integrity": "sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-win32-x64-msvc": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.33.0.tgz", + "integrity": "sha512-OlEICDx/Xl0FqSp4bry8zFnCvGpig3Gl4gCquvYwHuqJKEC1+n9NgDniFvqHGmMv1ZkqDJrDqKKSykTDX+ehuA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/nanoid": { + "version": "3.3.20", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.20.tgz", + "integrity": "sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/parse-svg-path": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/parse-svg-path/-/parse-svg-path-0.2.0.tgz", + "integrity": "sha512-Tf7FFIrguPKQwzD4pWnYkR2VOv3raoHeKED80Bm+BYHI3KxC8KsgsGC5+fSMzAGDA6UEk4bHvmi+RsjmL3khpg==", + "license": "MIT" + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/pixi.js": { + "version": "8.22.0", + "resolved": "https://registry.npmjs.org/pixi.js/-/pixi.js-8.22.0.tgz", + "integrity": "sha512-QbTANHMZ751MIjLiLSUSM8a7LNMWwMIf0KbRCqlW+SPS9hNLfSVS+cl1O2SEp9g1K/wyLzj/OJHv+1TUfiPr/w==", + "license": "MIT", + "workspaces": [ + "examples", + "playground" + ], + "dependencies": { + "@pixi/colord": "^2.9.6", + "@types/earcut": "^3.0.0", + "@webgpu/types": "^0.1.69", + "@xmldom/xmldom": "^0.8.15", + "earcut": "^3.0.2", + "eventemitter3": "^5.0.1", + "gifuct-js": "^2.1.2", + "ismobilejs": "^1.1.1", + "parse-svg-path": "^0.2.0", + "tiny-lru": "^11.4.7" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/pixijs" + } + }, + "node_modules/playwright-core": { + "version": "1.64.1", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.64.1.tgz", + "integrity": "sha512-BC4s8y6SEVA6Q1rSxZTto8hI1KUI3xXlHGZgvGqP4IqPdI/a6FX9H29IDNz7vKo9l21b6LfYosScPL6M3xxyDQ==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "playwright-core": "cli.js" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/postcss": { + "version": "8.5.32", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.32.tgz", + "integrity": "sha512-LJlKCCAUFKOuZxipUdYw1NzIITEsPcgyOG9LkvRJvuKj/bRzbuRY0ARXvL0pWGpsZvn8jku+LMep2eU0seHp8g==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.20", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.2" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/rolldown": { + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.16.tgz", + "integrity": "sha512-bWvlMpFKiTfDKfnK7FC2MPgPeWCf/Kpwsq49ApdW+FQaBZb6O6dZ4MAPbPUjp7hYQrw/RobqCzn64BRrQecGHw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@oxc-project/types": "=0.156.0", + "@rolldown/pluginutils": "^1.0.0" + }, + "bin": { + "rolldown": "bin/cli.mjs" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "optionalDependencies": { + "@rolldown/binding-android-arm-eabi": "1.2.16", + "@rolldown/binding-android-arm64": "1.2.16", + "@rolldown/binding-darwin-arm64": "1.2.16", + "@rolldown/binding-darwin-x64": "1.2.16", + "@rolldown/binding-freebsd-x64": "1.2.16", + "@rolldown/binding-linux-arm-gnueabihf": "1.2.16", + "@rolldown/binding-linux-arm64-gnu": "1.2.16", + "@rolldown/binding-linux-arm64-musl": "1.2.16", + "@rolldown/binding-linux-ppc64-gnu": "1.2.16", + "@rolldown/binding-linux-s390x-gnu": "1.2.16", + "@rolldown/binding-linux-x64-gnu": "1.2.16", + "@rolldown/binding-linux-x64-musl": "1.2.16", + "@rolldown/binding-openharmony-arm64": "1.2.16", + "@rolldown/binding-win32-arm64-msvc": "1.2.16", + "@rolldown/binding-win32-x64-msvc": "1.2.16" + } + }, + "node_modules/source-map-js": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.2.tgz", + "integrity": "sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/tiny-lru": { + "version": "11.4.7", + "resolved": "https://registry.npmjs.org/tiny-lru/-/tiny-lru-11.4.7.tgz", + "integrity": "sha512-w/Te7uMUVeH0CR8vZIjr+XiN41V+30lkDdK+NRIDCUYKKuL9VcmaUEmaPISuwGhLlrTGh5yu18lENtR9axSxYw==", + "license": "BSD-3-Clause", + "engines": { + "node": ">=12" + } + }, + "node_modules/tinyglobby": { + "version": "0.2.17", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz", + "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.4" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/typescript": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-7.0.2.tgz", + "integrity": "sha512-8FYau96o3NKOhbjKi/qNvG/W5jhzxkbdm5sj9AbZ/5T5sWqn3hJgLfGx27sRKZWTvyzCP8dLRBTf5tBTSRVUNA==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc" + }, + "engines": { + "node": ">=16.20.0" + }, + "optionalDependencies": { + "@typescript/typescript-aix-ppc64": "7.0.2", + "@typescript/typescript-darwin-arm64": "7.0.2", + "@typescript/typescript-darwin-x64": "7.0.2", + "@typescript/typescript-freebsd-arm64": "7.0.2", + "@typescript/typescript-freebsd-x64": "7.0.2", + "@typescript/typescript-linux-arm": "7.0.2", + "@typescript/typescript-linux-arm64": "7.0.2", + "@typescript/typescript-linux-loong64": "7.0.2", + "@typescript/typescript-linux-mips64el": "7.0.2", + "@typescript/typescript-linux-ppc64": "7.0.2", + "@typescript/typescript-linux-riscv64": "7.0.2", + "@typescript/typescript-linux-s390x": "7.0.2", + "@typescript/typescript-linux-x64": "7.0.2", + "@typescript/typescript-netbsd-arm64": "7.0.2", + "@typescript/typescript-netbsd-x64": "7.0.2", + "@typescript/typescript-openbsd-arm64": "7.0.2", + "@typescript/typescript-openbsd-x64": "7.0.2", + "@typescript/typescript-sunos-x64": "7.0.2", + "@typescript/typescript-win32-arm64": "7.0.2", + "@typescript/typescript-win32-x64": "7.0.2" + } + }, + "node_modules/vite": { + "version": "8.3.5", + "resolved": "https://registry.npmjs.org/vite/-/vite-8.3.5.tgz", + "integrity": "sha512-z1YpjieJ9g0ebTmQpLBv/oq9E3F9EIlOe+7LahW8SrE3LTiG3udBRUXQOlYXP9b+IC2q2phHeVxj9xGlw34OEQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "lightningcss": "^1.33.0", + "picomatch": "^4.0.7", + "postcss": "^8.5.30", + "rolldown": "~1.2.14", + "tinyglobby": "^0.2.17" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^20.19.0 || >=22.12.0", + "@vitejs/devtools": "^0.7.1 || ^0.8.0", + "esbuild": "^0.27.0 || ^0.28.0", + "jiti": ">=1.21.0", + "less": "^4.0.0", + "sass": "^1.70.0", + "sass-embedded": "^1.70.0", + "stylus": ">=0.54.8", + "sugarss": "^5.0.0", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "@vitejs/devtools": { + "optional": true + }, + "esbuild": { + "optional": true + }, + "jiti": { + "optional": true + }, + "less": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + } + } +} diff --git a/prototype-pixi-perf/package.json b/prototype-pixi-perf/package.json new file mode 100644 index 0000000..5b01c29 --- /dev/null +++ b/prototype-pixi-perf/package.json @@ -0,0 +1,19 @@ +{ + "name": "prototype-pixi-perf", + "version": "1.0.0", + "scripts": { + "dev": "vite", + "build": "tsc && vite build", + "bench": "node bench.mjs" + }, + "type": "module", + "dependencies": { + "pixi.js": "^8.22.0" + }, + "devDependencies": { + "playwright-core": "^1.64.1", + "typescript": "^7.0.2", + "vite": "^8.3.5" + }, + "private": true +} \ No newline at end of file diff --git a/prototype-pixi-perf/src/main.ts b/prototype-pixi-perf/src/main.ts new file mode 100644 index 0000000..d237741 --- /dev/null +++ b/prototype-pixi-perf/src/main.ts @@ -0,0 +1,464 @@ +// THROWAWAY perf prototype. Pixi v8. See ../README.md. +import { + Application, BitmapFont, BitmapText, Container, Culler, Graphics, GraphicsContext, + Rectangle, Sprite, Texture, TilingSprite, UPDATE_PRIORITY, +} from 'pixi.js'; + +// ---------- state ---------- +const S = { + map: 4096, tile: 0 /* 0 = auto (maxTex) */, n: 200, cell: 64, + grid: true, chaos: false, churn: false, cull: true, tool: 'move' as 'move' | 'pen', +}; +const q = new URLSearchParams(location.search); +const BENCH_MS = Number(q.get('benchMs') ?? 5000); +const WARM_MS = Number(q.get('warmMs') ?? 700); +const TOKEN_R = 24; +const TOKEN_MAX = 2000; +let customBitmap: ImageBitmap | null = null; +let mapInfo = ''; +let mapBuildMs = 0; +let maxTex = 0; +let benchStatus = ''; + +// ---------- app ---------- +const app = new Application(); +const pref = q.get('renderer'); // webgl | webgpu +await app.init({ + resizeTo: window, + background: 0x1a1a1a, + antialias: false, + resolution: Number(q.get('res') ?? Math.min(devicePixelRatio, 2)), + autoDensity: true, + preference: pref === 'webgl' || pref === 'webgpu' ? pref : undefined, + // DOM pointer events are used instead of Pixi's federated events (see README): no hit-testing per move. + eventFeatures: { move: false, globalMove: false, click: false, wheel: false }, +}); +document.body.prepend(app.canvas); +const rendererName = app.renderer.name; +{ + const r = app.renderer as any; + maxTex = rendererName === 'webgpu' + ? r.gpu.device.limits.maxTextureDimension2D + : r.gl.getParameter(WebGL2RenderingContext.MAX_TEXTURE_SIZE); +} +let gpuName = '?'; +try { + const gl = (app.renderer as any).gl as WebGL2RenderingContext | undefined; + const ext = gl?.getExtension('WEBGL_debug_renderer_info'); + if (gl && ext) gpuName = gl.getParameter(ext.UNMASKED_RENDERER_WEBGL); +} catch { /* ignore */ } + +const world = new Container(); +const mapLayer = new Container(); +const strokeLayer = new Container(); +const liveLayer = new Container(); +const tokenLayer = new Container(); +world.addChild(mapLayer, strokeLayer, tokenLayer, liveLayer); +app.stage.addChild(world); + +let grid: TilingSprite | null = null; + +// ---------- map (tiling over max texture size) ---------- +function hash(x: number, y: number) { + let h = (x * 374761393 + y * 668265263) | 0; + h = (h ^ (h >>> 13)) * 1274126177; + return ((h ^ (h >>> 16)) >>> 0) / 4294967296; +} +function drawProc(ctx: CanvasRenderingContext2D, ox: number, oy: number, w: number, h: number) { + const C = 128; // world-space cell, deterministic so tiles line up + for (let cy = Math.floor(oy / C); cy * C < oy + h; cy++) { + for (let cx = Math.floor(ox / C); cx * C < ox + w; cx++) { + const r = hash(cx, cy); + ctx.fillStyle = `hsl(${90 + r * 60}, ${25 + r * 25}%, ${22 + hash(cy, cx) * 18}%)`; + ctx.fillRect(cx * C - ox, cy * C - oy, C, C); + if (r > 0.7) { + ctx.fillStyle = 'rgba(40,90,160,.6)'; + ctx.beginPath(); + ctx.arc(cx * C - ox + C / 2, cy * C - oy + C / 2, 20 + r * 40, 0, 7); + ctx.fill(); + } + } + } + ctx.strokeStyle = 'rgba(0,0,0,.5)'; + ctx.lineWidth = 3; + for (let x = Math.ceil(ox / 1024) * 1024; x < ox + w; x += 1024) { ctx.beginPath(); ctx.moveTo(x - ox, 0); ctx.lineTo(x - ox, h); ctx.stroke(); } + for (let y = Math.ceil(oy / 1024) * 1024; y < oy + h; y += 1024) { ctx.beginPath(); ctx.moveTo(0, y - oy); ctx.lineTo(w, y - oy); ctx.stroke(); } +} +function buildMap() { + const t0 = performance.now(); + for (const c of mapLayer.removeChildren()) (c as Sprite).destroy({ texture: true, textureSource: true }); + const size = S.map; + const tile = Math.min(size, S.tile || maxTex, maxTex); + const nt = Math.ceil(size / tile); + try { + for (let ty = 0; ty < nt; ty++) { + for (let tx = 0; tx < nt; tx++) { + const ox = tx * tile, oy = ty * tile; + const w = Math.min(tile, size - ox), h = Math.min(tile, size - oy); + const cv = document.createElement('canvas'); + cv.width = w; cv.height = h; + const ctx = cv.getContext('2d')!; + if (customBitmap) { + const k = customBitmap.width / size, kh = customBitmap.height / size; + ctx.drawImage(customBitmap, ox * k, oy * kh, w * k, h * kh, 0, 0, w, h); + } else drawProc(ctx, ox, oy, w, h); + const spr = new Sprite(Texture.from(cv)); + spr.position.set(ox, oy); + spr.cullable = true; // culled by the Culler each frame (tiles outside view are skipped) + mapLayer.addChild(spr); + } + } + mapInfo = nt === 1 + ? `${size}px: SINGLE texture (maxTex ${maxTex})` + : `${size}px: TILED ${nt}x${nt} of ${tile}px (maxTex ${maxTex})`; + } catch (e) { + mapInfo = `${size}px: BUILD FAILED ${e}`; + } + if (grid) { grid.width = grid.height = size; } + mapBuildMs = performance.now() - t0; +} + +// ---------- grid (one TilingSprite, 1 quad) ---------- +function buildGrid() { + const c = S.cell; + const cv = document.createElement('canvas'); + cv.width = cv.height = c; + const ctx = cv.getContext('2d')!; + ctx.strokeStyle = 'rgba(255,255,255,.35)'; + ctx.lineWidth = 2; + ctx.strokeRect(0, 0, c, c); + const tex = Texture.from(cv); + if (!grid) { grid = new TilingSprite({ texture: tex, width: S.map, height: S.map }); mapLayer.parent!.addChildAt(grid, 1); } + else { const old = grid.texture; grid.texture = tex; old.destroy(true); } + grid.width = grid.height = S.map; + grid.visible = S.grid; +} + +// ---------- tokens ---------- +BitmapFont.install({ + name: 'tok', + style: { fontFamily: 'Arial', fontSize: 16, fill: 0xffffff, stroke: { color: 0x000000, width: 3 } }, + chars: [['a', 'z'], ['A', 'Z'], ['0', '9'], ' /-'], +}); +// one shared GraphicsContext per colour: tessellated once, reused by every token +const bodyCtx = [0xc0392b, 0x2980b9, 0x27ae60, 0x8e44ad, 0xd35400, 0x16a085].map( + (c) => new GraphicsContext().circle(0, 0, TOKEN_R).fill(c).stroke({ width: 3, color: 0xffffff }), +); +type Tok = { c: Container; label: BitmapText; x: number; y: number; vx: number; vy: number; hp: number; name: string }; +const toks: Tok[] = []; +const label = (t: Tok) => `${t.name} ${t.hp}/99`; +function makeTok(i: number): Tok { + const c = new Container(); + const body = new Graphics(bodyCtx[i % bodyCtx.length]); + const t: Tok = { + c, label: null as any, name: 'T' + i, hp: (hash(i, 7) * 99) | 0, + x: hash(i, 1) * S.map, y: hash(i, 2) * S.map, + vx: (hash(i, 3) - 0.5) * 400, vy: (hash(i, 4) - 0.5) * 400, + }; + const l = new BitmapText({ text: label(t), style: { fontFamily: 'tok', fontSize: 16 } }); + l.anchor.set(0.5, 0); + l.y = TOKEN_R + 2; + t.label = l; + c.addChild(body, l); + c.cullable = true; + c.cullArea = new Rectangle(-45, -TOKEN_R - 2, 90, TOKEN_R * 2 + 28); // fixed cull rect: no per-frame bounds calc + c.cullableChildren = false; + c.position.set(t.x, t.y); + return t; +} +function setTokens() { + while (toks.length < S.n) toks.push(makeTok(toks.length)); + tokenLayer.removeChildren(); // pooled, never destroyed + for (let i = 0; i < S.n; i++) { + const t = toks[i]; + t.x = Math.min(t.x, S.map); t.y = Math.min(t.y, S.map); + t.c.position.set(t.x, t.y); + tokenLayer.addChild(t.c); + } +} + +// ---------- strokes: live Graphics chunks -> baked to one Sprite texture ---------- +const PEN_W = 4; +let live: { pts: number[]; start: number; cur: Graphics; color: number } | null = null; +function drawChunk(g: Graphics, pts: number[], from: number, color: number) { + g.clear().moveTo(pts[from], pts[from + 1]); + for (let i = from + 2; i < pts.length; i += 2) g.lineTo(pts[i], pts[i + 1]); + if (pts.length - from === 2) g.lineTo(pts[from] + 0.01, pts[from + 1]); + g.stroke({ width: PEN_W, color, cap: 'round', join: 'round' }); +} +function startStroke(x: number, y: number) { + const color = (Math.random() * 0xffffff) | 0 | 0x303030; + const cur = new Graphics(); + liveLayer.addChild(cur); + live = { pts: [x, y], start: 0, cur, color }; + drawChunk(cur, live.pts, 0, color); +} +function addPoint(x: number, y: number) { + if (!live) return; + const L = live; + L.pts.push(x, y); + // only the last <=48 points get re-tessellated; older chunks stay frozen => O(1) per move + if (L.pts.length - L.start > 96) { + L.start = L.pts.length - 2; + L.cur = new Graphics(); + liveLayer.addChild(L.cur); + } + drawChunk(L.cur, L.pts, L.start, L.color); +} +function bake(target: Container) { + const b = target.getLocalBounds().rectangle; + const pad = PEN_W; + const frame = new Rectangle(Math.floor(b.x - pad), Math.floor(b.y - pad), Math.ceil(b.width + 2 * pad), Math.ceil(b.height + 2 * pad)); + // resolution follows zoom (sharp when zoomed in) but caps the texture at 4096px per side + const res = Math.min(Math.max(1, Math.min(2, world.scale.x)), 4096 / Math.max(frame.width, frame.height)); + const texture = app.renderer.textureGenerator.generateTexture({ target, frame, resolution: res, antialias: true }); + const spr = new Sprite(texture); + spr.scale.set(1 / res); + spr.position.set(frame.x, frame.y); + spr.cullable = true; + strokeLayer.addChild(spr); +} +function endStroke() { + if (!live) return; + live = null; + bake(liveLayer); + for (const c of liveLayer.removeChildren()) c.destroy(); +} +function randomStrokes(count: number) { + for (let k = 0; k < count; k++) { + const g = new Graphics(); + let x = Math.random() * S.map, y = Math.random() * S.map, a = Math.random() * 6.28; + const pts = [x, y]; + for (let i = 0; i < 60; i++) { a += (Math.random() - 0.5) * 0.9; x += Math.cos(a) * 14; y += Math.sin(a) * 14; pts.push(x, y); } + drawChunk(g, pts, 0, (Math.random() * 0xffffff) | 0 | 0x303030); + bake(g); + g.destroy(); + } +} +function clearStrokes() { + for (const c of strokeLayer.removeChildren()) (c as Sprite).destroy({ texture: true, textureSource: true }); +} + +// ---------- pan / zoom / drag / draw (DOM pointer events) ---------- +function zoomAt(px: number, py: number, k: number) { + const s0 = world.scale.x, s1 = Math.min(8, Math.max(0.02, s0 * k)); + world.position.set(px - (px - world.x) * (s1 / s0), py - (py - world.y) * (s1 / s0)); + world.scale.set(s1); +} +function fit() { + const s = (Math.min(innerWidth, innerHeight) / S.map) * 0.9; + world.scale.set(s); + world.position.set((innerWidth - S.map * s) / 2, (innerHeight - S.map * s) / 2); +} +const cv = app.canvas; +cv.addEventListener('contextmenu', (e) => e.preventDefault()); +cv.addEventListener('wheel', (e) => { e.preventDefault(); zoomAt(e.offsetX, e.offsetY, Math.exp(-e.deltaY * 0.0015)); }, { passive: false }); +const ptrs = new Map(); +let mode: 'none' | 'pan' | 'drag' | 'draw' | 'pinch' = 'none'; +let dragTok: Tok | null = null; +let pinch = { d: 1, cx: 0, cy: 0 }; +const toWorld = (x: number, y: number) => [(x - world.x) / world.scale.x, (y - world.y) / world.scale.x]; +function pinchState() { + const [a, b] = [...ptrs.values()]; + return { d: Math.hypot(a.x - b.x, a.y - b.y) || 1, cx: (a.x + b.x) / 2, cy: (a.y + b.y) / 2 }; +} +cv.addEventListener('pointerdown', (e) => { + cv.setPointerCapture(e.pointerId); + ptrs.set(e.pointerId, { x: e.offsetX, y: e.offsetY }); + if (ptrs.size >= 2) { endStroke(); dragTok = null; mode = 'pinch'; pinch = pinchState(); return; } + if (S.tool === 'pen' && e.button === 0) { mode = 'draw'; startStroke(...(toWorld(e.offsetX, e.offsetY) as [number, number])); return; } + const [wx, wy] = toWorld(e.offsetX, e.offsetY); + dragTok = null; + if (e.button === 0) { + for (let i = S.n - 1; i >= 0; i--) { // O(N) only on press, not per move + const t = toks[i]; + if ((t.x - wx) ** 2 + (t.y - wy) ** 2 < TOKEN_R * TOKEN_R) { dragTok = t; break; } + } + } + mode = dragTok ? 'drag' : 'pan'; +}); +cv.addEventListener('pointermove', (e) => { + const p = ptrs.get(e.pointerId); + if (!p) return; + const dx = e.offsetX - p.x, dy = e.offsetY - p.y; + p.x = e.offsetX; p.y = e.offsetY; + if (mode === 'pan') world.position.set(world.x + dx, world.y + dy); + else if (mode === 'drag' && dragTok) { + dragTok.x += dx / world.scale.x; dragTok.y += dy / world.scale.x; + dragTok.c.position.set(dragTok.x, dragTok.y); + } else if (mode === 'draw') { + const rect = cv.getBoundingClientRect(); + for (const ce of e.getCoalescedEvents?.() ?? [e]) { + const [wx, wy] = toWorld(ce.clientX - rect.left, ce.clientY - rect.top); + addPoint(wx, wy); + } + } else if (mode === 'pinch' && ptrs.size >= 2) { + const n = pinchState(); + world.position.set(world.x + (n.cx - pinch.cx), world.y + (n.cy - pinch.cy)); + zoomAt(n.cx, n.cy, n.d / pinch.d); + pinch = n; + } +}); +function up(e: PointerEvent) { + if (!ptrs.delete(e.pointerId)) return; + if (mode === 'draw') endStroke(); + dragTok = null; + mode = ptrs.size === 1 && mode === 'pinch' ? 'pan' : 'none'; +} +cv.addEventListener('pointerup', up); +cv.addEventListener('pointercancel', up); + +// ---------- per-frame loop + frame stats ---------- +type Sample = { t: number; dt: number; cpu: number }; +let samples: Sample[] = []; +let lastT = performance.now(); +let frameStart = 0; +let benchSink: Sample[] | null = null; +function setCull(on: boolean) { + if (!on) for (const l of [mapLayer, strokeLayer, tokenLayer]) for (const c of l.children) c.renderable = true; +} +app.ticker.add(() => { + const now = performance.now(); + frameStart = now; + const dt = now - lastT; + lastT = now; + samples.push({ t: now, dt, cpu: 0 }); + while (samples[0].t < now - 2000) samples.shift(); + const sec = Math.min(dt, 100) / 1000; + if (S.chaos) { + for (let i = 0; i < S.n; i++) { + const t = toks[i]; + t.x += t.vx * sec; t.y += t.vy * sec; + if (t.x < 0 || t.x > S.map) t.vx = -t.vx; + if (t.y < 0 || t.y > S.map) t.vy = -t.vy; + t.c.position.set(t.x, t.y); + } + } + if (S.churn) { + for (let i = 0; i < S.n; i++) { const t = toks[i]; t.hp = (t.hp + 1 + ((Math.random() * 7) | 0)) % 100; t.label.text = label(t); } + } + if (S.cull) Culler.shared.cull(world, app.screen, false); +}, undefined, UPDATE_PRIORITY.HIGH); +// runs after Pixi's render (LOW) => JS time spent per frame incl. render submission (not GPU time) +app.ticker.add(() => { + const s = samples[samples.length - 1]; + s.cpu = performance.now() - frameStart; + benchSink?.push(s); +}, undefined, UPDATE_PRIORITY.UTILITY); + +function stats() { + const n = samples.length || 1; + const avg = samples.reduce((a, s) => a + s.dt, 0) / n; + const worst = samples.reduce((a, s) => Math.max(a, s.dt), 0); + const cpu = samples.reduce((a, s) => a + s.cpu, 0) / n; + return { avg, worst, cpu, fps: 1000 / avg }; +} +const stat = document.getElementById('stats')!; +setInterval(() => { + const s = stats(); + stat.textContent = + `FPS ${s.fps.toFixed(1)} frame avg ${s.avg.toFixed(1)}ms worst(2s) ${s.worst.toFixed(1)}ms js ${s.cpu.toFixed(1)}ms\n` + + `renderer: ${rendererName}${pref ? ` (forced ${pref})` : ''} res ${app.renderer.resolution} maxTex ${maxTex}\n` + + `map: ${mapInfo} (built ${mapBuildMs.toFixed(0)}ms${customBitmap ? ', custom image' : ', procedural'})\n` + + `tokens ${S.n} strokes ${strokeLayer.children.length} grid ${S.grid ? S.cell + 'px' : 'off'} chaos ${S.chaos} churn ${S.churn} cull ${S.cull} tool ${S.tool}\n` + + `zoom ${world.scale.x.toFixed(2)}${benchStatus ? '\n' + benchStatus : ''}`; +}, 250); + +// ---------- benchmark ---------- +const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms)); +const nextFrames = (n: number) => new Promise((r) => { let k = 0; const f = () => { if (++k >= n) { app.ticker.remove(f); r(); } }; app.ticker.add(f); }); +async function runBench(out: HTMLTextAreaElement) { + const maps = [2048, 4096, 8192, 16384], counts = [50, 200, 500, 1000, 2000]; + const sc: { map: number; n: number; strokes: number }[] = []; + for (const m of maps) for (const n of counts) sc.push({ map: m, n, strokes: 0 }); + sc.push({ map: 4096, n: 50, strokes: 200 }, { map: 4096, n: 500, strokes: 200 }); + const saved = { ...S }; + S.chaos = true; S.churn = false; S.cull = true; S.grid = true; + const rows: string[] = []; + let strokes = strokeLayer.children.length; + for (let i = 0; i < sc.length; i++) { + const c = sc[i]; + benchStatus = `BENCH ${i + 1}/${sc.length}: map ${c.map} tokens ${c.n} strokes ${c.strokes}`; + if (S.map !== c.map) { S.map = c.map; buildMap(); fit(); } + if (strokes !== c.strokes) { clearStrokes(); randomStrokes(c.strokes); strokes = c.strokes; } + S.n = c.n; setTokens(); + const path = mapLayer.children.length === 1 ? 'single' : `${mapLayer.children.length} tiles`; + await sleep(WARM_MS); + await nextFrames(3); // first frames include GPU texture upload; never measure them + const sink: Sample[] = []; + benchSink = sink; + await sleep(BENCH_MS); + benchSink = null; + console.log(`scenario ${i}`, c.map, c.n, c.strokes, path, mapInfo, 'frames', sink.length); + if (!sink.length) await nextFrames(2); // unreachable in practice + const dts = sink.length ? sink.map((s) => s.dt) : [NaN]; + const avg = dts.reduce((a, b) => a + b, 0) / dts.length; + const sorted = [...dts].sort((a, b) => a - b); + const p99 = sorted[Math.floor(sorted.length * 0.99)]; + const cpu = sink.reduce((a, s) => a + s.cpu, 0) / sink.length; + rows.push(`| ${c.map} | ${path} | ${c.n} | ${c.strokes} | ${(1000 / avg).toFixed(1)} | ${avg.toFixed(1)} | ${p99.toFixed(1)} | ${Math.max(...dts).toFixed(1)} | ${cpu.toFixed(1)} | ${dts.length} |`); + } + Object.assign(S, saved); + buildMap(); setTokens(); clearStrokes(); buildGrid(); fit(); refreshUI(); + benchStatus = ''; + const md = + `Renderer: ${rendererName}, GPU: ${gpuName}, maxTex ${maxTex}, res ${app.renderer.resolution}, viewport ${innerWidth}x${innerHeight}, ${BENCH_MS}ms/scenario (+${WARM_MS}ms warmup), chaos on, grid on, cull on\n` + + `UA: ${navigator.userAgent}\n\n` + + `| map | map path | tokens | strokes | fps | avg ms | p99 ms | worst ms | js ms | frames |\n|---|---|---|---|---|---|---|---|---|---|\n` + + rows.join('\n'); + out.value = md; + (window as any).__bench = md; + return md; +} + +// ---------- controls ---------- +const ctl = document.getElementById('ctl')!; +const refreshers: (() => void)[] = []; +const refreshUI = () => refreshers.forEach((f) => f()); +function select(name: string, opts: (string | number)[], get: () => string | number, set: (v: string) => void) { + const l = document.createElement('label'); l.append(name); + const s = document.createElement('select'); + for (const o of opts) s.add(new Option(String(o), String(o))); + s.onchange = () => set(s.value); + refreshers.push(() => (s.value = String(get()))); + l.append(s); ctl.append(l); refreshers.at(-1)!(); +} +function check(name: string, get: () => boolean, set: (v: boolean) => void) { + const l = document.createElement('label'); l.append(name); + const c = document.createElement('input'); c.type = 'checkbox'; + c.onchange = () => set(c.checked); + refreshers.push(() => (c.checked = get())); + l.append(c); ctl.append(l); refreshers.at(-1)!(); +} +function button(name: string, fn: () => void) { + const b = document.createElement('button'); b.textContent = name; b.onclick = fn; ctl.append(b); +} +select('map size', [2048, 4096, 8192, 16384], () => S.map, (v) => { S.map = +v; buildMap(); buildGrid(); setTokens(); fit(); }); +select('tile size', ['auto', 2048, 4096], () => S.tile || 'auto', (v) => { S.tile = v === 'auto' ? 0 : +v; buildMap(); }); +const file = document.createElement('input'); file.type = 'file'; file.accept = 'image/*'; +file.onchange = async () => { if (file.files?.[0]) { customBitmap = await createImageBitmap(file.files[0]); buildMap(); } }; +ctl.append('map image:', file); +check('grid', () => S.grid, (v) => { S.grid = v; grid!.visible = v; }); +select('grid cell px', [16, 32, 50, 64, 100, 128, 256], () => S.cell, (v) => { S.cell = +v; buildGrid(); }); +select('tokens', [50, 200, 500, 1000, 2000], () => S.n, (v) => { S.n = +v; setTokens(); }); +check('chaos (move all every frame)', () => S.chaos, (v) => (S.chaos = v)); +check('HP churn (text every frame)', () => S.churn, (v) => (S.churn = v)); +check('culling', () => S.cull, (v) => { S.cull = v; setCull(v); }); +select('tool (RMB/MMB/2 fingers = pan)', ['move', 'pen'], () => S.tool, (v) => (S.tool = v as 'move' | 'pen')); +button('+200 random strokes', () => randomStrokes(200)); +button('clear strokes', clearStrokes); +button('fit view', fit); +const out = document.createElement('textarea'); out.id = 'out'; out.readOnly = true; +button('Run benchmark', () => { void runBench(out); }); +button('copy results', () => navigator.clipboard?.writeText(out.value)); +ctl.append(out); + +// ---------- init ---------- +buildMap(); +buildGrid(); +setTokens(); +fit(); +refreshUI(); +(window as any).__ready = true; +(window as any).__app = { S, world, strokeLayer, stats, runBench: () => runBench(out), randomStrokes, setTokens, buildMap, buildGrid, fit }; +if (q.get('bench')) void runBench(out); diff --git a/prototype-pixi-perf/tsconfig.json b/prototype-pixi-perf/tsconfig.json new file mode 100644 index 0000000..07a64dc --- /dev/null +++ b/prototype-pixi-perf/tsconfig.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "ESNext", + "moduleResolution": "bundler", + "lib": ["ES2022", "DOM"], + "strict": true, + "noEmit": true, + "skipLibCheck": true, + "types": ["vite/client"] + }, + "include": ["src"] +}