@null3d/engine 0.0.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +109 -0
- package/THIRD-PARTY-NOTICES.txt +0 -1
- package/dist/wasm/single/null3d.js +25 -10
- package/dist/wasm/single/null3d_bg.wasm +0 -0
- package/dist/wasm/threaded/null3d.js +25 -10
- package/dist/wasm/threaded/null3d_bg.wasm +0 -0
- package/docs/api/animation.md +114 -86
- package/docs/api/assets.md +135 -49
- package/docs/api/cameras.md +45 -12
- package/docs/api/controls.md +88 -62
- package/docs/api/debug.md +116 -41
- package/docs/api/engine.md +117 -35
- package/docs/api/feature-draws.md +23 -17
- package/docs/api/feature-effects.md +11 -11
- package/docs/api/feature-instances.md +70 -19
- package/docs/api/features.md +77 -47
- package/docs/api/geometry.md +132 -82
- package/docs/api/grass.md +55 -13
- package/docs/api/impostors.md +175 -22
- package/docs/api/input.md +24 -18
- package/docs/api/lights.md +78 -51
- package/docs/api/lines.md +41 -33
- package/docs/api/materials.md +248 -121
- package/docs/api/math.md +12 -13
- package/docs/api/objects.md +47 -22
- package/docs/api/page.md +58 -7
- package/docs/api/particles.md +33 -20
- package/docs/api/points.md +19 -31
- package/docs/api/post.md +75 -42
- package/docs/api/quality.md +42 -17
- package/docs/api/raycast.md +65 -51
- package/docs/api/reference/animation.md +10 -11
- package/docs/api/reference/assets.md +25 -22
- package/docs/api/reference/cameras.md +8 -4
- package/docs/api/reference/controls.md +134 -25
- package/docs/api/reference/debug.md +81 -14
- package/docs/api/reference/engine.md +58 -17
- package/docs/api/reference/feature-draws.md +3 -4
- package/docs/api/reference/feature-effects.md +2 -3
- package/docs/api/reference/feature-instances.md +5 -4
- package/docs/api/reference/features.md +7 -4
- package/docs/api/reference/geometry.md +287 -97
- package/docs/api/reference/grass.md +63 -3
- package/docs/api/reference/impostors.md +208 -13
- package/docs/api/reference/input.md +4 -5
- package/docs/api/reference/lights.md +13 -12
- package/docs/api/reference/lines.md +10 -11
- package/docs/api/reference/materials.md +54 -53
- package/docs/api/reference/math.md +35 -24
- package/docs/api/reference/objects.md +11 -12
- package/docs/api/reference/particles.md +31 -6
- package/docs/api/reference/points.md +6 -7
- package/docs/api/reference/post.md +21 -20
- package/docs/api/reference/quality.md +8 -5
- package/docs/api/reference/raycast.md +7 -8
- package/docs/api/reference/render.md +5 -4
- package/docs/api/reference/scene.md +52 -30
- package/docs/api/reference/sketch.md +15 -11
- package/docs/api/reference/sound.md +234 -0
- package/docs/api/reference/splats.md +42 -3
- package/docs/api/reference/sprites.md +7 -8
- package/docs/api/reference/tasks.md +16 -3
- package/docs/api/reference/terrain.md +27 -5
- package/docs/api/reference/textures.md +5 -6
- package/docs/api/reference/three-compat.md +18 -7
- package/docs/api/reference/time.md +1 -2
- package/docs/api/reference/ui.md +12 -9
- package/docs/api/reference/vertex-draws.md +5 -6
- package/docs/api/reference/water.md +153 -9
- package/docs/api/reference/wind.md +17 -4
- package/docs/api/render.md +73 -29
- package/docs/api/scene.md +164 -60
- package/docs/api/sketch.md +102 -15
- package/docs/api/sound.md +205 -0
- package/docs/api/splats.md +46 -12
- package/docs/api/sprites.md +10 -24
- package/docs/api/tasks.md +33 -24
- package/docs/api/terrain.md +42 -22
- package/docs/api/textures.md +68 -19
- package/docs/api/three-compat.md +15 -7
- package/docs/api/time.md +3 -5
- package/docs/api/ui.md +19 -23
- package/docs/api/vertex-draws.md +13 -12
- package/docs/api/water.md +262 -35
- package/docs/api/wind.md +63 -17
- package/docs/cli/null3d.md +177 -27
- package/docs/concepts/architecture.md +73 -27
- package/docs/concepts/assets.md +57 -33
- package/docs/concepts/backends.md +69 -27
- package/docs/concepts/color-management.md +54 -36
- package/docs/concepts/culling.md +68 -47
- package/docs/concepts/handles.md +14 -5
- package/docs/concepts/instances.md +74 -25
- package/docs/concepts/large-worlds.md +18 -8
- package/docs/concepts/lighting.md +155 -87
- package/docs/concepts/lod.md +126 -44
- package/docs/concepts/materials.md +58 -27
- package/docs/concepts/particle-buffer.md +48 -35
- package/docs/concepts/post-processing.md +84 -43
- package/docs/concepts/quality-preset-tables.md +56 -52
- package/docs/concepts/quality-presets.md +164 -52
- package/docs/concepts/render-graph.md +69 -29
- package/docs/concepts/render-layers.md +11 -21
- package/docs/concepts/shadows.md +105 -52
- package/docs/concepts/static-dynamic.md +22 -7
- package/docs/cookbook/index.md +164 -120
- package/docs/data/threejs-mapping.json +362 -367
- package/docs/errors/E1101.md +23 -5
- package/docs/errors/E1102.md +11 -3
- package/docs/errors/E1103.md +11 -3
- package/docs/errors/E1104.md +11 -3
- package/docs/errors/E1105.md +13 -5
- package/docs/errors/E1106.md +11 -3
- package/docs/errors/E1107.md +15 -5
- package/docs/errors/E1108.md +11 -3
- package/docs/errors/E1109.md +32 -6
- package/docs/errors/E1110.md +23 -5
- package/docs/errors/E1111.md +11 -3
- package/docs/errors/E1112.md +11 -3
- package/docs/errors/E1203.md +12 -4
- package/docs/errors/E1204.md +11 -3
- package/docs/errors/E1205.md +11 -3
- package/docs/errors/E1206.md +28 -6
- package/docs/errors/E1207.md +11 -3
- package/docs/errors/E1208.md +12 -3
- package/docs/errors/E1209.md +11 -3
- package/docs/errors/E1213.md +27 -5
- package/docs/errors/E1214.md +14 -6
- package/docs/errors/E1215.md +31 -6
- package/docs/errors/E1216.md +31 -6
- package/docs/errors/E1217.md +29 -6
- package/docs/errors/E1218.md +22 -6
- package/docs/errors/E1219.md +11 -3
- package/docs/errors/E1220.md +24 -5
- package/docs/errors/E1221.md +24 -5
- package/docs/errors/E1222.md +11 -3
- package/docs/errors/E1223.md +39 -6
- package/docs/errors/E1224.md +11 -3
- package/docs/errors/E1225.md +11 -3
- package/docs/errors/E1301.md +11 -3
- package/docs/errors/E1302.md +11 -3
- package/docs/errors/E1303.md +11 -3
- package/docs/errors/E1304.md +11 -3
- package/docs/errors/E1305.md +13 -3
- package/docs/errors/E1306.md +11 -3
- package/docs/errors/E1307.md +40 -0
- package/docs/errors/E1401.md +11 -3
- package/docs/errors/E1402.md +13 -5
- package/docs/errors/E1403.md +11 -3
- package/docs/errors/E1404.md +13 -3
- package/docs/errors/E1405.md +15 -4
- package/docs/errors/E1406.md +31 -5
- package/docs/errors/E1407.md +11 -3
- package/docs/errors/E1408.md +11 -3
- package/docs/errors/E1409.md +11 -3
- package/docs/errors/E1410.md +13 -5
- package/docs/errors/E1411.md +11 -3
- package/docs/errors/E1412.md +29 -6
- package/docs/errors/E1413.md +11 -3
- package/docs/errors/E1414.md +11 -3
- package/docs/errors/E1415.md +11 -3
- package/docs/errors/E1416.md +27 -6
- package/docs/errors/E1417.md +11 -3
- package/docs/errors/E1418.md +12 -3
- package/docs/errors/E1419.md +13 -5
- package/docs/errors/E1420.md +14 -6
- package/docs/errors/E1421.md +11 -3
- package/docs/errors/E1422.md +12 -3
- package/docs/errors/E1423.md +12 -3
- package/docs/errors/E1424.md +24 -5
- package/docs/errors/E1425.md +11 -3
- package/docs/errors/E1426.md +11 -3
- package/docs/errors/E1430.md +11 -3
- package/docs/errors/E1431.md +11 -3
- package/docs/errors/E1432.md +11 -3
- package/docs/errors/E1433.md +11 -3
- package/docs/errors/E1434.md +15 -6
- package/docs/errors/E1435.md +11 -3
- package/docs/errors/E1436.md +11 -3
- package/docs/errors/E1437.md +14 -6
- package/docs/errors/E1501.md +41 -6
- package/docs/errors/E1502.md +13 -3
- package/docs/errors/E1503.md +11 -3
- package/docs/errors/E1504.md +11 -3
- package/docs/errors/E1505.md +23 -5
- package/docs/errors/E1506.md +11 -3
- package/docs/errors/index.md +54 -30
- package/docs/getting-started/cdn.md +32 -10
- package/docs/getting-started/first-scene.md +21 -13
- package/docs/getting-started/hosting.md +152 -63
- package/docs/getting-started/install.md +44 -28
- package/docs/getting-started/network-use.md +33 -15
- package/docs/getting-started/project-structure.md +33 -12
- package/docs/getting-started/third-party-notices.md +12 -14
- package/docs/guides/accessibility.md +5 -5
- package/docs/guides/add-ons.md +86 -15
- package/docs/guides/agents.md +16 -9
- package/docs/guides/assets-pipeline.md +259 -82
- package/docs/guides/audio.md +115 -128
- package/docs/guides/baked-light-data.md +44 -23
- package/docs/guides/car-paint.md +38 -32
- package/docs/guides/content-pages.md +63 -35
- package/docs/guides/custom-passes.md +65 -22
- package/docs/guides/custom-shaders.md +59 -39
- package/docs/guides/debugging.md +74 -10
- package/docs/guides/deploying.md +85 -6
- package/docs/guides/deterministic-simulation.md +24 -17
- package/docs/guides/first-use-shaders.md +83 -45
- package/docs/guides/lens-kit.md +29 -26
- package/docs/guides/loading-screens.md +132 -47
- package/docs/guides/multiple-views.md +63 -13
- package/docs/guides/performance.md +192 -38
- package/docs/guides/phones.md +78 -15
- package/docs/guides/physics.md +7 -11
- package/docs/guides/screens.md +47 -33
- package/docs/guides/start-time.md +363 -0
- package/docs/guides/testing.md +152 -95
- package/docs/guides/ui-overlays.md +19 -14
- package/docs/guides/video-textures.md +14 -13
- package/docs/images/api/animation/character.webp +0 -0
- package/docs/images/api/animation/look-at-ring.webp +0 -0
- package/docs/images/api/animation/morph-tulips.webp +0 -0
- package/docs/images/api/animation/skeleton-lines.webp +0 -0
- package/docs/images/api/controls/gizmo-handles.webp +0 -0
- package/docs/images/api/controls/walk-and-fly.webp +0 -0
- package/docs/images/api/debug/debug-shapes.webp +0 -0
- package/docs/images/api/debug/levels-view.webp +0 -0
- package/docs/images/api/engine/transparent-canvas.webp +0 -0
- package/docs/images/api/feature-draws/feature-draw-clouds.webp +0 -0
- package/docs/images/api/feature-instances/compute-instances.webp +0 -0
- package/docs/images/api/feature-instances/instances-shadow.webp +0 -0
- package/docs/images/api/geometry/extra-shapes.webp +0 -0
- package/docs/images/api/geometry/generators.webp +0 -0
- package/docs/images/api/geometry/mesh-arrays.webp +0 -0
- package/docs/images/api/geometry/vertex-updates.webp +0 -0
- package/docs/images/api/grass/grass-grove.webp +0 -0
- package/docs/images/api/grass/grass-presets.webp +0 -0
- package/docs/images/api/grass/grass-shadow.webp +0 -0
- package/docs/images/api/impostors/impostor-handover.webp +0 -0
- package/docs/images/api/impostors/impostor-shadow.webp +0 -0
- package/docs/images/api/impostors/impostors-forest.webp +0 -0
- package/docs/images/api/lights/spot-cookies.webp +0 -0
- package/docs/images/api/lines/lines-lit.webp +0 -0
- package/docs/images/api/lines/lines-widths.webp +0 -0
- package/docs/images/api/materials/coat-and-sheen.webp +0 -0
- package/docs/images/api/materials/decals.webp +0 -0
- package/docs/images/api/materials/iridescence-and-anisotropy.webp +0 -0
- package/docs/images/api/materials/relief.webp +0 -0
- package/docs/images/api/materials/shader-inputs.webp +0 -0
- package/docs/images/api/materials/standard-grid.webp +0 -0
- package/docs/images/api/materials/subsurface.webp +0 -0
- package/docs/images/api/materials/translucency.webp +0 -0
- package/docs/images/api/objects/objects-turntable.webp +0 -0
- package/docs/images/api/particles/campfire.webp +0 -0
- package/docs/images/api/points/galaxy.webp +0 -0
- package/docs/images/api/reference/textures/texture-wrap.webp +0 -0
- package/docs/images/api/render/fullscreen-glow.webp +0 -0
- package/docs/images/api/render/reflection-mirror.webp +0 -0
- package/docs/images/api/render/security-camera.webp +0 -0
- package/docs/images/api/scene/aurora-sky-layer.webp +0 -0
- package/docs/images/api/sound/sound-demo.webp +0 -0
- package/docs/images/api/splats/splats-demo.webp +0 -0
- package/docs/images/api/sprites/sprites-lines.webp +0 -0
- package/docs/images/api/terrain/terrain-demo.webp +0 -0
- package/docs/images/api/textures/canvas-screen.webp +0 -0
- package/docs/images/api/textures/mipmaps.webp +0 -0
- package/docs/images/api/vertex-draws/rain.webp +0 -0
- package/docs/images/api/water/ocean.webp +0 -0
- package/docs/images/api/water/water-demo.webp +0 -0
- package/docs/images/api/water/water-rain.webp +0 -0
- package/docs/images/api/water/waterfall.webp +0 -0
- package/docs/images/concepts/assets/gltf-model.webp +0 -0
- package/docs/images/concepts/color-management/tone-mapped.webp +0 -0
- package/docs/images/concepts/culling/far-from-origin.webp +0 -0
- package/docs/images/concepts/instances/instances.webp +0 -0
- package/docs/images/concepts/instances/per-row-colors.webp +0 -0
- package/docs/images/concepts/large-worlds/large-world.webp +0 -0
- package/docs/images/concepts/lighting/area-lights.webp +0 -0
- package/docs/images/concepts/lighting/atmosphere.webp +0 -0
- package/docs/images/concepts/lighting/environment.webp +0 -0
- package/docs/images/concepts/lighting/light-shafts.webp +0 -0
- package/docs/images/concepts/lighting/reflection-probes.webp +0 -0
- package/docs/images/concepts/lod/forest.webp +0 -0
- package/docs/images/concepts/materials/weighted-transparency.webp +0 -0
- package/docs/images/concepts/post-processing/auto-exposure.webp +0 -0
- package/docs/images/concepts/post-processing/bounce-light.webp +0 -0
- package/docs/images/concepts/post-processing/depth-of-field.webp +0 -0
- package/docs/images/concepts/post-processing/post-effects-alley.webp +0 -0
- package/docs/images/concepts/post-processing/sharpen.webp +0 -0
- package/docs/images/concepts/post-processing/ssr-wet-street.webp +0 -0
- package/docs/images/concepts/render-layers/layers-cottages.webp +0 -0
- package/docs/images/concepts/shadows/hero-shadow.webp +0 -0
- package/docs/images/cookbook/index/picking.webp +0 -0
- package/docs/images/cookbook/index/time-of-day.webp +0 -0
- package/docs/images/errors/E1431/area-lights-no-tables.webp +0 -0
- package/docs/images/guides/custom-passes/reflection-water.webp +0 -0
- package/docs/images/guides/deterministic-simulation/replay-demo.webp +0 -0
- package/docs/images/guides/multiple-views/split-screen.webp +0 -0
- package/docs/images/guides/performance/overdraw-view.webp +0 -0
- package/docs/images/guides/testing/hold-mode-frame.webp +0 -0
- package/docs/images/index/showcase-island.webp +0 -0
- package/docs/images/porting/threejs-shaders/dissolve.webp +0 -0
- package/docs/images/shaders/builtins/builtins.webp +0 -0
- package/docs/images/shaders/surface-functions/custom-surface.webp +0 -0
- package/docs/images/shaders/surface-functions/vertex-offset.webp +0 -0
- package/docs/images/shots.json +2231 -0
- package/docs/index.md +18 -23
- package/docs/moves.json +1 -0
- package/docs/nav.json +300 -0
- package/docs/pages.md +230 -209
- package/docs/porting/react-three-fiber.md +225 -6
- package/docs/porting/threejs-loop-and-threads.md +217 -7
- package/docs/porting/threejs-mapping.md +1249 -233
- package/docs/porting/threejs-materials.md +218 -6
- package/docs/porting/threejs-overview.md +240 -7
- package/docs/porting/threejs-postprocessing.md +4 -8
- package/docs/porting/threejs-shaders.md +301 -6
- package/docs/porting/threejs-unsupported.md +83 -7
- package/docs/porting/verification.md +178 -6
- package/docs/shaders/builtins.md +15 -4
- package/docs/shaders/library.md +72 -45
- package/docs/shaders/surface-functions.md +59 -23
- package/docs/shaders/wgsl-rules.md +12 -5
- package/lib/debug/channel.d.ts +103 -0
- package/lib/debug/channel.js +269 -0
- package/lib/debug/debug.d.ts +11 -9
- package/lib/debug/draw.d.ts +11 -2
- package/lib/debug/draw.js +57 -6
- package/lib/debug/inspector.d.ts +60 -0
- package/lib/debug/inspector.js +475 -0
- package/lib/debug/overlay-look.d.ts +6 -0
- package/lib/debug/overlay-look.js +29 -7
- package/lib/debug/overlay.js +15 -11
- package/lib/debug/stats-options.d.ts +13 -0
- package/lib/debug/stats-panel.d.ts +22 -7
- package/lib/debug/stats-panel.js +80 -13
- package/lib/debug/stats.d.ts +2 -3
- package/lib/errors/codes.d.ts +17 -3
- package/lib/errors/codes.js +117 -105
- package/lib/errors/engine-error.js +25 -10
- package/lib/errors/fixes.d.ts +1 -0
- package/lib/errors/fixes.js +20 -19
- package/lib/generated/core.d.ts +1 -1
- package/lib/generated/core.js +1 -1
- package/lib/gpu/early-builds.d.ts +68 -0
- package/lib/gpu/early-builds.js +158 -0
- package/lib/gpu/pipeline-name.d.ts +6 -0
- package/lib/gpu/pipeline-name.js +23 -0
- package/lib/gpu/variants.d.ts +8 -2
- package/lib/gpu/variants.js +39 -7
- package/lib/gpu/webgl2/backend.d.ts +63 -2
- package/lib/gpu/webgl2/backend.js +226 -8
- package/lib/gpu/webgl2/programs.d.ts +18 -0
- package/lib/gpu/webgl2/programs.js +5 -2
- package/lib/gpu/webgpu/backend.d.ts +89 -2
- package/lib/gpu/webgpu/backend.js +255 -8
- package/lib/gpu/webgpu/pipelines.d.ts +13 -0
- package/lib/gpu/webgpu/pipelines.js +28 -14
- package/lib/index.d.ts +7 -5
- package/lib/index.js +3 -2
- package/lib/math/color.d.ts +5 -5
- package/lib/math/color.js +5 -5
- package/lib/math/mat4.d.ts +6 -12
- package/lib/math/mat4.js +6 -12
- package/lib/math/namespaces/quat.d.ts +3 -3
- package/lib/math/namespaces/quat.js +3 -3
- package/lib/math/quat.d.ts +8 -12
- package/lib/math/quat.js +8 -12
- package/lib/math/random.d.ts +2 -3
- package/lib/math/random.js +2 -3
- package/lib/math/types.d.ts +4 -4
- package/lib/math/vec3.d.ts +3 -6
- package/lib/math/vec3.js +3 -6
- package/lib/page/capabilities.d.ts +8 -8
- package/lib/page/capabilities.js +39 -25
- package/lib/page/check-store.d.ts +14 -2
- package/lib/page/check-store.js +34 -11
- package/lib/page/engine.d.ts +117 -31
- package/lib/page/engine.js +438 -99
- package/lib/page/first-frame.d.ts +16 -0
- package/lib/page/first-frame.js +35 -0
- package/lib/page/frame-stats.d.ts +34 -1
- package/lib/page/frame-stats.js +15 -0
- package/lib/page/label-loop.d.ts +7 -3
- package/lib/page/label-loop.js +26 -14
- package/lib/page/labels.d.ts +3 -3
- package/lib/page/pipeline-store.d.ts +25 -0
- package/lib/page/pipeline-store.js +84 -0
- package/lib/page/start-marker.d.ts +4 -1
- package/lib/page/start-marker.js +5 -2
- package/lib/page/stats-switch.js +2 -0
- package/lib/page/switches.d.ts +38 -6
- package/lib/page/switches.js +29 -5
- package/lib/quality/check.d.ts +24 -3
- package/lib/quality/check.js +21 -7
- package/lib/quality/chooser.d.ts +6 -0
- package/lib/quality/chooser.js +8 -0
- package/lib/quality/governor.d.ts +98 -6
- package/lib/quality/governor.js +250 -20
- package/lib/quality/preset-docs.d.ts +16 -1
- package/lib/quality/preset-docs.js +3 -0
- package/lib/quality/presets.d.ts +84 -7
- package/lib/quality/presets.js +94 -2
- package/lib/render/draw.d.ts +3 -2
- package/lib/render/draw.js +15 -5
- package/lib/render/load-draw.d.ts +7 -5
- package/lib/render/load-draw.js +7 -5
- package/lib/render/loss.d.ts +28 -10
- package/lib/render/loss.js +50 -22
- package/lib/render/recovery.d.ts +20 -0
- package/lib/render/recovery.js +44 -4
- package/lib/render/renderer.d.ts +85 -9
- package/lib/render/renderer.js +181 -42
- package/lib/render/scene-renderer.d.ts +19 -1
- package/lib/render/scene-renderer.js +25 -1
- package/lib/render/webgl2-renderers.js +8 -5
- package/lib/render/webgpu-renderers.js +5 -4
- package/lib/scene/animation.d.ts +28 -32
- package/lib/scene/animation.js +12 -15
- package/lib/scene/assets.d.ts +61 -86
- package/lib/scene/assets.js +103 -236
- package/lib/scene/background.d.ts +14 -18
- package/lib/scene/background.js +5 -2
- package/lib/scene/baked-light.d.ts +2 -2
- package/lib/scene/color.d.ts +3 -3
- package/lib/scene/downloads.d.ts +2 -0
- package/lib/scene/downloads.js +371 -0
- package/lib/scene/environment.d.ts +7 -7
- package/lib/scene/environment.js +1 -1
- package/lib/scene/fake-call-values.js +3 -3
- package/lib/scene/fog.d.ts +11 -4
- package/lib/scene/fog.js +8 -2
- package/lib/scene/frame-cameras.d.ts +35 -4
- package/lib/scene/frame-cameras.js +86 -10
- package/lib/scene/gltf.d.ts +33 -3
- package/lib/scene/gltf.js +78 -49
- package/lib/scene/grading.d.ts +2 -2
- package/lib/scene/grading.js +3 -3
- package/lib/scene/ktx2.d.ts +9 -1
- package/lib/scene/ktx2.js +3 -2
- package/lib/scene/level-rule.d.ts +121 -0
- package/lib/scene/level-rule.js +130 -0
- package/lib/scene/lines.d.ts +13 -17
- package/lib/scene/lines.js +3 -3
- package/lib/scene/lut.d.ts +1 -2
- package/lib/scene/lut.js +1 -2
- package/lib/scene/particles.d.ts +7 -3
- package/lib/scene/particles.js +3 -1
- package/lib/scene/picks.d.ts +2 -2
- package/lib/scene/pointer-events.d.ts +4 -7
- package/lib/scene/post.d.ts +39 -43
- package/lib/scene/post.js +4 -1
- package/lib/scene/prefab.d.ts +7 -8
- package/lib/scene/prefab.js +7 -8
- package/lib/scene/property-animation.d.ts +1 -1
- package/lib/scene/property-animation.js +1 -1
- package/lib/scene/queries.d.ts +7 -13
- package/lib/scene/resources.d.ts +238 -261
- package/lib/scene/resources.js +179 -81
- package/lib/scene/scene.d.ts +167 -120
- package/lib/scene/scene.js +243 -103
- package/lib/scene/serial-loads.d.ts +29 -0
- package/lib/scene/serial-loads.js +68 -0
- package/lib/scene/shader-preloads.d.ts +34 -0
- package/lib/scene/shader-preloads.js +38 -0
- package/lib/scene/sprites.d.ts +14 -17
- package/lib/scene/sprites.js +5 -6
- package/lib/scene/textures.d.ts +11 -12
- package/lib/scene/textures.js +9 -10
- package/lib/scene/time-of-day.d.ts +11 -7
- package/lib/scene/time-of-day.js +11 -8
- package/lib/scene/vertex-draws.d.ts +5 -4
- package/lib/scene/vertex-draws.js +7 -5
- package/lib/shader-artifact.json +1 -0
- package/lib/shared/core.d.ts +5 -0
- package/lib/shared/core.js +1 -0
- package/lib/shared/import-once.d.ts +6 -0
- package/lib/shared/import-once.js +19 -0
- package/lib/shared/labels.d.ts +5 -2
- package/lib/shared/labels.js +5 -2
- package/lib/shared/metrics.d.ts +38 -0
- package/lib/shared/metrics.js +62 -1
- package/lib/shared/permutation-words.d.ts +2 -0
- package/lib/shared/permutation-words.js +8 -0
- package/lib/shared/recording.d.ts +13 -5
- package/lib/shared/recording.js +31 -10
- package/lib/shared/run-task.js +7 -1
- package/lib/shared/sketch-data.d.ts +9 -0
- package/lib/shared/sketch-data.js +57 -0
- package/lib/shared/task-pending.d.ts +12 -0
- package/lib/shared/task-pending.js +61 -1
- package/lib/shared/tasks.js +79 -32
- package/lib/shared/version.d.ts +17 -1
- package/lib/shared/version.js +19 -1
- package/lib/shared/wasm.d.ts +12 -4
- package/lib/shared/wasm.js +50 -27
- package/lib/shared/worker-start.d.ts +7 -0
- package/lib/shared/worker-start.js +27 -0
- package/lib/sketch/define-sketch.d.ts +51 -7
- package/lib/sketch/define-sketch.js +2 -1
- package/lib/sketch/input.d.ts +2 -2
- package/lib/sketch/preset-check.d.ts +20 -6
- package/lib/sketch/preset-check.js +42 -17
- package/lib/sketch/quality.d.ts +69 -11
- package/lib/sketch/quality.js +54 -13
- package/lib/sketch/runner.d.ts +80 -9
- package/lib/sketch/runner.js +390 -52
- package/lib/sketch/ui.d.ts +5 -8
- package/lib/sketch/ui.js +4 -2
- package/lib/stats.d.ts +1 -0
- package/lib/workers/probe-worker.d.ts +5 -0
- package/lib/workers/probe-worker.js +13 -4
- package/lib/workers/protocol.d.ts +71 -13
- package/lib/workers/protocol.js +4 -0
- package/lib/workers/render-worker.js +29 -5
- package/lib/workers/sketch-worker.js +108 -16
- package/package.json +2 -2
|
@@ -21,6 +21,13 @@ export interface CanvasTarget {
|
|
|
21
21
|
* Metal's own convention, which needs no rewrite.
|
|
22
22
|
*/
|
|
23
23
|
export declare function useFirstProvokingVertex(gl: WebGL2RenderingContext): void;
|
|
24
|
+
/**
|
|
25
|
+
* A framebuffer that a live context refused. The backend skips the frame and asks again on the
|
|
26
|
+
* next one, because a driver can answer a lost context's check with a refusal before the loss flag
|
|
27
|
+
* is set; the same refusal on the next frame is a format the device does not draw into.
|
|
28
|
+
*/
|
|
29
|
+
export declare class WebGL2TargetRefused extends Error {
|
|
30
|
+
}
|
|
24
31
|
export declare class WebGL2Backend {
|
|
25
32
|
private readonly gl;
|
|
26
33
|
private readonly canvas;
|
|
@@ -72,6 +79,13 @@ export declare class WebGL2Backend {
|
|
|
72
79
|
readonly joins: JoinedBuilds;
|
|
73
80
|
/** True once a list has replayed, after which no frame waits for a joined shader's compile. */
|
|
74
81
|
private replayed;
|
|
82
|
+
/**
|
|
83
|
+
* How many frames in a row a live context has refused a target, and the target's message, so
|
|
84
|
+
* the next frame may refuse one again before the engine ends: a lost context can answer the
|
|
85
|
+
* check this way before its flag is set, and a cadence can put two targets in the way.
|
|
86
|
+
*/
|
|
87
|
+
private refusedFrames;
|
|
88
|
+
private refusedTarget;
|
|
75
89
|
/** The opcode and word of the command that the replay is carrying out. */
|
|
76
90
|
private replayOp;
|
|
77
91
|
private replayWord;
|
|
@@ -81,6 +95,10 @@ export declare class WebGL2Backend {
|
|
|
81
95
|
* draws draw nothing.
|
|
82
96
|
*/
|
|
83
97
|
private readonly parked;
|
|
98
|
+
/** The create commands of the pipelines that the lists before the first frame create. */
|
|
99
|
+
private readonly listing;
|
|
100
|
+
/** The compiles of the programs that the last start's first frame built, until this first frame. */
|
|
101
|
+
private early;
|
|
84
102
|
/**
|
|
85
103
|
* In development builds, the programs that a hot update of a custom material's shader compiles,
|
|
86
104
|
* each under the key of the program it replaces once it has compiled. `relinked` is set once the
|
|
@@ -92,7 +110,16 @@ export declare class WebGL2Backend {
|
|
|
92
110
|
* bits. Without it, every pipeline's build must be in the shaders that the backend got.
|
|
93
111
|
*/
|
|
94
112
|
moreShaders: DeviceShaderSet | undefined;
|
|
95
|
-
/**
|
|
113
|
+
/**
|
|
114
|
+
* Hears each program of the scene's objects that the driver refused to link twice, by its
|
|
115
|
+
* pipeline's name and the link's logs. Its draws draw nothing from then on, and the frames go
|
|
116
|
+
* on without them.
|
|
117
|
+
*/
|
|
118
|
+
refused: ((pipeline: string, reason: string) => void) | undefined;
|
|
119
|
+
/**
|
|
120
|
+
* True while the current pipeline's program is compiling, or after the driver refused it: draws
|
|
121
|
+
* draw nothing until it is set again.
|
|
122
|
+
*/
|
|
96
123
|
private skipDraws;
|
|
97
124
|
private readonly anisotropic;
|
|
98
125
|
private readonly maxAnisotropy;
|
|
@@ -245,6 +272,13 @@ export declare class WebGL2Backend {
|
|
|
245
272
|
* first draw waits for its compile.
|
|
246
273
|
*/
|
|
247
274
|
prepare(words: Uint32Array, start: number, end: number): number;
|
|
275
|
+
/**
|
|
276
|
+
* Starts to compile, in the background, the program of each pipeline that the list in
|
|
277
|
+
* `words[start, end)` creates after other commands. The frame before the first one then waits
|
|
278
|
+
* for them, as for the programs of the pipelines at the list's front, instead of its first draw
|
|
279
|
+
* with each waiting for its compile.
|
|
280
|
+
*/
|
|
281
|
+
private compileAhead;
|
|
248
282
|
/**
|
|
249
283
|
* Where the draw section of the list in `words[start, end)` begins, after the pipelines it
|
|
250
284
|
* creates. It walks the same ops as `prepare` and starts no build.
|
|
@@ -282,6 +316,20 @@ export declare class WebGL2Backend {
|
|
|
282
316
|
* with a few of them, so `scene.warmUp()` builds those, as for any material.
|
|
283
317
|
*/
|
|
284
318
|
precompile(features: readonly string[], module: FirstUseShaders): void;
|
|
319
|
+
/**
|
|
320
|
+
* Starts to compile the programs of `list`, a pipeline list of the pipelines that the first frame
|
|
321
|
+
* of the sketch's last start built (`gpu/early-builds.ts`). Each compile starts once its shader
|
|
322
|
+
* is there, and a pipeline of the same template and permutation takes the program. No frame
|
|
323
|
+
* waits for a program that no pipeline takes. A joined shader's program compiles when its
|
|
324
|
+
* pipeline comes, as its failure sends the effects back to a pass each.
|
|
325
|
+
*/
|
|
326
|
+
buildEarly(list: Uint32Array): void;
|
|
327
|
+
/**
|
|
328
|
+
* Ends the list of the pipelines that the frames before the first one created, and returns it,
|
|
329
|
+
* once: the first frame has drawn. The compiles of the last start's list that have not started
|
|
330
|
+
* stop.
|
|
331
|
+
*/
|
|
332
|
+
takeListing(): Uint32Array | undefined;
|
|
285
333
|
/** Creates each parked pipeline whose custom material's shader has arrived. */
|
|
286
334
|
private unpark;
|
|
287
335
|
/**
|
|
@@ -300,9 +348,13 @@ export declare class WebGL2Backend {
|
|
|
300
348
|
private countDraw;
|
|
301
349
|
/**
|
|
302
350
|
* Replays the draw list in `words[start, end)`. `floats` views the same memory as `words`, for
|
|
303
|
-
* float operands; `memory` is the engine memory that uploads read from.
|
|
351
|
+
* float operands; `memory` is the engine memory that uploads read from. A target that a live
|
|
352
|
+
* context refuses ends the replay without an error, and the next frame asks again before the
|
|
353
|
+
* refusal is reported: a lost context can answer the check that way before its flag is set.
|
|
304
354
|
*/
|
|
305
355
|
replay(words: Uint32Array, floats: Float32Array, start: number, end: number, memory: ArrayBufferLike): void;
|
|
356
|
+
/** Replays a draw list's commands, as `replay` describes them. */
|
|
357
|
+
private replayOps;
|
|
306
358
|
/**
|
|
307
359
|
* The program that draws mip levels, or the one that copies a layer, which starts compiling the
|
|
308
360
|
* first time.
|
|
@@ -320,6 +372,15 @@ export declare class WebGL2Backend {
|
|
|
320
372
|
* waits for its link when the driver has not finished it.
|
|
321
373
|
*/
|
|
322
374
|
private spareProgram;
|
|
375
|
+
/**
|
|
376
|
+
* Puts a program of the scene's objects in use, as `useProgram` does, and returns true. A link
|
|
377
|
+
* that the driver refused links once more, from new shaders: a driver can run short of memory
|
|
378
|
+
* while it links. A second refusal marks the program, so its draws draw nothing from then on,
|
|
379
|
+
* reports it, and returns false. Any other failure, such as a material with more textures than
|
|
380
|
+
* the stages hold, still stops the replay, and so does a link on a lost context, which the
|
|
381
|
+
* renderer recovers from as a loss.
|
|
382
|
+
*/
|
|
383
|
+
private useObjectsProgram;
|
|
323
384
|
/** Puts a program in use, first checking its link and binding its slots at its first use. */
|
|
324
385
|
private useProgram;
|
|
325
386
|
/**
|
|
@@ -21,14 +21,16 @@
|
|
|
21
21
|
import * as G from '../../generated/gpu.js';
|
|
22
22
|
import { DEV } from '../../shared/dev.js';
|
|
23
23
|
import { ImageTable } from '../../shared/images.js';
|
|
24
|
+
import { EarlyBuilds, PipelineListing } from '../early-builds.js';
|
|
24
25
|
import { JoinedBuilds, joinedReady } from '../effect-join.js';
|
|
25
26
|
import { CLOUD_FIELD_WORD, CLOUD_STEPS_WORD, LAYER_WORD, LIGHT_BUFFER_WORD, } from '../environment-words.js';
|
|
26
27
|
import { floatOfBits } from '../float-bits.js';
|
|
27
28
|
import { GpuMemory, textureBytes } from '../memory.js';
|
|
29
|
+
import { pipelineName } from '../pipeline-name.js';
|
|
28
30
|
import { variantFor } from '../variants.js';
|
|
29
31
|
import { forEachFallbackAttribute, forEachVertexAttribute, isNormalized, vertexStride, } from '../vertex-format.js';
|
|
30
32
|
import { setDepthMode } from './depth.js';
|
|
31
|
-
import { buildPermutation, createProgram, customTemplate, engineTemplates, linkLogs, metalFault, mipmapTemplate, prepareProgram, programHost, relink, slotOf, UPLOAD_UNIT, } from './programs.js';
|
|
33
|
+
import { buildPermutation, createProgram, customTemplate, engineTemplates, LinkFailure, linkLogs, metalFault, mipmapTemplate, prepareProgram, programHost, relink, slotOf, UPLOAD_UNIT, } from './programs.js';
|
|
32
34
|
/** The unit that the mip level shader samples: its source texture's group 0, binding 0. */
|
|
33
35
|
const MIP_UNIT = 0;
|
|
34
36
|
/** The key of the mip level program among the programs of pipelines. */
|
|
@@ -133,6 +135,13 @@ function pointAttribute(gl, stride, a) {
|
|
|
133
135
|
else
|
|
134
136
|
gl.vertexAttribPointer(a.location, a.size, type, isNormalized(a), stride, a.offset);
|
|
135
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* A framebuffer that a live context refused. The backend skips the frame and asks again on the
|
|
140
|
+
* next one, because a driver can answer a lost context's check with a refusal before the loss flag
|
|
141
|
+
* is set; the same refusal on the next frame is a format the device does not draw into.
|
|
142
|
+
*/
|
|
143
|
+
export class WebGL2TargetRefused extends Error {
|
|
144
|
+
}
|
|
136
145
|
/**
|
|
137
146
|
* How GL stores each texture format, by format code, for a canvas with alpha or without. A
|
|
138
147
|
* compressed format is there only when the context turned on its extension, which the backend
|
|
@@ -195,6 +204,34 @@ function glFormats(gl, canvasAlpha) {
|
|
|
195
204
|
add(G.FORMAT_DEPTH16_UNORM, gl.DEPTH_COMPONENT16, gl.DEPTH_COMPONENT, gl.UNSIGNED_SHORT, depth);
|
|
196
205
|
return formats;
|
|
197
206
|
}
|
|
207
|
+
/** The name of each format that a framebuffer's attachments may take. */
|
|
208
|
+
const FORMAT_NAMES = {
|
|
209
|
+
[G.FORMAT_CANVAS]: 'the canvas',
|
|
210
|
+
[G.FORMAT_RGBA8_UNORM]: 'RGBA8',
|
|
211
|
+
[G.FORMAT_RGBA8_UNORM_SRGB]: 'sRGB8',
|
|
212
|
+
[G.FORMAT_RGBA16_FLOAT]: 'RGBA16F',
|
|
213
|
+
[G.FORMAT_RG16_FLOAT]: 'RG16F',
|
|
214
|
+
[G.FORMAT_RG11B10_UFLOAT]: 'R11G11B10F',
|
|
215
|
+
[G.FORMAT_RGB9E5_UFLOAT]: 'RGB9E5',
|
|
216
|
+
[G.FORMAT_RGBA32_FLOAT]: 'RGBA32F',
|
|
217
|
+
[G.FORMAT_R32_UINT]: 'R32UI',
|
|
218
|
+
[G.FORMAT_R32_FLOAT]: 'R32F',
|
|
219
|
+
[G.FORMAT_RGBA32_UINT]: 'RGBA32UI',
|
|
220
|
+
[G.FORMAT_R16_FLOAT]: 'R16F',
|
|
221
|
+
[G.FORMAT_DEPTH24_PLUS]: 'depth24',
|
|
222
|
+
[G.FORMAT_DEPTH32_FLOAT]: 'depth32f',
|
|
223
|
+
[G.FORMAT_DEPTH16_UNORM]: 'depth16',
|
|
224
|
+
};
|
|
225
|
+
/** A framebuffer's attachments by name and GL's own format number, for a driver report. */
|
|
226
|
+
function describeFramebuffer(first, depth, second) {
|
|
227
|
+
const name = (target) => `${FORMAT_NAMES[target.format.code] ?? `format ${target.format.code}`} (0x${target.format.internal.toString(16)})`;
|
|
228
|
+
const parts = [`color ${name(first)}`];
|
|
229
|
+
if (second)
|
|
230
|
+
parts.push(`second color ${name(second)}`);
|
|
231
|
+
if (depth)
|
|
232
|
+
parts.push(`depth ${name(depth)}`);
|
|
233
|
+
return parts.join(', ');
|
|
234
|
+
}
|
|
198
235
|
/** The linear color formats that WebGL2 both renders into and filters, so `generateMipmap` takes them. */
|
|
199
236
|
const NATIVE_MIP_FORMATS = new Set([
|
|
200
237
|
G.FORMAT_RGBA8_UNORM,
|
|
@@ -207,6 +244,10 @@ const NATIVE_MIP_FORMATS = new Set([
|
|
|
207
244
|
* filters. The engine's own draws make the levels of other textures, such as uploaded images
|
|
208
245
|
* (`generateMipmaps` in the backend says why).
|
|
209
246
|
*/
|
|
247
|
+
/** True when `error` is a link that the driver refused, on a context that is not lost. */
|
|
248
|
+
function linkRefused(gl, error) {
|
|
249
|
+
return error instanceof LinkFailure && !gl.isContextLost();
|
|
250
|
+
}
|
|
210
251
|
function linearMips(format, usage, layers, mips) {
|
|
211
252
|
const target = G.TEXTURE_USAGE_RENDER_ATTACHMENT | G.TEXTURE_USAGE_COPY_DST;
|
|
212
253
|
return (mips > 1 &&
|
|
@@ -289,6 +330,13 @@ export class WebGL2Backend {
|
|
|
289
330
|
joins;
|
|
290
331
|
/** True once a list has replayed, after which no frame waits for a joined shader's compile. */
|
|
291
332
|
replayed = false;
|
|
333
|
+
/**
|
|
334
|
+
* How many frames in a row a live context has refused a target, and the target's message, so
|
|
335
|
+
* the next frame may refuse one again before the engine ends: a lost context can answer the
|
|
336
|
+
* check this way before its flag is set, and a cadence can put two targets in the way.
|
|
337
|
+
*/
|
|
338
|
+
refusedFrames = 0;
|
|
339
|
+
refusedTarget = '';
|
|
292
340
|
/** The opcode and word of the command that the replay is carrying out. */
|
|
293
341
|
replayOp = -1;
|
|
294
342
|
replayWord = -1;
|
|
@@ -298,6 +346,10 @@ export class WebGL2Backend {
|
|
|
298
346
|
* draws draw nothing.
|
|
299
347
|
*/
|
|
300
348
|
parked = new Map();
|
|
349
|
+
/** The create commands of the pipelines that the lists before the first frame create. */
|
|
350
|
+
listing = new PipelineListing();
|
|
351
|
+
/** The compiles of the programs that the last start's first frame built, until this first frame. */
|
|
352
|
+
early;
|
|
301
353
|
/**
|
|
302
354
|
* In development builds, the programs that a hot update of a custom material's shader compiles,
|
|
303
355
|
* each under the key of the program it replaces once it has compiled. `relinked` is set once the
|
|
@@ -309,7 +361,16 @@ export class WebGL2Backend {
|
|
|
309
361
|
* bits. Without it, every pipeline's build must be in the shaders that the backend got.
|
|
310
362
|
*/
|
|
311
363
|
moreShaders;
|
|
312
|
-
/**
|
|
364
|
+
/**
|
|
365
|
+
* Hears each program of the scene's objects that the driver refused to link twice, by its
|
|
366
|
+
* pipeline's name and the link's logs. Its draws draw nothing from then on, and the frames go
|
|
367
|
+
* on without them.
|
|
368
|
+
*/
|
|
369
|
+
refused;
|
|
370
|
+
/**
|
|
371
|
+
* True while the current pipeline's program is compiling, or after the driver refused it: draws
|
|
372
|
+
* draw nothing until it is set again.
|
|
373
|
+
*/
|
|
313
374
|
skipDraws = false;
|
|
314
375
|
anisotropic;
|
|
315
376
|
maxAnisotropy;
|
|
@@ -533,11 +594,40 @@ export class WebGL2Backend {
|
|
|
533
594
|
this.replayWord = -1;
|
|
534
595
|
let i = start;
|
|
535
596
|
while (i < end && (words[i] & 0xff) === G.OP_CREATE_RENDER_PIPELINE) {
|
|
597
|
+
this.listing.add(G.OP_CREATE_RENDER_PIPELINE, words, i + 1);
|
|
536
598
|
this.createPipeline(words, i + 1, true);
|
|
537
599
|
i += words[i] >>> 8;
|
|
538
600
|
}
|
|
601
|
+
if (this.listing.active && this.parallel)
|
|
602
|
+
this.compileAhead(words, i, end);
|
|
539
603
|
return i;
|
|
540
604
|
}
|
|
605
|
+
/**
|
|
606
|
+
* Starts to compile, in the background, the program of each pipeline that the list in
|
|
607
|
+
* `words[start, end)` creates after other commands. The frame before the first one then waits
|
|
608
|
+
* for them, as for the programs of the pipelines at the list's front, instead of its first draw
|
|
609
|
+
* with each waiting for its compile.
|
|
610
|
+
*/
|
|
611
|
+
compileAhead(words, start, end) {
|
|
612
|
+
for (let i = start; i < end;) {
|
|
613
|
+
const header = words[i];
|
|
614
|
+
const length = header >>> 8;
|
|
615
|
+
if (length === 0)
|
|
616
|
+
return;
|
|
617
|
+
if ((header & 0xff) === G.OP_CREATE_RENDER_PIPELINE) {
|
|
618
|
+
const template = words[i + 2];
|
|
619
|
+
const permutation = words[i + 3];
|
|
620
|
+
try {
|
|
621
|
+
if (!this.joins.joined(template) && this.templateReady(template, permutation))
|
|
622
|
+
this.programOf(template, permutation, true);
|
|
623
|
+
}
|
|
624
|
+
catch {
|
|
625
|
+
// The pipeline's own command meets the error.
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
i += length;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
541
631
|
/**
|
|
542
632
|
* Where the draw section of the list in `words[start, end)` begins, after the pipelines it
|
|
543
633
|
* creates. It walks the same ops as `prepare` and starts no build.
|
|
@@ -678,6 +768,42 @@ export class WebGL2Backend {
|
|
|
678
768
|
});
|
|
679
769
|
}
|
|
680
770
|
}
|
|
771
|
+
/**
|
|
772
|
+
* Starts to compile the programs of `list`, a pipeline list of the pipelines that the first frame
|
|
773
|
+
* of the sketch's last start built (`gpu/early-builds.ts`). Each compile starts once its shader
|
|
774
|
+
* is there, and a pipeline of the same template and permutation takes the program. No frame
|
|
775
|
+
* waits for a program that no pipeline takes. A joined shader's program compiles when its
|
|
776
|
+
* pipeline comes, as its failure sends the effects back to a pass each.
|
|
777
|
+
*/
|
|
778
|
+
buildEarly(list) {
|
|
779
|
+
this.early?.stop();
|
|
780
|
+
this.early = new EarlyBuilds(list, (op, operands) => {
|
|
781
|
+
const template = operands[1];
|
|
782
|
+
const permutation = operands[2];
|
|
783
|
+
if (op !== G.OP_CREATE_RENDER_PIPELINE || this.joins.joined(template))
|
|
784
|
+
return null;
|
|
785
|
+
if (!this.templateReady(template, permutation))
|
|
786
|
+
return undefined;
|
|
787
|
+
const key = `${template} ${permutation}`;
|
|
788
|
+
if (this.programs.has(key))
|
|
789
|
+
return null;
|
|
790
|
+
const glsl = this.need(this.templates, template, 'render pipeline template');
|
|
791
|
+
const program = createProgram(this.gl, glsl, permutation);
|
|
792
|
+
program.early = true;
|
|
793
|
+
this.programs.set(key, program);
|
|
794
|
+
return null;
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
/**
|
|
798
|
+
* Ends the list of the pipelines that the frames before the first one created, and returns it,
|
|
799
|
+
* once: the first frame has drawn. The compiles of the last start's list that have not started
|
|
800
|
+
* stop.
|
|
801
|
+
*/
|
|
802
|
+
takeListing() {
|
|
803
|
+
this.early?.stop();
|
|
804
|
+
this.early = undefined;
|
|
805
|
+
return this.listing.take();
|
|
806
|
+
}
|
|
681
807
|
/** Creates each parked pipeline whose custom material's shader has arrived. */
|
|
682
808
|
unpark() {
|
|
683
809
|
for (const [id, operands] of this.parked) {
|
|
@@ -752,7 +878,9 @@ export class WebGL2Backend {
|
|
|
752
878
|
}
|
|
753
879
|
/**
|
|
754
880
|
* Replays the draw list in `words[start, end)`. `floats` views the same memory as `words`, for
|
|
755
|
-
* float operands; `memory` is the engine memory that uploads read from.
|
|
881
|
+
* float operands; `memory` is the engine memory that uploads read from. A target that a live
|
|
882
|
+
* context refuses ends the replay without an error, and the next frame asks again before the
|
|
883
|
+
* refusal is reported: a lost context can answer the check that way before its flag is set.
|
|
756
884
|
*/
|
|
757
885
|
replay(words, floats, start, end, memory) {
|
|
758
886
|
if (memory !== this.memory) {
|
|
@@ -769,6 +897,36 @@ export class WebGL2Backend {
|
|
|
769
897
|
this.floats = floats;
|
|
770
898
|
this.unpackSlot = (this.unpackSlot + 1) % UNPACK_RING;
|
|
771
899
|
this.unpackUsed = 0;
|
|
900
|
+
try {
|
|
901
|
+
this.replayOps(words, floats, start, end);
|
|
902
|
+
}
|
|
903
|
+
catch (error) {
|
|
904
|
+
if (!(error instanceof WebGL2TargetRefused))
|
|
905
|
+
throw error;
|
|
906
|
+
// A live context refused a target. The driver can answer a lost context's check this
|
|
907
|
+
// way before the loss flag is set, so this frame draws nothing and the next frame asks
|
|
908
|
+
// again. A cadence can put two targets in the way on alternating frames, so the retry
|
|
909
|
+
// counts frames, not names.
|
|
910
|
+
if (this.refusedFrames > 0) {
|
|
911
|
+
const before = this.refusedTarget;
|
|
912
|
+
throw new WebGL2TargetRefused(before === error.message
|
|
913
|
+
? error.message
|
|
914
|
+
: `${error.message}; the frame before refused ${before}`);
|
|
915
|
+
}
|
|
916
|
+
this.refusedFrames = 1;
|
|
917
|
+
this.refusedTarget = error.message;
|
|
918
|
+
// The frame's finished reads still go, as at the end of every replay: a read that waits
|
|
919
|
+
// for a frame which never draws again would hold its page waiting.
|
|
920
|
+
this.flushReads();
|
|
921
|
+
return;
|
|
922
|
+
}
|
|
923
|
+
this.refusedFrames = 0;
|
|
924
|
+
this.refusedTarget = '';
|
|
925
|
+
this.flushReads();
|
|
926
|
+
this.replayed = true;
|
|
927
|
+
}
|
|
928
|
+
/** Replays a draw list's commands, as `replay` describes them. */
|
|
929
|
+
replayOps(words, floats, start, end) {
|
|
772
930
|
const gl = this.gl;
|
|
773
931
|
for (let i = start; i < end;) {
|
|
774
932
|
const header = words[i];
|
|
@@ -874,6 +1032,7 @@ export class WebGL2Backend {
|
|
|
874
1032
|
}
|
|
875
1033
|
case G.OP_CREATE_RENDER_PIPELINE:
|
|
876
1034
|
// A list that creates a pipeline after other commands waits for it at its first draw.
|
|
1035
|
+
this.listing.add(op, words, a);
|
|
877
1036
|
this.createPipeline(words, a, false);
|
|
878
1037
|
break;
|
|
879
1038
|
case G.OP_CREATE_BIND_GROUP: {
|
|
@@ -964,8 +1123,6 @@ export class WebGL2Backend {
|
|
|
964
1123
|
}
|
|
965
1124
|
i += length;
|
|
966
1125
|
}
|
|
967
|
-
this.flushReads();
|
|
968
|
-
this.replayed = true;
|
|
969
1126
|
}
|
|
970
1127
|
/**
|
|
971
1128
|
* The program that draws mip levels, or the one that copies a layer, which starts compiling the
|
|
@@ -1007,6 +1164,37 @@ export class WebGL2Backend {
|
|
|
1007
1164
|
this.useProgram(program);
|
|
1008
1165
|
return program;
|
|
1009
1166
|
}
|
|
1167
|
+
/**
|
|
1168
|
+
* Puts a program of the scene's objects in use, as `useProgram` does, and returns true. A link
|
|
1169
|
+
* that the driver refused links once more, from new shaders: a driver can run short of memory
|
|
1170
|
+
* while it links. A second refusal marks the program, so its draws draw nothing from then on,
|
|
1171
|
+
* reports it, and returns false. Any other failure, such as a material with more textures than
|
|
1172
|
+
* the stages hold, still stops the replay, and so does a link on a lost context, which the
|
|
1173
|
+
* renderer recovers from as a loss.
|
|
1174
|
+
*/
|
|
1175
|
+
useObjectsProgram(program) {
|
|
1176
|
+
const objects = program.objects;
|
|
1177
|
+
try {
|
|
1178
|
+
this.useProgram(program);
|
|
1179
|
+
return true;
|
|
1180
|
+
}
|
|
1181
|
+
catch (error) {
|
|
1182
|
+
if (!linkRefused(this.gl, error))
|
|
1183
|
+
throw error;
|
|
1184
|
+
}
|
|
1185
|
+
relink(this.gl, program);
|
|
1186
|
+
try {
|
|
1187
|
+
this.useProgram(program);
|
|
1188
|
+
return true;
|
|
1189
|
+
}
|
|
1190
|
+
catch (error) {
|
|
1191
|
+
if (!linkRefused(this.gl, error))
|
|
1192
|
+
throw error;
|
|
1193
|
+
objects.refused = true;
|
|
1194
|
+
this.refused?.(pipelineName(objects.template, objects.permutation), error.message);
|
|
1195
|
+
return false;
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1010
1198
|
/** Puts a program in use, first checking its link and binding its slots at its first use. */
|
|
1011
1199
|
useProgram(program) {
|
|
1012
1200
|
if (!program.ready) {
|
|
@@ -1058,6 +1246,8 @@ export class WebGL2Backend {
|
|
|
1058
1246
|
: undefined;
|
|
1059
1247
|
if (joined)
|
|
1060
1248
|
program.joined = joined;
|
|
1249
|
+
if (glsl.meshPrepass)
|
|
1250
|
+
program.objects = { template, permutation, refused: false };
|
|
1061
1251
|
if ((background || joined) && this.parallel) {
|
|
1062
1252
|
program.background = true;
|
|
1063
1253
|
this.compiling.push(program);
|
|
@@ -1069,6 +1259,14 @@ export class WebGL2Backend {
|
|
|
1069
1259
|
this.joins.keptApart(template);
|
|
1070
1260
|
}
|
|
1071
1261
|
}
|
|
1262
|
+
else if (program.early) {
|
|
1263
|
+
// A program that compiled ahead of its pipeline: the frames wait for it from now on.
|
|
1264
|
+
program.early = undefined;
|
|
1265
|
+
if (background && this.parallel) {
|
|
1266
|
+
program.background = true;
|
|
1267
|
+
this.compiling.push(program);
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1072
1270
|
return program;
|
|
1073
1271
|
}
|
|
1074
1272
|
/**
|
|
@@ -2033,8 +2231,17 @@ export class WebGL2Backend {
|
|
|
2033
2231
|
gl.drawBuffers(TWO_DRAW_BUFFERS);
|
|
2034
2232
|
}
|
|
2035
2233
|
const status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
|
|
2036
|
-
if (status !== gl.FRAMEBUFFER_COMPLETE)
|
|
2037
|
-
|
|
2234
|
+
if (status !== gl.FRAMEBUFFER_COMPLETE) {
|
|
2235
|
+
gl.deleteFramebuffer(framebuffer);
|
|
2236
|
+
const target = describeFramebuffer(first, depth, second);
|
|
2237
|
+
const text = `${target} (status 0x${status.toString(16)})`;
|
|
2238
|
+
// A driver can answer a lost context's check with this status before the loss flag is
|
|
2239
|
+
// set. The renderer drops a frame error while the context is lost, and its recovery
|
|
2240
|
+
// then starts.
|
|
2241
|
+
if (gl.isContextLost())
|
|
2242
|
+
throw new Error(`WebGL2 lost its context inside a framebuffer check: ${text}`);
|
|
2243
|
+
throw new WebGL2TargetRefused(`WebGL2 cannot draw into ${text}`);
|
|
2244
|
+
}
|
|
2038
2245
|
return framebuffer;
|
|
2039
2246
|
}
|
|
2040
2247
|
/**
|
|
@@ -2316,7 +2523,10 @@ export class WebGL2Backend {
|
|
|
2316
2523
|
}
|
|
2317
2524
|
setPipeline(p) {
|
|
2318
2525
|
const program = p.program;
|
|
2319
|
-
this.skipDraws =
|
|
2526
|
+
this.skipDraws =
|
|
2527
|
+
program.joined?.failed === true ||
|
|
2528
|
+
program.objects?.refused === true ||
|
|
2529
|
+
!this.compiled(program);
|
|
2320
2530
|
if (this.skipDraws)
|
|
2321
2531
|
return;
|
|
2322
2532
|
if (program.joined) {
|
|
@@ -2329,6 +2539,12 @@ export class WebGL2Backend {
|
|
|
2329
2539
|
return;
|
|
2330
2540
|
}
|
|
2331
2541
|
}
|
|
2542
|
+
else if (program.objects) {
|
|
2543
|
+
if (!this.useObjectsProgram(program)) {
|
|
2544
|
+
this.skipDraws = true;
|
|
2545
|
+
return;
|
|
2546
|
+
}
|
|
2547
|
+
}
|
|
2332
2548
|
else
|
|
2333
2549
|
this.useProgram(program);
|
|
2334
2550
|
if (this.current?.program !== program && program.textureUnits.length > 0)
|
|
@@ -2701,6 +2917,8 @@ export class WebGL2Backend {
|
|
|
2701
2917
|
this.counts.drawCalls += count;
|
|
2702
2918
|
}
|
|
2703
2919
|
destroy() {
|
|
2920
|
+
this.early?.stop();
|
|
2921
|
+
this.early = undefined;
|
|
2704
2922
|
const gl = this.gl;
|
|
2705
2923
|
for (let id = 0; id < this.buffers.length; id++)
|
|
2706
2924
|
this.destroyBuffer(id);
|
|
@@ -94,6 +94,21 @@ export interface Program {
|
|
|
94
94
|
readonly start: number;
|
|
95
95
|
failed: boolean;
|
|
96
96
|
};
|
|
97
|
+
/**
|
|
98
|
+
* True for a program that a start compiles ahead of its pipeline, from the list of the last
|
|
99
|
+
* start's first frame: no frame waits for it until a pipeline takes it.
|
|
100
|
+
*/
|
|
101
|
+
early?: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* For a program of a template that draws the scene's meshes: its template and permutation, which
|
|
104
|
+
* name it, and whether the driver refused to link it twice, which leaves its draws drawing
|
|
105
|
+
* nothing while the frames go on.
|
|
106
|
+
*/
|
|
107
|
+
objects?: {
|
|
108
|
+
readonly template: number;
|
|
109
|
+
readonly permutation: number;
|
|
110
|
+
refused: boolean;
|
|
111
|
+
};
|
|
97
112
|
}
|
|
98
113
|
/** A render pipeline: its program, and the fixed-function state and vertex format it asks for. */
|
|
99
114
|
export interface Pipeline {
|
|
@@ -178,6 +193,9 @@ export declare function relink(gl: WebGL2RenderingContext, p: Program): void;
|
|
|
178
193
|
* names each error with its line. Call it before the shaders are deleted.
|
|
179
194
|
*/
|
|
180
195
|
export declare function linkLogs(gl: WebGL2RenderingContext, p: Program): string;
|
|
196
|
+
/** A program whose link the driver refused, with the logs of its program and shaders. */
|
|
197
|
+
export declare class LinkFailure extends Error {
|
|
198
|
+
}
|
|
181
199
|
/**
|
|
182
200
|
* The texture units that the stages of a program read, as triples of the unit, the slot where bind
|
|
183
201
|
* groups leave the unit's texture and the slot of the sampler it reads with, or `NO_SAMPLER`. Units
|
|
@@ -289,7 +289,7 @@ export function createProgram(gl, template, permutation) {
|
|
|
289
289
|
const shading = variantFor(template.shader, build, 'glsl')?.glsl?.[template.pipeline];
|
|
290
290
|
const source = shading && build !== permutation ? { ...shading, fragment: PREPASS_FRAGMENT } : shading;
|
|
291
291
|
if (!source)
|
|
292
|
-
throw new Error(`a render pipeline template: ${missingVariant(
|
|
292
|
+
throw new Error(`a render pipeline template: ${missingVariant(build)}`);
|
|
293
293
|
const { program, shaders } = link(gl, source, '');
|
|
294
294
|
return {
|
|
295
295
|
program,
|
|
@@ -364,9 +364,12 @@ export function linkLogs(gl, p) {
|
|
|
364
364
|
.filter((log) => log)
|
|
365
365
|
.join('\n');
|
|
366
366
|
}
|
|
367
|
+
/** A program whose link the driver refused, with the logs of its program and shaders. */
|
|
368
|
+
export class LinkFailure extends Error {
|
|
369
|
+
}
|
|
367
370
|
/** The error of a program whose link failed, with the logs of its program and shaders. */
|
|
368
371
|
function linkError(gl, p, attempt) {
|
|
369
|
-
return new
|
|
372
|
+
return new LinkFailure(`a WebGL2 program failed to link${attempt}: ${linkLogs(gl, p)}`);
|
|
370
373
|
}
|
|
371
374
|
/**
|
|
372
375
|
* The texture units that the stages of a program read, as triples of the unit, the slot where bind
|