webgl2 1.3.0 → 1.3.2
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 +42 -40
- package/index.js +14 -7
- package/package.json +1 -1
- package/src/webgl2_context.js +146 -322
- package/webgl2.debug.wasm +0 -0
- package/webgl2.wasm +0 -0
package/coverage.md
CHANGED
|
@@ -4,50 +4,52 @@
|
|
|
4
4
|
|
|
5
5
|
| File | Lines Covered | Lines Missed | Total Lines | Coverage |
|
|
6
6
|
|---|---|---|---|---:|
|
|
7
|
-
| src/coverage.rs |
|
|
8
|
-
| src/decompiler/ast.rs | 3 |
|
|
9
|
-
| src/decompiler/emitter.rs |
|
|
10
|
-
| src/decompiler/lifter.rs |
|
|
11
|
-
| src/decompiler/
|
|
12
|
-
| src/decompiler/
|
|
13
|
-
| src/
|
|
14
|
-
| src/
|
|
15
|
-
| src/
|
|
16
|
-
| src/naga_wasm_backend/
|
|
17
|
-
| src/naga_wasm_backend/
|
|
18
|
-
| src/naga_wasm_backend/control_flow.rs | 37 | 30 | 67 | 55.22% 🟡 |
|
|
7
|
+
| src/coverage.rs | 11 | 5 | 16 | 68.75% 🟡 |
|
|
8
|
+
| src/decompiler/ast.rs | 3 | 5 | 8 | 37.50% 🟠 |
|
|
9
|
+
| src/decompiler/emitter.rs | 30 | 3 | 33 | 90.91% 🟢 |
|
|
10
|
+
| src/decompiler/lifter.rs | 6 | 2 | 8 | 75.00% 🟡 |
|
|
11
|
+
| src/decompiler/parser.rs | 2 | 1 | 3 | 66.67% 🟡 |
|
|
12
|
+
| src/decompiler/simplifier.rs | 35 | 2 | 37 | 94.59% 🟢 |
|
|
13
|
+
| src/error.rs | 32 | 5 | 37 | 86.49% 🟢 |
|
|
14
|
+
| src/lib.rs | 144 | 305 | 449 | 32.07% 🟠 |
|
|
15
|
+
| src/naga_wasm_backend/backend.rs | 154 | 28 | 182 | 84.62% 🟢 |
|
|
16
|
+
| src/naga_wasm_backend/call_lowering.rs | 9 | 3 | 12 | 75.00% 🟡 |
|
|
17
|
+
| src/naga_wasm_backend/control_flow.rs | 38 | 29 | 67 | 56.72% 🟡 |
|
|
19
18
|
| src/naga_wasm_backend/debug/stub.rs | 11 | 15 | 26 | 42.31% 🟠 |
|
|
20
|
-
| src/naga_wasm_backend/expressions.rs | 255 |
|
|
21
|
-
| src/naga_wasm_backend/function_abi.rs |
|
|
22
|
-
| src/naga_wasm_backend/functions/prep.rs |
|
|
23
|
-
| src/naga_wasm_backend/functions/registry.rs |
|
|
24
|
-
| src/naga_wasm_backend/memory_layout.rs |
|
|
25
|
-
| src/naga_wasm_backend/mod.rs |
|
|
26
|
-
| src/naga_wasm_backend/output_layout.rs |
|
|
27
|
-
| src/naga_wasm_backend/types.rs |
|
|
19
|
+
| src/naga_wasm_backend/expressions.rs | 255 | 149 | 404 | 63.12% 🟡 |
|
|
20
|
+
| src/naga_wasm_backend/function_abi.rs | 19 | 5 | 24 | 79.17% 🟡 |
|
|
21
|
+
| src/naga_wasm_backend/functions/prep.rs | 5 | 0 | 5 | 100.00% 🟢 |
|
|
22
|
+
| src/naga_wasm_backend/functions/registry.rs | 6 | 0 | 6 | 100.00% 🟢 |
|
|
23
|
+
| src/naga_wasm_backend/memory_layout.rs | 15 | 1 | 16 | 93.75% 🟢 |
|
|
24
|
+
| src/naga_wasm_backend/mod.rs | 7 | 0 | 7 | 100.00% 🟢 |
|
|
25
|
+
| src/naga_wasm_backend/output_layout.rs | 5 | 0 | 5 | 100.00% 🟢 |
|
|
26
|
+
| src/naga_wasm_backend/types.rs | 22 | 5 | 27 | 81.48% 🟢 |
|
|
27
|
+
| src/wasm_gl_emu/device.rs | 3 | 2 | 5 | 60.00% 🟡 |
|
|
28
28
|
| src/wasm_gl_emu/framebuffer.rs | 1 | 0 | 1 | 100.00% 🟢 |
|
|
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/registry.rs |
|
|
35
|
-
| src/webgl2_context/shaders.rs |
|
|
36
|
-
| src/webgl2_context/state.rs |
|
|
37
|
-
| src/webgl2_context/textures.rs |
|
|
38
|
-
| src/webgl2_context/types.rs |
|
|
39
|
-
| src/webgpu/adapter.rs |
|
|
40
|
-
| src/webgpu/backend.rs |
|
|
41
|
-
| src/webgpu/
|
|
42
|
-
| src/webgpu/
|
|
43
|
-
| src/webgpu/
|
|
44
|
-
|
|
|
29
|
+
| src/wasm_gl_emu/rasterizer.rs | 17 | 41 | 58 | 29.31% 🟠 |
|
|
30
|
+
| src/wasm_gl_emu/transfer.rs | 0 | 2 | 2 | 0.00% 🟡 |
|
|
31
|
+
| src/webgl2_context/buffers.rs | 14 | 0 | 14 | 100.00% 🟢 |
|
|
32
|
+
| src/webgl2_context/drawing.rs | 30 | 0 | 30 | 100.00% 🟢 |
|
|
33
|
+
| src/webgl2_context/ephemeral.rs | 3 | 0 | 3 | 100.00% 🟢 |
|
|
34
|
+
| src/webgl2_context/registry.rs | 10 | 0 | 10 | 100.00% 🟢 |
|
|
35
|
+
| src/webgl2_context/shaders.rs | 141 | 27 | 168 | 83.93% 🟢 |
|
|
36
|
+
| src/webgl2_context/state.rs | 2 | 0 | 2 | 100.00% 🟢 |
|
|
37
|
+
| src/webgl2_context/textures.rs | 59 | 0 | 59 | 100.00% 🟢 |
|
|
38
|
+
| src/webgl2_context/types.rs | 46 | 17 | 63 | 73.02% 🟡 |
|
|
39
|
+
| src/webgpu/adapter.rs | 5 | 0 | 5 | 100.00% 🟢 |
|
|
40
|
+
| src/webgpu/backend.rs | 61 | 21 | 82 | 74.39% 🟡 |
|
|
41
|
+
| src/webgpu/bind_group.rs | 3 | 0 | 3 | 100.00% 🟢 |
|
|
42
|
+
| src/webgpu/buffer.rs | 1 | 2 | 3 | 33.33% 🟡 |
|
|
43
|
+
| src/webgpu/command.rs | 7 | 5 | 12 | 58.33% 🟡 |
|
|
44
|
+
| src/webgpu/shader.rs | 1 | 0 | 1 | 100.00% 🟢 |
|
|
45
|
+
| src/webgpu/texture.rs | 8 | 4 | 12 | 66.67% 🟡 |
|
|
46
|
+
| **Total** | **1221** | **684** | **1905** | **64.09% 🟡** |
|
|
45
47
|
|
|
46
48
|
## Top Missed Files
|
|
47
49
|
|
|
48
50
|
| File | Lines Missed | Illustrative Line | Coverage |
|
|
49
51
|
|---|---|---|---:|
|
|
50
|
-
| src/lib.rs |
|
|
51
|
-
| src/naga_wasm_backend/expressions.rs |
|
|
52
|
-
| src/
|
|
53
|
-
| src/naga_wasm_backend/
|
|
52
|
+
| src/lib.rs | 305/449 | [1994] `depth_write_enabled: u32,` | 32.07% 🟠 |
|
|
53
|
+
| src/naga_wasm_backend/expressions.rs | 149/404 | [910] `if let Some(handle) = found_global {` | 63.12% 🟡 |
|
|
54
|
+
| src/wasm_gl_emu/rasterizer.rs | 41/58 | [370] `match eq {` | 29.31% 🟠 |
|
|
55
|
+
| src/naga_wasm_backend/control_flow.rs | 29/67 | [489] `let types = super::types::naga_to_wasm_types(` | 56.72% 🟡 |
|
package/index.js
CHANGED
|
@@ -366,16 +366,23 @@ async function initWASM({ debug } = {}) {
|
|
|
366
366
|
*/
|
|
367
367
|
function _readErrorMessage(instance) {
|
|
368
368
|
const ex = instance.exports;
|
|
369
|
-
if (!ex || typeof ex.
|
|
369
|
+
if (!ex || typeof ex.wasm_last_error !== 'function') {
|
|
370
|
+
if (typeof ex.wasm_last_error_ptr === 'function') {
|
|
371
|
+
const ptr = ex.wasm_last_error_ptr();
|
|
372
|
+
const len = ex.wasm_last_error_len();
|
|
373
|
+
if (ptr === 0 || len === 0) return '';
|
|
374
|
+
const mem = new Uint8Array(ex.memory.buffer);
|
|
375
|
+
const bytes = mem.subarray(ptr, ptr + len);
|
|
376
|
+
return new TextDecoder('utf-8').decode(bytes);
|
|
377
|
+
}
|
|
370
378
|
return '(no error message available)';
|
|
371
379
|
}
|
|
372
|
-
const ptr = ex.
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
}
|
|
380
|
+
const ptr = ex.wasm_last_error();
|
|
381
|
+
if (ptr === 0) return '';
|
|
382
|
+
const dv = new DataView(ex.memory.buffer);
|
|
383
|
+
const len = dv.getUint32(ptr - 16, true);
|
|
377
384
|
const mem = new Uint8Array(ex.memory.buffer);
|
|
378
|
-
const bytes = mem.
|
|
385
|
+
const bytes = mem.slice(ptr, ptr + len);
|
|
379
386
|
return new TextDecoder('utf-8').decode(bytes);
|
|
380
387
|
}
|
|
381
388
|
|
package/package.json
CHANGED
package/src/webgl2_context.js
CHANGED
|
@@ -709,48 +709,31 @@ export class WasmWebGL2RenderingContext {
|
|
|
709
709
|
throw new Error('wasm_ctx_read_pixels not found');
|
|
710
710
|
}
|
|
711
711
|
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
const len = width * height * bpp;
|
|
726
|
-
if (!out || out.byteLength < len) {
|
|
727
|
-
throw new Error(`output buffer too small (need ${len} bytes, have ${out ? out.byteLength : 0})`);
|
|
712
|
+
const ptr = ex.wasm_ctx_read_pixels(
|
|
713
|
+
this._ctxHandle,
|
|
714
|
+
x | 0,
|
|
715
|
+
y | 0,
|
|
716
|
+
width >>> 0,
|
|
717
|
+
height >>> 0,
|
|
718
|
+
format >>> 0,
|
|
719
|
+
type_ >>> 0
|
|
720
|
+
);
|
|
721
|
+
|
|
722
|
+
if (ptr === 0) {
|
|
723
|
+
const msg = readErrorMessage(this._instance);
|
|
724
|
+
throw new Error(`readPixels failed: ${msg}`);
|
|
728
725
|
}
|
|
729
726
|
|
|
730
|
-
const
|
|
731
|
-
|
|
727
|
+
const dv = new DataView(ex.memory.buffer);
|
|
728
|
+
const len = dv.getUint32(ptr - 16, true);
|
|
732
729
|
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
this._ctxHandle,
|
|
736
|
-
x | 0,
|
|
737
|
-
y | 0,
|
|
738
|
-
width >>> 0,
|
|
739
|
-
height >>> 0,
|
|
740
|
-
format >>> 0,
|
|
741
|
-
type_ >>> 0,
|
|
742
|
-
ptr >>> 0,
|
|
743
|
-
len >>> 0
|
|
744
|
-
);
|
|
745
|
-
_checkErr(code, this._instance);
|
|
746
|
-
|
|
747
|
-
const mem = new Uint8Array(ex.memory.buffer);
|
|
748
|
-
const src = mem.subarray(ptr, ptr + len);
|
|
749
|
-
const out_bytes = new Uint8Array(out.buffer, out.byteOffset, len);
|
|
750
|
-
out_bytes.set(src);
|
|
751
|
-
} finally {
|
|
752
|
-
ex.wasm_free(ptr);
|
|
730
|
+
if (!out || out.byteLength < len) {
|
|
731
|
+
throw new Error(`output buffer too small (need ${len} bytes, have ${out ? out.byteLength : 0})`);
|
|
753
732
|
}
|
|
733
|
+
|
|
734
|
+
const src = new Uint8Array(ex.memory.buffer, ptr, len);
|
|
735
|
+
const out_bytes = new Uint8Array(out.buffer, out.byteOffset, len);
|
|
736
|
+
out_bytes.set(src);
|
|
754
737
|
}
|
|
755
738
|
|
|
756
739
|
// --- Stubs for unimplemented WebGL2 methods (forwarding API surface) ---
|
|
@@ -856,43 +839,18 @@ export class WasmWebGL2RenderingContext {
|
|
|
856
839
|
}
|
|
857
840
|
const programHandle = program && typeof program === 'object' && typeof program._handle === 'number' ? program._handle : (program >>> 0);
|
|
858
841
|
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
const typePtr = ex.wasm_alloc(4);
|
|
862
|
-
const nameMaxLen = 256;
|
|
863
|
-
const namePtr = ex.wasm_alloc(nameMaxLen);
|
|
864
|
-
|
|
865
|
-
try {
|
|
866
|
-
const nameLen = ex.wasm_ctx_get_active_uniform(
|
|
867
|
-
this._ctxHandle,
|
|
868
|
-
programHandle,
|
|
869
|
-
index >>> 0,
|
|
870
|
-
sizePtr,
|
|
871
|
-
typePtr,
|
|
872
|
-
namePtr,
|
|
873
|
-
nameMaxLen
|
|
874
|
-
);
|
|
875
|
-
|
|
876
|
-
if (nameLen === 0) {
|
|
877
|
-
return null;
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
const mem32SizeIdx = sizePtr >>> 2;
|
|
881
|
-
const mem32TypeIdx = typePtr >>> 2;
|
|
882
|
-
|
|
883
|
-
const size = new Int32Array(ex.memory.buffer)[mem32SizeIdx];
|
|
884
|
-
const type_ = new Uint32Array(ex.memory.buffer)[mem32TypeIdx];
|
|
885
|
-
|
|
886
|
-
const nameBytes = new Uint8Array(ex.memory.buffer, namePtr, nameLen);
|
|
887
|
-
const name = new TextDecoder().decode(nameBytes);
|
|
842
|
+
const ptr = ex.wasm_ctx_get_active_uniform(this._ctxHandle, programHandle, index >>> 0);
|
|
843
|
+
if (ptr === 0) return null;
|
|
888
844
|
|
|
889
|
-
|
|
845
|
+
const dv = new DataView(ex.memory.buffer);
|
|
846
|
+
const totalLen = dv.getUint32(ptr - 16, true);
|
|
847
|
+
const size = dv.getInt32(ptr, true);
|
|
848
|
+
const type_ = dv.getUint32(ptr + 4, true);
|
|
849
|
+
const nameLen = totalLen - 8;
|
|
850
|
+
const nameBytes = new Uint8Array(ex.memory.buffer, ptr + 8, nameLen);
|
|
851
|
+
const name = new TextDecoder('utf-8').decode(nameBytes);
|
|
890
852
|
|
|
891
|
-
|
|
892
|
-
ex.wasm_free(sizePtr);
|
|
893
|
-
ex.wasm_free(typePtr);
|
|
894
|
-
ex.wasm_free(namePtr);
|
|
895
|
-
}
|
|
853
|
+
return { name, size, type: type_ };
|
|
896
854
|
}
|
|
897
855
|
|
|
898
856
|
getActiveAttrib(program, index) {
|
|
@@ -903,43 +861,18 @@ export class WasmWebGL2RenderingContext {
|
|
|
903
861
|
}
|
|
904
862
|
const programHandle = program && typeof program === 'object' && typeof program._handle === 'number' ? program._handle : (program >>> 0);
|
|
905
863
|
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
const typePtr = ex.wasm_alloc(4);
|
|
909
|
-
const nameMaxLen = 256;
|
|
910
|
-
const namePtr = ex.wasm_alloc(nameMaxLen);
|
|
911
|
-
|
|
912
|
-
try {
|
|
913
|
-
const nameLen = ex.wasm_ctx_get_active_attrib(
|
|
914
|
-
this._ctxHandle,
|
|
915
|
-
programHandle,
|
|
916
|
-
index >>> 0,
|
|
917
|
-
sizePtr,
|
|
918
|
-
typePtr,
|
|
919
|
-
namePtr,
|
|
920
|
-
nameMaxLen
|
|
921
|
-
);
|
|
922
|
-
|
|
923
|
-
if (nameLen === 0) {
|
|
924
|
-
return null;
|
|
925
|
-
}
|
|
926
|
-
|
|
927
|
-
const mem32SizeIdx = sizePtr >>> 2;
|
|
928
|
-
const mem32TypeIdx = typePtr >>> 2;
|
|
929
|
-
|
|
930
|
-
const size = new Int32Array(ex.memory.buffer)[mem32SizeIdx];
|
|
931
|
-
const type_ = new Uint32Array(ex.memory.buffer)[mem32TypeIdx];
|
|
932
|
-
|
|
933
|
-
const nameBytes = new Uint8Array(ex.memory.buffer, namePtr, nameLen);
|
|
934
|
-
const name = new TextDecoder().decode(nameBytes);
|
|
864
|
+
const ptr = ex.wasm_ctx_get_active_attrib(this._ctxHandle, programHandle, index >>> 0);
|
|
865
|
+
if (ptr === 0) return null;
|
|
935
866
|
|
|
936
|
-
|
|
867
|
+
const dv = new DataView(ex.memory.buffer);
|
|
868
|
+
const totalLen = dv.getUint32(ptr - 16, true);
|
|
869
|
+
const size = dv.getInt32(ptr, true);
|
|
870
|
+
const type_ = dv.getUint32(ptr + 4, true);
|
|
871
|
+
const nameLen = totalLen - 8;
|
|
872
|
+
const nameBytes = new Uint8Array(ex.memory.buffer, ptr + 8, nameLen);
|
|
873
|
+
const name = new TextDecoder('utf-8').decode(nameBytes);
|
|
937
874
|
|
|
938
|
-
|
|
939
|
-
ex.wasm_free(sizePtr);
|
|
940
|
-
ex.wasm_free(typePtr);
|
|
941
|
-
ex.wasm_free(namePtr);
|
|
942
|
-
}
|
|
875
|
+
return { name, size, type: type_ };
|
|
943
876
|
}
|
|
944
877
|
|
|
945
878
|
linkProgram(program) {
|
|
@@ -1216,18 +1149,14 @@ export class WasmWebGL2RenderingContext {
|
|
|
1216
1149
|
}
|
|
1217
1150
|
const shaderHandle = shader && typeof shader === 'object' && typeof shader._handle === 'number' ? shader._handle : (shader >>> 0);
|
|
1218
1151
|
|
|
1219
|
-
const
|
|
1220
|
-
|
|
1221
|
-
if (ptr === 0) throw new Error('Failed to allocate memory for getShaderInfoLog');
|
|
1152
|
+
const ptr = ex.wasm_ctx_get_shader_info_log(this._ctxHandle, shaderHandle);
|
|
1153
|
+
if (ptr === 0) return "";
|
|
1222
1154
|
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
} finally {
|
|
1229
|
-
ex.wasm_free(ptr);
|
|
1230
|
-
}
|
|
1155
|
+
const dv = new DataView(ex.memory.buffer);
|
|
1156
|
+
const len = dv.getUint32(ptr - 16, true);
|
|
1157
|
+
const mem = new Uint8Array(ex.memory.buffer);
|
|
1158
|
+
const bytes = mem.slice(ptr, ptr + len);
|
|
1159
|
+
return new TextDecoder().decode(bytes);
|
|
1231
1160
|
}
|
|
1232
1161
|
|
|
1233
1162
|
getProgramInfoLog(program) {
|
|
@@ -1238,18 +1167,14 @@ export class WasmWebGL2RenderingContext {
|
|
|
1238
1167
|
}
|
|
1239
1168
|
const programHandle = program && typeof program === 'object' && typeof program._handle === 'number' ? program._handle : (program >>> 0);
|
|
1240
1169
|
|
|
1241
|
-
const
|
|
1242
|
-
|
|
1243
|
-
if (ptr === 0) throw new Error('Failed to allocate memory for getProgramInfoLog');
|
|
1170
|
+
const ptr = ex.wasm_ctx_get_program_info_log(this._ctxHandle, programHandle);
|
|
1171
|
+
if (ptr === 0) return "";
|
|
1244
1172
|
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
} finally {
|
|
1251
|
-
ex.wasm_free(ptr);
|
|
1252
|
-
}
|
|
1173
|
+
const dv = new DataView(ex.memory.buffer);
|
|
1174
|
+
const len = dv.getUint32(ptr - 16, true);
|
|
1175
|
+
const mem = new Uint8Array(ex.memory.buffer);
|
|
1176
|
+
const bytes = mem.slice(ptr, ptr + len);
|
|
1177
|
+
return new TextDecoder().decode(bytes);
|
|
1253
1178
|
}
|
|
1254
1179
|
|
|
1255
1180
|
getProgramWasm(program, shaderType) {
|
|
@@ -1918,45 +1843,18 @@ export class WasmWebGL2RenderingContext {
|
|
|
1918
1843
|
}
|
|
1919
1844
|
const programHandle = program && typeof program === "object" && typeof program._handle === "number" ? program._handle : (program >>> 0);
|
|
1920
1845
|
|
|
1921
|
-
const
|
|
1922
|
-
|
|
1923
|
-
const nameCapacity = 256;
|
|
1924
|
-
const namePtr = ex.wasm_alloc(nameCapacity);
|
|
1925
|
-
|
|
1926
|
-
if (sizePtr === 0 || typePtr === 0 || namePtr === 0) {
|
|
1927
|
-
if (sizePtr) ex.wasm_free(sizePtr);
|
|
1928
|
-
if (typePtr) ex.wasm_free(typePtr);
|
|
1929
|
-
if (namePtr) ex.wasm_free(namePtr);
|
|
1930
|
-
throw new Error("Failed to allocate memory for getTransformFeedbackVarying");
|
|
1931
|
-
}
|
|
1932
|
-
|
|
1933
|
-
try {
|
|
1934
|
-
const code = ex.wasm_ctx_get_transform_feedback_varying(
|
|
1935
|
-
this._ctxHandle,
|
|
1936
|
-
programHandle,
|
|
1937
|
-
index >>> 0,
|
|
1938
|
-
sizePtr,
|
|
1939
|
-
typePtr,
|
|
1940
|
-
namePtr,
|
|
1941
|
-
nameCapacity
|
|
1942
|
-
);
|
|
1943
|
-
_checkErr(code, this._instance);
|
|
1944
|
-
|
|
1945
|
-
const mem = new DataView(ex.memory.buffer);
|
|
1946
|
-
const size = mem.getInt32(sizePtr, true);
|
|
1947
|
-
const type = mem.getUint32(typePtr, true);
|
|
1846
|
+
const ptr = ex.wasm_ctx_get_transform_feedback_varying(this._ctxHandle, programHandle, index >>> 0);
|
|
1847
|
+
if (ptr === 0) return null;
|
|
1948
1848
|
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1849
|
+
const dv = new DataView(ex.memory.buffer);
|
|
1850
|
+
const totalLen = dv.getUint32(ptr - 16, true);
|
|
1851
|
+
const size = dv.getInt32(ptr, true);
|
|
1852
|
+
const type = dv.getUint32(ptr + 4, true);
|
|
1853
|
+
const nameLen = totalLen - 8;
|
|
1854
|
+
const nameBytes = new Uint8Array(ex.memory.buffer, ptr + 8, nameLen);
|
|
1855
|
+
const name = new TextDecoder('utf-8').decode(nameBytes);
|
|
1953
1856
|
|
|
1954
|
-
|
|
1955
|
-
} finally {
|
|
1956
|
-
ex.wasm_free(sizePtr);
|
|
1957
|
-
ex.wasm_free(typePtr);
|
|
1958
|
-
ex.wasm_free(namePtr);
|
|
1959
|
-
}
|
|
1857
|
+
return { name, size, type };
|
|
1960
1858
|
}
|
|
1961
1859
|
|
|
1962
1860
|
createQuery() { this._assertNotDestroyed(); throw new Error('not implemented'); }
|
|
@@ -2317,148 +2215,78 @@ export class WasmWebGL2RenderingContext {
|
|
|
2317
2215
|
getParameter(pname) {
|
|
2318
2216
|
this._assertNotDestroyed();
|
|
2319
2217
|
const ex = this._instance.exports;
|
|
2320
|
-
if (!ex || typeof ex.
|
|
2321
|
-
throw new Error('
|
|
2218
|
+
if (!ex || typeof ex.wasm_ctx_get_parameter !== 'function') {
|
|
2219
|
+
throw new Error('wasm_ctx_get_parameter not found');
|
|
2322
2220
|
}
|
|
2323
2221
|
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
const code = ex.wasm_ctx_get_parameter_v(this._ctxHandle, pname, ptr, 16);
|
|
2328
|
-
_checkErr(code, this._instance);
|
|
2329
|
-
const mem = new Int32Array(ex.memory.buffer, ptr, 4);
|
|
2330
|
-
return new Int32Array(mem);
|
|
2331
|
-
} finally {
|
|
2332
|
-
ex.wasm_free(ptr, 16);
|
|
2333
|
-
}
|
|
2222
|
+
const ptr = ex.wasm_ctx_get_parameter(this._ctxHandle, pname);
|
|
2223
|
+
if (ptr === 0) {
|
|
2224
|
+
return null;
|
|
2334
2225
|
}
|
|
2335
2226
|
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
ex.
|
|
2227
|
+
const dv = new DataView(ex.memory.buffer);
|
|
2228
|
+
|
|
2229
|
+
switch (pname) {
|
|
2230
|
+
case this.VENDOR:
|
|
2231
|
+
case this.RENDERER:
|
|
2232
|
+
case this.VERSION:
|
|
2233
|
+
case this.SHADING_LANGUAGE_VERSION: {
|
|
2234
|
+
const len = dv.getUint32(ptr - 16, true);
|
|
2235
|
+
const bytes = new Uint8Array(ex.memory.buffer, ptr, len);
|
|
2236
|
+
return new TextDecoder().decode(bytes);
|
|
2345
2237
|
}
|
|
2346
|
-
}
|
|
2347
2238
|
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2239
|
+
case this.VIEWPORT:
|
|
2240
|
+
return new Int32Array(ex.memory.buffer.slice(ptr, ptr + 16));
|
|
2241
|
+
|
|
2242
|
+
case this.COLOR_CLEAR_VALUE:
|
|
2243
|
+
return new Float32Array(ex.memory.buffer.slice(ptr, ptr + 16));
|
|
2244
|
+
|
|
2245
|
+
case this.COLOR_WRITEMASK: {
|
|
2353
2246
|
const mem = new Uint8Array(ex.memory.buffer, ptr, 4);
|
|
2354
2247
|
return [mem[0] !== 0, mem[1] !== 0, mem[2] !== 0, mem[3] !== 0];
|
|
2355
|
-
} finally {
|
|
2356
|
-
ex.wasm_free(ptr, 4);
|
|
2357
2248
|
}
|
|
2358
|
-
}
|
|
2359
2249
|
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
const code = ex.wasm_ctx_get_parameter_v(this._ctxHandle, pname, ptr, 4);
|
|
2364
|
-
_checkErr(code, this._instance);
|
|
2365
|
-
const handle = new Int32Array(ex.memory.buffer, ptr, 1)[0];
|
|
2250
|
+
case this.DRAW_FRAMEBUFFER_BINDING:
|
|
2251
|
+
case this.READ_FRAMEBUFFER_BINDING: {
|
|
2252
|
+
const handle = dv.getInt32(ptr, true);
|
|
2366
2253
|
if (handle === 0) return null;
|
|
2367
2254
|
return this._fbHandles.get(handle) || null;
|
|
2368
|
-
} finally {
|
|
2369
|
-
ex.wasm_free(ptr, 4);
|
|
2370
2255
|
}
|
|
2371
|
-
}
|
|
2372
2256
|
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
try {
|
|
2376
|
-
const code = ex.wasm_ctx_get_parameter_v(this._ctxHandle, pname, ptr, 4);
|
|
2377
|
-
_checkErr(code, this._instance);
|
|
2378
|
-
const handle = new Int32Array(ex.memory.buffer, ptr, 1)[0];
|
|
2257
|
+
case this.RENDERBUFFER_BINDING: {
|
|
2258
|
+
const handle = dv.getInt32(ptr, true);
|
|
2379
2259
|
if (handle === 0) return null;
|
|
2380
2260
|
return this._rbHandles.get(handle) || null;
|
|
2381
|
-
} finally {
|
|
2382
|
-
ex.wasm_free(ptr, 4);
|
|
2383
|
-
}
|
|
2384
|
-
}
|
|
2385
|
-
|
|
2386
|
-
if (pname === 0x8824 /* MAX_DRAW_BUFFERS */ || pname === 0x8CDF /* MAX_COLOR_ATTACHMENTS */) {
|
|
2387
|
-
const ptr = ex.wasm_alloc(4);
|
|
2388
|
-
try {
|
|
2389
|
-
const code = ex.wasm_ctx_get_parameter_v(this._ctxHandle, pname, ptr, 4);
|
|
2390
|
-
_checkErr(code, this._instance);
|
|
2391
|
-
return new Int32Array(ex.memory.buffer, ptr, 1)[0];
|
|
2392
|
-
} finally {
|
|
2393
|
-
ex.wasm_free(ptr, 4);
|
|
2394
2261
|
}
|
|
2395
|
-
}
|
|
2396
2262
|
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
_checkErr(code, this._instance);
|
|
2425
|
-
const mem = new Int32Array(ex.memory.buffer, ptr, 1);
|
|
2426
|
-
return mem[0];
|
|
2427
|
-
} finally {
|
|
2428
|
-
ex.wasm_free(ptr, 4);
|
|
2429
|
-
}
|
|
2430
|
-
}
|
|
2431
|
-
|
|
2432
|
-
const singleIntParams = [
|
|
2433
|
-
0x0B74, // DEPTH_FUNC
|
|
2434
|
-
0x0B92, // STENCIL_FUNC
|
|
2435
|
-
0x0B93, // STENCIL_VALUE_MASK
|
|
2436
|
-
0x0B97, // STENCIL_REF
|
|
2437
|
-
0x8800, // STENCIL_BACK_FUNC
|
|
2438
|
-
0x8CA4, // STENCIL_BACK_VALUE_MASK
|
|
2439
|
-
0x8CA3, // STENCIL_BACK_REF
|
|
2440
|
-
0x0B94, // STENCIL_FAIL
|
|
2441
|
-
0x0B95, // STENCIL_PASS_DEPTH_FAIL
|
|
2442
|
-
0x0B96, // STENCIL_PASS_DEPTH_PASS
|
|
2443
|
-
0x8801, // STENCIL_BACK_FAIL
|
|
2444
|
-
0x8802, // STENCIL_BACK_PASS_DEPTH_FAIL
|
|
2445
|
-
0x8803, // STENCIL_BACK_PASS_DEPTH_PASS
|
|
2446
|
-
];
|
|
2447
|
-
|
|
2448
|
-
if (singleIntParams.includes(pname)) {
|
|
2449
|
-
const ptr = ex.wasm_alloc(4);
|
|
2450
|
-
try {
|
|
2451
|
-
const code = ex.wasm_ctx_get_parameter_v(this._ctxHandle, pname, ptr, 4);
|
|
2452
|
-
_checkErr(code, this._instance);
|
|
2453
|
-
const mem = new Int32Array(ex.memory.buffer, ptr, 1);
|
|
2454
|
-
return mem[0];
|
|
2455
|
-
} finally {
|
|
2456
|
-
ex.wasm_free(ptr, 4);
|
|
2457
|
-
}
|
|
2458
|
-
}
|
|
2459
|
-
|
|
2460
|
-
if (pname === 0x8869 /* MAX_VERTEX_ATTRIBS */) {
|
|
2461
|
-
return 16;
|
|
2263
|
+
case this.MAX_DRAW_BUFFERS:
|
|
2264
|
+
case this.MAX_COLOR_ATTACHMENTS:
|
|
2265
|
+
case this.MAX_VERTEX_ATTRIBS:
|
|
2266
|
+
case this.STENCIL_WRITEMASK:
|
|
2267
|
+
case this.STENCIL_BACK_WRITEMASK:
|
|
2268
|
+
case this.DEPTH_FUNC:
|
|
2269
|
+
case this.STENCIL_FUNC:
|
|
2270
|
+
case this.STENCIL_VALUE_MASK:
|
|
2271
|
+
case this.STENCIL_REF:
|
|
2272
|
+
case this.STENCIL_BACK_FUNC:
|
|
2273
|
+
case this.STENCIL_BACK_VALUE_MASK:
|
|
2274
|
+
case this.STENCIL_BACK_REF:
|
|
2275
|
+
case this.STENCIL_FAIL:
|
|
2276
|
+
case this.STENCIL_PASS_DEPTH_FAIL:
|
|
2277
|
+
case this.STENCIL_PASS_DEPTH_PASS:
|
|
2278
|
+
case this.STENCIL_BACK_FAIL:
|
|
2279
|
+
case this.STENCIL_BACK_PASS_DEPTH_FAIL:
|
|
2280
|
+
case this.STENCIL_BACK_PASS_DEPTH_PASS:
|
|
2281
|
+
return dv.getInt32(ptr, true);
|
|
2282
|
+
|
|
2283
|
+
case this.DEPTH_WRITEMASK:
|
|
2284
|
+
return dv.getUint8(ptr) !== 0;
|
|
2285
|
+
|
|
2286
|
+
default:
|
|
2287
|
+
if (pname >= this.DRAW_BUFFER0 && pname <= this.DRAW_BUFFER7) {
|
|
2288
|
+
return dv.getInt32(ptr, true);
|
|
2289
|
+
}
|
|
2462
2290
|
}
|
|
2463
2291
|
|
|
2464
2292
|
throw new Error(`getParameter for ${pname} not implemented`);
|
|
@@ -2740,16 +2568,24 @@ export class WasmWebGL2RenderingContext {
|
|
|
2740
2568
|
*/
|
|
2741
2569
|
export function readErrorMessage(instance) {
|
|
2742
2570
|
const ex = instance.exports;
|
|
2743
|
-
if (!ex || typeof ex.
|
|
2571
|
+
if (!ex || typeof ex.wasm_last_error !== 'function') {
|
|
2572
|
+
// Fallback to old ptr/len if exists, otherwise return unknown
|
|
2573
|
+
if (typeof ex.wasm_last_error_ptr === 'function') {
|
|
2574
|
+
const ptr = ex.wasm_last_error_ptr();
|
|
2575
|
+
const len = ex.wasm_last_error_len();
|
|
2576
|
+
if (ptr === 0 || len === 0) return '';
|
|
2577
|
+
const mem = new Uint8Array(ex.memory.buffer);
|
|
2578
|
+
const bytes = mem.subarray(ptr, ptr + len);
|
|
2579
|
+
return new TextDecoder('utf-8').decode(bytes);
|
|
2580
|
+
}
|
|
2744
2581
|
return '(no error message available)';
|
|
2745
2582
|
}
|
|
2746
|
-
const ptr = ex.
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
}
|
|
2583
|
+
const ptr = ex.wasm_last_error();
|
|
2584
|
+
if (ptr === 0) return '';
|
|
2585
|
+
const dv = new DataView(ex.memory.buffer);
|
|
2586
|
+
const len = dv.getUint32(ptr - 16, true);
|
|
2751
2587
|
const mem = new Uint8Array(ex.memory.buffer);
|
|
2752
|
-
const bytes = mem.
|
|
2588
|
+
const bytes = mem.slice(ptr, ptr + len);
|
|
2753
2589
|
return new TextDecoder('utf-8').decode(bytes);
|
|
2754
2590
|
}
|
|
2755
2591
|
|
|
@@ -2897,24 +2733,18 @@ export function getShaderGlsl(ctxHandle, programHandle, shaderType) {
|
|
|
2897
2733
|
mem.set(wasmBytes, wasmBytesPtr);
|
|
2898
2734
|
|
|
2899
2735
|
// Call the decompiler
|
|
2900
|
-
const
|
|
2736
|
+
const glslPtr = ex.wasm_decompile_to_glsl(wasmBytesPtr, wasmBytesLen);
|
|
2901
2737
|
|
|
2902
|
-
if (
|
|
2738
|
+
if (glslPtr === 0) {
|
|
2903
2739
|
return null;
|
|
2904
2740
|
}
|
|
2905
2741
|
|
|
2906
|
-
|
|
2907
|
-
const
|
|
2908
|
-
const glslLen = ex.wasm_get_decompiled_glsl_len();
|
|
2909
|
-
|
|
2910
|
-
if (glslPtr === 0 || glslLen === 0) {
|
|
2911
|
-
return null;
|
|
2912
|
-
}
|
|
2742
|
+
const dv = new DataView(ex.memory.buffer);
|
|
2743
|
+
const glslLen = dv.getUint32(glslPtr - 16, true);
|
|
2913
2744
|
|
|
2914
2745
|
// Read the GLSL string
|
|
2915
|
-
const glslBytes = new Uint8Array(ex.memory.buffer).
|
|
2916
|
-
|
|
2917
|
-
return decoder.decode(glslBytes);
|
|
2746
|
+
const glslBytes = new Uint8Array(ex.memory.buffer).slice(glslPtr, glslPtr + glslLen);
|
|
2747
|
+
return new TextDecoder('utf-8').decode(glslBytes);
|
|
2918
2748
|
} finally {
|
|
2919
2749
|
// Free the allocated memory
|
|
2920
2750
|
ex.wasm_free(wasmBytesPtr);
|
|
@@ -2953,24 +2783,18 @@ export function decompileWasmToGlsl(gl, wasmBytes) {
|
|
|
2953
2783
|
mem.set(wasmBytes, wasmBytesPtr);
|
|
2954
2784
|
|
|
2955
2785
|
// Call the decompiler
|
|
2956
|
-
const
|
|
2786
|
+
const glslPtr = ex.wasm_decompile_to_glsl(wasmBytesPtr, wasmBytesLen);
|
|
2957
2787
|
|
|
2958
|
-
if (
|
|
2788
|
+
if (glslPtr === 0) {
|
|
2959
2789
|
return null;
|
|
2960
2790
|
}
|
|
2961
2791
|
|
|
2962
|
-
|
|
2963
|
-
const
|
|
2964
|
-
const glslLen = ex.wasm_get_decompiled_glsl_len();
|
|
2965
|
-
|
|
2966
|
-
if (glslPtr === 0 || glslLen === 0) {
|
|
2967
|
-
return null;
|
|
2968
|
-
}
|
|
2792
|
+
const dv = new DataView(ex.memory.buffer);
|
|
2793
|
+
const glslLen = dv.getUint32(glslPtr - 16, true);
|
|
2969
2794
|
|
|
2970
2795
|
// Read the GLSL string
|
|
2971
|
-
const glslBytes = new Uint8Array(ex.memory.buffer).
|
|
2972
|
-
|
|
2973
|
-
return decoder.decode(glslBytes);
|
|
2796
|
+
const glslBytes = new Uint8Array(ex.memory.buffer).slice(glslPtr, glslPtr + glslLen);
|
|
2797
|
+
return new TextDecoder('utf-8').decode(glslBytes);
|
|
2974
2798
|
} finally {
|
|
2975
2799
|
// Free the allocated memory
|
|
2976
2800
|
ex.wasm_free(wasmBytesPtr);
|
package/webgl2.debug.wasm
CHANGED
|
Binary file
|
package/webgl2.wasm
CHANGED
|
Binary file
|