webgl2 1.1.8 → 1.1.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/coverage.md CHANGED
@@ -4,33 +4,34 @@
4
4
 
5
5
  | File | Lines Covered | Lines Missed | Total Lines | Coverage |
6
6
  |---|---|---|---|---:|
7
- | src/lib.rs | 108 | 30 | 138 | 78.26% 🟡 |
8
- | src/naga_wasm_backend/backend.rs | 43 | 2 | 45 | 95.56% 🟢 |
9
- | src/naga_wasm_backend/control_flow.rs | 25 | 11 | 36 | 69.44% 🟡 |
7
+ | src/lib.rs | 110 | 29 | 139 | 79.14% 🟡 |
8
+ | src/naga_wasm_backend/backend.rs | 43 | 1 | 44 | 97.73% 🟢 |
9
+ | src/naga_wasm_backend/control_flow.rs | 30 | 12 | 42 | 71.43% 🟡 |
10
10
  | src/naga_wasm_backend/debug/stub.rs | 20 | 0 | 20 | 100.00% 🟢 |
11
- | src/naga_wasm_backend/expressions.rs | 41 | 19 | 60 | 68.33% 🟡 |
12
- | src/naga_wasm_backend/types.rs | 7 | 0 | 7 | 100.00% 🟢 |
11
+ | src/naga_wasm_backend/expressions.rs | 40 | 19 | 59 | 67.80% 🟡 |
12
+ | src/naga_wasm_backend/output_layout.rs | 1 | 1 | 2 | 50.00% 🟡 |
13
+ | src/naga_wasm_backend/types.rs | 6 | 0 | 6 | 100.00% 🟢 |
13
14
  | src/wasm_gl_emu/framebuffer.rs | 1 | 0 | 1 | 100.00% 🟢 |
14
- | src/wasm_gl_emu/rasterizer.rs | 14 | 0 | 14 | 100.00% 🟢 |
15
+ | src/wasm_gl_emu/rasterizer.rs | 20 | 2 | 22 | 90.91% 🟢 |
15
16
  | src/webgl2_context/buffers.rs | 15 | 1 | 16 | 93.75% 🟢 |
16
- | src/webgl2_context/drawing.rs | 29 | 4 | 33 | 87.88% 🟢 |
17
+ | src/webgl2_context/drawing.rs | 34 | 7 | 41 | 82.93% 🟢 |
17
18
  | src/webgl2_context/framebuffers.rs | 8 | 0 | 8 | 100.00% 🟢 |
18
19
  | src/webgl2_context/registry.rs | 5 | 0 | 5 | 100.00% 🟢 |
19
- | src/webgl2_context/renderbuffers.rs | 10 | 0 | 10 | 100.00% 🟢 |
20
- | src/webgl2_context/shaders.rs | 70 | 3 | 73 | 95.89% 🟢 |
21
- | src/webgl2_context/state.rs | 13 | 3 | 16 | 81.25% 🟢 |
20
+ | src/webgl2_context/renderbuffers.rs | 11 | 0 | 11 | 100.00% 🟢 |
21
+ | src/webgl2_context/shaders.rs | 80 | 13 | 93 | 86.02% 🟢 |
22
+ | src/webgl2_context/state.rs | 14 | 2 | 16 | 87.50% 🟢 |
22
23
  | src/webgl2_context/textures.rs | 10 | 0 | 10 | 100.00% 🟢 |
23
- | src/webgl2_context/types.rs | 11 | 1 | 12 | 91.67% 🟢 |
24
- | src/webgl2_context/vaos.rs | 37 | 0 | 37 | 100.00% 🟢 |
24
+ | src/webgl2_context/types.rs | 10 | 2 | 12 | 83.33% 🟢 |
25
+ | src/webgl2_context/vaos.rs | 36 | 0 | 36 | 100.00% 🟢 |
25
26
  | src/webgpu/adapter.rs | 3 | 0 | 3 | 100.00% 🟢 |
26
- | src/webgpu/backend.rs | 25 | 25 | 50 | 50.00% 🟡 |
27
- | **Total** | **495** | **99** | **594** | **83.33% 🟢** |
27
+ | src/webgpu/backend.rs | 24 | 26 | 50 | 48.00% 🟠 |
28
+ | **Total** | **521** | **115** | **636** | **81.92% 🟢** |
28
29
 
29
30
  ## Top Missed Files
30
31
 
31
32
  | File | Lines Missed | Illustrative Line | Coverage |
32
33
  |---|---|---|---:|
33
- | src/lib.rs | 30/138 | [516] `/// Set uniform 3f.` | 78.26% 🟡 |
34
- | src/webgpu/backend.rs | 25/50 | [919] `}` | 50.00% 🟡 |
35
- | src/naga_wasm_backend/expressions.rs | 19/60 | [11] `pub fn is_integer_type(type_inner: &TypeInner) -> bool {` | 68.33% 🟡 |
36
- | src/naga_wasm_backend/control_flow.rs | 11/36 | [181] `for i in (0..types.len()).rev() {` | 69.44% 🟡 |
34
+ | src/lib.rs | 29/139 | [1011] `#[no_mangle]` | 79.14% 🟡 |
35
+ | src/webgpu/backend.rs | 26/50 | [919] `}` | 48.00% 🟠 |
36
+ | src/naga_wasm_backend/expressions.rs | 19/59 | [11] `pub fn is_integer_type(type_inner: &TypeInner) -> bool {` | 67.80% 🟡 |
37
+ | src/webgl2_context/shaders.rs | 13/93 | [575] `if !varying_locations.values().any(|&v| v == *loc) {` | 86.02% 🟢 |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webgl2",
3
- "version": "1.1.8",
3
+ "version": "1.1.9",
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",
@@ -162,8 +162,6 @@ export class WasmWebGL2RenderingContext {
162
162
  console.error(` attrPtr: ${attrPtr}, uniformPtr: ${uniformPtr}, varyingPtr: ${varyingPtr}, privatePtr: ${privatePtr}, texturePtr: ${texturePtr}`);
163
163
  throw e;
164
164
  }
165
- } else {
166
- // console.log(`DEBUG: Shader instance or main missing for type ${type}. Instance: ${!!shaderInstance}`);
167
165
  }
168
166
  }
169
167
 
@@ -518,9 +516,15 @@ export class WasmWebGL2RenderingContext {
518
516
  const code = ex.wasm_ctx_link_program(this._ctxHandle, programHandle);
519
517
  _checkErr(code, this._instance);
520
518
 
521
- // After linking, we need to instantiate the WASM modules on the host
519
+ // After linking, we need to instantiate the WASM modules on the host.
520
+ // According to the WebGL 2.0 Spec (https://registry.khronos.org/webgl/specs/latest/2.0/#3.7.6),
521
+ // linkProgram sets the LINK_STATUS parameter. If linking fails, no executable is generated.
522
+ // We must check LINK_STATUS before attempting to instantiate the WASM, as getProgramWasm will return null.
522
523
  if (program && typeof program === 'object') {
523
- this._instantiateProgramShaders(program);
524
+ const linkStatus = this.getProgramParameter(program, this.LINK_STATUS);
525
+ if (linkStatus) {
526
+ this._instantiateProgramShaders(program);
527
+ }
524
528
  }
525
529
  }
526
530
 
@@ -571,40 +575,29 @@ export class WasmWebGL2RenderingContext {
571
575
  };
572
576
  };
573
577
 
574
- if (vsWasm) {
575
- try {
576
- const vsModule = new WebAssembly.Module(vsWasm);
577
- const instanceRef = { current: null };
578
- const debugEnv = createDebugEnv(this.VERTEX_SHADER, instanceRef);
579
-
580
- program._vsInstance = new WebAssembly.Instance(vsModule, {
581
- env: {
582
- memory: this._instance.exports.memory,
583
- ...debugEnv
584
- }
585
- });
586
- instanceRef.current = program._vsInstance;
587
- } catch (e) {
588
- console.log(`DEBUG: VS Instance creation failed: ${e}`);
578
+ const vsModule = new WebAssembly.Module(vsWasm);
579
+ const vsInstanceRef = { current: null };
580
+ const vsDebugEnv = createDebugEnv(this.VERTEX_SHADER, vsInstanceRef);
581
+
582
+ program._vsInstance = new WebAssembly.Instance(vsModule, {
583
+ env: {
584
+ memory: this._instance.exports.memory,
585
+ ...vsDebugEnv
589
586
  }
590
- }
591
- if (fsWasm) {
592
- try {
593
- const fsModule = new WebAssembly.Module(fsWasm);
594
- const instanceRef = { current: null };
595
- const debugEnv = createDebugEnv(this.FRAGMENT_SHADER, instanceRef);
596
-
597
- program._fsInstance = new WebAssembly.Instance(fsModule, {
598
- env: {
599
- memory: this._instance.exports.memory,
600
- ...debugEnv
601
- }
602
- });
603
- instanceRef.current = program._fsInstance;
604
- } catch (e) {
605
- console.log(`DEBUG: FS Instance creation failed: ${e}`);
587
+ });
588
+ vsInstanceRef.current = program._vsInstance;
589
+
590
+ const fsModule = new WebAssembly.Module(fsWasm);
591
+ const fsInstanceRef = { current: null };
592
+ const fsDebugEnv = createDebugEnv(this.FRAGMENT_SHADER, fsInstanceRef);
593
+
594
+ program._fsInstance = new WebAssembly.Instance(fsModule, {
595
+ env: {
596
+ memory: this._instance.exports.memory,
597
+ ...fsDebugEnv
606
598
  }
607
- }
599
+ });
600
+ fsInstanceRef.current = program._fsInstance;
608
601
  }
609
602
 
610
603
  getProgramDebugStub(program, shaderType) {
@@ -1352,7 +1345,8 @@ export class WasmWebGL2RenderingContext {
1352
1345
  try {
1353
1346
  const mem = new Uint8Array(ex.memory.buffer);
1354
1347
  mem.set(bytes, ptr);
1355
- const code = ex.wasm_ctx_uniform_matrix_4fv(this._ctxHandle, locHandle, transpose ? 1 : 0, ptr, len);
1348
+ const count = len / 4;
1349
+ const code = ex.wasm_ctx_uniform_matrix_4fv(this._ctxHandle, locHandle, transpose ? 1 : 0, ptr, count);
1356
1350
  _checkErr(code, this._instance);
1357
1351
  } finally {
1358
1352
  ex.wasm_free(ptr);
package/webgl2.debug.wasm CHANGED
Binary file
package/webgl2.wasm CHANGED
Binary file