xbintsc 0.7.0 → 0.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/ast/common.d.ts +10 -0
- package/dist/src/checker/source.js +4 -0
- package/dist/src/checker/source.js.map +1 -1
- package/dist/src/cli/help.d.ts +1 -1
- package/dist/src/cli/main.js +15 -3
- package/dist/src/cli/main.js.map +1 -1
- package/dist/src/codegen/generator/calls/access.js +4 -11
- package/dist/src/codegen/generator/calls/access.js.map +1 -1
- package/dist/src/codegen/generator/calls/element-inline.d.ts +42 -0
- package/dist/src/codegen/generator/calls/element-inline.js +388 -0
- package/dist/src/codegen/generator/calls/element-inline.js.map +1 -0
- package/dist/src/codegen/generator/calls/invocation.js +82 -1
- package/dist/src/codegen/generator/calls/invocation.js.map +1 -1
- package/dist/src/codegen/generator/calls.d.ts +3 -1
- package/dist/src/codegen/generator/calls.js +3 -1
- package/dist/src/codegen/generator/calls.js.map +1 -1
- package/dist/src/codegen/generator/debug.js +20 -3
- package/dist/src/codegen/generator/debug.js.map +1 -1
- package/dist/src/codegen/generator/expressions/assignment.js +10 -2
- package/dist/src/codegen/generator/expressions/assignment.js.map +1 -1
- package/dist/src/codegen/generator/expressions/global-values.d.ts +19 -0
- package/dist/src/codegen/generator/expressions/global-values.js +49 -0
- package/dist/src/codegen/generator/expressions/global-values.js.map +1 -0
- package/dist/src/codegen/generator/expressions/primary.d.ts +0 -2
- package/dist/src/codegen/generator/expressions/primary.js +4 -24
- package/dist/src/codegen/generator/expressions/primary.js.map +1 -1
- package/dist/src/codegen/generator/expressions.d.ts +2 -1
- package/dist/src/codegen/generator/expressions.js +2 -1
- package/dist/src/codegen/generator/expressions.js.map +1 -1
- package/dist/src/codegen/generator/layout.d.ts +65 -0
- package/dist/src/codegen/generator/layout.js +50 -0
- package/dist/src/codegen/generator/layout.js.map +1 -0
- package/dist/src/codegen/generator/state.js +4 -0
- package/dist/src/codegen/generator/state.js.map +1 -1
- package/dist/src/diagnostics/diagnostic.js +1 -1
- package/dist/src/diagnostics/diagnostic.js.map +1 -1
- package/dist/src/diagnostics/source-text.d.ts +37 -9
- package/dist/src/diagnostics/source-text.js +124 -23
- package/dist/src/diagnostics/source-text.js.map +1 -1
- package/dist/src/diagnostics/source.d.ts +16 -6
- package/dist/src/diagnostics/source.js +25 -4
- package/dist/src/diagnostics/source.js.map +1 -1
- package/dist/src/driver/build-key.d.ts +14 -0
- package/dist/src/driver/build-key.js +6 -1
- package/dist/src/driver/build-key.js.map +1 -1
- package/dist/src/driver/bundler/concatenate.js +11 -4
- package/dist/src/driver/bundler/concatenate.js.map +1 -1
- package/dist/src/driver/bundler/graph.js +2 -2
- package/dist/src/driver/bundler/graph.js.map +1 -1
- package/dist/src/driver/bundler/merge.js +11 -5
- package/dist/src/driver/bundler/merge.js.map +1 -1
- package/dist/src/driver/bundler/reexport-resolution.js +3 -0
- package/dist/src/driver/bundler/reexport-resolution.js.map +1 -1
- package/dist/src/driver/compiler.js +13 -3
- package/dist/src/driver/compiler.js.map +1 -1
- package/dist/src/driver/frontend.js +3 -4
- package/dist/src/driver/frontend.js.map +1 -1
- package/dist/src/driver/runtime-objects.d.ts +1 -1
- package/dist/src/driver/runtime-objects.js +4 -0
- package/dist/src/driver/runtime-objects.js.map +1 -1
- package/dist/src/driver/toolchain.js +28 -5
- package/dist/src/driver/toolchain.js.map +1 -1
- package/dist/src/driver/version.d.ts +1 -1
- package/dist/src/driver/version.js +1 -1
- package/dist/src/extensions/gui/html.js +42 -10
- package/dist/src/extensions/gui/html.js.map +1 -1
- package/dist/src/extensions/gui/index.js +48 -0
- package/dist/src/extensions/gui/index.js.map +1 -1
- package/dist/src/extensions/registry.d.ts +20 -0
- package/dist/src/extensions/registry.js.map +1 -1
- package/dist/src/parser/expressions.js +2 -2
- package/dist/src/parser/expressions.js.map +1 -1
- package/dist/src/parser/helpers.d.ts +8 -0
- package/dist/src/parser/helpers.js +21 -0
- package/dist/src/parser/helpers.js.map +1 -1
- package/dist/tests/cli/main.test.js +9 -0
- package/dist/tests/cli/main.test.js.map +1 -1
- package/dist/tests/codegen/element-layout.test.d.ts +19 -0
- package/dist/tests/codegen/element-layout.test.js +80 -0
- package/dist/tests/codegen/element-layout.test.js.map +1 -0
- package/dist/tests/codegen/expressions.test.js +25 -0
- package/dist/tests/codegen/expressions.test.js.map +1 -1
- package/dist/tests/codegen/llvm.test.js +13 -0
- package/dist/tests/codegen/llvm.test.js.map +1 -1
- package/dist/tests/diagnostics/diagnostic.test.js +9 -0
- package/dist/tests/diagnostics/diagnostic.test.js.map +1 -1
- package/dist/tests/diagnostics/source-text.test.d.ts +1 -0
- package/dist/tests/diagnostics/source-text.test.js +50 -0
- package/dist/tests/diagnostics/source-text.test.js.map +1 -0
- package/dist/tests/diagnostics/source.test.js +17 -0
- package/dist/tests/diagnostics/source.test.js.map +1 -1
- package/dist/tests/driver/build-key.test.d.ts +1 -0
- package/dist/tests/driver/build-key.test.js +49 -0
- package/dist/tests/driver/build-key.test.js.map +1 -0
- package/dist/tests/driver/toolchain.test.js +8 -1
- package/dist/tests/driver/toolchain.test.js.map +1 -1
- package/dist/tests/driver/usage.test.js +2 -1
- package/dist/tests/driver/usage.test.js.map +1 -1
- package/dist/tests/e2e/async-await.test.js +16 -0
- package/dist/tests/e2e/async-await.test.js.map +1 -1
- package/dist/tests/e2e/compile-builtins.test.js +29 -0
- package/dist/tests/e2e/compile-builtins.test.js.map +1 -1
- package/dist/tests/e2e/compile-modules.test.js +13 -0
- package/dist/tests/e2e/compile-modules.test.js.map +1 -1
- package/dist/tests/e2e/compile-objects-classes.test.js.map +1 -1
- package/dist/tests/e2e/compile-prototype-chain.test.d.ts +8 -0
- package/dist/tests/e2e/compile-prototype-chain.test.js +24 -0
- package/dist/tests/e2e/compile-prototype-chain.test.js.map +1 -0
- package/dist/tests/e2e/differential-language.test.js +25 -0
- package/dist/tests/e2e/differential-language.test.js.map +1 -1
- package/dist/tests/e2e/differential-values.test.js +59 -0
- package/dist/tests/e2e/differential-values.test.js.map +1 -1
- package/dist/tests/e2e/gc.test.js +22 -0
- package/dist/tests/e2e/gc.test.js.map +1 -1
- package/dist/tests/e2e/gui-audio-extra.test.d.ts +12 -0
- package/dist/tests/e2e/gui-audio-extra.test.js +185 -0
- package/dist/tests/e2e/gui-audio-extra.test.js.map +1 -0
- package/dist/tests/e2e/gui-browser.test.js +35 -2
- package/dist/tests/e2e/gui-browser.test.js.map +1 -1
- package/dist/tests/e2e/gui-dom.test.js +88 -0
- package/dist/tests/e2e/gui-dom.test.js.map +1 -1
- package/dist/tests/e2e/gui-webgl-declarations.test.d.ts +13 -0
- package/dist/tests/e2e/gui-webgl-declarations.test.js +136 -0
- package/dist/tests/e2e/gui-webgl-declarations.test.js.map +1 -0
- package/dist/tests/e2e/gui-webgl-texture-units.test.d.ts +12 -0
- package/dist/tests/e2e/gui-webgl-texture-units.test.js +86 -0
- package/dist/tests/e2e/gui-webgl-texture-units.test.js.map +1 -0
- package/dist/tests/e2e/gui-webgl2-blit.test.js +6 -2
- package/dist/tests/e2e/gui-webgl2-blit.test.js.map +1 -1
- package/dist/tests/e2e/gui-webgl2-msaa-float.test.d.ts +12 -0
- package/dist/tests/e2e/gui-webgl2-msaa-float.test.js +157 -0
- package/dist/tests/e2e/gui-webgl2-msaa-float.test.js.map +1 -0
- package/dist/tests/e2e/gui-webgl2-msaa.test.d.ts +10 -0
- package/dist/tests/e2e/gui-webgl2-msaa.test.js +344 -0
- package/dist/tests/e2e/gui-webgl2-msaa.test.js.map +1 -0
- package/dist/tests/e2e/gui-webgl2-target-orientation.test.d.ts +15 -0
- package/dist/tests/e2e/gui-webgl2-target-orientation.test.js +287 -0
- package/dist/tests/e2e/gui-webgl2-target-orientation.test.js.map +1 -0
- package/dist/tests/e2e/gui-webgl2.test.js +59 -1
- package/dist/tests/e2e/gui-webgl2.test.js.map +1 -1
- package/dist/tests/e2e/hang-watchdog.test.d.ts +10 -0
- package/dist/tests/e2e/hang-watchdog.test.js +50 -0
- package/dist/tests/e2e/hang-watchdog.test.js.map +1 -0
- package/dist/tests/e2e/method-call-cache.test.d.ts +5 -0
- package/dist/tests/e2e/method-call-cache.test.js +65 -0
- package/dist/tests/e2e/method-call-cache.test.js.map +1 -0
- package/dist/tests/e2e/performance-now.test.d.ts +9 -0
- package/dist/tests/e2e/performance-now.test.js +36 -0
- package/dist/tests/e2e/performance-now.test.js.map +1 -0
- package/dist/tests/e2e/property-ic.test.js +33 -0
- package/dist/tests/e2e/property-ic.test.js.map +1 -1
- package/dist/tests/e2e/shape-interning.test.d.ts +16 -0
- package/dist/tests/e2e/shape-interning.test.js +55 -0
- package/dist/tests/e2e/shape-interning.test.js.map +1 -0
- package/dist/tests/e2e/string-utf16.test.js +9 -0
- package/dist/tests/e2e/string-utf16.test.js.map +1 -1
- package/dist/tests/e2e/typed-array-views.test.js +26 -0
- package/dist/tests/e2e/typed-array-views.test.js.map +1 -1
- package/dist/tests/e2e/url-search-params.test.js +19 -0
- package/dist/tests/e2e/url-search-params.test.js.map +1 -1
- package/dist/tests/extensions/gui.test.js +16 -1
- package/dist/tests/extensions/gui.test.js.map +1 -1
- package/dist/tests/helpers.js +1 -0
- package/dist/tests/helpers.js.map +1 -1
- package/dist/tests/parser/expressions.test.js +36 -0
- package/dist/tests/parser/expressions.test.js.map +1 -1
- package/doc/ai/contributing.md +8 -5
- package/doc/ai/extensions.md +12 -3
- package/doc/ai/language-support.md +2 -1
- package/doc/ai/troubleshooting.md +14 -0
- package/doc/ai/zh-CN/contributing.md +6 -3
- package/doc/ai/zh-CN/extensions.md +10 -2
- package/doc/ai/zh-CN/language-support.md +2 -1
- package/doc/ai/zh-CN/troubleshooting.md +12 -0
- package/doc/gui/api.md +26 -4
- package/doc/gui/dom.md +8 -0
- package/doc/gui/known-issues.md +35 -6
- package/doc/gui/runtime.md +16 -1
- package/doc/gui/webgl.md +97 -26
- package/doc/gui-scripts.md +2 -1
- package/doc/gui.md +8 -5
- package/doc/implemented/checker.md +9 -0
- package/doc/implemented/codegen.md +7 -0
- package/doc/implemented/parser.md +2 -1
- package/doc/implemented/runtime-core.md +9 -2
- package/doc/implemented/stdlib.md +10 -2
- package/doc/implemented/typed-arrays.md +18 -2
- package/doc/zh-CN/gui/api.md +19 -5
- package/doc/zh-CN/gui/dom.md +6 -0
- package/doc/zh-CN/gui/known-issues.md +24 -5
- package/doc/zh-CN/gui/runtime.md +13 -1
- package/doc/zh-CN/gui/webgl.md +20 -7
- package/doc/zh-CN/gui-scripts.md +2 -1
- package/doc/zh-CN/gui.md +4 -1
- package/doc/zh-CN/implemented/checker.md +7 -0
- package/doc/zh-CN/implemented/codegen.md +7 -0
- package/doc/zh-CN/implemented/parser.md +2 -1
- package/doc/zh-CN/implemented/runtime-core.md +9 -2
- package/doc/zh-CN/implemented/stdlib.md +6 -2
- package/doc/zh-CN/implemented/typed-arrays.md +14 -2
- package/package.json +7 -7
- package/runtime/ext_gui/audio.cpp +39 -3
- package/runtime/ext_gui/audio_extra.cpp +353 -0
- package/runtime/ext_gui/audio_extra.h +47 -0
- package/runtime/ext_gui/audio_fft.h +76 -0
- package/runtime/ext_gui/audio_internal.h +21 -0
- package/runtime/ext_gui/audio_mixer.cpp +46 -1
- package/runtime/ext_gui/audio_mixer.h +89 -1
- package/runtime/ext_gui/audio_mixer_extra.cpp +126 -0
- package/runtime/ext_gui/audio_nodes.cpp +242 -0
- package/runtime/ext_gui/audio_nodes_internal.h +81 -0
- package/runtime/ext_gui/audio_nodes_spatial.cpp +375 -0
- package/runtime/ext_gui/browser.cpp +9 -0
- package/runtime/ext_gui/browser_screen.cpp +73 -0
- package/runtime/ext_gui/dom_api_canvas.cpp +9 -1
- package/runtime/ext_gui/dom_api_internal.h +3 -0
- package/runtime/ext_gui/dom_api_node.cpp +21 -0
- package/runtime/ext_gui/dom_api_node_read.cpp +29 -0
- package/runtime/ext_gui/dom_api_proto.cpp +3 -0
- package/runtime/ext_gui/dom_api_webgl2.cpp +16 -11
- package/runtime/ext_gui/dom_api_webgl2_msaa.cpp +64 -0
- package/runtime/ext_gui/dom_api_webgl_compressed.cpp +2 -2
- package/runtime/ext_gui/dom_api_webgl_framebuffer.cpp +68 -11
- package/runtime/ext_gui/dom_api_webgl_methods.h +3 -0
- package/runtime/ext_gui/dom_api_webgl_state.cpp +4 -2
- package/runtime/ext_gui/dom_api_webgl_texture.cpp +6 -6
- package/runtime/ext_gui/gui.cpp +6 -1
- package/runtime/ext_gui/gui_engine.h +2 -0
- package/runtime/ext_gui/gui_events.cpp +13 -8
- package/runtime/ext_gui/gui_webgl.cpp +3 -2
- package/runtime/ext_gui/style_ua.cpp +4 -0
- package/runtime/ext_gui/warnings.cpp +1 -1
- package/runtime/ext_gui/webgl.h +102 -7
- package/runtime/ext_gui/webgl_api.h +3 -2
- package/runtime/ext_gui/webgl_blit.cpp +109 -15
- package/runtime/ext_gui/webgl_blit_color.cpp +264 -0
- package/runtime/ext_gui/webgl_blit_depth.cpp +26 -8
- package/runtime/ext_gui/webgl_buffer.cpp +20 -170
- package/runtime/ext_gui/webgl_context.cpp +117 -169
- package/runtime/ext_gui/webgl_draw.cpp +116 -5
- package/runtime/ext_gui/webgl_draw_buffers.cpp +21 -6
- package/runtime/ext_gui/webgl_draw_setup.cpp +1 -0
- package/runtime/ext_gui/webgl_draw_state.h +2 -0
- package/runtime/ext_gui/webgl_feature.cpp +2 -2
- package/runtime/ext_gui/webgl_feature.h +4 -3
- package/runtime/ext_gui/webgl_framebuffer.cpp +346 -0
- package/runtime/ext_gui/webgl_glsl_rewrite.cpp +78 -47
- package/runtime/ext_gui/webgl_objects.h +16 -2
- package/runtime/ext_gui/webgl_pipeline.cpp +1 -1
- package/runtime/ext_gui/webgl_state.cpp +45 -36
- package/runtime/ext_gui/webgl_targets.cpp +440 -0
- package/runtime/ext_gui/webgl_texture.cpp +81 -25
- package/runtime/ext_gui/window.cpp +8 -0
- package/runtime/rt.h +27 -27
- package/runtime/rt_binary.h +44 -0
- package/runtime/rt_internal.h +52 -60
- package/runtime/rt_object.h +83 -0
- package/runtime/rt_profile.h +45 -0
- package/runtime/xt_alloc.c +88 -133
- package/runtime/xt_array_buffer.c +99 -71
- package/runtime/xt_builtins.c +3 -1
- package/runtime/xt_constructors.c +1 -0
- package/runtime/xt_containers/access.inc +96 -11
- package/runtime/xt_containers/arrays.inc +2 -1
- package/runtime/xt_containers/cstr_cache.inc +56 -0
- package/runtime/xt_containers/method_cache.inc +121 -0
- package/runtime/xt_containers/object_keys.inc +58 -0
- package/runtime/xt_containers/objects.inc +47 -79
- package/runtime/xt_containers/shapes.inc +153 -8
- package/runtime/xt_containers.c +4 -0
- package/runtime/xt_gc_release.c +70 -0
- package/runtime/xt_gc_stack.c +83 -0
- package/runtime/xt_gc_verify.c +1 -0
- package/runtime/xt_io/console.inc +66 -0
- package/runtime/xt_io/exception.inc +32 -6
- package/runtime/xt_io/watchdog.inc +101 -0
- package/runtime/xt_io.c +1 -0
- package/runtime/xt_loop.c +23 -3
- package/runtime/xt_pool.c +151 -0
- package/runtime/xt_profile.c +126 -0
- package/runtime/xt_stdlib/dispatch.inc +7 -1
- package/runtime/xt_stdlib/math.inc +272 -57
- package/runtime/xt_stdlib2/json_stringify.inc +1 -2
- package/runtime/xt_stdlib2/regexp-match.inc +17 -0
- package/runtime/xt_storage/indexed_db.c +4 -1
- package/runtime/xt_structured_clone.c +2 -1
- package/runtime/xt_typed_array/construction.inc +10 -0
- package/runtime/xt_typed_array/elements.inc +43 -23
- package/runtime/xt_url.c +50 -0
- package/runtime/xt_values/constructors.inc +4 -1
- package/runtime/xt_values/strings.inc +3 -1
- package/src/ast/common.ts +10 -0
- package/src/checker/source.ts +3 -0
- package/src/cli/main.ts +14 -3
- package/src/codegen/generator/calls/access.ts +5 -10
- package/src/codegen/generator/calls/element-inline.ts +433 -0
- package/src/codegen/generator/calls/invocation.ts +87 -1
- package/src/codegen/generator/calls.ts +5 -0
- package/src/codegen/generator/debug.ts +21 -3
- package/src/codegen/generator/expressions/assignment.ts +11 -2
- package/src/codegen/generator/expressions/global-values.ts +57 -0
- package/src/codegen/generator/expressions/primary.ts +4 -27
- package/src/codegen/generator/expressions.ts +3 -0
- package/src/codegen/generator/layout.ts +54 -0
- package/src/codegen/generator/state.ts +5 -0
- package/src/diagnostics/diagnostic.ts +1 -1
- package/src/diagnostics/source-text.ts +118 -22
- package/src/diagnostics/source.ts +29 -7
- package/src/driver/build-key.ts +21 -1
- package/src/driver/bundler/concatenate.ts +12 -5
- package/src/driver/bundler/graph.ts +2 -2
- package/src/driver/bundler/merge.ts +11 -4
- package/src/driver/bundler/reexport-resolution.ts +2 -0
- package/src/driver/compiler.ts +14 -3
- package/src/driver/frontend.ts +3 -4
- package/src/driver/runtime-objects.ts +4 -0
- package/src/driver/toolchain.ts +28 -5
- package/src/driver/version.ts +1 -1
- package/src/extensions/gui/html.ts +41 -11
- package/src/extensions/gui/index.ts +50 -1
- package/src/extensions/registry.ts +20 -0
- package/src/parser/expressions.ts +2 -2
- package/src/parser/helpers.ts +22 -0
package/doc/gui/webgl.md
CHANGED
|
@@ -34,7 +34,9 @@ reports the type as well.
|
|
|
34
34
|
- Each context owns one offscreen `R8G8B8A8_UNORM` colour texture (the drawing
|
|
35
35
|
buffer) and a `D32_FLOAT` depth texture, sized from the canvas's `width` /
|
|
36
36
|
`height` attributes. `canvas.width = …` recreates them and discards the
|
|
37
|
-
contents, like the DOM rule.
|
|
37
|
+
contents, like the DOM rule. With MSAA the draws go into a 4× colour texture
|
|
38
|
+
and every render pass resolves it into the colour texture the page composites
|
|
39
|
+
(see [Multisample antialiasing](#multisample-antialiasing-msaa)).
|
|
38
40
|
- The context records into its own SDL_GPU command buffer. `clear`/`draw*`
|
|
39
41
|
keep a render pass open; only a buffer/texture upload or a framebuffer
|
|
40
42
|
change ends it and starts a new pass with `LOAD`, so the drawing buffer
|
|
@@ -44,8 +46,20 @@ reports the type as well.
|
|
|
44
46
|
WebGL command buffer. The image pipeline then samples the colour texture as
|
|
45
47
|
an ordinary `PaintImage`, with no CPU copy.
|
|
46
48
|
- WebGL's origin is bottom-left while SDL_GPU render targets are top-left, so
|
|
47
|
-
the framebuffer
|
|
48
|
-
|
|
49
|
+
the two framebuffer kinds are stored differently. The default drawing buffer
|
|
50
|
+
is **top-down**, the way the compositor presents it (texture row 0 is the
|
|
51
|
+
image's top): its `viewport`/`scissor` are converted, `readPixels` reverses
|
|
52
|
+
rows and a draw uses a positive-height, y-flipped viewport. A user framebuffer
|
|
53
|
+
is **bottom-up**, the way a texture is sampled (`v = 0` is its bottom row), so
|
|
54
|
+
`viewport`/`scissor`/`readPixels` map GL rows straight through and a draw
|
|
55
|
+
flips the viewport with a negative height. That flip also mirrors the winding
|
|
56
|
+
the rasteriser sees, so the GL front-face comparison is flipped for a
|
|
57
|
+
bottom-up target (and is part of the pipeline key, so the two orientations
|
|
58
|
+
keep distinct pipelines). A render target therefore samples back in WebGL's
|
|
59
|
+
orientation, and a depth texture (shadow map) matches the projection that
|
|
60
|
+
wrote it. `blitFramebuffer` between the two kinds cannot use
|
|
61
|
+
`SDL_BlitGPUTexture` (its copy cannot reverse rows), so it draws a sampling
|
|
62
|
+
pass instead; a blit between two targets of the same kind keeps the GPU blit.
|
|
49
63
|
- A fixed-function state change (`blendFunc`, `depthFunc`, `cullFace`,
|
|
50
64
|
`colorMask`, …) changes which `SDL_GPUGraphicsPipeline` is needed, so
|
|
51
65
|
pipelines are created lazily and cached on the program. The key is the
|
|
@@ -62,6 +76,51 @@ reports the type as well.
|
|
|
62
76
|
steady state: two draws with the same layout and different buffers create no
|
|
63
77
|
pipeline after the first frame.
|
|
64
78
|
|
|
79
|
+
## Multisample antialiasing (MSAA)
|
|
80
|
+
|
|
81
|
+
`getContext("webgl2")` — and `getContext("webgl")` — honour the `antialias`
|
|
82
|
+
context-creation attribute, which defaults to `true` like WebGL's. On a
|
|
83
|
+
supported backend the drawing buffer is **4× multisampled**:
|
|
84
|
+
|
|
85
|
+
- `getContextAttributes().antialias` reports `true`, `getParameter(SAMPLES)`
|
|
86
|
+
reports `4`, `SAMPLE_BUFFERS` reports `1` and `MAX_SAMPLES` reports `4` for the
|
|
87
|
+
default framebuffer. `getContext("webgl2", { antialias: false })` keeps the
|
|
88
|
+
single-sampled path (`SAMPLES`/`SAMPLE_BUFFERS` report `0`).
|
|
89
|
+
- Draws render into a multisampled colour texture with a matching 4× depth
|
|
90
|
+
texture. Every `end` of a render pass resolves the colour target into the
|
|
91
|
+
single-sampled texture the page composites, so the compositor, `readPixels` and
|
|
92
|
+
`blitFramebuffer` all see the resolved image without an extra call.
|
|
93
|
+
- A scissored `clear` draws a textured quad into the multisampled target
|
|
94
|
+
(`SDL_BlitGPUTexture` cannot target one); the quad's edges fall on pixel
|
|
95
|
+
boundaries, so every pixel inside the scissor rectangle gets full coverage.
|
|
96
|
+
- `renderbufferStorageMultisample(target, samples, internalformat, width,
|
|
97
|
+
height)` allocates a 4× colour or depth(-stencil) renderbuffer;
|
|
98
|
+
`texStorage2DMultisample`/`texImage2DMultisample` do the same for a texture.
|
|
99
|
+
Attaching one to a framebuffer makes it a render target, and
|
|
100
|
+
`checkFramebufferStatus` reports `FRAMEBUFFER_INCOMPLETE_MULTISAMPLE` when the
|
|
101
|
+
attached colour and depth buffers disagree on the sample count.
|
|
102
|
+
- `blitFramebuffer` resolves a multisampled source into a single-sampled
|
|
103
|
+
destination when the source and destination rectangles and colour formats are
|
|
104
|
+
identical and the filter is `NEAREST` — the ES 3.0 resolve rules. The resolve
|
|
105
|
+
of a half-float (or float) colour target is a **sampling pass**, not
|
|
106
|
+
`SDL_BlitGPUTexture`: SDL_GPU's blit is `vkCmdBlitImage`, and Vulkan does not
|
|
107
|
+
require 16F/32F images to support blit source/destination, so the invalid
|
|
108
|
+
command lost the Vulkan device on a three.js `samples > 0` render target.
|
|
109
|
+
A sampling pass copies every colour format (the full-rectangle resolve
|
|
110
|
+
three.js performs maps exactly). Blitting into a multisampled draw framebuffer
|
|
111
|
+
is `INVALID_OPERATION`, and `readPixels` from a multisampled user framebuffer
|
|
112
|
+
is `INVALID_OPERATION` too (resolve it first).
|
|
113
|
+
|
|
114
|
+
Both backends that can run WebGL enable MSAA: Vulkan (Windows/Linux) and Metal
|
|
115
|
+
(macOS) resolve the 4× drawing buffer, including scissored clears and instanced
|
|
116
|
+
draws. A device that cannot sample 4× RGBA8 and depth keeps the single-sampled
|
|
117
|
+
path: `antialias` reports `false`, `MAX_SAMPLES` is `0`, and
|
|
118
|
+
`renderbufferStorageMultisample` / `texStorage2DMultisample` degrade to
|
|
119
|
+
single-sampled storage (`RENDERBUFFER_SAMPLES` reports `0`) so a page that still
|
|
120
|
+
asks for MSAA keeps a working attachment. Depth and stencil attachments cannot
|
|
121
|
+
be resolved through SDL_GPU, so a multisampled depth blit is accepted and leaves
|
|
122
|
+
the destination depth untouched (stencil bits were already unsupported).
|
|
123
|
+
|
|
65
124
|
## Shaders: GLSL ES to SPIR-V (and on to MSL)
|
|
66
125
|
|
|
67
126
|
SDL_GPU cannot compile GLSL at run time, and each backend consumes its own
|
|
@@ -107,11 +166,13 @@ The translator (`runtime/ext_gui/webgl_glsl*.cpp`) handles GLSL ES 1.00 and
|
|
|
107
166
|
|
|
108
167
|
Non-sampler uniforms are merged across both stages and emitted as one block in
|
|
109
168
|
each stage (set 1 for the vertex shader, set 3 for the fragment shader), which
|
|
110
|
-
matches SDL_GPU's Vulkan descriptor layout.
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
169
|
+
matches SDL_GPU's Vulkan descriptor layout. A declaration that names several
|
|
170
|
+
variables (`uniform sampler2D a, b;`, `uniform vec3 tint, fill;`) is rewritten
|
|
171
|
+
one declarator at a time: each sampler gets its own binding, because a GLSL
|
|
172
|
+
declaration shares one `layout(...)` across all of its declarators, and each
|
|
173
|
+
non-sampler becomes its own block member. `uniformMatrix4fv` writes column-major
|
|
174
|
+
floats into the reflected offsets; `uniform1i` on a sampler stores the texture
|
|
175
|
+
unit. The block is pushed with the dynamic uniform-buffer API on every draw.
|
|
115
176
|
|
|
116
177
|
Limits of the translator: struct-typed uniforms, user uniform blocks, uniform
|
|
117
178
|
arrays whose size is not resolved by the preprocessor, and a sampler array
|
|
@@ -198,11 +259,12 @@ available from GLSL ES 3.00, which is what the instanced example uses.
|
|
|
198
259
|
(`FRAMEBUFFER`/`READ_FRAMEBUFFER`/`DRAW_FRAMEBUFFER`),
|
|
199
260
|
`framebufferTexture2D` (`COLOR_ATTACHMENT0`, `DEPTH_ATTACHMENT`,
|
|
200
261
|
`DEPTH_STENCIL_ATTACHMENT`), `checkFramebufferStatus`, `createRenderbuffer`,
|
|
201
|
-
`bindRenderbuffer`, `renderbufferStorage` (depth or depth-stencil),
|
|
202
|
-
`framebufferRenderbuffer`, `delete*`, and
|
|
203
|
-
SDL's blit
|
|
204
|
-
|
|
205
|
-
|
|
262
|
+
`bindRenderbuffer`, `renderbufferStorage` (colour, depth or depth-stencil),
|
|
263
|
+
`renderbufferStorageMultisample`, `framebufferRenderbuffer`, `delete*`, and
|
|
264
|
+
`blitFramebuffer` (colour through SDL's blit, or a resolve for a multisampled
|
|
265
|
+
source; depth through a sampling pass that writes `gl_FragDepth`; stencil bits
|
|
266
|
+
are accepted but not copied). This is enough for render-to-texture,
|
|
267
|
+
multisampled render targets, shadow maps and post-processing passes.
|
|
206
268
|
- **State**: `enable`/`disable`/`isEnabled` for `BLEND`, `DEPTH_TEST`,
|
|
207
269
|
`CULL_FACE`, `SCISSOR_TEST` and `STENCIL_TEST`,
|
|
208
270
|
`clearColor`/`clearDepth`/`clearStencil`, `clear` (with `SCISSOR_TEST` it
|
|
@@ -218,8 +280,10 @@ available from GLSL ES 3.00, which is what the instanced example uses.
|
|
|
218
280
|
pair that differs uses the front value.
|
|
219
281
|
- **Readback**: `readPixels` (RGBA/UNSIGNED_BYTE) from the default framebuffer
|
|
220
282
|
or a bound RGBA8 framebuffer; a float/depth attachment is sampled into an
|
|
221
|
-
RGBA8 target first
|
|
222
|
-
|
|
283
|
+
RGBA8 target first, and the default framebuffer's multisampled colour target
|
|
284
|
+
is resolved into the readable texture automatically. Reading a multisampled
|
|
285
|
+
user framebuffer directly is `INVALID_OPERATION`. It blocks until the GPU
|
|
286
|
+
finishes; use it for tests and screenshots, not per frame.
|
|
223
287
|
|
|
224
288
|
WebGL 2 adds:
|
|
225
289
|
|
|
@@ -272,11 +336,12 @@ backend's `[0, 1]` clip space rather than GL's `[-1, 1] → [0, 1]` remap:
|
|
|
272
336
|
## Not implemented
|
|
273
337
|
|
|
274
338
|
Transform feedback (the entry points are no-ops: SDL_GPU has no transform
|
|
275
|
-
feedback stage) and
|
|
276
|
-
colour targets,
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
339
|
+
feedback stage) and multisampled *depth/stencil* resolves (SDL_GPU can resolve
|
|
340
|
+
colour targets only, so a multisample depth blit leaves the destination depth
|
|
341
|
+
untouched). `blitFramebuffer` copies colour and depth; stencil bits are accepted
|
|
342
|
+
but not copied because SDL_GPU cannot sample a stencil attachment. Shaders
|
|
343
|
+
cannot sample a multisampled texture (`sampler2DMS`): reading one requires a
|
|
344
|
+
resolve through `blitFramebuffer`.
|
|
280
345
|
|
|
281
346
|
Shader limitations that remain: struct-typed uniforms and user uniform blocks
|
|
282
347
|
are flattened, but built-in interface blocks (`gl_PerVertex` redeclarations) are
|
|
@@ -331,6 +396,11 @@ SPIRV-Cross, nor any `webgl_*` member (see [Link features](./build.md#link-featu
|
|
|
331
396
|
colour attachments and reads each back.
|
|
332
397
|
- `tests/e2e/gui-webgl2-ubo.test.ts` binds a std140 block, updates its members
|
|
333
398
|
and verifies the drawn colour.
|
|
399
|
+
- `tests/e2e/gui-webgl2-msaa.test.ts` checks the antialiased default drawing
|
|
400
|
+
buffer (a partially covered edge pixel resolves to a blend), resolves a
|
|
401
|
+
multisampled renderbuffer and `texStorage2DMultisample` texture through
|
|
402
|
+
`blitFramebuffer`, reports `FRAMEBUFFER_INCOMPLETE_MULTISAMPLE` for mismatched
|
|
403
|
+
attachments and rejects `readPixels` from a multisampled framebuffer.
|
|
334
404
|
- `examples/gui/webgl-cube` is a spinning, lit, textured cube; it runs in a
|
|
335
405
|
browser unchanged and is covered by
|
|
336
406
|
`tests/e2e/gui-example-webgl.test.ts`.
|
|
@@ -358,9 +428,10 @@ Canvas2D fallback is bundled any more**. Verified with three.js r160 through SDL
|
|
|
358
428
|
`Sprite`, `Line`, `Points` and `InstancedMesh`.
|
|
359
429
|
|
|
360
430
|
Features outside this engine's subset still cannot be emulated: transform
|
|
361
|
-
feedback and
|
|
362
|
-
are available,
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
431
|
+
feedback and multisampled depth resolves. Depth textures, float render targets
|
|
432
|
+
and compressed textures are available, MSAA colour resolves run on Vulkan and
|
|
433
|
+
Metal, and comparative `sampler2DShadow` sampling is translated, so three.js
|
|
434
|
+
shadow maps can use the hardware depth compare on both backends (see
|
|
435
|
+
[known issues](./known-issues.md) for an Intel-Mac driver caveat). A scene that
|
|
436
|
+
needs transform feedback will not render correctly; everything the previous
|
|
437
|
+
Canvas2D fallback could show now goes through the GPU.
|
package/doc/gui-scripts.md
CHANGED
|
@@ -64,7 +64,8 @@ run scripts is to **compile them ahead of time**.
|
|
|
64
64
|
| 1 | **No page JS engine.** Behaviour is native TS. `<script>` bodies are *AOT-compiled* to native code by xbintsc and invoked through `xt_call_with_this` — there is still no interpreter. |
|
|
65
65
|
| 8 | **Scripts are compile-time assets.** The HTML asset loader transforms inline `<script>` bodies into compiled modules and replaces them with `data-xt-id` markers; the runtime only *invokes* already-compiled functions. |
|
|
66
66
|
| 9 | **The DOM is owned by the engine; handles are engine objects.** Handles use the same shared-prototype object model as window handles; hidden fields carry a window reference, a document generation and a node index. |
|
|
67
|
-
| 10 | **`window`/`document` are injected as parameters**, not globals, so no global-object machinery is added to the compiler. |
|
|
67
|
+
| 10 | **`window`/`document` are injected as parameters**, not globals, so no global-object machinery is added to the compiler. The *window members* a browser also exposes as bare globals (`innerWidth`, `location`, `addEventListener`, `screen`, …) are declared by the extension as member reads of the window value, so `innerWidth` lowers to `xt_get(window, "innerWidth")` and stays live. |
|
|
68
|
+
| 11 | **A `<script>` is JavaScript unless it says `lang="ts"`.** That is the browser rule, and it is also what keeps a minified bundle (or any plain JS page) out of the type checker, whose inference is only sound for code that was written with annotations. Names and redeclarations are still checked, because code generation needs them. |
|
|
68
69
|
|
|
69
70
|
## Architecture
|
|
70
71
|
|
package/doc/gui.md
CHANGED
|
@@ -352,12 +352,15 @@ engine were Rust.
|
|
|
352
352
|
the WebGL 1 one, with the WebGL 2 constants and methods.
|
|
353
353
|
- GLSL ES 3.00 sources (`#version 300 es`, `in`/`out`, named fragment
|
|
354
354
|
outputs, `gl_InstanceID`) compile through the same rewriter.
|
|
355
|
-
-
|
|
356
|
-
SDL's per-instance input rate, and sampler objects override a texture
|
|
357
|
-
unit's filter/wrap state. `texStorage2D`, `copyBufferSubData`,
|
|
355
|
+
- `texStorage2D`, `copyBufferSubData`,
|
|
358
356
|
`getBufferSubData` and `clearBuffer*` are implemented; query/fence/UBO and
|
|
359
|
-
transform-feedback entry points exist and degrade gracefully.
|
|
360
|
-
|
|
357
|
+
transform-feedback entry points exist and degrade gracefully.
|
|
358
|
+
- Vulkan and Metal contexts are 4× multisampled when the `antialias`
|
|
359
|
+
attribute (default true) allows it: every pass resolves the drawing buffer
|
|
360
|
+
into the composited texture, `renderbufferStorageMultisample`/
|
|
361
|
+
`texStorage2DMultisample` allocate multisampled render targets, and
|
|
362
|
+
`blitFramebuffer` resolves colour. See [WebGL](./gui/webgl.md); e2e in
|
|
363
|
+
`tests/e2e/gui-webgl2.test.ts` and
|
|
361
364
|
`tests/e2e/gui-example-webgl2.test.ts`, demo in
|
|
362
365
|
`examples/gui/webgl2-cubes`.
|
|
363
366
|
19. **M19 — decorative CSS** ✅
|
|
@@ -105,6 +105,15 @@ other control flow does not.
|
|
|
105
105
|
- Bundled sources under `node_modules` are not checked at all: the checker is a
|
|
106
106
|
gate for the code you wrote, and failing on a dependency's internals would
|
|
107
107
|
make the default-on checker unusable with packages.
|
|
108
|
+
- Plain JavaScript sources are not type-checked either (TypeScript only reports
|
|
109
|
+
on them with `checkJs`): an external `.js`/`.mjs`/`.cjs`/`.jsx` script, and an
|
|
110
|
+
inline `<script>` body in an HTML page that does not say `lang="ts"`. Names
|
|
111
|
+
are still resolved and redeclarations are still reported — both are needed for
|
|
112
|
+
code generation — but no type, arity or property diagnostic is produced. That
|
|
113
|
+
is the browser rule as well: a page's script is JavaScript unless it opts in,
|
|
114
|
+
and minified bundles legitimately install methods on a state object after its
|
|
115
|
+
literal, initialize a "call it later" variable with `null`, and call functions
|
|
116
|
+
through default parameters.
|
|
108
117
|
|
|
109
118
|
## Behaviour without the checker
|
|
110
119
|
|
|
@@ -7,6 +7,11 @@ Location: `src/codegen/llvm.ts`
|
|
|
7
7
|
- Emits LLVM IR text (`.ll`); no custom register allocation (relies on `alloca` + mem2reg).
|
|
8
8
|
- Statement / block boundary values live in `alloca`; conditionals and short-circuits materialize into temporary slots instead of `phi`.
|
|
9
9
|
- Property reads are inline-cached per source site: each access owns a zeroed `[2 x i64]` global (`@ic.N`) passed to `xt_get_ic`. Ordinary objects carry an interned hidden-class shape (`xt_shape`, a `(parent, key)` transition tree) and the cache stores `(shape, property index)`, so a hit is a shape-pointer compare plus one key check instead of a linear property scan. Inserts/deletes and integer-key reordering rebuild or transition the shape, which invalidates stale caches; arrays, functions and containers fall back to `xt_get`.
|
|
10
|
+
- Property **writes** get the same per-site cache: each `obj.name = value` owns a `[2 x i64]` global (`@st.N`) passed to `xt_set_ic`. A hit compares the receiver's shape and the slot's key and writes the value field; a miss goes through `xt_set` (new property, delete, accessor, frozen object, host view, array, typed array) and refills the cache when the key ended up as an own data property. That removes the own-property scan, the inherited-setter walk and the typed-array kind probe from every hot store.
|
|
11
|
+
- `Math.<fn>(...)` with a fixed arity lowers to a direct runtime entry (`xt_math1_floor`, `xt_math2_imul`, `xt_math0_random`, …) instead of `xt_math_call(name, argc, argv)`: the name and arity are known at compile time, so the arguments are passed in registers and the runtime skips the name dispatch and the argument array. Any other shape (a spread argument, a wrong argument count, `min`/`max`, a first-class `Math` alias) keeps `xt_math_call`, which dispatches on the first byte of the name instead of a linear `strcmp` chain.
|
|
12
|
+
- Shape transitions are interned by the key's **text**, not by the address of the string that holds it: `xt_shape_transition` hashes the string bytes and compares keys by value. A key built at run time — a typed array's `byteLength`, a DOM handle's `length`, `obj["k" + i]` — is a fresh string with the same bytes, so pointer-keyed interning created a new shape on every insert; past the 16K limit each new object then had no shape at all, which silently disabled both inline caches for the rest of the program (a 1.4 MB bundled page interned 260 000+ transitions and spent about a minute in level setup). The table has 4096 buckets and interns up to 262 144 transitions; `XT_SHAPE_TRACE=1` reports the count as it grows, so a page that outgrows it is visible instead of merely slow.
|
|
13
|
+
- Element access `obj[key]` is inlined into the IR (`calls/element-inline.ts`) instead of being a runtime call. The emitted fast path guards the key to a canonical array index (integral, `0 .. 2^32-2` — `ta[1.5]` and `ta[-1]` stay ordinary property accesses), then loads the live `length`/`items` (or a typed-array view's `view_bytes`/kind) straight out of the container header and does the element load/store itself; strings, `Map`s, host views, out-of-range indices and the integer typed-array *stores* (which need `ToUintN`/`ToIntN` wrapping) branch to `xt_get_element` / `xt_set_element`, so semantics stay exactly the runtime's. The field offsets live in `layout.ts` and are checked against `runtime/rt_object.h` by `tests/codegen/element-layout.test.ts`. Without this, every element access was a call clang could not inline (no LTO), which cost geometry code ~50x a plain array on typed arrays.
|
|
14
|
+
- Method calls obj.name(...) carry a three-word monomorphic inline cache (@mt.N) passed to xt_call_method_ic: a hit compares the receiver''s prototype value and the holder''s shape, re-reads the cached property slot and calls its *current* value with his, so a reassigned/deleted/added method is still observed; anything else (built-ins, Map/Set, host views, deep prototype chains, getters, a non-function value) takes the full xt_call_method dispatch. That removed the per-call resolution walk from numeric code, which was ~26x a V8 call.
|
|
10
15
|
- Numeric operators keep the inline two-double fast path; operands that are numeric literals skip their tag check. Conditions whose expression is a comparison, `in`, `instanceof` or `!` are already boolean tags, so codegen emits `icmp eq i64 value, XT_TRUE` instead of calling `xt_truthy` (this removes the call from the hot loop condition).
|
|
11
16
|
- Control flow: `if` / `while` / `do` / `for` / `for...of` / `for...in`, `switch`, `try/catch/finally`, `break` / `continue` / `return`.
|
|
12
17
|
- `for...of` and spread iterate arrays, strings, typed arrays, `Map`, `Set`, generators and any object exposing `[Symbol.iterator]()` through `xt_iter_open` → `xt_iter_has` / `xt_iter_value` (`Map` yields `[key, value]` pairs); a non-iterable throws `TypeError`. Arrays also expose a stable `Array.prototype[Symbol.iterator]`; calling it returns an iterator object with `next()` that is itself iterable.
|
|
@@ -32,3 +37,5 @@ Location: `src/codegen/llvm.ts`
|
|
|
32
37
|
- Builtin calls: `console.log` / `info` / `warn` / `error`, `Math.*`, `Object.*`, array / string methods, global functions, extension builtins (uniform `(argc, argv)` ABI).
|
|
33
38
|
- `main` entry point (returns 0, calls the module function, then drains microtasks and runs the event loop until no timers or descriptors remain).
|
|
34
39
|
- Unsupported nodes uniformly report `UnsupportedFeature`; they never crash.
|
|
40
|
+
|
|
41
|
+
|
|
@@ -9,7 +9,7 @@ Module syntax (`import` / `export`, import attributes) and the driver-level bund
|
|
|
9
9
|
## Statements
|
|
10
10
|
|
|
11
11
|
- Variable declarations: `var` / `let` / `const`, with multiple declarators `const a = 1, b = 2;`
|
|
12
|
-
- Function declarations, function expressions and methods, including the `async` modifier, generators (`function*`, `yield`, `yield*`, `.next`/`.throw`/`.return`) and async generators (`async function*`, `for await...of`)
|
|
12
|
+
- Function declarations, function expressions and methods, including the `async` modifier, generators (`function*`, `yield`, `yield*`, `.next`/`.throw`/`.return`) and async generators (`async function*`, `for await...of`). A `yield` with no operand is an expression too: `yield` followed by `,`, a closing bracket/brace/paren, `;` or a line break yields `undefined`, which is how a minified generator is written (`yield, doThing(), yield`)
|
|
13
13
|
- `class` declarations / class expressions (constructor, fields, methods, `static`, `static { ... }` blocks, `extends`)
|
|
14
14
|
- `if` / `else`
|
|
15
15
|
- `while`, `do...while`
|
|
@@ -57,3 +57,4 @@ Module syntax (`import` / `export`, import attributes) and the driver-level bund
|
|
|
57
57
|
## ASI
|
|
58
58
|
|
|
59
59
|
- Automatic Semicolon Insertion, based on `precededByLineBreak` / `}` / EOF.
|
|
60
|
+
|
|
@@ -16,10 +16,15 @@ standard-library surface have their own pages:
|
|
|
16
16
|
- [Async, promises and generators](./async.md)
|
|
17
17
|
- [fetch](./fetch.md)
|
|
18
18
|
|
|
19
|
-
- Allocator: non-moving mark-sweep collector behind `xt_alloc` (explicit roots, subsystem root providers and a conservative C-stack scan). Collection is deferred while a bundle's module bodies run (`xt_gc_begin_startup` raises the threshold to 512 MiB until `xt_gc_end_startup`): a large module graph is built entirely inside one generated function, and collecting in the middle of it has corrupted live objects. `XT_GC_THRESHOLD` still overrides both values. Two environment switches exist for this class of bug: `XT_GC_VERIFY=1` re-scans
|
|
19
|
+
- Allocator: non-moving mark-sweep collector behind `xt_alloc` (explicit roots, subsystem root providers and a conservative C-stack scan). Collection is deferred while a bundle's module bodies run (`xt_gc_begin_startup` raises the threshold to 512 MiB until `xt_gc_end_startup`): a large module graph is built entirely inside one generated function, and collecting in the middle of it has corrupted live objects. `XT_GC_THRESHOLD` still overrides both values. The next threshold is **4×** the surviving heap: an interactive scene keeps a large live set for minutes, and at 2× a three.js page collected once every ~1.2 s; 4× halves the number of stop-the-world pauses while the threshold still follows (and shrinks with) the live set, so it cannot ratchet upwards. `XT_GC_TRACE=1` prints each collection's heap, allocation and live-kind counts plus its `took <ms>` broken into table/mark/sweep phases. Two environment switches exist for this class of bug: `XT_GC_VERIFY=1` re-scans
|
|
20
20
|
every marked object's payload before the sweep and prints any block it
|
|
21
21
|
references that stayed unmarked (a tracer or root gap), and the crash report
|
|
22
22
|
names a fault address that falls inside a block the collector freed. I/O worker threads allocate result values but never collect (`xt_gc_worker_thread`): the collector scans the main stack region and is not thread-safe, and a block born during a collection is marked so the sweep keeps it.
|
|
23
|
+
- Small-block allocation: blocks up to 2 KiB (most objects, closures, strings, and the property/array buffers behind them) come from per-size-class free lists carved out of 1 MiB slabs instead of `malloc`/`calloc`; the collector returns a block to its class, so a steady state reuses memory and object-heavy scene code stops paying a C allocator round trip per object. Large blocks keep `malloc`/`free`, I/O workers keep `calloc` (the pool is main-thread only), and a pooled block is marked by `XT_GC_POOLED` so the sweep releases it correctly.
|
|
24
|
+
- Tracing is **precise** for the kinds a program allocates in bulk: an `xt_object` marks its prototype, error stack and each property's key/value/getter/setter, an array its items and `extra`, a function its name bag, prototype and environment, and maps/sets/regexps their element arrays. Only the exotic kinds (iterators, symbols) still use the conservative payload scan. `xt_gc_mark_value` rejects every number with one tag compare, so marking a 400k-object scene does not spend its time in five `XT_IS_*` branches per property slot.
|
|
25
|
+
- The C-string property lookups behind the host bindings (`xt_object_get_cstr(w, "__xt_gl_context")`, the typed-array helpers, the runtime's own helpers) intern the key contents in a small, GC-rooted table instead of allocating an `xt_string` per call. This was the dominant allocation source for a WebGL page: the Saltline boot made ~24M such calls, and after the table the same run makes ~165k calls and allocates ~192k strings in total, roughly two orders of magnitude less garbage for the collector to sweep.
|
|
26
|
+
- Time: `performance.now()` returns milliseconds since the **program's** time origin, like a browser's navigation start or Node's process start, not the raw monotonic counter (on Windows the QPC counts from machine boot, so a process started six days into an uptime used to report six days on its first call). `xt_time_init()` snapshots the origin from the generated `main`, and animation-frame callbacks receive the same clock.
|
|
27
|
+
- Profiling: `XT_PROFILE=1` counts entries to the hottest runtime helpers (allocation, collection, property get/set, method dispatch, closure calls, array element reads, typed-array reads/writes, `Math` dispatch) and prints them to stderr at exit. It also breaks allocations down by object kind and lists the twenty most frequent C-string property names, which attributes allocation pressure to a helper or a key without a sampling profiler. The counters cost one branch when enabled and nothing when unset; pair them with a microbenchmark of the same helper to attribute time.
|
|
23
28
|
- Value construction: `xt_undefined/xt_null/xt_bool/xt_number/xt_string_new/xt_string_from_cstr`.
|
|
24
29
|
- Type conversion: `xt_truthy`, `xt_to_number`, `xt_to_string`, `xt_typeof`.
|
|
25
30
|
- Arithmetic: `add/sub/mul/div/mod/pow/neg/pos`.
|
|
@@ -31,6 +36,8 @@ names a fault address that falls inside a block the collector freed. I/O worker
|
|
|
31
36
|
- Operator helpers: `xt_in` (`in`), `xt_delete` (`delete`), `xt_rest_args` (rest parameters / `arguments`).
|
|
32
37
|
- Box: `box_new/get/set` (for closure-captured variables).
|
|
33
38
|
- Functions and closures: `arg`, `closure_new/call/env/arity`.
|
|
34
|
-
- Exceptions: `xt_try_enter` / `xt_try_exception` / `xt_try_leave` maintain the `_setjmp` frame stack; `xt_throw` long-jumps to the nearest `try` when a frame exists, otherwise prints `Uncaught ...` and exits. A promise rejection nobody observes is fatal too: `xt_promise_report_unhandled` runs once the event loop drains, prints `Unhandled promise rejection` plus the reason and exits with status 1 (see [Async](./async.md)). Codegen also maintains a shadow call stack (function name, source file and line) that `Error.stack` captures (see [Standard library](./stdlib.md)), and a fatal-signal handler dumps the same frames on a native crash. While a bundle's module bodies run, the stack names the module being initialised (` module: <path>` above the frames): every module shares one generated function, so its frames alone all carry the entry file's coordinates. `--debug` additionally emits `!DICompileUnit` / `!DISubprogram` / `!DILocation` metadata and compiles with `-g -fno-omit-frame-pointer`, so gdb/lldb/WinDbg map instructions back to source lines.
|
|
39
|
+
- Exceptions: `xt_try_enter` / `xt_try_exception` / `xt_try_leave` maintain the `_setjmp` frame stack; `xt_throw` long-jumps to the nearest `try` when a frame exists, otherwise prints `Uncaught ...` and exits. A promise rejection nobody observes is fatal too: `xt_promise_report_unhandled` runs once the event loop drains, prints `Unhandled promise rejection` plus the reason and exits with status 1 (see [Async](./async.md)). Codegen also maintains a shadow call stack (function name, source file and line) that `Error.stack` captures (see [Standard library](./stdlib.md)), and a fatal-signal handler dumps the same frames on a native crash. While a bundle's module bodies run, the stack names the module being initialised (` module: <path>` above the frames): every module shares one generated function, so its frames alone all carry the entry file's coordinates. Setting `XT_STACK_WATCHDOG_MS=<n>` starts a sampler thread that prints those frames whenever no function has been entered or left for *n* milliseconds, turning a silent hang (an unexpected infinite loop, a blocking host call) into a source location; the thread is not started when the variable is unset. `--debug` additionally emits `!DICompileUnit` / `!DISubprogram` / `!DILocation` metadata and compiles with `-g -fno-omit-frame-pointer`, so gdb/lldb/WinDbg map instructions back to source lines. `!DILocation` has a 16-bit `column` field, so a column from a minified bundle (they run to hundreds of thousands) is clamped to 65535 instead of making clang reject the module; the line is clamped to the 24-bit limit for the same reason.
|
|
35
40
|
- Typed pointers that the collector follows from inside a struct (a promise's reaction list, an active coroutine frame, a string's rope children) are validated against the heap table before marking, so a stale one is skipped instead of dereferenced (`XT_GC_VERIFY=1` reports it).
|
|
41
|
+
- A lazily built value (`Function.prototype[Symbol.hasInstance]`, a prototype cache, `console`, `JSON`, a symbol registry) registers its static slot as a root **before** the allocations that build the value. A static is outside the conservative stack scan, so a collection between storing the value and registering the slot sweeps an object the program still holds; the stale slot then marks a freed block, which on Windows (where the compiler kept no stack copy) corrupted the small-block free list and crashed the next `xt_pool_alloc`.
|
|
36
42
|
- Objects / functions: `xt_object` with a prototype chain, `xt_function` with a property bag (static members and `prototype`); `xt_new` (instantiation), `xt_instance_of` (prototype chain), `xt_object_freeze/is_frozen/from_entries`; `xt_constructors.c` holds the first-class constructor cache, constructor prototypes and static-value dispatch.
|
|
43
|
+
|
|
@@ -56,7 +56,9 @@ own pages: [Collections](./collections.md), [Typed arrays and binary data](./typ
|
|
|
56
56
|
|
|
57
57
|
- Number formatting and coercion match Node: `toFixed` / `toPrecision` / `toExponential`, hex / octal / binary parsing, and the full `+` / relational `ToPrimitive` rules. These are covered by the differential tests.
|
|
58
58
|
- `BigInt` literals and values: arbitrary precision arithmetic, bitwise and shift operators, comparisons, `toString(radix)`, `BigInt()`, `BigInt.asIntN` / `BigInt.asUintN`.
|
|
59
|
-
- `Math`: the full function set and constants.
|
|
59
|
+
- `Math`: the full function set and constants. `Math.hypot(...values)` accepts any number of arguments (ECMA-262 21.3.2.18): every argument participates, a `NaN` wins and the sum is scaled by the largest magnitude so `hypot(1e308, 1e308)` does not overflow.
|
|
60
|
+
- `Math.cbrt` uses the runtime's own fdlibm implementation (the version V8 ships) rather than the host libm, whose low bits vary: glibc computes `Math.cbrt(27)` as `3.0000000000000004`. Results are therefore bit-identical with Node on every host.
|
|
61
|
+
- `Math` call sites dispatch on the first byte of the member name before comparing the full name, so `Math.imul` / `floor` / `exp` in a numeric loop no longer pay for a linear `strcmp` chain (procedural texture and geometry code calls them hundreds of millions of times; removing the chain halved level setup on a bundled three.js page).
|
|
60
62
|
- `Math` is also a first-class object: `const cos = Math.cos`, `[1, 2].map(Math.max)` and `const { sqrt, PI } = Math` read members as values (`xt_math_object()` caches one native closure per function, so reads stay cheap).
|
|
61
63
|
- `Number` statics and `Number()` conversion; `parseInt` / `parseFloat` / `isNaN` / `isFinite`.
|
|
62
64
|
|
|
@@ -75,6 +77,7 @@ own pages: [Collections](./collections.md), [Typed arrays and binary data](./typ
|
|
|
75
77
|
|
|
76
78
|
- `RegExp` uses the runtime's self-contained POSIX-ERE-compatible matcher (`regcomp` / `regexec` style) on every host, so results do not depend on the platform's libc. Capture groups are exposed through `exec` / `match` / `replace` / `split` / `search`.
|
|
77
79
|
- Quantifiers include `*`, `+`, `?` and the counted forms `{n}`, `{n,}` and `{n,m}` (with a lazy `?` suffix). Malformed brace groups such as `{x}` and `{,2}` stay literal, as in JavaScript; an inverted range such as `{2,1}` is also treated as literal instead of being rejected.
|
|
80
|
+
- A JavaScript pattern is translated for the matcher first (`\d`/`\w`/`\s` → classes, `(?:` → a capturing group, control-character escapes → literals). Any other escape is a **literal character** and keeps its backslash, so `\[`, `\]`, `\(`, `\.`, `\+` match those characters and do not start syntax: `"x[ i ]y".replace(/\[\s*i\s*\]/g, …)` behaves like Node. three.js's `unrollLoops` depends on exactly that shape.
|
|
78
81
|
- Matching is byte-oriented and `/g` / `/y` `lastIndex` is not honoured — see [Runtime deviations](../unimplemented/deviations.md).
|
|
79
82
|
|
|
80
83
|
## Symbol
|
|
@@ -101,7 +104,11 @@ own pages: [Collections](./collections.md), [Typed arrays and binary data](./typ
|
|
|
101
104
|
|
|
102
105
|
## URLSearchParams
|
|
103
106
|
|
|
104
|
-
- `URLSearchParams` is implemented in `runtime/xt_url.c`.
|
|
107
|
+
- `URLSearchParams` is implemented in `runtime/xt_url.c`. It is iterable
|
|
108
|
+
(`[Symbol.iterator]`, so `[...params]`, `for (const [k, v] of params)` and
|
|
109
|
+
`Object.fromEntries(params)` work), and `Object.fromEntries` consumes any
|
|
110
|
+
iterable — an array of pairs, a `Map`, a `URLSearchParams` or a generator —
|
|
111
|
+
rather than only an array.
|
|
105
112
|
|
|
106
113
|
## Errors
|
|
107
114
|
|
|
@@ -112,6 +119,7 @@ own pages: [Collections](./collections.md), [Typed arrays and binary data](./typ
|
|
|
112
119
|
## console
|
|
113
120
|
|
|
114
121
|
- `xt_print` / `xt_println` / `xt_console_log` / `info` / `warn` / `error`; `info` / `log` go to stdout, `warn` / `error` to stderr.
|
|
122
|
+
- `console` is a first-class object as well as a namespace: `const log = console.log`, `const { warn } = console`, `console.error.bind(console)` and `console.error = ...` all work, because reading `console` produces a cached object whose methods are ordinary functions (`xt_console_object`). Call sites stay direct (`console.log(...)` lowers to the runtime symbol), so the object costs nothing until a program uses it as a value.
|
|
115
123
|
- Node-style inspection: arrays `[ a, b ]`, objects `{ k: v }`, UTF-8-aware, with circular references marked.
|
|
116
124
|
- `dir` / `trace` / `assert` / `count` / `countReset` / `group` / `groupEnd` / `table` / `time` / `timeEnd` / `timeLog`.
|
|
117
125
|
|
|
@@ -12,12 +12,28 @@ Location: `runtime/xt_typed_array.c`, `runtime/xt_array_buffer.c`.
|
|
|
12
12
|
- Element reads/writes apply the per-type coercion (`ToIntN` / `ToUintN`, `Uint8ClampedArray` rounding, `Float32` single-precision rounding).
|
|
13
13
|
- Prototype methods: `fill` / `set` / `slice` / `subarray` / `join` / `toString` / `indexOf` / `lastIndexOf` / `includes` / `forEach` / `map` / `filter` / `every` / `some` / `find` / `findIndex` / `reduce` / `reverse` / `sort` / `copyWithin` / `at` / `keys` / `values` / `entries`. Iterator methods still return arrays, not iterator objects.
|
|
14
14
|
- Typed arrays are views over an `ArrayBuffer`; `subarray` shares the buffer and `slice` copies.
|
|
15
|
+
- Element access is direct memory access, not a property lookup: an `ArrayBuffer`
|
|
16
|
+
owns one `uint8_t` block (allocation kind `XT_OBJECT_KIND_ARRAY_BUFFER`), and a
|
|
17
|
+
view resolves that block plus its byte offset once at construction (`view_bytes`
|
|
18
|
+
in `xt_object`) and then indexes it with a `memcpy`-sized read/write. The
|
|
19
|
+
general `xt_get`/`xt_set` path is only used for non-index keys and for views
|
|
20
|
+
without a real buffer. This is what makes geometry code (three.js reading and
|
|
21
|
+
writing `position`/`normal` attribute arrays) run at memory speed instead of
|
|
22
|
+
paying a runtime call per byte; the same work used to be ~50x slower than a
|
|
23
|
+
plain array.
|
|
24
|
+
- Only canonical array indices (`0 .. 2^32-2`, integral) name an element:
|
|
25
|
+
`ta[1.5]`, `ta[-1]` and `ta[2**32]` are ordinary property accesses, and an
|
|
26
|
+
out-of-range index reads `undefined` / ignores the write.
|
|
15
27
|
|
|
16
28
|
## ArrayBuffer and DataView
|
|
17
29
|
|
|
18
|
-
- `ArrayBuffer`: `byteLength`, `slice`, `ArrayBuffer.isView`.
|
|
30
|
+
- `ArrayBuffer`: `byteLength`, `slice`, `ArrayBuffer.isView`. `byteLength` and
|
|
31
|
+
`slice` are served by the runtime (`xt_get`), not stored as own properties, so
|
|
32
|
+
`Object.keys(new ArrayBuffer(8))` is empty like on the platform.
|
|
19
33
|
- `DataView`: big-endian by default, optional `littleEndian`, with `get` / `set` for Uint8 / Int8 / Uint16 / Int16 / Uint32 / Int32 / Float32 / Float64.
|
|
20
|
-
- Multiple views over one buffer share its bytes.
|
|
34
|
+
- Multiple views over one buffer share its bytes. The collector frees a buffer's
|
|
35
|
+
byte block when the buffer is swept; a view keeps its buffer reachable, so the
|
|
36
|
+
cached base pointer in a view never dangles.
|
|
21
37
|
|
|
22
38
|
## Not implemented
|
|
23
39
|
|
package/doc/zh-CN/gui/api.md
CHANGED
|
@@ -98,6 +98,7 @@ requestAnimationFrame(frame);
|
|
|
98
98
|
| --- | --- |
|
|
99
99
|
| `window`、`self` | 最近打开的窗口句柄(若程序尚未创建窗口,会隐式打开一个),因此 `window.innerWidth`、`window.addEventListener`、`window.setTimeout`、`window.localStorage`、`window.location`、`window.devicePixelRatio`、`window.matchMedia` 都可用 |
|
|
100
100
|
| `document` | 该窗口的 document 句柄 |
|
|
101
|
+
| 裸 window 成员 | 浏览器的全局作用域其实就是 window,因此 `innerWidth`、`innerHeight`、`outerWidth`、`outerHeight`、`devicePixelRatio`、`location`、`screen`、`scrollX`/`scrollY`、`addEventListener`/`removeEventListener`/`dispatchEvent`、`setTimeout`/`clearTimeout`/`setInterval`/`clearInterval`、`queueMicrotask`、`focus`/`blur`、`scrollTo`/`scrollBy` 不带 `window.` 前缀也能用。每一项都是从 window 上实时读取成员(`xt_get(window, name)`;调用走 `xt_call_method`),所以 `innerWidth` 会跟随窗口尺寸变化,`location.href` 仍是真实对象。`screen` 描述的是显示器(`width`/`height`/`availWidth`/`availHeight`/`colorDepth`/`pixelDepth`/`orientation`),不是窗口 |
|
|
101
102
|
| `navigator` | `userAgent`(以 `xbintsc` 结尾的桌面 Chrome 字符串)、`platform`、`vendor`、`language(s)`、`hardwareConcurrency`、`maxTouchPoints`、`onLine`、`vibrate()` |
|
|
102
103
|
| `localStorage` | 内存中的 `getItem` / `setItem` / `removeItem` / `clear` / `key` / `length` |
|
|
103
104
|
| `AudioContext`、`webkitAudioContext` | 带真实混音器与解码器的 Web Audio 图(见下) |
|
|
@@ -108,6 +109,7 @@ requestAnimationFrame(frame);
|
|
|
108
109
|
| `ImageBitmap`、`createImageBitmap(source)` | 由已解码像素支撑的不可变位图(`<img>`、`<canvas>`、`<video>` 帧、`OffscreenCanvas` 与 `ImageData` 形状);promise 立即 settle,`texImage2D` 可直接接受该对象 |
|
|
109
110
|
| `OffscreenCanvas` | 真正的 2D 离屏位图,带 `getContext("2d")`、`width`/`height`、`transferToImageBitmap()` 与 `convertToBlob()`;`canvas.transferControlToOffscreen()` 会把元素位图交给它(见 [Canvas](./canvas.md))。离屏 WebGL 上下文不提供。 |
|
|
110
111
|
| `ImageData`、`XRWebGL*`、`Request`、`Headers`、`Response`、`DOMParser` | `typeof` 探测返回 `"undefined"`(没有 XR、DOM 解析器或流式后端),让页面走自己的“不支持”分支,而不是调用空壳。`fetch` 仍然可用,并返回 response 形状的对象,但没有 `Response` 构造函数,且 `response.arrayBuffer()` 目前返回字节数组而不是 `ArrayBuffer`;`ReadableStream` 等 Web Streams 类来自核心运行时。Three.js 页面在本后端上使用真实渲染器(见[已知问题](./known-issues.md))。 |
|
|
112
|
+
| `VideoFrame`、`OfflineAudioContext`、`Float16Array` | 媒体/three.js 特性探测所期望的名字。`VideoFrame` 是真实的构造函数值,因此 `frame instanceof VideoFrame` 安全地得到 `false`,而不是抛 `TypeError`;`OfflineAudioContext` 能构造出对象,但背后没有离线渲染器(离线渲染音频仍需 `AudioContext`);`Float16Array` 是 `undefined`,因此 `typeof Float16Array < "u"` 会走降级分支(运行时没有 16 位浮点元素类型) |
|
|
111
113
|
| `requestAnimationFrame` / `cancelAnimationFrame` | 排入窗口的动画帧列表,见[运行时集成](./runtime.md) |
|
|
112
114
|
| `alert` / `confirm` / `prompt`、`matchMedia`、`getComputedStyle`、`escape` | 宿主实现。`matchMedia` 返回**实时**列表(按查询缓存):`matches` 在窗口尺寸变化时重新求值,翻转时触发 `change` 监听器。`confirm`/`prompt` 仅在 `XT_GUI_DIALOGS=1` 时使用原生对话框,否则把消息写到 stderr 并返回文档化的默认值(Annex B `escape` 按 UTF-16 码元编码,与 `decodeURIComponent(escape(bytes))` 一致) |
|
|
113
115
|
|
|
@@ -125,12 +127,24 @@ requestAnimationFrame(frame);
|
|
|
125
127
|
已实现的节点:`createGain`、`createOscillator`(sine、square、sawtooth、triangle)、
|
|
126
128
|
`createBufferSource`(buffer、loop、loopStart/loopEnd、playbackRate/detune)、
|
|
127
129
|
`createBiquadFilter`(lowpass、highpass、bandpass、lowshelf、highshelf、peaking、notch、allpass)、
|
|
128
|
-
`createDynamicsCompressor`、`createStereoPanner`、`createConstantSource
|
|
129
|
-
`createDelay(maxDelayTime)
|
|
130
|
+
`createDynamicsCompressor`、`createStereoPanner`、`createConstantSource`、
|
|
131
|
+
`createDelay(maxDelayTime)`、`createWaveShaper`(`curve`、`oversample`)、
|
|
132
|
+
`createConvolver`(`buffer`、`normalize`)、`createAnalyser`(`fftSize`、`frequencyBinCount`、
|
|
133
|
+
`smoothingTimeConstant`、`minDecibels`/`maxDecibels` 及四个 `get…Data` 方法)、
|
|
134
|
+
`createPanner`(`positionX/Y/Z` 与 `orientationX/Y/Z` 是 AudioParam,另有距离/锥角属性与
|
|
135
|
+
`setPosition`/`setOrientation`)、`createMediaElementSource`、`createMediaStreamSource`,
|
|
136
|
+
以及带九个 AudioParam 的 `context.listener`。`connect` 返回目标节点,因此可链式连接
|
|
130
137
|
(`src.connect(gain).connect(ctx.destination)`);`disconnect()` / `disconnect(target)`
|
|
131
138
|
会更新原生图;`start(when, offset, duration)` / `stop(when)` 按图的时钟生效。
|
|
132
|
-
列表之外的节点(`
|
|
133
|
-
`
|
|
139
|
+
列表之外的节点(`createChannelSplitter`、`createChannelMerger`、`createPeriodicWave`、
|
|
140
|
+
`createIIRFilter`、`createScriptProcessor` 等)不提供,其方法就是缺失的。
|
|
141
|
+
|
|
142
|
+
卷积器是**分块 FFT** 卷积(128 帧一块、256 点变换),因此一两秒的混响脉冲响应也能承受;
|
|
143
|
+
`normalize`(默认)会把响应缩放到「白噪声输入电平不变」。1.4 秒响应约占实时 10%,2.2 秒约 18%。
|
|
144
|
+
分析器使用规范中的 Blackman 窗与分贝映射,`smoothingTimeConstant` 是跨调用的滑动平均。
|
|
145
|
+
声像器按 `context.listener` 做等功率声像,并支持 linear/inverse/exponential 距离模型与锥角衰减;
|
|
146
|
+
`panningModel = "HRTF"` 会被接受但走同一条等功率路径(引擎不带 HRIR 数据集)。
|
|
147
|
+
两个媒体源是**合法的静音节点**——引擎没有采集或媒体元素音频管线,所以它们静音而不是缺失。
|
|
134
148
|
|
|
135
149
|
每个 `AudioParam` 都有实时 `value`,以及 `setValueAtTime` / `linearRampToValueAtTime` /
|
|
136
150
|
`exponentialRampToValueAtTime` / `setTargetAtTime` / `cancelScheduledValues` /
|
|
@@ -252,4 +266,4 @@ N 帧取平均)。
|
|
|
252
266
|
|
|
253
267
|
多窗口由对象模型自然得出:`createWindow` 返回一个原生对象句柄;每个句柄
|
|
254
268
|
拥有自己的 `SDL_Window`/GPU 表面与自己的 DOM 树。`run()` 驱动一个共享主循环,
|
|
255
|
-
它每帧 tick 所有窗口,并在最后一个窗口关闭时退出。
|
|
269
|
+
它每帧 tick 所有窗口,并在最后一个窗口关闭时退出。
|
package/doc/zh-CN/gui/dom.md
CHANGED
|
@@ -158,8 +158,14 @@ inner.addEventListener("click", (e) => console.log(e.target.id, e.currentTarget.
|
|
|
158
158
|
inner.click(); // 在该元素处合成一次点击
|
|
159
159
|
console.log(box.offsetWidth, box.offsetHeight); // 取整后的边框盒
|
|
160
160
|
console.log(box.contains(inner)); // 后代判断
|
|
161
|
+
console.log(inner.closest("button, .card") != null); // 自身或最近祖先匹配
|
|
161
162
|
```
|
|
162
163
|
|
|
164
|
+
`element.hidden` 是反射的布尔属性:赋 `true` 会写入 `hidden` 属性(因此
|
|
165
|
+
`hidden === true`、`getAttribute("hidden") === ""`),赋假值则移除它。UA 样式表把
|
|
166
|
+
`[hidden]` 当作 `display: none`,与浏览器一致——作者样式里设置了 `display` 的规则仍然优先,
|
|
167
|
+
所以页面通常先用 class 把 `opacity` 过渡掉,再设置 `hidden`。
|
|
168
|
+
|
|
163
169
|
### style 属性、dataset、计算样式与几何
|
|
164
170
|
|
|
165
171
|
内联 `style` 对象是一个 CSSOM 声明块。以属性名赋值/读取的是与 `setProperty`
|
|
@@ -6,20 +6,39 @@
|
|
|
6
6
|
|
|
7
7
|
## 已知问题
|
|
8
8
|
|
|
9
|
+
- **Web Audio 没有 `MediaStream`/采集管线,且两个节点的行为是近似实现。**
|
|
10
|
+
`createMediaElementSource` 与 `createMediaStreamSource` 返回合法但**静音**的节点:引擎没有
|
|
11
|
+
麦克风/摄像头采集,也不会把媒体元素自身的播放接入音频图,因此页面把二者接入图里得到的是静音,
|
|
12
|
+
而不是报错。`WaveShaperNode.oversample` 在 2 或 4 个子采样点上平均曲线,而不是对输入做带限滤波,
|
|
13
|
+
它能减轻硬曲线引入的混叠但不能消除。`PannerNode.panningModel = "HRTF"` 会被接受,但走等功率
|
|
14
|
+
路径——引擎不带 HRIR 数据集,因此结果是带距离/锥角衰减的立体声声像,而不是双耳滤波。
|
|
15
|
+
`ConvolverNode` 按能量归一化(把响应缩放到「白噪声输入电平不变」),与浏览器的归一化接近但不
|
|
16
|
+
逐位一致。
|
|
9
17
|
- **WebGL 1.0 与 2.0 运行在 GPU 上,但只实现了各自的子集。**
|
|
10
18
|
`canvas.getContext("webgl")` / `"webgl2"` 返回真正的 GPU 上下文(见
|
|
11
19
|
[WebGL](./webgl.md)):GLSL ES 着色器由内置 glslang 翻译为 SPIR-V——Vulkan
|
|
12
20
|
后端直接消费,Metal 上再由内置 SPIRV-Cross 交叉编译为 MSL——绘图缓冲
|
|
13
21
|
是一张离屏颜色纹理,页面直接合成而无须读回。WebGL 2 增加了 VAO、实例化、
|
|
14
22
|
整数属性、采样器对象、`texStorage2D`、缓冲拷贝、Uniform 块、立方体/3D/数组
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
transform feedback
|
|
18
|
-
|
|
19
|
-
|
|
23
|
+
纹理、浮点/深度/压缩纹理、多渲染目标、scissor 清除,以及 Vulkan 上的 4×
|
|
24
|
+
多重采样抗锯齿。`blitFramebuffer` 复制颜色与深度,并解析多重采样颜色源;
|
|
25
|
+
transform feedback、模板 blit 与多重采样深度 blit 尚未实现(SDL_GPU 没有
|
|
26
|
+
transform feedback 阶段、无法解析深度,也无法采样模板附件)。
|
|
27
|
+
在两种着色器格式都不接受的 SDL_GPU 后端(Direct3D 12,需要 DXIL)上两种
|
|
28
|
+
上下文都为 `null`。`.js` 资源加载器现在只修补 three.js 的着色器循环展开;
|
|
20
29
|
`WebGLRenderer` 直接运行在真实后端上,不再有 Canvas2D 回退。阴影贴图
|
|
21
30
|
(比较型 `sampler2DShadow` 采样深度纹理)、立方体贴图/环境贴图与 HDR 渲染目标
|
|
22
31
|
均已支持。
|
|
32
|
+
- **MSAA 在 Vulkan 与 Metal 上启用,并且改变了哪些 blit 合法。**
|
|
33
|
+
`antialias` 属性默认开启;受支持的上下文得到 4× 绘图缓冲,每个渲染 pass
|
|
34
|
+
结束时解析到页面合成的颜色纹理,因此 `getParameter(SAMPLES)` 为 4,部分覆盖的
|
|
35
|
+
边缘像素会是混合色。设备若不支持 4× 颜色与深度,则保持单采样路径
|
|
36
|
+
(`antialias` 为 false、`MAX_SAMPLES` 为 0,多重采样存储请求会降级为单采样的
|
|
37
|
+
renderbuffer/纹理且 `SAMPLES` 为 0)。与浏览器一致,
|
|
38
|
+
blit 到抗锯齿的默认帧缓冲是 `INVALID_OPERATION`:页面若要自己把离屏目标解析到
|
|
39
|
+
canvas,应传入 `getContext("webgl2", { antialias: false })`。多重采样颜色源只有在
|
|
40
|
+
源/目标矩形完全相同、格式相同且过滤为 `NEAREST` 时才能解析;多重采样深度附件可以
|
|
41
|
+
渲染(深度测试按样本工作),但无法通过 SDL_GPU 解析。
|
|
23
42
|
- **部分 Intel Mac 上比较型采样器会被错误编译。** 在 Intel GPU(在 Intel Iris
|
|
24
43
|
Plus Graphics + macOS 26 上观察到)上,Metal 着色器编译器会丢弃调用
|
|
25
44
|
`sample_compare` 的片元函数:绘制不产生任何像素,于是
|
package/doc/zh-CN/gui/runtime.md
CHANGED
|
@@ -48,13 +48,25 @@ deferred` 才是页面自身造成的工作。调试"漏掉的失效"时可用
|
|
|
48
48
|
动画帧回调,因此页面可以自行停止);
|
|
49
49
|
- 只有在**仍有回调**时才重新排程,空闲页面会让事件循环排空并退出进程 ——
|
|
50
50
|
这正是浏览器标签页的生命周期;
|
|
51
|
+
- **每一次**请求都会重新启动它,包括通过**窗口方法**
|
|
52
|
+
(`window.requestAnimationFrame` / `self.requestAnimationFrame`)发出的请求,
|
|
53
|
+
而不只是裸全局函数。three.js 的 `setAnimationLoop` 在其启动很久之后通过
|
|
54
|
+
`self` 申请下一帧,此时帧泵已排空;漏掉这一点会让渲染器再也拿不到帧,页面就
|
|
55
|
+
停在最后一张已呈现的画面上(Saltline 页面因此一直停在“准备就绪”:DOM 里的
|
|
56
|
+
启动遮罩其实已隐藏,但负责把它画出来的那一帧从未执行);
|
|
57
|
+
- 回调收到的时间戳是 `DOMHighResTimeStamp`,与 `performance.now()` 同一时钟,
|
|
58
|
+
而不是 `SDL_GetTicks()`(机器开机时长);
|
|
51
59
|
- 下一次 tick 排在**帧开始 + 16 ms**,而不是帧结束后再等 16 ms:帧自身耗时不再
|
|
52
60
|
叠加到间隔上,10 ms 的帧以 16 ms 周期运行(而不是 26 ms),比 16 ms 更慢的页面
|
|
53
61
|
则以全速运行,而不是每帧再落后一帧的时间;
|
|
54
62
|
- 当 `xt_gui_run_active()` 为真(程序自己调用了 `run()`)时它会让路,避免同一
|
|
55
63
|
窗口每 tick 被渲染两次;
|
|
56
64
|
- `XT_GUI_AUTOCLOSE_MS=n` 让帧泵在 `n` 毫秒后退出,测试用它来运行不会自行
|
|
57
|
-
|
|
65
|
+
关闭的页面;
|
|
66
|
+
- `XT_GUI_TRACE=1` 会把 WebGL 的 resolve/blit/渲染 pass 序列(包括已提交命令缓冲
|
|
67
|
+
的最后一批绘制)打印到 stderr,`XT_GUI_VK_DEBUG=1` 让 SDL 以调试模式创建设备,
|
|
68
|
+
从而启用 Vulkan 的 Khronos 校验层——这两个开关就是定位“半浮点解析丢失设备”时
|
|
69
|
+
使用的。
|
|
58
70
|
|
|
59
71
|
这使网络 I/O、定时器与 `await` 在 GUI 程序内部继续工作。
|
|
60
72
|
|