xbintsc 0.7.7 → 0.7.9
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/cli/help.d.ts +1 -1
- package/dist/src/cli/help.js +1 -1
- package/dist/src/codegen/generator/calls/invocation.js +6 -4
- package/dist/src/codegen/generator/calls/invocation.js.map +1 -1
- package/dist/src/codegen/generator/context.d.ts +4 -3
- package/dist/src/codegen/generator/context.js +6 -5
- package/dist/src/codegen/generator/context.js.map +1 -1
- package/dist/src/codegen/generator/expressions/assignment.js +3 -3
- package/dist/src/driver/config.d.ts +1 -1
- package/dist/src/driver/options.d.ts +1 -1
- package/dist/src/driver/version.d.ts +1 -1
- package/dist/src/driver/version.js +1 -1
- package/dist/src/extensions/gui/features.d.ts +14 -6
- package/dist/src/extensions/gui/features.js +34 -6
- package/dist/src/extensions/gui/features.js.map +1 -1
- package/dist/src/extensions/gui/index.js +3 -3
- package/dist/tests/codegen/llvm.test.js +1 -1
- package/dist/tests/e2e/gui-audio.test.js +24 -0
- package/dist/tests/e2e/gui-audio.test.js.map +1 -1
- package/dist/tests/e2e/gui-draw-perf.test.js +9 -0
- package/dist/tests/e2e/gui-draw-perf.test.js.map +1 -1
- package/dist/tests/e2e/gui-font-face.test.d.ts +3 -1
- package/dist/tests/e2e/gui-font-face.test.js +99 -7
- package/dist/tests/e2e/gui-font-face.test.js.map +1 -1
- package/dist/tests/e2e/gui-frame-pacing.test.d.ts +15 -0
- package/dist/tests/e2e/gui-frame-pacing.test.js +68 -0
- package/dist/tests/e2e/gui-frame-pacing.test.js.map +1 -0
- package/dist/tests/e2e/gui-initial-url.test.d.ts +10 -0
- package/dist/tests/e2e/gui-initial-url.test.js +49 -0
- package/dist/tests/e2e/gui-initial-url.test.js.map +1 -0
- package/dist/tests/e2e/gui-layout.test.js +85 -0
- package/dist/tests/e2e/gui-layout.test.js.map +1 -1
- package/dist/tests/e2e/gui-webgl-depth-init.test.d.ts +13 -0
- package/dist/tests/e2e/gui-webgl-depth-init.test.js +144 -0
- package/dist/tests/e2e/gui-webgl-depth-init.test.js.map +1 -0
- package/dist/tests/e2e/gui-webgl-depth-range.test.d.ts +18 -0
- package/dist/tests/e2e/gui-webgl-depth-range.test.js +140 -0
- package/dist/tests/e2e/gui-webgl-depth-range.test.js.map +1 -0
- package/dist/tests/e2e/gui-webgl.test.js +49 -0
- package/dist/tests/e2e/gui-webgl.test.js.map +1 -1
- package/dist/tests/e2e/gui-webgpu-attachment.test.d.ts +19 -0
- package/dist/tests/e2e/gui-webgpu-attachment.test.js +258 -0
- package/dist/tests/e2e/gui-webgpu-attachment.test.js.map +1 -0
- package/dist/tests/e2e/method-call-cache.test.js +27 -0
- package/dist/tests/e2e/method-call-cache.test.js.map +1 -1
- package/dist/tests/extensions/gui-features.test.js +27 -2
- package/dist/tests/extensions/gui-features.test.js.map +1 -1
- package/doc/ai/extensions.md +10 -4
- package/doc/ai/zh-CN/extensions.md +8 -3
- package/doc/gui/animation.md +1 -1
- package/doc/gui/api.md +35 -2
- package/doc/gui/build.md +34 -15
- package/doc/gui/dom.md +3 -2
- package/doc/gui/known-issues.md +1 -1
- package/doc/gui/layout.md +9 -3
- package/doc/gui/rendering.md +45 -8
- package/doc/gui/runtime.md +13 -0
- package/doc/gui/webgl.md +29 -3
- package/doc/gui/webgpu.md +20 -0
- package/doc/gui.md +9 -4
- package/doc/implemented/codegen.md +4 -3
- package/doc/zh-CN/gui/animation.md +1 -1
- package/doc/zh-CN/gui/api.md +25 -2
- package/doc/zh-CN/gui/build.md +20 -7
- package/doc/zh-CN/gui/dom.md +3 -2
- package/doc/zh-CN/gui/known-issues.md +1 -1
- package/doc/zh-CN/gui/layout.md +7 -4
- package/doc/zh-CN/gui/rendering.md +33 -8
- package/doc/zh-CN/gui/runtime.md +9 -0
- package/doc/zh-CN/gui/webgl.md +7 -4
- package/doc/zh-CN/gui/webgpu.md +18 -0
- package/doc/zh-CN/gui.md +10 -5
- package/doc/zh-CN/implemented/codegen.md +4 -3
- package/package.json +7 -7
- package/runtime/ext_gui/audio_graph_commands.cpp +127 -0
- package/runtime/ext_gui/audio_mixer.cpp +84 -163
- package/runtime/ext_gui/audio_mixer.h +59 -3
- package/runtime/ext_gui/audio_mixer_extra.cpp +8 -0
- package/runtime/ext_gui/audio_param_apply.cpp +160 -0
- package/runtime/ext_gui/browser.cpp +6 -19
- package/runtime/ext_gui/browser_location.cpp +78 -0
- package/runtime/ext_gui/css.cpp +1 -0
- package/runtime/ext_gui/css.h +4 -0
- package/runtime/ext_gui/css_sheet.cpp +4 -2
- package/runtime/ext_gui/document_animation.cpp +7 -0
- package/runtime/ext_gui/dom_api_computed_style.cpp +3 -2
- package/runtime/ext_gui/dom_api_webgl.cpp +39 -2
- package/runtime/ext_gui/dom_api_webgl_extensions.cpp +134 -0
- package/runtime/ext_gui/dom_api_webgl_internal.h +4 -0
- package/runtime/ext_gui/dom_api_webgl_shader.cpp +28 -4
- package/runtime/ext_gui/dom_api_webgl_state.cpp +6 -103
- package/runtime/ext_gui/gui.cpp +100 -1
- package/runtime/ext_gui/gui_events.cpp +8 -2
- package/runtime/ext_gui/layout_flex.cpp +5 -2
- package/runtime/ext_gui/layout_flow.cpp +24 -1
- package/runtime/ext_gui/layout_flow_internal.h +11 -2
- package/runtime/ext_gui/media_query.cpp +3 -0
- package/runtime/ext_gui/perf.cpp +18 -6
- package/runtime/ext_gui/perf.h +37 -0
- package/runtime/ext_gui/style.cpp +28 -10
- package/runtime/ext_gui/style.h +10 -1
- package/runtime/ext_gui/style_length.cpp +4 -0
- package/runtime/ext_gui/style_print.cpp +7 -1
- package/runtime/ext_gui/style_values.cpp +6 -5
- package/runtime/ext_gui/text.cpp +4 -0
- package/runtime/ext_gui/text_font_bytes.cpp +117 -0
- package/runtime/ext_gui/text_font_bytes.h +65 -0
- package/runtime/ext_gui/text_font_db.cpp +5 -0
- package/runtime/ext_gui/text_font_sfnt.cpp +71 -24
- package/runtime/ext_gui/text_font_sfnt.h +5 -2
- package/runtime/ext_gui/text_hb.cpp +34 -5
- package/runtime/ext_gui/text_stb.cpp +7 -30
- package/runtime/ext_gui/text_webfont.cpp +217 -0
- package/runtime/ext_gui/warnings.cpp +26 -0
- package/runtime/ext_gui/warnings.h +8 -0
- package/runtime/ext_gui/webfont_bridge.c +23 -0
- package/runtime/ext_gui/webgl.h +36 -39
- package/runtime/ext_gui/webgl_blit_color.cpp +5 -0
- package/runtime/ext_gui/webgl_buffer_objects.cpp +19 -5
- package/runtime/ext_gui/webgl_context.cpp +2 -0
- package/runtime/ext_gui/webgl_draw.cpp +72 -12
- package/runtime/ext_gui/webgl_draw_setup.cpp +8 -2
- package/runtime/ext_gui/webgl_draw_state.h +13 -2
- package/runtime/ext_gui/webgl_framebuffer.cpp +8 -0
- package/runtime/ext_gui/webgl_objects.h +19 -0
- package/runtime/ext_gui/webgl_program.h +64 -0
- package/runtime/ext_gui/webgl_state.cpp +7 -0
- package/runtime/ext_gui/webgl_targets.cpp +31 -7
- package/runtime/ext_gui/webgl_uniform.cpp +78 -0
- package/runtime/ext_gui/webgpu.h +10 -0
- package/runtime/ext_gui/webgpu_buffer.cpp +3 -1
- package/runtime/ext_gui/webgpu_canvas.cpp +1 -0
- package/runtime/ext_gui/webgpu_command.cpp +51 -11
- package/runtime/ext_gui/webgpu_convert.cpp +7 -2
- package/runtime/ext_gui/webgpu_pass.cpp +12 -0
- package/runtime/ext_gui/webgpu_queue.cpp +3 -0
- package/runtime/ext_gui/webgpu_resources.cpp +1 -0
- package/runtime/ext_gui/window.cpp +6 -0
- package/runtime/rt_object.h +6 -0
- package/runtime/rt_profile.h +6 -0
- package/runtime/xt_containers/access.inc +2 -47
- package/runtime/xt_containers/ic_get.inc +70 -0
- package/runtime/xt_containers/method_cache.inc +42 -11
- package/runtime/xt_containers/objects.inc +12 -1
- package/runtime/xt_containers/shapes.inc +78 -0
- package/runtime/xt_containers.c +1 -0
- package/runtime/xt_profile.c +3 -0
- package/scripts/build-gui.ts +43 -49
- package/scripts/gui-engine-build.ts +58 -0
- package/scripts/gui-vendor-source.ts +53 -0
- package/scripts/gui-webfont-build.ts +138 -0
- package/src/cli/help.ts +1 -1
- package/src/codegen/generator/calls/invocation.ts +6 -4
- package/src/codegen/generator/context.ts +6 -6
- package/src/codegen/generator/expressions/assignment.ts +3 -3
- package/src/driver/config.ts +1 -1
- package/src/driver/options.ts +1 -1
- package/src/driver/version.ts +1 -1
- package/src/extensions/gui/features.ts +34 -6
- package/src/extensions/gui/index.ts +3 -3
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* End-to-end test for `gl.depthRange`, the state a first-person renderer uses to
|
|
3
|
+
* keep its view model (weapon, hands) in front of the world.
|
|
4
|
+
*
|
|
5
|
+
* three.js-driven games render the world with one camera, then narrow the depth
|
|
6
|
+
* range (`depthRange(0, 0.05)`) and render the view model with a second camera
|
|
7
|
+
* that has a much smaller near plane. Every view-model fragment then lands in
|
|
8
|
+
* the first 5% of the depth buffer, so the world can never occlude it — without
|
|
9
|
+
* that remap the hand is depth-tested at its real distance and the ground cuts
|
|
10
|
+
* through it (saltline's "the hand sinks into the floor" bug).
|
|
11
|
+
*
|
|
12
|
+
* The probes below pin the observable halves of the GL semantics: the default
|
|
13
|
+
* [0, 1] range leaves the ordering alone, a narrowed range pulls farther
|
|
14
|
+
* fragments in front, the range also rewrites the depth a fragment *writes*
|
|
15
|
+
* (not just the value it tests against), and `getParameter(DEPTH_RANGE)`
|
|
16
|
+
* reports the live range.
|
|
17
|
+
*/
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* End-to-end test for `gl.depthRange`, the state a first-person renderer uses to
|
|
3
|
+
* keep its view model (weapon, hands) in front of the world.
|
|
4
|
+
*
|
|
5
|
+
* three.js-driven games render the world with one camera, then narrow the depth
|
|
6
|
+
* range (`depthRange(0, 0.05)`) and render the view model with a second camera
|
|
7
|
+
* that has a much smaller near plane. Every view-model fragment then lands in
|
|
8
|
+
* the first 5% of the depth buffer, so the world can never occlude it — without
|
|
9
|
+
* that remap the hand is depth-tested at its real distance and the ground cuts
|
|
10
|
+
* through it (saltline's "the hand sinks into the floor" bug).
|
|
11
|
+
*
|
|
12
|
+
* The probes below pin the observable halves of the GL semantics: the default
|
|
13
|
+
* [0, 1] range leaves the ordering alone, a narrowed range pulls farther
|
|
14
|
+
* fragments in front, the range also rewrites the depth a fragment *writes*
|
|
15
|
+
* (not just the value it tests against), and `getParameter(DEPTH_RANGE)`
|
|
16
|
+
* reports the live range.
|
|
17
|
+
*/
|
|
18
|
+
import { afterAll, beforeAll, describe, expect, it } from "vitest";
|
|
19
|
+
import { createGuiHarness, guiAvailable } from "./gui-helpers.js";
|
|
20
|
+
const harness = createGuiHarness();
|
|
21
|
+
const PAGE = `
|
|
22
|
+
<html><head><title>webgl-depth-range</title></head>
|
|
23
|
+
<body style="margin:0">
|
|
24
|
+
<canvas id="c" width="64" height="64"></canvas>
|
|
25
|
+
</body></html>`;
|
|
26
|
+
describe.skipIf(!guiAvailable)("gui extension — WebGL depth range", () => {
|
|
27
|
+
beforeAll(() => harness.setup());
|
|
28
|
+
afterAll(() => harness.cleanup());
|
|
29
|
+
it("remaps fragment depth and depth writes into the requested range", () => {
|
|
30
|
+
const { value, stderr } = harness.compileAndRun("webgl-depth-range", `
|
|
31
|
+
import { createWindow } from "gui";
|
|
32
|
+
import page from "./page.html";
|
|
33
|
+
|
|
34
|
+
const win = createWindow({ title: "depth-range", width: 320, height: 240 });
|
|
35
|
+
const label = (name: string, value: any): void => console.log(name + "=" + value);
|
|
36
|
+
|
|
37
|
+
win.on("ready", () => {
|
|
38
|
+
const canvas: any = document.getElementById("c");
|
|
39
|
+
const gl: any = canvas.getContext("webgl2");
|
|
40
|
+
if (gl == null) {
|
|
41
|
+
console.log("webgl2=false");
|
|
42
|
+
win.close();
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const vs: any = gl.createShader(gl.VERTEX_SHADER);
|
|
47
|
+
gl.shaderSource(vs,
|
|
48
|
+
"#version 300 es\\n" +
|
|
49
|
+
"in vec2 a_pos;\\n" +
|
|
50
|
+
"uniform float u_z;\\n" +
|
|
51
|
+
"void main() { gl_Position = vec4(a_pos, u_z, 1.0); }");
|
|
52
|
+
gl.compileShader(vs);
|
|
53
|
+
const fs: any = gl.createShader(gl.FRAGMENT_SHADER);
|
|
54
|
+
gl.shaderSource(fs,
|
|
55
|
+
"#version 300 es\\n" +
|
|
56
|
+
"precision highp float;\\n" +
|
|
57
|
+
"uniform vec4 u_color;\\n" +
|
|
58
|
+
"out vec4 fragColor;\\n" +
|
|
59
|
+
"void main() { fragColor = u_color; }");
|
|
60
|
+
gl.compileShader(fs);
|
|
61
|
+
const program: any = gl.createProgram();
|
|
62
|
+
gl.attachShader(program, vs);
|
|
63
|
+
gl.attachShader(program, fs);
|
|
64
|
+
gl.linkProgram(program);
|
|
65
|
+
label("link", gl.getProgramParameter(program, gl.LINK_STATUS) === true);
|
|
66
|
+
|
|
67
|
+
const quad: any = gl.createBuffer();
|
|
68
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, quad);
|
|
69
|
+
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 3, -1, -1, 3]), gl.STATIC_DRAW);
|
|
70
|
+
gl.useProgram(program);
|
|
71
|
+
const pos: any = gl.getAttribLocation(program, "a_pos");
|
|
72
|
+
gl.enableVertexAttribArray(pos);
|
|
73
|
+
gl.vertexAttribPointer(pos, 2, gl.FLOAT, false, 8, 0);
|
|
74
|
+
const z_loc: any = gl.getUniformLocation(program, "u_z");
|
|
75
|
+
const color_loc: any = gl.getUniformLocation(program, "u_color");
|
|
76
|
+
|
|
77
|
+
const px = new Uint8Array(4);
|
|
78
|
+
const probe = (): string => {
|
|
79
|
+
gl.readPixels(32, 32, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, px);
|
|
80
|
+
return px[0] + "," + px[1] + "," + px[2] + "," + px[3];
|
|
81
|
+
};
|
|
82
|
+
const draw = (z: number, r: number, g: number, b: number): void => {
|
|
83
|
+
gl.uniform1f(z_loc, z);
|
|
84
|
+
gl.uniform4f(color_loc, r, g, b, 1);
|
|
85
|
+
gl.drawArrays(gl.TRIANGLES, 0, 3);
|
|
86
|
+
};
|
|
87
|
+
const reset = (): void => {
|
|
88
|
+
gl.clearColor(0, 0, 0, 1);
|
|
89
|
+
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
gl.viewport(0, 0, 64, 64);
|
|
93
|
+
gl.enable(gl.DEPTH_TEST);
|
|
94
|
+
gl.depthFunc(gl.LESS);
|
|
95
|
+
gl.depthMask(true);
|
|
96
|
+
|
|
97
|
+
/* -- 1. default range: a farther fragment is rejected ---------------- */
|
|
98
|
+
gl.depthRange(0, 1);
|
|
99
|
+
reset();
|
|
100
|
+
draw(0.8, 1, 0, 0);
|
|
101
|
+
draw(0.96, 0, 1, 0);
|
|
102
|
+
label("default", probe());
|
|
103
|
+
|
|
104
|
+
/* -- 2. narrowed range: every fragment lands in front ---------------- */
|
|
105
|
+
reset();
|
|
106
|
+
draw(0.8, 1, 0, 0);
|
|
107
|
+
gl.depthRange(0, 0.05);
|
|
108
|
+
draw(0.96, 0, 1, 0);
|
|
109
|
+
gl.depthRange(0, 1);
|
|
110
|
+
label("compress", probe());
|
|
111
|
+
|
|
112
|
+
/* -- 3. narrowed range also remaps the depth that is written --------- */
|
|
113
|
+
reset();
|
|
114
|
+
gl.depthRange(0, 0.1);
|
|
115
|
+
draw(0.96, 1, 0, 0);
|
|
116
|
+
gl.depthRange(0, 1);
|
|
117
|
+
draw(0.8, 0, 1, 0);
|
|
118
|
+
label("write", probe());
|
|
119
|
+
|
|
120
|
+
gl.depthRange(0.25, 0.75);
|
|
121
|
+
const range: any = gl.getParameter(gl.DEPTH_RANGE);
|
|
122
|
+
label("range-param", range[0] + "," + range[1]);
|
|
123
|
+
gl.depthRange(0, 1);
|
|
124
|
+
|
|
125
|
+
label("error", gl.getError());
|
|
126
|
+
win.close();
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
win.loadHTML(page);
|
|
130
|
+
`, { files: { "page.html": PAGE }, autocloseMs: 10000 });
|
|
131
|
+
expect(value("link")).toBe("true");
|
|
132
|
+
expect(value("default")).toBe("255,0,0,255");
|
|
133
|
+
expect(value("compress")).toBe("0,255,0,255");
|
|
134
|
+
expect(value("write")).toBe("255,0,0,255");
|
|
135
|
+
expect(value("range-param")).toBe("0.25,0.75");
|
|
136
|
+
expect(value("error")).toBe("0");
|
|
137
|
+
expect(stderr).not.toContain("pipeline creation failed");
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
//# sourceMappingURL=gui-webgl-depth-range.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gui-webgl-depth-range.test.js","sourceRoot":"","sources":["../../../tests/e2e/gui-webgl-depth-range.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAElE,MAAM,OAAO,GAAG,gBAAgB,EAAE,CAAC;AAEnC,MAAM,IAAI,GAAG;;;;eAIE,CAAC;AAEhB,QAAQ,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC,mCAAmC,EAAE,GAAG,EAAE;IACvE,SAAS,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;IACjC,QAAQ,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAElC,EAAE,CAAC,iEAAiE,EAAE,GAAG,EAAE;QACzE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,aAAa,CAC7C,mBAAmB,EACnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoGC,EACD,EAAE,KAAK,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,CACrD,CAAC;QAEF,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACnC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC7C,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC9C,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC3C,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC/C,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACjC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,0BAA0B,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -338,6 +338,55 @@ describe.skipIf(!guiAvailable)("gui extension — WebGL", () => {
|
|
|
338
338
|
expect(value("error")).toBe("0");
|
|
339
339
|
expect(stderr).not.toContain("pipeline creation failed");
|
|
340
340
|
});
|
|
341
|
+
it("publishes KHR_parallel_shader_compile with a synchronous completion status", () => {
|
|
342
|
+
const { value } = harness.compileAndRun("webgl-parallel-compile", `
|
|
343
|
+
import { createWindow } from "gui";
|
|
344
|
+
import page from "./page.html";
|
|
345
|
+
|
|
346
|
+
const win = createWindow({ title: "parallel-compile", width: 320, height: 240 });
|
|
347
|
+
const label = (name: string, value: any): void => console.log(name + "=" + value);
|
|
348
|
+
|
|
349
|
+
win.on("ready", () => {
|
|
350
|
+
const canvas: any = document.getElementById("c");
|
|
351
|
+
const gl: any = canvas.getContext("webgl");
|
|
352
|
+
const ext: any = gl.getExtension("KHR_parallel_shader_compile");
|
|
353
|
+
label("ext", ext != null);
|
|
354
|
+
label("supported",
|
|
355
|
+
gl.getSupportedExtensions().indexOf("KHR_parallel_shader_compile") >= 0);
|
|
356
|
+
label("completion-pname", ext.COMPLETION_STATUS_KHR);
|
|
357
|
+
|
|
358
|
+
const vs: any = gl.createShader(gl.VERTEX_SHADER);
|
|
359
|
+
gl.shaderSource(vs, "attribute vec2 a_pos;" +
|
|
360
|
+
"void main() { gl_Position = vec4(a_pos, 0.0, 1.0); }");
|
|
361
|
+
gl.compileShader(vs);
|
|
362
|
+
label("shader-complete",
|
|
363
|
+
gl.getShaderParameter(vs, ext.COMPLETION_STATUS_KHR) === true);
|
|
364
|
+
|
|
365
|
+
const fs: any = gl.createShader(gl.FRAGMENT_SHADER);
|
|
366
|
+
gl.shaderSource(fs, "precision mediump float;" +
|
|
367
|
+
"void main() { gl_FragColor = vec4(1.0); }");
|
|
368
|
+
gl.compileShader(fs);
|
|
369
|
+
const program: any = gl.createProgram();
|
|
370
|
+
gl.attachShader(program, vs);
|
|
371
|
+
gl.attachShader(program, fs);
|
|
372
|
+
gl.linkProgram(program);
|
|
373
|
+
label("linked", gl.getProgramParameter(program, gl.LINK_STATUS));
|
|
374
|
+
label("program-complete",
|
|
375
|
+
gl.getProgramParameter(program, ext.COMPLETION_STATUS_KHR) === true);
|
|
376
|
+
label("error", gl.getError());
|
|
377
|
+
win.close();
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
win.loadHTML(page);
|
|
381
|
+
`, { files: { "page.html": PAGE } });
|
|
382
|
+
expect(value("ext")).toBe("true");
|
|
383
|
+
expect(value("supported")).toBe("true");
|
|
384
|
+
expect(value("completion-pname")).toBe("37297"); // 0x91B1
|
|
385
|
+
expect(value("shader-complete")).toBe("true");
|
|
386
|
+
expect(value("linked")).toBe("true");
|
|
387
|
+
expect(value("program-complete")).toBe("true");
|
|
388
|
+
expect(value("error")).toBe("0");
|
|
389
|
+
});
|
|
341
390
|
it("samples a cube map face by direction", () => {
|
|
342
391
|
const { value, stderr } = harness.compileAndRun("webgl-cube-map", `
|
|
343
392
|
import { createWindow } from "gui";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gui-webgl.test.js","sourceRoot":"","sources":["../../../tests/e2e/gui-webgl.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAElE,MAAM,OAAO,GAAG,gBAAgB,EAAE,CAAC;AAEnC,MAAM,IAAI,GAAG;;;;eAIE,CAAC;AAEhB,QAAQ,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC,uBAAuB,EAAE,GAAG,EAAE;IAC3D,SAAS,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;IACjC,QAAQ,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAElC,EAAE,CAAC,2DAA2D,EAAE,GAAG,EAAE;QACnE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,aAAa,CAC7C,OAAO,EACP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAqIC,E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ine used to
|
|
3
|
+
* get wrong:
|
|
4
|
+
*
|
|
5
|
+
* - `loadOp`/`depthLoadOp`/`stencilLoadOp: "load"` must keep the contents the
|
|
6
|
+
* previous pass stored. The engine used to hand SDL a cycling target even for
|
|
7
|
+
* a LOAD pass, and SDL rotates such a target to another internal allocation,
|
|
8
|
+
* so a second pass began from undefined memory — the colour and depth of the
|
|
9
|
+
* first pass silently disappeared.
|
|
10
|
+
* - A texture that no pass or copy has written yet must read as WebGPU's
|
|
11
|
+
* initial zeroes rather than uninitialised GPU memory: depth 0, stencil 0,
|
|
12
|
+
* transparent black. A first pass that LOADs it may not expose garbage.
|
|
13
|
+
* - `stencilLoadOp`/`stencilStoreOp` must be honoured; the engine used to clear
|
|
14
|
+
* the stencil aspect of every pass, so a stencil written by one pass was gone
|
|
15
|
+
* in the next.
|
|
16
|
+
*
|
|
17
|
+
* Every probe renders to an offscreen texture and copies one texel back.
|
|
18
|
+
*/
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* End-to-end test for WebGPU pass-attachment semantics that the engine used to
|
|
3
|
+
* get wrong:
|
|
4
|
+
*
|
|
5
|
+
* - `loadOp`/`depthLoadOp`/`stencilLoadOp: "load"` must keep the contents the
|
|
6
|
+
* previous pass stored. The engine used to hand SDL a cycling target even for
|
|
7
|
+
* a LOAD pass, and SDL rotates such a target to another internal allocation,
|
|
8
|
+
* so a second pass began from undefined memory — the colour and depth of the
|
|
9
|
+
* first pass silently disappeared.
|
|
10
|
+
* - A texture that no pass or copy has written yet must read as WebGPU's
|
|
11
|
+
* initial zeroes rather than uninitialised GPU memory: depth 0, stencil 0,
|
|
12
|
+
* transparent black. A first pass that LOADs it may not expose garbage.
|
|
13
|
+
* - `stencilLoadOp`/`stencilStoreOp` must be honoured; the engine used to clear
|
|
14
|
+
* the stencil aspect of every pass, so a stencil written by one pass was gone
|
|
15
|
+
* in the next.
|
|
16
|
+
*
|
|
17
|
+
* Every probe renders to an offscreen texture and copies one texel back.
|
|
18
|
+
*/
|
|
19
|
+
import { afterAll, beforeAll, describe, expect, it } from "vitest";
|
|
20
|
+
import { createGuiHarness, guiAvailable } from "./gui-helpers.js";
|
|
21
|
+
const harness = createGuiHarness();
|
|
22
|
+
const PAGE = `
|
|
23
|
+
<html><head><title>webgpu-attachment</title></head>
|
|
24
|
+
<body style="margin:0">
|
|
25
|
+
<canvas id="c" width="32" height="32"></canvas>
|
|
26
|
+
</body></html>`;
|
|
27
|
+
describe.skipIf(!guiAvailable)("gui extension — WebGPU attachment load and initialisation", () => {
|
|
28
|
+
beforeAll(() => harness.setup());
|
|
29
|
+
afterAll(() => harness.cleanup());
|
|
30
|
+
it("keeps loaded contents and starts fresh attachments at zero", () => {
|
|
31
|
+
const { value, stderr } = harness.compileAndRun("webgpu-attachment", `
|
|
32
|
+
import { createWindow } from "gui";
|
|
33
|
+
import page from "./page.html";
|
|
34
|
+
|
|
35
|
+
const win = createWindow({ title: "attachment", width: 320, height: 240 });
|
|
36
|
+
const label = (name: string, value: any): void => console.log(name + "=" + value);
|
|
37
|
+
const rgba = (p: any): string => p[0] + "," + p[1] + "," + p[2] + "," + p[3];
|
|
38
|
+
|
|
39
|
+
const RENDER = \`
|
|
40
|
+
struct VOut { @builtin(position) pos: vec4f };
|
|
41
|
+
|
|
42
|
+
@vertex
|
|
43
|
+
fn vs(@builtin(vertex_index) i: u32) -> VOut {
|
|
44
|
+
var p = array<vec2f, 3>(vec2f(-1.0, -1.0), vec2f(3.0, -1.0), vec2f(-1.0, 3.0));
|
|
45
|
+
var o: VOut;
|
|
46
|
+
o.pos = vec4f(p[i], 0.5, 1.0);
|
|
47
|
+
return o;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@fragment
|
|
51
|
+
fn fs() -> @location(0) vec4f {
|
|
52
|
+
return vec4f(0.0, 0.0, 1.0, 1.0);
|
|
53
|
+
}
|
|
54
|
+
\`;
|
|
55
|
+
|
|
56
|
+
const run = async (): Promise<void> => {
|
|
57
|
+
const gpu: any = (navigator as any).gpu;
|
|
58
|
+
const adapter = await gpu.requestAdapter();
|
|
59
|
+
const device: any = await adapter.requestDevice();
|
|
60
|
+
const module: any = device.createShaderModule({ code: RENDER });
|
|
61
|
+
|
|
62
|
+
const colorTexture = (): any => device.createTexture({
|
|
63
|
+
size: { width: 32, height: 32 },
|
|
64
|
+
format: "rgba8unorm",
|
|
65
|
+
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_SRC,
|
|
66
|
+
});
|
|
67
|
+
const depthTexture = (format: string): any => device.createTexture({
|
|
68
|
+
size: { width: 32, height: 32 },
|
|
69
|
+
format,
|
|
70
|
+
usage: GPUTextureUsage.RENDER_ATTACHMENT,
|
|
71
|
+
});
|
|
72
|
+
const pipeline = (format: string, compare: string, write: boolean, stencil: any): any =>
|
|
73
|
+
device.createRenderPipeline({
|
|
74
|
+
vertex: { module, entryPoint: "vs", buffers: [] },
|
|
75
|
+
fragment: { module, entryPoint: "fs", targets: [{ format: "rgba8unorm" }] },
|
|
76
|
+
primitive: { topology: "triangle-list" },
|
|
77
|
+
depthStencil: {
|
|
78
|
+
format,
|
|
79
|
+
depthWriteEnabled: write,
|
|
80
|
+
depthCompare: compare,
|
|
81
|
+
stencilFront: stencil,
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const read = async (texture: any): Promise<any> => {
|
|
86
|
+
const buffer: any = device.createBuffer({
|
|
87
|
+
size: 256,
|
|
88
|
+
usage: GPUBufferUsage.MAP_READ | GPUBufferUsage.COPY_DST,
|
|
89
|
+
});
|
|
90
|
+
const encoder: any = device.createCommandEncoder();
|
|
91
|
+
encoder.copyTextureToBuffer(
|
|
92
|
+
{ texture, origin: { x: 16, y: 16 } },
|
|
93
|
+
{ buffer, bytesPerRow: 256 },
|
|
94
|
+
{ width: 1, height: 1 },
|
|
95
|
+
);
|
|
96
|
+
device.queue.submit([encoder.finish()]);
|
|
97
|
+
await buffer.mapAsync(GPUMapMode.READ);
|
|
98
|
+
const pixels = new Uint8Array(buffer.getMappedRange());
|
|
99
|
+
const out = [pixels[0], pixels[1], pixels[2], pixels[3]];
|
|
100
|
+
buffer.unmap();
|
|
101
|
+
buffer.destroy();
|
|
102
|
+
return out;
|
|
103
|
+
};
|
|
104
|
+
const submit = async (encoder: any): Promise<void> => {
|
|
105
|
+
device.queue.submit([encoder.finish()]);
|
|
106
|
+
await device.queue.onSubmittedWorkDone();
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
/* A second pass that LOADs the green colour and the depth of 1.0 the
|
|
110
|
+
* first pass stored must keep both: the draw at z=0.5 passes the depth
|
|
111
|
+
* test and paints blue. */
|
|
112
|
+
const color: any = colorTexture();
|
|
113
|
+
const depth: any = depthTexture("depth32float");
|
|
114
|
+
const encoder: any = device.createCommandEncoder();
|
|
115
|
+
const clearPass: any = encoder.beginRenderPass({
|
|
116
|
+
colorAttachments: [{
|
|
117
|
+
view: color.createView(),
|
|
118
|
+
clearValue: { r: 0, g: 1, b: 0, a: 1 },
|
|
119
|
+
loadOp: "clear",
|
|
120
|
+
storeOp: "store",
|
|
121
|
+
}],
|
|
122
|
+
depthStencilAttachment: {
|
|
123
|
+
view: depth.createView(),
|
|
124
|
+
depthClearValue: 1.0,
|
|
125
|
+
depthLoadOp: "clear",
|
|
126
|
+
depthStoreOp: "store",
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
clearPass.end();
|
|
130
|
+
const loadPass: any = encoder.beginRenderPass({
|
|
131
|
+
colorAttachments: [{ view: color.createView(), loadOp: "load", storeOp: "store" }],
|
|
132
|
+
depthStencilAttachment: { view: depth.createView(), depthLoadOp: "load", depthStoreOp: "store" },
|
|
133
|
+
});
|
|
134
|
+
loadPass.setPipeline(pipeline("depth32float", "less", true, null));
|
|
135
|
+
loadPass.draw(3, 1, 0, 0);
|
|
136
|
+
loadPass.end();
|
|
137
|
+
await submit(encoder);
|
|
138
|
+
label("load", rgba(await read(color)));
|
|
139
|
+
|
|
140
|
+
/* A texture that was never written loads as WebGPU's zeroes. Depth 0
|
|
141
|
+
* rejects a fragment at z=0.5 under "less" and accepts it under
|
|
142
|
+
* "greater", so the pair pins the loaded value to 0. */
|
|
143
|
+
const lessColor: any = colorTexture();
|
|
144
|
+
const lessDepth: any = depthTexture("depth32float");
|
|
145
|
+
const lessEncoder: any = device.createCommandEncoder();
|
|
146
|
+
const lessPass: any = lessEncoder.beginRenderPass({
|
|
147
|
+
colorAttachments: [{
|
|
148
|
+
view: lessColor.createView(),
|
|
149
|
+
clearValue: { r: 1, g: 0, b: 0, a: 1 },
|
|
150
|
+
loadOp: "clear",
|
|
151
|
+
storeOp: "store",
|
|
152
|
+
}],
|
|
153
|
+
depthStencilAttachment: {
|
|
154
|
+
view: lessDepth.createView(),
|
|
155
|
+
depthLoadOp: "load",
|
|
156
|
+
depthStoreOp: "store",
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
lessPass.setPipeline(pipeline("depth32float", "less", false, null));
|
|
160
|
+
lessPass.draw(3, 1, 0, 0);
|
|
161
|
+
lessPass.end();
|
|
162
|
+
await submit(lessEncoder);
|
|
163
|
+
label("fresh-less", rgba(await read(lessColor)));
|
|
164
|
+
|
|
165
|
+
const greaterColor: any = colorTexture();
|
|
166
|
+
const greaterDepth: any = depthTexture("depth32float");
|
|
167
|
+
const greaterEncoder: any = device.createCommandEncoder();
|
|
168
|
+
const greaterPass: any = greaterEncoder.beginRenderPass({
|
|
169
|
+
colorAttachments: [{
|
|
170
|
+
view: greaterColor.createView(),
|
|
171
|
+
clearValue: { r: 1, g: 0, b: 0, a: 1 },
|
|
172
|
+
loadOp: "clear",
|
|
173
|
+
storeOp: "store",
|
|
174
|
+
}],
|
|
175
|
+
depthStencilAttachment: {
|
|
176
|
+
view: greaterDepth.createView(),
|
|
177
|
+
depthLoadOp: "load",
|
|
178
|
+
depthStoreOp: "store",
|
|
179
|
+
},
|
|
180
|
+
});
|
|
181
|
+
greaterPass.setPipeline(pipeline("depth32float", "greater", false, null));
|
|
182
|
+
greaterPass.draw(3, 1, 0, 0);
|
|
183
|
+
greaterPass.end();
|
|
184
|
+
await submit(greaterEncoder);
|
|
185
|
+
label("fresh-greater", rgba(await read(greaterColor)));
|
|
186
|
+
|
|
187
|
+
/* The colour aspect is zero-initialised too: transparent black. */
|
|
188
|
+
const blank: any = colorTexture();
|
|
189
|
+
const blankEncoder: any = device.createCommandEncoder();
|
|
190
|
+
const blankPass: any = blankEncoder.beginRenderPass({
|
|
191
|
+
colorAttachments: [{ view: blank.createView(), loadOp: "load", storeOp: "store" }],
|
|
192
|
+
});
|
|
193
|
+
blankPass.end();
|
|
194
|
+
await submit(blankEncoder);
|
|
195
|
+
label("fresh-color", rgba(await read(blank)));
|
|
196
|
+
|
|
197
|
+
/* Stencil 1 is stored by the first pass; the second pass LOADs it and
|
|
198
|
+
* draws only where the reference matches. */
|
|
199
|
+
const maskColor: any = colorTexture();
|
|
200
|
+
const maskDepth: any = depthTexture("depth24plus-stencil8");
|
|
201
|
+
/* depth24plus-stencil8 is a promise format (the engine backs it with
|
|
202
|
+
* depth32float-stencil8); the getter must still report the name the
|
|
203
|
+
* page asked for. */
|
|
204
|
+
label("stencil-format", maskDepth.format);
|
|
205
|
+
const maskStencil: any = { compare: "equal", passOp: "keep" };
|
|
206
|
+
const maskEncoder: any = device.createCommandEncoder();
|
|
207
|
+
const stencilClear: any = maskEncoder.beginRenderPass({
|
|
208
|
+
colorAttachments: [{
|
|
209
|
+
view: maskColor.createView(),
|
|
210
|
+
clearValue: { r: 1, g: 0, b: 0, a: 1 },
|
|
211
|
+
loadOp: "clear",
|
|
212
|
+
storeOp: "store",
|
|
213
|
+
}],
|
|
214
|
+
depthStencilAttachment: {
|
|
215
|
+
view: maskDepth.createView(),
|
|
216
|
+
depthClearValue: 1.0,
|
|
217
|
+
depthLoadOp: "clear",
|
|
218
|
+
depthStoreOp: "store",
|
|
219
|
+
stencilClearValue: 1,
|
|
220
|
+
stencilLoadOp: "clear",
|
|
221
|
+
stencilStoreOp: "store",
|
|
222
|
+
},
|
|
223
|
+
});
|
|
224
|
+
stencilClear.end();
|
|
225
|
+
const stencilLoad: any = maskEncoder.beginRenderPass({
|
|
226
|
+
colorAttachments: [{ view: maskColor.createView(), loadOp: "load", storeOp: "store" }],
|
|
227
|
+
depthStencilAttachment: {
|
|
228
|
+
view: maskDepth.createView(),
|
|
229
|
+
depthLoadOp: "load",
|
|
230
|
+
depthStoreOp: "store",
|
|
231
|
+
stencilLoadOp: "load",
|
|
232
|
+
stencilStoreOp: "store",
|
|
233
|
+
},
|
|
234
|
+
});
|
|
235
|
+
stencilLoad.setStencilReference(1);
|
|
236
|
+
stencilLoad.setPipeline(pipeline("depth24plus-stencil8", "always", false, maskStencil));
|
|
237
|
+
stencilLoad.draw(3, 1, 0, 0);
|
|
238
|
+
stencilLoad.end();
|
|
239
|
+
await submit(maskEncoder);
|
|
240
|
+
label("stencil", rgba(await read(maskColor)));
|
|
241
|
+
|
|
242
|
+
win.close();
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
win.on("ready", () => { run(); });
|
|
246
|
+
win.loadHTML(page);
|
|
247
|
+
console.log("loaded");
|
|
248
|
+
`, { files: { "page.html": PAGE }, autocloseMs: 12000, console: true });
|
|
249
|
+
expect(value("load")).toBe("0,0,255,255");
|
|
250
|
+
expect(value("fresh-less")).toBe("255,0,0,255");
|
|
251
|
+
expect(value("fresh-greater")).toBe("0,0,255,255");
|
|
252
|
+
expect(value("fresh-color")).toBe("0,0,0,0");
|
|
253
|
+
expect(value("stencil-format")).toBe("depth24plus-stencil8");
|
|
254
|
+
expect(value("stencil")).toBe("0,0,255,255");
|
|
255
|
+
expect(stderr).not.toContain("SDL_GPU");
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
//# sourceMappingURL=gui-webgpu-attachment.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gui-webgpu-attachment.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CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAChD,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACnD,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC7C,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QAC7D,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC7C,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -61,5 +61,32 @@ describeE2E("end-to-end method call cache", (harness) => {
|
|
|
61
61
|
"rewritten",
|
|
62
62
|
].join("\n"));
|
|
63
63
|
});
|
|
64
|
+
it("observes an own method added after the site warmed on a prototype method", () => {
|
|
65
|
+
/* three.js gives every `Euler` an own `_onChangeCallback` from its
|
|
66
|
+
* `Object3D` constructor, while thousands of other Eulers already warmed
|
|
67
|
+
* the `this._onChangeCallback()` call site with the prototype's empty
|
|
68
|
+
* method. The cache used to keep calling the prototype method, so
|
|
69
|
+
* `rotation.set(...)` never synced the quaternion: mouse input changed the
|
|
70
|
+
* camera's Euler angles but the rendered 3D scene stayed still. */
|
|
71
|
+
const source = `
|
|
72
|
+
class Euler {
|
|
73
|
+
x = 0;
|
|
74
|
+
_onChangeCallback(): void {}
|
|
75
|
+
set(x: number): Euler { this.x = x; this._onChangeCallback(); return this; }
|
|
76
|
+
}
|
|
77
|
+
const plain: Euler[] = [];
|
|
78
|
+
for (let i = 0; i < 2000; i++) {
|
|
79
|
+
const e = new Euler();
|
|
80
|
+
plain.push(e);
|
|
81
|
+
e.set(i);
|
|
82
|
+
}
|
|
83
|
+
let fired = -1;
|
|
84
|
+
const e = new Euler();
|
|
85
|
+
(e as any)._onChangeCallback = () => { fired = e.x; };
|
|
86
|
+
e.set(42);
|
|
87
|
+
console.log("fired=" + fired + " plain=" + plain.length);
|
|
88
|
+
`;
|
|
89
|
+
expect(runProgram(source)).toBe("fired=42 plain=2000");
|
|
90
|
+
});
|
|
64
91
|
});
|
|
65
92
|
//# sourceMappingURL=method-call-cache.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"method-call-cache.test.js","sourceRoot":"","sources":["../../../tests/e2e/method-call-cache.test.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,WAAW,CAAC,8BAA8B,EAAE,CAAC,OAAO,EAAE,EAAE;IACtD,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAE/B,EAAE,CAAC,oFAAoF,EAAE,GAAG,EAAE;QAC5F;;;;uCAI+B;QAC/B,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAmCd,CAAC;QACF,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAC7B;YACE,aAAa;YACb,WAAW;YACX,OAAO;YACP,mBAAmB;YACnB,OAAO;YACP,mBAAmB;YACnB,+BAA+B;YAC/B,OAAO;YACP,WAAW;YACX,WAAW;SACZ,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"method-call-cache.test.js","sourceRoot":"","sources":["../../../tests/e2e/method-call-cache.test.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,WAAW,CAAC,8BAA8B,EAAE,CAAC,OAAO,EAAE,EAAE;IACtD,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAE/B,EAAE,CAAC,oFAAoF,EAAE,GAAG,EAAE;QAC5F;;;;uCAI+B;QAC/B,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAmCd,CAAC;QACF,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAC7B;YACE,aAAa;YACb,WAAW;YACX,OAAO;YACP,mBAAmB;YACnB,OAAO;YACP,mBAAmB;YACnB,+BAA+B;YAC/B,OAAO;YACP,WAAW;YACX,WAAW;SACZ,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,0EAA0E,EAAE,GAAG,EAAE;QAClF;;;;;2EAKmE;QACnE,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;KAiBd,CAAC;QACF,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -12,7 +12,7 @@ vi.mock("../../src/driver/paths.js", () => ({
|
|
|
12
12
|
platformSlug: () => "darwin-x64",
|
|
13
13
|
}));
|
|
14
14
|
import { guiExtension } from "../../src/extensions/gui/index.js";
|
|
15
|
-
import { guiLinkFeatures, hasGpuUsage, hasImageUsage, hasMediaUsage, hasShapingUsage, hasWebglUsage, hasWebgpuUsage, } from "../../src/extensions/gui/features.js";
|
|
15
|
+
import { guiLinkFeatures, hasGpuUsage, hasImageUsage, hasMediaUsage, hasShapingUsage, hasWebfontUsage, hasWebglUsage, hasWebgpuUsage, } from "../../src/extensions/gui/features.js";
|
|
16
16
|
afterEach(() => {
|
|
17
17
|
vi.restoreAllMocks();
|
|
18
18
|
mocks.findRuntimeLibrary.mockReset();
|
|
@@ -32,16 +32,18 @@ const media = guiLinkFeatures.find((feature) => feature.name === "media");
|
|
|
32
32
|
const gpu = guiLinkFeatures.find((feature) => feature.name === "gpu");
|
|
33
33
|
const images = guiLinkFeatures.find((feature) => feature.name === "images");
|
|
34
34
|
const shaping = guiLinkFeatures.find((feature) => feature.name === "shaping");
|
|
35
|
+
const webfonts = guiLinkFeatures.find((feature) => feature.name === "webfonts");
|
|
35
36
|
const webgpu = guiLinkFeatures.find((feature) => feature.name === "webgpu");
|
|
36
37
|
const webgl = guiLinkFeatures.find((feature) => feature.name === "webgl");
|
|
37
38
|
describe("gui link features", () => {
|
|
38
|
-
it("declares media, gpu, images, shaping and webgl as optional halves of gui", () => {
|
|
39
|
+
it("declares media, gpu, images, shaping, webfonts and webgl as optional halves of gui", () => {
|
|
39
40
|
expect(guiExtension.linkFeatures?.()).toBe(guiLinkFeatures);
|
|
40
41
|
expect(guiLinkFeatures.map((feature) => feature.name)).toEqual([
|
|
41
42
|
"media",
|
|
42
43
|
"gpu",
|
|
43
44
|
"images",
|
|
44
45
|
"shaping",
|
|
46
|
+
"webfonts",
|
|
45
47
|
"webgpu",
|
|
46
48
|
"webgl",
|
|
47
49
|
]);
|
|
@@ -49,6 +51,7 @@ describe("gui link features", () => {
|
|
|
49
51
|
expect(gpu.description).toMatch(/glslang|GLSL/);
|
|
50
52
|
expect(images.description).toMatch(/stb_image|NanoSVG/);
|
|
51
53
|
expect(shaping.description).toMatch(/HarfBuzz|FreeType/);
|
|
54
|
+
expect(webfonts.description).toMatch(/WOFF/);
|
|
52
55
|
expect(webgpu.requires).toEqual(["gpu"]);
|
|
53
56
|
expect(webgl.requires).toEqual(["gpu"]);
|
|
54
57
|
});
|
|
@@ -70,6 +73,12 @@ describe("gui link features", () => {
|
|
|
70
73
|
expect(shaping.runtimeSources?.()).toEqual([join("/tmp/runtime", "ext_gui", "text_bridge.c")]);
|
|
71
74
|
expect(shaping.nativeObjects?.()).toBeUndefined();
|
|
72
75
|
});
|
|
76
|
+
it("links the webfonts bridge without an archive", () => {
|
|
77
|
+
expect(webfonts.runtimeSources?.()).toEqual([
|
|
78
|
+
join("/tmp/runtime", "ext_gui", "webfont_bridge.c"),
|
|
79
|
+
]);
|
|
80
|
+
expect(webfonts.nativeObjects?.()).toBeUndefined();
|
|
81
|
+
});
|
|
73
82
|
it("links the webgpu bridge without an archive", () => {
|
|
74
83
|
expect(webgpu.runtimeSources?.()).toEqual([join("/tmp/runtime", "ext_gui", "webgpu_bridge.c")]);
|
|
75
84
|
expect(webgpu.nativeObjects?.()).toBeUndefined();
|
|
@@ -179,6 +188,22 @@ describe("shaping usage detection", () => {
|
|
|
179
188
|
expect(hasShapingUsage(usage({ dynamicMarkup: true }))).toBe(true);
|
|
180
189
|
});
|
|
181
190
|
});
|
|
191
|
+
describe("webfont usage detection", () => {
|
|
192
|
+
it("turns on for a .woff/.woff2 source in HTML or CSS", () => {
|
|
193
|
+
expect(hasWebfontUsage(usage({
|
|
194
|
+
strings: ['@font-face { font-family: "X"; src: url("./x.woff2") format("woff2"); }'],
|
|
195
|
+
}))).toBe(true);
|
|
196
|
+
expect(hasWebfontUsage(usage({ strings: ["url(fonts/legacy.woff)"] }))).toBe(true);
|
|
197
|
+
expect(hasWebfontUsage(usage({ strings: ['src: url("x.woff2")'] }))).toBe(true);
|
|
198
|
+
});
|
|
199
|
+
it("stays off for plain sfnt sources and text-only pages", () => {
|
|
200
|
+
expect(hasWebfontUsage(usage({ strings: ['@font-face { font-family: "X"; src: url("./x.ttf"); }'] }))).toBe(false);
|
|
201
|
+
expect(hasWebfontUsage(usage({ strings: ["<div>Hello</div>"] }))).toBe(false);
|
|
202
|
+
});
|
|
203
|
+
it("turns on for dynamic markup", () => {
|
|
204
|
+
expect(hasWebfontUsage(usage({ dynamicMarkup: true }))).toBe(true);
|
|
205
|
+
});
|
|
206
|
+
});
|
|
182
207
|
describe("webgpu usage detection", () => {
|
|
183
208
|
it("recognises WebGPU calls and WGSL sources", () => {
|
|
184
209
|
expect(hasWebgpuUsage(usage({ strings: ["webgpu"] }))).toBe(true);
|