webgl2 1.2.0 → 1.2.3
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/coverage.md +41 -40
- package/demo.js +15 -7
- package/index.js +443 -368
- package/package.json +5 -3
- package/src/webgl2_context.js +2555 -2446
- package/src/webgl2_resources.js +91 -0
- package/src/webgpu_context.js +1298 -840
- package/webgl2.debug.wasm +0 -0
- package/webgl2.wasm +0 -0
package/coverage.md
CHANGED
|
@@ -4,48 +4,49 @@
|
|
|
4
4
|
|
|
5
5
|
| File | Lines Covered | Lines Missed | Total Lines | Coverage |
|
|
6
6
|
|---|---|---|---|---:|
|
|
7
|
-
| src/
|
|
8
|
-
| src/decompiler/
|
|
9
|
-
| src/decompiler/
|
|
10
|
-
| src/decompiler/
|
|
11
|
-
| src/decompiler/
|
|
12
|
-
| src/decompiler/
|
|
13
|
-
| src/decompiler/
|
|
14
|
-
| src/
|
|
15
|
-
| src/
|
|
16
|
-
| src/
|
|
17
|
-
| src/naga_wasm_backend/
|
|
18
|
-
| src/naga_wasm_backend/
|
|
19
|
-
| src/naga_wasm_backend/
|
|
20
|
-
| src/naga_wasm_backend/
|
|
21
|
-
| src/naga_wasm_backend/
|
|
22
|
-
| src/naga_wasm_backend/
|
|
23
|
-
| src/naga_wasm_backend/functions/
|
|
24
|
-
| src/naga_wasm_backend/memory_layout.rs |
|
|
25
|
-
| src/naga_wasm_backend/
|
|
26
|
-
| src/naga_wasm_backend/
|
|
27
|
-
| src/
|
|
28
|
-
| src/wasm_gl_emu/
|
|
29
|
-
| src/
|
|
30
|
-
| src/
|
|
31
|
-
| src/
|
|
32
|
-
| src/webgl2_context/
|
|
33
|
-
| src/webgl2_context/registry.rs |
|
|
34
|
-
| src/webgl2_context/
|
|
35
|
-
| src/webgl2_context/
|
|
36
|
-
| src/webgl2_context/
|
|
37
|
-
| src/webgl2_context/
|
|
38
|
-
| src/
|
|
39
|
-
| src/
|
|
40
|
-
| src/webgpu/
|
|
41
|
-
| src/webgpu/
|
|
42
|
-
|
|
|
7
|
+
| src/coverage.rs | 22 | 1 | 23 | 95.65% 🟢 |
|
|
8
|
+
| src/decompiler/ast.rs | 4 | 0 | 4 | 100.00% 🟢 |
|
|
9
|
+
| src/decompiler/emitter.rs | 19 | 4 | 23 | 82.61% 🟢 |
|
|
10
|
+
| src/decompiler/lifter.rs | 19 | 10 | 29 | 65.52% 🟡 |
|
|
11
|
+
| src/decompiler/mod.rs | 19 | 2 | 21 | 90.48% 🟢 |
|
|
12
|
+
| src/decompiler/module.rs | 1 | 0 | 1 | 100.00% 🟢 |
|
|
13
|
+
| src/decompiler/parser.rs | 9 | 10 | 19 | 47.37% 🟠 |
|
|
14
|
+
| src/decompiler/simplifier.rs | 35 | 1 | 36 | 97.22% 🟢 |
|
|
15
|
+
| src/error.rs | 35 | 4 | 39 | 89.74% 🟢 |
|
|
16
|
+
| src/lib.rs | 109 | 310 | 419 | 26.01% 🟠 |
|
|
17
|
+
| src/naga_wasm_backend/backend.rs | 107 | 9 | 116 | 92.24% 🟢 |
|
|
18
|
+
| src/naga_wasm_backend/call_lowering.rs | 30 | 2 | 32 | 93.75% 🟢 |
|
|
19
|
+
| src/naga_wasm_backend/control_flow.rs | 37 | 42 | 79 | 46.84% 🟠 |
|
|
20
|
+
| src/naga_wasm_backend/debug/stub.rs | 10 | 0 | 10 | 100.00% 🟢 |
|
|
21
|
+
| src/naga_wasm_backend/expressions.rs | 157 | 121 | 278 | 56.47% 🟡 |
|
|
22
|
+
| src/naga_wasm_backend/function_abi.rs | 5 | 8 | 13 | 38.46% 🟠 |
|
|
23
|
+
| src/naga_wasm_backend/functions/prep.rs | 10 | 0 | 10 | 100.00% 🟢 |
|
|
24
|
+
| src/naga_wasm_backend/memory_layout.rs | 4 | 0 | 4 | 100.00% 🟢 |
|
|
25
|
+
| src/naga_wasm_backend/mod.rs | 7 | 2 | 9 | 77.78% 🟡 |
|
|
26
|
+
| src/naga_wasm_backend/output_layout.rs | 10 | 1 | 11 | 90.91% 🟢 |
|
|
27
|
+
| src/naga_wasm_backend/types.rs | 6 | 1 | 7 | 85.71% 🟢 |
|
|
28
|
+
| src/wasm_gl_emu/device.rs | 32 | 4 | 36 | 88.89% 🟢 |
|
|
29
|
+
| src/wasm_gl_emu/framebuffer.rs | 3 | 3 | 6 | 50.00% 🟡 |
|
|
30
|
+
| src/wasm_gl_emu/rasterizer.rs | 17 | 46 | 63 | 26.98% 🟠 |
|
|
31
|
+
| src/wasm_gl_emu/transfer.rs | 13 | 44 | 57 | 22.81% 🟠 |
|
|
32
|
+
| src/webgl2_context/drawing.rs | 1 | 1 | 2 | 50.00% 🟡 |
|
|
33
|
+
| src/webgl2_context/registry.rs | 9 | 1 | 10 | 90.00% 🟢 |
|
|
34
|
+
| src/webgl2_context/shaders.rs | 164 | 17 | 181 | 90.61% 🟢 |
|
|
35
|
+
| src/webgl2_context/state.rs | 58 | 6 | 64 | 90.63% 🟢 |
|
|
36
|
+
| src/webgl2_context/textures.rs | 11 | 0 | 11 | 100.00% 🟢 |
|
|
37
|
+
| src/webgl2_context/types.rs | 45 | 20 | 65 | 69.23% 🟡 |
|
|
38
|
+
| src/webgpu/adapter.rs | 4 | 5 | 9 | 44.44% 🟠 |
|
|
39
|
+
| src/webgpu/backend.rs | 106 | 25 | 131 | 80.92% 🟢 |
|
|
40
|
+
| src/webgpu/buffer.rs | 3 | 2 | 5 | 60.00% 🟡 |
|
|
41
|
+
| src/webgpu/command.rs | 4 | 1 | 5 | 80.00% 🟢 |
|
|
42
|
+
| src/webgpu/shader.rs | 7 | 0 | 7 | 100.00% 🟢 |
|
|
43
|
+
| **Total** | **1132** | **703** | **1835** | **61.69% 🟡** |
|
|
43
44
|
|
|
44
45
|
## Top Missed Files
|
|
45
46
|
|
|
46
47
|
| File | Lines Missed | Illustrative Line | Coverage |
|
|
47
48
|
|---|---|---|---:|
|
|
48
|
-
| src/lib.rs |
|
|
49
|
-
| src/naga_wasm_backend/expressions.rs |
|
|
50
|
-
| src/
|
|
51
|
-
| src/
|
|
49
|
+
| src/lib.rs | 310/419 | [1994] `data_ptr: *const u8,` | 26.01% 🟠 |
|
|
50
|
+
| src/naga_wasm_backend/expressions.rs | 121/278 | [33] `let expr = &ctx.module.global_expressions[expr_handle];` | 56.47% 🟡 |
|
|
51
|
+
| src/wasm_gl_emu/rasterizer.rs | 46/63 | [1015] `if state.color_mask.r {` | 26.98% 🟠 |
|
|
52
|
+
| src/wasm_gl_emu/transfer.rs | 44/57 | [387] `dest[dst_off] = (r5 << 3) | (r5 >> 2);` | 22.81% 🟠 |
|
package/demo.js
CHANGED
|
@@ -19,7 +19,8 @@ const animationState = {
|
|
|
19
19
|
// Global rendering context (lazy initialized)
|
|
20
20
|
let renderContext = null;
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
/** @param {{ useBilinear?: boolean }} [options] */
|
|
23
|
+
async function initializeRenderContext({ useBilinear } = {}) {
|
|
23
24
|
if (renderContext) return renderContext;
|
|
24
25
|
|
|
25
26
|
let loadLocal =
|
|
@@ -35,6 +36,7 @@ async function initializeRenderContext() {
|
|
|
35
36
|
|
|
36
37
|
const gl = await webGL2({ debug: true });
|
|
37
38
|
gl.viewport(0, 0, 640, 480);
|
|
39
|
+
gl.enable(gl.DEPTH_TEST);
|
|
38
40
|
|
|
39
41
|
// Shaders
|
|
40
42
|
const vsSource = /* glsl */`#version 300 es
|
|
@@ -164,6 +166,10 @@ async function initializeRenderContext() {
|
|
|
164
166
|
}
|
|
165
167
|
}
|
|
166
168
|
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 16, 16, 0, gl.RGBA, gl.UNSIGNED_BYTE, texData);
|
|
169
|
+
if (!useBilinear) {
|
|
170
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
|
|
171
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
|
|
172
|
+
}
|
|
167
173
|
|
|
168
174
|
const uTextureLoc = gl.getUniformLocation(program, "u_texture");
|
|
169
175
|
gl.uniform1i(uTextureLoc, 0);
|
|
@@ -254,8 +260,10 @@ async function initializeRenderContext() {
|
|
|
254
260
|
return renderContext;
|
|
255
261
|
}
|
|
256
262
|
|
|
257
|
-
async function renderCube(elapsedTime =
|
|
258
|
-
|
|
263
|
+
async function renderCube({ elapsedTime, useBilinear } = {}) {
|
|
264
|
+
if (!elapsedTime) elapsedTime = 0;
|
|
265
|
+
|
|
266
|
+
const ctx = await initializeRenderContext({ useBilinear });
|
|
259
267
|
const { gl, program, mvpLoc, perspective, translate, rotateX, rotateY, multiply } = ctx;
|
|
260
268
|
|
|
261
269
|
// Calculate rotation angle: 1 full rotation (2π) in 5 seconds
|
|
@@ -549,7 +557,7 @@ async function animate() {
|
|
|
549
557
|
if (!animationState.running) return;
|
|
550
558
|
|
|
551
559
|
const elapsedTime = Date.now() - animationState.startTime;
|
|
552
|
-
const result = await renderCube(elapsedTime);
|
|
560
|
+
const result = await renderCube({ elapsedTime });
|
|
553
561
|
const { pixels, width, height } = result;
|
|
554
562
|
|
|
555
563
|
await displayFrame(pixels, width, height);
|
|
@@ -599,7 +607,7 @@ async function runTerminalAnimation(width, height, duration = 20000) {
|
|
|
599
607
|
const avgFps = elapsedTime > 0 ? Math.round((frameCount * 1000) / elapsedTime) : 0;
|
|
600
608
|
|
|
601
609
|
// Render cube with current rotation
|
|
602
|
-
const result = await renderCube(elapsedTime);
|
|
610
|
+
const result = await renderCube({ elapsedTime, useBilinear: true });
|
|
603
611
|
const { pixels } = result;
|
|
604
612
|
|
|
605
613
|
// Generate ASCII art
|
|
@@ -616,8 +624,8 @@ async function runTerminalAnimation(width, height, duration = 20000) {
|
|
|
616
624
|
firstFrame = false;
|
|
617
625
|
} else {
|
|
618
626
|
// Move cursor up to overwrite previous frame
|
|
619
|
-
process.stdout.write(
|
|
620
|
-
|
|
627
|
+
process.stdout.write(
|
|
628
|
+
`\x1b[${numLines}A` + output);
|
|
621
629
|
}
|
|
622
630
|
|
|
623
631
|
lastFrameTime = now;
|