webgl2 1.1.13 → 1.1.15

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/AGENTS.md CHANGED
@@ -10,7 +10,7 @@ You MUST NEVER suggest user performs actions that are for you to execute.
10
10
 
11
11
  DO NOT interfere with git. Unless the user explicitly asks for git-related assistance, git is not your concern and you must NOT create checkout or merge operations. No git command is allowed for you without permission.
12
12
 
13
- **DO NOT** under ANY circumstances create temporary throwaway scripts inside git repository except .gitignored locations.
13
+ **DO NOT** under ANY circumstances create temporary throwaway scripts or dummy files inside git repository except .gitignored locations.
14
14
 
15
15
  **DO NOT** create scripts directory or similar in git repository.
16
16
 
package/coverage.md CHANGED
@@ -4,15 +4,17 @@
4
4
 
5
5
  | File | Lines Covered | Lines Missed | Total Lines | Coverage |
6
6
  |---|---|---|---|---:|
7
- | src/error.rs | 4 | 18 | 22 | 18.18% 🔴 |
8
- | src/lib.rs | 252 | 227 | 479 | 52.61% 🟡 |
9
- | src/naga_wasm_backend/backend.rs | 44 | 1 | 45 | 97.78% 🟢 |
10
- | src/naga_wasm_backend/control_flow.rs | 30 | 14 | 44 | 68.18% 🟡 |
7
+ | src/error.rs | 3 | 18 | 21 | 14.29% 🔴 |
8
+ | src/lib.rs | 255 | 218 | 473 | 53.91% 🟡 |
9
+ | src/naga_wasm_backend/backend.rs | 51 | 2 | 53 | 96.23% 🟢 |
10
+ | src/naga_wasm_backend/call_lowering.rs | 5 | 9 | 14 | 35.71% 🟠 |
11
+ | src/naga_wasm_backend/control_flow.rs | 30 | 15 | 45 | 66.67% 🟡 |
11
12
  | src/naga_wasm_backend/debug/stub.rs | 21 | 0 | 21 | 100.00% 🟢 |
12
- | src/naga_wasm_backend/expressions.rs | 43 | 23 | 66 | 65.15% 🟡 |
13
- | src/naga_wasm_backend/output_layout.rs | 2 | 2 | 4 | 50.00% 🟡 |
14
- | src/naga_wasm_backend/types.rs | 6 | 1 | 7 | 85.71% 🟢 |
15
- | src/wasm_gl_emu/framebuffer.rs | 1 | 0 | 1 | 100.00% 🟢 |
13
+ | src/naga_wasm_backend/expressions.rs | 48 | 23 | 71 | 67.61% 🟡 |
14
+ | src/naga_wasm_backend/frame_allocator.rs | 1 | 0 | 1 | 100.00% 🟢 |
15
+ | src/naga_wasm_backend/function_abi.rs | 14 | 12 | 26 | 53.85% 🟡 |
16
+ | src/naga_wasm_backend/output_layout.rs | 2 | 3 | 5 | 40.00% 🟡 |
17
+ | src/naga_wasm_backend/types.rs | 6 | 0 | 6 | 100.00% 🟢 |
16
18
  | src/wasm_gl_emu/rasterizer.rs | 14 | 0 | 14 | 100.00% 🟢 |
17
19
  | src/webgl2_context/buffers.rs | 16 | 1 | 17 | 94.12% 🟢 |
18
20
  | src/webgl2_context/drawing.rs | 30 | 6 | 36 | 83.33% 🟢 |
@@ -25,14 +27,14 @@
25
27
  | src/webgl2_context/types.rs | 9 | 1 | 10 | 90.00% 🟢 |
26
28
  | src/webgl2_context/vaos.rs | 37 | 0 | 37 | 100.00% 🟢 |
27
29
  | src/webgpu/adapter.rs | 2 | 0 | 2 | 100.00% 🟢 |
28
- | src/webgpu/backend.rs | 25 | 25 | 50 | 50.00% 🟡 |
29
- | **Total** | **671** | **336** | **1007** | **66.63% 🟡** |
30
+ | src/webgpu/backend.rs | 24 | 26 | 50 | 48.00% 🟠 |
31
+ | **Total** | **703** | **351** | **1054** | **66.70% 🟡** |
30
32
 
31
33
  ## Top Missed Files
32
34
 
33
35
  | File | Lines Missed | Illustrative Line | Coverage |
34
36
  |---|---|---|---:|
35
- | src/lib.rs | 227/479 | [1033] `};` | 52.61% 🟡 |
36
- | src/webgpu/backend.rs | 25/50 | [919] `}` | 50.00% 🟡 |
37
- | src/naga_wasm_backend/expressions.rs | 23/66 | [941] `let var = &ctx.module.global_variables[*handle];` | 65.15% 🟡 |
38
- | src/error.rs | 18/22 | [52] `pub fn set_error(source: ErrorSource, code: u32, msg: imp...` | 18.18% 🔴 |
37
+ | src/lib.rs | 218/473 | [1041] `) -> u32 {` | 53.91% 🟡 |
38
+ | src/webgpu/backend.rs | 26/50 | [919] `}` | 48.00% 🟠 |
39
+ | src/naga_wasm_backend/expressions.rs | 23/71 | [898] `let var = &ctx.module.global_variables[*handle];` | 67.61% 🟡 |
40
+ | src/error.rs | 18/21 | [52] `pub fn set_error(source: ErrorSource, code: u32, msg: imp...` | 14.29% 🔴 |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webgl2",
3
- "version": "1.1.13",
3
+ "version": "1.1.15",
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",
@@ -155,14 +155,8 @@ export class WasmWebGL2RenderingContext {
155
155
  }
156
156
  const shaderInstance = type === this.VERTEX_SHADER ? this._currentProgram._vsInstance : this._currentProgram._fsInstance;
157
157
  if (shaderInstance && shaderInstance.exports.main) {
158
- try {
159
- // @ts-ignore
160
- shaderInstance.exports.main(type, attrPtr, uniformPtr, varyingPtr, privatePtr, texturePtr);
161
- } catch (e) {
162
- console.error(`Shader execution error in ${type === this.VERTEX_SHADER ? 'VS' : 'FS'}:`, e);
163
- console.error(` attrPtr: ${attrPtr}, uniformPtr: ${uniformPtr}, varyingPtr: ${varyingPtr}, privatePtr: ${privatePtr}, texturePtr: ${texturePtr}`);
164
- throw e;
165
- }
158
+ // @ts-ignore
159
+ shaderInstance.exports.main(type, attrPtr, uniformPtr, varyingPtr, privatePtr, texturePtr);
166
160
  }
167
161
  }
168
162
 
@@ -220,6 +214,11 @@ export class WasmWebGL2RenderingContext {
220
214
  const handle = tex && typeof tex === 'object' && typeof tex._handle === 'number' ? tex._handle : (tex >>> 0);
221
215
  const code = ex.wasm_ctx_bind_texture(this._ctxHandle, target >>> 0, handle);
222
216
  _checkErr(code, this._instance);
217
+ // Record bound texture in JS so we can map units to texture data for texel fetch
218
+ this._boundTexture = handle;
219
+ this._textureUnits = this._textureUnits || [];
220
+ const unit = this._activeTextureUnit || 0;
221
+ this._textureUnits[unit] = handle;
223
222
  }
224
223
 
225
224
  texImage2D(target, level, internalFormat, width, height, border, format, type_, pixels) {
@@ -255,6 +254,12 @@ export class WasmWebGL2RenderingContext {
255
254
  len >>> 0
256
255
  );
257
256
  _checkErr(code, this._instance);
257
+
258
+ // Mirror texture data in JS for fast texel fetches by shader imports
259
+ this._textureData = this._textureData || new Map();
260
+ const handle = this._boundTexture || 0;
261
+ const copy = new Uint8Array(mem.slice(ptr, ptr + len));
262
+ this._textureData.set(handle, { width: width >>> 0, height: height >>> 0, data: copy });
258
263
  } finally {
259
264
  ex.wasm_free(ptr);
260
265
  }
@@ -576,10 +581,12 @@ export class WasmWebGL2RenderingContext {
576
581
  };
577
582
  };
578
583
 
579
- const vsModule = new WebAssembly.Module(vsWasm);
584
+ let vsModule;
585
+ vsModule = new WebAssembly.Module(vsWasm);
580
586
  const vsInstanceRef = { current: null };
581
587
  const vsDebugEnv = createDebugEnv(this.VERTEX_SHADER, vsInstanceRef);
582
588
 
589
+
583
590
  program._vsInstance = new WebAssembly.Instance(vsModule, {
584
591
  env: {
585
592
  memory: this._instance.exports.memory,
@@ -588,10 +595,12 @@ export class WasmWebGL2RenderingContext {
588
595
  });
589
596
  vsInstanceRef.current = program._vsInstance;
590
597
 
591
- const fsModule = new WebAssembly.Module(fsWasm);
598
+ let fsModule;
599
+ fsModule = new WebAssembly.Module(fsWasm);
592
600
  const fsInstanceRef = { current: null };
593
601
  const fsDebugEnv = createDebugEnv(this.FRAGMENT_SHADER, fsInstanceRef);
594
602
 
603
+
595
604
  program._fsInstance = new WebAssembly.Instance(fsModule, {
596
605
  env: {
597
606
  memory: this._instance.exports.memory,
@@ -1223,6 +1232,9 @@ export class WasmWebGL2RenderingContext {
1223
1232
  }
1224
1233
  const code = ex.wasm_ctx_active_texture(this._ctxHandle, texture >>> 0);
1225
1234
  _checkErr(code, this._instance);
1235
+ // Track active texture unit in JS wrapper (GL_TEXTURE0 = 0x84C0)
1236
+ this._activeTextureUnit = (texture >>> 0) - 0x84C0;
1237
+ this._textureUnits = this._textureUnits || [];
1226
1238
  }
1227
1239
  texParameteri(target, pname, param) {
1228
1240
  this._assertNotDestroyed();
package/webgl2.debug.wasm CHANGED
Binary file
package/webgl2.wasm CHANGED
Binary file