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 CHANGED
@@ -4,48 +4,49 @@
4
4
 
5
5
  | File | Lines Covered | Lines Missed | Total Lines | Coverage |
6
6
  |---|---|---|---|---:|
7
- | src/decompiler/ast.rs | 0 | 1 | 1 | 0.00% 🟡 |
8
- | src/decompiler/emitter.rs | 17 | 8 | 25 | 68.00% 🟡 |
9
- | src/decompiler/lifter.rs | 17 | 21 | 38 | 44.74% 🟠 |
10
- | src/decompiler/mod.rs | 8 | 6 | 14 | 57.14% 🟡 |
11
- | src/decompiler/module.rs | 1 | 1 | 2 | 50.00% 🟡 |
12
- | src/decompiler/parser.rs | 17 | 2 | 19 | 89.47% 🟢 |
13
- | src/decompiler/simplifier.rs | 53 | 19 | 72 | 73.61% 🟡 |
14
- | src/error.rs | 7 | 15 | 22 | 31.82% 🟠 |
15
- | src/lib.rs | 315 | 210 | 525 | 60.00% 🟡 |
16
- | src/naga_wasm_backend/backend.rs | 62 | 2 | 64 | 96.88% 🟢 |
17
- | src/naga_wasm_backend/call_lowering.rs | 18 | 0 | 18 | 100.00% 🟢 |
18
- | src/naga_wasm_backend/control_flow.rs | 54 | 16 | 70 | 77.14% 🟡 |
19
- | src/naga_wasm_backend/debug/stub.rs | 20 | 0 | 20 | 100.00% 🟢 |
20
- | src/naga_wasm_backend/expressions.rs | 65 | 105 | 170 | 38.24% 🟠 |
21
- | src/naga_wasm_backend/function_abi.rs | 22 | 0 | 22 | 100.00% 🟢 |
22
- | src/naga_wasm_backend/functions/prep.rs | 4 | 0 | 4 | 100.00% 🟢 |
23
- | src/naga_wasm_backend/functions/registry.rs | 4 | 1 | 5 | 80.00% 🟢 |
24
- | src/naga_wasm_backend/memory_layout.rs | 9 | 0 | 9 | 100.00% 🟢 |
25
- | src/naga_wasm_backend/output_layout.rs | 2 | 2 | 4 | 50.00% 🟡 |
26
- | src/naga_wasm_backend/types.rs | 11 | 0 | 11 | 100.00% 🟢 |
27
- | src/wasm_gl_emu/framebuffer.rs | 1 | 0 | 1 | 100.00% 🟢 |
28
- | src/wasm_gl_emu/rasterizer.rs | 26 | 18 | 44 | 59.09% 🟡 |
29
- | src/webgl2_context/blend.rs | 2 | 1 | 3 | 66.67% 🟡 |
30
- | src/webgl2_context/buffers.rs | 18 | 1 | 19 | 94.74% 🟢 |
31
- | src/webgl2_context/drawing.rs | 26 | 3 | 29 | 89.66% 🟢 |
32
- | src/webgl2_context/framebuffers.rs | 10 | 0 | 10 | 100.00% 🟢 |
33
- | src/webgl2_context/registry.rs | 7 | 0 | 7 | 100.00% 🟢 |
34
- | src/webgl2_context/renderbuffers.rs | 11 | 0 | 11 | 100.00% 🟢 |
35
- | src/webgl2_context/shaders.rs | 113 | 12 | 125 | 90.40% 🟢 |
36
- | src/webgl2_context/state.rs | 23 | 1 | 24 | 95.83% 🟢 |
37
- | src/webgl2_context/textures.rs | 28 | 17 | 45 | 62.22% 🟡 |
38
- | src/webgl2_context/types.rs | 15 | 1 | 16 | 93.75% 🟢 |
39
- | src/webgl2_context/vaos.rs | 35 | 0 | 35 | 100.00% 🟢 |
40
- | src/webgpu/adapter.rs | 3 | 0 | 3 | 100.00% 🟢 |
41
- | src/webgpu/backend.rs | 25 | 27 | 52 | 48.08% 🟠 |
42
- | **Total** | **1049** | **490** | **1539** | **68.16% 🟡** |
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 | 210/525 | [1040] `/// Get active attribute info.` | 60.00% 🟡 |
49
- | src/naga_wasm_backend/expressions.rs | 105/170 | [1504] `for j in 0..count {` | 38.24% 🟠 |
50
- | src/webgpu/backend.rs | 27/52 | [965] `}` | 48.08% 🟠 |
51
- | src/decompiler/lifter.rs | 21/38 | [455] `fn unary_op(&mut self, op: UnaryOp) {` | 44.74% 🟠 |
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
- async function initializeRenderContext() {
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 = 0) {
258
- const ctx = await initializeRenderContext();
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(`\x1b[${numLines}A`);
620
- process.stdout.write(output);
627
+ process.stdout.write(
628
+ `\x1b[${numLines}A` + output);
621
629
  }
622
630
 
623
631
  lastFrameTime = now;