webgl2 1.3.1 → 1.3.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 +43 -42
- package/package.json +1 -1
- package/src/webgl2_context.js +93 -61
- package/webgl2.debug.wasm +0 -0
- package/webgl2.wasm +0 -0
package/coverage.md
CHANGED
|
@@ -4,52 +4,53 @@
|
|
|
4
4
|
|
|
5
5
|
| File | Lines Covered | Lines Missed | Total Lines | Coverage |
|
|
6
6
|
|---|---|---|---|---:|
|
|
7
|
-
| src/coverage.rs |
|
|
8
|
-
| src/decompiler/ast.rs |
|
|
9
|
-
| src/decompiler/emitter.rs |
|
|
7
|
+
| src/coverage.rs | 14 | 5 | 19 | 73.68% 🟡 |
|
|
8
|
+
| src/decompiler/ast.rs | 2 | 4 | 6 | 33.33% 🟡 |
|
|
9
|
+
| src/decompiler/emitter.rs | 27 | 4 | 31 | 87.10% 🟢 |
|
|
10
10
|
| src/decompiler/lifter.rs | 6 | 2 | 8 | 75.00% 🟡 |
|
|
11
|
-
| src/decompiler/
|
|
12
|
-
| src/decompiler/
|
|
13
|
-
| src/
|
|
14
|
-
| src/
|
|
15
|
-
| src/
|
|
11
|
+
| src/decompiler/mod.rs | 1 | 0 | 1 | 100.00% 🟢 |
|
|
12
|
+
| src/decompiler/parser.rs | 3 | 2 | 5 | 60.00% 🟡 |
|
|
13
|
+
| src/decompiler/simplifier.rs | 35 | 2 | 37 | 94.59% 🟢 |
|
|
14
|
+
| src/error.rs | 31 | 6 | 37 | 83.78% 🟢 |
|
|
15
|
+
| src/lib.rs | 151 | 331 | 482 | 31.33% 🟠 |
|
|
16
|
+
| src/naga_wasm_backend/backend.rs | 153 | 30 | 183 | 83.61% 🟢 |
|
|
16
17
|
| src/naga_wasm_backend/call_lowering.rs | 9 | 3 | 12 | 75.00% 🟡 |
|
|
17
|
-
| src/naga_wasm_backend/control_flow.rs |
|
|
18
|
-
| src/naga_wasm_backend/debug/stub.rs | 11 |
|
|
19
|
-
| src/naga_wasm_backend/expressions.rs | 270 |
|
|
20
|
-
| src/naga_wasm_backend/function_abi.rs |
|
|
21
|
-
| src/naga_wasm_backend/functions/prep.rs |
|
|
22
|
-
| src/naga_wasm_backend/functions/registry.rs |
|
|
23
|
-
| src/naga_wasm_backend/memory_layout.rs |
|
|
24
|
-
| src/naga_wasm_backend/mod.rs |
|
|
25
|
-
| src/naga_wasm_backend/output_layout.rs |
|
|
26
|
-
| src/naga_wasm_backend/types.rs |
|
|
27
|
-
| src/wasm_gl_emu/device.rs |
|
|
28
|
-
| src/wasm_gl_emu/framebuffer.rs |
|
|
29
|
-
| src/wasm_gl_emu/rasterizer.rs |
|
|
30
|
-
| src/wasm_gl_emu/transfer.rs |
|
|
31
|
-
| src/webgl2_context/
|
|
32
|
-
| src/webgl2_context/
|
|
33
|
-
| src/webgl2_context/
|
|
34
|
-
| src/webgl2_context/
|
|
35
|
-
| src/webgl2_context/
|
|
36
|
-
| src/webgl2_context/
|
|
37
|
-
| src/webgl2_context/
|
|
38
|
-
| src/webgl2_context/
|
|
39
|
-
| src/
|
|
40
|
-
| src/
|
|
41
|
-
| src/webgpu/
|
|
42
|
-
| src/webgpu/
|
|
43
|
-
| src/webgpu/
|
|
44
|
-
| src/webgpu/
|
|
45
|
-
| src/webgpu/
|
|
46
|
-
| **Total** | **
|
|
18
|
+
| src/naga_wasm_backend/control_flow.rs | 41 | 27 | 68 | 60.29% 🟡 |
|
|
19
|
+
| src/naga_wasm_backend/debug/stub.rs | 11 | 13 | 24 | 45.83% 🟠 |
|
|
20
|
+
| src/naga_wasm_backend/expressions.rs | 270 | 147 | 417 | 64.75% 🟡 |
|
|
21
|
+
| src/naga_wasm_backend/function_abi.rs | 19 | 5 | 24 | 79.17% 🟡 |
|
|
22
|
+
| src/naga_wasm_backend/functions/prep.rs | 4 | 0 | 4 | 100.00% 🟢 |
|
|
23
|
+
| src/naga_wasm_backend/functions/registry.rs | 5 | 0 | 5 | 100.00% 🟢 |
|
|
24
|
+
| src/naga_wasm_backend/memory_layout.rs | 12 | 0 | 12 | 100.00% 🟢 |
|
|
25
|
+
| src/naga_wasm_backend/mod.rs | 7 | 0 | 7 | 100.00% 🟢 |
|
|
26
|
+
| src/naga_wasm_backend/output_layout.rs | 5 | 0 | 5 | 100.00% 🟢 |
|
|
27
|
+
| src/naga_wasm_backend/types.rs | 23 | 6 | 29 | 79.31% 🟡 |
|
|
28
|
+
| src/wasm_gl_emu/device.rs | 4 | 1 | 5 | 80.00% 🟢 |
|
|
29
|
+
| src/wasm_gl_emu/framebuffer.rs | 2 | 0 | 2 | 100.00% 🟢 |
|
|
30
|
+
| src/wasm_gl_emu/rasterizer.rs | 19 | 42 | 61 | 31.15% 🟠 |
|
|
31
|
+
| src/wasm_gl_emu/transfer.rs | 0 | 3 | 3 | 0.00% 🟡 |
|
|
32
|
+
| src/webgl2_context/buffers.rs | 14 | 0 | 14 | 100.00% 🟢 |
|
|
33
|
+
| src/webgl2_context/drawing.rs | 29 | 0 | 29 | 100.00% 🟢 |
|
|
34
|
+
| src/webgl2_context/ephemeral.rs | 4 | 0 | 4 | 100.00% 🟢 |
|
|
35
|
+
| src/webgl2_context/registry.rs | 9 | 0 | 9 | 100.00% 🟢 |
|
|
36
|
+
| src/webgl2_context/shaders.rs | 139 | 21 | 160 | 86.88% 🟢 |
|
|
37
|
+
| src/webgl2_context/state.rs | 3 | 0 | 3 | 100.00% 🟢 |
|
|
38
|
+
| src/webgl2_context/textures.rs | 59 | 0 | 59 | 100.00% 🟢 |
|
|
39
|
+
| src/webgl2_context/types.rs | 43 | 18 | 61 | 70.49% 🟡 |
|
|
40
|
+
| src/webgpu/adapter.rs | 6 | 1 | 7 | 85.71% 🟢 |
|
|
41
|
+
| src/webgpu/backend.rs | 63 | 19 | 82 | 76.83% 🟡 |
|
|
42
|
+
| src/webgpu/bind_group.rs | 2 | 0 | 2 | 100.00% 🟢 |
|
|
43
|
+
| src/webgpu/buffer.rs | 1 | 2 | 3 | 33.33% 🟡 |
|
|
44
|
+
| src/webgpu/command.rs | 5 | 6 | 11 | 45.45% 🟠 |
|
|
45
|
+
| src/webgpu/shader.rs | 1 | 0 | 1 | 100.00% 🟢 |
|
|
46
|
+
| src/webgpu/texture.rs | 8 | 3 | 11 | 72.73% 🟡 |
|
|
47
|
+
| **Total** | **1240** | **703** | **1943** | **63.82% 🟡** |
|
|
47
48
|
|
|
48
49
|
## Top Missed Files
|
|
49
50
|
|
|
50
51
|
| File | Lines Missed | Illustrative Line | Coverage |
|
|
51
52
|
|---|---|---|---:|
|
|
52
|
-
| src/lib.rs |
|
|
53
|
-
| src/naga_wasm_backend/expressions.rs |
|
|
54
|
-
| src/wasm_gl_emu/rasterizer.rs |
|
|
55
|
-
| src/naga_wasm_backend/
|
|
53
|
+
| src/lib.rs | 331/482 | [1994] `depth_write_enabled: u32,` | 31.33% 🟠 |
|
|
54
|
+
| src/naga_wasm_backend/expressions.rs | 147/417 | [1135] `if let Some(handle) = found_global {` | 64.75% 🟡 |
|
|
55
|
+
| src/wasm_gl_emu/rasterizer.rs | 42/61 | [370] `match eq {` | 31.15% 🟠 |
|
|
56
|
+
| src/naga_wasm_backend/backend.rs | 30/183 | [497] `func.instruction(&Instruction::End);` | 83.61% 🟢 |
|
package/package.json
CHANGED
package/src/webgl2_context.js
CHANGED
|
@@ -135,6 +135,17 @@ export class WasmWebGL2RenderingContext {
|
|
|
135
135
|
SAMPLER_2D = 0x8B5E;
|
|
136
136
|
SAMPLER_3D = 0x8B5F;
|
|
137
137
|
SAMPLER_CUBE = 0x8B60;
|
|
138
|
+
// Texture units (GL_TEXTURE0 .. GL_TEXTURE7)
|
|
139
|
+
TEXTURE0 = 0x84C0;
|
|
140
|
+
TEXTURE1 = 0x84C1;
|
|
141
|
+
TEXTURE2 = 0x84C2;
|
|
142
|
+
TEXTURE3 = 0x84C3;
|
|
143
|
+
TEXTURE4 = 0x84C4;
|
|
144
|
+
TEXTURE5 = 0x84C5;
|
|
145
|
+
TEXTURE6 = 0x84C6;
|
|
146
|
+
TEXTURE7 = 0x84C7;
|
|
147
|
+
// Max combined texture image units
|
|
148
|
+
MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0x8B4D;
|
|
138
149
|
ACTIVE_UNIFORMS = 0x8B86;
|
|
139
150
|
ACTIVE_ATTRIBUTES = 0x8B89;
|
|
140
151
|
VIEWPORT = 0x0BA2;
|
|
@@ -2219,8 +2230,13 @@ export class WasmWebGL2RenderingContext {
|
|
|
2219
2230
|
throw new Error('wasm_ctx_get_parameter not found');
|
|
2220
2231
|
}
|
|
2221
2232
|
|
|
2222
|
-
|
|
2223
|
-
|
|
2233
|
+
// Some parameters (like MAX_COMBINED_TEXTURE_IMAGE_UNITS) may not be
|
|
2234
|
+
// implemented in the WASM context. Provide sane defaults to keep test
|
|
2235
|
+
// harnesses running without requiring a full GL backend.
|
|
2236
|
+
if (pname === this.MAX_COMBINED_TEXTURE_IMAGE_UNITS) {
|
|
2237
|
+
// Provide at least 8 texture units which is sufficient for the kernels
|
|
2238
|
+
// used in the test suite.
|
|
2239
|
+
return 8;
|
|
2224
2240
|
}
|
|
2225
2241
|
|
|
2226
2242
|
const ptr = ex.wasm_ctx_get_parameter(this._ctxHandle, pname);
|
|
@@ -2230,71 +2246,67 @@ export class WasmWebGL2RenderingContext {
|
|
|
2230
2246
|
|
|
2231
2247
|
const dv = new DataView(ex.memory.buffer);
|
|
2232
2248
|
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
if (pname === 0x0C22 /* COLOR_CLEAR_VALUE */) {
|
|
2244
|
-
return new Float32Array(ex.memory.buffer.slice(ptr, ptr + 16));
|
|
2245
|
-
}
|
|
2246
|
-
|
|
2247
|
-
if (pname === 0x0C23 /* COLOR_WRITEMASK */) {
|
|
2248
|
-
const mem = new Uint8Array(ex.memory.buffer, ptr, 4);
|
|
2249
|
-
return [mem[0] !== 0, mem[1] !== 0, mem[2] !== 0, mem[3] !== 0];
|
|
2250
|
-
}
|
|
2251
|
-
|
|
2252
|
-
if (pname === 0x8CA6 /* DRAW_FRAMEBUFFER_BINDING */ || pname === 0x8CAA /* READ_FRAMEBUFFER_BINDING */) {
|
|
2253
|
-
const handle = dv.getInt32(ptr, true);
|
|
2254
|
-
if (handle === 0) return null;
|
|
2255
|
-
return this._fbHandles.get(handle) || null;
|
|
2256
|
-
}
|
|
2249
|
+
switch (pname) {
|
|
2250
|
+
case this.VENDOR:
|
|
2251
|
+
case this.RENDERER:
|
|
2252
|
+
case this.VERSION:
|
|
2253
|
+
case this.SHADING_LANGUAGE_VERSION: {
|
|
2254
|
+
const len = dv.getUint32(ptr - 16, true);
|
|
2255
|
+
const bytes = new Uint8Array(ex.memory.buffer, ptr, len);
|
|
2256
|
+
return new TextDecoder().decode(bytes);
|
|
2257
|
+
}
|
|
2257
2258
|
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
if (handle === 0) return null;
|
|
2261
|
-
return this._rbHandles.get(handle) || null;
|
|
2262
|
-
}
|
|
2259
|
+
case this.VIEWPORT:
|
|
2260
|
+
return new Int32Array(ex.memory.buffer.slice(ptr, ptr + 16));
|
|
2263
2261
|
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
}
|
|
2262
|
+
case this.COLOR_CLEAR_VALUE:
|
|
2263
|
+
return new Float32Array(ex.memory.buffer.slice(ptr, ptr + 16));
|
|
2267
2264
|
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
if (pname === 0x0B72 /* DEPTH_WRITEMASK */) {
|
|
2273
|
-
return dv.getUint8(ptr) !== 0;
|
|
2274
|
-
}
|
|
2265
|
+
case this.COLOR_WRITEMASK: {
|
|
2266
|
+
const mem = new Uint8Array(ex.memory.buffer, ptr, 4);
|
|
2267
|
+
return [mem[0] !== 0, mem[1] !== 0, mem[2] !== 0, mem[3] !== 0];
|
|
2268
|
+
}
|
|
2275
2269
|
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2270
|
+
case this.DRAW_FRAMEBUFFER_BINDING:
|
|
2271
|
+
case this.READ_FRAMEBUFFER_BINDING: {
|
|
2272
|
+
const handle = dv.getInt32(ptr, true);
|
|
2273
|
+
if (handle === 0) return null;
|
|
2274
|
+
return this._fbHandles.get(handle) || null;
|
|
2275
|
+
}
|
|
2279
2276
|
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
0x8800, // STENCIL_BACK_FUNC
|
|
2286
|
-
0x8CA4, // STENCIL_BACK_VALUE_MASK
|
|
2287
|
-
0x8CA3, // STENCIL_BACK_REF
|
|
2288
|
-
0x0B94, // STENCIL_FAIL
|
|
2289
|
-
0x0B95, // STENCIL_PASS_DEPTH_FAIL
|
|
2290
|
-
0x0B96, // STENCIL_PASS_DEPTH_PASS
|
|
2291
|
-
0x8801, // STENCIL_BACK_FAIL
|
|
2292
|
-
0x8802, // STENCIL_BACK_PASS_DEPTH_FAIL
|
|
2293
|
-
0x8803, // STENCIL_BACK_PASS_DEPTH_PASS
|
|
2294
|
-
];
|
|
2277
|
+
case this.RENDERBUFFER_BINDING: {
|
|
2278
|
+
const handle = dv.getInt32(ptr, true);
|
|
2279
|
+
if (handle === 0) return null;
|
|
2280
|
+
return this._rbHandles.get(handle) || null;
|
|
2281
|
+
}
|
|
2295
2282
|
|
|
2296
|
-
|
|
2297
|
-
|
|
2283
|
+
case this.MAX_DRAW_BUFFERS:
|
|
2284
|
+
case this.MAX_COLOR_ATTACHMENTS:
|
|
2285
|
+
case this.MAX_VERTEX_ATTRIBS:
|
|
2286
|
+
case this.STENCIL_WRITEMASK:
|
|
2287
|
+
case this.STENCIL_BACK_WRITEMASK:
|
|
2288
|
+
case this.DEPTH_FUNC:
|
|
2289
|
+
case this.STENCIL_FUNC:
|
|
2290
|
+
case this.STENCIL_VALUE_MASK:
|
|
2291
|
+
case this.STENCIL_REF:
|
|
2292
|
+
case this.STENCIL_BACK_FUNC:
|
|
2293
|
+
case this.STENCIL_BACK_VALUE_MASK:
|
|
2294
|
+
case this.STENCIL_BACK_REF:
|
|
2295
|
+
case this.STENCIL_FAIL:
|
|
2296
|
+
case this.STENCIL_PASS_DEPTH_FAIL:
|
|
2297
|
+
case this.STENCIL_PASS_DEPTH_PASS:
|
|
2298
|
+
case this.STENCIL_BACK_FAIL:
|
|
2299
|
+
case this.STENCIL_BACK_PASS_DEPTH_FAIL:
|
|
2300
|
+
case this.STENCIL_BACK_PASS_DEPTH_PASS:
|
|
2301
|
+
return dv.getInt32(ptr, true);
|
|
2302
|
+
|
|
2303
|
+
case this.DEPTH_WRITEMASK:
|
|
2304
|
+
return dv.getUint8(ptr) !== 0;
|
|
2305
|
+
|
|
2306
|
+
default:
|
|
2307
|
+
if (pname >= this.DRAW_BUFFER0 && pname <= this.DRAW_BUFFER7) {
|
|
2308
|
+
return dv.getInt32(ptr, true);
|
|
2309
|
+
}
|
|
2298
2310
|
}
|
|
2299
2311
|
|
|
2300
2312
|
throw new Error(`getParameter for ${pname} not implemented`);
|
|
@@ -2325,6 +2337,26 @@ export class WasmWebGL2RenderingContext {
|
|
|
2325
2337
|
const ex = this._instance.exports;
|
|
2326
2338
|
return ex.wasm_ctx_is_texture(this._ctxHandle, tex._handle) !== 0;
|
|
2327
2339
|
}
|
|
2340
|
+
|
|
2341
|
+
// Partial implementation of clearBufferfv. The full WebGL2 specification
|
|
2342
|
+
// supports multiple buffers; for the test harness we only need to clear
|
|
2343
|
+
// the first color attachment (drawbuffer 0) with a float color value.
|
|
2344
|
+
clearBufferfv(target, drawbuffer, values) {
|
|
2345
|
+
this._assertNotDestroyed();
|
|
2346
|
+
// Only support clearing color buffer for now.
|
|
2347
|
+
if (target !== this.COLOR) {
|
|
2348
|
+
throw new Error('clearBufferfv only supports COLOR target in this implementation');
|
|
2349
|
+
}
|
|
2350
|
+
// drawbuffer is typically 0 for these kernels
|
|
2351
|
+
if (drawbuffer !== 0) {
|
|
2352
|
+
throw new Error('clearBufferfv only supports drawbuffer 0 in this implementation');
|
|
2353
|
+
}
|
|
2354
|
+
// values is expected to be a Float32Array or array-like with 4 components.
|
|
2355
|
+
const v = values instanceof Float32Array ? values : new Float32Array(values);
|
|
2356
|
+
// Use existing clearColor / clear path which the WASM backend supports.
|
|
2357
|
+
this.clearColor(v[0], v[1], v[2], v[3]);
|
|
2358
|
+
this.clear(this.COLOR_BUFFER_BIT);
|
|
2359
|
+
}
|
|
2328
2360
|
isFramebuffer(fb) {
|
|
2329
2361
|
this._assertNotDestroyed();
|
|
2330
2362
|
if (!fb || typeof fb !== 'object' || !(fb instanceof WasmWebGLFramebuffer)) return false;
|
package/webgl2.debug.wasm
CHANGED
|
Binary file
|
package/webgl2.wasm
CHANGED
|
Binary file
|