xbintsc 0.5.23 → 0.5.32
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/AGENTS.md +11 -2
- package/README.md +47 -16
- package/README.zh-CN.md +21 -2
- package/dist/scripts/support-matrix.d.ts +18 -0
- package/dist/scripts/support-matrix.js +141 -0
- package/dist/scripts/support-matrix.js.map +1 -0
- package/dist/src/ast/common.d.ts +2 -2
- package/dist/src/ast/declarations.d.ts +7 -1
- package/dist/src/ast/expressions.d.ts +5 -0
- package/dist/src/ast/kinds.d.ts +2 -0
- package/dist/src/ast/kinds.js +2 -0
- package/dist/src/ast/kinds.js.map +1 -1
- package/dist/src/binder/binder.d.ts +2 -1
- package/dist/src/binder/binder.js +2 -0
- package/dist/src/binder/binder.js.map +1 -1
- package/dist/src/binder/declarations.d.ts +9 -0
- package/dist/src/binder/declarations.js +64 -0
- package/dist/src/binder/declarations.js.map +1 -1
- package/dist/src/binder/references.js +99 -4
- package/dist/src/binder/references.js.map +1 -1
- package/dist/src/binder/types.d.ts +32 -0
- package/dist/src/binder/types.js.map +1 -1
- package/dist/src/canonical.d.ts +29 -0
- package/dist/src/canonical.js +35 -0
- package/dist/src/canonical.js.map +1 -0
- package/dist/src/checker/assignability.d.ts +13 -0
- package/dist/src/checker/assignability.js +146 -0
- package/dist/src/checker/assignability.js.map +1 -0
- package/dist/src/checker/calls.d.ts +13 -0
- package/dist/src/checker/calls.js +127 -0
- package/dist/src/checker/calls.js.map +1 -0
- package/dist/src/checker/checker.d.ts +26 -0
- package/dist/src/checker/checker.js +31 -0
- package/dist/src/checker/checker.js.map +1 -0
- package/dist/src/checker/declarations.d.ts +9 -0
- package/dist/src/checker/declarations.js +15 -0
- package/dist/src/checker/declarations.js.map +1 -0
- package/dist/src/checker/flow.d.ts +21 -0
- package/dist/src/checker/flow.js +241 -0
- package/dist/src/checker/flow.js.map +1 -0
- package/dist/src/checker/globals.d.ts +9 -0
- package/dist/src/checker/globals.js +29 -0
- package/dist/src/checker/globals.js.map +1 -0
- package/dist/src/checker/source.d.ts +38 -0
- package/dist/src/checker/source.js +48 -0
- package/dist/src/checker/source.js.map +1 -0
- package/dist/src/checker/type-infer.d.ts +18 -0
- package/dist/src/checker/type-infer.js +173 -0
- package/dist/src/checker/type-infer.js.map +1 -0
- package/dist/src/checker/type-model.d.ts +73 -0
- package/dist/src/checker/type-model.js +151 -0
- package/dist/src/checker/type-model.js.map +1 -0
- package/dist/src/checker/type-system.d.ts +58 -0
- package/dist/src/checker/type-system.js +569 -0
- package/dist/src/checker/type-system.js.map +1 -0
- package/dist/src/checker/typecheck-types.d.ts +22 -0
- package/dist/src/checker/typecheck-types.js +109 -0
- package/dist/src/checker/typecheck-types.js.map +1 -0
- package/dist/src/checker/typecheck.d.ts +62 -0
- package/dist/src/checker/typecheck.js +574 -0
- package/dist/src/checker/typecheck.js.map +1 -0
- package/dist/src/checker/undefined.d.ts +14 -0
- package/dist/src/checker/undefined.js +32 -0
- package/dist/src/checker/undefined.js.map +1 -0
- package/dist/src/checker/walk.d.ts +10 -0
- package/dist/src/checker/walk.js +15 -0
- package/dist/src/checker/walk.js.map +1 -0
- package/dist/src/cli/help.d.ts +7 -0
- package/dist/src/cli/help.js +64 -0
- package/dist/src/cli/help.js.map +1 -0
- package/dist/src/cli/hints.js +2 -1
- package/dist/src/cli/hints.js.map +1 -1
- package/dist/src/cli/main.js +12 -48
- package/dist/src/cli/main.js.map +1 -1
- package/dist/src/codegen/generator/calls/access.js +8 -8
- package/dist/src/codegen/generator/calls/access.js.map +1 -1
- package/dist/src/codegen/generator/calls/invocation.js +9 -4
- package/dist/src/codegen/generator/calls/invocation.js.map +1 -1
- package/dist/src/codegen/generator/calls/super.d.ts +9 -1
- package/dist/src/codegen/generator/calls/super.js +56 -5
- package/dist/src/codegen/generator/calls/super.js.map +1 -1
- package/dist/src/codegen/generator/context.d.ts +13 -2
- package/dist/src/codegen/generator/context.js +25 -19
- package/dist/src/codegen/generator/context.js.map +1 -1
- package/dist/src/codegen/generator/debug.js +2 -1
- package/dist/src/codegen/generator/debug.js.map +1 -1
- package/dist/src/codegen/generator/expressions/primary.d.ts +4 -1
- package/dist/src/codegen/generator/expressions/primary.js +68 -8
- package/dist/src/codegen/generator/expressions/primary.js.map +1 -1
- package/dist/src/codegen/generator/generator.js +11 -1
- package/dist/src/codegen/generator/generator.js.map +1 -1
- package/dist/src/codegen/generator/module.d.ts +3 -0
- package/dist/src/codegen/generator/module.js +116 -26
- package/dist/src/codegen/generator/module.js.map +1 -1
- package/dist/src/codegen/generator/state.d.ts +11 -1
- package/dist/src/codegen/generator/state.js.map +1 -1
- package/dist/src/codegen/generator/statements/variables.js +26 -7
- package/dist/src/codegen/generator/statements/variables.js.map +1 -1
- package/dist/src/codegen/generator/tables.d.ts +2 -0
- package/dist/src/codegen/generator/tables.js +4 -0
- package/dist/src/codegen/generator/tables.js.map +1 -1
- package/dist/src/driver/build-key.d.ts +2 -0
- package/dist/src/driver/build-key.js +1 -0
- package/dist/src/driver/build-key.js.map +1 -1
- package/dist/src/driver/bundler/graph.js +5 -1
- package/dist/src/driver/bundler/graph.js.map +1 -1
- package/dist/src/driver/bundler/merge.js +16 -1
- package/dist/src/driver/bundler/merge.js.map +1 -1
- package/dist/src/driver/bundler/types.d.ts +12 -0
- package/dist/src/driver/compiler.d.ts +1 -1
- package/dist/src/driver/compiler.js +3 -0
- package/dist/src/driver/compiler.js.map +1 -1
- package/dist/src/driver/fingerprint.js +2 -1
- package/dist/src/driver/fingerprint.js.map +1 -1
- package/dist/src/driver/frontend.d.ts +8 -6
- package/dist/src/driver/frontend.js +4 -0
- package/dist/src/driver/frontend.js.map +1 -1
- package/dist/src/driver/options.d.ts +6 -0
- package/dist/src/driver/version.d.ts +1 -1
- package/dist/src/driver/version.js +1 -1
- package/dist/src/extensions/gui/css.d.ts +26 -0
- package/dist/src/extensions/gui/css.js +100 -0
- package/dist/src/extensions/gui/css.js.map +1 -0
- package/dist/src/extensions/gui/html.js +28 -7
- package/dist/src/extensions/gui/html.js.map +1 -1
- package/dist/src/extensions/gui/index.js +79 -2
- package/dist/src/extensions/gui/index.js.map +1 -1
- package/dist/src/extensions/gui/three.d.ts +16 -0
- package/dist/src/extensions/gui/three.js +22 -0
- package/dist/src/extensions/gui/three.js.map +1 -0
- package/dist/src/extensions/media/index.d.ts +6 -5
- package/dist/src/extensions/media/index.js +12 -14
- package/dist/src/extensions/media/index.js.map +1 -1
- package/dist/src/extensions/registry.d.ts +38 -0
- package/dist/src/extensions/registry.js +10 -0
- package/dist/src/extensions/registry.js.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/parser/declarations/classes.js +7 -0
- package/dist/src/parser/declarations/classes.js.map +1 -1
- package/dist/src/parser/expressions.js +14 -1
- package/dist/src/parser/expressions.js.map +1 -1
- package/dist/src/parser/literals.js +6 -2
- package/dist/src/parser/literals.js.map +1 -1
- package/dist/tests/binder/binder.test.js +29 -0
- package/dist/tests/binder/binder.test.js.map +1 -1
- package/dist/tests/canonical.test.d.ts +1 -0
- package/dist/tests/canonical.test.js +19 -0
- package/dist/tests/canonical.test.js.map +1 -0
- package/dist/tests/checker/checker.test.d.ts +1 -0
- package/dist/tests/checker/checker.test.js +245 -0
- package/dist/tests/checker/checker.test.js.map +1 -0
- package/dist/tests/cli/check.test.js +20 -0
- package/dist/tests/cli/check.test.js.map +1 -1
- package/dist/tests/conformance/matrix.test.d.ts +6 -0
- package/dist/tests/conformance/matrix.test.js +23 -0
- package/dist/tests/conformance/matrix.test.js.map +1 -0
- package/dist/tests/conformance/test262/manifest.d.ts +115 -0
- package/dist/tests/conformance/test262/manifest.js +257 -0
- package/dist/tests/conformance/test262/manifest.js.map +1 -0
- package/dist/tests/conformance/test262.test.d.ts +11 -0
- package/dist/tests/conformance/test262.test.js +74 -0
- package/dist/tests/conformance/test262.test.js.map +1 -0
- package/dist/tests/docs/structure.test.js +9 -11
- package/dist/tests/docs/structure.test.js.map +1 -1
- package/dist/tests/e2e/child-process.test.js +3 -2
- package/dist/tests/e2e/child-process.test.js.map +1 -1
- package/dist/tests/e2e/compile-builtins.test.js +45 -0
- package/dist/tests/e2e/compile-builtins.test.js.map +1 -1
- package/dist/tests/e2e/compile-objects-classes.test.js +77 -0
- package/dist/tests/e2e/compile-objects-classes.test.js.map +1 -1
- package/dist/tests/e2e/differential-syntax.test.d.ts +5 -0
- package/dist/tests/e2e/differential-syntax.test.js +95 -0
- package/dist/tests/e2e/differential-syntax.test.js.map +1 -0
- package/dist/tests/e2e/differential-values.test.js +15 -0
- package/dist/tests/e2e/differential-values.test.js.map +1 -1
- package/dist/tests/e2e/gui-browser.test.d.ts +13 -0
- package/dist/tests/e2e/gui-browser.test.js +163 -0
- package/dist/tests/e2e/gui-browser.test.js.map +1 -0
- package/dist/tests/e2e/gui-effects.test.d.ts +6 -0
- package/dist/tests/e2e/gui-effects.test.js +262 -0
- package/dist/tests/e2e/gui-effects.test.js.map +1 -0
- package/dist/tests/e2e/gui-example-browser.test.js +2 -2
- package/dist/tests/e2e/gui-example-browser.test.js.map +1 -1
- package/dist/tests/e2e/gui-example-canvas.test.js +5 -4
- package/dist/tests/e2e/gui-example-canvas.test.js.map +1 -1
- package/dist/tests/e2e/gui-example-svg.test.js +4 -3
- package/dist/tests/e2e/gui-example-svg.test.js.map +1 -1
- package/dist/tests/e2e/gui-example-webgl.test.d.ts +10 -0
- package/dist/tests/e2e/gui-example-webgl.test.js +75 -0
- package/dist/tests/e2e/gui-example-webgl.test.js.map +1 -0
- package/dist/tests/e2e/gui-example-webgl2.test.d.ts +8 -0
- package/dist/tests/e2e/gui-example-webgl2.test.js +72 -0
- package/dist/tests/e2e/gui-example-webgl2.test.js.map +1 -0
- package/dist/tests/e2e/gui-example.test.js +4 -3
- package/dist/tests/e2e/gui-example.test.js.map +1 -1
- package/dist/tests/e2e/gui-helpers.js +4 -3
- package/dist/tests/e2e/gui-helpers.js.map +1 -1
- package/dist/tests/e2e/gui-layout.test.js +48 -0
- package/dist/tests/e2e/gui-layout.test.js.map +1 -1
- package/dist/tests/e2e/gui-media.test.js +10 -8
- package/dist/tests/e2e/gui-media.test.js.map +1 -1
- package/dist/tests/e2e/gui-webgl.test.d.ts +11 -0
- package/dist/tests/e2e/gui-webgl.test.js +179 -0
- package/dist/tests/e2e/gui-webgl.test.js.map +1 -0
- package/dist/tests/e2e/gui-webgl2.test.d.ts +10 -0
- package/dist/tests/e2e/gui-webgl2.test.js +238 -0
- package/dist/tests/e2e/gui-webgl2.test.js.map +1 -0
- package/dist/tests/e2e/harness.d.ts +9 -0
- package/dist/tests/e2e/harness.js +14 -2
- package/dist/tests/e2e/harness.js.map +1 -1
- package/dist/tests/e2e/native-extensions.test.js +2 -1
- package/dist/tests/e2e/native-extensions.test.js.map +1 -1
- package/dist/tests/e2e/property-descriptors.test.js +20 -0
- package/dist/tests/e2e/property-descriptors.test.js.map +1 -1
- package/dist/tests/e2e/unicode-output.test.js +5 -3
- package/dist/tests/e2e/unicode-output.test.js.map +1 -1
- package/dist/tests/e2e/weak-collections.test.js +16 -2
- package/dist/tests/e2e/weak-collections.test.js.map +1 -1
- package/dist/tests/extensions/gui.test.js +41 -0
- package/dist/tests/extensions/gui.test.js.map +1 -1
- package/dist/tests/extensions/media.test.js +7 -3
- package/dist/tests/extensions/media.test.js.map +1 -1
- package/dist/tests/helpers.d.ts +1 -0
- package/dist/tests/helpers.js +1 -0
- package/dist/tests/helpers.js.map +1 -1
- package/dist/tests/parser/declarations.test.js +20 -0
- package/dist/tests/parser/declarations.test.js.map +1 -1
- package/dist/tests/parser/expressions.test.js +36 -0
- package/dist/tests/parser/expressions.test.js.map +1 -1
- package/dist/tests/platform.d.ts +32 -0
- package/dist/tests/platform.js +40 -0
- package/dist/tests/platform.js.map +1 -0
- package/dist/tests/platform.test.d.ts +12 -0
- package/dist/tests/platform.test.js +51 -0
- package/dist/tests/platform.test.js.map +1 -0
- package/dist/tests/version.test.js +4 -4
- package/dist/tests/version.test.js.map +1 -1
- package/doc/ai/README.md +10 -4
- package/doc/ai/build-recipe.md +1 -0
- package/doc/ai/cli.md +17 -5
- package/doc/ai/contributing.md +59 -2
- package/doc/ai/extensions.md +38 -7
- package/doc/ai/language-support.md +25 -16
- package/doc/ai/troubleshooting.md +12 -8
- package/doc/ai/zh-CN/README.md +9 -4
- package/doc/ai/zh-CN/build-recipe.md +1 -0
- package/doc/ai/zh-CN/cli.md +13 -3
- package/doc/ai/zh-CN/contributing.md +49 -3
- package/doc/ai/zh-CN/extensions.md +33 -6
- package/doc/ai/zh-CN/language-support.md +23 -14
- package/doc/ai/zh-CN/troubleshooting.md +10 -6
- package/doc/gui/api.md +47 -1
- package/doc/gui/build.md +72 -16
- package/doc/gui/canvas.md +11 -3
- package/doc/gui/dom.md +33 -18
- package/doc/gui/known-issues.md +58 -15
- package/doc/gui/layout.md +18 -0
- package/doc/gui/media.md +17 -13
- package/doc/gui/rendering.md +50 -3
- package/doc/gui/runtime.md +18 -0
- package/doc/gui/webgl.md +256 -0
- package/doc/gui-scripts.md +7 -0
- package/doc/gui.md +108 -17
- package/doc/implemented/binder.md +2 -0
- package/doc/implemented/checker.md +117 -0
- package/doc/implemented/cli.md +13 -1
- package/doc/implemented/codegen.md +3 -2
- package/doc/implemented/driver.md +2 -2
- package/doc/implemented/operators.md +2 -1
- package/doc/implemented/parser.md +3 -2
- package/doc/implemented/pipeline.md +8 -1
- package/doc/implemented/stdlib.md +2 -1
- package/doc/implemented/tests.md +3 -1
- package/doc/implemented.md +2 -0
- package/doc/npm-package.md +419 -0
- package/doc/requirements.md +22 -10
- package/doc/support-matrix.md +83 -0
- package/doc/unimplemented/classes.md +3 -0
- package/doc/unimplemented/deviations.md +3 -2
- package/doc/unimplemented/toolchain.md +1 -1
- package/doc/unimplemented/types.md +24 -8
- package/doc/unimplemented.md +1 -1
- package/doc/zh-CN/gui/api.md +43 -1
- package/doc/zh-CN/gui/build.md +64 -15
- package/doc/zh-CN/gui/canvas.md +9 -2
- package/doc/zh-CN/gui/dom.md +20 -7
- package/doc/zh-CN/gui/known-issues.md +46 -13
- package/doc/zh-CN/gui/layout.md +14 -0
- package/doc/zh-CN/gui/media.md +15 -11
- package/doc/zh-CN/gui/rendering.md +41 -4
- package/doc/zh-CN/gui/runtime.md +16 -0
- package/doc/zh-CN/gui/webgl.md +115 -0
- package/doc/zh-CN/gui-scripts.md +5 -0
- package/doc/zh-CN/gui.md +89 -14
- package/doc/zh-CN/implemented/binder.md +2 -0
- package/doc/zh-CN/implemented/checker.md +99 -0
- package/doc/zh-CN/implemented/cli.md +12 -1
- package/doc/zh-CN/implemented/codegen.md +3 -2
- package/doc/zh-CN/implemented/driver.md +2 -2
- package/doc/zh-CN/implemented/operators.md +1 -1
- package/doc/zh-CN/implemented/parser.md +3 -2
- package/doc/zh-CN/implemented/pipeline.md +3 -1
- package/doc/zh-CN/implemented/stdlib.md +2 -1
- package/doc/zh-CN/implemented/tests.md +3 -1
- package/doc/zh-CN/implemented.md +2 -0
- package/doc/zh-CN/npm-package.md +394 -0
- package/doc/zh-CN/post/announce.md +47 -47
- package/doc/zh-CN/requirements.md +16 -7
- package/doc/zh-CN/support-matrix.md +82 -0
- package/doc/zh-CN/unimplemented/classes.md +3 -0
- package/doc/zh-CN/unimplemented/deviations.md +3 -2
- package/doc/zh-CN/unimplemented/toolchain.md +1 -1
- package/doc/zh-CN/unimplemented/types.md +16 -6
- package/doc/zh-CN/unimplemented.md +1 -1
- package/llms.txt +6 -1
- package/package.json +2 -1
- package/runtime/ext_gui/audio.cpp +316 -0
- package/runtime/ext_gui/browser.cpp +573 -0
- package/runtime/ext_gui/browser_escape.cpp +85 -0
- package/runtime/ext_gui/browser_loop.cpp +83 -0
- package/runtime/ext_gui/canvas.cpp +12 -21
- package/runtime/ext_gui/canvas_internal.h +10 -0
- package/runtime/ext_gui/canvas_raster.cpp +79 -1
- package/runtime/ext_gui/clip_values.cpp +246 -0
- package/runtime/ext_gui/css.cpp +94 -0
- package/runtime/ext_gui/css.h +22 -1
- package/runtime/ext_gui/css_match.cpp +3 -0
- package/runtime/ext_gui/css_selector.cpp +9 -0
- package/runtime/ext_gui/css_sheet.cpp +89 -45
- package/runtime/ext_gui/document.cpp +4 -1
- package/runtime/ext_gui/document.h +2 -0
- package/runtime/ext_gui/dom.h +16 -0
- package/runtime/ext_gui/dom_api.cpp +37 -0
- package/runtime/ext_gui/dom_api_canvas.cpp +17 -80
- package/runtime/ext_gui/dom_api_canvas_extra.cpp +130 -1
- package/runtime/ext_gui/dom_api_canvas_pending.cpp +41 -0
- package/runtime/ext_gui/dom_api_document.cpp +96 -5
- package/runtime/ext_gui/dom_api_events.cpp +20 -0
- package/runtime/ext_gui/dom_api_internal.h +278 -0
- package/runtime/ext_gui/dom_api_proto.cpp +6 -0
- package/runtime/ext_gui/dom_api_webgl.cpp +376 -0
- package/runtime/ext_gui/dom_api_webgl2.cpp +434 -0
- package/runtime/ext_gui/dom_api_webgl2_draw.cpp +269 -0
- package/runtime/ext_gui/dom_api_webgl_buffer.cpp +212 -0
- package/runtime/ext_gui/dom_api_webgl_rt.h +30 -0
- package/runtime/ext_gui/dom_api_webgl_shader.cpp +443 -0
- package/runtime/ext_gui/dom_api_webgl_state.cpp +444 -0
- package/runtime/ext_gui/dom_api_webgl_texture.cpp +445 -0
- package/runtime/ext_gui/effect_values.cpp +312 -0
- package/runtime/ext_gui/gradient_values.cpp +476 -0
- package/runtime/ext_gui/grid_values.cpp +230 -0
- package/runtime/ext_gui/gui.cpp +90 -23
- package/runtime/ext_gui/gui_canvas.cpp +50 -2
- package/runtime/ext_gui/gui_engine.h +71 -0
- package/runtime/ext_gui/gui_events.cpp +4 -1
- package/runtime/ext_gui/gui_media.cpp +1 -1
- package/runtime/ext_gui/gui_webgl.cpp +83 -0
- package/runtime/ext_gui/layout.cpp +21 -0
- package/runtime/ext_gui/layout_flow.cpp +81 -4
- package/runtime/ext_gui/layout_flow_internal.h +31 -0
- package/runtime/ext_gui/layout_grid.cpp +374 -0
- package/runtime/ext_gui/media.h +1 -1
- package/runtime/ext_gui/media_api.h +2 -2
- package/runtime/ext_gui/media_query.cpp +211 -0
- package/runtime/ext_gui/paint.cpp +111 -77
- package/runtime/ext_gui/paint.h +33 -3
- package/runtime/ext_gui/paint_background.cpp +229 -0
- package/runtime/ext_gui/paint_clip.cpp +268 -0
- package/runtime/ext_gui/paint_effects.cpp +324 -0
- package/runtime/ext_gui/paint_internal.h +85 -0
- package/runtime/ext_gui/renderer.cpp +8 -31
- package/runtime/ext_gui/renderer_clip.cpp +196 -0
- package/runtime/ext_gui/renderer_image.cpp +13 -8
- package/runtime/ext_gui/renderer_internal.h +15 -8
- package/runtime/ext_gui/renderer_text.cpp +6 -31
- package/runtime/ext_gui/style.cpp +343 -20
- package/runtime/ext_gui/style.h +144 -3
- package/runtime/ext_gui/style_print.cpp +134 -1
- package/runtime/ext_gui/style_values.cpp +152 -126
- package/runtime/ext_gui/style_values_internal.h +35 -0
- package/runtime/ext_gui/webgl.h +466 -0
- package/runtime/ext_gui/webgl2_constants.h +274 -0
- package/runtime/ext_gui/webgl_buffer.cpp +565 -0
- package/runtime/ext_gui/webgl_constants.h +317 -0
- package/runtime/ext_gui/webgl_context.cpp +466 -0
- package/runtime/ext_gui/webgl_draw.cpp +495 -0
- package/runtime/ext_gui/webgl_glsl.h +125 -0
- package/runtime/ext_gui/webgl_glsl_compile.cpp +431 -0
- package/runtime/ext_gui/webgl_glsl_rewrite.cpp +349 -0
- package/runtime/ext_gui/webgl_glsl_scan.cpp +581 -0
- package/runtime/ext_gui/webgl_msl.cpp +62 -0
- package/runtime/ext_gui/webgl_msl.h +33 -0
- package/runtime/ext_gui/webgl_pipeline.cpp +274 -0
- package/runtime/ext_gui/webgl_program_internal.h +18 -0
- package/runtime/ext_gui/webgl_shader.cpp +582 -0
- package/runtime/ext_gui/webgl_texture.cpp +293 -0
- package/runtime/ext_gui/webgl_uniform.cpp +167 -0
- package/runtime/ext_gui/webgl_webgl2.cpp +224 -0
- package/runtime/ext_gui/window.cpp +9 -0
- package/runtime/ext_media/media.cpp +1 -1
- package/runtime/ext_media/media_bridge.c +9 -3
- package/runtime/ext_node/path/path.c +7 -7
- package/runtime/ext_node/url/url.c +4 -2
- package/runtime/rt.h +15 -0
- package/runtime/rt_internal.h +1 -0
- package/runtime/xt_constructors.c +2 -1
- package/runtime/xt_containers/access.inc +8 -0
- package/runtime/xt_containers/objects.inc +22 -2
- package/runtime/xt_io/exception.inc +4 -2
- package/runtime/xt_regex/api.inc +2 -0
- package/runtime/xt_regex/matcher.inc +16 -3
- package/runtime/xt_regex/parser.inc +8 -2
- package/runtime/xt_regex/types.inc +3 -0
- package/runtime/xt_stdlib/math.inc +62 -0
- package/runtime/xt_stdlib2/date.inc +7 -1
- package/runtime/xt_stdlib2/objects.inc +14 -0
- package/runtime/xt_stdlib2/regexp-match.inc +60 -21
- package/runtime/xt_stdlib2/regexp.inc +1 -0
- package/runtime/xt_typed_array.c +1 -1
- package/scripts/build-gui.ts +90 -3
- package/scripts/build-media.ts +323 -58
- package/scripts/setup-vs-toolchain.ps1 +152 -0
- package/scripts/support-matrix.ts +167 -0
- package/src/ast/common.ts +2 -0
- package/src/ast/declarations.ts +12 -1
- package/src/ast/expressions.ts +6 -0
- package/src/ast/kinds.ts +2 -0
- package/src/binder/binder.ts +3 -0
- package/src/binder/declarations.ts +70 -0
- package/src/binder/references.ts +97 -4
- package/src/binder/types.ts +30 -0
- package/src/canonical.ts +37 -0
- package/src/checker/assignability.ts +134 -0
- package/src/checker/calls.ts +135 -0
- package/src/checker/checker.ts +47 -0
- package/src/checker/declarations.ts +26 -0
- package/src/checker/flow.ts +236 -0
- package/src/checker/globals.ts +40 -0
- package/src/checker/source.ts +53 -0
- package/src/checker/type-infer.ts +185 -0
- package/src/checker/type-model.ts +212 -0
- package/src/checker/type-system.ts +578 -0
- package/src/checker/typecheck-types.ts +112 -0
- package/src/checker/typecheck.ts +586 -0
- package/src/checker/undefined.ts +43 -0
- package/src/checker/walk.ts +16 -0
- package/src/cli/help.ts +65 -0
- package/src/cli/hints.ts +2 -1
- package/src/cli/main.ts +12 -49
- package/src/codegen/generator/calls/access.ts +8 -8
- package/src/codegen/generator/calls/invocation.ts +8 -5
- package/src/codegen/generator/calls/super.ts +67 -5
- package/src/codegen/generator/context.ts +31 -19
- package/src/codegen/generator/debug.ts +2 -1
- package/src/codegen/generator/expressions/primary.ts +84 -13
- package/src/codegen/generator/generator.ts +11 -1
- package/src/codegen/generator/module.ts +115 -24
- package/src/codegen/generator/state.ts +11 -1
- package/src/codegen/generator/statements/variables.ts +26 -6
- package/src/codegen/generator/tables.ts +5 -0
- package/src/driver/build-key.ts +3 -0
- package/src/driver/bundler/graph.ts +6 -2
- package/src/driver/bundler/merge.ts +14 -1
- package/src/driver/bundler/types.ts +13 -0
- package/src/driver/compiler.ts +4 -1
- package/src/driver/fingerprint.ts +2 -1
- package/src/driver/frontend.ts +13 -2
- package/src/driver/options.ts +6 -0
- package/src/driver/version.ts +1 -1
- package/src/extensions/gui/css.ts +113 -0
- package/src/extensions/gui/html.ts +31 -11
- package/src/extensions/gui/index.ts +81 -2
- package/src/extensions/gui/three.ts +25 -0
- package/src/extensions/media/index.ts +13 -16
- package/src/extensions/registry.ts +48 -0
- package/src/index.ts +1 -0
- package/src/parser/declarations/classes.ts +7 -0
- package/src/parser/expressions.ts +13 -1
- package/src/parser/literals.ts +6 -2
|
@@ -0,0 +1,466 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* xbintsc GUI engine — WebGL 1.0 context on SDL_GPU.
|
|
3
|
+
*
|
|
4
|
+
* A `WebGLContext` owns one offscreen RGBA8 colour texture (plus a depth
|
|
5
|
+
* texture) and records GPU work into its own SDL_GPU command buffer. The
|
|
6
|
+
* texture the page composites is that colour target, so a draw reaches the
|
|
7
|
+
* screen without a CPU round-trip: geometry, lighting, texture sampling and
|
|
8
|
+
* blending all execute on the GPU.
|
|
9
|
+
*
|
|
10
|
+
* WebGL's origin is bottom-left while SDL_GPU render targets use a top-left
|
|
11
|
+
* origin (its Vulkan backend flips the viewport), so the framebuffer is stored
|
|
12
|
+
* top-down; `viewport`/`scissor` are converted and `readPixels` flips rows back
|
|
13
|
+
* to the GL convention.
|
|
14
|
+
*
|
|
15
|
+
* Shaders are translated to SPIR-V by `webgl_glsl.cpp` (glslang). Pipeline
|
|
16
|
+
* objects depend on the vertex layout and fixed-function state, so they are
|
|
17
|
+
* created lazily per (program, layout, state) combination and cached.
|
|
18
|
+
*
|
|
19
|
+
* Handles are integer ids, not pointers: a `deleteBuffer`/`deleteTexture` call
|
|
20
|
+
* must make an old JavaScript handle a no-op rather than a dangling pointer.
|
|
21
|
+
*/
|
|
22
|
+
#ifndef XT_GUI_WEBGL_H
|
|
23
|
+
#define XT_GUI_WEBGL_H
|
|
24
|
+
|
|
25
|
+
#include <SDL3/SDL.h>
|
|
26
|
+
|
|
27
|
+
#include <cstdint>
|
|
28
|
+
#include <memory>
|
|
29
|
+
#include <string>
|
|
30
|
+
#include <unordered_map>
|
|
31
|
+
#include <vector>
|
|
32
|
+
|
|
33
|
+
#include "webgl_constants.h"
|
|
34
|
+
#include "webgl2_constants.h"
|
|
35
|
+
#include "webgl_glsl.h"
|
|
36
|
+
|
|
37
|
+
namespace xtgui {
|
|
38
|
+
|
|
39
|
+
constexpr int kWebGLMaxAttribs = 16;
|
|
40
|
+
constexpr int kWebGLMaxTextureUnits = 16;
|
|
41
|
+
|
|
42
|
+
struct WebGLShader {
|
|
43
|
+
uint32_t id = 0;
|
|
44
|
+
int type = 0; // GL_VERTEX_SHADER / GL_FRAGMENT_SHADER
|
|
45
|
+
std::string source;
|
|
46
|
+
std::string log;
|
|
47
|
+
bool compiled = false;
|
|
48
|
+
bool delete_requested = false;
|
|
49
|
+
int attachments = 0;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/** One active uniform of a linked program, with its std140 home. */
|
|
53
|
+
struct WebGLUniform {
|
|
54
|
+
std::string name;
|
|
55
|
+
GlslBlockMember layout;
|
|
56
|
+
bool sampler = false;
|
|
57
|
+
int unit = -1;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
struct WebGLProgram {
|
|
61
|
+
uint32_t id = 0;
|
|
62
|
+
uint32_t vs = 0;
|
|
63
|
+
uint32_t fs = 0;
|
|
64
|
+
bool linked = false;
|
|
65
|
+
std::string log;
|
|
66
|
+
std::vector<WebGLUniform> uniforms;
|
|
67
|
+
std::vector<GlslUniformDecl> attribs;
|
|
68
|
+
std::unordered_map<std::string, int> attrib_locations; // name -> location
|
|
69
|
+
std::unordered_map<std::string, int> attrib_bindings; // bindAttribLocation overrides
|
|
70
|
+
std::unordered_map<std::string, int> uniform_index; // name -> uniforms[] index
|
|
71
|
+
std::vector<int> vs_sampler_uniforms; // local binding -> uniforms[] index
|
|
72
|
+
std::vector<int> fs_sampler_uniforms;
|
|
73
|
+
std::vector<uint8_t> block; // std140 uniform data
|
|
74
|
+
int block_size = 0;
|
|
75
|
+
bool block_dirty = true;
|
|
76
|
+
bool vs_has_block = false;
|
|
77
|
+
bool fs_has_block = false;
|
|
78
|
+
SDL_GPUShader *vs_shader = nullptr;
|
|
79
|
+
SDL_GPUShader *fs_shader = nullptr;
|
|
80
|
+
std::vector<SDL_GPUGraphicsPipeline *> pipelines;
|
|
81
|
+
std::unordered_map<std::string, SDL_GPUGraphicsPipeline *> pipeline_cache;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
struct WebGLBuffer {
|
|
85
|
+
uint32_t id = 0;
|
|
86
|
+
std::vector<uint8_t> data;
|
|
87
|
+
SDL_GPUBuffer *gpu = nullptr;
|
|
88
|
+
uint32_t capacity = 0;
|
|
89
|
+
bool dirty = true;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
struct WebGLTexture {
|
|
93
|
+
uint32_t id = 0;
|
|
94
|
+
int width = 0;
|
|
95
|
+
int height = 0;
|
|
96
|
+
int levels = 1;
|
|
97
|
+
SDL_GPUTexture *gpu = nullptr;
|
|
98
|
+
SDL_GPUTextureFormat format = SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM;
|
|
99
|
+
bool as_target = false;
|
|
100
|
+
bool has_mipmaps = false;
|
|
101
|
+
int min_filter = 0;
|
|
102
|
+
int mag_filter = 0;
|
|
103
|
+
int wrap_s = 0;
|
|
104
|
+
int wrap_t = 0;
|
|
105
|
+
SDL_GPUSampler *sampler = nullptr;
|
|
106
|
+
bool dirty = false;
|
|
107
|
+
bool defined = false;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
struct WebGLRenderbuffer {
|
|
111
|
+
uint32_t id = 0;
|
|
112
|
+
int width = 0;
|
|
113
|
+
int height = 0;
|
|
114
|
+
bool stencil = false;
|
|
115
|
+
SDL_GPUTexture *depth = nullptr;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
struct WebGLFramebuffer {
|
|
119
|
+
uint32_t id = 0;
|
|
120
|
+
uint32_t color_texture = 0;
|
|
121
|
+
uint32_t depth_renderbuffer = 0;
|
|
122
|
+
int width = 0;
|
|
123
|
+
int height = 0;
|
|
124
|
+
SDL_GPUTexture *depth = nullptr; // owned when no renderbuffer supplies one
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
/** Per-attribute array state. */
|
|
128
|
+
struct WebGLAttribState {
|
|
129
|
+
bool enabled = false;
|
|
130
|
+
bool integer = false; // `vertexAttribIPointer` rather than `vertexAttribPointer`
|
|
131
|
+
uint32_t buffer = 0;
|
|
132
|
+
int size = 4;
|
|
133
|
+
int type = GL_FLOAT;
|
|
134
|
+
bool normalized = false;
|
|
135
|
+
int stride = 0;
|
|
136
|
+
int offset = 0;
|
|
137
|
+
int divisor = 0; // 0 = per vertex, 1 = per instance
|
|
138
|
+
float current[4] = {0.0f, 0.0f, 0.0f, 1.0f};
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
/** A WebGL 2 vertex-array object: the attribute table plus its element buffer.
|
|
142
|
+
* SDL_GPU has no VAO concept, so binding one restores this state into the live
|
|
143
|
+
* `attribs_` array. */
|
|
144
|
+
struct WebGLVertexArray {
|
|
145
|
+
uint32_t id = 0;
|
|
146
|
+
WebGLAttribState attribs[kWebGLMaxAttribs];
|
|
147
|
+
uint32_t element_buffer = 0;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
/** A WebGL 2 sampler object, bound to a texture unit with `bindSampler`. */
|
|
151
|
+
struct WebGLSampler {
|
|
152
|
+
uint32_t id = 0;
|
|
153
|
+
int min_filter = 0;
|
|
154
|
+
int mag_filter = 0;
|
|
155
|
+
int wrap_s = 0;
|
|
156
|
+
int wrap_t = 0;
|
|
157
|
+
SDL_GPUSampler *gpu = nullptr;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
struct WebGLQuery {
|
|
161
|
+
uint32_t id = 0;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
struct WebGLSync {
|
|
165
|
+
uint32_t id = 0;
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
/** The fixed-function state a pipeline depends on. */
|
|
169
|
+
struct WebGLDrawState {
|
|
170
|
+
bool blend = false;
|
|
171
|
+
int blend_src_rgb = GL_ONE;
|
|
172
|
+
int blend_dst_rgb = GL_ZERO;
|
|
173
|
+
int blend_src_alpha = GL_ONE;
|
|
174
|
+
int blend_dst_alpha = GL_ZERO;
|
|
175
|
+
int blend_eq_rgb = GL_FUNC_ADD;
|
|
176
|
+
int blend_eq_alpha = GL_FUNC_ADD;
|
|
177
|
+
bool depth_test = false;
|
|
178
|
+
bool depth_write = true;
|
|
179
|
+
int depth_func = GL_LESS;
|
|
180
|
+
bool cull = false;
|
|
181
|
+
int cull_face = GL_BACK;
|
|
182
|
+
int front_face = GL_CCW;
|
|
183
|
+
bool color_mask[4] = {true, true, true, true};
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
class WebGLContext {
|
|
187
|
+
public:
|
|
188
|
+
WebGLContext(uint64_t id, int width, int height, bool webgl2);
|
|
189
|
+
~WebGLContext();
|
|
190
|
+
|
|
191
|
+
uint64_t id() const { return id_; }
|
|
192
|
+
bool is_webgl2() const { return webgl2_; }
|
|
193
|
+
int width() const { return width_; }
|
|
194
|
+
int height() const { return height_; }
|
|
195
|
+
/** Resize the drawing buffer; GL semantics discard its contents. */
|
|
196
|
+
void resize(int width, int height);
|
|
197
|
+
|
|
198
|
+
/** End the current pass and submit the queued commands (called once per
|
|
199
|
+
* frame, before the page's own render pass samples the colour texture). */
|
|
200
|
+
void submit();
|
|
201
|
+
SDL_GPUTexture *color_texture();
|
|
202
|
+
bool lost() const { return lost_; }
|
|
203
|
+
|
|
204
|
+
/* -- object lookups ---------------------------------------------------- */
|
|
205
|
+
WebGLShader *shader(uint32_t id);
|
|
206
|
+
WebGLProgram *program(uint32_t id);
|
|
207
|
+
WebGLBuffer *buffer(uint32_t id);
|
|
208
|
+
WebGLTexture *texture(uint32_t id);
|
|
209
|
+
WebGLFramebuffer *framebuffer(uint32_t id);
|
|
210
|
+
WebGLRenderbuffer *renderbuffer(uint32_t id);
|
|
211
|
+
WebGLVertexArray *vertex_array(uint32_t id);
|
|
212
|
+
WebGLSampler *sampler(uint32_t id);
|
|
213
|
+
WebGLQuery *query(uint32_t id);
|
|
214
|
+
WebGLSync *sync(uint32_t id);
|
|
215
|
+
|
|
216
|
+
/* -- state ------------------------------------------------------------- */
|
|
217
|
+
void enable(int cap);
|
|
218
|
+
void disable(int cap);
|
|
219
|
+
bool is_enabled(int cap) const;
|
|
220
|
+
void clear_color(float r, float g, float b, float a);
|
|
221
|
+
void clear_depth(float depth) { clear_depth_ = depth; }
|
|
222
|
+
void clear_stencil(int value) { clear_stencil_ = value; }
|
|
223
|
+
void color_mask(bool r, bool g, bool b, bool a);
|
|
224
|
+
void depth_mask(bool write) { state_.depth_write = write; }
|
|
225
|
+
void depth_func(int func) { state_.depth_func = func; }
|
|
226
|
+
void blend_func(int src, int dst);
|
|
227
|
+
void blend_func_separate(int src_rgb, int dst_rgb, int src_alpha, int dst_alpha);
|
|
228
|
+
void blend_equation(int mode);
|
|
229
|
+
void blend_equation_separate(int rgb, int alpha);
|
|
230
|
+
void cull_face(int mode);
|
|
231
|
+
void front_face(int mode);
|
|
232
|
+
void viewport(int x, int y, int w, int h);
|
|
233
|
+
void scissor(int x, int y, int w, int h);
|
|
234
|
+
void clear(int mask);
|
|
235
|
+
void finish();
|
|
236
|
+
|
|
237
|
+
/* -- shaders and programs --------------------------------------------- */
|
|
238
|
+
uint32_t create_shader(int type);
|
|
239
|
+
void delete_shader(uint32_t id);
|
|
240
|
+
void shader_source(uint32_t id, const std::string &source);
|
|
241
|
+
bool compile_shader(uint32_t id);
|
|
242
|
+
std::string shader_info_log(uint32_t id);
|
|
243
|
+
bool shader_compiled(uint32_t id);
|
|
244
|
+
std::string shader_source_text(uint32_t id);
|
|
245
|
+
|
|
246
|
+
uint32_t create_program();
|
|
247
|
+
void delete_program(uint32_t id);
|
|
248
|
+
bool attach_shader(uint32_t program, uint32_t shader);
|
|
249
|
+
bool detach_shader(uint32_t program, uint32_t shader);
|
|
250
|
+
bool link_program(uint32_t id);
|
|
251
|
+
void use_program(uint32_t id);
|
|
252
|
+
bool program_linked(uint32_t id);
|
|
253
|
+
std::string program_info_log(uint32_t id);
|
|
254
|
+
std::vector<uint32_t> attached_shaders(uint32_t id);
|
|
255
|
+
int active_uniform_count(uint32_t id);
|
|
256
|
+
int active_attrib_count(uint32_t id);
|
|
257
|
+
const WebGLUniform *active_uniform(uint32_t id, int index);
|
|
258
|
+
const GlslUniformDecl *active_attrib(uint32_t id, int index);
|
|
259
|
+
|
|
260
|
+
int uniform_location(uint32_t program, const std::string &name);
|
|
261
|
+
int attrib_location(uint32_t program, const std::string &name);
|
|
262
|
+
void bind_attrib_location(uint32_t program, int index, const std::string &name);
|
|
263
|
+
|
|
264
|
+
/* Uniform uploads: `location` is an index into the program's uniform table
|
|
265
|
+
* (the DOM layer wraps it in the `WebGLUniformLocation` handle). */
|
|
266
|
+
void uniform_floats(uint32_t program, int location, int components, const double *values,
|
|
267
|
+
int count);
|
|
268
|
+
void uniform_ints(uint32_t program, int location, int components, const int *values, int count);
|
|
269
|
+
void uniform_matrix(uint32_t program, int location, int dimensions, const double *values);
|
|
270
|
+
bool uniform_values(uint32_t program, int location, std::vector<double> *out);
|
|
271
|
+
|
|
272
|
+
/* -- buffers and vertex attributes ------------------------------------ */
|
|
273
|
+
uint32_t create_buffer();
|
|
274
|
+
void delete_buffer(uint32_t id);
|
|
275
|
+
void bind_buffer(int target, uint32_t id);
|
|
276
|
+
bool buffer_data(uint32_t id, const uint8_t *bytes, uint32_t size, int usage);
|
|
277
|
+
bool buffer_sub_data(uint32_t id, uint32_t offset, const uint8_t *bytes, uint32_t size);
|
|
278
|
+
uint32_t buffer_size(uint32_t id);
|
|
279
|
+
void enable_attrib(int index, bool enabled);
|
|
280
|
+
bool attrib_enabled(int index) const;
|
|
281
|
+
void attrib_pointer(int index, int size, int type, bool normalized, int stride, int offset);
|
|
282
|
+
void attrib_value(int index, int components, const float *values);
|
|
283
|
+
void attrib_state(int index, int *size, int *type, int *stride, bool *normalized,
|
|
284
|
+
float current[4]) const;
|
|
285
|
+
uint32_t attrib_buffer(int index) const { return attribs_[index].buffer; }
|
|
286
|
+
void attrib_ipointer(int index, int size, int type, int stride, int offset);
|
|
287
|
+
void attrib_divisor(int index, int divisor);
|
|
288
|
+
|
|
289
|
+
/* -- WebGL 2 vertex arrays, instancing and buffer copies --------------- */
|
|
290
|
+
uint32_t create_vertex_array();
|
|
291
|
+
void delete_vertex_array(uint32_t id);
|
|
292
|
+
void bind_vertex_array(uint32_t id);
|
|
293
|
+
bool is_vertex_array(uint32_t id) const;
|
|
294
|
+
uint32_t bound_vertex_array() const { return bound_vertex_array_; }
|
|
295
|
+
void draw_arrays_instanced(int mode, int first, int count, int instances);
|
|
296
|
+
void draw_elements_instanced(int mode, int count, int type, int offset, int instances);
|
|
297
|
+
void draw_range_elements(int mode, int start, int end, int count, int type, int offset);
|
|
298
|
+
bool copy_buffer_sub_data(int read_target, int write_target, uint32_t read_offset,
|
|
299
|
+
uint32_t write_offset, uint32_t size);
|
|
300
|
+
bool get_buffer_sub_data(int target, uint32_t offset, uint8_t *out, uint32_t size);
|
|
301
|
+
|
|
302
|
+
/* -- WebGL 2 sampler objects ------------------------------------------- */
|
|
303
|
+
uint32_t create_sampler();
|
|
304
|
+
void delete_sampler(uint32_t id);
|
|
305
|
+
void bind_sampler(int unit, uint32_t id);
|
|
306
|
+
bool sampler_parameter(uint32_t id, int pname, int value);
|
|
307
|
+
int sampler_parameter_value(uint32_t id, int pname);
|
|
308
|
+
|
|
309
|
+
/* -- WebGL 2 queries, syncs and uniform-block stubs -------------------- */
|
|
310
|
+
uint32_t create_query();
|
|
311
|
+
void delete_query(uint32_t id);
|
|
312
|
+
bool is_query(uint32_t id) const;
|
|
313
|
+
uint32_t create_sync();
|
|
314
|
+
void delete_sync(uint32_t id);
|
|
315
|
+
bool is_sync(uint32_t id) const;
|
|
316
|
+
uint32_t uniform_block_index(uint32_t program, const std::string &name) const;
|
|
317
|
+
|
|
318
|
+
/* -- textures ---------------------------------------------------------- */
|
|
319
|
+
uint32_t create_texture();
|
|
320
|
+
void delete_texture(uint32_t id);
|
|
321
|
+
void bind_texture(int target, uint32_t id);
|
|
322
|
+
void active_texture(int unit);
|
|
323
|
+
bool tex_parameter(uint32_t texture, int pname, int value);
|
|
324
|
+
int tex_parameter_value(uint32_t id, int pname);
|
|
325
|
+
bool tex_image_rgba(uint32_t id, int width, int height, const uint8_t *rgba);
|
|
326
|
+
bool tex_sub_image_rgba(uint32_t id, int x, int y, int width, int height, const uint8_t *rgba);
|
|
327
|
+
bool generate_mipmap(uint32_t id);
|
|
328
|
+
/** WebGL 2 `texStorage2D`: allocate immutable storage at `width`×`height`.
|
|
329
|
+
* The backend always allocates the full mip chain, so `levels` is a hint. */
|
|
330
|
+
bool tex_storage_2d(uint32_t id, int levels, int width, int height);
|
|
331
|
+
int texture_width(uint32_t id);
|
|
332
|
+
|
|
333
|
+
/* -- framebuffers ------------------------------------------------------ */
|
|
334
|
+
uint32_t create_framebuffer();
|
|
335
|
+
void delete_framebuffer(uint32_t id);
|
|
336
|
+
void bind_framebuffer(uint32_t id);
|
|
337
|
+
bool framebuffer_texture(uint32_t framebuffer, uint32_t texture);
|
|
338
|
+
bool framebuffer_status(uint32_t id);
|
|
339
|
+
uint32_t create_renderbuffer();
|
|
340
|
+
void delete_renderbuffer(uint32_t id);
|
|
341
|
+
void bind_renderbuffer(uint32_t id) { bound_renderbuffer_ = id; }
|
|
342
|
+
bool renderbuffer_storage(uint32_t id, int width, int height, bool stencil);
|
|
343
|
+
bool framebuffer_renderbuffer(uint32_t framebuffer, uint32_t renderbuffer);
|
|
344
|
+
|
|
345
|
+
/* -- drawing ----------------------------------------------------------- */
|
|
346
|
+
void draw_arrays(int mode, int first, int count);
|
|
347
|
+
void draw_elements(int mode, int count, int type, int offset);
|
|
348
|
+
bool read_pixels(int x, int y, int width, int height, uint8_t *out);
|
|
349
|
+
/** WebGL 2 `clearBufferfv` / `clearBufferiv` / `clearBufferuiv`. */
|
|
350
|
+
void clear_buffer_float(int buffer, int drawbuffer, const float *values, int count);
|
|
351
|
+
void clear_buffer_int(int buffer, int drawbuffer, const int *values, int count);
|
|
352
|
+
void clear_buffer_uint(int buffer, int drawbuffer, const unsigned int *values, int count);
|
|
353
|
+
void clear_buffer_fi(int buffer, int drawbuffer, float depth, int stencil);
|
|
354
|
+
|
|
355
|
+
/* -- queries ----------------------------------------------------------- */
|
|
356
|
+
double parameter(int pname);
|
|
357
|
+
std::string string_parameter(int pname);
|
|
358
|
+
uint32_t bound_buffer(int target) const;
|
|
359
|
+
uint32_t bound_texture(int unit) const;
|
|
360
|
+
uint32_t current_program_id() const { return current_program_; }
|
|
361
|
+
uint32_t bound_framebuffer_id() const { return bound_framebuffer_; }
|
|
362
|
+
uint32_t bound_renderbuffer_id() const { return bound_renderbuffer_; }
|
|
363
|
+
void viewport_box(int out[4]) const;
|
|
364
|
+
void scissor_box(int out[4]) const;
|
|
365
|
+
int error() {
|
|
366
|
+
int value = error_;
|
|
367
|
+
error_ = 0;
|
|
368
|
+
return value;
|
|
369
|
+
}
|
|
370
|
+
void set_error(int value) {
|
|
371
|
+
if (error_ == 0) error_ = value;
|
|
372
|
+
}
|
|
373
|
+
const char *driver() const;
|
|
374
|
+
|
|
375
|
+
private:
|
|
376
|
+
/* -- GPU plumbing ------------------------------------------------------ */
|
|
377
|
+
void ensure_command();
|
|
378
|
+
void end_pass();
|
|
379
|
+
void flush_uploads();
|
|
380
|
+
void begin_pass(bool clear_color, bool clear_depth);
|
|
381
|
+
SDL_GPUTexture *target_color();
|
|
382
|
+
SDL_GPUTexture *target_depth();
|
|
383
|
+
SDL_GPUTexture *ensure_texture_gpu(WebGLTexture *texture, bool as_target);
|
|
384
|
+
SDL_GPUSampler *sampler_for(WebGLTexture *texture);
|
|
385
|
+
SDL_GPUBuffer *ensure_buffer_gpu(WebGLBuffer *buffer);
|
|
386
|
+
void ensure_default_target();
|
|
387
|
+
void rebuild_default_target();
|
|
388
|
+
bool ensure_fallback();
|
|
389
|
+
SDL_GPUBuffer *upload_temp_buffer(const void *data, uint32_t size,
|
|
390
|
+
SDL_GPUBufferUsageFlags usage);
|
|
391
|
+
void draw(int mode, int first, int count, int index_type, int offset, int instances);
|
|
392
|
+
void save_vertex_array();
|
|
393
|
+
void load_vertex_array(const WebGLVertexArray *array);
|
|
394
|
+
SDL_GPUSampler *sampler_gpu(WebGLSampler *sampler);
|
|
395
|
+
uint32_t buffer_for_target(int target) const;
|
|
396
|
+
void release_program_pipelines(WebGLProgram *program);
|
|
397
|
+
SDL_GPUGraphicsPipeline *create_pipeline(WebGLProgram *program, int mode, int index_type,
|
|
398
|
+
int attribute_count, int buffer_count,
|
|
399
|
+
const SDL_GPUVertexAttribute *attrs,
|
|
400
|
+
const SDL_GPUVertexBufferDescription *buffers,
|
|
401
|
+
const std::string &key);
|
|
402
|
+
|
|
403
|
+
uint64_t id_ = 0;
|
|
404
|
+
int width_ = 0;
|
|
405
|
+
int height_ = 0;
|
|
406
|
+
bool lost_ = false;
|
|
407
|
+
bool webgl2_ = false;
|
|
408
|
+
|
|
409
|
+
SDL_GPUCommandBuffer *cmd_ = nullptr;
|
|
410
|
+
SDL_GPURenderPass *pass_ = nullptr;
|
|
411
|
+
bool pass_targets_default_ = true;
|
|
412
|
+
uint32_t pass_framebuffer_ = 0;
|
|
413
|
+
|
|
414
|
+
SDL_GPUTexture *color_ = nullptr;
|
|
415
|
+
SDL_GPUTexture *depth_ = nullptr;
|
|
416
|
+
SDL_GPUTexture *fallback_texture_ = nullptr;
|
|
417
|
+
SDL_GPUSampler *fallback_sampler_ = nullptr;
|
|
418
|
+
|
|
419
|
+
float clear_color_[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
|
420
|
+
float clear_depth_ = 1.0f;
|
|
421
|
+
int clear_stencil_ = 0;
|
|
422
|
+
WebGLDrawState state_;
|
|
423
|
+
int viewport_[4] = {0, 0, 0, 0};
|
|
424
|
+
int scissor_box_[4] = {0, 0, 0, 0};
|
|
425
|
+
bool scissor_test_ = false;
|
|
426
|
+
bool stencil_test_ = false;
|
|
427
|
+
|
|
428
|
+
std::unordered_map<uint32_t, std::unique_ptr<WebGLShader>> shaders_;
|
|
429
|
+
std::unordered_map<uint32_t, std::unique_ptr<WebGLProgram>> programs_;
|
|
430
|
+
std::unordered_map<uint32_t, std::unique_ptr<WebGLBuffer>> buffers_;
|
|
431
|
+
std::unordered_map<uint32_t, std::unique_ptr<WebGLTexture>> textures_;
|
|
432
|
+
std::unordered_map<uint32_t, std::unique_ptr<WebGLFramebuffer>> framebuffers_;
|
|
433
|
+
std::unordered_map<uint32_t, std::unique_ptr<WebGLRenderbuffer>> renderbuffers_;
|
|
434
|
+
std::unordered_map<uint32_t, std::unique_ptr<WebGLVertexArray>> vertex_arrays_;
|
|
435
|
+
std::unordered_map<uint32_t, std::unique_ptr<WebGLSampler>> samplers_;
|
|
436
|
+
std::unordered_map<uint32_t, std::unique_ptr<WebGLQuery>> queries_;
|
|
437
|
+
std::unordered_map<uint32_t, std::unique_ptr<WebGLSync>> syncs_;
|
|
438
|
+
/** GPU buffers created for this context's transient draws (constant vertex
|
|
439
|
+
* attributes, expanded index data); released with the context. */
|
|
440
|
+
std::vector<SDL_GPUBuffer *> temp_buffers_;
|
|
441
|
+
|
|
442
|
+
uint32_t current_program_ = 0;
|
|
443
|
+
uint32_t bound_array_ = 0;
|
|
444
|
+
uint32_t bound_element_ = 0;
|
|
445
|
+
uint32_t bound_framebuffer_ = 0;
|
|
446
|
+
uint32_t bound_renderbuffer_ = 0;
|
|
447
|
+
uint32_t bound_textures_[kWebGLMaxTextureUnits] = {};
|
|
448
|
+
uint32_t bound_samplers_[kWebGLMaxTextureUnits] = {};
|
|
449
|
+
uint32_t bound_vertex_array_ = 0;
|
|
450
|
+
WebGLVertexArray default_vertex_array_;
|
|
451
|
+
uint32_t copy_read_buffer_ = 0;
|
|
452
|
+
uint32_t copy_write_buffer_ = 0;
|
|
453
|
+
int active_unit_ = 0;
|
|
454
|
+
WebGLAttribState attribs_[kWebGLMaxAttribs];
|
|
455
|
+
|
|
456
|
+
uint32_t next_object_id_ = 1;
|
|
457
|
+
int error_ = 0;
|
|
458
|
+
};
|
|
459
|
+
|
|
460
|
+
/** Resolve a process-wide WebGL context id (used by the renderer when it paints
|
|
461
|
+
* a `<canvas>`). */
|
|
462
|
+
WebGLContext *xt_webgl_by_id(uint64_t id);
|
|
463
|
+
|
|
464
|
+
} // namespace xtgui
|
|
465
|
+
|
|
466
|
+
#endif /* XT_GUI_WEBGL_H */
|