webgl2 1.2.7 → 1.3.0

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,47 +4,50 @@
4
4
 
5
5
  | File | Lines Covered | Lines Missed | Total Lines | Coverage |
6
6
  |---|---|---|---|---:|
7
- | src/coverage.rs | 5 | 0 | 5 | 100.00% 🟢 |
8
- | src/decompiler/ast.rs | 2 | 0 | 2 | 100.00% 🟢 |
9
- | src/decompiler/emitter.rs | 2 | 1 | 3 | 66.67% 🟡 |
10
- | src/decompiler/lifter.rs | 4 | 2 | 6 | 66.67% 🟡 |
11
- | src/decompiler/simplifier.rs | 44 | 0 | 44 | 100.00% 🟢 |
12
- | src/error.rs | 31 | 6 | 37 | 83.78% 🟢 |
13
- | src/lib.rs | 99 | 314 | 413 | 23.97% 🟠 |
14
- | src/naga_wasm_backend/backend.rs | 148 | 47 | 195 | 75.90% 🟡 |
15
- | src/naga_wasm_backend/call_lowering.rs | 26 | 3 | 29 | 89.66% 🟢 |
16
- | src/naga_wasm_backend/control_flow.rs | 38 | 44 | 82 | 46.34% 🟠 |
17
- | src/naga_wasm_backend/debug/stub.rs | 11 | 0 | 11 | 100.00% 🟢 |
18
- | src/naga_wasm_backend/expressions.rs | 158 | 153 | 311 | 50.80% 🟡 |
19
- | src/naga_wasm_backend/function_abi.rs | 24 | 11 | 35 | 68.57% 🟡 |
20
- | src/naga_wasm_backend/functions/prep.rs | 7 | 2 | 9 | 77.78% 🟡 |
21
- | src/naga_wasm_backend/functions/registry.rs | 4 | 1 | 5 | 80.00% 🟢 |
22
- | src/naga_wasm_backend/mod.rs | 5 | 3 | 8 | 62.50% 🟡 |
23
- | src/naga_wasm_backend/output_layout.rs | 11 | 2 | 13 | 84.62% 🟢 |
24
- | src/naga_wasm_backend/types.rs | 18 | 4 | 22 | 81.82% 🟢 |
25
- | src/wasm_gl_emu/device.rs | 2 | 0 | 2 | 100.00% 🟢 |
26
- | src/wasm_gl_emu/framebuffer.rs | 4 | 1 | 5 | 80.00% 🟢 |
27
- | src/wasm_gl_emu/rasterizer.rs | 25 | 24 | 49 | 51.02% 🟡 |
28
- | src/wasm_gl_emu/transfer.rs | 11 | 12 | 23 | 47.83% 🟠 |
29
- | src/webgl2_context/buffers.rs | 4 | 0 | 4 | 100.00% 🟢 |
30
- | src/webgl2_context/drawing.rs | 36 | 1 | 37 | 97.30% 🟢 |
31
- | src/webgl2_context/renderbuffers.rs | 12 | 1 | 13 | 92.31% 🟢 |
32
- | src/webgl2_context/shaders.rs | 176 | 52 | 228 | 77.19% 🟡 |
33
- | src/webgl2_context/state.rs | 11 | 3 | 14 | 78.57% 🟡 |
34
- | src/webgl2_context/textures.rs | 10 | 3 | 13 | 76.92% 🟡 |
35
- | src/webgl2_context/types.rs | 5 | 1 | 6 | 83.33% 🟢 |
36
- | src/webgpu/adapter.rs | 8 | 0 | 8 | 100.00% 🟢 |
37
- | src/webgpu/backend.rs | 112 | 25 | 137 | 81.75% 🟢 |
38
- | src/webgpu/buffer.rs | 1 | 3 | 4 | 25.00% 🟡 |
39
- | src/webgpu/command.rs | 5 | 6 | 11 | 45.45% 🟠 |
40
- | src/webgpu/pipeline.rs | 0 | 1 | 1 | 0.00% 🟡 |
41
- | **Total** | **1059** | **726** | **1785** | **59.33% 🟡** |
7
+ | src/coverage.rs | 12 | 5 | 17 | 70.59% 🟡 |
8
+ | src/decompiler/ast.rs | 3 | 2 | 5 | 60.00% 🟡 |
9
+ | src/decompiler/emitter.rs | 6 | 0 | 6 | 100.00% 🟢 |
10
+ | src/decompiler/lifter.rs | 10 | 1 | 11 | 90.91% 🟢 |
11
+ | src/decompiler/module.rs | 1 | 0 | 1 | 100.00% 🟢 |
12
+ | src/decompiler/parser.rs | 15 | 5 | 20 | 75.00% 🟡 |
13
+ | src/decompiler/simplifier.rs | 35 | 6 | 41 | 85.37% 🟢 |
14
+ | src/error.rs | 34 | 7 | 41 | 82.93% 🟢 |
15
+ | src/lib.rs | 183 | 310 | 493 | 37.12% 🟠 |
16
+ | src/naga_wasm_backend/backend.rs | 161 | 29 | 190 | 84.74% 🟢 |
17
+ | src/naga_wasm_backend/call_lowering.rs | 10 | 5 | 15 | 66.67% 🟡 |
18
+ | src/naga_wasm_backend/control_flow.rs | 37 | 30 | 67 | 55.22% 🟡 |
19
+ | src/naga_wasm_backend/debug/stub.rs | 11 | 15 | 26 | 42.31% 🟠 |
20
+ | src/naga_wasm_backend/expressions.rs | 255 | 152 | 407 | 62.65% 🟡 |
21
+ | src/naga_wasm_backend/function_abi.rs | 14 | 5 | 19 | 73.68% 🟡 |
22
+ | src/naga_wasm_backend/functions/prep.rs | 8 | 0 | 8 | 100.00% 🟢 |
23
+ | src/naga_wasm_backend/functions/registry.rs | 1 | 0 | 1 | 100.00% 🟢 |
24
+ | src/naga_wasm_backend/memory_layout.rs | 12 | 0 | 12 | 100.00% 🟢 |
25
+ | src/naga_wasm_backend/mod.rs | 9 | 1 | 10 | 90.00% 🟢 |
26
+ | src/naga_wasm_backend/output_layout.rs | 7 | 2 | 9 | 77.78% 🟡 |
27
+ | src/naga_wasm_backend/types.rs | 14 | 6 | 20 | 70.00% 🟡 |
28
+ | src/wasm_gl_emu/framebuffer.rs | 1 | 0 | 1 | 100.00% 🟢 |
29
+ | src/wasm_gl_emu/rasterizer.rs | 38 | 26 | 64 | 59.38% 🟡 |
30
+ | src/wasm_gl_emu/transfer.rs | 1 | 0 | 1 | 100.00% 🟢 |
31
+ | src/webgl2_context/blend.rs | 6 | 0 | 6 | 100.00% 🟢 |
32
+ | src/webgl2_context/buffers.rs | 15 | 1 | 16 | 93.75% 🟢 |
33
+ | src/webgl2_context/drawing.rs | 31 | 1 | 32 | 96.88% 🟢 |
34
+ | src/webgl2_context/registry.rs | 13 | 1 | 14 | 92.86% 🟢 |
35
+ | src/webgl2_context/shaders.rs | 147 | 21 | 168 | 87.50% 🟢 |
36
+ | src/webgl2_context/state.rs | 15 | 16 | 31 | 48.39% 🟠 |
37
+ | src/webgl2_context/textures.rs | 52 | 0 | 52 | 100.00% 🟢 |
38
+ | src/webgl2_context/types.rs | 24 | 9 | 33 | 72.73% 🟡 |
39
+ | src/webgpu/adapter.rs | 13 | 6 | 19 | 68.42% 🟡 |
40
+ | src/webgpu/backend.rs | 72 | 9 | 81 | 88.89% 🟢 |
41
+ | src/webgpu/buffer.rs | 0 | 3 | 3 | 0.00% 🟡 |
42
+ | src/webgpu/command.rs | 23 | 4 | 27 | 85.19% 🟢 |
43
+ | src/webgpu/pipeline.rs | 1 | 0 | 1 | 100.00% 🟢 |
44
+ | **Total** | **1290** | **678** | **1968** | **65.55% 🟡** |
42
45
 
43
46
  ## Top Missed Files
44
47
 
45
48
  | File | Lines Missed | Illustrative Line | Coverage |
46
49
  |---|---|---|---:|
47
- | src/lib.rs | 314/413 | [1994] `}` | 23.97% 🟠 |
48
- | src/naga_wasm_backend/expressions.rs | 153/311 | [1555] `ctx.wasm_func.instruction(&Instruction::LocalSet(temp_b));` | 50.80% 🟡 |
49
- | src/webgl2_context/shaders.rs | 52/228 | [428] `used_locations.insert(loc, (name.clone(), origin));` | 77.19% 🟡 |
50
- | src/naga_wasm_backend/backend.rs | 47/195 | [110] `code: CodeSection::new(),` | 75.90% 🟡 |
50
+ | src/lib.rs | 310/493 | [1996] `}` | 37.12% 🟠 |
51
+ | src/naga_wasm_backend/expressions.rs | 152/407 | [1845] `translate_expression_component(*arg, j, ctx)?;` | 62.65% 🟡 |
52
+ | src/naga_wasm_backend/control_flow.rs | 30/67 | [488] `if let Some(ret) = &called_func.result {` | 55.22% 🟡 |
53
+ | src/naga_wasm_backend/backend.rs | 29/190 | [469] `func.instruction(&Instruction::F32Div);` | 84.74% 🟢 |
package/index.js CHANGED
@@ -269,26 +269,30 @@ async function initWASM({ debug } = {}) {
269
269
  ACTIVE_FRAME_SP: turboGlobals.ACTIVE_FRAME_SP,
270
270
  };
271
271
 
272
- // Map transcendental functions to JS Math equivalents for maximum accuracy
273
- env.gl_sin = Math.sin;
274
- env.gl_cos = Math.cos;
275
- env.gl_tan = Math.tan;
276
- env.gl_asin = Math.asin;
277
- env.gl_acos = Math.acos;
278
- env.gl_atan = Math.atan;
279
- env.gl_atan2 = Math.atan2;
280
- env.gl_exp = Math.exp;
281
- env.gl_exp2 = (x) => Math.pow(2, x);
282
- env.gl_log = Math.log;
283
- env.gl_log2 = Math.log2;
284
- env.gl_pow = Math.pow;
285
- env.gl_ldexp = (mant, exp) => mant * Math.pow(2, exp);
286
- env.gl_sinh = Math.sinh;
287
- env.gl_cosh = Math.cosh;
288
- env.gl_tanh = Math.tanh;
289
- env.gl_asinh = Math.asinh;
290
- env.gl_acosh = Math.acosh;
291
- env.gl_atanh = Math.atanh;
272
+ env.gl_sin = instance.exports.gl_sin;
273
+ env.gl_cos = instance.exports.gl_cos;
274
+ env.gl_tan = instance.exports.gl_tan;
275
+ env.gl_asin = instance.exports.gl_asin;
276
+ env.gl_acos = instance.exports.gl_acos;
277
+ env.gl_atan = instance.exports.gl_atan;
278
+ env.gl_atan2 = instance.exports.gl_atan2;
279
+ env.gl_exp = instance.exports.gl_exp;
280
+ env.gl_exp2 = instance.exports.gl_exp2;
281
+ env.gl_log = instance.exports.gl_log;
282
+ env.gl_log2 = instance.exports.gl_log2;
283
+ env.gl_pow = instance.exports.gl_pow;
284
+ env.gl_ldexp = instance.exports.gl_ldexp;
285
+ env.gl_sinh = instance.exports.gl_sinh;
286
+ env.gl_cosh = instance.exports.gl_cosh;
287
+ env.gl_tanh = instance.exports.gl_tanh;
288
+ env.gl_asinh = instance.exports.gl_asinh;
289
+ env.gl_acosh = instance.exports.gl_acosh;
290
+ env.gl_atanh = instance.exports.gl_atanh;
291
+
292
+ // Link diagnostic and math helpers from the main module
293
+ env.gl_debug4 = instance.exports.gl_debug4;
294
+ env.gl_inverse_mat2 = instance.exports.gl_inverse_mat2;
295
+ env.gl_inverse_mat3 = instance.exports.gl_inverse_mat3;
292
296
 
293
297
  const shaderInstance = new WebAssembly.Instance(shaderModule, { env });
294
298
  if (shaderInstance.exports.main) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webgl2",
3
- "version": "1.2.7",
3
+ "version": "1.3.0",
4
4
  "description": "WebGL2 tools to derisk large GPU projects on the web beyond toys and demos.",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -1036,7 +1036,10 @@ export class WasmWebGL2RenderingContext {
1036
1036
  const mathFuncs = [
1037
1037
  'gl_sin', 'gl_cos', 'gl_tan', 'gl_asin', 'gl_acos', 'gl_atan', 'gl_atan2',
1038
1038
  'gl_exp', 'gl_exp2', 'gl_log', 'gl_log2', 'gl_pow',
1039
- 'gl_sinh', 'gl_cosh', 'gl_tanh', 'gl_asinh', 'gl_acosh', 'gl_atanh'
1039
+ 'gl_sinh', 'gl_cosh', 'gl_tanh', 'gl_asinh', 'gl_acosh', 'gl_atanh',
1040
+ 'gl_inverse_mat2', 'gl_inverse_mat3',
1041
+ 'gl_debug4'
1042
+
1040
1043
  ];
1041
1044
  for (const name of mathFuncs) {
1042
1045
  if (this._instance.exports[name]) {
@@ -1056,7 +1059,19 @@ export class WasmWebGL2RenderingContext {
1056
1059
  }
1057
1060
 
1058
1061
  let fsModule;
1062
+ // Dump WASM to disk when debug_shaders is enabled to aid diagnostics
1063
+ if (this._debugShaders) {
1064
+ try {
1065
+ require('fs').writeFileSync('test_debug/failing_fragment.wasm', Buffer.from(fsWasm));
1066
+ } catch (e) {
1067
+ // Best-effort; ignore write failures in constrained environments
1068
+ }
1069
+ }
1070
+ if (this._debug) {
1071
+ console.log("Compiling FS Module...");
1072
+ }
1059
1073
  fsModule = new WebAssembly.Module(fsWasm);
1074
+
1060
1075
  const fsInstanceRef = { current: null };
1061
1076
  const fsDebugEnv = createDebugEnv(this.FRAGMENT_SHADER, fsInstanceRef);
1062
1077
 
@@ -1078,6 +1093,10 @@ export class WasmWebGL2RenderingContext {
1078
1093
  }
1079
1094
  }
1080
1095
 
1096
+ if (!fsEnv.gl_debug4) fsEnv.gl_debug4 = (a, b, c, d) => {};
1097
+ if (!fsEnv.gl_inverse_mat2) fsEnv.gl_inverse_mat2 = (in_ptr, out_ptr) => {};
1098
+ if (!fsEnv.gl_inverse_mat3) fsEnv.gl_inverse_mat3 = (in_ptr, out_ptr) => {};
1099
+
1081
1100
  program._fsInstance = new WebAssembly.Instance(fsModule, {
1082
1101
  env: fsEnv
1083
1102
  });
package/webgl2.debug.wasm CHANGED
Binary file
package/webgl2.wasm CHANGED
Binary file